Add SetOff menu (experimental)

This commit is contained in:
Armel FAUVEAU
2024-09-24 22:55:33 +02:00
parent 7fdc2cc3f9
commit 4a144cb522
13 changed files with 115 additions and 2 deletions

View File

@@ -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
@@ -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

View File

@@ -1567,6 +1567,31 @@ void APP_TimeSlice500ms(void)
BACKLIGHT_TurnOff();
}
#ifdef ENABLE_FEAT_F4HWN_SLEEP
if (gSleepModeCountdown_500ms == gSetting_set_off * 120 && gWakeUp) {
ST7565_Init();
BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2_GREEN, false);
BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1_RED, false);
gWakeUp = false;
}
if (gSleepModeCountdown_500ms > 0 && --gSleepModeCountdown_500ms == 0) {
gBacklightCountdown_500ms = 0;
BACKLIGHT_TurnOff();
ST7565_ShutDown();
gWakeUp = true;
gPowerSaveCountdownExpired = true;
}
if (gWakeUp) {
static bool swap = true;
swap = !swap; // Alterne l'état à chaque exécution
BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2_GREEN, swap);
BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1_RED, swap);
FUNCTION_Select(FUNCTION_POWER_SAVE);
}
#endif
if (gReducedService)
{
BOARD_ADC_GetBatteryInfo(&gBatteryCurrentVoltage, &gBatteryCurrent);

View File

@@ -376,6 +376,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;
@@ -868,6 +874,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;
@@ -1294,6 +1306,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;

View File

@@ -31,6 +31,10 @@
uint16_t gBacklightCountdown_500ms = 0;
bool backlightOn;
#ifdef ENABLE_FEAT_F4HWN_SLEEP
uint16_t gSleepModeCountdown_500ms = 0;
#endif
void BACKLIGHT_InitHardware()
{
// 48MHz / 94 / 1024 ~ 500Hz
@@ -117,6 +121,10 @@ void BACKLIGHT_TurnOn(void)
gBacklightCountdown_500ms = 0;
break;
}
#ifdef ENABLE_FEAT_F4HWN_SLEEP
gSleepModeCountdown_500ms = gSetting_set_off * 120;
#endif
}
void BACKLIGHT_TurnOff()

View File

@@ -23,6 +23,10 @@
extern uint16_t gBacklightCountdown_500ms;
extern uint8_t gBacklightBrightness;
#ifdef ENABLE_FEAT_F4HWN_SLEEP
extern uint16_t gSleepModeCountdown_500ms;
#endif
#ifdef ENABLE_BLMIN_TMP_OFF
typedef enum {
BLMIN_STAT_ON,

View File

@@ -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);

View File

@@ -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);

4
main.c
View File

@@ -130,9 +130,13 @@ void Main(void)
SETTINGS_SaveSettings();
#ifndef ENABLE_VOX
gMenuCursor = 64; // move to hidden section, fix me if change... !!! Remove VOX and Mic Bar
#else
#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
}

5
misc.c
View File

@@ -104,6 +104,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;

5
misc.h
View File

@@ -156,6 +156,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;

View File

@@ -346,7 +346,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
@@ -740,7 +743,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) |

View File

@@ -147,6 +147,9 @@ 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
@@ -978,6 +981,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]);

View File

@@ -125,6 +125,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,