/* * Common stuff we always do at the end of setup */ EXTFN void morpheuz_load_standard_postamble() { read_internal_data(); read_config_data(); // Start clock tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick); battery_state_handler(battery_state_service_peek()); battery_state_service_subscribe(&battery_state_handler); bluetooth_state_handler(bluetooth_connection_service_peek()); bluetooth_connection_service_subscribe(bluetooth_state_handler); init_morpheuz(); light_enable_interaction(); }
static void main_window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_layer); s_timehour_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_Font_AgentB_72)); s_timemin_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_Font_AgentB_44)); s_timeampm_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_Font_AgentB_22)); s_smaller_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_Font_AgentB_22)); xHalf = bounds.size.w / 2; // Create Hours Time display s_timehours_layer = text_layer_create( GRect(0, 39, xHalf + 20, 94)); text_layer_set_background_color(s_timehours_layer, GColorClear); text_layer_set_text_color(s_timehours_layer, GColorRed); text_layer_set_font(s_timehours_layer, s_timehour_font); text_layer_set_text_alignment(s_timehours_layer, GTextAlignmentRight); // Create Minutes Time display s_timemins_layer = text_layer_create( GRect(0, 46, xHalf + 20, 68)); text_layer_set_background_color(s_timemins_layer, GColorClear); text_layer_set_text_color(s_timemins_layer, GColorWhite); text_layer_set_font(s_timemins_layer, s_timemin_font); text_layer_set_text_alignment(s_timemins_layer, GTextAlignmentRight); // Create AM or PM Time display s_time_ampm_layer = text_layer_create( GRect(0, 89, xHalf + 20, 68)); text_layer_set_background_color(s_time_ampm_layer, GColorClear); text_layer_set_text_color(s_time_ampm_layer, GColorLightGray); text_layer_set_font(s_time_ampm_layer, s_timeampm_font); text_layer_set_text_alignment(s_time_ampm_layer, GTextAlignmentRight); // Create Steps display s_steps_layer = text_layer_create( GRect(0, 125, bounds.size.w, 24)); text_layer_set_background_color(s_steps_layer, GColorClear); text_layer_set_text_color(s_steps_layer, GColorWhite); text_layer_set_font(s_steps_layer, s_smaller_font); text_layer_set_text_alignment(s_steps_layer, GTextAlignmentCenter); //Create Day display s_day_layer = text_layer_create( GRect(0, 24, bounds.size.w, 26)); text_layer_set_background_color(s_day_layer, GColorClear); text_layer_set_text_color(s_day_layer, GColorLightGray); text_layer_set_font(s_day_layer, s_smaller_font); text_layer_set_text_alignment(s_day_layer, GTextAlignmentCenter); //Create Battery display s_battery_layer = layer_create(bounds); layer_set_update_proc(s_battery_layer, layer_update_proc); update_time(); update_date(); battery_state_handler(battery_state_service_peek()); layer_add_child(window_layer, text_layer_get_layer(s_timehours_layer)); layer_add_child(window_layer, text_layer_get_layer(s_timemins_layer)); layer_add_child(window_layer, text_layer_get_layer(s_time_ampm_layer)); layer_add_child(window_layer, text_layer_get_layer(s_steps_layer)); layer_add_child(window_layer, text_layer_get_layer(s_day_layer)); layer_add_child(window_layer, s_battery_layer); }
static void window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_layer); top_layer = layer_create(bounds); layer_set_update_proc(top_layer, update_top_callback); layer_add_child(window_layer, top_layer); weather_image = gbitmap_create_with_resource(WEATHER_IMAGE_RESOURCE[0]); weather_layer = bitmap_layer_create(GRect(0, 93, 72, 50)); bitmap_layer_set_bitmap(weather_layer, battery_image); bitmap_layer_set_alignment(weather_layer, GAlignCenter); bitmap_layer_set_compositing_mode(weather_layer,GCompOpAssignInverted); layer_add_child(window_layer, bitmap_layer_get_layer(weather_layer)); text_temp_layer = text_layer_create(GRect(65, 91, 79, 50)); text_layer_set_text_color(text_temp_layer, GColorWhite); text_layer_set_text_alignment(text_temp_layer,GTextAlignmentCenter); text_layer_set_background_color(text_temp_layer, GColorClear); text_layer_set_font(text_temp_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_LIGHT)); text_layer_set_text(text_temp_layer, temp_text); layer_add_child(window_layer, text_layer_get_layer(text_temp_layer)); bottom_layer = layer_create(bounds); layer_set_update_proc(bottom_layer, update_bottom_callback); layer_add_child(window_layer, bottom_layer); for(int i=0; i<LAYER_NUMBER; i++){ layer_number[i] = flip_layer_create(GRect(3 + i * 69, 21, 69, 36 * 2)); flip_layer_set_images(layer_number[i], NUMBER_IMAGE_RESOURCE_UP_IDS, NUMBER_IMAGE_RESOURCE_DOWN_IDS, NUMBER_IMAGE_COUNT); layer_add_child(window_layer, flip_layer_get_layer(layer_number[i])); } text_city_layer = text_layer_create(GRect(2, -1, 90, 16)); text_layer_set_text_color(text_city_layer, GColorBlack); text_layer_set_text_alignment(text_city_layer,GTextAlignmentLeft); text_layer_set_background_color(text_city_layer, GColorClear); text_layer_set_font(text_city_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); text_layer_set_text(text_city_layer, city_text); layer_add_child(window_layer, text_layer_get_layer(text_city_layer)); // text_temp_layer = text_layer_create(GRect(4, 144, 50, 20)); // text_layer_set_text_color(text_temp_layer, GColorBlack); // text_layer_set_text_alignment(text_temp_layer,GTextAlignmentLeft); // text_layer_set_background_color(text_temp_layer, GColorClear); // text_layer_set_font(text_temp_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)); // text_layer_set_text(text_temp_layer, temp_text); // layer_add_child(window_layer, text_layer_get_layer(text_temp_layer)); text_date_layer = text_layer_create(GRect(4, 144, 138, 20)); text_layer_set_text_color(text_date_layer, GColorBlack); text_layer_set_text_alignment(text_date_layer,GTextAlignmentRight); text_layer_set_background_color(text_date_layer, GColorClear); text_layer_set_font(text_date_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)); text_layer_set_text(text_date_layer, date_text); layer_add_child(window_layer, text_layer_get_layer(text_date_layer)); battery_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BATTERY_100); battery_layer = bitmap_layer_create(GRect(144-18, 0, 16, 16)); bitmap_layer_set_bitmap(battery_layer, battery_image); bitmap_layer_set_alignment(battery_layer, GAlignCenter); bitmap_layer_set_compositing_mode(battery_layer,GCompOpClear); layer_add_child(window_layer, bitmap_layer_get_layer(battery_layer)); bluetooth_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BLUETOOTH_ON); bluetooth_layer = bitmap_layer_create(GRect(112, 2, 11, 12)); bitmap_layer_set_bitmap(bluetooth_layer, battery_image); bitmap_layer_set_alignment(bluetooth_layer, GAlignCenter); layer_add_child(window_layer, bitmap_layer_get_layer(bluetooth_layer)); time_t now = time(NULL); struct tm *tick_time = localtime(&now); handle_minute_tick(tick_time, MINUTE_UNIT); battery_state_handler(battery_state_service_peek()); bluetooth_connection_handler(bluetooth_connection_service_peek()); }