Skip to content

Commit

Permalink
Fix backlight issue
Browse files Browse the repository at this point in the history
  • Loading branch information
LolloDev5123 committed Jan 12, 2024
1 parent 7d6f6b0 commit b1b4910
Showing 1 changed file with 5 additions and 108 deletions.
113 changes: 5 additions & 108 deletions helper/battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const uint16_t Voltage2PercentageTable[][7][2] = {
static_assert(ARRAY_SIZE(Voltage2PercentageTable[BATTERY_TYPE_1600_MAH]) ==
ARRAY_SIZE(Voltage2PercentageTable[BATTERY_TYPE_2200_MAH]));


unsigned int BATTERY_VoltsToPercent(const unsigned int voltage_10mV)
{
const uint16_t (*crv)[2] = Voltage2PercentageTable[gEeprom.BATTERY_TYPE];
Expand All @@ -99,8 +100,7 @@ unsigned int BATTERY_VoltsToPercent(const unsigned int voltage_10mV)
}
#endif


void BATTERY_GetReadings(bool bDisplayBatteryLevel)
/*void BATTERY_GetReadings(bool bDisplayBatteryLevel)
{
uint16_t Voltage = (gBatteryVoltages[0] + gBatteryVoltages[1] + gBatteryVoltages[2] + gBatteryVoltages[3]) / 4;
uint8_t PreviousBatteryLevel = gBatteryDisplayLevel;
Expand Down Expand Up @@ -130,109 +130,8 @@ void BATTERY_GetReadings(bool bDisplayBatteryLevel)
if (!gLowBattery && bDisplayBatteryLevel)
UI_DisplayBattery(gBatteryDisplayLevel);
}
}
//////2
/*
void BATTERY_GetReadings(bool bDisplayBatteryLevel)
{
uint16_t Voltage = (gBatteryVoltages[0] + gBatteryVoltages[1] + gBatteryVoltages[2] + gBatteryVoltages[3]) / 4;
uint8_t PreviousBatteryLevel = gBatteryDisplayLevel;
if (Voltage >= gBatteryCalibration[5]) gBatteryDisplayLevel = 6;
else if (Voltage >= gBatteryCalibration[4]) gBatteryDisplayLevel = 5;
else if (Voltage >= gBatteryCalibration[3]) gBatteryDisplayLevel = 4;
else if (Voltage >= gBatteryCalibration[2]) gBatteryDisplayLevel = 3;
else if (Voltage >= gBatteryCalibration[1]) gBatteryDisplayLevel = 2;
else if (Voltage >= gBatteryCalibration[0]) gBatteryDisplayLevel = 1;
else gBatteryDisplayLevel = 0;
gBatteryVoltageAverage = (Voltage * 760) / gBatteryCalibration[3];
if (gScreenToDisplay == DISPLAY_MENU && gMenuCursor == MENU_VOL) gUpdateDisplay = true;
if (gBatteryCurrent < 501) {
if (gChargingWithTypeC) {
gUpdateStatus = true;
gChargingWithTypeC = 0;
}
} else {
if (!gChargingWithTypeC) {
gUpdateStatus = true;
BACKLIGHT_TurnOn();
gChargingWithTypeC = 1;
}
}
if (PreviousBatteryLevel != gBatteryDisplayLevel) {
gLowBattery = (gBatteryDisplayLevel < 2);
gLowBatteryCountdown = 0;
if (!gLowBattery && bDisplayBatteryLevel) {
UI_DisplayBattery(gBatteryDisplayLevel);
}
}
}
*/
////2
/*
void BATTERY_GetReadings(bool bDisplayBatteryLevel)
{
uint16_t Voltage;
uint8_t PreviousBatteryLevel;
PreviousBatteryLevel = gBatteryDisplayLevel;
Voltage = (gBatteryVoltages[0] + gBatteryVoltages[1] + gBatteryVoltages[2] + gBatteryVoltages[3]) / 4;
if (gBatteryCalibration[5] < Voltage) {
gBatteryDisplayLevel = 6;
} else if (gBatteryCalibration[4] < Voltage) {
gBatteryDisplayLevel = 5;
} else if (gBatteryCalibration[3] < Voltage) {
gBatteryDisplayLevel = 4;
} else if (gBatteryCalibration[2] < Voltage) {
gBatteryDisplayLevel = 3;
} else if (gBatteryCalibration[1] < Voltage) {
gBatteryDisplayLevel = 2;
} else if (gBatteryCalibration[0] < Voltage) {
gBatteryDisplayLevel = 1;
} else {
gBatteryDisplayLevel = 0;
}
gBatteryVoltageAverage = (Voltage * 760) / gBatteryCalibration[3];
if ((gScreenToDisplay == DISPLAY_MENU) && gMenuCursor == MENU_VOL) {
gUpdateDisplay = true;
}
if (gBatteryCurrent < 501) {
if (gChargingWithTypeC) {
gUpdateStatus = true;
}
gChargingWithTypeC = 0;
} else {
if (!gChargingWithTypeC) {
gUpdateStatus = true;
BACKLIGHT_TurnOn();
}
gChargingWithTypeC = 1;
}
}*/

if (PreviousBatteryLevel != gBatteryDisplayLevel) {
if (gBatteryDisplayLevel < 2) {
gLowBattery = true;
} else {
gLowBattery = false;
if (bDisplayBatteryLevel) {
UI_DisplayBattery(gBatteryDisplayLevel);
}
}
gLowBatteryCountdown = 0;
}
}
*/
////1
/*
void BATTERY_GetReadings(bool bDisplayBatteryLevel) {
uint8_t PreviousBatteryLevel = gBatteryDisplayLevel;
uint16_t Voltage = Mid(gBatteryVoltages, ARRAY_SIZE(gBatteryVoltages));
Expand All @@ -242,7 +141,7 @@ void BATTERY_GetReadings(bool bDisplayBatteryLevel) {
for (int i = ARRAY_SIZE(gBatteryCalibration) - 1; i >= 0; --i) {
if (Voltage > gBatteryCalibration[i]) {
// old config gBatteryDisplayLevel = i + 1;
gBatteryDisplayLevel = i + 1;
gBatteryDisplayLevel = i + 3/5;
break;
}
}
Expand Down Expand Up @@ -273,6 +172,4 @@ void BATTERY_GetReadings(bool bDisplayBatteryLevel) {
}
gLowBatteryCountdown = 0;
}
}
*/

}

0 comments on commit b1b4910

Please sign in to comment.