FuriHal, Power, UnitTests: battery charging voltage limit API (#2063)

This commit is contained in:
Shane Synan
2022-12-08 01:57:49 -05:00
committed by GitHub
parent 6a470a464e
commit 5c3a5cd8f7
13 changed files with 173 additions and 4 deletions

View File

@@ -12,6 +12,20 @@ void power_draw_battery_callback(Canvas* canvas, void* context) {
if(power->info.gauge_is_ok) {
canvas_draw_box(canvas, 2, 2, (power->info.charge + 4) / 5, 4);
if(power->info.voltage_battery_charging < 4.2) {
// Battery charging voltage is modified, indicate with cross pattern
canvas_invert_color(canvas);
uint8_t battery_bar_width = (power->info.charge + 4) / 5;
bool cross_odd = false;
// Start 1 further in from the battery bar's x position
for(uint8_t x = 3; x <= battery_bar_width; x++) {
// Cross pattern is from the center of the battery bar
// y = 2 + 1 (inset) + 1 (for every other)
canvas_draw_dot(canvas, x, 3 + (uint8_t)cross_odd);
cross_odd = !cross_odd;
}
canvas_invert_color(canvas);
}
if(power->state == PowerStateCharging) {
canvas_set_bitmap_mode(canvas, 1);
canvas_set_color(canvas, ColorWhite);
@@ -132,6 +146,7 @@ static bool power_update_info(Power* power) {
info.capacity_full = furi_hal_power_get_battery_full_capacity();
info.current_charger = furi_hal_power_get_battery_current(FuriHalPowerICCharger);
info.current_gauge = furi_hal_power_get_battery_current(FuriHalPowerICFuelGauge);
info.voltage_battery_charging = furi_hal_power_get_battery_charging_voltage();
info.voltage_charger = furi_hal_power_get_battery_voltage(FuriHalPowerICCharger);
info.voltage_gauge = furi_hal_power_get_battery_voltage(FuriHalPowerICFuelGauge);
info.voltage_vbus = furi_hal_power_get_usb_voltage();

View File

@@ -41,6 +41,7 @@ typedef struct {
float current_charger;
float current_gauge;
float voltage_battery_charging;
float voltage_charger;
float voltage_gauge;
float voltage_vbus;