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); convertFromValueToBcd(&data[0], frequency);
data[4] = 0x1; data[4] = 0x1;
sendCommand(&data[0], sizeof(data)); 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(); FT817_NBS::Frequency getFrequency();
void setFrequency(unsigned long frequency); void setFrequency(unsigned long frequency);
void toggleAB(); void toggleAB();
void setMode(FT817_NBS::SignalMode);
}; };
#endif #endif

View File

@ -4,11 +4,13 @@
#define SET_FREQ 4 #define SET_FREQ 4
#define SWITCH_AB 5 #define SWITCH_AB 5
#define SWITCH_USB_CW 6
SoftwareSerial radio = SoftwareSerial(2, 3); SoftwareSerial radio = SoftwareSerial(2, 3);
FT817_NBS ft817(&radio); FT817_NBS ft817(&radio);
void setFreq(); void setFreq();
void switchUsbCw();
void setup() { void setup() {
// put your setup code here, to run once: // put your setup code here, to run once:
@ -16,10 +18,12 @@ void setup() {
Serial.begin(9600); Serial.begin(9600);
pinMode(SET_FREQ, INPUT_PULLUP); pinMode(SET_FREQ, INPUT_PULLUP);
pinMode(SWITCH_AB, INPUT_PULLUP); pinMode(SWITCH_AB, INPUT_PULLUP);
pinMode(SWITCH_USB_CW, INPUT_PULLUP);
} }
boolean pressBlockSetFreq = false; boolean pressBlockSetFreq = false;
boolean pressBlockSwitchAB = false; boolean pressBlockSwitchAB = false;
boolean pressBlockSwitchUsbCW = false;
void loop() { void loop() {
// put your main code here, to run repeatedly: // put your main code here, to run repeatedly:
@ -42,6 +46,16 @@ void loop() {
pressBlockSwitchAB = false; pressBlockSwitchAB = false;
delay(20); 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(){ void setFreq(){
@ -61,5 +75,29 @@ void setFreq(){
delay(300); 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(); ft817.toggleAB();
} }