diff options
author | lonkaars <loek@pipeframe.xyz> | 2022-06-26 17:40:36 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2022-06-26 17:40:36 +0200 |
commit | 2a0270f3ba6eb993fb39ed3564f626d724156654 (patch) | |
tree | d8d310eb35768f84d25453eae4b8cd4721bd8ddf /client | |
parent | 55fe6aaeee49894dc07516f0c4e21f692b2950fe (diff) |
implement battery measurement and target area switching
Diffstat (limited to 'client')
-rw-r--r-- | client/main.c | 5 | ||||
-rw-r--r-- | client/main.h | 1 | ||||
-rw-r--r-- | client/time.h | 1 | ||||
-rw-r--r-- | client/ui.c | 2 |
4 files changed, 7 insertions, 2 deletions
diff --git a/client/main.c b/client/main.c index 4d7f484..4eed232 100644 --- a/client/main.c +++ b/client/main.c @@ -33,5 +33,10 @@ int main(int argc, char **argv) { g_w2_state.ping_received = false; w2_send_ping(); } + + if (w2_timer_end(W2_TIMER_INFO) > W2_BATTERY_MEAS_FREQ) { + w2_send_info(); + w2_timer_start(W2_TIMER_INFO); + } } } diff --git a/client/main.h b/client/main.h index b72b507..e215ae6 100644 --- a/client/main.h +++ b/client/main.h @@ -9,7 +9,6 @@ typedef struct { bool ping_timeout; bool connected; - uint8_t battery_level; uint8_t mode; diff --git a/client/time.h b/client/time.h index a989c5c..130f91a 100644 --- a/client/time.h +++ b/client/time.h @@ -6,6 +6,7 @@ extern unsigned long g_w2_client_timers[W2_CLIENT_TIMER_COUNT]; typedef enum { W2_TIMER_PING = 0, W2_TIMER_UPDATE = 1, + W2_TIMER_INFO = 2, } w2_e_client_timers; void w2_timer_start(w2_e_client_timers label); diff --git a/client/ui.c b/client/ui.c index 6bc0986..61f9d0e 100644 --- a/client/ui.c +++ b/client/ui.c @@ -87,7 +87,7 @@ void w2_ui_paint_statusbar() { sprintf(temp, "(%s)", g_w2_state.info.build_str); w2_wmvaddstr(g_w2_ui_pad_statusbar, 0, g_w2_ui_width / 2 - strlen(temp) / 2, temp); - sprintf(temp, "%s %imv", W2_UI_BATT_STAT_BATTERY, g_w2_state.info.battery_mv); + sprintf(temp, "%s %i%%", W2_UI_BATT_STAT_BATTERY, g_w2_state.info.battery_percent); w2_wmvaddstr(g_w2_ui_pad_statusbar, 0, g_w2_ui_width - strlen(temp), temp); sprintf(temp, "[%s]", g_w2_mode_strings[g_w2_state.mode]); |