beta 0.25 commit

This commit is contained in:
phdlee
2018-01-10 11:34:15 +09:00
parent 8176b50f48
commit f563e74a4e
7 changed files with 2044 additions and 420 deletions

View File

@@ -10,8 +10,8 @@
* - If the menu item is clicked on, then it is selected,
* - If the menu item is NOT clicked on, then the menu's prompt is to be displayed
*/
#define printLineF1(x) (printLineF(1, x))
#define printLineF2(x) (printLineF(0, x))
int menuBand(int btn){
int knob = 0;
@@ -22,14 +22,17 @@ int menuBand(int btn){
// offset = frequency % 1000000l;
if (!btn){
printLine2("Band Select?");
printLineF2(F("Band Select?"));
return;
}
printLine2("Press to confirm");
printLineF2(F("Press to confirm"));
//wait for the button menu select button to be lifted)
while (btnDown())
while (btnDown()) {
delay(50);
Check_Cat(0); //To prevent disconnections
}
delay(50);
ritDisable();
@@ -58,50 +61,72 @@ int menuBand(int btn){
updateDisplay();
}
delay(20);
Check_Cat(0); //To prevent disconnections
}
while(btnDown())
while(btnDown()) {
delay(50);
Check_Cat(0); //To prevent disconnections
}
delay(50);
printLine2("");
updateDisplay();
printLine2ClearAndUpdate();
menuOn = 0;
}
void menuVfoToggle(int btn){
//0: default, 1:not use, 2:LSB, 3:USB, 4:CW, 5:AM, 6:FM
byte modeToByte(){
if (isUSB)
return 3;
else
return 2;
}
void byteToMode(byte modeValue){
if (modeValue == 3)
isUSB = 1;
else
isUSB = 0;
}
void menuVfoToggle(int btn)
{
if (!btn){
if (vfoActive == VFO_A)
printLine2("Select VFO B? ");
printLineF2(F("Select VFO B?"));
else
printLine2("Select VFO A? ");
printLineF2(F("Select VFO A?"));
}
else {
if (vfoActive == VFO_B){
vfoB = frequency;
EEPROM.put(VFO_B, frequency);
vfoB_mode = modeToByte();
storeFrequencyAndMode(2); //vfoB -> eeprom
vfoActive = VFO_A;
printLine2("Selected VFO A ");
frequency = vfoA;
saveCheckFreq = frequency;
byteToMode(vfoA_mode);
printLineF2(F("Selected VFO A"));
}
else {
vfoA = frequency;
EEPROM.put(VFO_A, frequency);
vfoA_mode = modeToByte();
storeFrequencyAndMode(1); //vfoA -> eeprom
vfoActive = VFO_B;
printLine2("Selected VFO B ");
frequency = vfoB;
saveCheckFreq = frequency;
byteToMode(vfoB_mode);
printLineF2(F("Selected VFO B"));
}
ritDisable();
setFrequency(frequency);
if (frequency >= 10000000l)
isUSB = true;
else
isUSB = false;
updateDisplay();
printLine2("");
delay(1000);
//updateDisplay();
delay_background(500, 0);
printLine2ClearAndUpdate();
//exit the menu
menuOn = 0;
}
@@ -110,49 +135,67 @@ void menuVfoToggle(int btn){
void menuRitToggle(int btn){
if (!btn){
if (ritOn == 1)
printLine2("RIT:On, Off? ");
printLineF2(F("RIT:On, Off?"));
else
printLine2("RIT:Off, On? ");
printLineF2(F("RIT:Off, On?"));
}
else {
if (ritOn == 0){
printLine2("RIT is ON");
printLineF2(F("RIT is ON"));
//enable RIT so the current frequency is used at transmit
ritEnable(frequency);
}
else{
printLine2("RIT is OFF");
printLineF2(F("RIT is OFF"));
ritDisable();
}
menuOn = 0;
delay(500);
printLine2("");
updateDisplay();
delay_background(500, 0);
printLine2ClearAndUpdate();
}
}
void menuSidebandToggle(int btn){
if (!btn){
if (isUSB == true)
printLine2("Select LSB?");
printLineF2(F("Select LSB?"));
else
printLine2("Select USB?");
printLineF2(F("Select USB?"));
}
else {
if (isUSB == true){
isUSB = false;
printLine2("LSB Selected");
delay(500);
printLine2("");
printLineF2(F("LSB Selected"));
}
else {
isUSB = true;
printLine2("USB Selected");
delay(500);
printLine2("");
printLineF2(F("USB Selected"));
}
updateDisplay();
setFrequency(frequency);
delay_background(500, 0);
printLine2ClearAndUpdate();
menuOn = 0;
}
}
void menuTxOnOff(int btn){
if (!btn){
if (isTxOff == 0)
printLineF2(F("TX OFF?"));
else
printLineF2(F("TX ON?"));
}
else {
if (isTxOff == 0){
isTxOff = 1;
printLineF2(F("TX OFF!"));
}
else {
isTxOff = 0;
printLineF2(F("TX ON!"));
}
delay_background(500, 0);
printLine2ClearAndUpdate();
menuOn = 0;
}
}
@@ -164,20 +207,20 @@ void menuSidebandToggle(int btn){
void menuSetup(int btn){
if (!btn){
if (!modeCalibrate)
printLine2("Setup On?");
printLineF2(F("Setup On?"));
else
printLine2("Setup Off?");
printLineF2(F("Setup Off?"));
}else {
if (!modeCalibrate){
modeCalibrate = true;
printLine2("Setup:On ");
printLineF2(F("Setup:On"));
}
else {
modeCalibrate = false;
printLine2("Setup:Off ");
printLineF2(F("Setup:Off"));
}
delay(2000);
printLine2("");
delay_background(2000, 0);
printLine2Clear();
menuOn = 0;
}
}
@@ -185,13 +228,10 @@ void menuSetup(int btn){
void menuExit(int btn){
if (!btn){
printLine2("Exit Menu? ");
printLineF2(F("Exit Menu?"));
}
else{
printLine2("Exiting menu");
delay(300);
printLine2("");
updateDisplay();
printLine2ClearAndUpdate();
menuOn = 0;
}
}
@@ -211,12 +251,12 @@ int menuCWSpeed(int btn){
return;
}
printLine1("Press PTT to set");
printLineF1(F("Press PTT to set"));
strcpy(b, "WPM:");
itoa(wpm,c, 10);
strcat(b, c);
printLine2(b);
delay(300);
delay_background(300, 0);
while(!btnDown() && digitalRead(PTT) == HIGH){
@@ -236,19 +276,139 @@ int menuCWSpeed(int btn){
if (btnDown())
//re-enable the clock1 and clock 2
break;
Check_Cat(0); //To prevent disconnections
}
//save the setting
if (digitalRead(PTT) == LOW){
printLine2("CW Speed set!");
printLineF2(F("CW Speed set!"));
cwSpeed = 1200/wpm;
EEPROM.put(CW_SPEED, cwSpeed);
delay(2000);
delay_background(2000, 0);
}
printLine2("");
printLine2ClearAndUpdate();
menuOn = 0;
}
int menuCWAutoKey(int btn){
if (!btn){
printLineF2(F("CW AutoKey Mode?"));
return;
}
//Check CW_AUTO_MAGIC_KEY and CW Text Count
EEPROM.get(CW_AUTO_COUNT, cwAutoTextCount);
if (EEPROM.read(CW_AUTO_MAGIC_KEY) != 0x73 || cwAutoTextCount < 1)
{
printLineF2(F("Empty CW data"));
delay_background(2000, 0);
return;
}
printLineF1(F("Press PTT to Send"));
delay_background(500, 0);
updateDisplay();
beforeCWTextIndex = 255; //255 value is for start check
isCWAutoMode = 1;
menuOn = 0;
}
int menuSetupCwDelay(int btn){
int knob = 0;
int tmpCWDelay = cwDelayTime * 10;
if (!btn){
strcpy(b, "CW TX->RX Delay");
printLine2(b);
return;
}
printLineF1(F("Press PTT to set"));
strcpy(b, "DELAY:");
itoa(tmpCWDelay,c, 10);
strcat(b, c);
printLine2(b);
delay_background(300, 0);
while(!btnDown() && digitalRead(PTT) == HIGH){
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
if (digitalRead(PTT) == LOW){
printLineF2(F("CW Delay set!"));
cwDelayTime = tmpCWDelay / 10;
EEPROM.put(CW_DELAY, cwDelayTime);
delay_background(2000, 0);
}
printLine2ClearAndUpdate();
menuOn = 0;
}
int menuSetupTXCWInterval(int btn){
int knob = 0;
int tmpTXCWInterval = delayBeforeCWStartTime * 2;
if (!btn){
strcpy(b, "CW Start Delay");
printLine2(b);
return;
}
printLineF1(F("Press PTT to set"));
strcpy(b, "Start Delay:");
itoa(tmpTXCWInterval,c, 10);
strcat(b, c);
printLine2(b);
delay_background(300, 0);
while(!btnDown() && digitalRead(PTT) == HIGH){
knob = enc_read();
if (knob != 0){
if (tmpTXCWInterval > 0 && knob < 0)
tmpTXCWInterval -= 2;
if (tmpTXCWInterval < 500 && knob > 0)
tmpTXCWInterval += 2;
strcpy(b, "Start Delay:");
itoa(tmpTXCWInterval,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
if (digitalRead(PTT) == LOW){
printLineF2(F("CW Start set!"));
delayBeforeCWStartTime = tmpTXCWInterval / 2;
EEPROM.put(CW_START, delayBeforeCWStartTime);
delay_background(2000, 0);
}
printLine2ClearAndUpdate();
menuOn = 0;
}
/**
@@ -276,7 +436,7 @@ int factoryCalibration(int btn){
delay(100);
if (!btn){
printLine2("Set Calibration?");
printLineF2(F("Set Calibration?"));
return 0;
}
@@ -287,7 +447,7 @@ int factoryCalibration(int btn){
//turn off the second local oscillator and the bfo
si5351_set_calibration(calibration);
startTx(TX_CW);
startTx(TX_CW, 1);
si5351bx_setfreq(2, 10000000l);
strcpy(b, "#1 10 MHz cal:");
@@ -324,10 +484,10 @@ int factoryCalibration(int btn){
keyDown = 0;
stopTx();
printLine2("Calibration set!");
printLineF2(F("Calibration set!"));
EEPROM.put(MASTER_CAL, calibration);
initOscillators();
setFrequency(frequency);
setFrequency(frequency);
updateDisplay();
while(btnDown())
@@ -340,13 +500,13 @@ int menuSetupCalibration(int btn){
int32_t prev_calibration;
if (!btn){
printLine2("Set Calibration?");
printLineF2(F("Set Calibration?"));
return 0;
}
printLine1("Set to Zero-beat,");
printLine2("press PTT to save");
delay(1000);
printLineF1(F("Set to Zero-beat,"));
printLineF2(F("press PTT to save"));
delay_background(1000, 0);
prev_calibration = calibration;
calibration = 0;
@@ -385,19 +545,18 @@ int menuSetupCalibration(int btn){
//save the setting
if (digitalRead(PTT) == LOW){
printLine1("Calibration set!");
printLine2("Set Carrier now");
printLineF1(F("Calibration set!"));
printLineF2(F("Set Carrier now"));
EEPROM.put(MASTER_CAL, calibration);
delay(2000);
delay_background(2000, 0);
}
else
calibration = prev_calibration;
printLine2("");
initOscillators();
//si5351_set_calibration(calibration);
setFrequency(frequency);
updateDisplay();
printLine2ClearAndUpdate();
menuOn = 0;
}
@@ -422,14 +581,14 @@ void menuSetupCarrier(int btn){
unsigned long prevCarrier;
if (!btn){
printLine2("Set the BFO");
printLineF2(F("Set the BFO"));
return;
}
prevCarrier = usbCarrier;
printLine1("Tune to best Signal");
printLine2("PTT to confirm. ");
delay(1000);
printLineF1(F("Tune to best Signal"));
printLineF1(F("PTT to confirm. "));
delay_background(1000, 0);
usbCarrier = 11995000l;
si5351bx_setfreq(0, usbCarrier);
@@ -449,23 +608,23 @@ void menuSetupCarrier(int btn){
si5351bx_setfreq(0, usbCarrier);
printCarrierFreq(usbCarrier);
Check_Cat(0); //To prevent disconnections
delay(100);
}
//save the setting
if (digitalRead(PTT) == LOW){
printLine2("Carrier set! ");
printLineF2(F("Carrier set!"));
EEPROM.put(USB_CAL, usbCarrier);
delay(1000);
delay_background(1000, 0);
}
else
usbCarrier = prevCarrier;
si5351bx_setfreq(0, usbCarrier);
setFrequency(frequency);
updateDisplay();
printLine2("");
printLine2ClearAndUpdate();
menuOn = 0;
}
@@ -474,18 +633,18 @@ void menuSetupCwTone(int btn){
int prev_sideTone;
if (!btn){
printLine2("Change CW Tone");
printLineF2(F("Change CW Tone"));
return;
}
prev_sideTone = sideTone;
printLine1("Tune CW tone");
printLine2("PTT to confirm. ");
delay(1000);
printLineF1(F("Tune CW tone"));
printLineF2(F("PTT to confirm."));
delay_background(1000, 0);
tone(CW_TONE, sideTone);
//disable all clock 1 and clock 2
while (digitalRead(PTT) == LOW || !btnDown())
while (digitalRead(PTT) == HIGH && !btnDown())
{
knob = enc_read();
@@ -501,30 +660,58 @@ void menuSetupCwTone(int btn){
printLine2(b);
delay(100);
Check_Cat(0); //To prevent disconnections
}
noTone(CW_TONE);
//save the setting
if (digitalRead(PTT) == LOW){
printLine2("Sidetone set! ");
printLineF2(F("Sidetone set!"));
EEPROM.put(CW_SIDETONE, usbCarrier);
delay(2000);
delay_background(2000, 0);
}
else
sideTone = prev_sideTone;
printLine2("");
updateDisplay();
printLine2ClearAndUpdate();
menuOn = 0;
}
void setDialLock(byte tmpLock, byte fromMode) {
isDialLock = tmpLock;
if (fromMode == 2 || fromMode == 3) return;
if (isDialLock == 1)
printLineF2(F("Dial Lock ON"));
else
printLineF2(F("Dial Lock OFF"));
delay_background(1000, 0);
printLine2ClearAndUpdate();
}
int btnDownTimeCount;
void doMenu(){
int select=0, i,btnState;
//wait for the button to be raised up
while(btnDown())
delay(50);
delay(50); //debounce
//for DialLock On/Off function
btnDownTimeCount = 0;
//wait for the button to be raised up
while(btnDown()){
delay(50);
Check_Cat(0); //To prevent disconnections
//btnDownTimeCount++;
//check long time Down Button -> 3 Second
if (btnDownTimeCount++ > (2000 / 50)) {
setDialLock(isDialLock == 1 ? 0 : 1, 0); //Reverse Dialo lock
return;
}
}
delay(50); //debounce
menuOn = 2;
while (menuOn){
@@ -532,9 +719,9 @@ void doMenu(){
btnState = btnDown();
if (i > 0){
if (modeCalibrate && select + i < 110)
if (modeCalibrate && select + i < 150)
select += i;
if (!modeCalibrate && select + i < 70)
if (!modeCalibrate && select + i < 80)
select += i;
}
if (i < 0 && select - i >= 0)
@@ -551,22 +738,34 @@ void doMenu(){
else if (select < 50)
menuCWSpeed(btnState);
else if (select < 60)
menuCWAutoKey(btnState);
else if (select < 70)
menuSetup(btnState);
else if (select < 70 && !modeCalibrate)
else if (select < 80 && !modeCalibrate)
menuExit(btnState);
else if (select < 80 && modeCalibrate)
menuSetupCalibration(btnState); //crystal
else if (select < 90 && modeCalibrate)
menuSetupCarrier(btnState); //lsb
menuSetupCalibration(btnState); //crystal
else if (select < 100 && modeCalibrate)
menuSetupCwTone(btnState);
menuSetupCarrier(btnState); //lsb
else if (select < 110 && modeCalibrate)
menuExit(btnState);
menuSetupCwTone(btnState);
else if (select < 120 && modeCalibrate)
menuSetupCwDelay(btnState);
else if (select < 130 && modeCalibrate)
menuSetupTXCWInterval(btnState);
else if (select < 140 && modeCalibrate)
menuTxOnOff(btnState);
else if (select < 150 && modeCalibrate)
menuExit(btnState);
Check_Cat(0); //To prevent disconnections
}
//debounce the button
while(btnDown())
while(btnDown()){
delay(50);
Check_Cat(0); //To prevent disconnections
}
delay(50);
}