From cf1afa5ccfcf7bafadb1897131492f8a86ae93a8 Mon Sep 17 00:00:00 2001 From: Michael <77412328+dj2mg@users.noreply.github.com> Date: Sat, 21 Feb 2026 19:35:32 +0100 Subject: [PATCH 1/7] Added missing overload for print used in tests/simulator --- code/test/RA8875.h | 1 + code/test/RA8875_SDL.cpp | 6 ++++++ code/test/RA8875_mock.cpp | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/code/test/RA8875.h b/code/test/RA8875.h index c9379a5..6b6c9f5 100644 --- a/code/test/RA8875.h +++ b/code/test/RA8875.h @@ -71,6 +71,7 @@ class RA8875 { void print(int value); void print(int64_t value); void print(float value); + void print(float value, int digits); uint8_t getFontWidth(); uint8_t getFontHeight(); diff --git a/code/test/RA8875_SDL.cpp b/code/test/RA8875_SDL.cpp index 419eb61..060ff57 100644 --- a/code/test/RA8875_SDL.cpp +++ b/code/test/RA8875_SDL.cpp @@ -1062,6 +1062,12 @@ void RA8875::print(float value) { print(buf); } +void RA8875::print(float value, int digits) { + char buf[32]; + snprintf(buf, sizeof(buf), "%.1f", value); + print(buf); +} + void RA8875::setFontDefault() { _font_scale = 1; _custom_font = nullptr; diff --git a/code/test/RA8875_mock.cpp b/code/test/RA8875_mock.cpp index bbcc3d5..1d29f07 100644 --- a/code/test/RA8875_mock.cpp +++ b/code/test/RA8875_mock.cpp @@ -84,6 +84,10 @@ void RA8875::print(float value) { // Mock implementation - could log the value if needed for testing } +void RA8875::print(float value, int digits) { + // Mock implementation - could log the value if needed for testing +} + void RA8875::setFontDefault() { // Mock implementation - reset to default font _font_scale = 1; From 1ac152091d0a27fad9c01d7ee89627cf55d22dfc Mon Sep 17 00:00:00 2001 From: Michael <77412328+dj2mg@users.noreply.github.com> Date: Sat, 14 Mar 2026 16:51:57 +0100 Subject: [PATCH 2/7] Changed band type to enum --- code/src/PhoenixSketch/Globals.cpp | 3 --- code/src/PhoenixSketch/SDT.h | 8 +++++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/code/src/PhoenixSketch/Globals.cpp b/code/src/PhoenixSketch/Globals.cpp index 8a81a23..eb1fb04 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 diff --git a/code/src/PhoenixSketch/SDT.h b/code/src/PhoenixSketch/SDT.h index b7b7930..7b6eca0 100644 --- a/code/src/PhoenixSketch/SDT.h +++ b/code/src/PhoenixSketch/SDT.h @@ -320,6 +320,12 @@ struct BIT { uint8_t AD7991_I2C_ADDR; }; +enum BandType { + BROADCAST_BAND, + HAM_BAND, + MISC_BAND +}; + /** Contains the parameters that define a band */ struct band { int64_t freqVFO1_Hz; /** Frequency of VFO1 in Hz (hardware mixer) */ @@ -330,7 +336,7 @@ struct band { int32_t FHiCut_Hz; /** Audio bandpass filter edge */ int32_t FLoCut_Hz; /** Audio bandpass filter edge */ float32_t RFgain_dB; /** Gain applied in the DSP receive chain */ - uint8_t band_type; /** UNUSED */ + BandType band_type; /** type of band */ int32_t AGC_thresh; /** AGC threshold value used by DSP receive code */ }; From 6e53c6f290f27e62de21eb41cbdccba4879526e2 Mon Sep 17 00:00:00 2001 From: Michael <77412328+dj2mg@users.noreply.github.com> Date: Fri, 20 Mar 2026 20:27:54 +0100 Subject: [PATCH 3/7] Disabled transmit for non-ham bands --- code/src/PhoenixSketch/Mode.cpp | 7 +- code/src/PhoenixSketch/Mode.h | 6 + code/src/PhoenixSketch/ModeSm.cpp | 14 +- code/src/PhoenixSketch/ModeSm.drawio | 376 +++++++++++++------------ code/src/PhoenixSketch/ModeSm.h | 2 +- code/src/PhoenixSketch/ModeSm.sim.html | 22 +- code/test/ModeSm_test.cpp | 61 +++- 7 files changed, 283 insertions(+), 205 deletions(-) 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 @@