From: Nils Faerber Date: Sat, 27 Apr 2013 20:19:55 +0000 (+0200) Subject: Lot's of stuff... X-Git-Url: https://git.karo-electronics.de/?p=oswald.git;a=commitdiff_plain;h=ad140c1dc1090e2a99ff7a362713436e0ae51c7d Lot's of stuff... --- diff --git a/README b/README index 51a6c5c..89390b3 100644 --- a/README +++ b/README @@ -1,3 +1,7 @@ OSWALD Open Smart Watch Application Loadable Development + +License: LGPL (Gnu Library Public License), +permission granted for static linking, +see individual files for licensing information diff --git a/metawatch b/metawatch new file mode 160000 index 0000000..cc2b5c0 --- /dev/null +++ b/metawatch @@ -0,0 +1 @@ +Subproject commit cc2b5c03be2b68fafd5b9022ab5a7bb70d5e7e7c diff --git a/ui/LcdDisplay.c b/ui/LcdDisplay.c index 725908a..f4e26c9 100644 --- a/ui/LcdDisplay.c +++ b/ui/LcdDisplay.c @@ -5,6 +5,7 @@ #include "LcdDisplay.h" + void oswald_draw_bitmap(const uint8_t xstart, const uint8_t ystart, const uint8_t width, const uint8_t height, const void *bmp) { uint8_t x, y; @@ -20,7 +21,7 @@ void oswald_draw_bitmap(const uint8_t xstart, const uint8_t ystart, const uint8_ } } -void DrawLcdLineBresenham(u8t xstart, u8t ystart, u8t xend, u8t yend) +void DrawLcdLineBresenham(const uint8_t xstart, const uint8_t ystart, const uint8_t xend, const uint8_t yend) { int x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err; @@ -65,7 +66,7 @@ void DrawLcdLineBresenham(u8t xstart, u8t ystart, u8t xend, u8t yend) // lcd_update_display(); } -void DrawLcdLineBresenhamWW(u8t xstart, u8t ystart, u8t xend, u8t yend, u8t thickness) +void DrawLcdLineBresenhamWW(const uint8_t xstart, const uint8_t ystart, const uint8_t xend, const uint8_t yend, const uint8_t thickness) { int i, x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err; @@ -122,7 +123,7 @@ void DrawLcdLineBresenhamWW(u8t xstart, u8t ystart, u8t xend, u8t yend, u8t thic // lcd_update_display(); } -u8t WriteLcdCharacter(u8t x, u8t y, u8t Character) +u8t WriteLcdCharacter(const uint8_t x, const uint8_t y, const uint8_t Character) { u8t CharacterHeight = GetCharacterHeight(); u8t CharacterWidth = GetCharacterWidth(Character); @@ -137,10 +138,10 @@ u8t WriteLcdCharacter(u8t x, u8t y, u8t Character) if (bitmap[ly] & (1< 147) ? 147 : mlen); } else if (strncmp(icmd, "$MCL", 4) == 0) { // clear message memset(MainMessage, 0, 148); + } else if (strncmp(icmd, "$BAT", 4) == 0) { // clear message + char rtime[16]; + snprintf(rtime, 16, "#BAT%d,%d\n", OswaldPowerState.charge_state, OswaldPowerState.percent); + hal_bluetooth_send_data(rtime, strlen(rtime)); } } } diff --git a/ui/oswald_watch_faces.c b/ui/oswald_watch_faces.c index 7e27fd4..4ca034f 100644 --- a/ui/oswald_watch_faces.c +++ b/ui/oswald_watch_faces.c @@ -16,6 +16,7 @@ #include "battery100_icon.xbm" #include "charger_icon.xbm" #include "bluetooth_icon.xbm" +#include "bluetooth_con_icon.xbm" /* sine table, per degree, factor 100 */ @@ -71,6 +72,43 @@ int16_t f_cos(int16_t v) return sintab[v]; } +void draw_status_icons(void) +{ + static uint8_t ci = 0; + + if (OswaldPowerState.source) { + oswald_draw_bitmap(81, 0, charger_icon_width, charger_icon_height, charger_icon_bits); + + if (OswaldPowerState.charge_state != POWER_CHARGER_DONE) { + if (ci==0) oswald_draw_bitmap(81, 0, battery0_icon_width, battery0_icon_height, battery0_icon_bits); + else if (ci==1) oswald_draw_bitmap(81, 0, battery25_icon_width, battery25_icon_height, battery25_icon_bits); + else if (ci==2) oswald_draw_bitmap(81, 0, battery50_icon_width, battery50_icon_height, battery50_icon_bits); + else if (ci==3) oswald_draw_bitmap(81, 0, battery75_icon_width, battery75_icon_height, battery75_icon_bits); + else if (ci==4) oswald_draw_bitmap(81, 0, battery100_icon_width, battery100_icon_height, battery100_icon_bits); + ci++; + ci %= 5; + } else { + oswald_draw_bitmap(81, 0, battery100_icon_width, battery100_icon_height, battery100_icon_bits); + } + } else { + if (OswaldPowerState.percent > 75) + oswald_draw_bitmap(81, 0, battery100_icon_width, battery100_icon_height, battery100_icon_bits); + else if (OswaldPowerState.percent > 50) + oswald_draw_bitmap(81, 0, battery75_icon_width, battery75_icon_height, battery75_icon_bits); + else if (OswaldPowerState.percent > 25) + oswald_draw_bitmap(81, 0, battery50_icon_width, battery50_icon_height, battery50_icon_bits); + else if (OswaldPowerState.percent > 5) + oswald_draw_bitmap(81, 0, battery25_icon_width, battery25_icon_height, battery25_icon_bits); + else + oswald_draw_bitmap(81, 0, battery0_icon_width, battery0_icon_height, battery0_icon_bits); + } + + if (hal_bluetooth_get_state() == BLUETOOTH_ON) + oswald_draw_bitmap(81, 0, bluetooth_icon_width, bluetooth_icon_height, bluetooth_icon_bits); + else if (hal_bluetooth_get_state() == BLUETOOTH_CONNECTED) + oswald_draw_bitmap(81, 0, bluetooth_con_icon_width, bluetooth_con_icon_height, bluetooth_con_icon_bits); +} + void DrawLcdAnaClock(boolean show_seconds) { int16_t i, x, y, x2, y2; @@ -99,40 +137,42 @@ void DrawLcdAnaClock(boolean show_seconds) snprintf(tstr, 16, "%02d", OswaldClk.day); WriteLcdString(70, 40, tstr); + // Marker // plot(R*cos(360° * i/N), R*sin(360° * i/N)) for (i=0; i<12; i++) { - tmp = 48 + ((43 * f_cos((360 / 12) * i)) / 100); - x = tmp; - tmp = 48 + ((43 * f_sin((360 / 12) * i)) / 100); - y = tmp; - tmp = 48 + ((48 * f_cos((360 / 12) * i)) / 100); - x2 = tmp; - tmp = 48 + ((48 * f_sin((360 / 12) * i)) / 100); - y2 = tmp; + x = 47 + ((43 * f_cos((360 / 12) * i)) / 100); + y = 47 + ((43 * f_sin((360 / 12) * i)) / 100); + x2 = 47 + ((47 * f_cos((360 / 12) * i)) / 100); + y2 = 47 + ((47 * f_sin((360 / 12) * i)) / 100); DrawLcdLineBresenhamWW(x, y, x2, y2, 2); + // g_printerr("br %d,%d %d,%d\n", x,y,x2,y2); }; // Hour - tmp = 48 + (30 * f_cos(((360 / 12) * hour) + ((OswaldClk.minute * 360) /12 / 60)) / 100); + tmp = 47 + (30 * f_cos(((360 / 12) * hour) + ((OswaldClk.minute * 360) /12 / 60)) / 100); x = tmp; - tmp = 48 + (30 * f_sin(((360 / 12) * hour) + ((OswaldClk.minute * 360) /12 / 60)) / 100); + tmp = 47 + (30 * f_sin(((360 / 12) * hour) + ((OswaldClk.minute * 360) /12 / 60)) / 100); y = tmp; - DrawLcdLineBresenhamWW(48, 48, x, y, 2); + DrawLcdLineBresenhamWW(47, 47, x, y, 2); + // Minute - tmp = 48 + ((40 * f_cos((360 / 60) * minute)) / 100); + tmp = 47 + ((40 * f_cos((360 / 60) * minute)) / 100); x = tmp; - tmp = 48 + ((40 * f_sin((360 / 60) * minute)) / 100); + tmp = 47 + ((40 * f_sin((360 / 60) * minute)) / 100); y = tmp; - DrawLcdLineBresenhamWW(48, 48, x, y, 2); + DrawLcdLineBresenhamWW(47, 47, x, y, 2); + if (show_seconds) { // Seconds - tmp = 48 + ((40 * f_cos((360 / 60) * seconds)) / 100); + tmp = 47 + ((40 * f_cos((360 / 60) * seconds)) / 100); x = tmp; - tmp = 48 + ((40 * f_sin((360 / 60) * seconds)) / 100); + tmp = 47 + ((40 * f_sin((360 / 60) * seconds)) / 100); y = tmp; - DrawLcdLineBresenham(48, 48, x, y); + DrawLcdLineBresenham(47, 47, x, y); }; + draw_status_icons(); + hal_lcd_update_display(); } @@ -186,6 +226,7 @@ void DrawLcdDigitalClock(boolean show_seconds) snprintf(tstr, 16, "%d/%d %d", OswaldClk.month, OswaldClk.day, OswaldClk.year); WriteLcdString(3, 25, tstr); +#if 0 if (OswaldPowerState.source) oswald_draw_bitmap(81, 4, charger_icon_width, charger_icon_height, charger_icon_bits); @@ -203,6 +244,9 @@ void DrawLcdDigitalClock(boolean show_seconds) if (hal_bluetooth_get_state() >= BLUETOOTH_ON) oswald_draw_bitmap(81, 4, bluetooth_icon_width, bluetooth_icon_height, bluetooth_icon_bits); +#else + draw_status_icons(); +#endif gRow = 0; gColumn = 45;