From 071747aea88d7dbdcb6f877bb1a94782afd18555 Mon Sep 17 00:00:00 2001 From: Christian Vogel Date: Sat, 3 Mar 2012 13:47:15 +0100 Subject: Add battery info to hello world. --- src/target/firmware/apps/hello_world/main.c | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/target/firmware/apps/hello_world/main.c b/src/target/firmware/apps/hello_world/main.c index cdf4dae0..3720088e 100644 --- a/src/target/firmware/apps/hello_world/main.c +++ b/src/target/firmware/apps/hello_world/main.c @@ -41,6 +41,7 @@ #include #include #include +#include /* Main Program */ const char *hr = "======================================================================\n"; @@ -67,6 +68,36 @@ static void l1a_l23_rx_cb(uint8_t dlci, struct msgb *msg) puts("\n"); } +void +write_battery_info(void *p){ + char buf[128]; + + fb_setfg(FB_COLOR_WHITE); + fb_setfont(FB_FONT_C64); + + snprintf(buf,sizeof(buf),"B: %04d mV",battery_info.bat_volt_mV); + fb_gotoxy(8,41); + fb_putstr(buf,framebuffer->width-8); + + snprintf(buf,sizeof(buf),"C: %04d mV",battery_info.charger_volt_mV); + fb_gotoxy(8,49); + fb_putstr(buf,framebuffer->width-8); + + snprintf(buf,sizeof(buf),"F: %08x",battery_info.flags); + fb_gotoxy(8,57); + fb_putstr(buf,framebuffer->width-8); + + fb_flush(); + osmo_timer_schedule((struct osmo_timer_list*)p,100); + +} + +/* timer that fires the charging loop regularly */ +static struct osmo_timer_list write_battery_info_timer = { + .cb = &write_battery_info, + .data = &write_battery_info_timer +}; + int main(void) { board_init(); @@ -123,6 +154,8 @@ int main(void) sercomm_register_rx_cb(SC_DLCI_CONSOLE, console_rx_cb); sercomm_register_rx_cb(SC_DLCI_L1A_L23, l1a_l23_rx_cb); + osmo_timer_schedule(&write_battery_info_timer,100); + /* beyond this point we only react to interrupts */ puts("entering interrupt loop\n"); while (1) { -- cgit v1.2.3