Here are my final code changes:
--- Documents/GitHub/rockbox/bootloader/ipod6g.c 2023-02-08 18:36:18
+++ /Volumes/tank/Docker/rbclient/rockbox/bootloader/ipod6g.c 2023-02-11 19:45:41
@@ -189,6 +189,8 @@
usb_charging_maxcurrent_change(100);
+ int backlight_on = true;
+
while (1)
{
vbat = _battery_voltage();
@@ -209,6 +211,21 @@
if (power_input_status() != POWER_INPUT_NONE) {
lcd_set_foreground(LCD_RBYELLOW);
printf("Low battery: %d mV, charging... ", vbat);
+ if (button_hold()) {
+ if (backlight_on)
+ {
+ backlight_on = false;
+ backlight_hw_off(); // Turn the backlight OFF when charging if the hold switch is ON.
+ }
+ }
+ else
+ {
+ if (!backlight_on)
+ {
+ backlight_on = true;
+ backlight_hw_on(); // Turn the backlight ON when charging if the hold switch is OFF.
+ }
+ }
sleep(HZ*3);
}
else {
I just use my own variable instead of relying on any functions.