From 70fc6aeba87129db4f1465b7946a228a305eccd1 Mon Sep 17 00:00:00 2001 From: phdlee Date: Mon, 7 May 2018 13:56:46 +0900 Subject: [PATCH] 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 //=====================================================