diff options
author | Harald Welte <laforge@gnumonks.org> | 2012-04-28 09:41:52 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2012-04-28 09:41:52 +0200 |
commit | 186fefcc76294e69c367b2eb8796bb824927248d (patch) | |
tree | 6d653d56cae269101cd4f137dc7d98b44541285c | |
parent | 5b87e3e4bdf7878a95342264153b4bdd907d9632 (diff) | |
parent | 757ba862e9ad30e64d3196004df98ee198f03107 (diff) |
Merge branch 'battery'
-rw-r--r-- | src/target/firmware/Makefile | 3 | ||||
-rw-r--r-- | src/target/firmware/apps/rssi/main.c | 22 | ||||
-rw-r--r-- | src/target/firmware/fb/font.c | 2 | ||||
-rw-r--r-- | src/target/firmware/fb/symbols.c | 113 | ||||
-rw-r--r-- | src/target/firmware/include/fb/font.h | 1 |
5 files changed, 138 insertions, 3 deletions
diff --git a/src/target/firmware/Makefile b/src/target/firmware/Makefile index 21892a42..a71eef60 100644 --- a/src/target/firmware/Makefile +++ b/src/target/firmware/Makefile @@ -9,7 +9,8 @@ APPLICATIONS?=hello_world compal_dsp_dump layer1 loader chainload rssi # Framebuffer support, board specific drivers # -FB_OBJS=fb/framebuffer.o fb/font.o fb/helvR08.o fb/helvB14.o fb/c64.o +FB_OBJS=fb/framebuffer.o fb/font.o fb/helvR08.o fb/helvB14.o fb/c64.o \ + fb/symbols.o FB_e88_OBJS=$(FB_OBJS) fb/fb_bw8.o fb/fb_st7558.o FB_e99_OBJS=$(FB_OBJS) fb/fb_rgb332.o fb/fb_ssd1783.o diff --git a/src/target/firmware/apps/rssi/main.c b/src/target/firmware/apps/rssi/main.c index a189740f..7d10e1cd 100644 --- a/src/target/firmware/apps/rssi/main.c +++ b/src/target/firmware/apps/rssi/main.c @@ -50,6 +50,7 @@ #include <osmocom/gsm/rsl.h> #include <osmocom/gsm/protocol/gsm_04_08.h> #include <osmocom/gsm/gsm48_ie.h> +#include <battery/battery.h> enum key_codes key_code = KEY_INV; int key_pressed = 0; @@ -170,6 +171,7 @@ static void print_display(char *text, int *y, int c) static void refresh_display(void) { char text[16]; + int bat = battery_info.battery_percent; fb_clear(); @@ -179,9 +181,25 @@ static void refresh_display(void) fb_setfg(FB_COLOR_BLUE); fb_setfont(FB_FONT_HELVR08); fb_gotoxy(0, 7); - fb_putstr("Osmocom Monitor Tool", -1); - fb_gotoxy(0, 10); + fb_putstr("Osmocom RSSI", -1); + fb_setfg(FB_COLOR_RGB(0xc0, 0xc0, 0x00)); + fb_setfont(FB_FONT_SYMBOLS); + fb_gotoxy(framebuffer->width - 15, 8); + if (bat >= 100 && (battery_info.flags & BATTERY_CHG_ENABLED) + && !(battery_info.flags & BATTERY_CHARGING)) + fb_putstr("@HHBC", framebuffer->width); + else { + sprintf(text, "@%c%c%cC", (bat >= 30) ? 'B':'A', + (bat >= 60) ? 'B':'A', (bat >= 90) ? 'B':'A'); + fb_putstr(text, framebuffer->width); + } + fb_gotoxy(0, 8); + sprintf(text, "%c%cE%c%c", (power >= 40) ? 'D':'G', + (power >= 10) ? 'D':'G', (power >= 10) ? 'F':'G', + (power >= 40) ? 'F':'G'); + fb_putstr(text, framebuffer->width); fb_setfg(FB_COLOR_GREEN); + fb_gotoxy(0, 10); fb_boxto(framebuffer->width - 1, 10); } fb_setfg(FB_COLOR_BLACK); diff --git a/src/target/firmware/fb/font.c b/src/target/firmware/fb/font.c index d98096f3..18c1bfe9 100644 --- a/src/target/firmware/fb/font.c +++ b/src/target/firmware/fb/font.c @@ -32,6 +32,7 @@ extern const struct fb_font font_helvR14; extern const struct fb_font font_helvB14; // extern const struct fb_font font_helvB24; extern const struct fb_font font_c64; +extern const struct fb_font font_symbols; const struct fb_font *fb_fonts[]={ // &font_4x6, @@ -43,6 +44,7 @@ const struct fb_font *fb_fonts[]={ &font_helvB14, // &font_helvB24, &font_c64, + &font_symbols, }; const struct fb_char * diff --git a/src/target/firmware/fb/symbols.c b/src/target/firmware/fb/symbols.c new file mode 100644 index 00000000..e9eab82a --- /dev/null +++ b/src/target/firmware/fb/symbols.c @@ -0,0 +1,113 @@ +#include <fb/font.h> +static const uint8_t font_symbols_data[] = { +/* @ battery - */ + /*0000:*/ 3, 3, 8, 0, 0, /* width and bbox (w,h,x,y) */ + /*0005:*/ 0x60, /* .##..... */ + /*0006:*/ 0x40, /* .#...... */ + /*0007:*/ 0x40, /* .#...... */ + /*0008:*/ 0x40, /* .#...... */ + /*0009:*/ 0x40, /* .#...... */ + /*000a:*/ 0x40, /* .#...... */ + /*000b:*/ 0x40, /* .#...... */ + /*000c:*/ 0x60, /* .##..... */ +/* A battery empty */ + /*000d:*/ 3, 3, 8, 0, 0, /* width and bbox (w,h,x,y) */ + /*0012:*/ 0xe0, /* ###..... */ + /*0013:*/ 0x00, /* ........ */ + /*0014:*/ 0x00, /* ........ */ + /*0015:*/ 0x00, /* ........ */ + /*0016:*/ 0x00, /* ........ */ + /*0017:*/ 0x00, /* ........ */ + /*0018:*/ 0x00, /* ........ */ + /*0019:*/ 0xe0, /* ###..... */ +/* B battery full */ + /*001a:*/ 3, 3, 8, 0, 0, /* width and bbox (w,h,x,y) */ + /*001f:*/ 0xe0, /* ###..... */ + /*0020:*/ 0x00, /* ........ */ + /*0021:*/ 0xc0, /* ##...... */ + /*0022:*/ 0xc0, /* ##...... */ + /*0023:*/ 0xc0, /* ##...... */ + /*0024:*/ 0xc0, /* ##...... */ + /*0025:*/ 0x00, /* ........ */ + /*0026:*/ 0xe0, /* ###..... */ +/* C battery + */ + /*0027:*/ 3, 3, 8, 0, 0, /* width and bbox (w,h,x,y) */ + /*002c:*/ 0x80, /* #....... */ + /*002d:*/ 0x80, /* #....... */ + /*002e:*/ 0xc0, /* ##...... */ + /*002f:*/ 0xc0, /* ##...... */ + /*0030:*/ 0xc0, /* ##...... */ + /*0031:*/ 0xc0, /* ##...... */ + /*0032:*/ 0x80, /* #....... */ + /*0033:*/ 0x80, /* #....... */ +/* D radiation left */ + /*0034:*/ 3, 3, 8, 0, 0, /* width and bbox (w,h,x,y) */ + /*0039:*/ 0x20, /* ..#..... */ + /*003a:*/ 0x40, /* .#...... */ + /*003b:*/ 0x20, /* ..#..... */ + /*003c:*/ 0x00, /* ........ */ + /*003d:*/ 0x00, /* ........ */ + /*003e:*/ 0x00, /* ........ */ + /*003f:*/ 0x00, /* ........ */ + /*0040:*/ 0x00, /* ........ */ +/* E tower */ + /*0041:*/ 5, 5, 8, 0, 0, /* width and bbox (w,h,x,y) */ + /*0046:*/ 0x20, /* ..#..... */ + /*0047:*/ 0x50, /* .#.#.... */ + /*0048:*/ 0x20, /* ..#..... */ + /*0049:*/ 0x20, /* ..#..... */ + /*004a:*/ 0x50, /* .#.#.... */ + /*004b:*/ 0x50, /* .#.#.... */ + /*004c:*/ 0x88, /* #...#... */ + /*004d:*/ 0xf8, /* #####... */ +/* F radiation right */ + /*004e:*/ 3, 3, 8, 0, 0, /* width and bbox (w,h,x,y) */ + /*0053:*/ 0x80, /* #....... */ + /*0054:*/ 0x40, /* .#...... */ + /*0055:*/ 0x80, /* #....... */ + /*0056:*/ 0x00, /* ........ */ + /*0057:*/ 0x00, /* ........ */ + /*0058:*/ 0x00, /* ........ */ + /*0059:*/ 0x00, /* ........ */ + /*005a:*/ 0x00, /* ........ */ +/* G no radiation */ + /*005b:*/ 3, 3, 8, 0, 0, /* width and bbox (w,h,x,y) */ + /*0060:*/ 0x00, /* ........ */ + /*0061:*/ 0x00, /* ........ */ + /*0062:*/ 0x00, /* ........ */ + /*0063:*/ 0x00, /* ........ */ + /*0064:*/ 0x00, /* ........ */ + /*0065:*/ 0x00, /* ........ */ + /*0066:*/ 0x00, /* ........ */ + /*0067:*/ 0x00, /* ........ */ +/* H battery loaded */ + /*0068:*/ 3, 3, 8, 0, 0, /* width and bbox (w,h,x,y) */ + /*006d:*/ 0xe0, /* ###..... */ + /*006e:*/ 0x00, /* ........ */ + /*006f:*/ 0xe0, /* ###..... */ + /*0070:*/ 0xe0, /* ###..... */ + /*0071:*/ 0xe0, /* ###..... */ + /*0072:*/ 0xe0, /* ###..... */ + /*0073:*/ 0x00, /* ........ */ + /*0074:*/ 0xe0, /* ###..... */ +}; +static const uint16_t font_symbols_offsets[] = { + 0x0000 /* '@' */, + 0x000d /* 'A' */, + 0x001a /* 'B' */, + 0x0027 /* 'C' */, + 0x0034 /* 'D' */, + 0x0041 /* 'E' */, + 0x004e /* 'F' */, + 0x005b /* 'G' */, + 0x0068 /* 'H' */, +}; +const struct fb_font font_symbols = { + .height = 8, + .ascent = 8, + .firstchar = 64, /* '@' */ + .lastchar = 72, + .chardata = font_symbols_data, + .charoffs = font_symbols_offsets, +}; + diff --git a/src/target/firmware/include/fb/font.h b/src/target/firmware/include/fb/font.h index 40a6974b..9dee8ffb 100644 --- a/src/target/firmware/include/fb/font.h +++ b/src/target/firmware/include/fb/font.h @@ -70,6 +70,7 @@ enum fb_font_id { FB_FONT_HELVB14, // FB_FONT_HELVB24, FB_FONT_C64, + FB_FONT_SYMBOLS, }; extern const struct fb_font *fb_fonts[]; // note: has to match fb_font_id enum! |