1. Battery is full
2. Battery is charging (not full)
3. Battery is discharging (not full)
4. Battery is on critical(<=33%) and charging
5. Battery is on critical and discharging
Code: Select all
if (battery_percentage >= 99)
{a = "Battery is full";
}
else
{if (battery_plugged == 0 AND battery_percentage <= 33)
{a = "Battery is on CRITICAL and DISCHARGING";
}
if (battery_plugged != 0 AND battery_percentage <= 33)
{a = "Battery is on CRITICAL and CHARGING";
}
else
{if (battery_plugged == 0)
{a = "Battery is DISCHARGING";
}
if (battery_plugged != 0)
{a = "Battery is CHARGING";
};
};
};
b = "{battery_percentage, numberformat, 0}%";
//final speech output
if (battery_percentage >= 99)
{d = "{a}";
}
else
{d = "{a} at {b}";
}
The issue is not big as I already have re-wrote the code differently and it works flawlessly, but I do not understand why this code doesn't work. I'd like to know that.