void create_chrono_objects() { app_log(APP_LOG_LEVEL_INFO, __FILE__, __LINE__, "create_chrono_objects"); hand_cache_init(&chrono_minute_cache); hand_cache_init(&chrono_second_cache); hand_cache_init(&chrono_tenth_cache); update_chrono_laps_time(); }
void create_chrono_objects() { app_log(APP_LOG_LEVEL_INFO, __FILE__, __LINE__, "create_chrono_objects"); hand_cache_init(&chrono_minute_cache); hand_cache_init(&chrono_second_cache); hand_cache_init(&chrono_tenth_cache); Layer *window_layer = window_get_root_layer(window); { // We defer loading the chrono dial until we actually need to render it. //load_chrono_dial(); int height = 56; //chrono_dial_white.bitmap->bounds.size.h; int width = 56; //chrono_dial_white.bitmap->bounds.size.w; int x = chrono_tenth_hand_def.place_x - width / 2; int y = chrono_tenth_hand_def.place_y - height / 2; chrono_dial_layer = layer_create(GRect(x, y, width, height)); assert(chrono_dial_layer != NULL); } layer_set_update_proc(chrono_dial_layer, &chrono_dial_layer_update_callback); layer_add_child(window_layer, chrono_dial_layer); update_chrono_laps_time(); }
// Creates all of the objects needed for the watch. Normally called // only by handle_init(), but might be invoked midstream in a // memory-panic situation. void create_objects() { app_log(APP_LOG_LEVEL_INFO, __FILE__, __LINE__, "create_objects"); window = window_create(); assert(window != NULL); struct WindowHandlers window_handlers; memset(&window_handlers, 0, sizeof(window_handlers)); window_handlers.load = window_load_handler; window_handlers.appear = window_appear_handler; window_handlers.disappear = window_disappear_handler; window_handlers.unload = window_unload_handler; window_set_window_handlers(window, window_handlers); window_set_fullscreen(window, true); window_stack_push(window, false); hand_cache_init(&hour_cache); hand_cache_init(&minute_cache); hand_cache_init(&second_cache); Layer *window_layer = window_get_root_layer(window); GRect window_frame = layer_get_frame(window_layer); clock_face_layer = layer_create(window_frame); assert(clock_face_layer != NULL); layer_set_update_proc(clock_face_layer, &clock_face_layer_update_callback); layer_add_child(window_layer, clock_face_layer); { const struct IndicatorTable *window = &battery_table[config.face_index]; init_battery_gauge(window_layer, window->x, window->y, window->invert, window->opaque); } { const struct IndicatorTable *window = &bluetooth_table[config.face_index]; init_bluetooth_indicator(window_layer, window->x, window->y, window->invert, window->opaque); } for (int i = 0; i < NUM_DATE_WINDOWS; ++i) { const struct IndicatorTable *window = &date_windows[i][config.face_index]; Layer *layer = layer_create_with_data(GRect(window->x - 19, window->y - 8, 39, 19), sizeof(DateWindowData)); assert(layer != NULL); date_window_layers[i] = layer; DateWindowData *data = (DateWindowData *)layer_get_data(layer); data->date_window_index = i; layer_set_update_proc(layer, &date_window_layer_update_callback); layer_add_child(window_layer, layer); } #ifdef MAKE_CHRONOGRAPH create_chrono_objects(); #endif // MAKE_CHRONOGRAPH // Init all of the hands, taking care to arrange them in the correct // stacking order. int i; for (i = 0; stacking_order[i] != STACKING_ORDER_DONE; ++i) { switch (stacking_order[i]) { case STACKING_ORDER_HOUR: hour_layer = layer_create(window_frame); assert(hour_layer != NULL); layer_set_update_proc(hour_layer, &hour_layer_update_callback); layer_add_child(window_layer, hour_layer); break; case STACKING_ORDER_MINUTE: minute_layer = layer_create(window_frame); assert(minute_layer != NULL); layer_set_update_proc(minute_layer, &minute_layer_update_callback); layer_add_child(window_layer, minute_layer); break; case STACKING_ORDER_SECOND: second_layer = layer_create(window_frame); assert(second_layer != NULL); layer_set_update_proc(second_layer, &second_layer_update_callback); layer_add_child(window_layer, second_layer); break; case STACKING_ORDER_CHRONO_MINUTE: #if defined(ENABLE_CHRONO_MINUTE_HAND) && defined(MAKE_CHRONOGRAPH) chrono_minute_layer = layer_create(window_frame); assert(chrono_minute_layer != NULL); layer_set_update_proc(chrono_minute_layer, &chrono_minute_layer_update_callback); layer_add_child(window_layer, chrono_minute_layer); #endif // ENABLE_CHRONO_MINUTE_HAND break; case STACKING_ORDER_CHRONO_SECOND: #if defined(ENABLE_CHRONO_SECOND_HAND) && defined(MAKE_CHRONOGRAPH) chrono_second_layer = layer_create(window_frame); assert(chrono_second_layer != NULL); layer_set_update_proc(chrono_second_layer, &chrono_second_layer_update_callback); layer_add_child(window_layer, chrono_second_layer); #endif // ENABLE_CHRONO_SECOND_HAND break; case STACKING_ORDER_CHRONO_TENTH: #if defined(ENABLE_CHRONO_TENTH_HAND) && defined(MAKE_CHRONOGRAPH) chrono_tenth_layer = layer_create(window_frame); assert(chrono_tenth_layer != NULL); layer_set_update_proc(chrono_tenth_layer, &chrono_tenth_layer_update_callback); layer_add_child(window_layer, chrono_tenth_layer); #endif // ENABLE_CHRONO_TENTH_HAND break; } } }