void handle_init(void) { window = window_create(); tick_timer_service_subscribe(MINUTE_UNIT, tick_handler); accel_tap_service_subscribe(tap_handler); hour_text_layer = text_layer_create(GRect(0, 0, 144, 107)); text_layer_set_background_color(hour_text_layer, GColorBlack); text_layer_set_text_color(hour_text_layer, GColorWhite); text_layer_set_text(hour_text_layer, "00"); text_layer_set_font(hour_text_layer, fonts_get_system_font(FONT_KEY_ROBOTO_BOLD_SUBSET_49)); //TODO: Make the numbers prettier. Maybe use custom font/rendering? text_layer_set_text_alignment(hour_text_layer, GTextAlignmentCenter); minute_text_layer = text_layer_create(GRect(0, 107, 144, 61)); text_layer_set_background_color(minute_text_layer, GColorBlack); text_layer_set_text_color(minute_text_layer, GColorWhite); text_layer_set_text(minute_text_layer, "00"); text_layer_set_font(minute_text_layer, fonts_get_system_font(FONT_KEY_ROBOTO_BOLD_SUBSET_49)); text_layer_set_text_alignment(minute_text_layer, GTextAlignmentCenter); layer_add_child(window_get_root_layer(window), text_layer_get_layer(hour_text_layer)); layer_add_child(window_get_root_layer(window), text_layer_get_layer(minute_text_layer)); update_hour(); update_minute(); window_stack_push(window, true); }
static void update_all(void) { update_minute(); update_daily(); update_weather(FORCE_WEATHER_UPDATE); battery_handler(battery_state_service_peek()); // force refresh bluetooth_handler(bluetooth_connection_service_peek()); }
static void time_handler(struct tm *tick_time, TimeUnits units_changed) { static int current_day = -1; update_minute(); update_weather(tick_time->tm_min); // saves computation of day, month, year, from being calculated every minute if(current_day != tick_time->tm_yday) { current_day = tick_time->tm_yday; update_daily(); } }
static void tick_handler_minute(struct tm *tick_time, TimeUnits units_changed) { update_minute(); }