summaryrefslogtreecommitdiffstats
path: root/src/target
diff options
context:
space:
mode:
authorChristian Vogel <vogelchr@vogel.cx>2012-03-03 13:47:15 +0100
committerHarald Welte <laforge@gnumonks.org>2012-04-28 09:38:45 +0200
commit071747aea88d7dbdcb6f877bb1a94782afd18555 (patch)
tree3f02c29e155e4fbac355b5e89868616bed88b7e9 /src/target
parent76527fd1e3c987b7bd1533f1eed8696c42390fc3 (diff)
Add battery info to hello world.
Diffstat (limited to 'src/target')
-rw-r--r--src/target/firmware/apps/hello_world/main.c33
1 files changed, 33 insertions, 0 deletions
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 <comm/sercomm.h>
#include <comm/timer.h>
#include <fb/framebuffer.h>
+#include <battery/battery.h>
/* 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) {