WriteLcdNumber(20, 18, accel_data->y);
WriteLcdString(2, 34, "Z:");
WriteLcdNumber(20, 34, accel_data->z);
+ lcd_update_display();
}
void accel_handle_events(u16t event, void *data)
WriteLcdString(2, 79, "_");
}
WriteLcdString(15, 79, "dd.mm. mm/dd");
+
+ lcd_update_display();
}
void datetime_handle_updown(u8t pos, s8t incr)
WriteLcdString(2, 56, "Item 5");
WriteLcdString(50, 20+(9*test_menu.menu_pos), "*");
+ lcd_update_display();
}
static void handle_menu_user_buttons(watch_button button)
};
}
+
+typedef struct {
+ u8t hr;
+ u8t min;
+ u8t sec;
+ u8t csec;
+ u8t lapse_hr;
+ u8t lapse_min;
+ u8t lapse_sec;
+ u8t lapse_csec;
+ boolean running;
+} stopwatch_data_t;
+static stopwatch_data_t stopwatch_screen = { 0, 0, 0, 0, 0, 0, 0, 0, FALSE };
+
+
+static void update_stop_watch_screen(stopwatch_data_t *sdata)
+{
+ SetFont(MetaWatchMonospaced10);
+
+ 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);
+
+ lcd_update_display();
+}
+
+static void draw_stop_watch_screen(stopwatch_data_t *sdata)
+{
+ SetFont(MetaWatch16);
+ WriteLcdString(2, 5, "StopWatch");
+
+ update_stop_watch_screen(sdata);
+}
+
+static void handle_stop_watch_buttons(watch_button button)
+{
+ switch (button) {
+ case BUTTON_A: // start/stop
+ if (stopwatch_screen.running) {
+ disable_centisecond_timer();
+ stopwatch_screen.running = FALSE;
+ } else {
+ enable_centisecond_timer();
+ stopwatch_screen.running = TRUE;
+ }
+ break;
+ case BUTTON_B: // lapse
+ stopwatch_screen.lapse_hr = stopwatch_screen.hr;
+ stopwatch_screen.lapse_min = stopwatch_screen.min;
+ stopwatch_screen.lapse_sec = stopwatch_screen.sec;
+ stopwatch_screen.lapse_csec = stopwatch_screen.csec;
+ break;
+ case BUTTON_D: // reset
+ stopwatch_screen.hr = 0;
+ stopwatch_screen.min = 0;
+ stopwatch_screen.sec = 0;
+ stopwatch_screen.csec = 0;
+ stopwatch_screen.lapse_hr = 0;
+ stopwatch_screen.lapse_min = 0;
+ stopwatch_screen.lapse_sec = 0;
+ stopwatch_screen.lapse_csec = 0;
+ break;
+ default:
+ break;
+ }
+}
+
+void stop_watch_handle_events(u16t event, void *data)
+{
+ switch (event) {
+ case EVENT_USER_BUTTONS:
+ dbg_out("button event %d\n", *(int *)data);
+ handle_stop_watch_buttons(*(watch_button *)data);
+ update_stop_watch_screen(&stopwatch_screen);
+ break;
+ case EVENT_SCREEN_VISIBLE:
+ lcd_clear_display();
+ draw_stop_watch_screen(&stopwatch_screen);
+ break;
+ case EVENT_SCREEN_DESTROY:
+ disable_centisecond_timer();
+ stopwatch_screen.running = FALSE;
+ break;
+ case EVENT_CS_TIMER:
+ stopwatch_screen.csec++;
+ if (stopwatch_screen.csec > 99) {
+ stopwatch_screen.csec = 0;
+ stopwatch_screen.sec++;
+ };
+ if (stopwatch_screen.sec > 59) {
+ stopwatch_screen.sec = 0;
+ stopwatch_screen.min++;
+ };
+ if (stopwatch_screen.min > 59) {
+ stopwatch_screen.min = 0;
+ stopwatch_screen.hr++;
+ };
+ if (stopwatch_screen.hr > 59) {
+ stopwatch_screen.hr = 0;
+ };
+ if (stopwatch_screen.csec % 10 == 0)
+ update_stop_watch_screen(&stopwatch_screen);
+ break;
+ default:
+ break;
+ };
+}