Added Switch USB <--> CW... Defaults to USB.

Pin: 6
This commit is contained in:
Nicolas Bachschwell 2020-05-08 23:39:46 +02:00
parent e2eb1e499f
commit 558c67a456
Signed by: NBSgamesAT
GPG Key ID: B2F1E0D04F024688
3 changed files with 48 additions and 0 deletions

View File

@ -137,4 +137,13 @@ void FT817_NBS::setFrequency(unsigned long frequency){
convertFromValueToBcd(&data[0], frequency);
data[4] = 0x1;
sendCommand(&data[0], sizeof(data));
}
void FT817_NBS::setMode(FT817_NBS::SignalMode mode){
if(mode == SignalMode::UNKNOWN || mode == SignalMode::WFM){
return;
}
uint8_t value = (uint8_t) mode;
uint8_t data[5] = {value, 0x0, 0x0, 0x0, 0x7};
sendCommand(&data[0], sizeof(data));
}

View File

@ -30,5 +30,6 @@ public:
FT817_NBS::Frequency getFrequency();
void setFrequency(unsigned long frequency);
void toggleAB();
void setMode(FT817_NBS::SignalMode);
};
#endif

View File

@ -4,11 +4,13 @@
#define SET_FREQ 4
#define SWITCH_AB 5
#define SWITCH_USB_CW 6
SoftwareSerial radio = SoftwareSerial(2, 3);
FT817_NBS ft817(&radio);
void setFreq();
void switchUsbCw();
void setup() {
// put your setup code here, to run once:
@ -16,10 +18,12 @@ void setup() {
Serial.begin(9600);
pinMode(SET_FREQ, INPUT_PULLUP);
pinMode(SWITCH_AB, INPUT_PULLUP);
pinMode(SWITCH_USB_CW, INPUT_PULLUP);
}
boolean pressBlockSetFreq = false;
boolean pressBlockSwitchAB = false;
boolean pressBlockSwitchUsbCW = false;
void loop() {
// put your main code here, to run repeatedly:
@ -42,6 +46,16 @@ void loop() {
pressBlockSwitchAB = false;
delay(20);
}
if (digitalRead(SWITCH_USB_CW) == LOW && !pressBlockSwitchUsbCW){
switchUsbCw();
pressBlockSwitchUsbCW = true;
}
else if(digitalRead(SWITCH_USB_CW) != LOW){
pressBlockSwitchUsbCW = false;
delay(20);
}
}
void setFreq(){
@ -61,5 +75,29 @@ void setFreq(){
delay(300);
ft817.toggleAB();
}
void switchUsbCw(){
FT817_NBS::SignalMode mode = ft817.getFrequency().mode;
FT817_NBS::SignalMode newMode;
if (mode == FT817_NBS::SignalMode::USB){
newMode = FT817_NBS::SignalMode::CW;
}
else{
newMode = FT817_NBS::SignalMode::USB;
}
delay(300);
ft817.setMode(newMode);
delay(300);
ft817.toggleAB();
delay(300);
ft817.setMode(newMode);
delay(300);
ft817.toggleAB();
}