Fix battery glitch
Battery charge was mistakenly being computed because values used in computation were defined in a function which was not included as a header file.
This commit is contained in:
parent
6b47a32292
commit
daeeee64dd
|
|
@ -36,6 +36,7 @@ typedef struct
|
||||||
bool radioStateUpdated;
|
bool radioStateUpdated;
|
||||||
curTime_t time;
|
curTime_t time;
|
||||||
float v_bat;
|
float v_bat;
|
||||||
|
float charge;
|
||||||
|
|
||||||
uint8_t ui_screen;
|
uint8_t ui_screen;
|
||||||
uint8_t backlight_level;
|
uint8_t backlight_level;
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <state.h>
|
#include <state.h>
|
||||||
|
#include <battery.h>
|
||||||
#include <interfaces/platform.h>
|
#include <interfaces/platform.h>
|
||||||
|
|
||||||
state_t state;
|
state_t state;
|
||||||
|
|
@ -35,6 +36,7 @@ void state_init()
|
||||||
state.time = rtc_getTime();
|
state.time = rtc_getTime();
|
||||||
#endif
|
#endif
|
||||||
state.v_bat = platform_getVbat();
|
state.v_bat = platform_getVbat();
|
||||||
|
state.charge = battery_getCharge(state.v_bat);
|
||||||
|
|
||||||
state.backlight_level = 255;
|
state.backlight_level = 255;
|
||||||
state.channelInfoUpdated = true;
|
state.channelInfoUpdated = true;
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
#include <ui.h>
|
#include <ui.h>
|
||||||
#include <state.h>
|
#include <state.h>
|
||||||
#include <threads.h>
|
#include <threads.h>
|
||||||
|
#include <battery.h>
|
||||||
#include <interfaces/keyboard.h>
|
#include <interfaces/keyboard.h>
|
||||||
#include <interfaces/graphics.h>
|
#include <interfaces/graphics.h>
|
||||||
#include <interfaces/platform.h>
|
#include <interfaces/platform.h>
|
||||||
|
|
@ -249,6 +250,7 @@ static void dev_task(void *arg)
|
||||||
state.time = rtc_getTime();
|
state.time = rtc_getTime();
|
||||||
#endif
|
#endif
|
||||||
state.v_bat = platform_getVbat();
|
state.v_bat = platform_getVbat();
|
||||||
|
state.charge = battery_getCharge(state.v_bat);
|
||||||
|
|
||||||
OSMutexPost(&state_mutex, OS_OPT_POST_NONE, &os_err);
|
OSMutexPost(&state_mutex, OS_OPT_POST_NONE, &os_err);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,12 +49,11 @@ void _ui_drawMainTop(state_t* last_state)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Print battery icon on top bar, use 4 px padding
|
// Print battery icon on top bar, use 4 px padding
|
||||||
float charge = battery_getCharge(last_state->v_bat);
|
|
||||||
uint16_t bat_width = SCREEN_WIDTH / 9;
|
uint16_t bat_width = SCREEN_WIDTH / 9;
|
||||||
uint16_t bat_height = layout.top_h - (layout.status_v_pad * 2);
|
uint16_t bat_height = layout.top_h - (layout.status_v_pad * 2);
|
||||||
point_t bat_pos = {SCREEN_WIDTH - bat_width - layout.horizontal_pad,
|
point_t bat_pos = {SCREEN_WIDTH - bat_width - layout.horizontal_pad,
|
||||||
layout.status_v_pad};
|
layout.status_v_pad};
|
||||||
gfx_drawBattery(bat_pos, bat_width, bat_height, charge);
|
gfx_drawBattery(bat_pos, bat_width, bat_height, last_state->charge);
|
||||||
|
|
||||||
// Print radio mode on top bar
|
// Print radio mode on top bar
|
||||||
char mode[4] = "";
|
char mode[4] = "";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue