From 681e01d019e7779fd046ff133b730bc20cdcd5c0 Mon Sep 17 00:00:00 2001 From: Rob French Date: Sat, 16 May 2020 23:51:46 -0500 Subject: [PATCH] Updates to be compatible with iopcomm.h/iopcomm.cpp, and with the new two-tone test mode. --- ubitx_20/cat_libs.ino | 100 ++++++++++++++++-------------------- ubitx_20/ubitx_20.ino | 3 +- ubitx_20/ubitx_lcd_1602.ino | 5 ++ ubitx_20/ubitx_menu.ino | 45 ++++++++++------ 4 files changed, 81 insertions(+), 72 deletions(-) diff --git a/ubitx_20/cat_libs.ino b/ubitx_20/cat_libs.ino index 354f5e0..eb39c43 100644 --- a/ubitx_20/cat_libs.ino +++ b/ubitx_20/cat_libs.ino @@ -32,6 +32,8 @@ **************************************************************************/ +#include + #include "ubitx.h" //for broken protocol @@ -48,55 +50,25 @@ #define CAT_MODE_FMN 0x88 #define ACK 0 -// KC4UPR--uBITX IOP: prefixes to determine "mode" of serial transmission -#define CAT_PREFIX 0xC0 -#define IOP_PREFIX 0xD0 -#define EEPROM_READ_PREFIX 0xE0 -#define EEPROM_WRITE_PREFIX 0xF0 - -#define IOP_MODE_COMMAND 0x00 -#define IOP_START_TX_COMMAND 0x01 -#define IOP_STOP_TX_COMMAND 0x02 -#define IOP_MODE_SSB 0x00 -#define IOP_MODE_DIGI 0x01 -#define IOP_MODE_CW 0x02 /* * KC4UPR - IOP update, 2020-05-03 * * Send the current mode to the I/O Processor. - * - * NOTE: Not yet called from CAT, only from menu... */ -void iopSendMode(char cw_mode, char is_usb, char digi_mode) +void iopSendMode(char cw_mode, char is_usb, char digi_mode, char is_test) { byte mode; - Serial.write(IOP_PREFIX | 2); - Serial.write(IOP_MODE_COMMAND); if (cw_mode > 0) - mode = IOP_MODE_CW; + mode = MODE_CW; else if (digi_mode > 0) - mode = IOP_MODE_DIGI; + mode = MODE_DIGI; + else if (is_test) + mode = MODE_TEST; else - mode = IOP_MODE_SSB; - Serial.write(mode); -} - -// Used to tell the IOP that we're transmitting, when it came via -// CAT (otherwise, IOP is the one who tells Raduino to start TX!). -void iopStartTx() -{ - Serial.write(IOP_PREFIX | 1); - Serial.write(IOP_START_TX_COMMAND); -} - -// Used to tell the IOP to stop transmitting, when it came via -// CAT (otherwise, IOP is the one who tells Raduino to stop TX!). -void iopStopTx() -{ - Serial.write(IOP_PREFIX | 1); - Serial.write(IOP_STOP_TX_COMMAND); + mode = MODE_SSB; + sendIOPModeCommand(mode); } unsigned int skipTimeCount = 0; @@ -111,7 +83,7 @@ void SendCatData(byte sendCount) // // NOTE: Need to do some error checking at some point to ensure we don't // try to send more than 15 bytes!!! - Serial.write(CAT_PREFIX | sendCount); + Serial.write(prefixAndLengthToByte(CAT_PREFIX, sendCount)); for (byte i = 0; i < sendCount; i++) Serial.write(CAT_BUFF[i]); @@ -236,7 +208,7 @@ void CatSetPTT(boolean isPTTOn, byte fromType) txCAT = true; // KC4UPR - added the next line to tell the IOP we're transmitting - iopStartTx(); + sendIOPStartTxCommand(); startTx(TX_SSB, 1); //Exit menu, Memory Keyer... ETC @@ -252,7 +224,7 @@ void CatSetPTT(boolean isPTTOn, byte fromType) if (inTx) { // KC4UPR - added the next line to tell the IOP we're not transmitting - iopStopTx(); + sendIOPStopTxCommand(); stopTx(); txCAT = false; @@ -281,21 +253,33 @@ void CatSetMode(byte tmpMode, byte fromType) if (!inTx) { - if (tmpMode == CAT_MODE_CW) - { - cwMode = 1; - } - else if (tmpMode == CAT_MODE_USB) - { - cwMode = 0; - isUSB = true; - } - else - { - cwMode = 0; - isUSB = false; - } + switch(tmpMode) { + case CAT_MODE_CW: + cwMode = 2; // should be CWU + break; + case CAT_MODE_CWR: + cwMode = 1; // should be CWL + break; + + case CAT_MODE_USB: + cwMode = 0; + digiMode = 0; + isUSB = true; + break; + + case CAT_MODE_LSB: + cwMode = 0; + digiMode = 0; + isUSB = false; + break; + + case CAT_MODE_DIG: + cwMode = 0; + digiMode = 1; + isUSB = true; // DGU - but need to eventually use the FT-817 customization + } + iopSendMode(cwMode, isUSB, digiMode, isTest); setFrequency(frequency); updateDisplay(); } @@ -318,7 +302,7 @@ void ReadEEPRom() //for remove warnings. // KC4UPR--uBITX IOP: Adding an additional byte at the beginning that // indicates that this is a "Memory Manager mode" transmission. // Then we repeat some of the CAT_BUFF data. - Serial.write(EEPROM_READ_PREFIX); + Serial.write(prefixAndLengthToByte(RAD_EEPROM_READ_PREFIX, 5)); Serial.write(CAT_BUFF[0]); Serial.write(CAT_BUFF[1]); Serial.write(CAT_BUFF[2]); @@ -371,7 +355,7 @@ void WriteEEPRom(void) //for remove warning // indicates that this is a "Memory Manager mode" transmission. // // Also indicates that we are going to be sending two bytes of data. - Serial.write(EEPROM_WRITE_PREFIX | 2); + Serial.write(prefixAndLengthToByte(RAD_EEPROM_WRITE_PREFIX, 2)); //Check Checksum if (CAT_BUFF[3] != ((CAT_BUFF[0] + CAT_BUFF[1] + CAT_BUFF[2]) % 256)) @@ -969,4 +953,8 @@ void Init_Cat(long baud, int portConfig) { Serial.begin(baud, portConfig); Serial.flush(); + + // At start, immediately send mode to IOP. Currently, IOP has no way to + // request the mode. + iopSendMode(cwMode, isUSB, digiMode, isTest); } diff --git a/ubitx_20/ubitx_20.ino b/ubitx_20/ubitx_20.ino index 4fb2bcd..fc9cfee 100644 --- a/ubitx_20/ubitx_20.ino +++ b/ubitx_20/ubitx_20.ino @@ -1,4 +1,4 @@ - //Firmware Version +//Firmware Version //+ : This symbol identifies the firmware. // It was originally called 'CEC V1.072' but it is too long to waste the LCD window. // I do not want to make this Firmware users's uBITX messy with my callsign. @@ -193,6 +193,7 @@ char splitOn = 0; //working split, uses VFO B as the transmit freque char keyDown = 0; //in cw mode, denotes the carrier is being transmitted char isUSB = 0; //upper sideband was selected, this is reset to the default for the +char isTest = 0; // two-tone test mode char cwMode = 0; //compatible original source, and extend mode //if cwMode == 0, mode check : isUSB, cwMode > 0, mode Check : cwMode //iscwMode = 0 : ssbmode, 1 :cwl, 2 : cwu, 3 : cwn (none tx) char digiMode = 0; // 0: normal uBITX behavior (transmit LSB/USB when PTT is depressed) diff --git a/ubitx_20/ubitx_lcd_1602.ino b/ubitx_20/ubitx_lcd_1602.ino index 1f669ad..f4fb70a 100644 --- a/ubitx_20/ubitx_lcd_1602.ino +++ b/ubitx_20/ubitx_lcd_1602.ino @@ -443,6 +443,11 @@ void updateDisplay() { strcpy(c, "DGU "); else strcpy(c, "DGL "); + } else if (isTest == 1) { + if (isUSB) + strcpy(c, "TTU "); + else + strcpy(c, "TTL "); } else { if (isUSB) strcpy(c, "USB "); diff --git a/ubitx_20/ubitx_menu.ino b/ubitx_20/ubitx_menu.ino index dd5a4cb..d177b61 100644 --- a/ubitx_20/ubitx_menu.ino +++ b/ubitx_20/ubitx_menu.ino @@ -149,6 +149,7 @@ byte modeToByte(){ //autoSetModebyFreq : 0 //autoSetModebyFreq : 1, if (modValue is not set, set mode by frequency) void byteToMode(byte modeValue, byte autoSetModebyFreq){ + isTest = false; // test never settable from EEPROM isUSB = false; cwMode = 0; digiMode = 0; @@ -181,6 +182,15 @@ void byteToMode(byte modeValue, byte autoSetModebyFreq){ isUSB = true; digiMode = 1; break; +/* + case 8: // TTL + isUSB = false; + break; + + case 9: // TTU + isUSB = true; + break; +*/ } } /* if (modeValue == 4) { @@ -973,7 +983,7 @@ void menuSelectMode(int btn){ } else { - //LSB, USB, CWL, CWU, DGL, DGU + //LSB, USB, CWL, CWU, DGL, DGU, TTL, TTU if (cwMode == 0) { if (isUSB == 0) { selectModeType = 0; // LSB @@ -983,6 +993,10 @@ void menuSelectMode(int btn){ // modify if digital mode is set if (digiMode > 0) { selectModeType += (3 + digiMode); + + // modify if two-tone test mode is set + } else if (isTest > 0) { + selectModeType += 5; } } else if (cwMode == 1) { selectModeType = 2; // CWL @@ -999,29 +1013,30 @@ void menuSelectMode(int btn){ selectModeType = 3;*/ beforeMode = selectModeType; - selectModeType = getValueByKnob(11, selectModeType, 0, 5, 1, " LSB USB CWL CWU DGL DGU ", 4); //3 : Select Mode, targetValue, minKnobValue, maxKnobValue, stepSize + selectModeType = getValueByKnob(11, selectModeType, 0, 7, 1, " LSB USB CWL CWU DGL DGU TTL TTU", 4); //3 : Select Mode, targetValue, minKnobValue, maxKnobValue, stepSize if (beforeMode != selectModeType) { //printLineF1(F("Changed Mode")); if (selectModeType == 0) { - cwMode = 0; isUSB = 0; digiMode = 0; - } - else if (selectModeType == 1) { - cwMode = 0; isUSB = 1; digiMode = 0; - } - else if (selectModeType == 2) { - cwMode = 1; digiMode = 0; - } - else if (selectModeType == 3) { - cwMode = 2; digiMode = 0; + cwMode = 0; isUSB = 0; digiMode = 0; isTest = 0; + } else if (selectModeType == 1) { + cwMode = 0; isUSB = 1; digiMode = 0; isTest = 0; + } else if (selectModeType == 2) { + cwMode = 1; digiMode = 0; isTest = 0; + } else if (selectModeType == 3) { + cwMode = 2; digiMode = 0; isTest = 0; } else if (selectModeType == 4) { - cwMode = 0; isUSB = 0; digiMode = 1; + cwMode = 0; isUSB = 0; digiMode = 1; isTest = 0; } else if (selectModeType == 5) { - cwMode = 0; isUSB = 1; digiMode = 1; + cwMode = 0; isUSB = 1; digiMode = 1; isTest = 0; + } else if (selectModeType == 6) { + cwMode = 0; isUSB = 0; digiMode = 0; isTest = 1; + } else if (selectModeType == 7) { + cwMode = 0; isUSB = 1; digiMode = 0; isTest = 1; } // KC4UPR: sending mode to IOP - iopSendMode(cwMode, isUSB, digiMode); + iopSendMode(cwMode, isUSB, digiMode, isTest); FrequencyToVFO(1); }