// There are two of these because we have to schedule the next animation // while the other is still in motion because otherwise we cancel the // in-progress animation. // (Actually, with the current implementation this is probably no longer // necessary.) PropertyAnimation up_animation; PropertyAnimation down_animation; // This works around the inability to use the current GRect macro // for constants. #define ConstantGRect(x, y, w, h) {{(x), (y)}, {(w), (h)}} GRect UPPER_TO_RECT = ConstantGRect(0, 5, 144, 168-5); GRect LOWER_TO_RECT = ConstantGRect(0, 112, 144, 168-112); #define ANIMATION_DURATION_IN_MS 1500 void init_animations() { property_animation_init_layer_frame(&up_animation, &text_time_layer.layer, &LOWER_TO_RECT, &UPPER_TO_RECT); animation_set_duration(&up_animation.animation, ANIMATION_DURATION_IN_MS); animation_set_curve(&up_animation.animation, AnimationCurveEaseOut); property_animation_init_layer_frame(&down_animation, &text_time_layer.layer, &UPPER_TO_RECT, &LOWER_TO_RECT);
static TextLayer *text_time_layer; static TextLayer *text_ampm_layer; static TextLayer *text_secs_layer; static TextLayer *text_days_layer; static TextLayer *text_date_layer; static TextLayer *text_week_layer; static GFont *font_time; static GFont *font_days; static GFont *font_date; static InverterLayer *currentDayLayer; static AppSync app; static uint8_t sync_buffer[256]; // Define layer rectangles (x, y, width, height) GRect TIME_RECT = ConstantGRect( 29, 4, 110, 72 ); GRect AMPM_RECT = ConstantGRect( 122, 0, 22, 22 ); GRect SECS_RECT = ConstantGRect( 124, -1, 24, 24 ); GRect DATE_RECT = ConstantGRect( 11, 132, 80, 50 ); GRect WEEK_RECT = ConstantGRect( 72, 132, 92, 50 ); GRect DAYS_RECT = ConstantGRect( 17, 94, 140, 30 ); GRect BATT_RECT = ConstantGRect( 20, 79, 103, 17 ); GRect BT_RECT = ConstantGRect( 127, 78, 17, 20 ); GRect EMPTY_RECT = ConstantGRect( 0, 0, 0, 0 ); GRect OFF_DATE_RECT = ConstantGRect( 12, 132, 144, 70 ); GRect OFF_WEEK_RECT = ConstantGRect( 74, 132, 144, 70 ); GRect TEMP_RECT = ConstantGRect( 18, 53, 40, 40); GRect ICON_RECT = ConstantGRect( 16, 21, 20, 20);
INVALID_RESOURCE, APP_INFO_WATCH_FACE); #define ConstantGRect(x, y, w, h) {{(x), (y)}, {(w), (h)}} /* CONSTANTS - BackgroundColor is the main filling (black) - ForegroundColor is the filling of the cross, points and segments (white) - AnimationTime is the duration in milliseconds of transitions (2000) - Points are the coordinates of the two points at of each quadrant */ const GColor BackgroundColor = GColorBlack; const GColor ForegroundColor = GColorWhite; const int AnimationTime = 2000; const GRect Points[2] = { ConstantGRect(33, 25, 4, 4), ConstantGRect(33, 53, 4, 4) }; /* Each number is contained in a quadrant which has a layer (its coordinates), 2 permanent points and 8 possible segments. Also storing the animations that need to be globally accessible and the current segments byte for future comparison. */ typedef struct { Layer layer; Layer points[2]; Layer segments[8]; PropertyAnimation animations[8]; bool cancelAnimations[8]; char currentSegments; } Quadrant;
static char date_str[] = "xx"; static char weather_str[] = "eleven"; static char center_str[] = "thirteen"; static char temp_str[] = "clock"; static char temp_f_str[] = "clock"; static char temp_c_str[] = "clock"; static char city_str[] = "1234"; static char connected_str[] = ""; static char disconnected_str[] = "Disconnected"; #define STAGGER_STR 100 #define STAGGER_IN 500 #define WAIT_TIME 2500 #define ConstantGRect(x, y, w, h) {{(x), (y)}, {(w), (h)}} // borrowed from drop_zone // hour, tens, ones frames off screen to the right, center (default), left static GRect r_rect_hour = ConstantGRect(168, 20, 144, 168 - 20); static GRect r_rect_tens = ConstantGRect(168, 55, 144, 168 - 55); static GRect r_rect_ones = ConstantGRect(168, 90, 144, 168 - 90); static GRect c_rect_hour = ConstantGRect(0, 20, 144, 168 - 20); static GRect c_rect_tens = ConstantGRect(0, 55, 144, 168 - 55); static GRect c_rect_ones = ConstantGRect(0, 90, 144, 168 - 90); static GRect c_rect_connection = ConstantGRect(0, 150, 144, 168 - 150); static GRect l_rect_hour = ConstantGRect(-168, 20, 144, 168 - 20); static GRect l_rect_tens = ConstantGRect(-168, 55, 144, 168 - 55); static GRect l_rect_ones = ConstantGRect(-168, 90, 144, 168 - 90); static PropertyAnimation *hour_anim = NULL; static PropertyAnimation *tens_anim = NULL; static PropertyAnimation *ones_anim = NULL; static bool introComplete = false; static bool noInterrupts = false; static bool timerCallback2 = false;