From c8b2110052c00d79d4ec8f18fdd90ba82794c950 Mon Sep 17 00:00:00 2001 From: Rob French Date: Fri, 8 May 2020 00:16:59 -0500 Subject: [PATCH] Successful communication between Raduino and IOP. Digi modes working. Have a high-pitched whine in RX audio, however (IOP problem, not Raduino). --- ubitx_20/cat_libs.ino | 44 +++++++++++--- ubitx_20/ubitx.h | 4 +- ubitx_20/ubitx_20.ino | 7 ++- ubitx_20/ubitx_lcd_1602.ino | 17 ++++-- ubitx_20/ubitx_menu.ino | 112 +++++++++++++++++++++++++++--------- 5 files changed, 141 insertions(+), 43 deletions(-) diff --git a/ubitx_20/cat_libs.ino b/ubitx_20/cat_libs.ino index 13b3ab4..354f5e0 100644 --- a/ubitx_20/cat_libs.ino +++ b/ubitx_20/cat_libs.ino @@ -54,30 +54,49 @@ #define EEPROM_READ_PREFIX 0xE0 #define EEPROM_WRITE_PREFIX 0xF0 -#define IOP_MODE_COMMAND 0x00 -#define IOP_MODE_SSB 0x01 -#define IOP_MODE_DIGI 0x02 -#define IOP_MODE_CW 0x03 +#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: This all needs to be expanded to include digital... - * * NOTE: Not yet called from CAT, only from menu... */ -void iopSendMode(char is_cw, char is_usb) +void iopSendMode(char cw_mode, char is_usb, char digi_mode) { byte mode; Serial.write(IOP_PREFIX | 2); Serial.write(IOP_MODE_COMMAND); - if (is_cw) + if (cw_mode > 0) mode = IOP_MODE_CW; + else if (digi_mode > 0) + mode = IOP_MODE_DIGI; 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); } unsigned int skipTimeCount = 0; @@ -202,7 +221,8 @@ void CatSetSplit(boolean isSplit) //for remove warning messages void CatSetPTT(boolean isPTTOn, byte fromType) { - // + // KC4UPR - so I think this means, that if we're currently processing a CW keyer (auto/manual), + // not to accept a CAT command in the middle of it. if ((!inTx) && (fromType == 2 || fromType == 3)) { Serial.write(ACK); return; @@ -215,6 +235,9 @@ void CatSetPTT(boolean isPTTOn, byte fromType) { txCAT = true; + // KC4UPR - added the next line to tell the IOP we're transmitting + iopStartTx(); + startTx(TX_SSB, 1); //Exit menu, Memory Keyer... ETC if (isCWAutoMode > 0) { @@ -228,6 +251,9 @@ void CatSetPTT(boolean isPTTOn, byte fromType) { if (inTx) { + // KC4UPR - added the next line to tell the IOP we're not transmitting + iopStopTx(); + stopTx(); txCAT = false; } diff --git a/ubitx_20/ubitx.h b/ubitx_20/ubitx.h index 3dbb4fb..427a99e 100644 --- a/ubitx_20/ubitx.h +++ b/ubitx_20/ubitx.h @@ -310,8 +310,8 @@ extern void printLineF(char linenmbr, const __FlashStringHelper *c); extern void printLineFromEEPRom(char linenmbr, char lcdColumn, byte eepromStartIndex, byte eepromEndIndex, char offsetType); extern byte delay_background(unsigned delayTime, byte fromType); extern int btnDown(void); -extern char c[30]; -extern char b[30]; +extern char c[40]; +extern char b[40]; extern int enc_read(void); extern void si5351bx_init(void); extern void si5351bx_setfreq(uint8_t clknum, uint32_t fout); diff --git a/ubitx_20/ubitx_20.ino b/ubitx_20/ubitx_20.ino index c78da97..4fb2bcd 100644 --- a/ubitx_20/ubitx_20.ino +++ b/ubitx_20/ubitx_20.ino @@ -191,10 +191,15 @@ boolean txCAT = false; //turned on if the transmitting due to a CAT comma char inTx = 0; //it is set to 1 if in transmit mode (whatever the reason : cw, ptt or cat) char splitOn = 0; //working split, uses VFO B as the transmit frequency 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 isUSB = 0; //upper sideband was selected, this is reset to the default for the 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) + // 1: user-defined digital mode via USB audio input; DTU (default) USB if isUSB; DTL LSB if !isUSB + // Effect of non-zero digiMode on ubitx software: should disable the physical PTT inputs (front/back), + // but might need to consider physical PTT as a way to stop CAT-based transmission. Also affects the mode + // info sent to the IOP. //frequency when it crosses the frequency border of 10 MHz byte menuOn = 0; //set to 1 when the menu is being displayed, if a menu item sets it to zero, the menu is exited diff --git a/ubitx_20/ubitx_lcd_1602.ino b/ubitx_20/ubitx_lcd_1602.ino index 76f2e5b..1f669ad 100644 --- a/ubitx_20/ubitx_lcd_1602.ino +++ b/ubitx_20/ubitx_lcd_1602.ino @@ -282,7 +282,7 @@ void LCD_CreateChar(uint8_t location, uint8_t charmap[]) //SWR GRAPH, DrawMeter and drawingMeter Logic function by VK2ETA #define OPTION_SKINNYBARS -char c[30], b[30]; +char c[40], b[40]; char printBuff[2][17]; //mirrors what is showing on the two lines of the display @@ -438,10 +438,17 @@ void updateDisplay() { else { if (cwMode == 0) { - if (isUSB) - strcpy(c, "USB "); - else - strcpy(c, "LSB "); + if (digiMode == 1) { + if (isUSB) + strcpy(c, "DGU "); + else + strcpy(c, "DGL "); + } else { + if (isUSB) + strcpy(c, "USB "); + else + strcpy(c, "LSB "); + } } else if (cwMode == 1) { diff --git a/ubitx_20/ubitx_menu.ino b/ubitx_20/ubitx_menu.ino index 4bec378..dd5a4cb 100644 --- a/ubitx_20/ubitx_menu.ino +++ b/ubitx_20/ubitx_menu.ino @@ -131,9 +131,9 @@ byte modeToByte(){ if (cwMode == 0) { if (isUSB) - return 3; + return 3 + (digiMode > 0 ? 3 + digiMode : 0); else - return 2; + return 2 + (digiMode > 0 ? 3 + digiMode : 0); } else if (cwMode == 1) { @@ -149,20 +149,56 @@ byte modeToByte(){ //autoSetModebyFreq : 0 //autoSetModebyFreq : 1, if (modValue is not set, set mode by frequency) void byteToMode(byte modeValue, byte autoSetModebyFreq){ - if (modeValue == 4) - cwMode = 1; - else if (modeValue == 5) - cwMode = 2; - else - { + isUSB = false; + cwMode = 0; + digiMode = 0; + + if (autoSetModebyFreq == 1 && (modeValue == 0)) { + isUSB = (frequency > 10000000l) ? true : false; + } else { + switch(modeValue) { + // LSB by default, so we can skip this case + //case 2: // LSB + //break; + + case 3: // USB + isUSB = true; + break; + + case 4: // CWL + cwMode = 1; + break; + + case 5: // CWU + cwMode = 2; + break; + + case 6: // DGL + digiMode = 1; + break; + + case 7: // DGU + isUSB = true; + digiMode = 1; + break; + } + } +/* if (modeValue == 4) { + cwMode = 1; digiMode = 0; + } else if (modeValue == 5) { + cwMode = 2; digiMode = 0; + } else { cwMode = 0; - if (modeValue == 3) - isUSB = 1; + if (modeValue == 3) { + isUSB = 1; digiMode = 0; + } else if (modeValue == 6) { + isUSB = + } else if (autoSetModebyFreq == 1 && (modeValue == 0)) isUSB = (frequency > 10000000l) ? true : false; else isUSB = 0; - } + }*/ } @@ -651,12 +687,19 @@ int getValueByKnob(int valueType, int targetValue, int minKnobValue, int maxKnob moveDetectStep = 0; } - strcpy(b, displayTitle); - if (valueType == 11) //Mode Select { - b[targetValue * 4] = '>'; - } + int tmpCol = targetValue * 4; + if (tmpCol >= 16) { + tmpCol -= 16; + strcpy(b, &displayTitle[16]); + } else { + strcpy(b, displayTitle); + } + b[tmpCol] = '>'; + } else { + strcpy(b, displayTitle); + /* else if (valueType == 4) //CW Key Type Select { @@ -668,8 +711,6 @@ int getValueByKnob(int valueType, int targetValue, int minKnobValue, int maxKnob strcat(b, "IAMBICB"); } */ - else - { strcat(b, ":"); itoa(targetValue,c, 10); strcat(b, c); @@ -932,36 +973,55 @@ void menuSelectMode(int btn){ } else { - //LSB, USB, CWL, CWU - if (cwMode == 0 && isUSB == 0) + //LSB, USB, CWL, CWU, DGL, DGU + if (cwMode == 0) { + if (isUSB == 0) { + selectModeType = 0; // LSB + } else { + selectModeType = 1; // USB + } + // modify if digital mode is set + if (digiMode > 0) { + selectModeType += (3 + digiMode); + } + } else if (cwMode == 1) { + selectModeType = 2; // CWL + } else { + selectModeType = 3; // CWU + } + /*if (cwMode == 0 && isUSB == 0) selectModeType = 0; else if (cwMode == 0 && isUSB == 1) selectModeType = 1; else if (cwMode == 1) selectModeType = 2; else - selectModeType = 3; + selectModeType = 3;*/ beforeMode = selectModeType; - selectModeType = getValueByKnob(11, selectModeType, 0, 3, 1, " LSB USB CWL CWU", 4); //3 : Select Mode, targetValue, minKnobValue, maxKnobValue, stepSize + selectModeType = getValueByKnob(11, selectModeType, 0, 5, 1, " LSB USB CWL CWU DGL DGU ", 4); //3 : Select Mode, targetValue, minKnobValue, maxKnobValue, stepSize if (beforeMode != selectModeType) { //printLineF1(F("Changed Mode")); if (selectModeType == 0) { - cwMode = 0; isUSB = 0; + cwMode = 0; isUSB = 0; digiMode = 0; } else if (selectModeType == 1) { - cwMode = 0; isUSB = 1; + cwMode = 0; isUSB = 1; digiMode = 0; } else if (selectModeType == 2) { - cwMode = 1; + cwMode = 1; digiMode = 0; } else if (selectModeType == 3) { - cwMode = 2; + cwMode = 2; digiMode = 0; + } else if (selectModeType == 4) { + cwMode = 0; isUSB = 0; digiMode = 1; + } else if (selectModeType == 5) { + cwMode = 0; isUSB = 1; digiMode = 1; } // KC4UPR: sending mode to IOP - iopSendMode(cwMode, isUSB); + iopSendMode(cwMode, isUSB, digiMode); FrequencyToVFO(1); }