/* Handler function to update the time, which gets triggered by the TickTimerService. */ static void handle_tick(struct tm *tick_time, TimeUnits units_changed) { if ((units_changed & SECOND_UNIT) == SECOND_UNIT) { update_seconds(); } if ((units_changed & MINUTE_UNIT) == MINUTE_UNIT) { update_time(); } #if VIBE_ON_HOUR if ((units_changed & HOUR_UNIT) == HOUR_UNIT) { vibes_double_pulse(); } #endif }
static void handle_tick(struct tm *tick_time, TimeUnits units_changed) { if (units_changed & DAY_UNIT) { update_days(tick_time); } if (units_changed & HOUR_UNIT) { update_hours(tick_time); } if (units_changed & MINUTE_UNIT) { update_minutes(tick_time); } if (units_changed & SECOND_UNIT) { update_seconds(tick_time); } }
static void handle_tick(struct tm *tick_time, TimeUnits units_changed) { if (units_changed & DAY_UNIT) { static char date_text[] = "XXXX"; int new_cur_day = tick_time->tm_year*1000 + tick_time->tm_yday; if (new_cur_day != cur_day) { cur_day = new_cur_day; switch(tick_time->tm_mday) { case 1 : case 21 : case 31 : strftime(date_text, sizeof(date_text), "%est", tick_time); break; case 2 : case 22 : strftime(date_text, sizeof(date_text), "%end", tick_time); break; case 3 : case 23 : strftime(date_text, sizeof(date_text), "%erd", tick_time); break; default : strftime(date_text, sizeof(date_text), "%eth", tick_time); break; } text_layer_set_text(layer_date_text, date_text); } } if (units_changed & HOUR_UNIT) { update_hours(tick_time); } if (units_changed & MINUTE_UNIT) { update_minutes(tick_time); } if (units_changed & SECOND_UNIT) { update_seconds(tick_time); } }
static void update_display(struct tm *current_time, bool force_update) { update_seconds(current_time->tm_sec); if (current_time->tm_sec == 0 || force_update) { // the hours and minutes update_time(current_time); if ((current_time->tm_hour == 0 && current_time->tm_min == 0) || force_update) { // the day and date update_date(current_time->tm_mday, current_time->tm_wday); if (current_time->tm_mday == 1 || force_update) { update_month(current_time->tm_mon); if (current_time->tm_mon == 0 || force_update) { update_year(current_time->tm_year); } } } } }