Modified about Loopback protocol

This commit is contained in:
phdlee 2018-06-28 23:29:06 +09:00
parent fe44c703c5
commit dd43ba4c33
3 changed files with 135 additions and 216 deletions

View File

@ -6,7 +6,7 @@
// So I put + in the sense that it was improved one by one based on Original Firmware. // So I put + in the sense that it was improved one by one based on Original Firmware.
// This firmware has been gradually changed based on the original firmware created by Farhan, Jack, Jerry and others. // This firmware has been gradually changed based on the original firmware created by Farhan, Jack, Jerry and others.
#define FIRMWARE_VERSION_INFO F("+v1.094") #define FIRMWARE_VERSION_INFO F("+v1.095")
#define FIRMWARE_VERSION_NUM 0x04 //1st Complete Project : 1 (Version 1.061), 2st Project : 2, 1.08: 3, 1.09 : 4 #define FIRMWARE_VERSION_NUM 0x04 //1st Complete Project : 1 (Version 1.061), 2st Project : 2, 1.08: 3, 1.09 : 4
/** /**
@ -467,13 +467,17 @@ void startTx(byte txMode, byte isDisplayUpdate){
} }
else else
{ {
if (splitOn == 1) { if (splitOn == 1)
if (vfoActive == VFO_B) { {
FrequencyToVFO(1); //Save current Frequency and Mode to eeprom
if (vfoActive == VFO_B)
{
vfoActive = VFO_A; vfoActive = VFO_A;
frequency = vfoA; frequency = vfoA;
byteToMode(vfoA_mode, 0); byteToMode(vfoA_mode, 0);
} }
else if (vfoActive == VFO_A){ else if (vfoActive == VFO_A)
{
vfoActive = VFO_B; vfoActive = VFO_B;
frequency = vfoB; frequency = vfoB;
byteToMode(vfoB_mode, 0); byteToMode(vfoB_mode, 0);

View File

@ -184,9 +184,16 @@ byte L_displayOption2; //byte displayOption2 (Reserve)
#define TS_CMD_STOPADC 14 #define TS_CMD_STOPADC 14
#define TS_CMD_SPECTRUMOPT 15 //Option for Spectrum #define TS_CMD_SPECTRUMOPT 15 //Option for Spectrum
#define TS_CMD_SPECTRUM 16 //Get Spectrum Value #define TS_CMD_SPECTRUM 16 //Get Spectrum Value
#define TS_CMD_TUNESTEP 17 //Get Spectrum Value
#define TS_CMD_SWTRIG 21 //SW Action Trigger for WSPR and more #define TS_CMD_SWTRIG 21 //SW Action Trigger for WSPR and more
#define TS_CMD_READMEM 31 //Read EEProm #define TS_CMD_READMEM 31 //Read EEProm
#define TS_CMD_WRITEMEM 32 //Write EEProm #define TS_CMD_WRITEMEM 32 //Write EEProm
#define TS_CMD_LOOPBACK0 74 //Loopback1 (Response to Loopback Channgel)
#define TS_CMD_LOOPBACK1 75 //Loopback2 (Response to Loopback Channgel)
#define TS_CMD_LOOPBACK2 76 //Loopback3 (Response to Loopback Channgel)
#define TS_CMD_LOOPBACK3 77 //Loopback4 (Response to Loopback Channgel)
#define TS_CMD_LOOPBACK4 78 //Loopback5 (Response to Loopback Channgel)
#define TS_CMD_LOOPBACK5 79 //Loopback6 (Response to Loopback Channgel)
#define TS_CMD_FACTORYRESET 85 //Factory Reset #define TS_CMD_FACTORYRESET 85 //Factory Reset
#define TS_CMD_UBITX_REBOOT 95 //Reboot #define TS_CMD_UBITX_REBOOT 95 //Reboot
@ -776,7 +783,7 @@ void SWS_Process(void)
} }
else if (commandType == TS_CMD_SPLIT) else if (commandType == TS_CMD_SPLIT)
{ {
menuSplitOnOff(1); menuSplitOnOff(10);
} }
else if (commandType == TS_CMD_RIT) else if (commandType == TS_CMD_RIT)
{ {
@ -855,6 +862,10 @@ void SWS_Process(void)
spectrumScanCount = swr_buffer[commandStartIndex + 6]; //Maximum 120 spectrumScanCount = swr_buffer[commandStartIndex + 6]; //Maximum 120
spectrumIncStep = swr_buffer[commandStartIndex + 7] * 20; //Increaase Step spectrumIncStep = swr_buffer[commandStartIndex + 7] * 20; //Increaase Step
} }
else if (commandType == TS_CMD_TUNESTEP) //Set Tune Step
{
tuneStepIndex = swr_buffer[commandStartIndex + 4]; //Tune Step Index
}
else if (commandType == TS_CMD_SWTRIG) else if (commandType == TS_CMD_SWTRIG)
{ {
TriggerBySW = 1; //Action Trigger by Software TriggerBySW = 1; //Action Trigger by Software
@ -903,7 +914,14 @@ void SWS_Process(void)
{ {
eepromIndex = -2; eepromIndex = -2;
} }
SendCommandL('n', eepromIndex); //Index Input SendCommandL('n', eepromIndex); //Index Input
}
//else if (TS_CMD_LOOPBACK0 <= commandType && commandType <= TS_CMD_LOOPBACK5) //Loop back Channel 0 ~ 5 Loop back Channel 1~5 : Reserve
else if (TS_CMD_LOOPBACK0 == commandType) //Loop back Channel 0 ~ 5
{
SendCommandUL('v', *(unsigned long *)&swr_buffer[commandStartIndex + 4]); //Return data
SendCommandUL('g', commandType); //Index Input
//return;
} }
else if (commandType == TS_CMD_FACTORYRESET || commandType == TS_CMD_UBITX_REBOOT) else if (commandType == TS_CMD_FACTORYRESET || commandType == TS_CMD_UBITX_REBOOT)
{ {
@ -911,6 +929,7 @@ void SWS_Process(void)
{ {
if (commandType == TS_CMD_UBITX_REBOOT) if (commandType == TS_CMD_UBITX_REBOOT)
{ {
FrequencyToVFO(1); //Save current Frequency and Mode to eeprom
asm volatile (" jmp 0"); asm volatile (" jmp 0");
} }
else else
@ -979,7 +998,7 @@ void SendUbitxData(void)
EEPROM.get(EXTERNAL_DEVICE_OPT1, nextionDisplayOption); EEPROM.get(EXTERNAL_DEVICE_OPT1, nextionDisplayOption);
SendCommandUL(CMD_DISP_OPTION2, nextionDisplayOption); SendCommandUL(CMD_DISP_OPTION2, nextionDisplayOption);
SendCommandStr(CMD_VERSION, "+v1.094"); //Version SendCommandStr(CMD_VERSION, "+v1.095"); //Version
SendEEPromData(CMD_CALLSIGN, 0, userCallsignLength -1, 0); SendEEPromData(CMD_CALLSIGN, 0, userCallsignLength -1, 0);
/* /*

View File

@ -389,7 +389,14 @@ void menuVfoToggle(int btn)
ritDisable(); ritDisable();
setFrequency(frequency); setFrequency(frequency);
menuClearExit(0);
#ifdef USE_SW_SERIAL
menuOn = 0;
#else
//Only Clear And Delay for Character LCD
menuClearExit(0);
#endif
} }
} }
@ -406,17 +413,20 @@ void menuSplitOnOff(int btn){
if (splitOn == 1){ if (splitOn == 1){
splitOn = 0; splitOn = 0;
printLineF2(F("SPT Off")); printLineF2(F("SPT Off"));
//printLineF2(F("[OFF]"));
} }
else { else {
splitOn = 1; splitOn = 1;
if (ritOn == 1) if (ritOn == 1)
ritOn = 0; ritOn = 0;
printLineF2(F("SPT On")); printLineF2(F("SPT On"));
//printLineF2(F("[ON]"));
} }
#ifdef USE_SW_SERIAL
menuOn = 0;
#else
//Only Clear And Delay for Character LCD
menuClearExit(500); menuClearExit(500);
#endif
} }
} }
@ -438,8 +448,13 @@ void menuTxOnOff(int btn, byte optionType){
isTxType &= ~(optionType); isTxType &= ~(optionType);
printLineF2(F("TX ON")); printLineF2(F("TX ON"));
} }
#ifdef USE_SW_SERIAL
menuOn = 0;
#else
//Only Clear And Delay for Character LCD
menuClearExit(500); menuClearExit(500);
#endif
} }
} }
@ -472,7 +487,13 @@ void menuSDROnOff(int btn)
EEPROM.put(ENABLE_SDR, sdrModeOn); EEPROM.put(ENABLE_SDR, sdrModeOn);
setFrequency(frequency); setFrequency(frequency);
SetCarrierFreq(); SetCarrierFreq();
#ifdef USE_SW_SERIAL
menuOn = 0;
#else
//Only Clear And Delay for Character LCD
menuClearExit(500); menuClearExit(500);
#endif
} }
} }
@ -730,7 +751,14 @@ void menuCWSpeed(int btn){
//printLineF2(F("CW Speed set!")); //printLineF2(F("CW Speed set!"));
cwSpeed = 1200 / wpm; cwSpeed = 1200 / wpm;
EEPROM.put(CW_SPEED, cwSpeed); EEPROM.put(CW_SPEED, cwSpeed);
menuClearExit(1000); //menuClearExit(1000);
#ifdef USE_SW_SERIAL
menuOn = 0;
#else
//Only Clear And Delay for Character LCD
menuClearExit(1000);
#endif
} }
//Modified by KD8CEC //Modified by KD8CEC
@ -751,44 +779,22 @@ void menuSetupCwTone(int btn){
sideTone = getValueByKnob(1, sideTone, 100, 2000, 10, "Tone", 2); //1 : Generate Tone, targetValue, minKnobValue, maxKnobValue, stepSize sideTone = getValueByKnob(1, sideTone, 100, 2000, 10, "Tone", 2); //1 : Generate Tone, targetValue, minKnobValue, maxKnobValue, stepSize
/*
//disable all clock 1 and clock 2
while (digitalRead(PTT) == HIGH && !btnDown())
{
knob = enc_read();
if (knob > 0 && sideTone < 2000)
sideTone += 10;
else if (knob < 0 && sideTone > 100 )
sideTone -= 10;
else
continue; //don't update the frequency or the display
tone(CW_TONE, sideTone);
itoa(sideTone, b, 10);
printLine2(b);
delay_background(100, 0);
}
*/
noTone(CW_TONE); noTone(CW_TONE);
//save the setting printLineF2(F("Sidetone set!"));
//if (digitalRead(PTT) == LOW){ EEPROM.put(CW_SIDETONE, sideTone);
printLineF2(F("Sidetone set!"));
EEPROM.put(CW_SIDETONE, sideTone); //delay_background(2000, 0);
delay_background(2000, 0); //menuClearExit(0);
//} #ifdef USE_SW_SERIAL
//else menuOn = 0;
// sideTone = prev_sideTone; #else
//Only Clear And Delay for Character LCD
menuClearExit(0); delay_background(2000, 0);
menuClearExit(0);
#endif
} }
//Modified by KD8CEC //Modified by KD8CEC
void menuSetupCwDelay(int btn){ void menuSetupCwDelay(int btn){
//int knob = 0; //int knob = 0;
@ -799,44 +805,18 @@ void menuSetupCwDelay(int btn){
return; return;
} }
//printLineF1(F("Press, set Delay"));
/*
strcpy(b, "DELAY:");
itoa(tmpCWDelay,c, 10);
strcat(b, c);
printLine2(b);
*/
//delay_background(300, 0);
tmpCWDelay = getValueByKnob(0, tmpCWDelay, 3, 2500, 10, "Delay", 2); //0 : Generate Tone, targetValue, minKnobValue, maxKnobValue, stepSize tmpCWDelay = getValueByKnob(0, tmpCWDelay, 3, 2500, 10, "Delay", 2); //0 : Generate Tone, targetValue, minKnobValue, maxKnobValue, stepSize
/*
while(!btnDown()){
knob = enc_read();
if (knob != 0){
if (tmpCWDelay > 3 && knob < 0)
tmpCWDelay -= 10;
if (tmpCWDelay < 2500 && knob > 0)
tmpCWDelay += 10;
strcpy(b, "DELAY:");
itoa(tmpCWDelay,c, 10);
strcat(b, c);
printLine2(b);
}
//abort if this button is down
if (btnDown())
break;
Check_Cat(0); //To prevent disconnections
}
*/
//save the setting //save the setting
//printLineF2(F("CW Delay set!"));
cwDelayTime = tmpCWDelay / 10; cwDelayTime = tmpCWDelay / 10;
EEPROM.put(CW_DELAY, cwDelayTime); EEPROM.put(CW_DELAY, cwDelayTime);
menuClearExit(1000); //menuClearExit(1000);
#ifdef USE_SW_SERIAL
menuOn = 0;
#else
//Only Clear And Delay for Character LCD
menuClearExit(1000);
#endif
} }
//CW Time delay by KD8CEC //CW Time delay by KD8CEC
@ -855,41 +835,17 @@ void menuSetupTXCWInterval(int btn){
tmpTXCWInterval = getValueByKnob(0, tmpTXCWInterval, 0, 500, 2, "Delay", 2); //0 : Generate Tone, targetValue, minKnobValue, maxKnobValue, stepSize tmpTXCWInterval = getValueByKnob(0, tmpTXCWInterval, 0, 500, 2, "Delay", 2); //0 : Generate Tone, targetValue, minKnobValue, maxKnobValue, stepSize
/*
while(!btnDown()){
if (needDisplayInformation == 1) {
strcpy(b, "Start Delay:");
itoa(tmpTXCWInterval,c, 10);
strcat(b, c);
printLine2(b);
needDisplayInformation = 0;
}
knob = enc_read();
if (knob != 0){
if (tmpTXCWInterval > 0 && knob < 0)
tmpTXCWInterval -= 2;
if (tmpTXCWInterval < 500 && knob > 0)
tmpTXCWInterval += 2;
needDisplayInformation = 1;
}
//abort if this button is down
//if (btnDown())
// break;
Check_Cat(0); //To prevent disconnections
}
*/
//save the setting
//printLineF2(F("CW Start set!"));
delayBeforeCWStartTime = tmpTXCWInterval / 2; delayBeforeCWStartTime = tmpTXCWInterval / 2;
EEPROM.put(CW_START, delayBeforeCWStartTime); EEPROM.put(CW_START, delayBeforeCWStartTime);
//menuClearExit(1000);
#ifdef USE_SW_SERIAL
menuOn = 0;
#else
//Only Clear And Delay for Character LCD
menuClearExit(1000);
#endif
menuClearExit(1000);
} }
//IF Shift function, BFO Change like RIT, by KD8CEC //IF Shift function, BFO Change like RIT, by KD8CEC
@ -907,36 +863,7 @@ void menuIFSSetup(int btn){
{ {
isIFShift = 1; isIFShift = 1;
//delay_background(500, 0);
//updateLine2Buffer(1);
//setFrequency(frequency);
ifShiftValue = getValueByKnob(2, ifShiftValue, -20000, 20000, 50, "IFS", 2); //2 : IF Setup (updateLine2Buffer(1), SetFrequency), targetValue, minKnobValue, maxKnobValue, stepSize ifShiftValue = getValueByKnob(2, ifShiftValue, -20000, 20000, 50, "IFS", 2); //2 : IF Setup (updateLine2Buffer(1), SetFrequency), targetValue, minKnobValue, maxKnobValue, stepSize
/*
//Off or Change Value
while(!btnDown() ){
if (needApplyChangeValue ==1)
{
updateLine2Buffer(1);
setFrequency(frequency);
SetCarrierFreq();
needApplyChangeValue = 0;
}
knob = enc_read();
if (knob != 0){
if (knob < 0)
ifShiftValue -= 50;
else if (knob > 0)
ifShiftValue += 50;
needApplyChangeValue = 1;
}
Check_Cat(0); //To prevent disconnections
}
*/
delay_background(500, 0); //for check Long Press function key delay_background(500, 0); //for check Long Press function key
if (btnDown() || ifShiftValue == 0) if (btnDown() || ifShiftValue == 0)
@ -949,7 +876,13 @@ void menuIFSSetup(int btn){
//Store IF Shiift //Store IF Shiift
EEPROM.put(IF_SHIFTVALUE, ifShiftValue); EEPROM.put(IF_SHIFTVALUE, ifShiftValue);
menuClearExit(0); //menuClearExit(0);
#ifdef USE_SW_SERIAL
menuOn = 0;
#else
//Only Clear And Delay for Character LCD
menuClearExit(0);
#endif
} }
} }
@ -975,7 +908,15 @@ void menuATTSetup(int btn){
setFrequency(frequency); setFrequency(frequency);
//SetCarrierFreq(); //SetCarrierFreq();
} }
//menuClearExit(0);
#ifdef USE_SW_SERIAL
menuOn = 0;
#else
//Only Clear And Delay for Character LCD
menuClearExit(0); menuClearExit(0);
#endif
} }
} }
@ -1002,44 +943,10 @@ void menuSelectMode(int btn){
selectModeType = 3; selectModeType = 3;
beforeMode = selectModeType; beforeMode = selectModeType;
//delay_background(500, 0);
selectModeType = getValueByKnob(11, selectModeType, 0, 3, 1, " LSB USB CWL CWU", 4); //3 : Select Mode, targetValue, minKnobValue, maxKnobValue, stepSize selectModeType = getValueByKnob(11, selectModeType, 0, 3, 1, " LSB USB CWL CWU", 4); //3 : Select Mode, targetValue, minKnobValue, maxKnobValue, stepSize
/* if (beforeMode != selectModeType)
while(!btnDown()){ {
//Display Mode Name
memset(c, 0, sizeof(c));
strcpy(c, " LSB USB CWL CWU");
c[selectModeType * 4] = '>';
printLine1(c);
knob = enc_read();
if (knob != 0)
{
moveStep += (knob > 0 ? 1 : -1);
if (moveStep < -3) {
if (selectModeType > 0)
selectModeType--;
moveStep = 0;
}
else if (moveStep > 3) {
if (selectModeType < 3)
selectModeType++;
moveStep = 0;
}
}
//Check_Cat(0); //To prevent disconnections
delay_background(50, 0);
}
*/
if (beforeMode != selectModeType) {
//printLineF1(F("Changed Mode")); //printLineF1(F("Changed Mode"));
if (selectModeType == 0) { if (selectModeType == 0) {
cwMode = 0; isUSB = 0; cwMode = 0; isUSB = 0;
@ -1058,9 +965,14 @@ void menuSelectMode(int btn){
} }
SetCarrierFreq(); SetCarrierFreq();
setFrequency(frequency); setFrequency(frequency);
//menuClearExit(500);
#ifdef USE_SW_SERIAL
menuOn = 0;
#else
//Only Clear And Delay for Character LCD
menuClearExit(500); menuClearExit(500);
#endif
} }
} }
@ -1073,45 +985,11 @@ void menuSetupKeyType(int btn){
printLineF2(F("Change Key Type?")); printLineF2(F("Change Key Type?"));
} }
else { else {
//printLineF2(F("Press to set Key")); //for reduce usable flash memory
//delay_background(500, 0);
selectedKeyType = cwKeyType; selectedKeyType = cwKeyType;
//selectedKeyType = getValueByKnob(12, selectedKeyType, 0, 2, 1, " KEY:", 5); //4 : Select Key Type, targetValue, minKnobValue, maxKnobValue, stepSize //selectedKeyType = getValueByKnob(12, selectedKeyType, 0, 2, 1, " KEY:", 5); //4 : Select Key Type, targetValue, minKnobValue, maxKnobValue, stepSize
selectedKeyType = getValueByKnob(11, selectedKeyType, 0, 2, 1, " ST IA IB", 5); //4 : Select Key Type, targetValue, minKnobValue, maxKnobValue, stepSize selectedKeyType = getValueByKnob(11, selectedKeyType, 0, 2, 1, " ST IA IB", 5); //4 : Select Key Type, targetValue, minKnobValue, maxKnobValue, stepSize
/*
while(!btnDown()){
//Display Key Type
if (selectedKeyType == 0)
printLineF1(F("Straight"));
else if (selectedKeyType == 1)
printLineF1(F("IAMBICA"));
else if (selectedKeyType == 2)
printLineF1(F("IAMBICB"));
knob = enc_read();
if (knob != 0)
{
moveStep += (knob > 0 ? 1 : -1);
if (moveStep < -3) {
if (selectedKeyType > 0)
selectedKeyType--;
moveStep = 0;
}
else if (moveStep > 3) {
if (selectedKeyType < 2)
selectedKeyType++;
moveStep = 0;
}
}
Check_Cat(0); //To prevent disconnections
}
*/
printLineF2(F("CW Key Type set!")); printLineF2(F("CW Key Type set!"));
cwKeyType = selectedKeyType; cwKeyType = selectedKeyType;
EEPROM.put(CW_KEY_TYPE, cwKeyType); EEPROM.put(CW_KEY_TYPE, cwKeyType);
@ -1127,7 +1005,14 @@ void menuSetupKeyType(int btn){
keyerControl |= IAMBICB; keyerControl |= IAMBICB;
} }
//menuClearExit(1000);
#ifdef USE_SW_SERIAL
menuOn = 0;
#else
//Only Clear And Delay for Character LCD
menuClearExit(1000); menuClearExit(1000);
#endif
} }
} }
@ -1364,7 +1249,14 @@ void menuSetup(int btn){
else else
{ {
modeCalibrate = ! modeCalibrate; modeCalibrate = ! modeCalibrate;
//menuClearExit(1000);
#ifdef USE_SW_SERIAL
menuOn = 0;
#else
//Only Clear And Delay for Character LCD
menuClearExit(1000); menuClearExit(1000);
#endif
} }
} }
@ -1395,13 +1287,17 @@ void menuRitToggle(int btn){
ritDisable(); ritDisable();
} }
//menuClearExit(500);
#ifdef USE_SW_SERIAL
menuOn = 0;
#else
//Only Clear And Delay for Character LCD
menuClearExit(500); menuClearExit(500);
#endif
} }
} }
/** /**
* Take a deep breath, math(ematics) ahead * Take a deep breath, math(ematics) ahead
* The 25 mhz oscillator is multiplied by 35 to run the vco at 875 mhz * The 25 mhz oscillator is multiplied by 35 to run the vco at 875 mhz