From d229a10092b39a3f752ed5b472a42f79908c1e91 Mon Sep 17 00:00:00 2001 From: phdlee Date: Fri, 2 Feb 2018 20:49:00 +0900 Subject: [PATCH] change tune step size and fixed bug --- ubitx_20/ubitx_20.ino | 24 ++++++++++++++++++++---- ubitx_20/ubitx_menu.ino | 2 +- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/ubitx_20/ubitx_20.ino b/ubitx_20/ubitx_20.ino index 1ba7d95..098e2af 100644 --- a/ubitx_20/ubitx_20.ino +++ b/ubitx_20/ubitx_20.ino @@ -160,7 +160,8 @@ int count = 0; //to generally count ticks, loops, etc #define TX_TUNE_TYPE 261 // #define HAM_BAND_RANGE 262 //FROM (2BYTE) TO (2BYTE) * 10 = 40byte #define HAM_BAND_FREQS 302 //40, 1 BAND = 4Byte most bit is mode -#define TUNING_STEP 342 //TUNING STEP * 6 (index 1 + STEPS 5) +#define TUNING_STEP 342 //TUNING STEP * 6 (index 1 + STEPS 5) //1STEP : + //for reduce cw key error, eeprom address #define CW_ADC_MOST_BIT1 348 //most 2bits of DOT_TO , DOT_FROM, ST_TO, ST_FROM @@ -260,7 +261,7 @@ byte sideToneSub = 0; //DialLock byte isDialLock = 0; //000000[0]vfoB [0]vfoA 0Bit : A, 1Bit : B byte isTxType = 0; //000000[0 - isSplit] [0 - isTXStop] -byte arTuneStep[5]; +long arTuneStep[5]; byte tuneStepIndex; //default Value 0, start Offset is 0 because of check new user byte displayOption1 = 0; @@ -806,6 +807,21 @@ void storeFrequencyAndMode(byte saveType) } } +unsigned int byteToSteps(byte srcByte) { + byte powerVal = (byte)(srcByte >> 6); + unsigned int baseVal = srcByte & 0x3F; + + if (powerVal == 1) + return baseVal * 10; + else if (powerVal == 2) + return baseVal * 100; + else if (powerVal == 3) + return baseVal * 1000; + else + return baseVal; +} + + /** * The settings are read from EEPROM. The first time around, the values may not be * present or out of range, in this case, some intelligent defaults are copied into the @@ -926,8 +942,8 @@ void initSettings(){ findedValidValueCount = 0; EEPROM.get(TUNING_STEP, tuneStepIndex); for (byte i = 0; i < 5; i++) { - arTuneStep[i] = EEPROM.read(TUNING_STEP + i + 1); - if (arTuneStep[i] >= 1 && arTuneStep[i] < 251) //Maximum 250 for check valid Value + arTuneStep[i] = byteToSteps(EEPROM.read(TUNING_STEP + i + 1)); + if (arTuneStep[i] >= 1 && arTuneStep[i] <= 60000) //Maximum 650 for check valid Value findedValidValueCount++; } diff --git a/ubitx_20/ubitx_menu.ino b/ubitx_20/ubitx_menu.ino index 0e64dd3..298701a 100644 --- a/ubitx_20/ubitx_menu.ino +++ b/ubitx_20/ubitx_menu.ino @@ -1211,7 +1211,7 @@ void menuSetupCwTone(int btn){ //save the setting if (digitalRead(PTT) == LOW){ printLineF2(F("Sidetone set!")); - EEPROM.put(CW_SIDETONE, usbCarrier); + EEPROM.put(CW_SIDETONE, sideTone); delay_background(2000, 0); } else