From b83e605bc8ba69950a84b6ed268f0c196f68762c Mon Sep 17 00:00:00 2001 From: Nils Faerber Date: Mon, 22 Apr 2013 01:10:13 +0200 Subject: [PATCH] Bluetooth handling, screen reworks for icons --- ui/Bluetooth_icon.xbm | 10 ++ ui/LcdDisplay.c | 15 ++ ui/LcdDisplay.h | 1 + ui/Oswald.xbm | 84 ++++++++++ ui/alarm_icon.xbm | 10 ++ ui/battery0_icon.xbm | 7 + ui/battery100_icon.xbm | 7 + ui/battery25_icon.xbm | 7 + ui/battery50_icon.xbm | 7 + ui/battery75_icon.xbm | 7 + ui/bluetooth_icon.xbm | 7 + ui/charger_icon.xbm | 7 + ui/downbutton_icon.xbm | 7 + ui/lapsebutton_icon.xbm | 7 + ui/oswald-ui.c | 40 ++++- ui/oswald.h | 3 + ui/oswald_graphics.c | 9 +- ui/oswald_graphics.h | 2 + ui/oswald_hal.h | 6 + ui/oswald_main.c | 25 +++ ui/oswald_main.h | 3 +- ui/oswald_screens.c | 319 ++++++++++++++++++++++++++---------- ui/oswald_screens.h | 3 +- ui/oswald_watch_faces.c | 43 +++++ ui/resetbutton_icon.xbm | 7 + ui/startstopbutton_icon.xbm | 7 + ui/stopwatch.xbm | 10 ++ ui/stopwatch_icon.xbm | 10 ++ ui/timesetup_icon.xbm | 10 ++ ui/upbutton_icon.xbm | 7 + ui/watch_icon.xbm | 10 ++ 31 files changed, 609 insertions(+), 88 deletions(-) create mode 100644 ui/Bluetooth_icon.xbm create mode 100644 ui/Oswald.xbm create mode 100644 ui/alarm_icon.xbm create mode 100644 ui/battery0_icon.xbm create mode 100644 ui/battery100_icon.xbm create mode 100644 ui/battery25_icon.xbm create mode 100644 ui/battery50_icon.xbm create mode 100644 ui/battery75_icon.xbm create mode 100644 ui/bluetooth_icon.xbm create mode 100644 ui/charger_icon.xbm create mode 100644 ui/downbutton_icon.xbm create mode 100644 ui/lapsebutton_icon.xbm create mode 100644 ui/resetbutton_icon.xbm create mode 100644 ui/startstopbutton_icon.xbm create mode 100644 ui/stopwatch.xbm create mode 100644 ui/stopwatch_icon.xbm create mode 100644 ui/timesetup_icon.xbm create mode 100644 ui/upbutton_icon.xbm create mode 100644 ui/watch_icon.xbm diff --git a/ui/Bluetooth_icon.xbm b/ui/Bluetooth_icon.xbm new file mode 100644 index 0000000..82ee5d1 --- /dev/null +++ b/ui/Bluetooth_icon.xbm @@ -0,0 +1,10 @@ +#define Bluetooth_icon_width 24 +#define Bluetooth_icon_height 24 +static unsigned char Bluetooth_icon_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x6c, 0x00, + 0x10, 0xcc, 0x00, 0x30, 0x8c, 0x01, 0x60, 0x0c, 0x03, 0xc0, 0x0c, 0x06, + 0x80, 0x0d, 0x03, 0x00, 0x8f, 0x01, 0x00, 0xce, 0x00, 0x00, 0x7c, 0x00, + 0x00, 0x3c, 0x00, 0x00, 0x6e, 0x00, 0x00, 0xcf, 0x00, 0x80, 0x8d, 0x01, + 0xc0, 0x0c, 0x03, 0x60, 0x0c, 0x06, 0x30, 0x0c, 0x03, 0x10, 0x8c, 0x01, + 0x00, 0xcc, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x1c, 0x00, + }; diff --git a/ui/LcdDisplay.c b/ui/LcdDisplay.c index f889bbc..725908a 100644 --- a/ui/LcdDisplay.c +++ b/ui/LcdDisplay.c @@ -5,6 +5,21 @@ #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; + uint8_t *cb; + + // we only draw set pixel, unset pixel remain as they are + for (y=0; ypixmap), state ? ui_g->darea->style->black_gc : ui_g->darea->style->white_gc, ix, iy+1); gdk_draw_point(GDK_DRAWABLE(ui_g->pixmap), state ? ui_g->darea->style->black_gc : ui_g->darea->style->white_gc, ix+1, iy+1); -// gtk_widget_queue_draw(ui_g->darea); } /* updates the actual LCD so that drawing becomes visible */ @@ -56,6 +55,45 @@ void hal_lcd_clear_display(void) gtk_widget_queue_draw(ui_g->darea); } +static bluetooth_state bt_state = BLUETOOTH_OFF; +static boolean bt_visible = FALSE; + +bluetooth_state hal_bluetooth_set_state(bluetooth_state state) +{ + bt_state = state; + if (bt_state == BLUETOOTH_OFF) + bt_visible = FALSE; + + return bt_state; +} + +bluetooth_state hal_bluetooth_get_state(void) +{ + return bt_state; +} + +uint8_t *hal_bluetooth_get_local_bdaddr(void) +{ + static uint8_t local_bdaddr[6] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55}; + + return local_bdaddr; +} + +void hal_bluetooth_set_visible(boolean visible) +{ + bt_visible = visible; +} + +boolean hal_bluetooth_get_visible(void) +{ + return bt_visible; +} + +void hal_bluetooth_send_data(const void *mdat, uint16_t mlen) +{ + g_printerr("write comm %d\n", mlen); +} + static gint configure_event (GtkWidget *widget, GdkEventConfigure *event, gpointer user_data) { diff --git a/ui/oswald.h b/ui/oswald.h index 31ee5cd..ee51438 100644 --- a/ui/oswald.h +++ b/ui/oswald.h @@ -1,5 +1,7 @@ #ifndef _OSWALD_H #define _OSWALD_H +#include +#include #include //#define DEBUG 1 @@ -55,6 +57,7 @@ typedef enum { IDLE_SCREEN = 0, ALARM_SETUP_SCREEN, STOP_WATCH_SCREEN, + BLUETOOTH_SCREEN, ACCEL_DISPLAY_SCREEN, MENU_TEST_SCREEN, // APPLICATION_SCREEN, diff --git a/ui/oswald_graphics.c b/ui/oswald_graphics.c index a6eb14f..304aa7a 100644 --- a/ui/oswald_graphics.c +++ b/ui/oswald_graphics.c @@ -5,21 +5,26 @@ #include "oswald_graphics.h" +#if 0 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; + uint8_t *cb; // we only draw set pixel, unset pixel remain as they are for (y=0; yevent_func(EVENT_AMBIENTLIGHT_UPDATE, &light_level); } +void oswald_handle_comm_input(uint16_t mlen, const void *mdat) +{ + char *icmd = (char *) mdat; + + if (icmd[0] == '$') { + if (strncmp(icmd, "$GRT", 4) == 0) { // get current RTC + char rtime[16]; + snprintf(rtime, 10, "%02d%02d%02d\n", OswaldClk.hour, OswaldClk.minute, OswaldClk.second); + hal_bluetooth_send_data(rtime, strlen(rtime)); + } else if (strncmp(icmd, "$MSG", 4) == 0) { // message on main screen + char *msg = (icmd+4); + mlen -= 4; + memset(MainMessage, 0, 148); + strncpy(MainMessage, msg, (mlen > 147) ? 147 : mlen); + } else if (strncmp(icmd, "$MCL", 4) == 0) { // clear message + memset(MainMessage, 0, 148); + } + } +} + void oswald_init(void) { OswaldScreens[IDLE_SCREEN].event_mask = EVENT_USER_BUTTONS | EVENT_ONE_SEC_TIMER; @@ -172,6 +194,9 @@ void oswald_init(void) OswaldScreens[STOP_WATCH_SCREEN].event_mask = EVENT_USER_BUTTONS | EVENT_CS_TIMER; OswaldScreens[STOP_WATCH_SCREEN].event_func = stop_watch_handle_events; + OswaldScreens[BLUETOOTH_SCREEN].event_mask = EVENT_USER_BUTTONS | EVENT_HALF_SEC_TIMER; + OswaldScreens[BLUETOOTH_SCREEN].event_func = bluetooth_screen_events; + OswaldScreens[ALARM_SCREEN].event_mask = EVENT_USER_BUTTONS | EVENT_HALF_SEC_TIMER; OswaldScreens[ALARM_SCREEN].event_func = alarm_handle_events; diff --git a/ui/oswald_main.h b/ui/oswald_main.h index 57e8008..f8f6ab4 100644 --- a/ui/oswald_main.h +++ b/ui/oswald_main.h @@ -8,6 +8,7 @@ extern alarm_clk OswaldAlarm; extern power_state OswaldPowerState; extern watch_state OswaldState; extern watch_screen OswaldScreens[]; +extern char MainMessage[]; /* gets triggered by OS timer function */ void oswald_one_second_tick(); @@ -24,5 +25,5 @@ void oswald_one_second_tick(void); void oswald_halfsecond_tick(void); void oswald_centisecond_tick(void); void oswald_init(void); - +void oswald_handle_comm_input(uint16_t mlen, const void *mdat); #endif diff --git a/ui/oswald_screens.c b/ui/oswald_screens.c index c09958f..a16bf39 100644 --- a/ui/oswald_screens.c +++ b/ui/oswald_screens.c @@ -9,6 +9,15 @@ #include "oswald_screens.h" +#include "timesetup_icon.xbm" +#include "stopwatch_icon.xbm" +#include "alarm_icon.xbm" +#include "startstopbutton_icon.xbm" +#include "lapsebutton_icon.xbm" +#include "upbutton_icon.xbm" +#include "downbutton_icon.xbm" +#include "Bluetooth_icon.xbm" + typedef struct { void (*screendraw_func)(boolean show_seconds); @@ -85,6 +94,10 @@ void draw_accel_screen(accel_data_t *accel_data) WriteLcdNumber(20, 18, accel_data->y); WriteLcdString(2, 34, "Z:"); WriteLcdNumber(20, 34, accel_data->z); + + WriteLcdString(2, 54, "Light:"); + WriteLcdNumber(40, 54, accel_data->z); + hal_lcd_update_display(); } @@ -123,57 +136,67 @@ static datetime_setup_data_t dt_setup_screen = { void draw_datetime_setup_screen(datetime_setup_data_t *sdata) { hal_lcd_clear_display(); - SetFont(MetaWatch16); - WriteLcdString(2, 2, "Set"); +// SetFont(MetaWatch16); +// WriteLcdString(2, 2, "Set"); + oswald_draw_bitmap(36, 0, timesetup_icon_width, timesetup_icon_height, timesetup_icon_bits); + + oswald_draw_bitmap(81, 6, upbutton_icon_width, upbutton_icon_height, upbutton_icon_bits); + oswald_draw_bitmap(81, 38, downbutton_icon_width, downbutton_icon_height, downbutton_icon_bits); SetFont(MetaWatchTime); if ((sdata->pos == 0 && sdata->on) || sdata->pos != 0) { - WriteLcdCharacter(2, 20, (OswaldClk.hour / 10)); - WriteLcdCharacter(14, 20, (OswaldClk.hour % 10)); + WriteLcdCharacter(2, 30, (OswaldClk.hour / 10)); + WriteLcdCharacter(14, 30, (OswaldClk.hour % 10)); } - WriteLcdCharacter(26, 20, TIME_CHARACTER_COLON_INDEX); + WriteLcdCharacter(26, 30, TIME_CHARACTER_COLON_INDEX); if ((sdata->pos == 1 && sdata->on) || sdata->pos != 1) { - WriteLcdCharacter(31, 20, (OswaldClk.minute / 10)); - WriteLcdCharacter(43, 20, (OswaldClk.minute % 10)); + WriteLcdCharacter(31, 30, (OswaldClk.minute / 10)); + WriteLcdCharacter(43, 30, (OswaldClk.minute % 10)); } - +/* WriteLcdCharacter(55, 20, TIME_CHARACTER_COLON_INDEX); if ((sdata->pos == 2 && sdata->on) || sdata->pos != 2) { WriteLcdCharacter(60, 20, (OswaldClk.second / 10)); WriteLcdCharacter(72, 20, (OswaldClk.second % 10)); } - +*/ SetFont(MetaWatch16); + if ((sdata->pos == 2 && sdata->on) || sdata->pos != 2) { + WriteLcdCharacter(59, 36, 0x30 + (OswaldClk.second / 10)); + WriteLcdCharacter(66, 36, 0x30 + (OswaldClk.second % 10)); + } + + if ((sdata->pos == 3 && sdata->on) || sdata->pos != 3) { - WriteLcdNumber(2, 45, OswaldClk.day); + WriteLcdNumber(2, 55, OswaldClk.day); } - WriteLcdString(18, 45, "."); + WriteLcdString(18, 55, "."); if ((sdata->pos == 4 && sdata->on) || sdata->pos != 4) { - WriteLcdNumber(22, 45, OswaldClk.month); + WriteLcdNumber(22, 55, OswaldClk.month); } - WriteLcdString(38, 45, "."); + WriteLcdString(38, 55, "."); if ((sdata->pos == 5 && sdata->on) || sdata->pos != 5) { - WriteLcdNumber(42, 45, OswaldClk.year); + WriteLcdNumber(42, 55, OswaldClk.year); } SetFont(MetaWatch7); if ((sdata->pos == 6 && sdata->on) || sdata->pos != 6) { if (OswaldClk.clk24hr) - WriteLcdString(2, 66, "x"); + WriteLcdString(2, 76, "x"); else - WriteLcdString(2, 66, "_"); + WriteLcdString(2, 76, "_"); } - WriteLcdString(15, 66, "24hr"); + WriteLcdString(15, 76, "24hr"); if ((sdata->pos == 7 && sdata->on) || sdata->pos != 7) { if (OswaldClk.day_first) - WriteLcdString(2, 79, "x"); + WriteLcdString(2, 89, "x"); else - WriteLcdString(2, 79, "_"); + WriteLcdString(2, 89, "_"); } - WriteLcdString(15, 79, "dd.mm. mm/dd"); + WriteLcdString(15, 89, "dd.mm. mm/dd"); hal_lcd_update_display(); } @@ -290,6 +313,11 @@ void datetime_setup_events(u16t event, void *data) }; } + +/* + * Alarm setup + */ + typedef struct { u8t pos; boolean on; @@ -303,63 +331,47 @@ void draw_alarm_setup_screen(alarm_setup_data_t *sdata) { hal_lcd_clear_display(); - SetFont(MetaWatch16); - WriteLcdString(2, 2, "Alarm"); + oswald_draw_bitmap(36, 0, alarm_icon_width, alarm_icon_height, alarm_icon_bits); + + oswald_draw_bitmap(81, 6, upbutton_icon_width, upbutton_icon_height, upbutton_icon_bits); + oswald_draw_bitmap(81, 38, downbutton_icon_width, downbutton_icon_height, downbutton_icon_bits); SetFont(MetaWatchTime); if ((sdata->pos == 0 && sdata->on) || sdata->pos != 0) { - WriteLcdCharacter(2, 20, (OswaldAlarm.hour / 10)); - WriteLcdCharacter(14, 20, (OswaldAlarm.hour % 10)); + WriteLcdCharacter(22, 30, (OswaldAlarm.hour / 10)); + WriteLcdCharacter(34, 30, (OswaldAlarm.hour % 10)); } - WriteLcdCharacter(26, 20, TIME_CHARACTER_COLON_INDEX); + WriteLcdCharacter(46, 30, TIME_CHARACTER_COLON_INDEX); if ((sdata->pos == 1 && sdata->on) || sdata->pos != 1) { - WriteLcdCharacter(31, 20, (OswaldAlarm.minute / 10)); - WriteLcdCharacter(43, 20, (OswaldAlarm.minute % 10)); + WriteLcdCharacter(51, 30, (OswaldAlarm.minute / 10)); + WriteLcdCharacter(63, 30, (OswaldAlarm.minute % 10)); } SetFont(MetaWatchMonospaced10); - WriteLcdCharacter(3, 45, 'S'); - WriteLcdCharacter(15, 45, 'M'); - WriteLcdCharacter(27, 45, 'T'); - WriteLcdCharacter(39, 45, 'W'); - WriteLcdCharacter(51, 45, 'T'); - WriteLcdCharacter(63, 45, 'F'); - WriteLcdCharacter(75, 45, 'S'); + WriteLcdCharacter(3, 55, 'S'); + WriteLcdCharacter(15, 55, 'M'); + WriteLcdCharacter(27, 55, 'T'); + WriteLcdCharacter(39, 55, 'W'); + WriteLcdCharacter(51, 55, 'T'); + WriteLcdCharacter(63, 55, 'F'); + WriteLcdCharacter(75, 55, 'S'); if ((sdata->pos == 2 && sdata->on) || sdata->pos != 2) - WriteLcdCharacter(3, 55, (OswaldAlarm.wday & WDAY_SUNDAY) ? 'x' : '_'); + WriteLcdCharacter(3, 65, (OswaldAlarm.wday & WDAY_SUNDAY) ? 'x' : '_'); if ((sdata->pos == 3 && sdata->on) || sdata->pos != 3) - WriteLcdCharacter(15, 55, (OswaldAlarm.wday & WDAY_MONDAY) ? 'x' : '_'); + WriteLcdCharacter(15, 65, (OswaldAlarm.wday & WDAY_MONDAY) ? 'x' : '_'); if ((sdata->pos == 4 && sdata->on) || sdata->pos != 4) - WriteLcdCharacter(27, 55, (OswaldAlarm.wday & WDAY_TUESDAY) ? 'x' : '_'); + WriteLcdCharacter(27, 65, (OswaldAlarm.wday & WDAY_TUESDAY) ? 'x' : '_'); if ((sdata->pos == 5 && sdata->on) || sdata->pos != 5) - WriteLcdCharacter(39, 55, (OswaldAlarm.wday & WDAY_WEDNESDAY) ? 'x' : '_'); + WriteLcdCharacter(39, 65, (OswaldAlarm.wday & WDAY_WEDNESDAY) ? 'x' : '_'); if ((sdata->pos == 6 && sdata->on) || sdata->pos != 6) - WriteLcdCharacter(51, 55, (OswaldAlarm.wday & WDAY_THURSDAY) ? 'x' : '_'); + WriteLcdCharacter(51, 65, (OswaldAlarm.wday & WDAY_THURSDAY) ? 'x' : '_'); if ((sdata->pos == 7 && sdata->on) || sdata->pos != 7) - WriteLcdCharacter(63, 55, (OswaldAlarm.wday & WDAY_FRIDAY) ? 'x' : '_'); + WriteLcdCharacter(63, 65, (OswaldAlarm.wday & WDAY_FRIDAY) ? 'x' : '_'); if ((sdata->pos == 8 && sdata->on) || sdata->pos != 8) - WriteLcdCharacter(75, 55, (OswaldAlarm.wday & WDAY_SATURDAY) ? 'x' : '_'); + WriteLcdCharacter(75, 65, (OswaldAlarm.wday & WDAY_SATURDAY) ? 'x' : '_'); -#if 0 - SetFont(MetaWatch7); - if ((sdata->pos == 6 && sdata->on) || sdata->pos != 6) { - if (OswaldClk.clk24hr) - WriteLcdString(2, 66, "x"); - else - WriteLcdString(2, 66, "_"); - } - WriteLcdString(15, 66, "24hr"); - - if ((sdata->pos == 7 && sdata->on) || sdata->pos != 7) { - if (OswaldClk.day_first) - WriteLcdString(2, 79, "x"); - else - WriteLcdString(2, 79, "_"); - } - WriteLcdString(15, 79, "dd.mm. mm/dd"); -#endif hal_lcd_update_display(); } @@ -457,6 +469,10 @@ void alarm_setup_events(u16t event, void *data) } +/* + * Test menu + */ + typedef struct { u8t menu_pos; } test_menu_t; @@ -512,6 +528,10 @@ void test_menu_handle_events(u16t event, void *data) } +/* + * Stop Watch + */ + typedef struct { u8t hr; u8t min; @@ -531,36 +551,19 @@ static void update_stop_watch_screen(stopwatch_data_t *sdata) char tstr[16]; SetFont(MetaWatchMonospaced10); -#if 0 - WriteLcdNumber(0, 30, sdata->hr); - WriteLcdCharacter(14, 30, ':'); - WriteLcdNumber(19, 30, sdata->min); - WriteLcdCharacter(33, 30, ':'); - WriteLcdNumber(38, 30, sdata->sec); - WriteLcdCharacter(52, 30, '.'); - WriteLcdNumber(57, 30, sdata->csec / 10); - - WriteLcdNumber(0, 50, sdata->lapse_hr); - WriteLcdCharacter(14, 50, ':'); - WriteLcdNumber(19, 50, sdata->lapse_min); - WriteLcdCharacter(33, 50, ':'); - WriteLcdNumber(38, 50, sdata->lapse_sec); - WriteLcdCharacter(52, 50, '.'); - WriteLcdNumber(57, 50, sdata->lapse_csec / 10); -#else snprintf(tstr, 16, "%02d:%02d:%02d.%1d", sdata->hr, sdata->min, sdata->sec, sdata->csec / 10); - WriteLcdString(0, 30, tstr); + WriteLcdString(5, 40, tstr); snprintf(tstr, 16, "%02d:%02d:%02d.%02d", sdata->lapse_hr, sdata->lapse_min, sdata->lapse_sec, sdata->lapse_csec); - WriteLcdString(0, 50, tstr); -#endif + WriteLcdString(5, 60, tstr); hal_lcd_update_display(); } static void draw_stop_watch_screen(stopwatch_data_t *sdata) { - SetFont(MetaWatch16); - WriteLcdString(2, 5, "StopWatch"); + oswald_draw_bitmap(36, 0, stopwatch_icon_width, stopwatch_icon_height, stopwatch_icon_bits); + oswald_draw_bitmap(81, 6, startstopbutton_icon_width, startstopbutton_icon_height, startstopbutton_icon_bits); + oswald_draw_bitmap(81, 38, lapsebutton_icon_width, lapsebutton_icon_height, lapsebutton_icon_bits); update_stop_watch_screen(sdata); } @@ -640,12 +643,17 @@ void stop_watch_handle_events(u16t event, void *data) } +/* + * when alarm is fired + */ void draw_alarm_screen(void) { hal_lcd_clear_display(); - SetFont(MetaWatch16); - WriteLcdString(2, 2, "ALARM !"); +// SetFont(MetaWatch16); +// WriteLcdString(2, 2, "ALARM !"); + oswald_draw_bitmap(36, 20, alarm_icon_width, alarm_icon_height, alarm_icon_bits); + hal_lcd_update_display(); } @@ -677,3 +685,148 @@ void alarm_handle_events(u16t event, void *data) }; } + +/* + * Bluetooth screen + */ +typedef struct { + u8t pos; + boolean bt_en; + boolean on; +} bluetooth_data_t; +static bluetooth_data_t bluetooth_screen = { + 0, + FALSE, + TRUE +}; + +void draw_bluetooth_screen(bluetooth_data_t *sdata) +{ + char bstr[20]; + uint8_t *bd_addr; + + hal_lcd_clear_display(); + + oswald_draw_bitmap(36, 0, Bluetooth_icon_width, Bluetooth_icon_height, Bluetooth_icon_bits); + + oswald_draw_bitmap(81, 6, upbutton_icon_width, upbutton_icon_height, upbutton_icon_bits); + oswald_draw_bitmap(81, 38, downbutton_icon_width, downbutton_icon_height, downbutton_icon_bits); + + SetFont(MetaWatch5); + WriteLcdString(2, 30, "Enable:"); + if ((sdata->pos == 0 && sdata->on) || sdata->pos != 0) { + WriteLcdCharacter(45, 30, bluetooth_screen.bt_en ? 'x' : '_'); + } + WriteLcdString(2, 39, "State:"); + switch (hal_bluetooth_get_state()) { + case BLUETOOTH_OFF: + WriteLcdString(45, 39, "off"); + break; + case BLUETOOTH_ON: + WriteLcdString(45, 39, "on"); + break; + case BLUETOOTH_CONNECTED: + WriteLcdString(45, 39, "conn."); + break; + default: + break; + }; + if (hal_bluetooth_get_state() >= BLUETOOTH_ON) { + bd_addr = hal_bluetooth_get_local_bdaddr(); + snprintf(bstr, 20, "%02x:%02x:%02x:%02x:%02x:%02x", bd_addr[5], bd_addr[4], bd_addr[3], bd_addr[2], bd_addr[1], bd_addr[0]); + WriteLcdString(2, 48, bstr); + } else { + } + WriteLcdString(2, 57, "Visible:"); + if ((sdata->pos == 1 && sdata->on) || sdata->pos != 1) { + WriteLcdCharacter(45, 57, hal_bluetooth_get_visible() ? 'x' : '_'); + } + + hal_lcd_update_display(); +} + +void bluetooth_handle_updown(u8t pos, s8t incr) +{ + switch (pos) { + case 0: + if (hal_bluetooth_get_state() >= BLUETOOTH_ON) { + hal_bluetooth_set_state(BLUETOOTH_OFF); + bluetooth_screen.bt_en = FALSE; + } else { + hal_bluetooth_set_state(BLUETOOTH_ON); + bluetooth_screen.bt_en = TRUE; + } + break; + case 1: + if (hal_bluetooth_get_state() >= BLUETOOTH_ON && !hal_bluetooth_get_visible()) { + hal_bluetooth_set_visible(TRUE); + } else { + hal_bluetooth_set_visible(FALSE); + } + break; + case 2: + break; + case 3: + break; + case 4: + break; + case 5: + break; + case 6: + break; + case 7: + break; + case 8: + break; + default: + break; + }; +} + +void handle_bluetooth_buttons(watch_button button, bluetooth_data_t *sdata) +{ + switch (button) { + case BUTTON_A: + bluetooth_handle_updown(sdata->pos, 1); + break; + case BUTTON_B: + bluetooth_handle_updown(sdata->pos, -1); + break; + case BUTTON_F: + sdata->pos++; + sdata->pos %= 2; + break; + default: + break; + } + draw_bluetooth_screen(sdata); +} + +void bluetooth_screen_events(u16t event, void *data) +{ + switch (event) { + case EVENT_SCREEN_VISIBLE: + bluetooth_screen.pos = 0; + bluetooth_screen.bt_en = (hal_bluetooth_get_state() > 0); + draw_bluetooth_screen(&bluetooth_screen); + hal_enable_halfsecond_timer(); + break; + case EVENT_SCREEN_DESTROY: + hal_disable_halfsecond_timer(); + break; + case EVENT_USER_BUTTONS: + dbg_out("button event %d\n", *(int *)data); + handle_bluetooth_buttons(*(watch_button *)data, &bluetooth_screen); + break; + case EVENT_HALF_SEC_TIMER: + if (bluetooth_screen.on) + bluetooth_screen.on = FALSE; + else + bluetooth_screen.on = TRUE; + draw_bluetooth_screen(&bluetooth_screen); + break; + default: + break; + }; +} + diff --git a/ui/oswald_screens.h b/ui/oswald_screens.h index 005b0bb..cd221fe 100644 --- a/ui/oswald_screens.h +++ b/ui/oswald_screens.h @@ -16,5 +16,6 @@ void stop_watch_handle_events(u16t event, void *data); void alarm_handle_events(u16t event, void *data); -#endif +void bluetooth_screen_events(u16t event, void *data); +#endif diff --git a/ui/oswald_watch_faces.c b/ui/oswald_watch_faces.c index 6db3196..7e27fd4 100644 --- a/ui/oswald_watch_faces.c +++ b/ui/oswald_watch_faces.c @@ -9,6 +9,16 @@ #include "oswald_watch_faces.h" +#include "battery0_icon.xbm" +#include "battery25_icon.xbm" +#include "battery50_icon.xbm" +#include "battery75_icon.xbm" +#include "battery100_icon.xbm" +#include "charger_icon.xbm" +#include "bluetooth_icon.xbm" + + +/* sine table, per degree, factor 100 */ int16_t sintab[]={ 0, 2, 3, 5, 7, 9, 10, 12, 14, 16, 17, 19, 21, 22, 24, 26, 28, 29, 31, 33, @@ -131,6 +141,7 @@ void DrawLcdDigitalClock(boolean show_seconds) int gRow = 3; int gColumn = 3; char tstr[16]; + int i; SetFont(MetaWatchTime); @@ -175,6 +186,37 @@ void DrawLcdDigitalClock(boolean show_seconds) snprintf(tstr, 16, "%d/%d %d", OswaldClk.month, OswaldClk.day, OswaldClk.year); WriteLcdString(3, 25, tstr); + if (OswaldPowerState.source) + oswald_draw_bitmap(81, 4, charger_icon_width, charger_icon_height, charger_icon_bits); + + if (OswaldPowerState.percent > 75) + oswald_draw_bitmap(81, 4, battery100_icon_width, battery100_icon_height, battery100_icon_bits); + else if (OswaldPowerState.percent > 50) + oswald_draw_bitmap(81, 4, battery75_icon_width, battery75_icon_height, battery75_icon_bits); + else if (OswaldPowerState.percent > 25) + oswald_draw_bitmap(81, 4, battery50_icon_width, battery50_icon_height, battery50_icon_bits); + else if (OswaldPowerState.percent > 5) + oswald_draw_bitmap(81, 4, battery25_icon_width, battery25_icon_height, battery25_icon_bits); + else + oswald_draw_bitmap(81, 4, battery0_icon_width, battery0_icon_height, battery0_icon_bits); + + + if (hal_bluetooth_get_state() >= BLUETOOTH_ON) + oswald_draw_bitmap(81, 4, bluetooth_icon_width, bluetooth_icon_height, bluetooth_icon_bits); + + gRow = 0; + gColumn = 45; + SetFont(MetaWatch5); + for (i=0; i 90) { + gRow = 0; + gColumn += 7; + } + if (gColumn > 95) + i = 255; + } +#if 0 snprintf(tstr, 16, "%d%% (%dmV)", OswaldPowerState.percent, OswaldPowerState.level); WriteLcdString(2, 48, tstr); WriteLcdString(2, 64, OswaldPowerState.source ? "ext" : "bat"); @@ -198,6 +240,7 @@ void DrawLcdDigitalClock(boolean show_seconds) break; }; }; +#endif hal_lcd_update_display(); } diff --git a/ui/resetbutton_icon.xbm b/ui/resetbutton_icon.xbm new file mode 100644 index 0000000..6576efc --- /dev/null +++ b/ui/resetbutton_icon.xbm @@ -0,0 +1,7 @@ +#define resetbutton_icon_width 15 +#define resetbutton_icon_height 20 +static unsigned char resetbutton_icon_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x0e, 0x00, 0xff, 0x00, + 0xff, 0x00, 0xce, 0x00, 0xcc, 0x00, 0xc8, 0x00, 0xc0, 0x00, 0xc0, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, }; diff --git a/ui/startstopbutton_icon.xbm b/ui/startstopbutton_icon.xbm new file mode 100644 index 0000000..160799b --- /dev/null +++ b/ui/startstopbutton_icon.xbm @@ -0,0 +1,7 @@ +#define startstopbutton_icon_width 15 +#define startstopbutton_icon_height 20 +static unsigned char startstopbutton_icon_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, + 0x00, 0x1b, 0x00, 0x3b, 0x00, 0x7b, 0x00, 0x7b, 0x00, 0x3b, 0x00, 0x1b, + 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, }; diff --git a/ui/stopwatch.xbm b/ui/stopwatch.xbm new file mode 100644 index 0000000..ce022fb --- /dev/null +++ b/ui/stopwatch.xbm @@ -0,0 +1,10 @@ +#define stopwatch_width 24 +#define stopwatch_height 24 +static unsigned char stopwatch_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x18, 0x00, 0x00, 0x18, 0x00, + 0x00, 0x7e, 0x10, 0x80, 0x81, 0x39, 0x40, 0x18, 0x1e, 0x20, 0x18, 0x0c, + 0x10, 0x18, 0x08, 0x08, 0x18, 0x10, 0x08, 0x18, 0x10, 0x04, 0x18, 0x20, + 0x04, 0x18, 0x20, 0x04, 0x18, 0x20, 0x04, 0x00, 0x20, 0x04, 0x00, 0x20, + 0x04, 0x00, 0x20, 0x08, 0x00, 0x10, 0x08, 0x00, 0x10, 0x10, 0x00, 0x08, + 0x20, 0x00, 0x04, 0x40, 0x00, 0x02, 0x80, 0x81, 0x01, 0x00, 0x7e, 0x00, + }; diff --git a/ui/stopwatch_icon.xbm b/ui/stopwatch_icon.xbm new file mode 100644 index 0000000..9282fb2 --- /dev/null +++ b/ui/stopwatch_icon.xbm @@ -0,0 +1,10 @@ +#define stopwatch_icon_width 24 +#define stopwatch_icon_height 24 +static unsigned char stopwatch_icon_bits[] = { + 0x00, 0x18, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x18, + 0x00, 0xff, 0x3c, 0xc0, 0xff, 0x3f, 0xe0, 0x00, 0x1f, 0x70, 0x18, 0x0e, + 0x38, 0x18, 0x1c, 0x18, 0x18, 0x18, 0x0c, 0x18, 0x30, 0x0c, 0x18, 0x30, + 0x0c, 0x18, 0x30, 0x0c, 0x18, 0x30, 0x0c, 0x18, 0x30, 0x0c, 0x00, 0x30, + 0x0c, 0x00, 0x30, 0x0c, 0x00, 0x30, 0x18, 0x00, 0x18, 0x38, 0x00, 0x1c, + 0x70, 0x00, 0x0e, 0xe0, 0x00, 0x07, 0xc0, 0xff, 0x03, 0x00, 0xff, 0x00, + }; diff --git a/ui/timesetup_icon.xbm b/ui/timesetup_icon.xbm new file mode 100644 index 0000000..5e8699d --- /dev/null +++ b/ui/timesetup_icon.xbm @@ -0,0 +1,10 @@ +#define timesetup_icon_width 24 +#define timesetup_icon_height 24 +static unsigned char timesetup_icon_bits[] = { + 0x00, 0xff, 0x00, 0xc0, 0xff, 0x03, 0xe0, 0x00, 0x07, 0x70, 0x18, 0x0e, + 0x38, 0x18, 0x1c, 0x18, 0x18, 0x18, 0x0c, 0x18, 0x30, 0x0c, 0x18, 0x30, + 0x0c, 0x18, 0x30, 0x0c, 0xf8, 0x31, 0x0c, 0xf8, 0x31, 0x0c, 0x00, 0x30, + 0x0c, 0x00, 0x30, 0x0c, 0x00, 0x30, 0x18, 0x00, 0x18, 0x38, 0x00, 0x1c, + 0x70, 0x00, 0x0e, 0xe0, 0x00, 0x07, 0xc0, 0xff, 0x03, 0x00, 0xff, 0x00, + 0xfe, 0x00, 0x00, 0xff, 0xff, 0x3f, 0xff, 0xff, 0x3f, 0xfe, 0x00, 0x00, + }; diff --git a/ui/upbutton_icon.xbm b/ui/upbutton_icon.xbm new file mode 100644 index 0000000..6e16dd4 --- /dev/null +++ b/ui/upbutton_icon.xbm @@ -0,0 +1,7 @@ +#define upbutton_icon_width 15 +#define upbutton_icon_height 20 +static unsigned char upbutton_icon_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, + 0x00, 0x1e, 0x00, 0x3f, 0x80, 0x7f, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x0c, + 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, }; diff --git a/ui/watch_icon.xbm b/ui/watch_icon.xbm new file mode 100644 index 0000000..ecd95d1 --- /dev/null +++ b/ui/watch_icon.xbm @@ -0,0 +1,10 @@ +#define watch_icon_width 24 +#define watch_icon_height 24 +static unsigned char watch_icon_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xff, 0x00, 0xc0, 0xff, 0x03, 0xe0, 0x00, 0x07, 0x70, 0x18, 0x0e, + 0x38, 0x18, 0x1c, 0x18, 0x18, 0x18, 0x0c, 0x18, 0x30, 0x0c, 0x18, 0x30, + 0x0c, 0x18, 0x30, 0x0c, 0xf8, 0x31, 0x0c, 0xf8, 0x31, 0x0c, 0x00, 0x30, + 0x0c, 0x00, 0x30, 0x0c, 0x00, 0x30, 0x18, 0x00, 0x18, 0x38, 0x00, 0x1c, + 0x70, 0x00, 0x0e, 0xe0, 0x00, 0x07, 0xc0, 0xff, 0x03, 0x00, 0xff, 0x00, + }; -- 2.39.2