//----------------------------------------------------------------------------------------------------------------------- static void update_configuration(void) { if (persist_exists(CONFIG_KEY_THEME)) { int32_t theme = persist_read_int(CONFIG_KEY_THEME); CfgData.circle = (theme == 0); } else CfgData.circle = false; if (persist_exists(CONFIG_KEY_FSM)) CfgData.fsm = persist_read_bool(CONFIG_KEY_FSM); else CfgData.fsm = false; if (persist_exists(CONFIG_KEY_INV)) CfgData.inv = !CfgData.circle && persist_read_bool(CONFIG_KEY_INV); else CfgData.inv = true; if (persist_exists(CONFIG_KEY_ANIM)) CfgData.anim = persist_read_bool(CONFIG_KEY_ANIM); else CfgData.anim = true; if (persist_exists(CONFIG_KEY_SEP)) CfgData.sep = persist_read_bool(CONFIG_KEY_SEP); else CfgData.sep = true; if (persist_exists(CONFIG_KEY_DATEFMT)) CfgData.datefmt = (int16_t)persist_read_int(CONFIG_KEY_DATEFMT); else CfgData.datefmt = 0; if (persist_exists(CONFIG_KEY_SMART)) CfgData.smart = persist_read_bool(CONFIG_KEY_SMART); else CfgData.smart = true; if (persist_exists(CONFIG_KEY_VIBR)) CfgData.vibr = persist_read_bool(CONFIG_KEY_VIBR); else CfgData.vibr = false; app_log(APP_LOG_LEVEL_DEBUG, __FILE__, __LINE__, "Curr Conf: circle:%d, fsm:%d, inv:%d, anim:%d, sep:%d, datefmt:%d, smart:%d, vibr:%d", CfgData.circle, CfgData.fsm, CfgData.inv, CfgData.anim, CfgData.sep, CfgData.datefmt, CfgData.smart, CfgData.vibr); gbitmap_destroy(batteryAll); batteryAll = gbitmap_create_with_resource(CfgData.inv ? RESOURCE_ID_IMAGE_BATTERY_INV : RESOURCE_ID_IMAGE_BATTERY); bitmap_layer_set_bitmap(radio_layer, NULL); gbitmap_destroy(bmp_radio); bmp_radio = gbitmap_create_as_sub_bitmap(batteryAll, GRect(110, 0, 10, 20)); bitmap_layer_set_bitmap(radio_layer, bmp_radio); Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_get_root_layer(window)); window_set_background_color(window, CfgData.inv ? GColorWhite : GColorBlack); //Face Layer first on round layer_remove_from_parent(face_layer); layer_destroy(face_layer); #if defined(PBL_RECT) face_layer = layer_create(GRect(0, 0, bounds.size.w, CfgData.fsm ? bounds.size.h : bounds.size.h-n_bottom_margin)); layer_set_update_proc(face_layer, face_update_proc); #elif defined(PBL_ROUND) face_layer = layer_create(GRect(0, 0, bounds.size.w, bounds.size.h)); layer_set_update_proc(face_layer, face_update_proc); layer_add_child(window_layer, face_layer); #endif //Bottom Layer next, then Radio and Battery layer_remove_from_parent(text_layer_get_layer(date_layer)); layer_remove_from_parent(bitmap_layer_get_layer(radio_layer)); layer_remove_from_parent(bitmap_layer_get_layer(battery_layer)); #if defined(PBL_RECT) if (!CfgData.fsm) #endif { #if defined(PBL_RECT) layer_add_child(window_layer, text_layer_get_layer(date_layer)); #ifdef PBL_COLOR text_layer_set_text_color(date_layer, CfgData.inv ? GColorDarkGray : GColorLightGray); #else text_layer_set_text_color(date_layer, CfgData.inv ? GColorBlack : GColorWhite); #endif text_layer_set_background_color(date_layer, CfgData.inv ? GColorWhite : GColorBlack); #endif if (CfgData.smart) { layer_add_child(window_layer, bitmap_layer_get_layer(radio_layer)); layer_add_child(window_layer, bitmap_layer_get_layer(battery_layer)); } } //On Rect later #if defined(PBL_RECT) layer_add_child(window_layer, face_layer); #endif //Get a time structure so that it doesn't start blank time_t temp = time(NULL); struct tm *t = localtime(&temp); //Manually call the tick handler when the window is loading aktHH = t->tm_hour; aktMM = t->tm_min; handle_tick(t, MINUTE_UNIT); //Set Battery state BatteryChargeState btchg = battery_state_service_peek(); battery_state_service_handler(btchg); //Set Bluetooth state bool connected = bluetooth_connection_service_peek(); bluetooth_connection_handler(connected); }
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()); }