From 70fc6aeba87129db4f1465b7946a228a305eccd1 Mon Sep 17 00:00:00 2001 From: phdlee Date: Mon, 7 May 2018 13:56:46 +0900 Subject: [PATCH 1/4] Add Factory Recovery function --- ubitx_20/ubitx.h | 5 +++-- ubitx_20/ubitx_20.ino | 50 +++++++++++++++++++++++++++++++++++++++-- ubitx_20/ubitx_eemap.h | 4 +++- ubitx_20/ubitx_menu.ino | 3 +-- 4 files changed, 55 insertions(+), 7 deletions(-) diff --git a/ubitx_20/ubitx.h b/ubitx_20/ubitx.h index 09334e5..09153f1 100644 --- a/ubitx_20/ubitx.h +++ b/ubitx_20/ubitx.h @@ -24,10 +24,10 @@ //============================================================================== //Depending on the type of LCD mounted on the uBITX, uncomment one of the options below. //You must select only one. -#define UBITX_DISPLAY_LCD1602P //LCD mounted on unmodified uBITX +//#define UBITX_DISPLAY_LCD1602P //LCD mounted on unmodified uBITX //#define UBITX_DISPLAY_LCD1602I //I2C type 16 x 02 LCD //#define UBITX_DISPLAY_LCD1602I_DUAL -//#define UBITX_DISPLAY_LCD2004P //24 x 04 LCD (Parallel) +#define UBITX_DISPLAY_LCD2004P //24 x 04 LCD (Parallel) //#define UBITX_DISPLAY_LCD2004I //I2C type 24 x 04 LCD #define I2C_LCD_MASTER_ADDRESS_DEFAULT 0x3F //0x27 //DEFAULT, if Set I2C Address by uBITX Manager, read from EEProm @@ -37,6 +37,7 @@ //#define EXTEND_KEY_GROUP2 //Numeric (0~9), Point(.), Enter //Not supported in Version 1.0x //#define ENABLE_FACTORYALIGN +#define FACTORY_RECOVERY_BOOTUP //Whether to enter Factory Recovery mode by pressing FKey and turning on power #define ENABLE_ADCMONITOR //Starting with Version 1.07, you can read ADC values directly from uBITX Manager. So this function is not necessary. extern byte I2C_LCD_MASTER_ADDRESS; //0x27 //if Set I2C Address by uBITX Manager, read from EEProm diff --git a/ubitx_20/ubitx_20.ino b/ubitx_20/ubitx_20.ino index 764e52d..1199d97 100644 --- a/ubitx_20/ubitx_20.ino +++ b/ubitx_20/ubitx_20.ino @@ -6,8 +6,8 @@ // 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. -#define FIRMWARE_VERSION_INFO F("+v1.074") -#define FIRMWARE_VERSION_NUM 0x02 //1st Complete Project : 1 (Version 1.061), 2st Project : 2 +#define FIRMWARE_VERSION_INFO F("+v1.075") +#define FIRMWARE_VERSION_NUM 0x03 //1st Complete Project : 1 (Version 1.061), 2st Project : 2 /** Cat Suppoort uBITX CEC Version @@ -941,6 +941,15 @@ void initSettings(){ if (EEPROM.read(VERSION_ADDRESS) != FIRMWARE_VERSION_NUM) EEPROM.write(VERSION_ADDRESS, FIRMWARE_VERSION_NUM); + //Backup Calibration Setting from Factory Setup + //Check Factory Setting Backup Y/N + if (EEPROM.read(FACTORY_BACKUP_YN) != 0x13) { + EEPROM.write(FACTORY_BACKUP_YN, 0x13); //Set Backup Y/N + + for (unsigned int i = 0; i < 32; i++) //factory setting range + EEPROM.write(FACTORY_VALUES + i, EEPROM.read(i)); //0~31 => 65~96 + } + EEPROM.get(CW_CAL, cwmCarrier); //for Save VFO_A_MODE to eeprom @@ -1216,6 +1225,37 @@ void initPorts(){ digitalWrite(CW_KEY, 0); } +//Recovery Factory Setting Values +void factory_Recovery() +{ + if (EEPROM.read(FACTORY_BACKUP_YN) != 0x13) + return; + + printLineF2(F("FactoryRecovery?")); + delay(2000); + if (!btnDown()) + return; + + printLineF2(F("IF you continue")); + printLineF1(F("release the key")); + delay(2000); + if (btnDown()) + return; + + printLineF1(F("Press Key PTT")); + delay(2000); + if (digitalRead(PTT) == 0) + { + for (unsigned int i = 0; i < 32; i++) //factory setting range + EEPROM.write(i, EEPROM.read(FACTORY_VALUES + i)); //65~96 => 0~31 + + //printLineF2(F("CompleteRecovery")); + printLineF1(F("Power Reset!")); + while(1); //Hold + } +} + + void setup() { /* @@ -1266,6 +1306,11 @@ void setup() initPorts(); +#ifdef FACTORY_RECOVERY_BOOTUP + if (btnDown()) + factory_Recovery(); +#endif + byteToMode(vfoA_mode, 0); initOscillators(); @@ -1278,6 +1323,7 @@ void setup() if (btnDown()) factory_alignment(); #endif + } //Auto save Frequency and Mode with Protected eeprom life by KD8CEC diff --git a/ubitx_20/ubitx_eemap.h b/ubitx_20/ubitx_eemap.h index 200ba44..e799187 100644 --- a/ubitx_20/ubitx_eemap.h +++ b/ubitx_20/ubitx_eemap.h @@ -44,7 +44,9 @@ // (Enabled if the EEProm address is insufficient) // Address : 64 ~ 100 //============================================================================== -#define RESERVE_FOR_FACTORY2 64 +#define RESERVE_FOR_FACTORY2 64 //use Factory backup from Version 1.075 +#define FACTORY_BACKUP_YN 64 //Check Backup //Magic : 0x13 +#define FACTORY_VALUES 65 //65 ~ 65 + 32 //============================================================================== // KD8CEC EEPROM MAP diff --git a/ubitx_20/ubitx_menu.ino b/ubitx_20/ubitx_menu.ino index 2af9627..79f4ad7 100644 --- a/ubitx_20/ubitx_menu.ino +++ b/ubitx_20/ubitx_menu.ino @@ -1106,7 +1106,6 @@ void menuSetupKeyType(int btn){ } */ - printLineF2(F("CW Key Type set!")); cwKeyType = selectedKeyType; EEPROM.put(CW_KEY_TYPE, cwKeyType); @@ -1127,7 +1126,7 @@ void menuSetupKeyType(int btn){ } //===================================================== -//END OF STANDARD Tune Setup for reduce Program Memory +//END OF STANDARD Set by Knob for reduce Program Memory //===================================================== From 76d5c362d05911ca13013aec991d4d36cad2eb48 Mon Sep 17 00:00:00 2001 From: phdlee Date: Mon, 7 May 2018 14:08:22 +0900 Subject: [PATCH 2/4] complete test for Factory Recovery --- ubitx_20/ubitx.h | 4 ++-- ubitx_20/ubitx_20.ino | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ubitx_20/ubitx.h b/ubitx_20/ubitx.h index 09153f1..f60095d 100644 --- a/ubitx_20/ubitx.h +++ b/ubitx_20/ubitx.h @@ -24,10 +24,10 @@ //============================================================================== //Depending on the type of LCD mounted on the uBITX, uncomment one of the options below. //You must select only one. -//#define UBITX_DISPLAY_LCD1602P //LCD mounted on unmodified uBITX +#define UBITX_DISPLAY_LCD1602P //LCD mounted on unmodified uBITX //#define UBITX_DISPLAY_LCD1602I //I2C type 16 x 02 LCD //#define UBITX_DISPLAY_LCD1602I_DUAL -#define UBITX_DISPLAY_LCD2004P //24 x 04 LCD (Parallel) +//#define UBITX_DISPLAY_LCD2004P //24 x 04 LCD (Parallel) //#define UBITX_DISPLAY_LCD2004I //I2C type 24 x 04 LCD #define I2C_LCD_MASTER_ADDRESS_DEFAULT 0x3F //0x27 //DEFAULT, if Set I2C Address by uBITX Manager, read from EEProm diff --git a/ubitx_20/ubitx_20.ino b/ubitx_20/ubitx_20.ino index 1199d97..487faf4 100644 --- a/ubitx_20/ubitx_20.ino +++ b/ubitx_20/ubitx_20.ino @@ -1230,8 +1230,11 @@ void factory_Recovery() { if (EEPROM.read(FACTORY_BACKUP_YN) != 0x13) return; - - printLineF2(F("FactoryRecovery?")); + + if (digitalRead(PTT) == 0) //Do not proceed if PTT is pressed to prevent malfunction. + return; + + printLineF2(F("Factory Recovery")); delay(2000); if (!btnDown()) return; From 6a2369bc27872b96c4b74c05e237711a4d33783e Mon Sep 17 00:00:00 2001 From: phdlee Date: Wed, 9 May 2018 16:53:40 +0900 Subject: [PATCH 3/4] Fixed Band Select Bug --- ubitx_20/ubitx_20.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ubitx_20/ubitx_20.ino b/ubitx_20/ubitx_20.ino index 487faf4..216d34c 100644 --- a/ubitx_20/ubitx_20.ino +++ b/ubitx_20/ubitx_20.ino @@ -254,8 +254,8 @@ void setNextHamBandFreq(unsigned long f, char moveDirection) if ((resultFreq / 1000) < hamBandRange[(unsigned char)findedIndex][0] || (resultFreq / 1000) > hamBandRange[(unsigned char)findedIndex][1]) resultFreq = (unsigned long)(hamBandRange[(unsigned char)findedIndex][0]) * 1000; - setFrequency(resultFreq); byteToMode(loadMode, 1); + setFrequency(resultFreq); } void saveBandFreqByIndex(unsigned long f, unsigned long mode, char bandIndex) { From 65d21aba77fab333c15d08286497aafc4c8c0a9a Mon Sep 17 00:00:00 2001 From: phdlee Date: Wed, 9 May 2018 16:53:49 +0900 Subject: [PATCH 4/4] Fixed Band Select Bug --- VersionInfo.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VersionInfo.txt b/VersionInfo.txt index 581a34a..4ab4930 100644 --- a/VersionInfo.txt +++ b/VersionInfo.txt @@ -10,7 +10,7 @@ I am getting a lot of hints from the group. Ian KD8CEC kd8cec@gmail.com ================================================================== -Files modified in Version1.074 Beta +Files modified in Version1.075 Beta 1.Delted Files. @@ -25,6 +25,6 @@ Files modified in Version1.074 Beta - ubitx_lcd_1602.ino - ubitx_lcd_1602Dual.ino - ubitx_lcd_2004.ino - -ubitx_wspr.ino + - ubitx_wspr.ino \ No newline at end of file