]> git.karo-electronics.de Git - oswald.git/blobdiff - ui/oswald_main.c
Countless fixes and enhancements
[oswald.git] / ui / oswald_main.c
index 82b856712f9ebe3a1ec42c3c64dcac273b2a3a4c..df95ebb8547c164eb8c363de261ad5952212cf2e 100644 (file)
@@ -27,11 +27,20 @@ void oswald_change_to_screen(screen_number screen_id)
        }
 }
 
-void oswald_set_time(u8t hour, u8t minute, u8t second)
+void oswald_set_time(u8t hour, u8t minute, u8t second, boolean clk24hr)
 {
        OswaldClk.hour = hour;
        OswaldClk.minute = minute;
        OswaldClk.second = second;
+       OswaldClk.clk24hr = clk24hr;
+}
+
+void oswald_set_date(u8t day, u8t month, u16t year, boolean day_first)
+{
+       OswaldClk.day = day;
+       OswaldClk.month = month;
+       OswaldClk.year = year;
+       OswaldClk.day_first = day_first;
 }
 
 static void update_clock_state (void)
@@ -63,7 +72,20 @@ void oswald_one_second_tick(void)
        if (OswaldState.screen->event_func != NULL &&
            (OswaldState.screen->event_mask & EVENT_ONE_SEC_TIMER))
                OswaldState.screen->event_func(EVENT_ONE_SEC_TIMER, NULL);
-       // oswald_update_screen();
+}
+
+void oswald_centisecond_tick(void)
+{
+       if (OswaldState.screen->event_func != NULL &&
+           (OswaldState.screen->event_mask & EVENT_CS_TIMER))
+               OswaldState.screen->event_func(EVENT_CS_TIMER, NULL);
+}
+
+void oswald_halfsecond_tick(void)
+{
+       if (OswaldState.screen->event_func != NULL &&
+           (OswaldState.screen->event_mask & EVENT_HALF_SEC_TIMER))
+               OswaldState.screen->event_func(EVENT_HALF_SEC_TIMER, NULL);
 }
 
 void oswald_handle_button_press(watch_button button)
@@ -78,6 +100,7 @@ void oswald_handle_button_press(watch_button button)
                                OswaldState.screen->event_func(EVENT_USER_BUTTONS, &button);
                        break;
                case BUTTON_C:
+                       OswaldState.screen->event_func(EVENT_SCREEN_DESTROY, NULL);
                        // next screen
                        OswaldState.screen_id++;
                        if (OswaldState.screen_id >= LAST_SCREEN) {
@@ -96,16 +119,35 @@ void oswald_handle_button_press(watch_button button)
        };
 }
 
+void oswald_handle_accel_event(u8t x, u8t y, u8t z)
+{
+       accel_data_t accel_data;
+
+       accel_data.x = x;
+       accel_data.y = y;
+       accel_data.z = z;
+
+       if (OswaldState.screen->event_func != NULL &&
+           (OswaldState.screen->event_mask & EVENT_ACCEL_UPDATE))
+               OswaldState.screen->event_func(EVENT_ACCEL_UPDATE, &accel_data);
+}
+
+void oswald_handle_ambientlight_event(u8t light_level)
+{
+       if (OswaldState.screen->event_func != NULL &&
+           (OswaldState.screen->event_mask & EVENT_AMBIENTLIGHT_UPDATE))
+               OswaldState.screen->event_func(EVENT_AMBIENTLIGHT_UPDATE, &light_level);
+}
+
 void oswald_init(void)
 {
        OswaldScreens[IDLE_SCREEN].event_mask = EVENT_USER_BUTTONS | EVENT_ONE_SEC_TIMER;
        OswaldScreens[IDLE_SCREEN].event_func = idle_handle_events;
 
-       OswaldScreens[ACCEL_DISPLAY_SCREEN].event_mask = EVENT_USER_BUTTONS;
+       OswaldScreens[ACCEL_DISPLAY_SCREEN].event_mask = EVENT_USER_BUTTONS | EVENT_ACCEL_UPDATE;
        OswaldScreens[ACCEL_DISPLAY_SCREEN].event_func = accel_handle_events;
-       
 
-       OswaldScreens[DATETIME_SETTING_SCREEN].event_mask = EVENT_USER_BUTTONS | EVENT_ONE_SEC_TIMER;
+       OswaldScreens[DATETIME_SETTING_SCREEN].event_mask = EVENT_USER_BUTTONS | EVENT_HALF_SEC_TIMER;
        OswaldScreens[DATETIME_SETTING_SCREEN].event_func = datetime_setup_events;
 
        OswaldScreens[MENU_TEST_SCREEN].event_mask = EVENT_USER_BUTTONS;