From bbf883d3c5e84c4d69099fd1a818e617d6ec137c Mon Sep 17 00:00:00 2001 From: Rob French Date: Sat, 6 Jun 2020 00:07:50 -0500 Subject: [PATCH] Added support for a 16-char display to be received from the IOP, with a selectable timeout. Verified the basics of it working. Subsequently updated with better timeout code. This compiles, but has not been tested. --- ubitx_20/cat_libs.ino | 38 +++++++++++++++++++++++++------------ ubitx_20/ubitx_lcd_1602.ino | 21 +++++++++++++++++++- 2 files changed, 46 insertions(+), 13 deletions(-) diff --git a/ubitx_20/cat_libs.ino b/ubitx_20/cat_libs.ino index e59f31c..c5fd8af 100644 --- a/ubitx_20/cat_libs.ino +++ b/ubitx_20/cat_libs.ino @@ -73,8 +73,8 @@ void iopSendMode(char cw_mode, char is_usb, char digi_mode, char is_test) } unsigned int skipTimeCount = 0; -byte CAT_BUFF[5]; -byte CAT_SNDBUFF[5]; +byte CAT_BUFF[34]; +byte CAT_SNDBUFF[34]; void SendCatData(byte sendCount) { @@ -812,6 +812,7 @@ byte rxBufferCheckCount = 0; byte isProcessCheck_Cat = 0; char iopStatusWindow[4] = " "; // may need to move this if it's not visible to ubitx_lcd_1602 +char iopMenuDisplay[17] = " "; // KC4UPR - these are used to delay the display of the Smeter, if the // IOP status has recently been displayed, to give time to see it. @@ -819,6 +820,8 @@ char iopStatusWindow[4] = " "; // may need to move this if it's not visible t #define SMETER_DELAY_TIME 5000 bool displaySmeter = true; int delaySmeter; +int delayTopLine = 0; +int stateTopLine = 0; //fromType normal : 0, TX : 1, CW_STRAIGHT : 2, CW_PADDLE : 3, CW_AUTOMODE : 4 //if cw mode, no delay @@ -865,16 +868,13 @@ void Check_Cat(byte fromType) //Arived CAT DATA // KC4UPR - IOP update - 6 characters; first character determines mode (CAT or IOP) - for (i = 0; i < 6; i++) { //5; i++) - if (i == 0) { - byte first = Serial.read(); - readPrefix = byteToPrefix(first); - readLength = byteToLength(first); - } else { - CAT_BUFF[i-1] = Serial.read(); - } + // Will adjust based on readlength + byte first = Serial.read(); + readPrefix = byteToPrefix(first); + readLength = byteToLength(first); + for (int i = 0; i < readLength; i++) { + CAT_BUFF[i] = Serial.read(); } - // KC4UPR: I don't understand why this is here or how/when it will ever get called, but I will leave // it alone for now. @@ -884,7 +884,7 @@ void Check_Cat(byte fromType) isProcessCheck_Cat = 1; if (readPrefix == IOP_PREFIX) { - recvIOPMessage(msg, CAT_BUFF, 5); // not super robust... if IOP ever sends more (or less) than a 5 (6) byte message + recvIOPMessage(msg, CAT_BUFF, readLength); // not super robust... if IOP ever sends more (or less) than a 5 (6) byte message // following assumes it's a status message, 4 chars (including trailing null, which I'm ignoring... switch(msg.id) { case IOP_SSB_STATUS_MSG: @@ -901,6 +901,20 @@ void Check_Cat(byte fromType) case IOP_MODE_REQUEST: iopSendMode(cwMode, isUSB, digiMode, isTest); break; + + case IOP_MENU_DISPLAY_MSG: + for (int i = 0; i < 16; i++) { + iopMenuDisplay[i] = msg.data[i+1]; + } + if (int8_t(msg.data[0]) == 0) { + stateTopLine = 4; + } else if (int8_t(msg.data[0]) < 0) { + stateTopLine = 0; + } else { // > 0 + delayTopLine = millis() + (int8_t(msg.data[0]) * 1000); + stateTopLine = 2; + } + break; } } else if (readPrefix == CAT_PREFIX) { diff --git a/ubitx_20/ubitx_lcd_1602.ino b/ubitx_20/ubitx_lcd_1602.ino index 7d58293..2fc2da5 100644 --- a/ubitx_20/ubitx_lcd_1602.ino +++ b/ubitx_20/ubitx_lcd_1602.ino @@ -530,6 +530,25 @@ int freqScrollPosition = 0; void updateLine2Buffer(char displayType) { unsigned long tmpFreq = 0; + + if ((stateTopLine == 2) || (stateTopLine == 4)) { + strcpy(line2Buffer, iopMenuDisplay); + if (stateTopLine == 4) { + stateTopLine = 3; + } else { + stateTopLine = 1; + } + } + if (stateTopLine == 3) { + return; + } else if (stateTopLine == 1) { + if (delayTopLine < millis()) { + stateTopLine = 0; + } else { + return; + } + } + if (ritOn) { strcpy(line2Buffer, "RitTX:"); @@ -738,7 +757,7 @@ void idle_process() return; //if line2DisplayStatus == 0 <-- this condition is clear Line, you can display any message - if (line2DisplayStatus == 0 || (((displayOption1 & 0x04) == 0x04) && line2DisplayStatus == 2)) { + if (line2DisplayStatus == 0 || (((displayOption1 & 0x04) == 0x04) && line2DisplayStatus == 2) || stateTopLine > 0) { if (checkCount++ > 1) { updateLine2Buffer(0); //call by scheduler