Rearranged buttons, added INIT, USB Beacon, CW Beacon.
This commit is contained in:
parent
558c67a456
commit
5474a97f01
@ -146,4 +146,15 @@ void FT817_NBS::setMode(FT817_NBS::SignalMode mode){
|
||||
uint8_t value = (uint8_t) mode;
|
||||
uint8_t data[5] = {value, 0x0, 0x0, 0x0, 0x7};
|
||||
sendCommand(&data[0], sizeof(data));
|
||||
}
|
||||
|
||||
void FT817_NBS::setSplit(bool on){
|
||||
uint8_t data[5] = {0x0, 0x0, 0x0, 0x0};
|
||||
if(on){
|
||||
data[4] = 0x2;
|
||||
}
|
||||
else{
|
||||
data[4] = 0x82;
|
||||
}
|
||||
sendCommand(&data[0], sizeof(data));
|
||||
}
|
@ -31,5 +31,6 @@ public:
|
||||
void setFrequency(unsigned long frequency);
|
||||
void toggleAB();
|
||||
void setMode(FT817_NBS::SignalMode);
|
||||
void setSplit(bool on);
|
||||
};
|
||||
#endif
|
107
src/main.cpp
107
src/main.cpp
@ -4,13 +4,19 @@
|
||||
|
||||
#define SET_FREQ 4
|
||||
#define SWITCH_AB 5
|
||||
#define SWITCH_USB_CW 6
|
||||
#define SWITCH_USB_CW 7
|
||||
#define INIT 9
|
||||
#define LOWER_FREQ_BEACON 6
|
||||
#define HIGHER_FREQ_BEACON 8
|
||||
|
||||
SoftwareSerial radio = SoftwareSerial(2, 3);
|
||||
FT817_NBS ft817(&radio);
|
||||
|
||||
void setFreq();
|
||||
void switchUsbCw();
|
||||
void initRadio();
|
||||
bool setBeaconHigh();
|
||||
bool setBeaconLow();
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
@ -19,11 +25,19 @@ void setup() {
|
||||
pinMode(SET_FREQ, INPUT_PULLUP);
|
||||
pinMode(SWITCH_AB, INPUT_PULLUP);
|
||||
pinMode(SWITCH_USB_CW, INPUT_PULLUP);
|
||||
pinMode(INIT, INPUT_PULLUP);
|
||||
pinMode(HIGHER_FREQ_BEACON, INPUT_PULLUP);
|
||||
pinMode(LOWER_FREQ_BEACON, INPUT_PULLUP);
|
||||
}
|
||||
|
||||
boolean pressBlockSetFreq = false;
|
||||
boolean pressBlockSwitchAB = false;
|
||||
boolean pressBlockSwitchUsbCW = false;
|
||||
bool pressBlockSetFreq = false;
|
||||
bool pressBlockSwitchAB = false;
|
||||
bool pressBlockSwitchUsbCW = false;
|
||||
bool pressBlockInit = false;
|
||||
bool pressBlockLowerFreqBeacon = false;
|
||||
bool pressBlockHigherFreqBeacon = false;
|
||||
|
||||
unsigned long pressLengthInit = 0;
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
@ -56,6 +70,42 @@ void loop() {
|
||||
pressBlockSwitchUsbCW = false;
|
||||
delay(20);
|
||||
}
|
||||
|
||||
if(digitalRead(INIT) == LOW && !pressBlockInit){
|
||||
pressLengthInit = millis() + 1000;
|
||||
pressBlockInit = true;
|
||||
}
|
||||
else if(digitalRead(INIT) == LOW) {
|
||||
if(pressLengthInit != 0 && pressLengthInit <= millis()){
|
||||
pressLengthInit = 0;
|
||||
initRadio();
|
||||
}
|
||||
}
|
||||
else{
|
||||
pressLengthInit = 0;
|
||||
pressBlockInit = false;
|
||||
delay(20);
|
||||
}
|
||||
|
||||
if (digitalRead(HIGHER_FREQ_BEACON) == LOW && !pressBlockHigherFreqBeacon){
|
||||
setBeaconHigh();
|
||||
pressBlockHigherFreqBeacon = true;
|
||||
|
||||
}
|
||||
else if(digitalRead(HIGHER_FREQ_BEACON) != LOW){
|
||||
pressBlockHigherFreqBeacon = false;
|
||||
delay(20);
|
||||
}
|
||||
|
||||
if (digitalRead(LOWER_FREQ_BEACON) == LOW && !pressBlockLowerFreqBeacon){
|
||||
setBeaconLow();
|
||||
pressBlockLowerFreqBeacon = true;
|
||||
|
||||
}
|
||||
else if(digitalRead(LOWER_FREQ_BEACON) != LOW){
|
||||
pressBlockLowerFreqBeacon = false;
|
||||
delay(20);
|
||||
}
|
||||
}
|
||||
|
||||
void setFreq(){
|
||||
@ -100,4 +150,51 @@ void switchUsbCw(){
|
||||
|
||||
delay(300);
|
||||
ft817.toggleAB();
|
||||
}
|
||||
}
|
||||
|
||||
void initRadio(){
|
||||
ft817.setMode(FT817_NBS::SignalMode::USB);
|
||||
delay(300);
|
||||
ft817.setFrequency(14420000);
|
||||
delay(300);
|
||||
ft817.toggleAB();
|
||||
delay(300);
|
||||
ft817.setMode(FT817_NBS::SignalMode::USB);
|
||||
delay(300);
|
||||
ft817.setFrequency(43250000); //43274500, 43250000
|
||||
delay(300);
|
||||
ft817.setSplit(true);
|
||||
}
|
||||
|
||||
bool setBeacon(unsigned long frequency, FT817_NBS::SignalMode mode, bool firstVFO){
|
||||
unsigned long result = ft817.getFrequency().frequency;
|
||||
if(result >= 43000000 && result <= 44000000){
|
||||
delay(300);
|
||||
ft817.setMode(mode);
|
||||
delay(300);
|
||||
ft817.setFrequency(frequency);
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
delay(300);
|
||||
ft817.toggleAB();
|
||||
if(firstVFO){
|
||||
delay(300);
|
||||
return setBeacon(frequency, mode, false);
|
||||
}
|
||||
else{
|
||||
Serial.println("Could not set beacon. Please initialise the radio first.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool setBeaconHigh(){
|
||||
return setBeacon(43274500, FT817_NBS::SignalMode::USB, true);
|
||||
}
|
||||
|
||||
bool setBeaconLow(){
|
||||
return setBeacon(43250000, FT817_NBS::SignalMode::CW, true);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user