Got the 5 second "DSP status menu" working. Got comms between the IOP

and the Raduino working again.  Now implements a wrapper around all
IOP<=>Raduino comms (IOP prefix, CAT prefix...)
This commit is contained in:
Rob French 2020-05-18 08:15:28 -05:00
parent 681e01d019
commit 2f8fe7fb4c
3 changed files with 160 additions and 106 deletions

View File

@ -61,13 +61,13 @@ void iopSendMode(char cw_mode, char is_usb, char digi_mode, char is_test)
byte mode; byte mode;
if (cw_mode > 0) if (cw_mode > 0)
mode = MODE_CW; mode = RIG_MODE_CW;
else if (digi_mode > 0) else if (digi_mode > 0)
mode = MODE_DIGI; mode = RIG_MODE_DIGI;
else if (is_test) else if (is_test)
mode = MODE_TEST; mode = RIG_MODE_TEST;
else else
mode = MODE_SSB; mode = RIG_MODE_SSB;
sendIOPModeCommand(mode); sendIOPModeCommand(mode);
} }
@ -810,12 +810,25 @@ byte rxBufferCheckCount = 0;
//Prevent Stack Overflow //Prevent Stack Overflow
byte isProcessCheck_Cat = 0; byte isProcessCheck_Cat = 0;
char iopStatusWindow[4] = " "; // may need to move this if it's not visible to ubitx_lcd_1602
// 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.
// Put these here because of how Arduino IDE puts .ino files together.
#define SMETER_DELAY_TIME 5000
bool displaySmeter = true;
int delaySmeter;
//fromType normal : 0, TX : 1, CW_STRAIGHT : 2, CW_PADDLE : 3, CW_AUTOMODE : 4 //fromType normal : 0, TX : 1, CW_STRAIGHT : 2, CW_PADDLE : 3, CW_AUTOMODE : 4
//if cw mode, no delay //if cw mode, no delay
void Check_Cat(byte fromType) void Check_Cat(byte fromType)
{ {
byte i; byte i;
static PrefixID readPrefix;
static uint8_t readLength;
static IOPMessage msg;
//Check Serial Port Buffer //Check Serial Port Buffer
if (Serial.available() == 0) if (Serial.available() == 0)
{ {
@ -823,7 +836,9 @@ void Check_Cat(byte fromType)
rxBufferCheckCount = 0; rxBufferCheckCount = 0;
return; return;
} }
else if (Serial.available() < 5) // KC4UPR - IOP update: changed this to 6 characters, because we're going to have a
// first character which defines if this is CAT or IOP.
else if (Serial.available() < 6) //5)
{ {
//First Arrived //First Arrived
if (rxBufferCheckCount == 0) if (rxBufferCheckCount == 0)
@ -837,7 +852,7 @@ void Check_Cat(byte fromType)
for (i = 0; i < Serial.available(); i++) for (i = 0; i < Serial.available(); i++)
rxBufferCheckCount = Serial.read(); rxBufferCheckCount = Serial.read();
rxBufferCheckCount = 0; rxBufferCheckCount = 0;
} }
else if (rxBufferCheckCount < Serial.available()) //increase buffer count, slow arrived else if (rxBufferCheckCount < Serial.available()) //increase buffer count, slow arrived
{ {
@ -848,103 +863,133 @@ void Check_Cat(byte fromType)
} }
//Arived CAT DATA //Arived CAT DATA
for (i = 0; i < 5; i++) // KC4UPR - IOP update - 6 characters; first character determines mode (CAT or IOP)
CAT_BUFF[i] = Serial.read(); 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();
}
}
// 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.
if (isProcessCheck_Cat == 1) if (isProcessCheck_Cat == 1)
return; return;
isProcessCheck_Cat = 1; isProcessCheck_Cat = 1;
//reference : http://www.ka7oei.com/ft817_meow.html if (readPrefix == IOP_PREFIX) {
switch(CAT_BUFF[4]) recvIOPMessage(msg, CAT_BUFF, 5); // not super robust... if IOP ever sends more than a 5 (6) byte message
{ // following assumes it's a status message, 4 chars (including trailing null, which I'm ignoring...
//The stability has not been verified and there seems to be no need. so i remarked codes, switch(msg.id) {
//if you need, unmark lines case IOP_SSB_STATUS_MSG:
/* case IOP_DIGI_STATUS_MSG:
case 0x00 : //Lock On case IOP_CW_STATUS_MSG:
if (isDialLock == 1) //This command returns 00 if it was unlocked, and F0 if already locked. case IOP_TEST_STATUS_MSG:
CAT_BUFF[0] = 0xF0; iopStatusWindow[0] = msg.data[0];
else { iopStatusWindow[1] = msg.data[1];
CAT_BUFF[0] = 0x00; iopStatusWindow[2] = msg.data[2];
setDialLock(1, fromType); displaySmeter = false;
} delaySmeter = millis() + SMETER_DELAY_TIME;
Serial.write(CAT_BUFF[0]); //Time break;
}
} else if (readPrefix == CAT_PREFIX) {
//reference : http://www.ka7oei.com/ft817_meow.html
switch(CAT_BUFF[4])
{
//The stability has not been verified and there seems to be no need. so i remarked codes,
//if you need, unmark lines
/*
case 0x00 : //Lock On
if (isDialLock == 1) //This command returns 00 if it was unlocked, and F0 if already locked.
CAT_BUFF[0] = 0xF0;
else {
CAT_BUFF[0] = 0x00;
setDialLock(1, fromType);
}
Serial.write(CAT_BUFF[0]); //Time
break;
case 0x80 : //Lock Off
if (isDialLock == 0) //This command returns 00 if the '817 was already locked, and F0 (HEX) if already unlocked.
CAT_BUFF[0] = 0xF0;
else {
CAT_BUFF[0] = 0x00;
setDialLock(0, fromType);
}
Serial.write(CAT_BUFF[0]); //Time
break;
*/
case 0x01 : //Set Frequency
CatSetFreq(fromType);
break; break;
case 0x80 : //Lock Off
if (isDialLock == 0) //This command returns 00 if the '817 was already locked, and F0 (HEX) if already unlocked. case 0x02 : //Split On
CAT_BUFF[0] = 0xF0; case 0x82: //Split Off
else { CatSetSplit(CAT_BUFF[4] == 0x02);
CAT_BUFF[0] = 0x00;
setDialLock(0, fromType);
}
Serial.write(CAT_BUFF[0]); //Time
break; break;
*/
case 0x03 : //Read Frequency and mode
case 0x01 : //Set Frequency CatGetFreqMode(frequency);
CatSetFreq(fromType); break;
break;
case 0x07 : //Set Operating Mode
case 0x02 : //Split On CatSetMode(CAT_BUFF[0], fromType);
case 0x82: //Split Off break;
CatSetSplit(CAT_BUFF[4] == 0x02);
break; case 0x08 : //Set PTT_ON
case 0x88: //Set PTT Off
case 0x03 : //Read Frequency and mode CatSetPTT(CAT_BUFF[4] == 0x08, fromType);
CatGetFreqMode(frequency); break;
break;
case 0x81: //Toggle VFO
case 0x07 : //Set Operating Mode CatVFOToggle(true, fromType);
CatSetMode(CAT_BUFF[0], fromType); break;
break;
case 0xDB: //Read uBITX EEPROM Data
case 0x08 : //Set PTT_ON ReadEEPRom(); //Call by uBITX Manager Program
case 0x88: //Set PTT Off break;
CatSetPTT(CAT_BUFF[4] == 0x08, fromType); case 0xBB: //Read FT-817 EEPROM Data (for comfirtable)
break; ReadEEPRom_FT817();
break;
case 0x81: //Toggle VFO
CatVFOToggle(true, fromType); case 0xDC: //Write uBITX EEPROM Data
break; WriteEEPRom(); //Call by uBITX Manager Program
break;
case 0xDB: //Read uBITX EEPROM Data case 0xBC: //Write FT-817 EEPROM Data (for comfirtable)
ReadEEPRom(); //Call by uBITX Manager Program WriteEEPRom_FT817(fromType);
break; break;
case 0xBB: //Read FT-817 EEPROM Data (for comfirtable)
ReadEEPRom_FT817(); case 0xDD: //Read uBITX ADC Data
break; ReadADCValue(); //Call by uBITX Manager Program
break;
case 0xDC: //Write uBITX EEPROM Data
WriteEEPRom(); //Call by uBITX Manager Program case 0xDE: //IF-Shift Control by CAT
break; SetIFSValue(); //
case 0xBC: //Write FT-817 EEPROM Data (for comfirtable) break;
WriteEEPRom_FT817(fromType);
break; case 0xE7 : //Read RX Status
CatRxStatus();
case 0xDD: //Read uBITX ADC Data break;
ReadADCValue(); //Call by uBITX Manager Program case 0xF7: //Read TX Status
break; CatTxStatus();
break;
case 0xDE: //IF-Shift Control by CAT default:
SetIFSValue(); // /*
break; char buff[16];
sprintf(buff, "DEFAULT : %x", CAT_BUFF[4]);
case 0xE7 : //Read RX Status printLine2(buff);
CatRxStatus(); */
break; Serial.write(ACK);
case 0xF7: //Read TX Status break;
CatTxStatus(); } //end of switch
break; }
default:
/*
char buff[16];
sprintf(buff, "DEFAULT : %x", CAT_BUFF[4]);
printLine2(buff);
*/
Serial.write(ACK);
break;
} //end of switch
isProcessCheck_Cat = 0; isProcessCheck_Cat = 0;
} }

