diff --git a/Makefile b/Makefile index cf77eb5..bc3d846 100644 --- a/Makefile +++ b/Makefile @@ -45,6 +45,7 @@ ENABLE_FEAT_F4HWN_SCREENSHOT ?= 0 ENABLE_FEAT_F4HWN_SPECTRUM ?= 1 ENABLE_FEAT_F4HWN_RX_TX_TIMER ?= 1 ENABLE_FEAT_F4HWN_CHARGING_C ?= 1 +ENABLE_FEAT_F4HWN_SLEEP ?= 1 ENABLE_FEAT_F4HWN_PMR ?= 0 ENABLE_FEAT_F4HWN_GMRS_FRS_MURS ?= 0 ENABLE_FEAT_F4HWN_CA ?= 1 @@ -217,7 +218,7 @@ ifeq ($(ENABLE_FEAT_F4HWN),1) VERSION_STRING_1 ?= v0.22 AUTHOR_STRING_2 ?= F4HWN - VERSION_STRING_2 ?= v3.3 + VERSION_STRING_2 ?= v3.4 AUTHOR_STRING ?= $(AUTHOR_STRING_1)+$(AUTHOR_STRING_2) VERSION_STRING ?= $(VERSION_STRING_2) @@ -418,6 +419,9 @@ endif ifeq ($(ENABLE_FEAT_F4HWN_CHARGING_C),1) CFLAGS += -DENABLE_FEAT_F4HWN_CHARGING_C endif +ifeq ($(ENABLE_FEAT_F4HWN_SLEEP),1) + CFLAGS += -DENABLE_FEAT_F4HWN_SLEEP +endif ifeq ($(ENABLE_FEAT_F4HWN_PMR),1) CFLAGS += -DENABLE_FEAT_F4HWN_PMR endif diff --git a/README.md b/README.md index ccf4c8e..f50781b 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Anyway, have fun. # Donations -Special thanks to Jean-Cyrille F6IWW, Fabrice 14RC123, David F4BPP, Olivier 14RC206, Frédéric F4ESO, Stéphane F5LGW, Jorge Ornelas, Laurent F4AXK, Christophe Morel, Clayton W0LED, Pierre Antoine F6FWB, Jean-Claude 14FRS3306, Thierry F4GVO, Eric F1NOU, PricelessToolkit, Ady M6NYJ, Tom McGovern, Joseph Roth, Pierre-Yves Colin, Frank DJ7FG, Marcel Testaz, Brian Frobisher, Yannick F4JFO, Paolo Bussola, Dirk DL8DF, Szőke Levente and Bernard-Michel Herrera for their [donations](https://www.paypal.com/paypalme/F4HWN). That’s so kind of them. Thanks so much 🙏🏻 +Special thanks to Jean-Cyrille F6IWW, Fabrice 14RC123, David F4BPP, Olivier 14RC206, Frédéric F4ESO, Stéphane F5LGW, Jorge Ornelas, Laurent F4AXK, Christophe Morel, Clayton W0LED, Pierre Antoine F6FWB, Jean-Claude 14FRS3306, Thierry F4GVO, Eric F1NOU, PricelessToolkit, Ady M6NYJ, Tom McGovern, Joseph Roth, Pierre-Yves Colin, Frank DJ7FG, Marcel Testaz, Brian Frobisher, Yannick F4JFO, Paolo Bussola, Dirk DL8DF, Szőke Levente, Bernard-Michel Herrera, Jérôme Saintespes and Paul Davies for their [donations](https://www.paypal.com/paypalme/F4HWN). That’s so kind of them. Thanks so much 🙏🏻 ## Table of Contents @@ -82,11 +82,13 @@ Special thanks to Jean-Cyrille F6IWW, Fabrice 14RC123, David F4BPP, Olivier 14RC * add SetLck menu to set what is locked (Keys or Keys + PTT), * add SetGui menu to set font size on the VFO baseline (Classic or Tiny), * add TXLock menu to open TX on channel, - * add SetTmr menu to set RX and TX timers (Off or On) + * add SetTmr menu to set RX and TX timers (Off or On), + * add SetOff menu to set the delay before the transceiver goes into deep sleep (Off or 1 minute to 2 hours), * rename BatVol menu (52/63) to SysInf, which displays the firmware version in addition to the battery status, * improve PonMsg menu, * improve BackLt menu, * improve TxTOut menu, + * improve ScnRev menu (CARRIER FAST, CARRIER SLOW, STOP, TIMEOUT from 5 secondes to 2 minutes) * add HAM CA F Lock band (for Canadian zone), * remove blink and SOS functionality, * remove AM Fix menu (AM Fix is ENABLED by default), @@ -132,6 +134,7 @@ Special thanks to Jean-Cyrille F6IWW, Fabrice 14RC123, David F4BPP, Olivier 14RC * enabled AIR COPY * disabled ENABLE_DTMF_CALLING, * disabled SCRAMBLER, +* remove 200Tx, 350Tx and 500Tx, * unlock TX on all bands needs only to be repeat 3 times, * code refactoring and many memory optimization, * and more... diff --git a/app/app.c b/app/app.c index 277b885..e8e4a75 100644 --- a/app/app.c +++ b/app/app.c @@ -44,6 +44,9 @@ #include "audio.h" #include "board.h" #include "bsp/dp32g030/gpio.h" +#ifdef ENABLE_FEAT_F4HWN_SLEEP + #include "bsp/dp32g030/pwmplus.h" +#endif #include "driver/backlight.h" #ifdef ENABLE_FMRADIO #include "driver/bk1080.h" @@ -380,6 +383,8 @@ Skip: if (gScanStateDir != SCAN_OFF) { + + /* switch (gEeprom.SCAN_RESUME_MODE) { case SCAN_RESUME_TO: @@ -394,6 +399,41 @@ Skip: CHFRSCANNER_Stop(); break; } + */ + + if(gEeprom.SCAN_RESUME_MODE < 2) + { + gScanPauseDelayIn_10ms = scan_pause_delay_in_6_10ms + (scan_pause_delay_in_6_10ms * 24 * gEeprom.SCAN_RESUME_MODE); + gScheduleScanListen = false; + + } + else if(gEeprom.SCAN_RESUME_MODE == 2) + { + CHFRSCANNER_Stop(); + } + + /* + switch (gEeprom.SCAN_RESUME_MODE) + { + case 0: + gScanPauseDelayIn_10ms = scan_pause_delay_in_6_10ms; + gScheduleScanListen = false; + break; + + case 1: + gScanPauseDelayIn_10ms = scan_pause_delay_in_2_10ms * 5; + gScheduleScanListen = false; + break; + + case 26: + CHFRSCANNER_Stop(); + break; + + //default: + // gScanPauseDelayIn_10ms = scan_pause_delay_in_5_10ms * (gEeprom.SCAN_RESUME_MODE - 1) * 5; + // break; + } + */ } break; @@ -1071,7 +1111,18 @@ void APP_Update(void) { // dual watch mode off or scanning or rssi update request // go back to sleep +#ifdef ENABLE_FEAT_F4HWN_SLEEP + if(gWakeUp) + { + gPowerSave_10ms = 1000; // Why ? Why not :) 10s + } + else + { + gPowerSave_10ms = gEeprom.BATTERY_SAVE * 10; + } +#else gPowerSave_10ms = gEeprom.BATTERY_SAVE * 10; +#endif gRxIdleMode = true; goToSleep = false; @@ -1530,6 +1581,47 @@ void APP_TimeSlice500ms(void) BACKLIGHT_TurnOff(); } +#ifdef ENABLE_FEAT_F4HWN_SLEEP + if (gSleepModeCountdown_500ms == gSetting_set_off * 120 && gWakeUp) { + ST7565_Init(); + BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1_RED, false); + gPowerSave_10ms = gEeprom.BATTERY_SAVE * 10; + gWakeUp = false; + } + + if(gCurrentFunction != FUNCTION_TRANSMIT && !FUNCTION_IsRx()) + { + if (gSleepModeCountdown_500ms > 0 && --gSleepModeCountdown_500ms == 0) { + gBacklightCountdown_500ms = 0; + gPowerSave_10ms = 1; + gWakeUp = true; + PWM_PLUS0_CH0_COMP = 0; + ST7565_ShutDown(); + } + else if(gSleepModeCountdown_500ms < 60 && gSetting_set_off != 0) + { + if(gSleepModeCountdown_500ms % 2 == 0) + { + PWM_PLUS0_CH0_COMP = 0; + } + else + { + PWM_PLUS0_CH0_COMP = value[gEeprom.BACKLIGHT_MAX] * 4; // Max brightness + } + } + } + else + { + gSleepModeCountdown_500ms = gSetting_set_off * 120; + } + + if (gWakeUp) { + static bool swap = true; + swap = !swap; // Alterne l'état à chaque exécution + BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1_RED, swap); + } +#endif + if (gReducedService) { BOARD_ADC_GetBatteryInfo(&gBatteryCurrentVoltage, &gBatteryCurrent); diff --git a/app/chFrScanner.c b/app/chFrScanner.c index bc00c1f..c7966f5 100644 --- a/app/chFrScanner.c +++ b/app/chFrScanner.c @@ -102,6 +102,36 @@ void CHFRSCANNER_ContinueScanning(void) void CHFRSCANNER_Found(void) { + if (gEeprom.SCAN_RESUME_MODE > 2) { + if (!gScanPauseMode) { + gScanPauseDelayIn_10ms = scan_pause_delay_in_5_10ms * (gEeprom.SCAN_RESUME_MODE - 2) * 5; + gScanPauseMode = true; + } + } else { + gScanPauseDelayIn_10ms = 0; + } + + // gScheduleScanListen is always false... + gScheduleScanListen = false; + + /* + if(gEeprom.SCAN_RESUME_MODE > 1 && gEeprom.SCAN_RESUME_MODE < 26) + { + if (!gScanPauseMode) + { + gScanPauseDelayIn_10ms = scan_pause_delay_in_5_10ms * (gEeprom.SCAN_RESUME_MODE - 1) * 5; + gScheduleScanListen = false; + gScanPauseMode = true; + } + } + else + { + gScanPauseDelayIn_10ms = 0; + gScheduleScanListen = false; + } + */ + + /* switch (gEeprom.SCAN_RESUME_MODE) { case SCAN_RESUME_TO: @@ -119,6 +149,7 @@ void CHFRSCANNER_Found(void) gScheduleScanListen = false; break; } + */ #ifdef ENABLE_FEAT_F4HWN lastFoundFrqOrChanOld = lastFoundFrqOrChan; diff --git a/app/menu.c b/app/menu.c index 52987c9..17ae392 100644 --- a/app/menu.c +++ b/app/menu.c @@ -176,7 +176,7 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) case MENU_SC_REV: //*pMin = 0; - *pMax = ARRAY_SIZE(gSubMenu_SC_REV) - 1; + *pMax = 26; break; case MENU_ROGER: @@ -248,9 +248,11 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) #ifdef ENABLE_NOAA case MENU_NOAA_S: #endif +#ifndef ENABLE_FEAT_F4HWN case MENU_350TX: case MENU_200TX: case MENU_500TX: +#endif case MENU_350EN: #ifndef ENABLE_FEAT_F4HWN case MENU_SCREN: @@ -376,6 +378,12 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) *pMax = gSubMenu_SIDEFUNCTIONS_size-1; break; +#ifdef ENABLE_FEAT_F4HWN_SLEEP + case MENU_SET_OFF: + *pMax = 120; + break; +#endif + #ifdef ENABLE_FEAT_F4HWN case MENU_SET_PWR: *pMax = ARRAY_SIZE(gSubMenu_SET_PWR) - 1; @@ -789,9 +797,11 @@ void MENU_AcceptSetting(void) SETTINGS_FactoryReset(gSubMenuSelection); return; +#ifndef ENABLE_FEAT_F4HWN case MENU_350TX: gSetting_350TX = gSubMenuSelection; break; +#endif case MENU_F_LOCK: { if(gSubMenuSelection == F_LOCK_NONE) { // select 10 times to enable @@ -809,6 +819,7 @@ void MENU_AcceptSetting(void) gSetting_F_LOCK = gSubMenuSelection; break; } +#ifndef ENABLE_FEAT_F4HWN case MENU_200TX: gSetting_200TX = gSubMenuSelection; break; @@ -816,13 +827,12 @@ void MENU_AcceptSetting(void) case MENU_500TX: gSetting_500TX = gSubMenuSelection; break; - +#endif case MENU_350EN: gSetting_350EN = gSubMenuSelection; gVfoConfigureMode = VFO_CONFIGURE_RELOAD; gFlagResetVfos = true; break; - #ifndef ENABLE_FEAT_F4HWN case MENU_SCREN: gSetting_ScrambleEnable = gSubMenuSelection; @@ -868,6 +878,12 @@ void MENU_AcceptSetting(void) } break; +#ifdef ENABLE_FEAT_F4HWN_SLEEP + case MENU_SET_OFF: + gSetting_set_off = gSubMenuSelection; + break; +#endif + #ifdef ENABLE_FEAT_F4HWN case MENU_SET_PWR: gSetting_set_pwr = gSubMenuSelection; @@ -1230,14 +1246,17 @@ void MENU_ShowCurrentSetting(void) #endif break; +#ifndef ENABLE_FEAT_F4HWN case MENU_350TX: gSubMenuSelection = gSetting_350TX; break; +#endif case MENU_F_LOCK: gSubMenuSelection = gSetting_F_LOCK; break; +#ifndef ENABLE_FEAT_F4HWN case MENU_200TX: gSubMenuSelection = gSetting_200TX; break; @@ -1246,6 +1265,7 @@ void MENU_ShowCurrentSetting(void) gSubMenuSelection = gSetting_500TX; break; +#endif case MENU_350EN: gSubMenuSelection = gSetting_350EN; break; @@ -1294,6 +1314,12 @@ void MENU_ShowCurrentSetting(void) break; } +#ifdef ENABLE_FEAT_F4HWN_SLEEP + case MENU_SET_OFF: + gSubMenuSelection = gSetting_set_off; + break; +#endif + #ifdef ENABLE_FEAT_F4HWN case MENU_SET_PWR: gSubMenuSelection = gSetting_set_pwr; diff --git a/archive/f4hwn.bandscope.packed.v3.4.bin b/archive/f4hwn.bandscope.packed.v3.4.bin new file mode 100644 index 0000000..683e0cc Binary files /dev/null and b/archive/f4hwn.bandscope.packed.v3.4.bin differ diff --git a/archive/f4hwn.broadcast.packed.v3.4.bin b/archive/f4hwn.broadcast.packed.v3.4.bin new file mode 100644 index 0000000..84e697a Binary files /dev/null and b/archive/f4hwn.broadcast.packed.v3.4.bin differ diff --git a/archive/f4hwn.voxless.packed.v3.4.bin b/archive/f4hwn.voxless.packed.v3.4.bin new file mode 100644 index 0000000..f928f82 Binary files /dev/null and b/archive/f4hwn.voxless.packed.v3.4.bin differ diff --git a/driver/backlight.c b/driver/backlight.c index 8bac46a..997b388 100644 --- a/driver/backlight.c +++ b/driver/backlight.c @@ -31,6 +31,14 @@ uint16_t gBacklightCountdown_500ms = 0; bool backlightOn; +#ifdef ENABLE_FEAT_F4HWN + const uint8_t value[] = {0, 3, 6, 9, 15, 24, 38, 62, 100, 159, 255}; +#endif + +#ifdef ENABLE_FEAT_F4HWN_SLEEP + uint16_t gSleepModeCountdown_500ms = 0; +#endif + void BACKLIGHT_InitHardware() { // 48MHz / 94 / 1024 ~ 500Hz @@ -73,6 +81,10 @@ static void BACKLIGHT_Sound(void) void BACKLIGHT_TurnOn(void) { + #ifdef ENABLE_FEAT_F4HWN_SLEEP + gSleepModeCountdown_500ms = gSetting_set_off * 120; + #endif + #ifdef ENABLE_FEAT_F4HWN gBacklightBrightnessOld = BACKLIGHT_GetBrightness(); #endif @@ -146,8 +158,6 @@ static uint8_t currentBrightness; void BACKLIGHT_SetBrightness(uint8_t brigtness) { - const uint8_t value[] = {0, 3, 6, 9, 15, 24, 38, 62, 100, 159, 255}; - currentBrightness = brigtness; PWM_PLUS0_CH0_COMP = value[brigtness] * 4; //PWM_PLUS0_CH0_COMP = (1 << brigtness) - 1; diff --git a/driver/backlight.h b/driver/backlight.h index ae3b268..368ada7 100644 --- a/driver/backlight.h +++ b/driver/backlight.h @@ -23,6 +23,14 @@ extern uint16_t gBacklightCountdown_500ms; extern uint8_t gBacklightBrightness; +#ifdef ENABLE_FEAT_F4HWN + extern const uint8_t value[11]; +#endif + +#ifdef ENABLE_FEAT_F4HWN_SLEEP + extern uint16_t gSleepModeCountdown_500ms; +#endif + #ifdef ENABLE_BLMIN_TMP_OFF typedef enum { BLMIN_STAT_ON, diff --git a/driver/st7565.c b/driver/st7565.c index 4e008f3..fc3723d 100644 --- a/driver/st7565.c +++ b/driver/st7565.c @@ -256,6 +256,17 @@ void ST7565_Init(void) ST7565_FillScreen(0x00); } +#ifdef ENABLE_FEAT_F4HWN_SLEEP + void ST7565_ShutDown(void) + { + SPI_ToggleMasterMode(&SPI0->CR, false); + ST7565_WriteByte(ST7565_CMD_POWER_CIRCUIT | 0b000); // VB=0 VR=1 VF=1 + ST7565_WriteByte(ST7565_CMD_SET_START_LINE | 0); // line 0 + ST7565_WriteByte(ST7565_CMD_DISPLAY_ON_OFF | 0); // D=1 + SPI_ToggleMasterMode(&SPI0->CR, true); + } +#endif + void ST7565_FixInterfGlitch(void) { SPI_ToggleMasterMode(&SPI0->CR, false); diff --git a/driver/st7565.h b/driver/st7565.h index 80b43e1..d7e9e17 100644 --- a/driver/st7565.h +++ b/driver/st7565.h @@ -33,6 +33,9 @@ void ST7565_BlitLine(unsigned line); void ST7565_BlitStatusLine(void); void ST7565_FillScreen(uint8_t Value); void ST7565_Init(void); +#ifdef ENABLE_FEAT_F4HWN_SLEEP + void ST7565_ShutDown(void); +#endif void ST7565_FixInterfGlitch(void); void ST7565_HardwareReset(void); void ST7565_SelectColumnAndLine(uint8_t Column, uint8_t Line); diff --git a/frequencies.c b/frequencies.c index daad6ff..ac9953d 100644 --- a/frequencies.c +++ b/frequencies.c @@ -175,15 +175,23 @@ int32_t TX_freq_check(const uint32_t Frequency) if (Frequency >= frequencyBandTable[BAND3_137MHz].lower && Frequency < frequencyBandTable[BAND3_137MHz].upper) return 0; if (Frequency >= frequencyBandTable[BAND4_174MHz].lower && Frequency < frequencyBandTable[BAND4_174MHz].upper) + #ifndef ENABLE_FEAT_F4HWN if (gSetting_200TX) + #endif return 0; if (Frequency >= frequencyBandTable[BAND5_350MHz].lower && Frequency < frequencyBandTable[BAND5_350MHz].upper) + #ifndef ENABLE_FEAT_F4HWN if (gSetting_350TX && gSetting_350EN) + #else + if (gSetting_350EN) + #endif return 0; if (Frequency >= frequencyBandTable[BAND6_400MHz].lower && Frequency < frequencyBandTable[BAND6_400MHz].upper) return 0; if (Frequency >= frequencyBandTable[BAND7_470MHz].lower && Frequency <= 60000000) + #ifndef ENABLE_FEAT_F4HWN if (gSetting_500TX) + #endif return 0; break; diff --git a/functions.c b/functions.c index 7743005..abc8e61 100644 --- a/functions.c +++ b/functions.c @@ -118,7 +118,18 @@ void FUNCTION_Foreground(const FUNCTION_Type_t PreviousFunction) } void FUNCTION_PowerSave() { - gPowerSave_10ms = gEeprom.BATTERY_SAVE * 10; + #ifdef ENABLE_FEAT_F4HWN_SLEEP + if(gWakeUp) + { + gPowerSave_10ms = 1000; // Why ? Why not :) 10s + } + else + { + gPowerSave_10ms = gEeprom.BATTERY_SAVE * 10; + } + #else + gPowerSave_10ms = gEeprom.BATTERY_SAVE * 10; + #endif gPowerSaveCountdownExpired = false; gRxIdleMode = true; diff --git a/helper/boot.c b/helper/boot.c index 2739ce0..9f69735 100644 --- a/helper/boot.c +++ b/helper/boot.c @@ -102,6 +102,7 @@ void BOOT_ProcessMode(BOOT_Mode_t Mode) gAircopyState = AIRCOPY_READY; gEeprom.BACKLIGHT_TIME = 61; + gEeprom.KEY_LOCK = 0; GUI_SelectNextDisplay(DISPLAY_AIRCOPY); } diff --git a/main.c b/main.c index ec83117..3af6286 100644 --- a/main.c +++ b/main.c @@ -131,7 +131,11 @@ void Main(void) #ifndef ENABLE_VOX gMenuCursor = 64; // move to hidden section, fix me if change... !!! Remove VOX and Mic Bar #else - gMenuCursor = 66; // move to hidden section, fix me if change... !!! + #ifdef ENABLE_FEAT_F4HWN_SLEEP + gMenuCursor = 67; // move to hidden section, fix me if change... !!! + #else + gMenuCursor = 66; // move to hidden section, fix me if change... !!! + #endif #endif gSubMenuSelection = gSetting_F_LOCK; #endif diff --git a/misc.c b/misc.c index 6abf843..5b34b20 100644 --- a/misc.c +++ b/misc.c @@ -88,12 +88,18 @@ const uint32_t gDefaultAesKey[4] = {0x4AA5CC60, 0x0312CC5F, 0x const uint8_t gMicGain_dB2[5] = {3, 8, 16, 24, 31}; -bool gSetting_350TX; +#ifndef ENABLE_FEAT_F4HWN + bool gSetting_350TX; +#endif + #ifdef ENABLE_DTMF_CALLING bool gSetting_KILLED; #endif + +#ifndef ENABLE_FEAT_F4HWN bool gSetting_200TX; bool gSetting_500TX; +#endif bool gSetting_350EN; uint8_t gSetting_F_LOCK; bool gSetting_ScrambleEnable; @@ -104,6 +110,11 @@ enum BacklightOnRxTx_t gSetting_backlight_on_tx_rx; bool gSetting_AM_fix = true; #endif +#ifdef ENABLE_FEAT_F4HWN_SLEEP + uint8_t gSetting_set_off = 1; + bool gWakeUp = false; +#endif + #ifdef ENABLE_FEAT_F4HWN uint8_t gSetting_set_pwr = 1; bool gSetting_set_ptt = 0; diff --git a/misc.h b/misc.h index 854e6e4..a4d25b0 100644 --- a/misc.h +++ b/misc.h @@ -140,12 +140,19 @@ extern const uint16_t scan_pause_delay_in_7_10ms; extern const uint8_t gMicGain_dB2[5]; +#ifndef ENABLE_FEAT_F4HWN extern bool gSetting_350TX; +#endif + #ifdef ENABLE_DTMF_CALLING extern bool gSetting_KILLED; #endif + +#ifndef ENABLE_FEAT_F4HWN extern bool gSetting_200TX; extern bool gSetting_500TX; +#endif + extern bool gSetting_350EN; extern uint8_t gSetting_F_LOCK; extern bool gSetting_ScrambleEnable; @@ -156,6 +163,11 @@ extern enum BacklightOnRxTx_t gSetting_backlight_on_tx_rx; extern bool gSetting_AM_fix; #endif +#ifdef ENABLE_FEAT_F4HWN_SLEEP + extern uint8_t gSetting_set_off; + extern bool gWakeUp; +#endif + #ifdef ENABLE_FEAT_F4HWN extern uint8_t gSetting_set_pwr; extern bool gSetting_set_ptt; diff --git a/settings.c b/settings.c index 2145b5b..2f83125 100644 --- a/settings.c +++ b/settings.c @@ -119,7 +119,7 @@ void SETTINGS_InitEEPROM(void) gEeprom.KEY_1_LONG_PRESS_ACTION = (Data[2] < ACTION_OPT_LEN) ? Data[2] : ACTION_OPT_NONE; gEeprom.KEY_2_SHORT_PRESS_ACTION = (Data[3] < ACTION_OPT_LEN) ? Data[3] : ACTION_OPT_SCAN; gEeprom.KEY_2_LONG_PRESS_ACTION = (Data[4] < ACTION_OPT_LEN) ? Data[4] : ACTION_OPT_NONE; - gEeprom.SCAN_RESUME_MODE = (Data[5] < 3) ? Data[5] : SCAN_RESUME_CO; + gEeprom.SCAN_RESUME_MODE = (Data[5] < 27) ? Data[5] : 1; gEeprom.AUTO_KEYPAD_LOCK = (Data[6] < 2) ? Data[6] : false; #ifdef ENABLE_FEAT_F4HWN gEeprom.POWER_ON_DISPLAY_MODE = (Data[7] < 6) ? Data[7] : POWER_ON_DISPLAY_MODE_VOLTAGE; @@ -259,14 +259,17 @@ void SETTINGS_InitEEPROM(void) // 0F40..0F47 EEPROM_ReadBuffer(0x0F40, Data, 8); gSetting_F_LOCK = (Data[0] < F_LOCK_LEN) ? Data[0] : F_LOCK_DEF; +#ifndef ENABLE_FEAT_F4HWN gSetting_350TX = (Data[1] < 2) ? Data[1] : false; // was true +#endif #ifdef ENABLE_DTMF_CALLING gSetting_KILLED = (Data[2] < 2) ? Data[2] : false; #endif +#ifndef ENABLE_FEAT_F4HWN gSetting_200TX = (Data[3] < 2) ? Data[3] : false; gSetting_500TX = (Data[4] < 2) ? Data[4] : false; +#endif gSetting_350EN = (Data[5] < 2) ? Data[5] : true; - #ifdef ENABLE_FEAT_F4HWN gSetting_ScrambleEnable = false; #else @@ -346,7 +349,10 @@ void SETTINGS_InitEEPROM(void) int ctr_value = Data[5] & 0x0F; gSetting_set_ctr = (ctr_value > 0 && ctr_value < 16) ? ctr_value : 10; - gSetting_set_tmr = Data[4] & 1; + gSetting_set_tmr = Data[4] & 0x01; +#ifdef ENABLE_FEAT_F4HWN_SLEEP + gSetting_set_off = Data[4] >> 1; +#endif // Warning // Be aware, Data[3] is use by Spectrum @@ -688,14 +694,17 @@ void SETTINGS_SaveSettings(void) memset(State, 0xFF, sizeof(State)); State[0] = gSetting_F_LOCK; +#ifndef ENABLE_FEAT_F4HWN State[1] = gSetting_350TX; +#endif #ifdef ENABLE_DTMF_CALLING State[2] = gSetting_KILLED; #endif +#ifndef ENABLE_FEAT_F4HWN State[3] = gSetting_200TX; State[4] = gSetting_500TX; +#endif State[5] = gSetting_350EN; - #ifdef ENABLE_FEAT_F4HWN State[6] = false; #else @@ -740,7 +749,11 @@ void SETTINGS_SaveSettings(void) tmp = tmp | (1 << 3); */ +#ifdef ENABLE_FEAT_F4HWN_SLEEP + State[4] = (gSetting_set_off << 1) | (gSetting_set_tmr & 0x01); +#else State[4] = gSetting_set_tmr ? (1 << 0) : 0; +#endif tmp = (gSetting_set_inv << 0) | (gSetting_set_lck << 1) | diff --git a/settings.h b/settings.h index 410a857..cd6c365 100644 --- a/settings.h +++ b/settings.h @@ -59,11 +59,13 @@ enum TxLockModes_t { F_LOCK_LEN }; +/* enum { SCAN_RESUME_TO = 0, SCAN_RESUME_CO, SCAN_RESUME_SE }; +*/ enum { CROSS_BAND_OFF = 0, diff --git a/ui/menu.c b/ui/menu.c index e2a8b78..febc668 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -147,13 +147,18 @@ const t_menu_item MenuList[] = {"SetMet", MENU_SET_MET }, {"SetGui", MENU_SET_GUI }, {"SetTmr", MENU_SET_TMR }, +#ifdef ENABLE_FEAT_F4HWN_SLEEP + {"SetOff", MENU_SET_OFF }, +#endif #endif // hidden menu items from here on // enabled if pressing both the PTT and upper side button at power-on {"F Lock", MENU_F_LOCK }, +#ifndef ENABLE_FEAT_F4HWN {"Tx 200", MENU_200TX }, // was "200TX" {"Tx 350", MENU_350TX }, // was "350TX" {"Tx 500", MENU_500TX }, // was "500TX" +#endif {"350 En", MENU_350EN }, // was "350EN" #ifndef ENABLE_FEAT_F4HWN {"ScraEn", MENU_SCREN }, // was "SCREN" @@ -227,10 +232,10 @@ const char* const gSubMenu_RXMode[] = }; #endif -const char gSubMenu_SC_REV[][8] = +const char gSubMenu_SC_REV[][13] = { - "TIMEOUT", - "CARRIER", + "CARRIER\nFAST", + "CARRIER\nSLOW", "STOP" }; @@ -687,8 +692,9 @@ void UI_DisplayMenu(void) sprintf(String, "%s", "ON"); } - if(BACKLIGHT_GetBrightness() < 4) - BACKLIGHT_SetBrightness(4); + // Obsolete ??? + //if(BACKLIGHT_GetBrightness() < 4) + // BACKLIGHT_SetBrightness(4); break; case MENU_ABR_MIN: @@ -696,8 +702,9 @@ void UI_DisplayMenu(void) sprintf(String, "%d", gSubMenuSelection); if(gIsInSubMenu) BACKLIGHT_SetBrightness(gSubMenuSelection); - else if(BACKLIGHT_GetBrightness() < 4) - BACKLIGHT_SetBrightness(4); + // Obsolete ??? + //else if(BACKLIGHT_GetBrightness() < 4) + // BACKLIGHT_SetBrightness(4); break; case MENU_AM: @@ -732,9 +739,11 @@ void UI_DisplayMenu(void) #ifdef ENABLE_NOAA case MENU_NOAA_S: #endif +#ifndef ENABLE_FEAT_F4HWN case MENU_350TX: case MENU_200TX: case MENU_500TX: +#endif case MENU_350EN: #ifndef ENABLE_FEAT_F4HWN case MENU_SCREN: @@ -826,7 +835,14 @@ void UI_DisplayMenu(void) #endif case MENU_SC_REV: - strcpy(String, gSubMenu_SC_REV[gSubMenuSelection]); + if(gSubMenuSelection < 3) + { + strcpy(String, gSubMenu_SC_REV[gSubMenuSelection]); + } + else + { + sprintf(String, "TIMEOUT\n%02dm:%02ds", (((gSubMenuSelection - 2) * 5) / 60), (((gSubMenuSelection - 2) * 5) % 60)); + } break; case MENU_MDF: @@ -971,6 +987,19 @@ void UI_DisplayMenu(void) strcpy(String, gSubMenu_SIDEFUNCTIONS[gSubMenuSelection].name); break; +#ifdef ENABLE_FEAT_F4HWN_SLEEP + case MENU_SET_OFF: + if(gSubMenuSelection == 0) + { + sprintf(String, "%s", "OFF"); + } + else if(gSubMenuSelection < 121) + { + sprintf(String, "%02dh:%02dm", (gSubMenuSelection / 60), (gSubMenuSelection % 60)); + } + break; +#endif + #ifdef ENABLE_FEAT_F4HWN case MENU_SET_PWR: sprintf(String, "%s\n%sW", gSubMenu_TXP[gSubMenuSelection + 1], gSubMenu_SET_PWR[gSubMenuSelection]); diff --git a/ui/menu.h b/ui/menu.h index a16df43..22163d1 100644 --- a/ui/menu.h +++ b/ui/menu.h @@ -115,9 +115,11 @@ enum #endif MENU_RESET, MENU_F_LOCK, +#ifndef ENABLE_FEAT_F4HWN MENU_200TX, MENU_350TX, MENU_500TX, +#endif MENU_350EN, #ifndef ENABLE_FEAT_F4HWN MENU_SCREN, @@ -125,6 +127,9 @@ enum #ifdef ENABLE_F_CAL_MENU MENU_F_CALI, // reference xtal calibration #endif +#ifdef ENABLE_FEAT_F4HWN_SLEEP + MENU_SET_OFF, +#endif #ifdef ENABLE_FEAT_F4HWN MENU_SET_PWR, MENU_SET_PTT, @@ -160,7 +165,7 @@ extern const char* const gSubMenu_RXMode[4]; #ifdef ENABLE_VOICE extern const char gSubMenu_VOICE[3][4]; #endif -extern const char gSubMenu_SC_REV[3][8]; +extern const char gSubMenu_SC_REV[3][13]; extern const char* const gSubMenu_MDF[4]; #ifdef ENABLE_ALARM extern const char gSubMenu_AL_MOD[2][5];