Refactoring
This commit is contained in:
52
app/app.c
52
app/app.c
@@ -1723,57 +1723,7 @@ void APP_TimeSlice500ms(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (gLowBattery)
|
BATTERY_TimeSlice500ms();
|
||||||
{
|
|
||||||
gLowBatteryBlink = ++gLowBatteryCountdown & 1;
|
|
||||||
|
|
||||||
UI_DisplayBattery(0, gLowBatteryBlink);
|
|
||||||
|
|
||||||
if (gCurrentFunction != FUNCTION_TRANSMIT)
|
|
||||||
{ // not transmitting
|
|
||||||
|
|
||||||
if (gLowBatteryCountdown < 30)
|
|
||||||
{
|
|
||||||
if (gLowBatteryCountdown == 29 && !gChargingWithTypeC)
|
|
||||||
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gLowBatteryCountdown = 0;
|
|
||||||
|
|
||||||
if (!gChargingWithTypeC)
|
|
||||||
{ // not on charge
|
|
||||||
|
|
||||||
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP);
|
|
||||||
|
|
||||||
#ifdef ENABLE_VOICE
|
|
||||||
AUDIO_SetVoiceID(0, VOICE_ID_LOW_VOLTAGE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (gBatteryDisplayLevel == 0)
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_VOICE
|
|
||||||
AUDIO_PlaySingleVoice(true);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
gReducedService = true;
|
|
||||||
|
|
||||||
//if (gCurrentFunction != FUNCTION_POWER_SAVE)
|
|
||||||
FUNCTION_Select(FUNCTION_POWER_SAVE);
|
|
||||||
|
|
||||||
ST7565_HardwareReset();
|
|
||||||
|
|
||||||
if (gEeprom.BACKLIGHT_TIME < (ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1))
|
|
||||||
BACKLIGHT_TurnOff(); // turn the backlight off
|
|
||||||
}
|
|
||||||
#ifdef ENABLE_VOICE
|
|
||||||
else
|
|
||||||
AUDIO_PlaySingleVoice(false);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gScreenToDisplay == DISPLAY_SCANNER && gScannerEditState == 0 && gScanCssState < SCAN_CSS_STATE_FOUND)
|
if (gScreenToDisplay == DISPLAY_SCANNER && gScannerEditState == 0 && gScanCssState < SCAN_CSS_STATE_FOUND)
|
||||||
{
|
{
|
||||||
|
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
#include "battery.h"
|
#include "battery.h"
|
||||||
#include "driver/backlight.h"
|
#include "driver/backlight.h"
|
||||||
|
#include "driver/st7565.h"
|
||||||
|
#include "functions.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "ui/battery.h"
|
#include "ui/battery.h"
|
||||||
@@ -29,10 +31,12 @@ uint16_t gBatteryVoltages[4];
|
|||||||
uint16_t gBatteryVoltageAverage;
|
uint16_t gBatteryVoltageAverage;
|
||||||
uint8_t gBatteryDisplayLevel;
|
uint8_t gBatteryDisplayLevel;
|
||||||
bool gChargingWithTypeC;
|
bool gChargingWithTypeC;
|
||||||
bool gLowBattery;
|
|
||||||
bool gLowBatteryBlink;
|
bool gLowBatteryBlink;
|
||||||
uint16_t gBatteryCheckCounter;
|
uint16_t gBatteryCheckCounter;
|
||||||
|
|
||||||
|
bool lowBattery;
|
||||||
|
uint16_t lowBatteryCountdown;
|
||||||
|
|
||||||
volatile uint16_t gPowerSave_10ms;
|
volatile uint16_t gPowerSave_10ms;
|
||||||
|
|
||||||
|
|
||||||
@@ -134,16 +138,71 @@ void BATTERY_GetReadings(const bool bDisplayBatteryLevel)
|
|||||||
{
|
{
|
||||||
if (gBatteryDisplayLevel < 2)
|
if (gBatteryDisplayLevel < 2)
|
||||||
{
|
{
|
||||||
gLowBattery = true;
|
lowBattery = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gLowBattery = false;
|
lowBattery = false;
|
||||||
|
|
||||||
if (bDisplayBatteryLevel)
|
if (bDisplayBatteryLevel)
|
||||||
UI_DisplayBattery(gBatteryDisplayLevel, gLowBatteryBlink);
|
UI_DisplayBattery(gBatteryDisplayLevel, gLowBatteryBlink);
|
||||||
}
|
}
|
||||||
|
|
||||||
gLowBatteryCountdown = 0;
|
lowBatteryCountdown = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BATTERY_TimeSlice500ms(void)
|
||||||
|
{
|
||||||
|
if (lowBattery)
|
||||||
|
{
|
||||||
|
gLowBatteryBlink = ++lowBatteryCountdown & 1;
|
||||||
|
|
||||||
|
UI_DisplayBattery(0, gLowBatteryBlink);
|
||||||
|
|
||||||
|
if (gCurrentFunction != FUNCTION_TRANSMIT)
|
||||||
|
{ // not transmitting
|
||||||
|
|
||||||
|
if (lowBatteryCountdown < 30)
|
||||||
|
{
|
||||||
|
if (lowBatteryCountdown == 29 && !gChargingWithTypeC)
|
||||||
|
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lowBatteryCountdown = 0;
|
||||||
|
|
||||||
|
if (!gChargingWithTypeC)
|
||||||
|
{ // not on charge
|
||||||
|
|
||||||
|
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP);
|
||||||
|
|
||||||
|
#ifdef ENABLE_VOICE
|
||||||
|
AUDIO_SetVoiceID(0, VOICE_ID_LOW_VOLTAGE);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (gBatteryDisplayLevel == 0)
|
||||||
|
{
|
||||||
|
#ifdef ENABLE_VOICE
|
||||||
|
AUDIO_PlaySingleVoice(true);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
gReducedService = true;
|
||||||
|
|
||||||
|
//if (gCurrentFunction != FUNCTION_POWER_SAVE)
|
||||||
|
FUNCTION_Select(FUNCTION_POWER_SAVE);
|
||||||
|
|
||||||
|
ST7565_HardwareReset();
|
||||||
|
|
||||||
|
if (gEeprom.BACKLIGHT_TIME < (ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1))
|
||||||
|
BACKLIGHT_TurnOff(); // turn the backlight off
|
||||||
|
}
|
||||||
|
#ifdef ENABLE_VOICE
|
||||||
|
else
|
||||||
|
AUDIO_PlaySingleVoice(false);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -27,7 +27,6 @@ extern uint16_t gBatteryVoltages[4];
|
|||||||
extern uint16_t gBatteryVoltageAverage;
|
extern uint16_t gBatteryVoltageAverage;
|
||||||
extern uint8_t gBatteryDisplayLevel;
|
extern uint8_t gBatteryDisplayLevel;
|
||||||
extern bool gChargingWithTypeC;
|
extern bool gChargingWithTypeC;
|
||||||
extern bool gLowBattery;
|
|
||||||
extern bool gLowBatteryBlink;
|
extern bool gLowBatteryBlink;
|
||||||
extern uint16_t gBatteryCheckCounter;
|
extern uint16_t gBatteryCheckCounter;
|
||||||
|
|
||||||
@@ -41,6 +40,7 @@ typedef enum {
|
|||||||
|
|
||||||
unsigned int BATTERY_VoltsToPercent(const unsigned int voltage_10mV);
|
unsigned int BATTERY_VoltsToPercent(const unsigned int voltage_10mV);
|
||||||
void BATTERY_GetReadings(const bool bDisplayBatteryLevel);
|
void BATTERY_GetReadings(const bool bDisplayBatteryLevel);
|
||||||
|
void BATTERY_TimeSlice500ms(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
1
misc.c
1
misc.c
@@ -197,7 +197,6 @@ bool g_SquelchLost;
|
|||||||
uint8_t gFlashLightState;
|
uint8_t gFlashLightState;
|
||||||
volatile uint16_t gFlashLightBlinkCounter;
|
volatile uint16_t gFlashLightBlinkCounter;
|
||||||
bool gFlagEndTransmission;
|
bool gFlagEndTransmission;
|
||||||
uint16_t gLowBatteryCountdown;
|
|
||||||
uint8_t gNextMrChannel;
|
uint8_t gNextMrChannel;
|
||||||
ReceptionMode_t gRxReceptionMode;
|
ReceptionMode_t gRxReceptionMode;
|
||||||
|
|
||||||
|
1
misc.h
1
misc.h
@@ -274,7 +274,6 @@ extern bool g_SquelchLost;
|
|||||||
extern uint8_t gFlashLightState;
|
extern uint8_t gFlashLightState;
|
||||||
extern volatile uint16_t gFlashLightBlinkCounter;
|
extern volatile uint16_t gFlashLightBlinkCounter;
|
||||||
extern bool gFlagEndTransmission;
|
extern bool gFlagEndTransmission;
|
||||||
extern uint16_t gLowBatteryCountdown;
|
|
||||||
extern uint8_t gNextMrChannel;
|
extern uint8_t gNextMrChannel;
|
||||||
extern ReceptionMode_t gRxReceptionMode;
|
extern ReceptionMode_t gRxReceptionMode;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user