From 2e115e363b2225775353a715f349e758ca01c27b Mon Sep 17 00:00:00 2001 From: Rob French Date: Sun, 7 Jun 2020 15:27:27 -0500 Subject: [PATCH] Fixes associated with the Raduino display issues. --- iopcomm/iopcomm.cpp | 40 +++++++++++++++++++++++++++++++++------- iopcomm/iopcomm.h | 13 +++++++++---- ubitx_iop/cat.ino | 9 +++++++++ ubitx_iop/menu.h | 20 ++++++++++++++++---- 4 files changed, 67 insertions(+), 15 deletions(-) diff --git a/iopcomm/iopcomm.cpp b/iopcomm/iopcomm.cpp index 98ab316..2b699cd 100644 --- a/iopcomm/iopcomm.cpp +++ b/iopcomm/iopcomm.cpp @@ -87,6 +87,20 @@ void sendIOPModeRequest() sendIOPMessage(m); } +//====================================================================== + +void sendIOPDebugMessage(const char* text) +{ + IOPMessage m; + m.id = IOP_DEBUG_MSG; + m.len = strlen(text); + if (m.len > IOP_MESSAGE_MAX_LEN) { + m.len = IOP_MESSAGE_MAX_LEN; + } + strncpy(m.data, text, m.len); + sendIOPMessage(m); +}; + //====================================================================== // SSB STATUS MESSAGE //====================================================================== @@ -152,24 +166,36 @@ void sendIOPTestStatus() } //====================================================================== -// TEST STATUS MESSAGE +// MENU DISPLAY MESSAGE //====================================================================== -void sendIOPMenuDisplay(const char* text, int8_t secs) +void sendIOPMenuDisplay(const char* text) { IOPMessage m; int l = strlen(text); m.id = IOP_MENU_DISPLAY_MSG; - m.len = 17; - m.data[0] = uint8_t(secs); + m.len = 16; for (int i = 0; i < 16; i++) { if (i < l) { - m.data[i+1] = text[i]; + m.data[i] = text[i]; } else { - m.data[i+1] = ' '; + m.data[i] = ' '; } } - m.data[17] = '\0'; + m.data[16] = '\0'; + sendIOPMessage(m); + Serial.println((char *)m.data); +} + +//====================================================================== +// MENU INACTIVE MESSAGE +//====================================================================== + +void sendIOPMenuInactive() +{ + IOPMessage m; + m.id = IOP_MENU_INACTIVE_MSG; + m.len = 4; // NOTE: LEN = 4 for padding only... temporary sendIOPMessage(m); } diff --git a/iopcomm/iopcomm.h b/iopcomm/iopcomm.h index d57d811..5348812 100644 --- a/iopcomm/iopcomm.h +++ b/iopcomm/iopcomm.h @@ -67,6 +67,7 @@ enum MessageID { IOP_START_TX_COMMAND, IOP_STOP_TX_COMMAND, IOP_CW_CONFIG_MSG, + IOP_DEBUG_MSG, // Requests IOP_MODE_REQUEST, @@ -75,6 +76,7 @@ enum MessageID { IOP_CW_STATUS_MSG, IOP_TEST_STATUS_MSG, IOP_MENU_DISPLAY_MSG, + IOP_MENU_INACTIVE_MSG, // add any new elements here NUM_MESSAGE_IDS @@ -136,9 +138,10 @@ const uint8_t NO_FLAGS = 0; const uint8_t REVERSED = 1; struct IOPMessage { - uint8_t id; - uint8_t len; - uint8_t data[IOP_MESSAGE_MAX_LEN]; + IOPMessage() { memset(data, 0, IOP_MESSAGE_MAX_LEN); } + uint8_t id; + uint8_t len; + uint8_t data[IOP_MESSAGE_MAX_LEN]; }; //====================================================================== @@ -215,13 +218,15 @@ void recvIOPMessage(IOPMessage&, const uint8_t*, int); void sendIOPModeCommand(RigMode); void sendIOPStartTxCommand(); void sendIOPStopTxCommand(); +void sendIOPDebugMessage(const char*); void sendIOPModeRequest(); void sendIOPSSBStatus(SSBConfig const&); void sendIOPDGTStatus(DGTConfig const&); void sendIOPCWStatus(CWConfig const&); void sendIOPTestStatus(); -void sendIOPMenuDisplay(const char*, int8_t); +void sendIOPMenuDisplay(const char*); +void sendIOPMenuInactive(); //====================================================================== // TRANSLATOR diff --git a/ubitx_iop/cat.ino b/ubitx_iop/cat.ino index 5778eb9..70d54ac 100644 --- a/ubitx_iop/cat.ino +++ b/ubitx_iop/cat.ino @@ -84,6 +84,10 @@ void processIOPCommand(IOPMessage const& m) case RIG_MODE_TTU: USBDEBUG("new mode - TTU"); break; + default: + char errormessage[32]; + sprintf(errormessage, "unknown mode command - %3d", rig.modeNum()); + USBDEBUG("mode command not recognized"); } #endif } @@ -99,6 +103,11 @@ void processIOPCommand(IOPMessage const& m) case IOP_CW_CONFIG_MSG: break; + + case IOP_DEBUG_MSG: + USBDEBUG("IOP_DEBUG_MSG"); + USBDEBUG((const char*)m.data); + break; } } diff --git a/ubitx_iop/menu.h b/ubitx_iop/menu.h index ed686c5..4183c53 100644 --- a/ubitx_iop/menu.h +++ b/ubitx_iop/menu.h @@ -11,6 +11,8 @@ #define MAX_TEXT_LEN 16 #define MENU_SELECTED_CHAR '>' +const char blankLine[17] = " "; + class MenuItem { public: virtual ~MenuItem() {} @@ -37,7 +39,7 @@ const char* const filterID[NUM_RIG_MODES][NUM_RX_FILTERS] = { class TopMenu : public MenuItem { public: - TopMenu(Rig& rig): _rig(rig), _visible(false), _adjust_tx(false) { + TopMenu(Rig& rig): _rig(rig), _dirty(false), _visible(false), _adjust_tx(false) { strcpy(_text0, "R: T: "); strcpy(_text1, "0123456789ABCDEF"); } @@ -52,12 +54,16 @@ class TopMenu : public MenuItem { _adjust_tx ? ' ' : MENU_SELECTED_CHAR, filterID[_rig.modeNum()][_rig.filterNum()], _adjust_tx ? MENU_SELECTED_CHAR : ' '); - if (strcmp(_text0, _text1) != 0) { + if ((strcmp(_text0, _text1) != 0) || _dirty) { if (_visible) { - sendIOPMenuDisplay(_text0, 0); + sendIOPMenuDisplay(_text0); + USBDEBUG("updating menu:"); + USBDEBUG(_text0); } else { - sendIOPMenuDisplay(_text0, -1); + sendIOPMenuInactive(); + USBDEBUG("deactivating menu"); } + _dirty = false; strncpy(_text1, _text0, MAX_TEXT_LEN); } } @@ -68,12 +74,14 @@ class TopMenu : public MenuItem { } else { _adjust_tx = !_adjust_tx; } + _dirty = true; return this; } virtual MenuItem* altSelect() { if (_visible) { _visible = false; + _dirty = true; } return this; } @@ -81,6 +89,7 @@ class TopMenu : public MenuItem { virtual MenuItem* exit() { if (_visible) { _visible = false; + _dirty = true; } return this; } @@ -91,6 +100,7 @@ class TopMenu : public MenuItem { } else { _rig.switchRxFilter(true); } + _dirty = true; } return this; } @@ -101,12 +111,14 @@ class TopMenu : public MenuItem { } else { _rig.switchRxFilter(); } + _dirty = true; } return this; } private: Rig& _rig; + bool _dirty; bool _visible; bool _adjust_tx; char _text0[MAX_TEXT_LEN+1];