X-Git-Url: https://git.karo-electronics.de/?p=oswald.git;a=blobdiff_plain;f=ui%2Foswald_watch_faces.c;h=4ca034fb9951a97e4938cbac5a9e80b4d5e2771c;hp=7e27fd40ca58a80cd81cc421fbde2c37693103e7;hb=ad140c1dc1090e2a99ff7a362713436e0ae51c7d;hpb=b83e605bc8ba69950a84b6ed268f0c196f68762c 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;