View File

@ -518,8 +518,6 @@ void updateDisplay() {
} }
} }
char line2Buffer[17]; char line2Buffer[17];
//KD8CEC 200Hz ST //KD8CEC 200Hz ST
//L14.150 200Hz ST //L14.150 200Hz ST
@ -674,13 +672,18 @@ void updateLine2Buffer(char displayType)
if (isStepKhz == 0) if (isStepKhz == 0)
{ {
line2Buffer[11] = 'H'; // KC4UPR: Getting rid of the "Hz" to unclutter the top line.
line2Buffer[12] = 'z'; line2Buffer[11] = ' '; //'H';
line2Buffer[12] = ' '; //'z';
} }
line2Buffer[13] = ' '; //line2Buffer[13] = ' ';
//Check CW Key cwKeyType = 0; //0: straight, 1 : iambica, 2: iambicb // KC4UPR: Replacing these all with IOP status
line2Buffer[13] = iopStatusWindow[0];
line2Buffer[14] = iopStatusWindow[1];
line2Buffer[15] = iopStatusWindow[2];
/* //Check CW Key cwKeyType = 0; //0: straight, 1 : iambica, 2: iambicb
if (sdrModeOn == 1) if (sdrModeOn == 1)
{ {
line2Buffer[13] = 'S'; line2Buffer[13] = 'S';
@ -701,7 +704,7 @@ void updateLine2Buffer(char displayType)
{ {
line2Buffer[14] = 'I'; line2Buffer[14] = 'I';
line2Buffer[15] = 'B'; line2Buffer[15] = 'B';
} } */
} }
} }
@ -745,8 +748,14 @@ void idle_process()
} }
} }
if (!displaySmeter) {
if (delaySmeter < millis()) {
displaySmeter = true;
}
}
//S-Meter Display //S-Meter Display
if (((displayOption1 & 0x08) == 0x08 && (sdrModeOn == 0)) && (++checkCountSMeter > SMeterLatency)) if (((displayOption1 & 0x08) == 0x08 && (sdrModeOn == 0)) && (++checkCountSMeter > SMeterLatency) && displaySmeter)
{ {
int newSMeter; int newSMeter;

View File

@ -996,7 +996,7 @@ void menuSelectMode(int btn){
// modify if two-tone test mode is set // modify if two-tone test mode is set
} else if (isTest > 0) { } else if (isTest > 0) {
selectModeType += 5; selectModeType += 6;
} }
} else if (cwMode == 1) { } else if (cwMode == 1) {
selectModeType = 2; // CWL selectModeType = 2; // CWL