/* Initialization */ void handle_init( void ) { window = window_create(); window_stack_push( window, true ); Layer *window_layer = window_get_root_layer( window ); // Read persistent data if ( persist_exists( SETTING_STATUS_KEY ) ) { current_status = persist_read_int( SETTING_STATUS_KEY ); } else { current_status = STATUS_ON; } if ( persist_exists( SETTING_WEATHERSTATUS_KEY ) ) { weather_status = persist_read_int( SETTING_WEATHERSTATUS_KEY ); } else { weather_status = WEATHER_ON; } if ( persist_exists( SETTING_LANGUAGE_KEY ) ) { current_language = persist_read_int( SETTING_LANGUAGE_KEY ); } else { current_language = LANG_EN; } if ( persist_exists( SETTING_FORMAT_KEY ) ) { current_format = persist_read_int( SETTING_FORMAT_KEY ); } else { current_format = FORMAT_WEEK; } if ( persist_exists( SETTING_INVERT_KEY ) ) { invert_format = persist_read_int( SETTING_INVERT_KEY ); } else { invert_format = INVERT_ON; } if ( persist_exists( BLUETOOTHVIBE_KEY ) ) { bluetoothvibe_status = persist_read_int( BLUETOOTHVIBE_KEY ); } else { bluetoothvibe_status = BLUETOOTHVIBE_ON; } if ( persist_exists( HOURLYVIBE_KEY ) ) { hourlyvibe_status = persist_read_int( HOURLYVIBE_KEY ); } else { hourlyvibe_status = HOURLYVIBE_ON; } if ( persist_exists( SECS_KEY ) ) { secs_status = persist_read_int( SECS_KEY ); } else { secs_status = SECS_ON; } // Read watchface settings from persistent data or use default values current_status = persist_exists( SETTING_STATUS_KEY ) ? persist_read_int( SETTING_STATUS_KEY ) : STATUS_ON; weather_status = persist_exists( SETTING_WEATHERSTATUS_KEY ) ? persist_read_int( SETTING_WEATHERSTATUS_KEY ) : WEATHER_ON; current_language = persist_exists( SETTING_LANGUAGE_KEY ) ? persist_read_int( SETTING_LANGUAGE_KEY ) : LANG_EN; current_format = persist_exists( SETTING_FORMAT_KEY ) ? persist_read_int( SETTING_FORMAT_KEY ) : FORMAT_WEEK; invert_format = persist_exists( SETTING_INVERT_KEY ) ? persist_read_int( SETTING_INVERT_KEY ) : INVERT_ON; bluetoothvibe_status = persist_exists( BLUETOOTHVIBE_KEY ) ? persist_read_int( BLUETOOTHVIBE_KEY ) : BLUETOOTHVIBE_ON; hourlyvibe_status = persist_exists( HOURLYVIBE_KEY ) ? persist_read_int( HOURLYVIBE_KEY ) : HOURLYVIBE_ON; secs_status = persist_exists( SECS_KEY ) ? persist_read_int( SECS_KEY ) : SECS_ON; // Background image background_image = gbitmap_create_with_resource( RESOURCE_ID_IMAGE_BACKGROUND ); background_layer = bitmap_layer_create( layer_get_frame( window_layer ) ); bitmap_layer_set_bitmap( background_layer, background_image ); layer_add_child( window_layer, bitmap_layer_get_layer( background_layer ) ); // Initial settings Tuplet initial_values[] = { TupletInteger( SETTING_STATUS_KEY, current_status ) , TupletInteger( SETTING_WEATHERSTATUS_KEY, weather_status ) , TupletInteger( SETTING_LANGUAGE_KEY, current_language ) , TupletInteger( SETTING_FORMAT_KEY, current_format ) , TupletInteger( SETTING_INVERT_KEY, invert_format ) , TupletInteger( BLUETOOTHVIBE_KEY, bluetoothvibe_status ) , TupletInteger( HOURLYVIBE_KEY, hourlyvibe_status ) , TupletInteger( SECS_KEY, secs_status ) , TupletInteger( SETTING_ICON_KEY, (uint8_t) 14) , TupletCString( SETTING_TEMPERATURE_KEY, "") }; // Open AppMessage to transfers app_message_open( 256 , 256 ); // Initialize AppSync app_sync_init( &app, sync_buffer , sizeof( sync_buffer ) , initial_values , ARRAY_LENGTH( initial_values ) , tuple_changed_callback , app_error_callback , NULL ); // Perform sync app_sync_set( &app, initial_values, ARRAY_LENGTH( initial_values ) ); appStarted = true; // Adjust GRect for Hours, Minutes and Blink to compensate for missing AM/PM indicator if ( clock_is_24h_style() ) { TIME_RECT.origin.y = TIME_RECT.origin.y + 1; } // Load fonts font_time = fonts_load_custom_font( resource_get_handle( RESOURCE_ID_FONT_LCARS_68 ) ); font_days = fonts_load_custom_font( resource_get_handle( RESOURCE_ID_FONT_LCARS_20 ) ); font_date = fonts_load_custom_font( resource_get_handle( RESOURCE_ID_FONT_LCARS_25 ) ); // Setup time layer text_time_layer = setup_text_layer( TIME_RECT, GTextAlignmentRight, font_time ); #ifdef PBL_COLOR text_layer_set_text_color(text_time_layer, GColorChromeYellow); #endif layer_add_child( window_layer, text_layer_get_layer( text_time_layer ) ); // Setup AM/PM name layer text_ampm_layer = setup_text_layer( AMPM_RECT, GTextAlignmentLeft, font_days ); layer_add_child( window_layer, text_layer_get_layer( text_ampm_layer ) ); // Setup days line layer text_days_layer = setup_text_layer( DAYS_RECT, GTextAlignmentLeft, font_days ); #ifdef PBL_COLOR text_layer_set_text_color(text_days_layer, GColorDarkGray); #endif layer_add_child( window_layer, text_layer_get_layer( text_days_layer ) ); text_layer_set_text( text_days_layer, day_lines[current_language] ); // Setup date layer text_date_layer = setup_text_layer( ( current_status == STATUS_ON ) ? DATE_RECT : OFF_DATE_RECT , GTextAlignmentLeft , font_date ); #ifdef PBL_COLOR text_layer_set_text_color(text_date_layer, GColorChromeYellow); #endif layer_add_child( window_layer, text_layer_get_layer( text_date_layer ) ); // Setup week layer text_week_layer = setup_text_layer( ( current_status == STATUS_ON ) ? WEEK_RECT : OFF_WEEK_RECT , GTextAlignmentLeft , font_date ); #ifdef PBL_COLOR text_layer_set_text_color(text_week_layer, GColorChromeYellow); #endif layer_add_child( window_layer, text_layer_get_layer( text_week_layer ) ); // Setup weather info Layer *weather_holder = layer_create(GRect(0, 0, 144, 168 )); layer_add_child(window_layer, weather_holder); icon_layer = bitmap_layer_create( ( weather_status == WEATHER_ON ) ? ICON_RECT : EMPTY_RECT ); // icon_layer = bitmap_layer_create( ICON_RECT ); layer_add_child(weather_holder, bitmap_layer_get_layer(icon_layer)); temp_layer = setup_text_layer( ( weather_status == WEATHER_ON ) ? TEMP_RECT : EMPTY_RECT , GTextAlignmentLeft , font_days ); //temp_layer = setup_text_layer( TEMP_RECT, GTextAlignmentLeft, font_days ); layer_add_child(weather_holder, text_layer_get_layer(temp_layer)); // Setup battery layer battery_layer = bitmap_layer_create( ( current_status == STATUS_ON ) ? BATT_RECT : EMPTY_RECT ); layer_add_child( window_layer, bitmap_layer_get_layer( battery_layer ) ); // Setup bluetooth layer bluetooth_layer = bitmap_layer_create( ( current_status == STATUS_ON ) ? BT_RECT : EMPTY_RECT ); layer_add_child( window_layer, bitmap_layer_get_layer( bluetooth_layer ) ); // Add inverter layer (indicator for the current day of the week) currentDayLayer = inverter_layer_create( EMPTY_RECT ); layer_add_child( window_layer, inverter_layer_get_layer( currentDayLayer ) ); // Setup seconds name layer text_secs_layer = setup_text_layer( SECS_RECT, GTextAlignmentLeft, font_days ); layer_add_child( window_layer, text_layer_get_layer( text_secs_layer ) ); // Subscribe to services tick_timer_service_subscribe( SECOND_UNIT, handle_tick ); // Force update to avoid a blank screen at startup of the watchface update_time(); }
static void window_load(Window *window) { int num_a_items = 0; trig_menu_items[num_a_items++] = (SimpleMenuItem){ .title = "Identidade Pythag 1", .subtitle = "sin²u+cos²u = 1", }; trig_menu_items[num_a_items++] = (SimpleMenuItem){ .title = "Identidade Pythag 2", .subtitle = "1+tan²u= = sec²u", }; trig_menu_items[num_a_items++] = (SimpleMenuItem){ .title = "Identidade Pythag 3", .subtitle = "1+cot²u = sec²u", }; trig_menu_items[num_a_items++] = (SimpleMenuItem){ .title = "Identidade Quociente 1", .subtitle = "tan u = (sin u/cos u)", }; trig_menu_items[num_a_items++] = (SimpleMenuItem){ .title = "Identidade Quociente 2", .subtitle = "cot u = (cos u/sin u)", }; trig_menu_items[num_a_items++] = (SimpleMenuItem){ .title = "Identidade Recíproco 1", .subtitle = "sin u = (1/csc u)", }; trig_menu_items[num_a_items++] = (SimpleMenuItem){ .title = "Identidade Recíproco 2", .subtitle = "cos u = (1/sec u)", }; trig_menu_items[num_a_items++] = (SimpleMenuItem){ .title = "Identidade Recíproco 3", .subtitle = "tan u = (1/cot u)", }; trig_menu_items[num_a_items++] = (SimpleMenuItem){ .title = "Identidade Recíproco 4", .subtitle = "csc u = (1/sin u)", }; trig_menu_items[num_a_items++] = (SimpleMenuItem){ .title = "Identidade Recíproco 5", .subtitle = "sec u = (1/cos u)", }; trig_menu_items[num_a_items++] = (SimpleMenuItem){ .title = "Identidade Recíproco 6", .subtitle = "cot u = (1/tan u)", }; menu_sections.num_items = NUM_TRIG_MENU_ITEMS; menu_sections.items = trig_menu_items; Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_frame(window_layer); simple_menu_layer = simple_menu_layer_create(bounds, window, &menu_sections, 1, NULL); layer_add_child(window_layer, simple_menu_layer_get_layer(simple_menu_layer)); } void show_trig_menu(){ window = window_create(); window_set_window_handlers(window, (WindowHandlers) { .load = window_load, .unload = window_unload, }); window_stack_push(window, true /* Animated */); }
void handle_init(AppContextRef ctx) { (void)ctx; window_init(&window, "Nanji"); // window_set_background_color(&window, GColorBlack); window_stack_push(&window, true /* Animated */); resource_init_current_app(&NANJI_DESUKA); /* Label for year */ bmp_init_container(RESOURCE_ID_IMG_YEAR1, &image_lbl_yr1); layer_set_frame(&image_lbl_yr1.layer.layer, GRect(SCREENW - SMALL_W, 0, SMALL_W, SMALL_H)); layer_add_child(&window.layer, &image_lbl_yr1.layer.layer); bmp_init_container(RESOURCE_ID_IMG_YEAR2, &image_lbl_yr2); layer_set_frame(&image_lbl_yr2.layer.layer, GRect(SCREENW - SMALL_W, SMALL_H, SMALL_W, SMALL_H)); layer_add_child(&window.layer, &image_lbl_yr2.layer.layer); bmp_init_container(RESOURCE_ID_IMG_FUJI, &image_bg); layer_set_frame(&image_bg.layer.layer, GRect(SCREENW - LANDS_W, SCREENH - LANDS_H, LANDS_W, LANDS_H)); layer_add_child(&window.layer, &image_bg.layer.layer); bmp_init_container(RESOURCE_ID_IMG_WEEKD1, &image_lbl_wd1); layer_set_frame(&image_lbl_wd1.layer.layer, GRect(SCREENW - 4*SMALL_W, 1*SMALL_H, SMALL_W, SMALL_H)); layer_add_child(&window.layer, &image_lbl_wd1.layer.layer); bmp_init_container(RESOURCE_ID_IMG_WEEKD2, &image_lbl_wd2); layer_set_frame(&image_lbl_wd2.layer.layer, GRect(SCREENW - 4*SMALL_W, 2*SMALL_H, SMALL_W, SMALL_H)); layer_add_child(&window.layer, &image_lbl_wd2.layer.layer); bmp_init_container(RESOURCE_ID_IMG_YEARS, &image_lbl_yr); layer_add_child(&window.layer, &image_lbl_yr.layer.layer); bmp_init_container(RESOURCE_ID_IMG_MONTHS, &image_lbl_mt); layer_add_child(&window.layer, &image_lbl_mt.layer.layer); bmp_init_container(RESOURCE_ID_IMG_DAYS, &image_lbl_dy); layer_add_child(&window.layer, &image_lbl_dy.layer.layer); // bmp_init_container(RESOURCE_ID_IMG_WMON, &image_lbl_wd); // layer_add_child(&window.layer, &image_lbl_wd.layer.layer); bmp_init_container(RESOURCE_ID_IMG_HOURS, &image_lbl_hr); layer_add_child(&window.layer, &image_lbl_hr.layer.layer); bmp_init_container(RESOURCE_ID_IMG_MINUTES, &image_lbl_mn); layer_add_child(&window.layer, &image_lbl_mn.layer.layer); bmp_init_container(RESOURCE_ID_IMG_MORNING, &img_morning); bmp_init_container(RESOURCE_ID_IMG_NOON, &img_noon); bmp_init_container(RESOURCE_ID_IMG_NIGHT, &img_night); layer_set_frame(&img_morning.layer.layer, GRect(SCREENW - 5*SMALL_W, digit_used*SMALL_H, SMALL_W, SMALL_H)); layer_set_frame(&img_noon.layer.layer, GRect(SCREENW - 5*SMALL_W, digit_used*SMALL_H, SMALL_W, SMALL_H)); layer_set_frame(&img_night.layer.layer, GRect(SCREENW - 5*SMALL_W, digit_used*SMALL_H, SMALL_W, SMALL_H)); layer_add_child(&window.layer, &img_morning.layer.layer); layer_add_child(&window.layer, &img_noon.layer.layer); layer_add_child(&window.layer, &img_night.layer.layer); bmp_init_container(RESOURCE_ID_IMG_S0, &image_numbers_small[0]); bmp_init_container(RESOURCE_ID_IMG_S1, &image_numbers_small[1]); bmp_init_container(RESOURCE_ID_IMG_S2, &image_numbers_small[2]); bmp_init_container(RESOURCE_ID_IMG_S3, &image_numbers_small[3]); bmp_init_container(RESOURCE_ID_IMG_S4, &image_numbers_small[4]); bmp_init_container(RESOURCE_ID_IMG_S5, &image_numbers_small[5]); bmp_init_container(RESOURCE_ID_IMG_S6, &image_numbers_small[6]); bmp_init_container(RESOURCE_ID_IMG_S7, &image_numbers_small[7]); bmp_init_container(RESOURCE_ID_IMG_S8, &image_numbers_small[8]); bmp_init_container(RESOURCE_ID_IMG_S9, &image_numbers_small[9]); bmp_init_container(RESOURCE_ID_IMG_S10, &image_numbers_small[10]); // bmp_init_container(RESOURCE_ID_IMG_L0, &image_numbers_large[0]); // bmp_init_container(RESOURCE_ID_IMG_L1, &image_numbers_large[1]); // bmp_init_container(RESOURCE_ID_IMG_L2, &image_numbers_large[2]); // bmp_init_container(RESOURCE_ID_IMG_L3, &image_numbers_large[3]); // bmp_init_container(RESOURCE_ID_IMG_L4, &image_numbers_large[4]); // bmp_init_container(RESOURCE_ID_IMG_L5, &image_numbers_large[5]); // bmp_init_container(RESOURCE_ID_IMG_L6, &image_numbers_large[6]); // bmp_init_container(RESOURCE_ID_IMG_L7, &image_numbers_large[7]); // bmp_init_container(RESOURCE_ID_IMG_L8, &image_numbers_large[8]); // bmp_init_container(RESOURCE_ID_IMG_L9, &image_numbers_large[9]); // bmp_init_container(RESOURCE_ID_IMG_L10, &image_numbers_large[10]); bmp_init_container(RESOURCE_ID_IMG_WSUN, &image_week_days[0]); bmp_init_container(RESOURCE_ID_IMG_WMON, &image_week_days[1]); bmp_init_container(RESOURCE_ID_IMG_WTUE, &image_week_days[2]); bmp_init_container(RESOURCE_ID_IMG_WWED, &image_week_days[3]); bmp_init_container(RESOURCE_ID_IMG_WTHU, &image_week_days[4]); bmp_init_container(RESOURCE_ID_IMG_WFRI, &image_week_days[5]); bmp_init_container(RESOURCE_ID_IMG_WSAT, &image_week_days[6]); for (int i = 0; i < 3; ++i) { bitmap_layer_init(&bml_year[i], GRect(0, 0, SMALL_W, SMALL_W)); layer_add_child(&window.layer, &bml_year[i].layer); bitmap_layer_init(&bml_month[i], GRect(0, 0, SMALL_W, SMALL_W)); layer_add_child(&window.layer, &bml_month[i].layer); bitmap_layer_init(&bml_day[i], GRect(0, 0, SMALL_W, SMALL_W)); layer_add_child(&window.layer, &bml_day[i].layer); bitmap_layer_init(&bml_hour[i], GRect(0, 0, SMALL_W, SMALL_W)); layer_add_child(&window.layer, &bml_hour[i].layer); bitmap_layer_init(&bml_minute[i], GRect(0, 0, SMALL_W, SMALL_W)); layer_add_child(&window.layer, &bml_minute[i].layer); } bitmap_layer_init(&bml_weekday, GRect(0, 0, SMALL_W, SMALL_W)); layer_add_child(&window.layer, &bml_weekday.layer); handle_minute_tick(ctx, NULL); }
static void init(void) { memset(&time_digits_layers, 0, sizeof(time_digits_layers)); memset(&time_digits_images, 0, sizeof(time_digits_images)); memset(&date_digits_layers, 0, sizeof(date_digits_layers)); memset(&date_digits_images, 0, sizeof(date_digits_images)); memset(&battery_percent_layers, 0, sizeof(battery_percent_layers)); memset(&battery_percent_image, 0, sizeof(battery_percent_image)); /* canceled settings const int inbound_size = 64; const int outbound_size = 64; app_message_open(inbound_size, outbound_size); */ window = window_create(); if (window == NULL) { //APP_LOG(APP_LOG_LEVEL_DEBUG, "OOM: couldn't allocate window"); return; } window_stack_push(window, true /* Animated */); window_layer = window_get_root_layer(window); // loadPersistentSettings(); background_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BACKGROUND); background_layer = bitmap_layer_create(layer_get_frame(window_layer)); bitmap_layer_set_bitmap(background_layer, background_image); layer_add_child(window_layer, bitmap_layer_get_layer(background_layer)); separator_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_SEPARATOR); GRect frame = (GRect) { .origin = { .x = 69, .y = 91 }, .size = separator_image->bounds.size }; separator_layer = bitmap_layer_create(frame); bitmap_layer_set_bitmap(separator_layer, separator_image); layer_add_child(window_layer, bitmap_layer_get_layer(separator_layer)); /* meter_bar_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_METER_BAR); GRect frame2 = (GRect) { .origin = { .x = 17, .y = 43 }, .size = meter_bar_image->bounds.size }; meter_bar_layer = bitmap_layer_create(frame2); bitmap_layer_set_bitmap(meter_bar_layer, meter_bar_image); layer_add_child(window_layer, bitmap_layer_get_layer(meter_bar_layer)); */ bluetooth_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BLUETOOTH); GRect frame3 = (GRect) { .origin = { .x = 37, .y = 43 }, .size = bluetooth_image->bounds.size }; bluetooth_layer = bitmap_layer_create(frame3); bitmap_layer_set_bitmap(bluetooth_layer, bluetooth_image); layer_add_child(window_layer, bitmap_layer_get_layer(bluetooth_layer)); battery_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BATTERY); GRect frame4 = (GRect) { .origin = { .x = 111, .y = 43 }, .size = battery_image->bounds.size }; battery_layer = bitmap_layer_create(frame4); battery_image_layer = bitmap_layer_create(frame4); bitmap_layer_set_bitmap(battery_image_layer, battery_image); layer_set_update_proc(bitmap_layer_get_layer(battery_layer), battery_layer_update_callback); layer_add_child(window_layer, bitmap_layer_get_layer(battery_image_layer)); layer_add_child(window_layer, bitmap_layer_get_layer(battery_layer)); //week status layer (ShaBP) week_layer = text_layer_create(GRect(55, 38, 27, 14)); text_layer_set_text_color(week_layer, GColorBlack); text_layer_set_text_alignment(week_layer, GTextAlignmentLeft); text_layer_set_background_color(week_layer, GColorClear); text_layer_set_font(week_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); layer_add_child(window_layer, text_layer_get_layer(week_layer)); // steps layer (ShaBP) steps_layer = text_layer_create(GRect(20, 0, 48, 18)); text_layer_set_text_color(steps_layer, GColorWhite); text_layer_set_text_alignment(steps_layer, GTextAlignmentLeft); text_layer_set_background_color(steps_layer, GColorClear); text_layer_set_font(steps_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18)); layer_add_child(window_layer, text_layer_get_layer(steps_layer)); layer_set_hidden(text_layer_get_layer(steps_layer), true); steps_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_STEPS); steps_image_layer = bitmap_layer_create(GRect(9, 4, 9, 14)); bitmap_layer_set_bitmap(steps_image_layer, steps_image); layer_add_child(window_layer, bitmap_layer_get_layer(steps_image_layer)); layer_set_hidden(bitmap_layer_get_layer(steps_image_layer), true); // Goal percentage layer (ShaBP) /* goal_percent_layer = layer_create(GRect(12, 50, 120, 1)); layer_set_update_proc(goal_percent_layer, goal_percent_layer_update_callback); layer_add_child(window_get_root_layer(window), goal_percent_layer); */ // steps goal layer (ShaBP) goal_layer = text_layer_create(GRect(66, 0, 34, 18)); text_layer_set_text_color(goal_layer, GColorWhite); text_layer_set_text_alignment(goal_layer, GTextAlignmentRight); text_layer_set_background_color(goal_layer, GColorClear); text_layer_set_font(goal_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18)); layer_add_child(window_layer, text_layer_get_layer(goal_layer)); layer_set_hidden(text_layer_get_layer(goal_layer), true); goal_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_GOAL); GRect frame_goal = (GRect) { .origin = { .x = 103, .y = 8 }, .size = goal_image->bounds.size }; goal_image_layer = bitmap_layer_create(frame_goal); goal_fill_image_layer = bitmap_layer_create(frame_goal); bitmap_layer_set_bitmap(goal_image_layer, goal_image); layer_set_update_proc(bitmap_layer_get_layer(goal_fill_image_layer), goal_image_layer_update_callback); layer_set_hidden(bitmap_layer_get_layer(goal_image_layer), true); layer_add_child(window_layer, bitmap_layer_get_layer(goal_image_layer)); layer_add_child(window_layer, bitmap_layer_get_layer(goal_fill_image_layer)); //time format GRect frame5 = (GRect) { .origin = { .x = 12, .y = 68 }, .size = {.w = 19, .h = 8} };
// ---------------------------------------------------------------- // public module functions // ---------------------------------------------------------------- // ---------------------------------------------- // menu_timer_button_select() // ---------------------------------------------- void menu_timer_buttons_show_page() { window_stack_push(&window, true); } // menu_timer_button_select()
void handle_init(AppContextRef ctx) { (void)ctx; window_init(&window, "Modern Watch"); window_stack_push(&window, true /* Animated */); resource_init_current_app(&APP_RESOURCES); #if DISPLAY_LOGO && DISPLAY_DATE_ANALOG bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND_LOGO_DATEBOX, &background_image_container); #elif DISPLAY_LOGO bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND_LOGO, &background_image_container); #elif DISPLAY_DATE_ANALOG bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND_DATEBOX, &background_image_container); #else bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND, &background_image_container); #endif layer_add_child(&window.layer, &background_image_container.layer.layer); #if DISPLAY_DATE_ANALOG date_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ORBITRON_MEDIUM_12)); text_layer_init(&date_layer, GRect(116, 77, 20, 20)); text_layer_set_text_color(&date_layer, GColorBlack); #elif DISPLAY_DATE_DIGITAL || DISPLAY_DATE_DIGITAL_DAY date_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_DIGITALDREAM_NARROW_12)); text_layer_init(&date_layer, GRect(27, 40, 90, 30)); text_layer_set_text_color(&date_layer, GColorWhite); #endif #if DISPLAY_DATE_ANALOG || DISPLAY_DATE_DIGITAL || DISPLAY_DATE_DIGITAL_DAY text_layer_set_text_alignment(&date_layer, GTextAlignmentCenter); text_layer_set_background_color(&date_layer, GColorClear); text_layer_set_font(&date_layer, date_font); layer_add_child(&window.layer, &date_layer.layer); draw_date(); #endif layer_init(&hour_display_layer, window.layer.frame); hour_display_layer.update_proc = &hour_display_layer_update_callback; layer_add_child(&window.layer, &hour_display_layer); gpath_init(&hour_hand_outline_path, &HOUR_HAND_OUTLINE_PATH_POINTS); gpath_move_to(&hour_hand_outline_path, grect_center_point(&hour_display_layer.frame)); gpath_init(&hour_hand_path, &HOUR_HAND_PATH_POINTS); gpath_move_to(&hour_hand_path, grect_center_point(&hour_display_layer.frame)); layer_init(&minute_display_layer, window.layer.frame); minute_display_layer.update_proc = &minute_display_layer_update_callback; layer_add_child(&window.layer, &minute_display_layer); gpath_init(&minute_hand_outline_path, &MINUTE_HAND_OUTLINE_PATH_POINTS); gpath_move_to(&minute_hand_outline_path, grect_center_point(&minute_display_layer.frame)); gpath_init(&minute_hand_path, &MINUTE_HAND_PATH_POINTS); gpath_move_to(&minute_hand_path, grect_center_point(&minute_display_layer.frame)); layer_init(¢er_display_layer, window.layer.frame); center_display_layer.update_proc = ¢er_display_layer_update_callback; layer_add_child(&window.layer, ¢er_display_layer); #if DISPLAY_SECONDS layer_init(&second_display_layer, window.layer.frame); second_display_layer.update_proc = &second_display_layer_update_callback; layer_add_child(&window.layer, &second_display_layer); #endif }
static void handle_init(AppContextRef ctx) { (void)ctx; window_init(&s_data.window, "MichaPoe words #1"); window_stack_push(&s_data.window, true); resource_init_current_app(&WF_WOERTER_2); // resolution: 144 × 168 // Fonts GFont font_gross = fonts_load_custom_font(resource_get_handle(DATEFONTBIG)); GFont font_mittel = fonts_load_custom_font(resource_get_handle(DATEFONTMIDDLE)); GFont font_klein = fonts_load_custom_font(resource_get_handle(DATEFONTSMALL)); GFont font_minute = font_mittel; GFont font_qualifier = font_klein; GFont font_hour = font_gross; GFont font_daytime = font_klein; // init layers layer_init(&s_data.simple_bg_layer, s_data.window.layer.frame); s_data.simple_bg_layer.update_proc = &bg_update_proc; layer_add_child(&s_data.window.layer, &s_data.simple_bg_layer); // init date layer -> a plain parent layer to create a date update proc layer_init(&s_data.date_layer, s_data.window.layer.frame); s_data.date_layer.update_proc = &date_update_proc; layer_add_child(&s_data.window.layer, &s_data.date_layer); // calc top of frames int16_t top = TOPSPACE; s_data.minute_label_top = top; s_data.qualifier_label_top = top += TEXTLAYER_MINUTE_VSPACE + FONT_MINUTE_SIZE; s_data.hourqualifier_label_top = top += TEXTLAYER_QUALIFIER_VSPACE + FONT_QUALIFIER_SIZE; s_data.hour_label_top = top += TEXTLAYER_QUALIFIER_VSPACE + FONT_QUALIFIER_SIZE; s_data.daytime_label_top = top += TEXTLAYER_HOUR_VSPACE + FONT_HOUR_SIZE; top += TEXTLAYER_DAYTIME_VSPACE + FONT_DAYTIME_SIZE; int16_t move_down = (168 - top) / 2; s_data.minute_label_top += move_down; s_data.qualifier_label_top += move_down; s_data.hourqualifier_label_top += move_down; s_data.hour_label_top += move_down; s_data.daytime_label_top += move_down; // init minute text_layer_init(&s_data.minute_label, GRect(LEFTSPACE, s_data.minute_label_top, TEXTLAYERWIDTH, FONT_MINUTE_SIZE + TEXTLAYER_MINUTE_VSPACE)); text_layer_set_text(&s_data.minute_label, s_data.minute_buffer); text_layer_set_background_color(&s_data.minute_label, GColorBlack); text_layer_set_text_color(&s_data.minute_label, GColorWhite); text_layer_set_font(&s_data.minute_label, font_minute); layer_add_child(&s_data.date_layer, &s_data.minute_label.layer); // init qualifier text_layer_init(&s_data.qualifier_label, GRect(LEFTSPACE, s_data.qualifier_label_top, TEXTLAYERWIDTH, FONT_QUALIFIER_SIZE + TEXTLAYER_QUALIFIER_VSPACE)); text_layer_set_text(&s_data.qualifier_label, s_data.qualifier_buffer); text_layer_set_background_color(&s_data.qualifier_label, GColorBlack); text_layer_set_text_color(&s_data.qualifier_label, GColorWhite); text_layer_set_font(&s_data.qualifier_label, font_qualifier); layer_add_child(&s_data.date_layer, &s_data.qualifier_label.layer); // init hourqualifier text_layer_init(&s_data.hourqualifier_label, GRect(LEFTSPACE, s_data.hourqualifier_label_top, TEXTLAYERWIDTH, FONT_QUALIFIER_SIZE + TEXTLAYER_QUALIFIER_VSPACE)); text_layer_set_text(&s_data.hourqualifier_label, s_data.hourqualifier_buffer); text_layer_set_background_color(&s_data.hourqualifier_label, GColorBlack); text_layer_set_text_color(&s_data.hourqualifier_label, GColorWhite); text_layer_set_font(&s_data.hourqualifier_label, font_qualifier); layer_add_child(&s_data.date_layer, &s_data.hourqualifier_label.layer); // init hour text_layer_init(&s_data.hour_label, GRect(LEFTSPACE, s_data.hour_label_top, TEXTLAYERWIDTH, FONT_HOUR_SIZE + TEXTLAYER_HOUR_VSPACE)); text_layer_set_text(&s_data.hour_label, s_data.hour_buffer); text_layer_set_background_color(&s_data.hour_label, GColorBlack); text_layer_set_text_color(&s_data.hour_label, GColorWhite); text_layer_set_font(&s_data.hour_label, font_hour); layer_add_child(&s_data.date_layer, &s_data.hour_label.layer); // init daytime text_layer_init(&s_data.daytime_label, GRect(LEFTSPACE, s_data.daytime_label_top, TEXTLAYERWIDTH, FONT_DAYTIME_SIZE + TEXTLAYER_DAYTIME_VSPACE)); text_layer_set_text(&s_data.daytime_label, s_data.daytime_buffer); text_layer_set_background_color(&s_data.daytime_label, GColorBlack); text_layer_set_text_color(&s_data.daytime_label, GColorWhite); text_layer_set_font(&s_data.daytime_label, font_daytime); layer_add_child(&s_data.date_layer, &s_data.daytime_label.layer); }
/* Initialize the application. */ void handle_init(AppContextRef ctx) { PblTm tm; PebbleTickEvent t; ResHandle res_d; ResHandle res_h; // ResHandle res_m; ResHandle res_u; window_init(&window, "Antonio"); window_stack_push(&window, true /* Animated */); window_set_background_color(&window, GColorBlack); resource_init_current_app(&APP_RESOURCES); res_d = resource_get_handle(RESOURCE_ID_FUTURA_18); res_h = resource_get_handle(RESOURCE_ID_FUTURA_CONDENSED_53); res_u = resource_get_handle(RESOURCE_ID_FUTURA_12); font_date = fonts_load_custom_font(res_d); font_hour = fonts_load_custom_font(res_h); font_minute = fonts_load_custom_font(res_h); font_updated = fonts_load_custom_font(res_u); time_layer_init(&time_layer, window.layer.frame); time_layer_set_text_color(&time_layer, GColorWhite); time_layer_set_background_color(&time_layer, GColorClear); time_layer_set_fonts(&time_layer, font_hour, font_minute); layer_set_frame(&time_layer.layer, TIME_FRAME); layer_add_child(&window.layer, &time_layer.layer); text_layer_init(&date_layer, window.layer.frame); text_layer_set_text_color(&date_layer, GColorWhite); text_layer_set_background_color(&date_layer, GColorClear); text_layer_set_font(&date_layer, font_date); text_layer_set_text_alignment(&date_layer, GTextAlignmentCenter); layer_set_frame(&date_layer.layer, DATE_FRAME); layer_add_child(&window.layer, &date_layer.layer); // Add weather layer weather_layer_init(&weather_layer, GPoint(0, 90)); layer_add_child(&window.layer, &weather_layer.layer); // Add updated layer text_layer_init(&updated_layer, window.layer.frame); text_layer_set_text_color(&updated_layer, GColorBlack); text_layer_set_background_color(&updated_layer, GColorClear); text_layer_set_font(&updated_layer, font_updated); text_layer_set_text_alignment(&updated_layer, GTextAlignmentLeft); layer_set_frame(&updated_layer.layer, UPDATED_FRAME); layer_add_child(&window.layer, &updated_layer.layer); // Add hi/low layer text_layer_init(&minmax_layer, window.layer.frame); text_layer_set_text_color(&minmax_layer, GColorBlack); text_layer_set_background_color(&minmax_layer, GColorClear); text_layer_set_font(&minmax_layer, font_updated); text_layer_set_text_alignment(&minmax_layer, GTextAlignmentLeft); layer_set_frame(&minmax_layer.layer, MINMAX_FRAME); layer_add_child(&window.layer, &minmax_layer.layer); http_register_callbacks((HTTPCallbacks){.failure=failed,.success=success,.reconnect=reconnect,.location=location}, (void*)ctx);
static void window_load(Window *window) { // Load the bitmap asset // resource_init_current_app must be called before all asset loading. menu_icons[0] = gbitmap_create_with_resource(RESOURCE_ID_HAPPY); menu_icons[1] = gbitmap_create_with_resource(RESOURCE_ID_SAD); menu_icons[2] = gbitmap_create_with_resource(RESOURCE_ID_STRESSED); menu_icons[3] = gbitmap_create_with_resource(RESOURCE_ID_CALM); // ******** Menu Items ******** // First menu item. first_menu_items[0] = (SimpleMenuItem) { .icon = menu_icons[0], .title = "Happy", .subtitle = "Sweet!", .callback = menu_select_callback, }; // Second menu item. first_menu_items[1] = (SimpleMenuItem) { .icon = menu_icons[1], .title = "Sad", .subtitle = "Cheer Up!", .callback = menu_select_callback, }; // Third menu item. first_menu_items[2] = (SimpleMenuItem) { .icon = menu_icons[2], .title = "Stressed", .subtitle = "Take a chill pill!", .callback = menu_select_callback, }; // Fourth menu item. first_menu_items[3] = (SimpleMenuItem){ .icon = menu_icons[3], .title = "Calm", .subtitle = "Like a felon!", .callback = menu_select_callback, }; // ******** SECTIONS ******** menu_sections[0] = (SimpleMenuSection) { .num_items = NUM_FIRST_MENU_ITEM, .items = first_menu_items, }; // Required: gets the root layer. ( base layer ) Layer *window_layer = window_get_root_layer(window); // Required: Gets the dimensions of the whole pebble screen. GRect bounds = layer_get_bounds(window_layer); // initialize the menu. simple_menu_layer = simple_menu_layer_create(bounds, window, menu_sections, NUM_MENU_SECTIONS, NULL); // Required: add the window for display layer_add_child(window_layer, simple_menu_layer_get_layer(simple_menu_layer)); } /************************************************************/ /* window_unload */ /* */ /* Handles all the clean up before destroying the window. */ /************************************************************/ static void window_unload(Window *window) { simple_menu_layer_destroy(simple_menu_layer); // Destroy the images for(int i = 0; i < NUM_MENU_ICONS; i++){ gbitmap_destroy(menu_icons[i]); } } /************************************************************/ /* init */ /* */ /* Creates the window, sets the click_config_provider, sets */ /* the window handlers, and pushes the window onto the top */ /* of the stack so it is visible. */ /************************************************************/ static void init(void) { // Required: Creates the window. Needed to display everything. window = window_create(); // Required. Sets the hanldlers for the window. window_load for when the user enters the watchapp and // window_unload, for when the user leave the watch app. window_set_window_handlers(window, (WindowHandlers) { .load = window_load, .unload = window_unload, }); // Setup the messaging handlers. app_message_register_outbox_sent(out_sent_handler); app_message_register_outbox_failed(out_failed_handler); const uint32_t inbound_size = 10; const uint32_t outbound_size = 64; app_message_open(inbound_size, outbound_size); // Vibrate to let the user know. vibes_short_pulse(); // Required: Will push the window to the top of the stack and therefore making it visible. const bool animated = true; window_stack_push(window, animated); } /************************************************************/ /* deinit */ /* */ /* Destroys the window and performs all of the necessary */ /* clean up. */ /************************************************************/ static void deinit(void) { window_destroy(window); }
void init(){ // Window window = window_create(); window_stack_push(window, true /* Animated */); window_layer = window_get_root_layer(window); // Background image background_image_container = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BACKGROUND); background_layer = layer_create(GRECT_FULL_WINDOW); layer_set_update_proc(background_layer, &draw_background_callback); layer_add_child(window_layer, background_layer); // Date setup date_layer = text_layer_create(GRect(27, 100, 90, 21)); text_layer_set_text_color(date_layer, GColorWhite); text_layer_set_text_alignment(date_layer, GTextAlignmentCenter); text_layer_set_background_color(date_layer, GColorClear); text_layer_set_font(date_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18)); layer_add_child(window_layer, text_layer_get_layer(date_layer)); draw_date(); // Status setup icon_battery = gbitmap_create_with_resource(RESOURCE_ID_BATTERY_ICON); icon_battery_charge = gbitmap_create_with_resource(RESOURCE_ID_BATTERY_CHARGE); icon_bt = gbitmap_create_with_resource(RESOURCE_ID_BLUETOOTH); BatteryChargeState initial = battery_state_service_peek(); battery_level = initial.charge_percent; battery_plugged = initial.is_plugged; battery_layer = layer_create(GRect(50, 56, 24, 12)); //24*12 layer_set_update_proc(battery_layer, &battery_layer_update_callback); layer_add_child(window_layer, battery_layer); bt_ok = bluetooth_connection_service_peek(); bt_layer = layer_create(GRect(83, 56, 9, 12)); //9*12 layer_set_update_proc(bt_layer, &bt_layer_update_callback); layer_add_child(window_layer, bt_layer); // Hands setup hour_display_layer = layer_create(GRECT_FULL_WINDOW); layer_set_update_proc(hour_display_layer, &hour_display_layer_update_callback); layer_add_child(window_layer, hour_display_layer); hour_hand_path = gpath_create(&HOUR_HAND_PATH_POINTS); gpath_move_to(hour_hand_path, grect_center_point(&GRECT_FULL_WINDOW)); minute_display_layer = layer_create(GRECT_FULL_WINDOW); layer_set_update_proc(minute_display_layer, &minute_display_layer_update_callback); layer_add_child(window_layer, minute_display_layer); minute_hand_path = gpath_create(&MINUTE_HAND_PATH_POINTS); gpath_move_to(minute_hand_path, grect_center_point(&GRECT_FULL_WINDOW)); center_display_layer = layer_create(GRECT_FULL_WINDOW); layer_set_update_proc(center_display_layer, ¢er_display_layer_update_callback); layer_add_child(window_layer, center_display_layer); second_display_layer = layer_create(GRECT_FULL_WINDOW); layer_set_update_proc(second_display_layer, &second_display_layer_update_callback); layer_add_child(window_layer, second_display_layer); // Configurable inverse #ifdef INVERSE full_inverse_layer = inverter_layer_create(GRECT_FULL_WINDOW); layer_add_child(window_layer, inverter_layer_get_layer(full_inverse_layer)); #endif }
void kana_app_settings_show() { window_stack_push(simpleMenu->window, true); }
static void window_load(Window *window) { int num_a_items = 0; int num_a2_items = 0; int num_a3_items = 0; int num_a4_items = 0; math_menu_items[num_a_items++] = (SimpleMenuItem){ .title = "Algebra", .subtitle = "Formule Algebriche", .callback = algebra_select_callback, }; math_menu_items[num_a_items++] = (SimpleMenuItem){ .title = "Geometria", .subtitle = "Formule Geometriche", .callback = geometry_select_callback, }; math_menu_items[num_a_items++] = (SimpleMenuItem){ .title = "Analisi", .subtitle = "Formule Analitiche", .callback = calc_select_callback, }; math_menu_items[num_a_items++] = (SimpleMenuItem){ .title = "Trigonometia", .subtitle = "Formule Trigonometriche", .callback = trig_select_callback, }; science_menu_items[num_a2_items++] = (SimpleMenuItem){ .title = "Fisica", .subtitle = "Formule Fisiche", .callback = physics_select_callback, }; science_menu_items[num_a2_items++] = (SimpleMenuItem){ .title = "Chimica", .subtitle = "Formule Chimiche", .callback = chemistry_select_callback, }; science_menu_items[num_a2_items++] = (SimpleMenuItem){ .title = "Biologia", .subtitle = "Bio-Formule", .callback = bio_select_callback, }; other_menu_items[num_a4_items++] = (SimpleMenuItem){ .title = "Conversioni", .subtitle = "Conversioni d'unità", .callback = conversion_select_callback, }; about_menu_items[num_a3_items++] = (SimpleMenuItem){ .title = "Contattami", .subtitle = "*****@*****.**", }; about_menu_items[num_a3_items++] = (SimpleMenuItem){ .title = "Contattalo", .subtitle = "*****@*****.**", }; menu_sections[0] = (SimpleMenuSection){ .title ="Matematica", .num_items = NUM_MATH_MENU_ITEMS, .items = math_menu_items, }; menu_sections[1] = (SimpleMenuSection){ .title ="Scienze", .num_items = NUM_SCIENCE_MENU_ITEMS, .items = science_menu_items, }; menu_sections[2] = (SimpleMenuSection){ .title ="Altro", .num_items = NUM_OTHER_MENU_ITEMS, .items = other_menu_items, }; menu_sections[3] = (SimpleMenuSection){ .title ="About", .num_items = NUM_ABOUT_MENU_ITEMS, .items = about_menu_items, }; Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_frame(window_layer); simple_menu_layer = simple_menu_layer_create(bounds, window, menu_sections,NUM_MENU_SECTIONS, NULL); layer_add_child(window_layer, simple_menu_layer_get_layer(simple_menu_layer)); } static void window_unload(Window *window) { simple_menu_layer_destroy(simple_menu_layer); } int main(void) { window = window_create(); window_set_window_handlers(window, (WindowHandlers) { .load = window_load, .unload = window_unload, }); window_stack_push(window, true /* Animated */); app_event_loop(); window_destroy(window); }
void select_single_click_handler(ClickRecognizerRef recognizer, void *context) { // For Select Feature window_stack_push(settings, true); }
void resort_select_single_click_handler(ClickRecognizerRef recognizer, void *context) { // For Select Feature - Select Resort and show data send_cmd(); window_stack_push(window, true); }
//********************************** Handle Init ************************** void handle_init(void) { if (quiet_time_is_active()) { QuietTimeColor = GColorYellow; } else { QuietTimeColor = GColorRed; } GColor BGCOLOR = COLOR_FALLBACK(GColorDukeBlue, GColorBlack); BGColorHold = BGCOLOR; GColor TEXTCOLOR = COLOR_FALLBACK(GColorWhite, GColorWhite); TextColorHold = TEXTCOLOR; window = window_create(); window_set_background_color(window, BGCOLOR); window_stack_push(window, true /* Animated */); fontHelvNewLight20 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_HELV_NEW_LIGHT_20)); fontRobotoCondensed20 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_20)); fontRobotoCondensed21 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_21)); fontRobotoBoldSubset37 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLD_SUBSET_37)); fontRobotoBoldSubset49 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLD_SUBSET_49)); Layer *window_layer = window_get_root_layer(window); // Register callbacks app_message_register_inbox_received(inbox_received_callback); app_message_register_inbox_dropped(inbox_dropped_callback); app_message_register_outbox_failed(outbox_failed_callback); app_message_register_outbox_sent(outbox_sent_callback); // Open AppMessage app_message_open(128, 128); //degrees text_degrees_layer = text_layer_create(GRect(30, 1, 60, 200)); text_layer_set_text_alignment(text_degrees_layer, GTextAlignmentCenter); text_layer_set_text(text_degrees_layer, degreesstr); text_layer_set_font(text_degrees_layer, fontRobotoCondensed20); text_layer_set_background_color(text_degrees_layer, BGCOLOR); text_layer_set_text_color(text_degrees_layer, TEXTCOLOR); layer_add_child(window_layer, text_layer_get_layer(text_degrees_layer)); //degrees inside text_degrees_inside_layer = text_layer_create(GRect(85, 2, 55, 26)); text_layer_set_text_alignment(text_degrees_inside_layer, GTextAlignmentRight); text_layer_set_text(text_degrees_inside_layer, degreesstr); text_layer_set_font(text_degrees_inside_layer, fontRobotoCondensed20); text_layer_set_background_color(text_degrees_inside_layer, BGCOLOR); text_layer_set_text_color(text_degrees_inside_layer, TEXTCOLOR); layer_add_child(window_layer, text_layer_get_layer(text_degrees_inside_layer)); // WA1OUI text_wa1oui_layer = text_layer_create(GRect(1,25, 144, 148)); text_layer_set_text_alignment(text_wa1oui_layer, GTextAlignmentCenter); text_layer_set_text(text_wa1oui_layer, "WA1OUI"); text_layer_set_font(text_wa1oui_layer, fontRobotoBoldSubset37); text_layer_set_text_color(text_wa1oui_layer, TEXTCOLOR); text_layer_set_background_color(text_wa1oui_layer, BGCOLOR); layer_add_child(window_layer, text_layer_get_layer(text_wa1oui_layer)); // Dayname text_dayname_layer = text_layer_create(GRect(1, 65, 35, 168-65)); text_layer_set_text_alignment(text_dayname_layer, GTextAlignmentLeft); text_layer_set_font(text_dayname_layer, fontRobotoCondensed20); text_layer_set_text_color(text_dayname_layer, TEXTCOLOR); text_layer_set_background_color(text_dayname_layer, BGCOLOR); layer_add_child(window_layer, text_layer_get_layer(text_dayname_layer)); // wind text_wind_layer = text_layer_create(GRect(37, 65, 60, 168-65)); text_layer_set_text_alignment(text_wind_layer, GTextAlignmentCenter); text_layer_set_font(text_wind_layer, fontRobotoCondensed20); text_layer_set_text_color(text_wind_layer, TEXTCOLOR); text_layer_set_background_color(text_wind_layer, BGCOLOR); layer_add_child(window_layer, text_layer_get_layer(text_wind_layer)); // Rain text_rain_layer = text_layer_create(GRect(95, 65, 49, 168-65)); text_layer_set_text_alignment(text_rain_layer, GTextAlignmentRight); text_layer_set_font(text_rain_layer, fontRobotoCondensed21); text_layer_set_text_color(text_rain_layer, TEXTCOLOR); text_layer_set_background_color(text_rain_layer, BGCOLOR); layer_add_child(window_layer, text_layer_get_layer(text_rain_layer)); // Date text_date_layer = text_layer_create(GRect(8, 88, 144-8, 168-88)); text_layer_set_text_alignment(text_date_layer, GTextAlignmentCenter); text_layer_set_font(text_date_layer, fontRobotoCondensed21); text_layer_set_text_color(text_date_layer, TEXTCOLOR); text_layer_set_background_color(text_date_layer, BGCOLOR); layer_add_child(window_layer, text_layer_get_layer(text_date_layer)); // Time of Day text_time_layer = text_layer_create(GRect(7, 116, 144-7, 168-116)); text_layer_set_text_alignment(text_time_layer, GTextAlignmentCenter); text_layer_set_font(text_time_layer, fontRobotoBoldSubset49); text_layer_set_text_color(text_time_layer, TEXTCOLOR); text_layer_set_background_color(text_time_layer, BGCOLOR); layer_add_child(window_layer, text_layer_get_layer(text_time_layer)); // Red Line GRect red_line_frame = GRect(10, 28, 124, 2); RedLineLayer = layer_create(red_line_frame); layer_set_update_proc(RedLineLayer, red_line_layer_update_callback); layer_add_child(window_layer, RedLineLayer); // Battery Line GRect line_frame = GRect(22, 118, 104, 6); LineLayer = layer_create(line_frame); layer_set_update_proc(LineLayer, line_layer_update_callback); layer_add_child(window_layer, LineLayer); tick_timer_service_subscribe(MINUTE_UNIT, handle_tick); //Bluetooth Logo Setup area GRect BTArea = GRect(1, 5, 20, 20); BTLayer1 = layer_create(BTArea); layer_add_child(window_layer, BTLayer1); layer_set_update_proc(BTLayer1, BTLine_update_callback); bluetooth_connection_service_subscribe(&handle_bluetooth); handle_bluetooth(bluetooth_connection_service_peek()); handle_battery(battery_state_service_peek()); //app focus service subscribe app_focus_service_subscribe(&handle_appfocus); // Ensures time is displayed immediately (will break if NULL tick event accessed). // (This is why it's a good idea to have a separate routine to do the update itself.) time_t now = time(NULL); struct tm *current_time = localtime(&now); handle_tick(current_time, SECOND_UNIT); }
void handle_init(void) { my_window = window_create(); window_set_background_color(my_window, GColorBlack); line_layer = layer_create(GRect(0, 0, 144, 168)); layer_set_update_proc(line_layer, draw_line); time_layer = text_layer_create(GRect(90, 20, 144, 32)); text_layer_set_background_color(time_layer, GColorBlack); #if defined(PBL_ROUND) text_done = text_layer_create(GRect(33,99,144,48)); text_get = text_layer_create(GRect(33, 44, 144, 32)); text_shit = text_layer_create(GRect(33,74,144,32)); text_emoji = text_layer_create(GRect(15,44,50,50)); #elif defined(PBL_RECT) text_done = text_layer_create(GRect(22,95,144,48)); text_get = text_layer_create(GRect(22, 40, 144, 32)); text_shit = text_layer_create(GRect(22,70,144,32)); text_emoji = text_layer_create(GRect(2,40,50,50)); #endif text_layer_set_background_color(text_emoji, GColorBlack); text_layer_set_text_color(text_emoji, GColorWhite); text_layer_set_text(text_emoji, "\U0001F603"); s_custom_font_bold = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_ROBOTO_BOLD_48)); text_layer_set_font(text_done, s_custom_font_bold); text_layer_set_background_color(text_done, GColorBlack); #if defined(PBL_COLOR) text_layer_set_text_color(text_done, GColorRed); text_layer_set_text(text_done, "DONE."); #elif defined(PBL_BW) text_layer_set_text_color(text_done, GColorWhite); text_layer_set_text(text_done, "DONE."); #endif s_custom_font_24 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_ROBOTO_32)); text_layer_set_font(text_get, s_custom_font_24); text_layer_set_background_color(text_get, GColorBlack); text_layer_set_text_color(text_get, GColorWhite); text_layer_set_text(text_get, "Get"); text_layer_set_font(text_shit, s_custom_font_24); text_layer_set_background_color(text_shit, GColorBlack); text_layer_set_text_color(text_shit, GColorWhite); text_layer_set_text(text_shit, "Shit"); s_custom_font_bold = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_ROBOTO_18)); text_layer_set_font(time_layer, s_custom_font_bold); text_layer_set_text_color(time_layer, GColorWhite); text_layer_set_text(time_layer, "00:00"); //draw_line(ctx); layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(text_done)); layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(text_emoji)); layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(text_shit)); layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(text_get)); layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(time_layer)); layer_add_child(window_get_root_layer(my_window), line_layer); window_stack_push(my_window, true); tick_timer_service_subscribe(MINUTE_UNIT, tick_handler); }
void handle_init(void) { window = window_create(); window_stack_push(window, true /* Animated */); window_set_background_color(window, GColorBlack); Layer *window_layer = window_get_root_layer(window); // Setup weather bar Layer *weather_holder = layer_create(GRect(0, 0, 144, 50)); layer_add_child(window_layer, weather_holder); icon_layer = bitmap_layer_create(GRect(0, 0, 40, 40)); layer_add_child(weather_holder, bitmap_layer_get_layer(icon_layer)); temp_layer = text_layer_create(GRect(40, 3, 144 - 40, 28)); text_layer_set_text_color(temp_layer, GColorWhite); text_layer_set_background_color(temp_layer, GColorClear); text_layer_set_font(temp_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD)); text_layer_set_text_alignment(temp_layer, GTextAlignmentRight); layer_add_child(weather_holder, text_layer_get_layer(temp_layer)); // Initialize date & time text Layer *date_holder = layer_create(GRect(0, 52, 144, 94)); layer_add_child(window_layer, date_holder); ResHandle roboto_21 = resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_21); text_day_layer = text_layer_create(GRect(8, 0, 144-8, 25)); text_layer_set_text_color(text_day_layer, GColorWhite); text_layer_set_background_color(text_day_layer, GColorClear); text_layer_set_font(text_day_layer, fonts_load_custom_font(roboto_21)); layer_add_child(date_holder, text_layer_get_layer(text_day_layer)); text_date_layer = text_layer_create(GRect(8, 21, 144-8, 25)); 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(roboto_21)); layer_add_child(date_holder, text_layer_get_layer(text_date_layer)); line_layer = layer_create(GRect(8, 51, 144-16, 2)); layer_set_update_proc(line_layer, line_layer_update_callback); layer_add_child(date_holder, line_layer); ResHandle roboto_49 = resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLD_SUBSET_49); text_time_layer = text_layer_create(GRect(7, 45, 144-7, 49)); 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(roboto_49)); layer_add_child(date_holder, text_layer_get_layer(text_time_layer)); // Setup messaging const int inbound_size = 64; const int outbound_size = 64; app_message_open(inbound_size, outbound_size); Tuplet initial_values[] = { TupletInteger(WEATHER_ICON_KEY, (uint8_t) 13), TupletCString(WEATHER_TEMPERATURE_KEY, ""), TupletInteger(INVERT_COLOR_KEY, persist_read_bool(INVERT_COLOR_KEY)), }; app_sync_init(&sync, sync_buffer, sizeof(sync_buffer), initial_values, ARRAY_LENGTH(initial_values), sync_tuple_changed_callback, NULL, NULL); // FIXME testing code battery_text_layer = text_layer_create(GRect(0, 168 - 18, 144, 168)); text_layer_set_text_color(battery_text_layer, GColorWhite); text_layer_set_background_color(battery_text_layer, GColorClear); text_layer_set_font(battery_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)); text_layer_set_text_alignment(battery_text_layer, GTextAlignmentRight); layer_add_child(window_layer, text_layer_get_layer(battery_text_layer)); // Subscribe to notifications bluetooth_connection_service_subscribe(bluetooth_connection_changed); tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick); battery_state_service_subscribe(update_battery_state); // Update the battery on launch update_battery_state(battery_state_service_peek()); // TODO: Update display here to avoid blank display on launch? }
void handle_init(AppContextRef ctx) { (void)ctx; window_init(&window, "KP Sun-Moon-Clock"); window_stack_push(&window, true /* Animated */); window_set_background_color(&window, GColorWhite); resource_init_current_app(&APP_RESOURCES); font_moon = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_MOON_PHASES_SUBSET_30)); layer_init(&graphics_sun_layer, window.layer.frame); graphics_sun_layer.update_proc = &graphics_sun_layer_update_callback; layer_add_child(&window.layer, &graphics_sun_layer); rotbmp_pair_init_container(RESOURCE_ID_IMAGE_WATCHFACE_WHITE, RESOURCE_ID_IMAGE_WATCHFACE_BLACK, &watchface_container); layer_add_child(&graphics_sun_layer, &watchface_container.layer.layer); rotbmp_pair_layer_set_angle(&watchface_container.layer, 1); watchface_container.layer.layer.frame.origin.x = (144/2) - (watchface_container.layer.layer.frame.size.w/2); watchface_container.layer.layer.frame.origin.y = (168/2) - (watchface_container.layer.layer.frame.size.h/2); text_layer_init(&text_time_layer, window.layer.frame); text_layer_set_text_color(&text_time_layer, GColorBlack); text_layer_set_background_color(&text_time_layer, GColorClear); layer_set_frame(&text_time_layer.layer, GRect(0, 35, 144, 30)); text_layer_set_font(&text_time_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_30))); layer_add_child(&window.layer, &text_time_layer.layer); rotbmp_pair_init_container(RESOURCE_ID_IMAGE_HOUR_WHITE, RESOURCE_ID_IMAGE_HOUR_BLACK, &bitmap_container); rotbmp_pair_layer_set_src_ic(&bitmap_container.layer, GPoint(9,56)); layer_add_child(&window.layer, &bitmap_container.layer.layer); text_layer_init(&moonLayer, GRect(0, 100, 144 /* width */, 168-115 /* height */)); text_layer_set_text_color(&moonLayer, GColorWhite); text_layer_set_background_color(&moonLayer, GColorClear); text_layer_set_font(&moonLayer, font_moon); text_layer_set_text_alignment(&moonLayer, GTextAlignmentCenter); handle_day(ctx, NULL); layer_add_child(&window.layer, &moonLayer.layer); PblTm t; get_time(&t); rotbmp_pair_layer_set_angle(&bitmap_container.layer, TRIG_MAX_ANGLE * get24HourAngle(t.tm_hour, t.tm_min)); bitmap_container.layer.layer.frame.origin.x = (144/2) - (bitmap_container.layer.layer.frame.size.w/2); bitmap_container.layer.layer.frame.origin.y = (168/2) - (bitmap_container.layer.layer.frame.size.h/2); //Day of Week text text_layer_init(&dow_layer, GRect(0, 0, 144, 127+26)); text_layer_set_text_color(&dow_layer, GColorWhite); text_layer_set_background_color(&dow_layer, GColorClear); text_layer_set_font(&dow_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD)); text_layer_set_text_alignment(&dow_layer, GTextAlignmentLeft); text_layer_set_text(&dow_layer, "xxx"); layer_add_child(&window.layer, &dow_layer.layer); //Day of the Month text text_layer_init(&dom_layer, GRect(0, 10, 144, 137+26)); text_layer_set_text_color(&dom_layer, GColorWhite); text_layer_set_background_color(&dom_layer, GColorClear); text_layer_set_font(&dom_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24)); text_layer_set_text_alignment(&dom_layer, GTextAlignmentLeft); text_layer_set_text(&dom_layer, "00"); layer_add_child(&window.layer, &dom_layer.layer); //Month Text text_layer_init(&mon_layer, GRect(0, 0, 144, 127+26)); text_layer_set_text_color(&mon_layer, GColorWhite); text_layer_set_background_color(&mon_layer, GColorClear); text_layer_set_font(&mon_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD)); text_layer_set_text_alignment(&mon_layer, GTextAlignmentRight); text_layer_set_text(&mon_layer, "xxx"); layer_add_child(&window.layer, &mon_layer.layer); //Year Number text text_layer_init(&yon_layer, GRect(0, 10, 144, 137+26)); text_layer_set_text_color(&yon_layer, GColorWhite); text_layer_set_background_color(&yon_layer, GColorClear); text_layer_set_font(&yon_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24)); text_layer_set_text_alignment(&yon_layer, GTextAlignmentRight); text_layer_set_text(&yon_layer, "00"); layer_add_child(&window.layer, &yon_layer.layer); //Sunrise Text text_layer_init(&text_sunrise_layer, window.layer.frame); text_layer_set_text_color(&text_sunrise_layer, GColorWhite); text_layer_set_background_color(&text_sunrise_layer, GColorClear); layer_set_frame(&text_sunrise_layer.layer, GRect(0, 145, 144, 30)); text_layer_set_font(&text_sunrise_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18)); layer_add_child(&window.layer, &text_sunrise_layer.layer); //Sunset Text text_layer_init(&text_sunset_layer, window.layer.frame); text_layer_set_text_color(&text_sunset_layer, GColorWhite); text_layer_set_background_color(&text_sunset_layer, GColorClear); layer_set_frame(&text_sunset_layer.layer, GRect(0, 145, 144, 30)); text_layer_set_font(&text_sunset_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18)); layer_add_child(&window.layer, &text_sunset_layer.layer); http_set_app_id(55122370); http_register_callbacks((HTTPCallbacks){ .time=have_time, .location=have_location }, (void*)ctx);
static void main_window_load(Window *window) { s_menu_icon_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_MENU_ICON_1); // Although we already defined NUM_FIRST_MENU_ITEMS, you can define // an int as such to easily change the order of menu items later int num_a_items = 0; s_first_menu_items[num_a_items++] = (SimpleMenuItem) { .title = "First Item", .callback = menu_select_callback, }; s_first_menu_items[num_a_items++] = (SimpleMenuItem) { .title = "Second Item", .subtitle = "Here's a subtitle", .callback = menu_select_callback, }; s_first_menu_items[num_a_items++] = (SimpleMenuItem) { .title = "Third Item", .subtitle = "This has an icon", .callback = menu_select_callback, .icon = s_menu_icon_image, }; s_second_menu_items[0] = (SimpleMenuItem) { .title = "Special Item", .callback = special_select_callback, }; s_menu_sections[0] = (SimpleMenuSection) { .num_items = NUM_FIRST_MENU_ITEMS, .items = s_first_menu_items, }; s_menu_sections[1] = (SimpleMenuSection) { .title = "Yet Another Section", .num_items = NUM_SECOND_MENU_ITEMS, .items = s_second_menu_items, }; Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_frame(window_layer); s_simple_menu_layer = simple_menu_layer_create(bounds, window, s_menu_sections, NUM_MENU_SECTIONS, NULL); layer_add_child(window_layer, simple_menu_layer_get_layer(s_simple_menu_layer)); } void main_window_unload(Window *window) { simple_menu_layer_destroy(s_simple_menu_layer); gbitmap_destroy(s_menu_icon_image); } static void init() { s_main_window = window_create(); window_set_window_handlers(s_main_window, (WindowHandlers) { .load = main_window_load, .unload = main_window_unload, }); window_stack_push(s_main_window, true); } static void deinit() { window_destroy(s_main_window); } int main(void) { init(); app_event_loop(); deinit(); }
void handle_init(AppContextRef ctx) { window_init(&window, "Window Name"); window_stack_push(&window, true /* Animated */); }
static void init(void) { window = window_create(); window_stack_push(window, true); window_set_background_color(window, GColorBlack); Layer *root_layer = window_get_root_layer(window); GRect frame = layer_get_frame(root_layer); // Init fonts and images font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_16)); font_tiny = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_10)); battery_outline = gbitmap_create_with_resource(RESOURCE_ID_BATTERY_OUTLINE); battery_charge = gbitmap_create_with_resource(RESOURCE_ID_BATTERY_CHARGE); // Init layer for display display_layer = layer_create(frame); layer_set_update_proc(display_layer, &display_layer_update_callback); layer_add_child(root_layer, display_layer); // Init layer for text date_layer = text_layer_create(frame); layer_set_frame(text_layer_get_layer(date_layer), GRect(0, 130, 144, 168-130)); layer_set_bounds(text_layer_get_layer(date_layer), GRect(0, 0, 144, 168-130)); text_layer_set_text_alignment(date_layer, GTextAlignmentCenter); text_layer_set_font(date_layer, font); layer_add_child(root_layer, text_layer_get_layer(date_layer)); // Init layer for battery image battery_layer = bitmap_layer_create(frame); bitmap_layer_set_background_color(battery_layer, GColorClear); layer_set_frame(bitmap_layer_get_layer(battery_layer), GRect(4, 134, 30, 20)); layer_set_bounds(bitmap_layer_get_layer(battery_layer), GRect(0, 0, 30, 20)); bitmap_layer_set_bitmap(battery_layer, battery_outline); layer_add_child(root_layer, bitmap_layer_get_layer(battery_layer)); // Init layer for charge image charge_layer = bitmap_layer_create(frame); bitmap_layer_set_background_color(charge_layer, GColorClear); layer_set_frame(bitmap_layer_get_layer(charge_layer), GRect(8, 136, 20, 16)); layer_set_bounds(bitmap_layer_get_layer(charge_layer), GRect(0, 0, 20, 16)); bitmap_layer_set_bitmap(charge_layer, battery_charge); layer_add_child(root_layer, bitmap_layer_get_layer(charge_layer)); // Init battery fill layer battfill_layer = inverter_layer_create(frame); layer_set_frame(inverter_layer_get_layer(battfill_layer), GRect(8, 136, 0, 16)); layer_add_child(root_layer, inverter_layer_get_layer(battfill_layer)); // Init layer for battery percentage percent_layer = text_layer_create(frame); layer_set_frame(text_layer_get_layer(percent_layer), GRect(4, 154, 30, 14)); layer_set_bounds(text_layer_get_layer(percent_layer), GRect(0, 0, 30, 14)); text_layer_set_text_alignment(percent_layer, GTextAlignmentCenter); text_layer_set_font(percent_layer, font_tiny); layer_add_child(root_layer, text_layer_get_layer(percent_layer)); battery_state_service_subscribe(set_battery); set_battery(battery_state_service_peek()); show_battery(); tick_timer_service_subscribe(SECOND_UNIT, &handle_second_tick); }
void window_main_show() { window_stack_push(window_main, true); timers_postinit(); }
void handle_init(AppContextRef ctx) { (void)ctx; window_init(&window, "Polar Clock watch"); window_stack_push(&window, true); window_set_background_color(&window, GColorBlack); resource_init_current_app(&APP_RESOURCES); // Init the layer for the minute display layer_init(&minute_display_layer, window.layer.frame); minute_display_layer.update_proc = &minute_display_layer_update_callback; layer_add_child(&window.layer, &minute_display_layer); // Init the minute segment path gpath_init(&minute_segment_path, &MINUTE_SEGMENT_PATH_POINTS); gpath_move_to(&minute_segment_path, grect_center_point(&minute_display_layer.frame)); // Init the layer for the hour display layer_init(&hour_display_layer, window.layer.frame); hour_display_layer.update_proc = &hour_display_layer_update_callback; layer_add_child(&window.layer, &hour_display_layer); // Init the hour segment path gpath_init(&hour_segment_path, &HOUR_SEGMENT_PATH_POINTS); gpath_move_to(&hour_segment_path, grect_center_point(&hour_display_layer.frame)); #if SHOW_SECONDS // Init the layer for the second display layer_init(&second_display_layer, window.layer.frame); second_display_layer.update_proc = &second_display_layer_update_callback; layer_add_child(&window.layer, &second_display_layer); // Init the second segment path gpath_init(&second_segment_path, &SECOND_SEGMENT_PATH_POINTS); gpath_move_to(&second_segment_path, grect_center_point(&second_display_layer.frame)); #endif #if SHOW_TEXT_TIME text_layer_init(&text_time_layer, window.layer.frame); text_layer_set_text_color(&text_time_layer, GColorWhite); text_layer_set_background_color(&text_time_layer, GColorClear); #if SHOW_TEXT_DATE layer_set_frame(&text_time_layer.layer, GRect(47, 57, 144-47, 168-57)); #else layer_set_frame(&text_time_layer.layer, GRect(47, 70, 144-47, 168-70)); #endif text_layer_set_font(&text_time_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_21))); layer_add_child(&window.layer, &text_time_layer.layer); #endif #if SHOW_TEXT_DATE text_layer_init(&text_date_layer, window.layer.frame); text_layer_set_text_color(&text_date_layer, GColorWhite); text_layer_set_background_color(&text_date_layer, GColorClear); layer_set_frame(&text_date_layer.layer, GRect(44, 80, 144-44, 168-80)); text_layer_set_font(&text_date_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_21))); layer_add_child(&window.layer, &text_date_layer.layer); #endif }
void handle_init(AppContextRef ctx) { (void)ctx; g_ctx = ctx; window_init(&window, "Golf Dashboard"); window_stack_push(&window, true /* Animated */); GFont defaultfont = fonts_get_system_font(FONT_KEY_GOTHIC_14); layer_init(&holepar, GRect(0, 0, 144 /* width */, 40 /* height */)); holepar.update_proc = &holepar_layer_callback; layer_add_child(&window.layer, &holepar); text_layer_init(&holepar_hole, GRect(0, 0, 72, 17)); text_layer_set_background_color(&holepar_hole, GColorClear); text_layer_set_text_color(&holepar_hole, GColorBlack); text_layer_set_text(&holepar_hole, "Hole"); text_layer_set_text_alignment(&holepar_hole, GTextAlignmentCenter); layer_add_child(&holepar, &holepar_hole.layer); GFont holeparfont = fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD); text_layer_init(&holepar_hole_num, GRect(0, 10, 60, 30)); text_layer_set_background_color(&holepar_hole_num, GColorClear); text_layer_set_text_color(&holepar_hole_num, GColorBlack); text_layer_set_font(&holepar_hole_num,holeparfont); text_layer_set_text(&holepar_hole_num, ""); text_layer_set_text_alignment(&holepar_hole_num, GTextAlignmentCenter); layer_add_child(&holepar, &holepar_hole_num.layer); text_layer_init(&holepar_par, GRect(72, 0, 72, 17)); text_layer_set_background_color(&holepar_par, GColorClear); text_layer_set_text_color(&holepar_par, GColorBlack); text_layer_set_text(&holepar_par, "Par"); text_layer_set_text_alignment(&holepar_par, GTextAlignmentCenter); layer_add_child(&holepar, &holepar_par.layer); // GFont holeparfont = fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD); text_layer_init(&holepar_par_num, GRect(75, 10, 60, 30)); text_layer_set_background_color(&holepar_par_num, GColorClear); text_layer_set_text_color(&holepar_par_num, GColorBlack); text_layer_set_font(&holepar_par_num,holeparfont); text_layer_set_text(&holepar_par_num, "0"); text_layer_set_text_alignment(&holepar_par_num, GTextAlignmentCenter); layer_add_child(&holepar, &holepar_par_num.layer); text_layer_init(&roundtime, GRect(0, 40, 144 /* width */, 15 /* height */)); text_layer_set_background_color(&roundtime, GColorBlack); text_layer_set_text_color(&roundtime, GColorWhite); text_layer_set_font(&roundtime, defaultfont); text_layer_set_text(&roundtime, "Round Time: "); text_layer_set_text_alignment(&roundtime, GTextAlignmentCenter); layer_add_child(&window.layer, &roundtime.layer); GFont yrdfont = fonts_get_system_font(FONT_KEY_GOTHAM_42_MEDIUM_NUMBERS); text_layer_init(&distance, GRect(0, 55, 144 /* width */, 50 /* height */)); text_layer_set_background_color(&distance, GColorBlack); text_layer_set_text_color(&distance, GColorWhite); // Placeholder for Sports SDK text_layer_set_text(&distance, "000"); text_layer_set_font(&distance, yrdfont); text_layer_set_text_alignment(&distance, GTextAlignmentCenter); layer_add_child(&window.layer, &distance.layer); mini_snprintf(s_shots_hole, 25, "Shots: %d", thishole); text_layer_init(&shots_hole, GRect(0, 105, 72 /* width */, 15 /* height */)); text_layer_set_background_color(&shots_hole, GColorBlack); text_layer_set_text_color(&shots_hole, GColorWhite); text_layer_set_font(&shots_hole, defaultfont); text_layer_set_text(&shots_hole, s_shots_hole); text_layer_set_text_alignment(&shots_hole, GTextAlignmentLeft); layer_add_child(&window.layer, &shots_hole.layer); mini_snprintf(s_shots_total, 25, "Total: %d", totalshots); text_layer_init(&shots_total, GRect(72, 105, 72 /* width */, 15 /* height */)); text_layer_set_background_color(&shots_total, GColorBlack); text_layer_set_text_color(&shots_total, GColorWhite); text_layer_set_font(&shots_total, defaultfont); text_layer_set_text(&shots_total, s_shots_total); text_layer_set_text_alignment(&shots_total, GTextAlignmentRight); layer_add_child(&window.layer, &shots_total.layer); GFont clubfont = fonts_get_system_font(FONT_KEY_GOTHIC_24); text_layer_init(&club, GRect(0, 120, 144 /* width */, 168-120-16 /* height */)); text_layer_set_background_color(&club, GColorWhite); text_layer_set_text_color(&club, GColorBlack); text_layer_set_font(&club, clubfont); text_layer_set_text(&club, club_menu[club_menu_index]); text_layer_set_text_alignment(&club, GTextAlignmentCenter); layer_add_child(&window.layer, &club.layer); window_set_click_config_provider(&window, (ClickConfigProvider) click_config_provider); }
void handle_init(AppContextRef ctx) { (void)ctx; window_init(&window, "Brains Watch"); window_stack_push(&window, true); resource_init_current_app(&APP_RESOURCES); // rotbmp_pair_init_container(RESOURCE_ID_IMAGE_PANDA_WHITE, RESOURCE_ID_IMAGE_PANDA_BLACK, &bitmap_container); // Set up a layer for the static watch face background bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND, &background_image_container); layer_add_child(&window.layer, &background_image_container.layer.layer); dice = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_VISITOR_16)); text_layer_init(&date_layer, GRect(53, 105, 40, 40)); text_layer_set_text_alignment(&date_layer, GTextAlignmentCenter); text_layer_set_text_color(&date_layer, GColorWhite); text_layer_set_background_color(&date_layer, GColorClear); text_layer_set_font(&date_layer, dice); layer_add_child(&window.layer, &date_layer.layer); PblTm ti; get_time(&ti); string_format_time(date_text, sizeof(date_text), "%d", &ti); text_layer_set_text(&date_layer, date_text); // Set up a layer for the hour hand rotbmp_init_container(RESOURCE_ID_IMAGE_HOUR_HAND, &hour_hand_image_container); // hour_hand_image_container.layer.compositing_mode = GCompOpClear; rot_bitmap_set_src_ic(&hour_hand_image_container.layer, GPoint(3, 42)); layer_add_child(&window.layer, &hour_hand_image_container.layer.layer); // Set up a layer for the minute hand rotbmp_init_container(RESOURCE_ID_IMAGE_MINUTE_HAND, &minute_hand_image_container); // minute_hand_image_container.layer.compositing_mode = GCompOpClear; rot_bitmap_set_src_ic(&minute_hand_image_container.layer, GPoint(3, 58)); layer_add_child(&window.layer, &minute_hand_image_container.layer.layer); update_hand_positions(); // Setup the black and white circle in the centre of the watch face // (We use a bitmap rather than just drawing it because it means not having // to stuff around with working out the circle center etc.) rotbmp_pair_init_container(RESOURCE_ID_IMAGE_CENTER_CIRCLE_WHITE, RESOURCE_ID_IMAGE_CENTER_CIRCLE_BLACK, ¢er_circle_image_container); // TODO: Do this properly with a GRect(). // (144 = screen width, 168 = screen height) center_circle_image_container.layer.layer.frame.origin.x = (144/2) - (center_circle_image_container.layer.layer.frame.size.w/2); center_circle_image_container.layer.layer.frame.origin.y = (168/2) - (center_circle_image_container.layer.layer.frame.size.h/2); layer_add_child(&window.layer, ¢er_circle_image_container.layer.layer); layer_init(&second_display_layer, window.layer.frame); second_display_layer.update_proc = &second_display_layer_update_callback; layer_add_child(&window.layer, &second_display_layer); }
void handle_init(void) { my_window = window_create(); text_layer = text_layer_create(GRect(0, 0, 144, 20)); window_stack_push(my_window, true); }
/** * Called when message is received from PebbleKitJS * @param received * @param context */ void in_received_handler(DictionaryIterator *received, void *context) { APP_LOG(APP_LOG_LEVEL_DEBUG, "[PEBBLE] Message received"); int count = 0; Tuple *tuple = dict_read_first(received); while(tuple){ count ++; tuple = dict_read_next(received); } count=count-1; for (int i=0;i<count;i++) { Tuple *place = dict_find(received, i); if (place) { char* name=place->value->cstring; //Formatting char* rating = name; while(*rating!= '|') { rating++; } *rating++ = '\0'; char *body =rating; while(*body!= '|') { body++; } *body++ = '\0'; char *lat=body; while(*lat!= '|') { lat++; } *lat++ = '\0'; char* lng=lat; while(*lng!= '|') { lng++; } *lng++ = '\0'; //End of Formatting names[i]=name; ratings[i]=rating; detail[i]=body; lats[i]=lat; lngs[i]=lng; //APP_LOG(APP_LOG_LEVEL_DEBUG, "[PEBBLE] From JAVASCRIPT - venue: \n name %s\n rating%s\n detail %s\n lat %s\n lng%s", names[i],ratings[i],detail[i],lats[i],lngs[i]); APP_LOG(APP_LOG_LEVEL_DEBUG, "[PEBBLE] From JAVASCRIPT - venue:\n lat %s\n lng%s",lats[i],lngs[i]); } } createResultsMenu(count); bounds = layer_get_frame(window_get_root_layer(r_window)); r_menu_layer = simple_menu_layer_create(bounds,r_window, r_sections, 1, NULL); layer_add_child(window_get_root_layer(r_window), simple_menu_layer_get_layer(r_menu_layer)); window_stack_pop(animated); // pop out searching window window_stack_push(r_window, animated); // pusg results window }
void handle_init(AppContextRef ctx) { PblTm tm; PebbleTickEvent t; ResHandle res_d; ResHandle res_t; GFont font_date; GFont font_time; window_init(&window, "AccuInfo"); window_stack_push(&window, true /* Animated */); window_set_background_color(&window, BG_COLOR); resource_init_current_app(&APP_RESOURCES); res_d = resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_21); res_t = resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLD_SUBSET_41); font_date = fonts_load_custom_font(res_d); font_time = fonts_load_custom_font(res_t); text_layer_init(&day_layer, window.layer.frame); text_layer_set_text_color(&day_layer, FG_COLOR); text_layer_set_background_color(&day_layer, GColorClear); text_layer_set_text_alignment(&day_layer, GTextAlignmentCenter); text_layer_set_font(&day_layer, font_date); layer_set_frame(&day_layer.layer, GRect(1, 2, 144-1, 168-2)); layer_add_child(&window.layer, &day_layer.layer); text_layer_init(&time_layer, window.layer.frame); text_layer_set_text_color(&time_layer, FG_COLOR); text_layer_set_background_color(&time_layer, GColorClear); layer_set_frame(&time_layer.layer, GRect(1, 48, 144-1, 168-48)); text_layer_set_font(&time_layer, font_time); layer_add_child(&window.layer, &time_layer.layer); text_layer_init(&secs_layer, window.layer.frame); text_layer_set_text_color(&secs_layer, FG_COLOR); text_layer_set_background_color(&secs_layer, GColorClear); layer_set_frame(&secs_layer.layer, GRect(112, 46, 144-112, 168-46)); text_layer_set_font(&secs_layer, font_date); layer_add_child(&window.layer, &secs_layer.layer); text_layer_init(&m_layer, window.layer.frame); text_layer_set_text_color(&m_layer, FG_COLOR); text_layer_set_background_color(&m_layer, GColorClear); layer_set_frame(&m_layer.layer, GRect(112, 74, 144-112, 168-74)); text_layer_set_font(&m_layer, font_date); layer_add_child(&window.layer, &m_layer.layer); text_layer_init(&date_layer, window.layer.frame); text_layer_set_text_color(&date_layer, FG_COLOR); text_layer_set_background_color(&date_layer, GColorClear); text_layer_set_font(&date_layer, font_date); text_layer_set_text_alignment(&date_layer, GTextAlignmentCenter); layer_set_frame(&date_layer.layer, GRect(1, 118, 144-1, 168-118)); layer_add_child(&window.layer, &date_layer.layer); text_layer_init(&year_layer, window.layer.frame); text_layer_set_text_color(&year_layer, FG_COLOR); text_layer_set_background_color(&year_layer, GColorClear); text_layer_set_font(&year_layer, font_date); text_layer_set_text_alignment(&year_layer, GTextAlignmentCenter); layer_set_frame(&year_layer.layer, GRect(0, 142, 144, 168-142)); layer_add_child(&window.layer, &year_layer.layer); layer_init(&line_layer, window.layer.frame); line_layer.update_proc = &line_layer_update_callback; layer_add_child(&window.layer, &line_layer); get_time(&tm); t.tick_time = &tm; t.units_changed = SECOND_UNIT | MINUTE_UNIT | HOUR_UNIT | DAY_UNIT; handle_second_tick(ctx, &t); }
void handle_init(void) { w = initDatePicker(); // Push the window window_stack_push(w.window, true); }
void handle_init(void) { //fonts GFont bold18 = fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD); GFont norm18 = fonts_get_system_font(FONT_KEY_GOTHIC_14); GFont g28 = fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD); GFont g24 = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD); //init buffers s_data.day_buffer[0] = '\0'; s_data.num_buffer[0] = '\0'; //s_data.sec_buffer[0] = '\0'; s_data.min_buffer[0] = '\0'; s_data.hour_buffer[0] = '\0'; Tuplet tuples[] = { TupletInteger(setting_secondHand, secHandsDisp), TupletInteger(setting_BT, BTDisp), TupletInteger(setting_vibrate, vibrate), TupletInteger(setting_bat, batDisp) }; app_sync_init(&app, buffer, sizeof(buffer), tuples, ARRAY_LENGTH(tuples), tuple_changed_callback, app_error_callback, NULL); //APP_LOG(APP_LOG_LEVEL_DEBUG, "app sync init"); // Create a window and text layer s_data.window = window_create(); window_set_fullscreen(s_data.window, true); s_data.bg_layer = layer_create(layer_get_frame(window_get_root_layer(s_data.window))); s_data.date_layer = layer_create(layer_get_frame(s_data.bg_layer)); s_data.hands_layer = layer_create(layer_get_frame(s_data.bg_layer)); //APP_LOG(APP_LOG_LEVEL_DEBUG, "created window and layers"); // init clock face paths for (int i = 0; i < NUM_CLOCK_TICKS; ++i) { s_data.tick_paths[i] = gpath_create(&ANALOG_BG_POINTS[i]); } //APP_LOG(APP_LOG_LEVEL_DEBUG, "init clock face paths"); // init BT icon paths for (int i = 0; i < NUM_BT_LINES; ++i) { s_data.bt_paths[i] = gpath_create(&BLUETOOTH_POINTS[i]); } //APP_LOG(APP_LOG_LEVEL_DEBUG, "init bt icon paths"); // init BT icon paths for (int i = 0; i < NUM_BAT_LINES; ++i) { s_data.bat_paths[i] = gpath_create(&BATTERY_POINTS[i]); } //APP_LOG(APP_LOG_LEVEL_DEBUG, "init bt icon paths"); // init day s_data.day_label = text_layer_create(GRect(2, 151, 40, 20)); text_layer_set_text(s_data.day_label, s_data.day_buffer); text_layer_set_background_color(s_data.day_label, GColorClear); text_layer_set_text_color(s_data.day_label, GColorWhite); text_layer_set_font(s_data.day_label, norm18); layer_add_child(s_data.date_layer, text_layer_get_layer(s_data.day_label)); //APP_LOG(APP_LOG_LEVEL_DEBUG, "created day_label textLayer"); // init num s_data.num_label = text_layer_create(GRect(144 - 16, 151, 18, 20)); text_layer_set_text(s_data.num_label, s_data.num_buffer); text_layer_set_background_color(s_data.num_label, GColorClear); text_layer_set_text_color(s_data.num_label, GColorWhite); text_layer_set_font(s_data.num_label, norm18); layer_add_child(s_data.date_layer, text_layer_get_layer(s_data.num_label)); //APP_LOG(APP_LOG_LEVEL_DEBUG, "created num_label textLayer"); //init sec -> child layer of hands_layer s_data.sec_layer = text_layer_create(GRect(1, 1, secTextBoxSize, secTextBoxSize)); text_layer_set_text(s_data.sec_layer, s_data.sec_buffer); text_layer_set_text_alignment(s_data.sec_layer, GTextAlignmentCenter); text_layer_set_background_color(s_data.sec_layer, GColorClear); text_layer_set_text_color(s_data.sec_layer, GColorWhite); text_layer_set_font(s_data.sec_layer, norm18); layer_add_child(s_data.hands_layer, text_layer_get_layer(s_data.sec_layer)); //APP_LOG(APP_LOG_LEVEL_DEBUG, "created sec_label textLayer"); //init min -> child layer of hands_layer s_data.min_layer = text_layer_create(GRect(1, 1, minTextBoxSize, minTextBoxSize)); text_layer_set_text(s_data.min_layer, s_data.min_buffer); text_layer_set_text_alignment(s_data.min_layer, GTextAlignmentCenter); text_layer_set_background_color(s_data.min_layer, GColorClear); text_layer_set_text_color(s_data.min_layer, GColorWhite); text_layer_set_font(s_data.min_layer, g28); layer_add_child(s_data.hands_layer, text_layer_get_layer(s_data.min_layer)); //APP_LOG(APP_LOG_LEVEL_DEBUG, "created min_label textLayer"); //init hour -> child layer of hands_layer s_data.hour_layer = text_layer_create(GRect(1, 1, hourTextBoxSize, hourTextBoxSize)); text_layer_set_text(s_data.hour_layer, s_data.hour_buffer); text_layer_set_text_alignment(s_data.hour_layer, GTextAlignmentCenter); text_layer_set_background_color(s_data.hour_layer, GColorClear); text_layer_set_text_color(s_data.hour_layer, GColorWhite); text_layer_set_font(s_data.hour_layer, g24); layer_add_child(s_data.hands_layer, text_layer_get_layer(s_data.hour_layer)); //APP_LOG(APP_LOG_LEVEL_DEBUG, "created hour_label textLayer"); //update proc layer_set_update_proc(s_data.bg_layer, bg_update_proc); layer_set_update_proc(s_data.date_layer, date_update_proc); layer_set_update_proc(s_data.hands_layer, hands_update_proc); //APP_LOG(APP_LOG_LEVEL_DEBUG, "set update_procs"); //add layers to window layer_add_child(s_data.bg_layer, s_data.date_layer); layer_add_child(s_data.bg_layer, s_data.hands_layer); layer_add_child(window_get_root_layer(s_data.window), s_data.bg_layer); //APP_LOG(APP_LOG_LEVEL_DEBUG, "finished Layer setup"); // Push the window window_stack_push(s_data.window, true); //APP_LOG(APP_LOG_LEVEL_DEBUG, "Just pushed a window!"); APP_LOG(APP_LOG_LEVEL_DEBUG, "secHandsDisp %d", secHandsDisp); APP_LOG(APP_LOG_LEVEL_DEBUG, "BTDisp %d", BTDisp); APP_LOG(APP_LOG_LEVEL_DEBUG, "vibrate %d", vibrate); APP_LOG(APP_LOG_LEVEL_DEBUG, "batDisp %d", batDisp); if(secHandsDisp) { APP_LOG(APP_LOG_LEVEL_DEBUG, "handle second tick"); handle_tick(NULL, SECOND_UNIT); tick_timer_service_subscribe(SECOND_UNIT, handle_tick); } else { APP_LOG(APP_LOG_LEVEL_DEBUG, "handle minute tick"); handle_tick(NULL, MINUTE_UNIT); tick_timer_service_subscribe(MINUTE_UNIT, handle_tick); } bluetooth_connection_service_subscribe(handle_bluetooth); }