Added Switch USB <--> CW... Defaults to USB.
Pin: 6
This commit is contained in:
parent
e2eb1e499f
commit
558c67a456
@ -138,3 +138,12 @@ void FT817_NBS::setFrequency(unsigned long 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));
|
||||
}
|
@ -30,5 +30,6 @@ public:
|
||||
FT817_NBS::Frequency getFrequency();
|
||||
void setFrequency(unsigned long frequency);
|
||||
void toggleAB();
|
||||
void setMode(FT817_NBS::SignalMode);
|
||||
};
|
||||
#endif
|
38
src/main.cpp
38
src/main.cpp
@ -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(){
|
||||
@ -63,3 +77,27 @@ void setFreq(){
|
||||
|
||||
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();
|
||||
}
|
Loading…
Reference in New Issue
Block a user