diff --git a/code/src/PhoenixSketch/Globals.cpp b/code/src/PhoenixSketch/Globals.cpp index 8a81a23..34269cb 100644 --- a/code/src/PhoenixSketch/Globals.cpp +++ b/code/src/PhoenixSketch/Globals.cpp @@ -15,9 +15,6 @@ float32_t audioYPixel[SPECTRUM_RES/4]; VolumeFunction volumeFunction = AudioVolume; -//#define BROADCAST_BAND 0 -#define HAM_BAND 1 -//#define MISC_BAND 2 struct band bands[NUMBER_OF_BANDS] = { //freqVFO1 freqVFO2 band low band hi name mode Hi Low Gain_dB type AGC @@ -49,6 +46,7 @@ struct band bands[NUMBER_OF_BANDS] = //435000000, 420000000, 450000000, "70CM", USB, 3000, 200, 0, HAM_BAND, 20, // 70CM //915000000, 902000000, 928000000, "33CM", USB, 3000, 200, 0, HAM_BAND, 20, // 33CM //1270000000, 1240000000, 1300000000, "23CM", USB, 3000, 200, 0, HAM_BAND, 20, // 23CM + 200000, 200000, 80800000, "GEN", USB, 3000, 200, 0, MISC_BAND, 20, // General coverage }; struct BIT bit_results = { diff --git a/code/src/PhoenixSketch/LPFBoard.cpp b/code/src/PhoenixSketch/LPFBoard.cpp index 7a48cd7..e7d1d57 100644 --- a/code/src/PhoenixSketch/LPFBoard.cpp +++ b/code/src/PhoenixSketch/LPFBoard.cpp @@ -456,6 +456,7 @@ void SelectLPFBand(int32_t band){ band = LAST_BAND + 10; // force it to pick no filter. You're on your own now } } + SET_LPF_BAND(BandToBCD(band)); // And now actually change the hardware... UpdateMCPRegisters(); diff --git a/code/src/PhoenixSketch/Mode.cpp b/code/src/PhoenixSketch/Mode.cpp index 84ea9e1..41869c3 100644 --- a/code/src/PhoenixSketch/Mode.cpp +++ b/code/src/PhoenixSketch/Mode.cpp @@ -1,6 +1,7 @@ #include "SDT.h" // This file contains the entry and exit functions called upon changing states +// as well as functions used in guards void UpdateHardwareState(void){ UpdateRFHardwareState(); @@ -16,4 +17,8 @@ void ModeCWTransmitSpaceEnter(void){ SetInterrupt(iKEY2_PRESSED); } UpdateHardwareState(); -} \ No newline at end of file +} + +bool IsTxAllowed(void) { + return bands[ED.currentBand[ED.activeVFO]].band_type == HAM_BAND; +} diff --git a/code/src/PhoenixSketch/Mode.h b/code/src/PhoenixSketch/Mode.h index 4228fcd..b9c9fae 100644 --- a/code/src/PhoenixSketch/Mode.h +++ b/code/src/PhoenixSketch/Mode.h @@ -16,4 +16,10 @@ void UpdateHardwareState(void); */ void ModeCWTransmitSpaceEnter(void); +/** + * @brief Checks if transmit is allowed for the current band + * @note Used as guard for transitions to transmit states + */ +bool IsTxAllowed(void); + #endif // MODE_H diff --git a/code/src/PhoenixSketch/ModeSm.cpp b/code/src/PhoenixSketch/ModeSm.cpp index af29335..2e31768 100644 --- a/code/src/PhoenixSketch/ModeSm.cpp +++ b/code/src/PhoenixSketch/ModeSm.cpp @@ -1,4 +1,4 @@ -// Autogenerated with StateSmith 0.19.0+b5719011215d41a81572ed347c02b22db5d1a48f. +// Autogenerated with StateSmith 0.20.0+43839dcc75301cd62cac3f27a49bbde57af7ebda. // Algorithm: Balanced2. See https://github.com/StateSmith/StateSmith/wiki/Algorithms // This file is autogenerated! Do not edit it directly. Instead, edit the companion .drawio @@ -1205,7 +1205,8 @@ static void CW_RECEIVE_exit(ModeSm* sm) static void CW_RECEIVE_dah_pressed(ModeSm* sm) { // CW_RECEIVE behavior - // uml: DAH_PRESSED TransitionTo(CW_TRANSMIT_DAH_MARK) + // uml: DAH_PRESSED [IsTxAllowed()] TransitionTo(CW_TRANSMIT_DAH_MARK) + if (IsTxAllowed()) { // Step 1: Exit states until we reach `NORMAL_STATES` state (Least Common Ancestor for transition). CW_RECEIVE_exit(sm); @@ -1225,7 +1226,8 @@ static void CW_RECEIVE_dah_pressed(ModeSm* sm) static void CW_RECEIVE_dit_pressed(ModeSm* sm) { // CW_RECEIVE behavior - // uml: DIT_PRESSED TransitionTo(CW_TRANSMIT_DIT_MARK) + // uml: DIT_PRESSED [IsTxAllowed()] TransitionTo(CW_TRANSMIT_DIT_MARK) + if (IsTxAllowed()) { // Step 1: Exit states until we reach `NORMAL_STATES` state (Least Common Ancestor for transition). CW_RECEIVE_exit(sm); @@ -1257,7 +1259,8 @@ static void CW_RECEIVE_do(ModeSm* sm) static void CW_RECEIVE_key_pressed(ModeSm* sm) { // CW_RECEIVE behavior - // uml: KEY_PRESSED TransitionTo(CW_TRANSMIT_MARK) + // uml: KEY_PRESSED [IsTxAllowed()] TransitionTo(CW_TRANSMIT_MARK) + if (IsTxAllowed()) { // Step 1: Exit states until we reach `NORMAL_STATES` state (Least Common Ancestor for transition). CW_RECEIVE_exit(sm); @@ -1703,7 +1706,8 @@ static void SSB_RECEIVE_exit(ModeSm* sm) static void SSB_RECEIVE_ptt_pressed(ModeSm* sm) { // SSB_RECEIVE behavior - // uml: PTT_PRESSED TransitionTo(SSB_TRANSMIT) + // uml: PTT_PRESSED [IsTxAllowed()] TransitionTo(SSB_TRANSMIT) + if (IsTxAllowed()) { // Step 1: Exit states until we reach `NORMAL_STATES` state (Least Common Ancestor for transition). SSB_RECEIVE_exit(sm); diff --git a/code/src/PhoenixSketch/ModeSm.drawio b/code/src/PhoenixSketch/ModeSm.drawio index ff8941e..17fbcf7 100644 --- a/code/src/PhoenixSketch/ModeSm.drawio +++ b/code/src/PhoenixSketch/ModeSm.drawio @@ -1,133 +1,133 @@ - + - + - - + + - - + + - - - + + + - - + + - - + + - - + + + - - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - - + + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - + - + - - + + - - + + - + - + - + - + - + @@ -135,12 +135,12 @@ - - + + - + @@ -148,202 +148,210 @@ - - + + - + - - - + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - + + + - - + + - - + + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - + + + - - + + + - - - + + - - + + - - + + - - + + - - + + - - - + + + - - + + - - + + - - - + + + - - + + - - + + - - + + - - + + - - + + + + + + - - + + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -351,41 +359,41 @@ - - + + - - + + - - + + - - + + - - + + - + - - + + - - + + - - + + diff --git a/code/src/PhoenixSketch/ModeSm.h b/code/src/PhoenixSketch/ModeSm.h index 31a8c93..8575186 100644 --- a/code/src/PhoenixSketch/ModeSm.h +++ b/code/src/PhoenixSketch/ModeSm.h @@ -1,4 +1,4 @@ -// Autogenerated with StateSmith 0.19.0+b5719011215d41a81572ed347c02b22db5d1a48f. +// Autogenerated with StateSmith 0.20.0+43839dcc75301cd62cac3f27a49bbde57af7ebda. // Algorithm: Balanced2. See https://github.com/StateSmith/StateSmith/wiki/Algorithms // This file is autogenerated! Do not edit it directly. Instead, edit the companion .drawio diff --git a/code/src/PhoenixSketch/ModeSm.sim.html b/code/src/PhoenixSketch/ModeSm.sim.html index 6f211ec..5ae04dc 100644 --- a/code/src/PhoenixSketch/ModeSm.sim.html +++ b/code/src/PhoenixSketch/ModeSm.sim.html @@ -435,15 +435,15 @@ SSB_RECEIVE --> CW_RECEIVE : TO_CW_MODE -SSB_RECEIVE --> SSB_TRANSMIT : PTT_PRESSED +SSB_RECEIVE --> SSB_TRANSMIT : PTT_PRESSED [IsTxAllowed()] CW_RECEIVE --> SSB_RECEIVE : TO_SSB_MODE -CW_RECEIVE --> CW_TRANSMIT_MARK : KEY_PRESSED +CW_RECEIVE --> CW_TRANSMIT_MARK : KEY_PRESSED [IsTxAllowed()] -CW_RECEIVE --> CW_TRANSMIT_DAH_MARK : DAH_PRESSED +CW_RECEIVE --> CW_TRANSMIT_DAH_MARK : DAH_PRESSED [IsTxAllowed()] -CW_RECEIVE --> CW_TRANSMIT_DIT_MARK : DIT_PRESSED +CW_RECEIVE --> CW_TRANSMIT_DIT_MARK : DIT_PRESSED [IsTxAllowed()] SSB_TRANSMIT --> SSB_RECEIVE : PTT_RELEASED @@ -507,7 +507,7 @@