void topbar_layer_init(Window* window) { int16_t w = SCREEN_W - MENU_WIDTH; s_data.topbar_layer.layer = layer_create(GRect(0,0,w,SCREEN_H)); layer_add_child(window_get_root_layer(window), s_data.topbar_layer.layer); // time (centered in top bar) s_data.topbar_layer.time_layer = text_layer_create(GRect(0,0,w,TOPBAR_HEIGHT)); set_layer_attr_full(s_data.topbar_layer.time_layer, s_data.time, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLD_16)), GTextAlignmentCenter, GColorWhite, GColorBlack, window_get_root_layer(window)); // bluetooth icon s_data.topbar_layer.bluetooth_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BLUETOOTH); s_data.topbar_layer.bluetooth_layer = bitmap_layer_create(gbitmap_get_bounds(s_data.topbar_layer.bluetooth_image)); bitmap_layer_set_bitmap(s_data.topbar_layer.bluetooth_layer, s_data.topbar_layer.bluetooth_image); layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(s_data.topbar_layer.bluetooth_layer)); layer_set_hidden(bitmap_layer_get_layer(s_data.topbar_layer.bluetooth_layer), !bluetooth_connection_service_peek()); // accuracy (1/3, right) s_data.topbar_layer.accuracy_layer = text_layer_create(GRect(w-18,0,18,TOPBAR_HEIGHT)); set_layer_attr_full(s_data.topbar_layer.accuracy_layer, s_data.accuracy, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLD_16)), GTextAlignmentRight, GColorWhite, GColorBlack, window_get_root_layer(window)); }
void screen_map_layer_init(Window* window) { for (int i = 0; i < NUM_POINTS; i++) { pts[i] = GPoint(0, 0); } s_data.page_map = layer_create(GRect(0,TOPBAR_HEIGHT,SCREEN_W,SCREEN_H-TOPBAR_HEIGHT)); layer_add_child(window_get_root_layer(window), s_data.page_map); for(int i = 0; i < NUM_LIVE_FRIENDS; i++) { s_live.friends[i].name_frame = GRect(0, 15, 100, 15); s_live.friends[i].name_layer = text_layer_create(s_live.friends[i].name_frame); set_layer_attr_full(s_live.friends[i].name_layer, s_live.friends[i].name, font_12, GTextAlignmentLeft, GColorBlack, GColorWhite, s_data.page_map); } pathFrame = GRect(0, 0, MAP_VSIZE_X, MAP_VSIZE_Y); path_layer = layer_create(pathFrame); pathFrame.origin.x = -XINI + SCREEN_W/2; pathFrame.origin.y = -YINI + SCREEN_H/2; layer_set_frame(path_layer, pathFrame); layer_set_update_proc(path_layer, path_layer_update_callback); layer_add_child(s_data.page_map, path_layer); bearing_layer = layer_create(GRect(0, 0, SCREEN_W, SCREEN_H)); layer_set_update_proc(bearing_layer, bearing_layer_update_callback); layer_add_child(s_data.page_map, bearing_layer); bearing_gpath = gpath_create(&BEARING_PATH_POINTS); gpath_move_to(bearing_gpath, GPoint(SCREEN_W/2, SCREEN_H/2)); layer_set_hidden(s_data.page_map, true); s_gpsdata.xpos=0; s_gpsdata.ypos=0; s_gpsdata.nb_received=0; }
void hide_date_now(bool hide_date) { if (hide_date) { layer_set_hidden(bitmap_layer_get_layer(day_name_layer), true); layer_set_hidden(bitmap_layer_get_layer(month_layer), true); for (int i = 0; i < TOTAL_DATE_DIGITS; ++i) { layer_set_hidden( bitmap_layer_get_layer(date_digits_layers[i]), true); } } else { layer_set_hidden(bitmap_layer_get_layer(day_name_layer), false); layer_set_hidden(bitmap_layer_get_layer(month_layer), false); for (int i = 0; i < TOTAL_DATE_DIGITS; ++i) { layer_set_hidden( bitmap_layer_get_layer(date_digits_layers[i]), false); } } }
static void init() { app_message_register_inbox_received(in_received_handler); app_message_register_inbox_dropped(in_dropped_handler); app_message_open(128, 0); window = window_create(); window_set_background_color(window, GColorBlack); window_stack_push(window, true); Layer *window_layer = window_get_root_layer(window); // Add time layer label_layer_time = text_layer_create(GRect(0, 65, 144, 30)); text_layer_set_text_color(label_layer_time, GColorWhite); text_layer_set_background_color(label_layer_time, GColorClear); text_layer_set_text_alignment(label_layer_time, GTextAlignmentCenter); text_layer_set_font(label_layer_time, fonts_get_system_font(FONT_KEY_GOTHIC_28)); layer_set_hidden(text_layer_get_layer(label_layer_time), true); layer_add_child(window_layer, text_layer_get_layer(label_layer_time)); tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick); set_time_display(); }
static void rcLoad(Window *window) { //APP_LOG(APP_LOG_LEVEL_DEBUG, "Enter rcLoad()"); setCommonLoad("Reset Chrono"); resetChronoLayer = text_layer_create(GRect(2, 2, 128, 136)); text_layer_set_text_alignment(resetChronoLayer, GTextAlignmentCenter); text_layer_set_font(resetChronoLayer, fonts_get_system_font(FONT_KEY_GOTHIC_24)); text_layer_set_background_color(resetChronoLayer, GColorWhite); text_layer_set_text_color(resetChronoLayer, GColorBlack); layer_add_child(text_layer_get_layer(setDataLayer), text_layer_get_layer(resetChronoLayer)); // Chrono is running. if (chronoRunSelect == RUN_START) { text_layer_set_text(resetChronoLayer, "Chronometer is running. Press SELECT button to Stop and Reset."); } // Chrono is stopped. else { if (chronoElapsed == 0) { // Not needed for this option. layer_set_hidden(bitmap_layer_get_layer(nextIconLayer), true); text_layer_set_text(resetChronoLayer, "Chronometer is already Reset."); } else { text_layer_set_text(resetChronoLayer, "Press SELECT button to Reset chronometer."); } } //APP_LOG(APP_LOG_LEVEL_DEBUG, "about to set rc_click_config_provider()"); window_set_click_config_provider(setWindow, (ClickConfigProvider) rc_click_config_provider); }
static void tick_second_handler( struct tm *time, const TimeUnits unit ) { /* Bail out here if the timezone isn't set. */ if ( have_tz_offset() == false ) return; /* Get the UTC time and update the timers with it. */ struct tm utc = *time; time_convert_local_to_utc(&utc); update_event_times(&utc); /* Reload the menu in case row counts change. */ menu_layer_reload_data(event_menu); /* Stuff to do on the first tick. */ if ( first_tick == true ) { /* If the time zone message exists, we can remove it now. */ if ( tz_message != NULL ) { text_layer_destroy(tz_message); tz_message = NULL; } /* Set the selection to the first menu item on startup. */ menu_layer_set_selected_index(event_menu, (MenuIndex) { 0, 0 }, MenuRowAlignBottom, false); /* The menu layer is created hidden so we don't see * all the timers set to 0:00 before the first tick. */ layer_set_hidden(menu_layer_get_layer(event_menu), false); first_tick = false; } layer_mark_dirty(menu_layer_get_layer(event_menu)); }
void handle_press_back(ClickRecognizerRef recognizer, void *context) { if (m_in_menu) { window_stack_pop(true); } else { tick_timer_service_unsubscribe(); // hide counter layer_set_hidden(text_layer_get_layer(s_textlayer_count), true); layer_set_hidden(text_layer_get_layer(s_textlayer_over), true); // show all others layer_set_hidden(text_layer_get_layer(s_textlayer_60), false); layer_set_hidden(text_layer_get_layer(s_textlayer_90), false); layer_set_hidden(text_layer_get_layer(s_textlayer_120), false); layer_set_hidden(action_bar_layer_get_layer(s_actionbarlayer_main), false); m_in_menu = true; } }
static void toggleSeconds(bool hidden) { layer_set_hidden(bitmap_layer_get_layer(time_digits_layers[5]), hidden); layer_set_hidden(bitmap_layer_get_layer(time_digits_layers[6]), hidden); layer_set_hidden(bitmap_layer_get_layer(time_digits_layers[7]), hidden); layer_set_hidden(bitmap_layer_get_layer(zulu_time_digits_layers[5]), hidden); layer_set_hidden(bitmap_layer_get_layer(zulu_time_digits_layers[6]), hidden); layer_set_hidden(bitmap_layer_get_layer(zulu_time_digits_layers[7]), hidden); if (hidden) { // seconds aren't visible if (mTimeLayerShifted) { // 12hr clock, single digit layer_set_frame(time_layer, GRect(9, 0, 144, 168)); } else { layer_set_frame(time_layer, GRect(16, 0, 144, 168)); } if (mZuluLayerShifted) { // 12hr clock, single digit layer_set_frame(zulu_time_layer, GRect(9, 0, 144, 168)); } else { layer_set_frame(zulu_time_layer, GRect(16, 0, 144, 168)); } } else { // seconds are visible if (mTimeLayerShifted) { // 12hr clock, single digit layer_set_frame(time_layer, GRect(-7, 0, 144, 168)); } else { layer_set_frame(time_layer, GRect(0, 0, 144, 168)); } if (mZuluLayerShifted) { // 12hr clock, single digit layer_set_frame(zulu_time_layer, GRect(-7, 0, 144, 168)); } else { layer_set_frame(zulu_time_layer, GRect(0, 0, 144, 168)); } } }
void update_setpoint_icon(int t, bool is_upper, bool on) { int i = (t-1) * 2 + (1 - is_upper); layer_set_hidden(bitmap_layer_get_layer(setpoint_image_layers[i]), !on); }
static void main_window_load(Window *window) { // 144 x 168 // http://www.cplusplus.com/reference/ctime/strftime/ // http://developer.getpebble.com/docs/c/Graphics/Graphics_Types/Color_Definitions/ //Create GBitmap, then set to created BitmapLayer /* s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BACKGROUND); s_background_layer = bitmap_layer_create(GRect(0, 0, 144, 168)); bitmap_layer_set_bitmap(s_background_layer, s_background_bitmap); layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(s_background_layer)); */ //FONT_12 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_MIJNE_12)); FONT_12 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_DROID_12)); FONT_20 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_MIJNE_20)); FONT_32 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_MIJNE_32)); FONT_38 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_MIJNE_38)); FONT_44 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_MIJNE_44)); FONT_50 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_MIJNE_50)); // Create time TextLayer //s_time_layer = text_layer_create(GRect(0, 52, 139, 50)); s_time_layer = text_layer_create(GRect(0, 0, 144, 168)); text_layer_set_background_color(s_time_layer, GColorClear); text_layer_set_text_color(s_time_layer, GColorVividCerulean); text_layer_set_text(s_time_layer, "00:00:00"); text_layer_set_font(s_time_layer, FONT_12); text_layer_set_text_alignment(s_time_layer, GTextAlignmentRight); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_time_layer)); // HIDE since not (yet) used layer_set_hidden((Layer *) s_time_layer, true); // Add TimeInText layer ROW 01 (BIG) s_timeintext_row_01_layer = text_layer_create(GRect(0,4,144,168)); text_layer_set_background_color(s_timeintext_row_01_layer, GColorClear); text_layer_set_text_color(s_timeintext_row_01_layer, GColorVividCerulean); text_layer_set_text(s_timeintext_row_01_layer, "ROW 01"); text_layer_set_font(s_timeintext_row_01_layer, FONT_44); text_layer_set_text_alignment(s_timeintext_row_01_layer, GTextAlignmentCenter); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_timeintext_row_01_layer)); // Add TimeInText layer ROW 02 (SMALL) s_timeintext_row_02_layer = text_layer_create(GRect(0,63,144,168)); text_layer_set_background_color(s_timeintext_row_02_layer, GColorClear); text_layer_set_text_color(s_timeintext_row_02_layer, GColorVividCerulean); text_layer_set_text(s_timeintext_row_02_layer, "ROW 02"); text_layer_set_font(s_timeintext_row_02_layer, FONT_20); text_layer_set_text_alignment(s_timeintext_row_02_layer, GTextAlignmentCenter); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_timeintext_row_02_layer)); // Add TimeInText layer ROW 03 (BIG) s_timeintext_row_03_layer = text_layer_create(GRect(0,82,144,168)); text_layer_set_background_color(s_timeintext_row_03_layer, GColorClear); text_layer_set_text_color(s_timeintext_row_03_layer, GColorVividCerulean); text_layer_set_text(s_timeintext_row_03_layer, "ROW 03"); text_layer_set_font(s_timeintext_row_03_layer, FONT_44); text_layer_set_text_alignment(s_timeintext_row_03_layer, GTextAlignmentCenter); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_timeintext_row_03_layer)); // Add TimeInText layer ROW 04 (BIG) s_timeintext_row_04_layer = text_layer_create(GRect(0,25,144,168)); text_layer_set_background_color(s_timeintext_row_04_layer, GColorClear); text_layer_set_text_color(s_timeintext_row_04_layer, GColorVividCerulean); text_layer_set_text(s_timeintext_row_04_layer, "ROW 04"); text_layer_set_font(s_timeintext_row_04_layer, FONT_44); text_layer_set_text_alignment(s_timeintext_row_04_layer, GTextAlignmentCenter); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_timeintext_row_04_layer)); // Add TimeInText layer ROW 05 (BIG) s_timeintext_row_05_layer = text_layer_create(GRect(0,70,144,168)); text_layer_set_background_color(s_timeintext_row_05_layer, GColorClear); text_layer_set_text_color(s_timeintext_row_05_layer, GColorVividCerulean); text_layer_set_text(s_timeintext_row_05_layer, "ROW 05"); text_layer_set_font(s_timeintext_row_05_layer, FONT_44); text_layer_set_text_alignment(s_timeintext_row_05_layer, GTextAlignmentCenter); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_timeintext_row_05_layer)); // Add bluetooth layer //s_bluetooth_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_MIJNE_12)); s_bluetooth_layer = text_layer_create(GRect(0,0,144,168)); text_layer_set_background_color(s_bluetooth_layer, GColorClear); text_layer_set_text_color(s_bluetooth_layer, GColorVividCerulean); text_layer_set_text(s_bluetooth_layer, "Bleutooth"); text_layer_set_font(s_bluetooth_layer, FONT_12); text_layer_set_text_alignment(s_bluetooth_layer, GTextAlignmentLeft); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_bluetooth_layer)); // Add date layer //s_date_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_MIJNE_12)); s_date_layer = text_layer_create(GRect(0,152,144,168)); text_layer_set_background_color(s_date_layer, GColorClear); text_layer_set_text_color(s_date_layer, GColorVividCerulean); text_layer_set_text(s_date_layer, "Date"); //text_layer_set_font(s_date_font, s_bluetooth_font); text_layer_set_font(s_date_layer, FONT_12); text_layer_set_text_alignment(s_date_layer, GTextAlignmentCenter); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_date_layer)); // Add battery layer //s_battery_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_MIJNE_12)); s_battery_layer = text_layer_create(GRect(0,152,144,168)); text_layer_set_background_color(s_battery_layer, GColorClear); text_layer_set_text_color(s_battery_layer, GColorVividCerulean); text_layer_set_text(s_battery_layer, "Battery"); text_layer_set_font(s_battery_layer, FONT_12); text_layer_set_text_alignment(s_battery_layer, GTextAlignmentLeft); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_battery_layer)); // Add world layer //s_world_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_MIJNE_12)); s_world_layer = text_layer_create(GRect(0,152,144,168)); text_layer_set_background_color(s_world_layer, GColorClear); text_layer_set_text_color(s_world_layer, GColorVividCerulean); text_layer_set_text(s_world_layer, "World"); text_layer_set_font(s_world_layer, FONT_12); text_layer_set_text_alignment(s_world_layer, GTextAlignmentRight); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_world_layer)); // Create temperature Layer s_weather_layer = text_layer_create(GRect(0, 115, 144, 25)); text_layer_set_background_color(s_weather_layer, GColorClear); text_layer_set_text_color(s_weather_layer, GColorVividCerulean); text_layer_set_text_alignment(s_weather_layer, GTextAlignmentCenter); text_layer_set_text(s_weather_layer, "Loading..."); s_weather_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_MIJNE_12)); text_layer_set_font(s_weather_layer, s_weather_font); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_weather_layer)); // HIDE since not (yet) used layer_set_hidden((Layer *) s_weather_layer, true); // Make sure the time is displayed from the start update_time(); }
static void toggleHands(bool hidden) { layer_set_hidden((Layer *)minuteHandLayer, hidden); layer_set_hidden((Layer *)hourHandLayer, hidden); }
void hide_card_text(void) { layer_set_hidden((Layer*)card_back.back_line_one, true); }
static void init(void) { window=window_create(); window_stack_push(window, true /* Animated */); background_image_layer=bitmap_layer_create(layer_get_frame(window_get_root_layer(window))); background_image=gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BACKGROUND); bitmap_layer_set_bitmap(background_image_layer, background_image); layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(background_image_layer)); // Date Layer text_date_layer=text_layer_create(GRect(79, 5, 144-79, 168-5)); text_layer_set_text_color(text_date_layer, GColorWhite); text_layer_set_background_color(text_date_layer, GColorClear); text_layer_set_font(text_date_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_LCARS_BOLD_17))); layer_add_child(window_get_root_layer(window), text_layer_get_layer(text_date_layer)); // Nice date Layer text_nice_date_layer=text_layer_create(GRect(6, 26, 144-6, 168-26)); text_layer_set_background_color(text_nice_date_layer, GColorClear); text_layer_set_font(text_nice_date_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_LCARS_BOLD_17))); layer_add_child(window_get_root_layer(window), text_layer_get_layer(text_nice_date_layer)); // Time Layer text_time_layer=text_layer_create(GRect(36, 12, 144-36, 168-12)); text_layer_set_text_color(text_time_layer, GColorWhite); text_layer_set_background_color(text_time_layer, GColorClear); text_layer_set_font(text_time_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_LCARS_60))); layer_add_child(window_get_root_layer(window), text_layer_get_layer(text_time_layer)); // AMPM Layer text_ampm_layer=text_layer_create(GRect(36, 69, 144-36, 168-69)); text_layer_set_text_color(text_ampm_layer, GColorWhite); text_layer_set_background_color(text_ampm_layer, GColorClear); text_layer_set_font(text_ampm_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_LCARS_BOLD_17))); layer_add_child(window_get_root_layer(window), text_layer_get_layer(text_ampm_layer)); // Stardate Layer text_stardate_layer=text_layer_create(GRect(36, 95, 144-36, 168-95)); text_layer_set_text_color(text_stardate_layer, GColorWhite); text_layer_set_background_color(text_stardate_layer, GColorClear); text_layer_set_font(text_stardate_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_LCARS_36))); layer_add_child(window_get_root_layer(window), text_layer_get_layer(text_stardate_layer)); //Battery layer battery_percent=text_layer_create(GRect(8, 93, 27, 115)); text_layer_set_background_color(battery_percent, GColorClear); text_layer_set_font(battery_percent, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_LCARS_BOLD_17))); layer_add_child(window_get_root_layer(window), text_layer_get_layer(battery_percent)); //Battery charging layer battery_charge_image_layer=bitmap_layer_create(GRect(10, 92, 16, 3)); battery_charge_image=gbitmap_create_with_resource(RESOURCE_ID_BATTERY_CHARGING_IMAGE); bitmap_layer_set_bitmap(battery_charge_image_layer, battery_charge_image); layer_set_hidden(bitmap_layer_get_layer(battery_charge_image_layer), true); layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(battery_charge_image_layer)); //Battery status layer battery_status_layer=layer_create(GRect(6, 92, 20, 3)); layer_add_child(window_get_root_layer(window), battery_status_layer); layer_set_update_proc(battery_status_layer, battery_status_layer_update); //Bluetooth status layer bluetooth_status_layer=text_layer_create(GRect(15, 107, 14, 14)); text_layer_set_background_color(bluetooth_status_layer, GColorClear); layer_add_child(window_get_root_layer(window), text_layer_get_layer(bluetooth_status_layer)); //Prevent blank screen on init. time_t now=time(NULL); struct tm* tick_time; tick_time=localtime(&now); update_display(tick_time); update_battery_display(battery_state_service_peek()); update_bluetooth_status(bluetooth_connection_service_peek()); bluetooth_connection_service_subscribe(update_bluetooth_status); battery_state_service_subscribe(update_battery_display); tick_timer_service_subscribe(MINUTE_UNIT, &handle_minute_tick); }
void show_card_text(void) { layer_set_hidden((Layer*)card_back.back_line_one, false); }
static void show_no_con_error() { layer_set_hidden((Layer *)s_textlayer_1, false); }
void ShowMenuLayer(int index, const char *text) { text_layer_set_text(menuLayers[index], text); layer_set_hidden(text_layer_get_layer(menuLayers[index]), false); }
void handle_init(void) { window = window_create(); window_stack_push(window, true); window_set_background_color(window, GColorBlack); root = window_get_root_layer(window); GRect frame = layer_get_frame(root); background = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_HEAT_WHITE); bg_layer = bitmap_layer_create(GRect(0, 1, frame.size.w, 100)); bitmap_layer_set_background_color(bg_layer, GColorClear); bitmap_layer_set_bitmap(bg_layer, background); bitmap_layer_set_compositing_mode(bg_layer, GCompOpOr); date_layer = text_layer_create(GRect(0, 140, frame.size.w, 26)); text_layer_set_text_color(date_layer, GColorBlack); text_layer_set_background_color(date_layer, GColorClear); text_layer_set_font(date_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)); text_layer_set_text_alignment(date_layer, GTextAlignmentCenter); white_layer = text_layer_create(GRect(0, 105, frame.size.w, 63)); text_layer_set_background_color(white_layer, GColorWhite); time_layer = text_layer_create(GRect(0, 100, frame.size.w, 68)); text_layer_set_text_color(time_layer, GColorBlack); text_layer_set_background_color(time_layer, GColorClear); text_layer_set_font(time_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD)); text_layer_set_text_alignment(time_layer, GTextAlignmentCenter); status_layer = layer_create(GRect(0, 0, frame.size.w, 20)); battery_layer = text_layer_create(GRect(104, 0, /* width */ 40, 20 /* height */)); text_layer_set_text_color(battery_layer, GColorWhite); text_layer_set_background_color(battery_layer, GColorClear); text_layer_set_font(battery_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); text_layer_set_text_alignment(battery_layer, GTextAlignmentRight); text_layer_set_text(battery_layer, "---"); bt = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BT_WHITE); bt_layer = bitmap_layer_create(GRect(0, 0, 20, 20)); bitmap_layer_set_background_color(bt_layer, GColorClear); bluetooth_handler(bluetooth_connection_service_peek()); //bitmap_layer_set_compositing_mode(bt_layer, GCompOpOr); layer_add_child(status_layer, text_layer_get_layer(battery_layer)); layer_add_child(status_layer, bitmap_layer_get_layer(bt_layer)); game_layer = text_layer_create(GRect(0, 140, /* width */ frame.size.w, 26 /* height */)); //game_layer = text_layer_create(GRect(0, 5, /* width */ frame.size.w, 100 /* height */)); text_layer_set_text_color(game_layer, GColorBlack); text_layer_set_background_color(game_layer, GColorClear); text_layer_set_font(game_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)); text_layer_set_text_alignment(game_layer, GTextAlignmentCenter); tick_timer_service_subscribe(MINUTE_UNIT, &time_handler); battery_state_service_subscribe(&battery_handler); bluetooth_connection_service_subscribe(&bluetooth_handler); accel_tap_service_subscribe(tap_handler); layer_add_child(root, text_layer_get_layer(white_layer)); layer_add_child(root, text_layer_get_layer(time_layer)); layer_add_child(root, text_layer_get_layer(date_layer)); layer_add_child(root, text_layer_get_layer(game_layer)); layer_set_hidden(text_layer_get_layer(game_layer), true); layer_add_child(root, bitmap_layer_get_layer(bg_layer)); layer_add_child(root, status_layer); }
static void handle_bluetooth_connection (bool isConnected) { connectionStatus = isConnected; layer_set_hidden(bitmap_layer_get_layer(bluetooth_layer), isConnected); }
// update display static void update_display() { // Getting Battery State BatteryChargeState current_battery_charge_state = battery_state_service_peek(); if (current_battery_charge_state.is_charging) { chargeState = -1; } else { chargeState = current_battery_charge_state.charge_percent; } //APP_LOG(APP_LOG_LEVEL_DEBUG, "Setting chargeState = %d", chargeState); // Get a tm structure time_t temp = time(NULL); struct tm *tick_time = localtime(&temp); // Create a long-lived buffers static char buffer_hh[] = "00"; static char buffer_mm[] = "00"; static char buffer_dte[] = "ddd 00 mmm"; // Write the current hours into the buffer if(clock_is_24h_style() == true) { // Use 24 hour format strftime(buffer_hh, sizeof("00:00"), "%H", tick_time); } else { // Use 12 hour format strftime(buffer_hh, sizeof("00:00"), "%I", tick_time); } h1 = ascii_digit_to_int(buffer_hh[0]); h2 = ascii_digit_to_int(buffer_hh[1]); // hide leading zero if required if (h1 == 0 && hh_strip_zero) h1 = -1; // Write the current minuts into the buffer strftime(buffer_mm, sizeof("00"), "%M", tick_time); m1 = ascii_digit_to_int(buffer_mm[0]); m2 = ascii_digit_to_int(buffer_mm[1]); // debug //h1 = h2 = m1 = m2 = 0; // Write the current date into the buffer if (locale != locale_en) { // Ddd 00 Mmm //strftime(buffer_dte, sizeof("ddd 00 mmm"), "%a %d %b", tick_time); snprintf(buffer_dte, sizeof("ddd 00 mmm"), "%s %d %s", DAYS[locale][tick_time->tm_wday], tick_time->tm_mday, MONTHS[locale][tick_time->tm_mon]); } else { // Ddd Mmm 00 //strftime(buffer_dte, sizeof("ddd mmm 00"), "%a %b %d", tick_time); snprintf(buffer_dte, sizeof("ddd mmm 00"), "%s %s %d", DAYS[0][tick_time->tm_wday], MONTHS[0][tick_time->tm_mon], tick_time->tm_mday); } // undload and relaod time images unload_time_images(); load_time_images(); // Display values in TextLayers text_layer_set_text(s_time_layer_dte, buffer_dte); if (connection_service_peek_pebble_app_connection()) { // phone is connected layer_set_hidden(bitmap_layer_get_layer(s_warning_img_layer), true); //layer_set_hidden(text_layer_get_layer(s_time_layer_dte), false); lastBtStateConnected = true; } else { // phone is not connected //layer_set_hidden(text_layer_get_layer(s_time_layer_dte), true); layer_set_hidden(bitmap_layer_get_layer(s_warning_img_layer), false); // if we just lost the connection or if we want to have repeated vibrations, vibe twice if (lastBtStateConnected || repeat_vib) { lastBtStateConnected = false; vibes_double_pulse(); } } }
static void update_time() { // Get a tm structure time_t temp = time(NULL); struct tm *tick_time = localtime(&temp); // Create a long-lived buffer static char buffer[] = "00:00"; static char buffer2[] = "Xxx"; static char buffer2a[] = "00"; static char buffer3[] = "Xxx"; strftime(buffer3, sizeof(buffer3), "%a", tick_time); // Write the current hours and minutes into the buffer if(clock_is_24h_style() == true) { // Use 24 hour format strftime(buffer, sizeof("00:00"), "%H:%M", tick_time); text_layer_set_text(s_time_layer, buffer); } else { // Use 12 hour format strftime(buffer, sizeof(buffer), "%I:%M", tick_time); text_layer_set_text(s_time_layer,buffer+(('0' == buffer[0])?1:0)); } int bmin = BatteryINT; //if (bmin % 2) Even minutes if (tick_time->tm_min % bmin == 0) // divisible by 5 if(tick_time->tm_min % 5 == 0) { layer_set_hidden(s_image_layer, false); layer_set_hidden(s_image_layer2, false); BatteryChargeState charge_state = battery_state_service_peek(); if (charge_state.is_charging) { snprintf(buffer3, sizeof(buffer3), "%d%%", charge_state.charge_percent); s_image2 = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BATCHARGING); } else if (charge_state.charge_percent==100||charge_state.charge_percent==90) { snprintf(buffer3, sizeof(buffer3), "%d%%", charge_state.charge_percent); s_image2 = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BAT100); } else if (charge_state.charge_percent==70||charge_state.charge_percent==80) { snprintf(buffer3, sizeof(buffer3), "%d%%", charge_state.charge_percent); s_image2 = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BAT75); } else if (charge_state.charge_percent==50||charge_state.charge_percent==40||charge_state.charge_percent==60) { snprintf(buffer3, sizeof(buffer3), "%d%%", charge_state.charge_percent); s_image2 = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BAT50); } else if (charge_state.charge_percent==20||charge_state.charge_percent==30) { snprintf(buffer3, sizeof(buffer3), "%d%%", charge_state.charge_percent); s_image2 = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BAT25); } else if (charge_state.charge_percent==10||charge_state.charge_percent==0) { snprintf(buffer3, sizeof(buffer3), "%d%%", charge_state.charge_percent); s_image2 = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BAT00); } else { snprintf(buffer3, sizeof(buffer3), "%d%%", charge_state.charge_percent); s_image2 = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BAT75); } strftime(buffer2, sizeof(buffer2), "%b", tick_time); //Month text_layer_set_text(s_time_layer2, ""); text_layer_set_text(s_time_layer2a, ""); layer_set_update_proc(s_line_layer3, line_layer_update_callback3Red); layer_set_update_proc(s_line_layer4, line_layer_update_callback4Mag); if (bluetooth_connection_service_peek()) { s_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BTC55); } else { s_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BTNC55); } } else // even { layer_set_hidden(s_image_layer, true); layer_set_hidden(s_image_layer2, true); strftime(buffer2, sizeof(buffer2), "%b", tick_time); //Month strftime(buffer2a, sizeof(buffer2a), "%e", tick_time); //date strftime(buffer3, sizeof(buffer3), "%A", tick_time); //day of Week text_layer_set_text(s_time_layer2, buffer2); text_layer_set_text(s_time_layer2a, buffer2a); layer_set_update_proc(s_line_layer3, line_layer_update_callback3); layer_set_update_proc(s_line_layer4, line_layer_update_callback4); } // Display this time on the TextLayer text_layer_set_text(s_time_layer3, buffer3); }
void HideMenuLayer(int index) { layer_set_hidden(text_layer_get_layer(menuLayers[index]), true); }
static void select_click_up_handler(ClickRecognizerRef recognizer, void *context) { //revert to showing the temperature layer_set_hidden(text_layer_get_layer(text_weather_temp_layer), false); layer_set_hidden(text_layer_get_layer(text_weather_cond_layer), true); }
static void hide_no_con_error() { layer_set_hidden((Layer *)s_textlayer_1, true); }
static void select_click_down_handler(ClickRecognizerRef recognizer, void *context) { //show the weather condition instead of temperature while center button is pressed layer_set_hidden(text_layer_get_layer(text_weather_temp_layer), true); layer_set_hidden(text_layer_get_layer(text_weather_cond_layer), false); }
void show_card_text_front(void) { layer_set_hidden((Layer*)card_front.front_line_one, false); }
static void toggleBigMode() { if(settings.BigMode) { layer_set_hidden(bitmap_layer_get_layer(battery_image_layer), true); layer_set_hidden(bitmap_layer_get_layer(big_battery_image_layer), false); layer_set_hidden(time_layer, true); layer_set_hidden(zulu_time_layer, true); layer_set_hidden(date_layer, true); layer_set_hidden(big_time_layer, false); if(settings.Style<2) { layer_set_hidden(big_zulu_time_layer, true); layer_set_hidden(text_layer_get_layer(tiny_bottom_text), false); //true); layer_set_hidden(big_date_layer, false); } else { layer_set_hidden(big_zulu_time_layer, false); layer_set_hidden(text_layer_get_layer(tiny_bottom_text), false); layer_set_hidden(big_date_layer, true); } layer_set_frame(top_layer, GRect(0, -9, 144, 168)); layer_set_frame(bottom_layer, GRect(0, 10, 144, 168)); } else { layer_set_hidden(bitmap_layer_get_layer(battery_image_layer), false); layer_set_hidden(bitmap_layer_get_layer(big_battery_image_layer), true); layer_set_hidden(time_layer, false); layer_set_hidden(big_time_layer, true); layer_set_hidden(big_zulu_time_layer, true); layer_set_hidden(big_date_layer, true); if(settings.Style<2) { layer_set_hidden(zulu_time_layer, true); layer_set_hidden(text_layer_get_layer(tiny_bottom_text), false); //true); layer_set_hidden(date_layer, false); } else { layer_set_hidden(zulu_time_layer, false); layer_set_hidden(text_layer_get_layer(tiny_bottom_text), false); layer_set_hidden(date_layer, true); } layer_set_frame(top_layer, GRect(0, 0, 144, 168)); layer_set_frame(bottom_layer, GRect(0, 0, 144, 168)); } }
void hide_card_text_front(void) { layer_set_hidden((Layer*)card_front.front_line_one, true); }
static void remove_invert() { layer_set_hidden(inverter_layer_get_layer(inverter_layer), true); }
static void main_window_load(Window *window) { // Create GFont s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_ARVO_REGULAR_34)); s_date_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_ARVO_BOLD_16)); s_summary_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_ARVO_REGULAR_14)); // Create time TextLayer s_time_layer = text_layer_create(GRect(5, 122, 95, 36)); text_layer_set_background_color(s_time_layer, GColorClear); #ifdef PBL_COLOR text_layer_set_text_color(s_time_layer, GColorOrange); #else text_layer_set_text_color(s_time_layer, GColorWhite); #endif text_layer_set_font(s_time_layer, s_time_font); text_layer_set_text_alignment(s_time_layer, GTextAlignmentLeft); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_time_layer)); // Create date TextLayer s_date_layer = text_layer_create(GRect(105, 125, 30, 36)); text_layer_set_background_color(s_date_layer, GColorClear); #ifdef PBL_COLOR text_layer_set_text_color(s_date_layer, GColorOrange); #else text_layer_set_text_color(s_date_layer, GColorWhite); #endif text_layer_set_overflow_mode(s_date_layer, GTextOverflowModeWordWrap); text_layer_set_font(s_date_layer, s_date_font); text_layer_set_text_alignment(s_date_layer, GTextAlignmentCenter); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_date_layer)); // Create Main Icon s_weather_bitmap = gbitmap_create_with_resource(RESOURCE_ID_CLEAR_DAY); s_weather_bitmap_layer = bitmap_layer_create(GRect(10, 5, 48, 48)); bitmap_layer_set_bitmap(s_weather_bitmap_layer, s_weather_bitmap); #ifdef PBL_COLOR bitmap_layer_set_compositing_mode(s_weather_bitmap_layer, GCompOpSet); #endif layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(s_weather_bitmap_layer)); // Create Main Temperature Layer s_weather_text_layer = text_layer_create(GRect(56, 14, 83, 36)); text_layer_set_background_color(s_weather_text_layer, GColorClear); #ifdef PBL_COLOR text_layer_set_text_color(s_weather_text_layer, GColorPictonBlue); #else text_layer_set_text_color(s_weather_text_layer, GColorWhite); #endif text_layer_set_font(s_weather_text_layer, s_time_font); text_layer_set_text_alignment(s_weather_text_layer, GTextAlignmentRight); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_weather_text_layer)); // Create Weather Main Summary Layer s_weather_summary_layer = text_layer_create(GRect(5, 57, 134, 69)); text_layer_set_background_color(s_weather_summary_layer, GColorClear); text_layer_set_text_color(s_weather_summary_layer, GColorWhite); text_layer_set_overflow_mode(s_weather_summary_layer, GTextOverflowModeWordWrap); text_layer_set_font(s_weather_summary_layer, s_summary_font); text_layer_set_text_alignment(s_weather_summary_layer, GTextAlignmentCenter); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_weather_summary_layer)); // Create Weather Day Summary Layer (default hidden) s_weather_day_summary_layer = layer_create(GRect(0, 55, 144, 69)); layer_set_hidden(s_weather_day_summary_layer, true); layer_add_child(window_get_root_layer(window), s_weather_day_summary_layer); // Create Day Layers // First s_day_summary_first_day_layer = text_layer_create(GRect(25, 0, 36, 16)); text_layer_set_background_color(s_day_summary_first_day_layer, GColorClear); #ifdef PBL_COLOR text_layer_set_text_color(s_day_summary_first_day_layer, GColorOrange); #else text_layer_set_text_color(s_day_summary_first_day_layer, GColorWhite); #endif text_layer_set_font(s_day_summary_first_day_layer, s_summary_font); text_layer_set_text_alignment(s_day_summary_first_day_layer, GTextAlignmentCenter); layer_add_child(s_weather_day_summary_layer, text_layer_get_layer(s_day_summary_first_day_layer)); // Second s_day_summary_second_day_layer = text_layer_create(GRect(84, 0, 36, 16)); text_layer_set_background_color(s_day_summary_second_day_layer, GColorClear); #ifdef PBL_COLOR text_layer_set_text_color(s_day_summary_second_day_layer, GColorOrange); #else text_layer_set_text_color(s_day_summary_second_day_layer, GColorWhite); #endif text_layer_set_font(s_day_summary_second_day_layer, s_summary_font); text_layer_set_text_alignment(s_day_summary_second_day_layer, GTextAlignmentCenter); layer_add_child(s_weather_day_summary_layer, text_layer_get_layer(s_day_summary_second_day_layer)); // Create Summary Temperature layers // First s_day_summary_text_first_layer = text_layer_create(GRect(27, 16, 36, 16)); text_layer_set_background_color(s_day_summary_text_first_layer, GColorClear); #ifdef PBL_COLOR text_layer_set_text_color(s_day_summary_text_first_layer, GColorPictonBlue); #else text_layer_set_text_color(s_day_summary_text_first_layer, GColorWhite); #endif text_layer_set_font(s_day_summary_text_first_layer, s_summary_font); text_layer_set_text_alignment(s_day_summary_text_first_layer, GTextAlignmentCenter); layer_add_child(s_weather_day_summary_layer, text_layer_get_layer(s_day_summary_text_first_layer)); // Second s_day_summary_text_second_layer = text_layer_create(GRect(86, 16, 36, 16)); text_layer_set_background_color(s_day_summary_text_second_layer, GColorClear); #ifdef PBL_COLOR text_layer_set_text_color(s_day_summary_text_second_layer, GColorPictonBlue); #else text_layer_set_text_color(s_day_summary_text_second_layer, GColorWhite); #endif text_layer_set_font(s_day_summary_text_second_layer, s_summary_font); text_layer_set_text_alignment(s_day_summary_text_second_layer, GTextAlignmentCenter); layer_add_child(s_weather_day_summary_layer, text_layer_get_layer(s_day_summary_text_second_layer)); // Create Summary Icons For 2 days // First s_day_summary_first = gbitmap_create_with_resource(RESOURCE_ID_CLEAR_DAY); s_day_summary_first_layer = bitmap_layer_create(GRect(25, 34, 36, 36)); bitmap_layer_set_bitmap(s_day_summary_first_layer, s_day_summary_first); #ifdef PBL_COLOR bitmap_layer_set_compositing_mode(s_day_summary_first_layer, GCompOpSet); #endif layer_add_child(s_weather_day_summary_layer, bitmap_layer_get_layer(s_day_summary_first_layer)); // Second s_day_summary_second = gbitmap_create_with_resource(RESOURCE_ID_CLEAR_DAY); s_day_summary_second_layer = bitmap_layer_create(GRect(84, 34, 36, 36)); bitmap_layer_set_bitmap(s_day_summary_second_layer, s_day_summary_second); #ifdef PBL_COLOR bitmap_layer_set_compositing_mode(s_day_summary_second_layer, GCompOpSet); #endif layer_add_child(s_weather_day_summary_layer, bitmap_layer_get_layer(s_day_summary_second_layer)); }
static void set_invert() { layer_set_hidden(inverter_layer_get_layer(inverter_layer), false); }