diff --git a/src/display.cpp b/src/display.cpp index 3fa7e62a..732b3063 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -283,10 +283,8 @@ void dp_drawPage(time_t t, bool nextpage) { #if (defined BAT_MEASURE_ADC || defined HAS_PMU || defined HAS_IP5306) if (batt_level == 0) dp_printf("No batt "); - else if (batt_level < 100) - dp_printf("B:%3d%% ", batt_level); else - dp_printf("ext.Pwr "); + dp_printf("B:%3d%% ", batt_level); #else dp_printf(" "); #endif diff --git a/src/lorawan.cpp b/src/lorawan.cpp index 9e5250f8..ac3dd1f2 100644 --- a/src/lorawan.cpp +++ b/src/lorawan.cpp @@ -482,29 +482,22 @@ uint8_t myBattLevelCb(void *pUserData) { // we calculate the applicable value from MCMD_DEVS_BATT_MIN to // MCMD_DEVS_BATT_MAX from bat_percent value - uint8_t lmic_batt_level; uint8_t const batt_percent = read_battlevel(); if (batt_percent == 0) - lmic_batt_level = MCMD_DEVS_BATT_NOINFO; + return MCMD_DEVS_BATT_NOINFO; else #ifdef HAS_PMU if (pmu.isVBUSPlug()) - lmic_batt_level = MCMD_DEVS_EXT_POWER; + return MCMD_DEVS_EXT_POWER; #elif defined HAS_IP5306 if (IP5306_GetPowerSource()) - lmic_batt_level = MCMD_DEVS_EXT_POWER; + return MCMD_DEVS_EXT_POWER; #else - if (batt_percent >= 100) - lmic_batt_level = MCMD_DEVS_EXT_POWER; + return (batt_percent / 100.0 * + (MCMD_DEVS_BATT_MAX - MCMD_DEVS_BATT_MIN + 1)); #endif // HAS_PMU - - else - lmic_batt_level = - batt_percent / 100.0 * (MCMD_DEVS_BATT_MAX - MCMD_DEVS_BATT_MIN + 1); - - return lmic_batt_level; } // event EV_RXCOMPLETE message handler diff --git a/src/main.cpp b/src/main.cpp index c5ee155e..3d83ebce 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -233,7 +233,6 @@ void setup() { #ifdef HAS_RGB_LED switch_LED(LED_ON); strcat_P(features, " RGB"); - rgb_set_color(COLOR_PINK); #endif #endif // HAS_LED diff --git a/src/power.cpp b/src/power.cpp index 062bbcb8..2c6012b5 100644 --- a/src/power.cpp +++ b/src/power.cpp @@ -211,26 +211,18 @@ uint16_t read_voltage(void) { } uint8_t read_battlevel(mapFn_t mapFunction) { - // returns the estimated battery level in values 0 ... 100 [percent] - - uint8_t batt_percent; - #ifdef HAS_IP5306 - batt_percent = IP5306_GetBatteryLevel(); + return IP5306_GetBatteryLevel(); #else const uint16_t batt_voltage = read_voltage(); - if (batt_voltage <= BAT_MIN_VOLTAGE) - batt_percent = 0; + return 0; else if (batt_voltage >= BAT_MAX_VOLTAGE) - batt_percent = 100; + return 100; else - batt_percent = - (*mapFunction)(batt_voltage, BAT_MIN_VOLTAGE, BAT_MAX_VOLTAGE); -#endif // HAS_IP5306 - - return batt_percent; + return (*mapFunction)(batt_voltage, BAT_MIN_VOLTAGE, BAT_MAX_VOLTAGE); +#endif } bool batt_sufficient() {