void container_set_time(struct tm *t){ static char buffer[] = "00:00"; static char d_buffer[] = "September 26th"; if(clock_is_24h_style()){ strftime(buffer, sizeof(buffer), "%H:%M", t); } else{ strftime(buffer,sizeof(buffer),"%I:%M", t); } strftime(d_buffer,sizeof(d_buffer),"%d. %b. '%y", t); text_layer_set_text(base.time, buffer); text_layer_set_text(base.date, d_buffer); //APP_LOG(APP_LOG_LEVEL_DEBUG, "%s %s", buffer, d_buffer); int fix, hour; hour = t->tm_hour; if(hour > 12){ hour = hour-12; } fix = 132-(11*hour); if(hour == 12 || hour == 0){ fix = 0; } r_frame = GRect(14, fix, 144, 168); if(t->tm_sec == 0 && t->tm_min == 0){ GRect temp = layer_get_frame(base.root); animate_layer(base.root, &temp, &r_frame, 1000, 0); return; } layer_set_frame(base.root, GRect(14, fix, 144, 168)); }
void animate_code_on() { if (watch_otp_count) strcpy(pin_text, generateCode(otp_keys[otp_selected], timezone_offset)); else strcpy(pin_text, "123456"); otp_updated_at_tick = otp_update_tick; GRect start = text_pin_rect; switch(animation_direction) { case UP : start.origin.y += display_bounds.size.h; break; case DOWN : start.origin.y -= display_bounds.size.h; break; case LEFT : start.origin.x += display_bounds.size.w; break; case RIGHT : start.origin.x -= display_bounds.size.w; break; } animate_layer(text_layer_get_layer(text_pin_layer), AnimationCurveEaseOut, &start, &text_pin_rect, 300, on_animation_stopped_callback); }
void climber_animation(){ climber_runs++; climber_invert = !climber_invert; if(!is12){ if(climber_runs == 4){ climber_runs = 0; return; } } else{ if(climber_runs == 12){ climber_runs = 0; GRect temp1 = layer_get_frame(bitmap_layer_get_layer(guy)); GRect temp2 = GRect(30, 110, 14, 35); animate_layer(bitmap_layer_get_layer(guy), &temp1, &temp2, 1000, 0); bitmap_layer_set_bitmap(guy, standing_guy); return; } } if(climber_invert){ bitmap_layer_set_bitmap(guy, flipped_guy); } else{ bitmap_layer_set_bitmap(guy, default_guy); } if(!is12){ guy_timer = app_timer_register(625, climber_animation, NULL); } else{ guy_timer = app_timer_register(400, climber_animation, NULL); } }
void animation_control(void) { if (animation_count > 0) { animation_count--; return; } switch (animation_state) { case 0: // initial launch, animate the code and label on screen animation_state = 10; if (fonts_changed) set_fonts(); animate_code_on(); animate_label_on(); show_countdown_layer(); break; case 20: // animate the code off screen animation_state = 30; animation_direction = DOWN; animate_code_off(); break; case 30: // animate the code on screen animation_state = 10; animation_direction = LEFT; animate_code_on(); break; case 40: // animate the code and label off screen animation_state = 0; animation_count = 1; animate_code_off(); animate_label_off(); break; case 50: // animate the code and label and second counter off screen animation_state = 60; animation_unschedule_all(); animation_count = 1; animation_direction = RIGHT; hide_countdown_layer(); animate_code_off(); animate_label_off(); break; case 60: // animate the swipe layer on screen using the background color animation_state = 70; GRect start = GRect(0, display_bounds.size.h*-1, display_bounds.size.w, display_bounds.size.h); swipe_layer = text_layer_create(start); text_layer_set_background_color(swipe_layer, bg_color); Layer *window_layer = window_get_root_layer(single_code_main_window); layer_add_child(window_layer, text_layer_get_layer(swipe_layer)); animate_layer(text_layer_get_layer(swipe_layer), AnimationCurveEaseInOut, &start, &display_bounds, 500, on_animation_stopped_callback); break; case 70: // set the new colors and clear the swipe layer apply_display_colors(); text_layer_destroy(swipe_layer); animation_state = 0; animation_control(); break; } }
void climber_refresh_position(bool boot, struct tm *t){ int hour = t->tm_hour; if(hour > 12){ hour = hour-12; } int fix = 110-(11*hour); int fix2 = 4; if(hour%2 == 0){ fix2 = 3; } else{ fix2 = 7; } if(boot){ layer_set_frame(bitmap_layer_get_layer(guy), GRect(fix2, fix, 14, 27)); //APP_LOG(APP_LOG_LEVEL_DEBUG, "GRect(0, %d, 16, 29) (hour: %d)", fix, hour); if(hour%2 == 0){ bitmap_layer_set_bitmap(guy, default_guy); climber_invert = 0; } else{ bitmap_layer_set_bitmap(guy, flipped_guy); climber_invert = 1; } if(hour == 0 || hour == 12){ bitmap_layer_set_bitmap(guy, standing_guy); layer_set_frame(bitmap_layer_get_layer(guy), GRect(30, 110, 14, 35)); fix2 = 30; fix = 110; } } else{ if(t->tm_sec == 0 && t->tm_min == 0){ GRect temp = layer_get_frame(bitmap_layer_get_layer(guy)); int width = 0; if(hour == 12 || hour == 0){ width = 35; is12 = true; } else{ width = 27; is12 = false; } int length = 2500; int timerlength = 625; if(is12){ length = 4800; timerlength = 400; fix -= 4; } animate_layer(bitmap_layer_get_layer(guy), &temp, &GRect(fix2, fix, 14, width), length, 0); guy_timer = app_timer_register(timerlength, climber_animation, NULL); } } }
void animate_label_off() { GRect finish = text_label_rect; switch(animation_direction) { case UP : finish.origin.y -= display_bounds.size.h; break; case DOWN : finish.origin.y += display_bounds.size.h; break; case LEFT : finish.origin.x -= display_bounds.size.w; break; case RIGHT : finish.origin.x += display_bounds.size.w; break; } animate_layer(text_layer_get_layer(text_label_layer), AnimationCurveEaseIn, &text_label_rect, &finish, 300, on_animation_stopped_callback); }
void animate_label_on() { if (watch_otp_count) strcpy(label_text, otp_labels[otp_selected]); else strcpy(label_text, "EMPTY"); GRect start = text_label_rect; switch(animation_direction) { case UP : start.origin.y += display_bounds.size.h; break; case DOWN : start.origin.y -= display_bounds.size.h; break; case LEFT : start.origin.x += display_bounds.size.w; break; case RIGHT : start.origin.x -= display_bounds.size.w; break; } animate_layer(text_layer_get_layer(text_label_layer), AnimationCurveEaseOut, &start, &text_label_rect, 300, on_animation_stopped_callback); }
void tick_handler(struct tm *tick_time, TimeUnits units_changed){ hour = tick_time->tm_hour; minute = tick_time->tm_min; day = tick_time->tm_wday; mday = tick_time->tm_mday; second = tick_time->tm_sec; if(hour > 12){ fixedHour = hour-13; } else if(hour != 0){ fixedHour = hour-1; } else if(hour == 0){ fixedHour = 11; } if(main_settings.progressiveDrunk == 1){ if(hour > 1 && hour < 14){ main_settings.wordPack = 1; } else if(hour > 13 && hour < 19){ main_settings.wordPack = 2; } else if(hour > 18 && hour < 2){ main_settings.wordPack = 3; } } snprintf(word1Buffer, sizeof(word1Buffer), "%s", hourWords[0][fixedHour]); text_layer_set_text(first_word_t, word1Buffer); bottomMin = (minute%10); if(minute < 10){ snprintf(word3Buffer, sizeof(word3Buffer), "%s", ones[0][(int)bottomMin]); teenStatus = 1; } else if(minute > 10 && minute < 20){ snprintf(word3Buffer, sizeof(word3Buffer), "%s", teens[0][(minute%10)]); if(minute < 17){ teenStatus = 1; } else{ teenStatus = 2; } } else{ snprintf(word3Buffer, sizeof(word3Buffer), "%s", tens[0][(minute/10)]); teenStatus = 0; } text_layer_set_text(third_word_t, word3Buffer); switch(teenStatus){ case 0: snprintf(word4Buffer, sizeof(word4Buffer), "%s", ones[0][(int)bottomMin]); text_layer_set_text(fourth_word_t, word4Buffer); if(layer_get_hidden(text_layer_get_layer(fourth_word_t))){ layer_set_hidden(text_layer_get_layer(fourth_word_t), false); } break; case 1: layer_set_hidden(text_layer_get_layer(fourth_word_t), true); break; case 2: text_layer_set_text(fourth_word_t, "teen"); break; } if(minute % 10 == 0){ if(layer_get_hidden(text_layer_get_layer(fourth_word_t)) == 0){ layer_set_hidden(text_layer_get_layer(fourth_word_t), true); } } else{ if(layer_get_hidden(text_layer_get_layer(fourth_word_t)) && teenStatus != 1){ layer_set_hidden(text_layer_get_layer(fourth_word_t), false); } } if(main_settings.slotUse == SLOT_USE_DATE){ if(tick_time->tm_sec != 0 && !change && units_changed != DAY_UNIT){ goto SKIP_DATE; } change = false; switch(main_settings.dateFormat){ case DATE_FORMAT_DDMMYY: strftime(slotBuffer, sizeof(slotBuffer), "%d/%m/%y", tick_time); break; case DATE_FORMAT_MMDDYY: strftime(slotBuffer, sizeof(slotBuffer), "%m/%d/%y", tick_time); break; case DATE_FORMAT_MONTHDAYYEAR: if(mday == 1 || mday == 21 || mday == 31){ strftime(slotBuffer, sizeof(slotBuffer), "%b %dst, %Y", tick_time); } else if(mday == 2 || mday == 22){ strftime(slotBuffer, sizeof(slotBuffer), "%b %dnd, %Y", tick_time); } else if(mday == 3 || mday == 23){ strftime(slotBuffer, sizeof(slotBuffer), "%b %drd, %Y", tick_time); } else{ strftime(slotBuffer, sizeof(slotBuffer), "%b %dth, %Y", tick_time); } break; case DATE_FORMAT_WEEKDAY: snprintf(slotBuffer, sizeof(slotBuffer), "%s, it's %s", phrases_get_slot_swear(), daysChar[0][day]); break; } text_layer_set_text(slot_t, slotBuffer); } else if(main_settings.slotUse == SLOT_USE_TEMPERATURE){ if(tick_time->tm_sec != 0 && !change && units_changed != DAY_UNIT){ goto SKIP_DATE; } change = false; snprintf(slotBuffer, sizeof(slotBuffer), "%s, %d degrees.", phrases_get_slot_swear(), main_settings.previousTemp); text_layer_set_text(slot_t, slotBuffer); } SKIP_DATE:; if(minute == 20){ if(hour == 4 || hour == 16){ text_layer_set_text(second_word_t, "blazeit"); } } if(charging){ if(animation_i){ animate_layer(battery_bar_layer, &GRect(0, 0, 144, 168), &GRect(144, 0, 144, 168), 1000, 0); } else{ animate_layer(battery_bar_layer, &GRect(-144, 0, 144, 168), &GRect(0, 0, 144, 168), 1000, 0); } animation_i = !animation_i; } else{ GRect frame = layer_get_frame(battery_bar_layer); if(frame.origin.x != 0){ animate_layer(battery_bar_layer, &GRect(-144, 0, 144, 168), &GRect(0, 0, 144, 168), 500, 0); } } if(second == 59 && main_settings.animation != ANIMATION_DISABLED){ switch(minute){ case 59: fire_animation(first_word_t, 100, layer_get_frame(text_layer_get_layer(first_word_t)), false); fire_animation(second_word_t, 200, layer_get_frame(text_layer_get_layer(second_word_t)), true); fire_animation(third_word_t, 300, layer_get_frame(text_layer_get_layer(third_word_t)), false); fire_animation(fourth_word_t, 400, layer_get_frame(text_layer_get_layer(fourth_word_t)), false); break; default: fire_animation(third_word_t, 100, layer_get_frame(text_layer_get_layer(third_word_t)), false); fire_animation(fourth_word_t, 200, layer_get_frame(text_layer_get_layer(fourth_word_t)), false); break; } } if(main_settings.seconds){ static char seconds_buffer[] = "59."; snprintf(seconds_buffer, sizeof(seconds_buffer), "%d", second); text_layer_set_text(seconds_t, seconds_buffer); } }