Refactoring
This commit is contained in:
52
app/app.c
52
app/app.c
@@ -1723,57 +1723,7 @@ void APP_TimeSlice500ms(void)
|
||||
}
|
||||
|
||||
|
||||
if (gLowBattery)
|
||||
{
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
BATTERY_TimeSlice500ms();
|
||||
|
||||
if (gScreenToDisplay == DISPLAY_SCANNER && gScannerEditState == 0 && gScanCssState < SCAN_CSS_STATE_FOUND)
|
||||
{
|
||||
|
@@ -16,6 +16,8 @@
|
||||
|
||||
#include "battery.h"
|
||||
#include "driver/backlight.h"
|
||||
#include "driver/st7565.h"
|
||||
#include "functions.h"
|
||||
#include "misc.h"
|
||||
#include "settings.h"
|
||||
#include "ui/battery.h"
|
||||
@@ -29,10 +31,12 @@ uint16_t gBatteryVoltages[4];
|
||||
uint16_t gBatteryVoltageAverage;
|
||||
uint8_t gBatteryDisplayLevel;
|
||||
bool gChargingWithTypeC;
|
||||
bool gLowBattery;
|
||||
bool gLowBatteryBlink;
|
||||
uint16_t gBatteryCheckCounter;
|
||||
|
||||
bool lowBattery;
|
||||
uint16_t lowBatteryCountdown;
|
||||
|
||||
volatile uint16_t gPowerSave_10ms;
|
||||
|
||||
|
||||
@@ -134,16 +138,71 @@ void BATTERY_GetReadings(const bool bDisplayBatteryLevel)
|
||||
{
|
||||
if (gBatteryDisplayLevel < 2)
|
||||
{
|
||||
gLowBattery = true;
|
||||
lowBattery = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
gLowBattery = false;
|
||||
lowBattery = false;
|
||||
|
||||
if (bDisplayBatteryLevel)
|
||||
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 uint8_t gBatteryDisplayLevel;
|
||||
extern bool gChargingWithTypeC;
|
||||
extern bool gLowBattery;
|
||||
extern bool gLowBatteryBlink;
|
||||
extern uint16_t gBatteryCheckCounter;
|
||||
|
||||
@@ -41,6 +40,7 @@ typedef enum {
|
||||
|
||||
unsigned int BATTERY_VoltsToPercent(const unsigned int voltage_10mV);
|
||||
void BATTERY_GetReadings(const bool bDisplayBatteryLevel);
|
||||
void BATTERY_TimeSlice500ms(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
1
misc.c
1
misc.c
@@ -197,7 +197,6 @@ bool g_SquelchLost;
|
||||
uint8_t gFlashLightState;
|
||||
volatile uint16_t gFlashLightBlinkCounter;
|
||||
bool gFlagEndTransmission;
|
||||
uint16_t gLowBatteryCountdown;
|
||||
uint8_t gNextMrChannel;
|
||||
ReceptionMode_t gRxReceptionMode;
|
||||
|
||||
|
Reference in New Issue
Block a user