From 6ff1a935b923b69d34d18e68af612297912c806b Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Tue, 30 Nov 2021 00:06:33 +0000 Subject: [PATCH] powermgmt: Remove an unnecessary function Remove battery_read_info() which is a simple wrapper function only used by debug screens. Use the polling functions directly to save a bit of code size. Change-Id: I2919f78105bab186f6933dc1823f9fa67fe74f3e --- apps/debug_menu.c | 11 ++++++----- firmware/export/powermgmt.h | 4 ---- firmware/powermgmt.c | 16 ---------------- firmware/target/coldfire/debug-coldfire.c | 5 +++-- 4 files changed, 9 insertions(+), 27 deletions(-) diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 1b93278b0d..4c0486595f 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c @@ -849,7 +849,7 @@ static bool tsc2100_debug(void) static bool view_battery(void) { int view = 0; - int i, x, y, z, y1, y2, grid, graph; + int i, x, y, y1, y2, grid, graph; unsigned short maxv, minv; lcd_setfont(FONT_SYSFIXED); @@ -944,11 +944,12 @@ static bool view_battery(void) #else lcd_puts(0, 0, "Power status: unknown"); #endif - battery_read_info(&y, &z); + + y = _battery_voltage(); if (y > 0) - lcd_putsf(0, 1, "Battery: %d.%03d V (%d %%)", y / 1000, y % 1000, z); - else if (z > 0) - lcd_putsf(0, 1, "Battery: %d %%", z); + lcd_putsf(0, 1, "Battery: %d.%03d V (%d %%)", y / 1000, y % 1000, battery_level()); + else + lcd_putsf(0, 1, "Battery: %d %%", _battery_level()); #ifdef ADC_EXT_POWER y = (adc_read(ADC_EXT_POWER) * EXT_SCALE_FACTOR) / 1000; lcd_putsf(0, 2, "External: %d.%03d V", y / 1000, y % 1000); diff --git a/firmware/export/powermgmt.h b/firmware/export/powermgmt.h index 329e64d653..a4b924915c 100644 --- a/firmware/export/powermgmt.h +++ b/firmware/export/powermgmt.h @@ -149,10 +149,6 @@ unsigned int input_millivolts(void); /* voltage that device is running from */ void reset_battery_filter(int millivolts); #endif /* HAVE_BATTERY_SWITCH || HAVE_RESET_BATTERY_FILTER */ - -/* read unfiltered battery info */ -void battery_read_info(int *voltage, int *level); - /* Tells if the battery level is safe for disk writes */ bool battery_level_safe(void); diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c index 8e47b19721..313486889e 100644 --- a/firmware/powermgmt.c +++ b/firmware/powermgmt.c @@ -145,22 +145,6 @@ static void battery_status_update(void); static int runcurrent(void); #endif -void battery_read_info(int *voltage, int *level) -{ - int millivolts = _battery_voltage(); - int percent; - - if (voltage) - *voltage = millivolts; - - if (level) { - percent = _battery_level(); - if (percent < 0) - percent = voltage_to_battery_level(millivolts); - *level = percent; - } -} - #if BATTERY_TYPES_COUNT > 1 void set_battery_type(int type) { diff --git a/firmware/target/coldfire/debug-coldfire.c b/firmware/target/coldfire/debug-coldfire.c index ef44a82176..56f1bbe1a7 100644 --- a/firmware/target/coldfire/debug-coldfire.c +++ b/firmware/target/coldfire/debug-coldfire.c @@ -144,7 +144,7 @@ bool dbg_ports(void) adc_buttons = adc_read(ADC_BUTTONS); adc_remote = adc_read(ADC_REMOTE); - battery_read_info(&adc_battery_voltage, &adc_battery_level); + #if defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IRIVER_H300_SERIES) lcd_putsf(0, line++, "ADC_BUTTONS (%c): %02x", button_scan_enabled() ? '+' : '-', adc_buttons); @@ -162,7 +162,8 @@ bool dbg_ports(void) adc_read(ADC_REMOTEDETECT)); #endif - battery_read_info(&adc_battery_voltage, &adc_battery_level); + adc_battery_voltage = _battery_voltage(); + adc_battery_level = battery_level(); lcd_putsf(0, line++, "Batt: %d.%03dV %d%% ", adc_battery_voltage / 1000, adc_battery_voltage % 1000, adc_battery_level);