예제 #1
0
static void do_init(void) {
  s_data.window = window_create();
  const bool animated = true;
  window_stack_push(s_data.window, animated);

  window_set_background_color(s_data.window, GColorBlack);
  GFont timefont = fonts_get_system_font(FONT_KEY_BITHAM_30_BLACK);
  GFont datefont = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);

  Layer *window_layer = window_get_root_layer(s_data.window);
  GRect frame = layer_get_frame(window_layer);

  s_data.text_date_layer = text_layer_create(GRect(0, 0, frame.size.w, 32));
  text_layer_set_text_color(s_data.text_date_layer, GColorWhite);
  text_layer_set_background_color(s_data.text_date_layer, GColorClear);
  text_layer_set_font(s_data.text_date_layer, datefont);
  layer_add_child(window_layer, text_layer_get_layer(s_data.text_date_layer));

  s_data.text_time_layer = text_layer_create(GRect(0, 35, frame.size.w, frame.size.h - 20));
  text_layer_set_text_color(s_data.text_time_layer, GColorWhite);
  text_layer_set_background_color(s_data.text_time_layer, GColorClear);
  text_layer_set_font(s_data.text_time_layer, timefont);
  layer_add_child(window_layer, text_layer_get_layer(s_data.text_time_layer));

  GRect line_frame = GRect(0, 33, 144, 2);
  s_data.line_layer = layer_create(line_frame);
  layer_set_update_proc(s_data.line_layer, line_layer_update_callback);
  layer_add_child(window_layer, s_data.line_layer);

  time_t now = time(NULL);
  struct tm *t = localtime(&now);
  update_time(t);

  tick_timer_service_subscribe(MINUTE_UNIT, &handle_minute_tick);
  
}
예제 #2
0
static void window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);

  //ACTION: Create GBitmap, then set to created BitmapLayer
  clock_bitmap = gbitmap_create_with_resource(RESOURCE_ID_bg_image);
  clock_layer = bitmap_layer_create(GRect(0, 0, 144, 168));
  bitmap_layer_set_bitmap(clock_layer, clock_bitmap);
  layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(clock_layer));

  
  //Time TextLayer 
  s_date_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_mermaid_10)); 
  date_layer = text_layer_create(GRect(50, 97, 45, 10));
  text_layer_set_background_color(date_layer, GColorClear);
  text_layer_set_text_color(date_layer, GColorWhite);
  text_layer_set_text(date_layer,  "Wed 00");
  text_layer_set_font(date_layer, s_date_font);
  text_layer_set_text_alignment(date_layer, GTextAlignmentCenter);
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(date_layer));

  //Time TextLayer 
  s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_mermaid_18)); 
  time_layer = text_layer_create(GRect(43, 73, 58, 19));
  text_layer_set_background_color(time_layer, GColorBlack);
  text_layer_set_text_color(time_layer, GColorWhite);
  text_layer_set_text(time_layer,  "00:00");
  text_layer_set_font(time_layer, s_time_font);
  text_layer_set_text_alignment(time_layer, GTextAlignmentCenter);
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(time_layer));

  
  s_hands_layer = layer_create(bounds);
  layer_set_update_proc(s_hands_layer, hands_update_proc);
  layer_add_child(window_layer, s_hands_layer);
}
static void prv_window_load(Window *window) {
  GoalStarGoalEventWindowData *data = window_get_user_data(window);
  if (!data) {
    return;
  }

  Layer *window_root_layer = window_get_root_layer(window);
  const GRect window_root_layer_bounds = layer_get_bounds(window_root_layer);

  data->goal_reached_sequence =
    gdraw_command_sequence_create_with_resource(RESOURCE_ID_GOAL_REACHED);

  data->goal_reached_sequence_layer = layer_create(window_root_layer_bounds);
  Layer *goal_reached_sequence_layer = data->goal_reached_sequence_layer;
  layer_set_update_proc(goal_reached_sequence_layer, prv_goal_reached_sequence_layer_update_proc);
  layer_add_child(window_root_layer, goal_reached_sequence_layer);

  data->goal_reached_sequence_timer = app_timer_register(ANIMATION_FRAME_INTERVAL_MS,
                                                         prv_goal_reached_sequence_timer_handler,
                                                         data);

  prv_vibrate();
  light_enable_interaction();
}
예제 #4
0
void calendar_load(Window* wnd)
{
    // Set the background first
    window_set_background_color(wnd, CALENDAR_BACKGROUND);
    
    // Create a graphics context
    Layer* windowLayer = window_get_root_layer(wnd);
    
    // Get the frame of the parent layer
    GRect calendarFrame = layer_get_frame(windowLayer);
    GRect calendarBounds = calendarFrame;
    
    // Get the height and triple it
    // This allows us to have a region at the top and bottom
    // for next/previous months.
    // Then set the frame to be dead in the middle of it.
    calendarBounds.origin.y = -calendarFrame.size.h;
    calendarBounds.size.h *= 3;
    
    Layer* graphicsLayer = layer_create(calendarFrame);
    layer_set_bounds(graphicsLayer, calendarBounds);
    
    RootData* data = malloc(sizeof(RootData));
    if(data == NULL)
        APP_LOG(APP_LOG_LEVEL_ERROR, "Failed to allocate storage for data");
    data->graphicsLayer = graphicsLayer;
    data->curTime = time(NULL);
    window_set_user_data(wnd, data);
    
    // Set the update callback
    layer_set_update_proc(graphicsLayer, calendar_graphics_draw);
    
    layer_add_child(windowLayer, graphicsLayer);
    
    window_set_click_config_provider(wnd, calendar_click_config_provider);
}
예제 #5
0
void create_chrono_objects() {
  app_log(APP_LOG_LEVEL_INFO, __FILE__, __LINE__, "create_chrono_objects");
  hand_cache_init(&chrono_minute_cache);
  hand_cache_init(&chrono_second_cache);
  hand_cache_init(&chrono_tenth_cache);

  Layer *window_layer = window_get_root_layer(window);

  {
    // We defer loading the chrono dial until we actually need to render it.
    //load_chrono_dial();
    int height = 56;   //chrono_dial_white.bitmap->bounds.size.h;
    int width = 56;    //chrono_dial_white.bitmap->bounds.size.w;
    int x = chrono_tenth_hand_def.place_x - width / 2;
    int y = chrono_tenth_hand_def.place_y - height / 2;

    chrono_dial_layer = layer_create(GRect(x, y, width, height));
    assert(chrono_dial_layer != NULL);
  }
  layer_set_update_proc(chrono_dial_layer, &chrono_dial_layer_update_callback);
  layer_add_child(window_layer, chrono_dial_layer);

  update_chrono_laps_time();
}
예제 #6
0
void handle_init() {
  uint32_t seed = 4;
  tinymt32_init(&rndstate, seed);

  window = window_create();
  window_set_fullscreen(window, true);
  window_stack_push(window, true /* Animated */);
  window_set_background_color(window, GColorBlack);

  // resource_init_current_app(&APP_RESOURCES);

  // Init the layer for the minute display
  // layer_init(&layer, window.layer.frame);
  // layer.update_proc = &layer_update_callback;
  // layer_add_child(&window.layer, &layer);

  init_particles();

  // setup debugging text layer
  GRect window_bounds = layer_get_bounds(window_get_root_layer(window));
  text_header_layer = text_layer_create(window_bounds);
  text_layer_set_text_color(text_header_layer, GColorWhite);
  text_layer_set_background_color(text_header_layer, GColorClear);
  text_layer_set_font(text_header_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14));
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(text_header_layer));
 
  particle_layer = layer_create(window_bounds);
  layer_set_update_proc(particle_layer, update_particles_layer);
  layer_add_child(window_get_root_layer(window), particle_layer);

  app_timer_register(50, handle_animation_timer, NULL);
  app_timer_register(random_in_range(5000, 15000), handle_swarm_timer, NULL);

  tick_timer_service_subscribe(MINUTE_UNIT, handle_tick);
  accel_tap_service_subscribe(handle_tap);
}
static void main_window_load(Window *window) {
  
  // get the main window layer
  s_main_window_layer = window_get_root_layer(s_main_window);
  
  // Get the boundaries of the main layer
  s_main_window_bounds = layer_get_bounds(s_main_window_layer);
  
  // Get the center of the main layer
  s_main_window_center = grect_center_point(&s_main_window_bounds);
  
  // Create the layer we will draw on
  s_canvas_layer = layer_create(GRect(0, 0, s_main_window_bounds.size.w, s_main_window_bounds.size.h));
  
  // Add the layer to our main window layer
  layer_add_child(s_main_window_layer, s_canvas_layer);

  // Set the update procedure for our layer
  layer_set_update_proc(s_canvas_layer, canvas_update_proc);
  
  // Subscribe to the timer tick service to update every minute
  tick_timer_service_subscribe(MINUTE_UNIT, tick_handler);
    
}
예제 #8
0
static void init() {
  window = window_create();
  window_set_background_color(window, GColorBlack);   
  app_message_open(64, 64);

  window_stack_push(window, true);
                                       
  loadPersistentValues();     

  app_message_register_inbox_received(in_received_handler);
  app_message_register_outbox_failed(out_failed_handler);
  sendDefaultsToJS();
                                         
  // initialize layer for day text
  GFont font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_NEVIS_20));
  Layer *root_layer = window_get_root_layer(window);
  GRect frame = layer_get_frame(root_layer); 
  firstLayer = layer_create(frame);
  layer_add_child(root_layer, firstLayer);
  
  setupBackground();
  
  //todo - make text layer conditional on show date
  dayLayer = text_layer_create((GRect) { .origin = { 0, frame.size.h-20 -DATE_OFFSET}, .size = { frame.size.w-DATE_OFFSET, 20 } });
예제 #9
0
RefreshLayer *refresh_layer_create(GRect frame) {
    static const size_t RefreshLayer_size = sizeof(RefreshLayer);
    RefreshLayer *refresh_layer = malloc(RefreshLayer_size);
    memset(refresh_layer, 0, RefreshLayer_size);

    refresh_layer->layer = layer_create(frame);

    GRect icon_layer_frame = GRect(0, 0, frame.size.w, frame.size.h - text_layer_height);
    refresh_layer->icon_layer = bitmap_layer_create(icon_layer_frame);
    bitmap_layer_set_bitmap(refresh_layer->icon_layer, error_bitmap);
    bitmap_layer_set_compositing_mode(refresh_layer->icon_layer, GCompOpAssignInverted);
    layer_add_child(refresh_layer->layer, (Layer *)refresh_layer->icon_layer);

    GRect text_layer_frame = GRect(0, frame.size.h - text_layer_height, frame.size.w, text_layer_height);
    refresh_layer->text_layer = text_layer_create(text_layer_frame);
    text_layer_set_background_color(refresh_layer->text_layer, GColorBlack);
    text_layer_set_font(refresh_layer->text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
    text_layer_set_text(refresh_layer->text_layer, refresh_text);
    text_layer_set_text_alignment(refresh_layer->text_layer, GTextAlignmentCenter);
    text_layer_set_text_color(refresh_layer->text_layer, GColorWhite);
    layer_add_child(refresh_layer->layer, (Layer *)refresh_layer->text_layer);

    return refresh_layer;
}
예제 #10
0
void handle_init()
{
    window = window_create();
    window_stack_push(window, true /* Animated */);

    window_set_background_color(window, BackgroundColor);

    blocks_down_rect = GRect(22, 7, BLOCK_SIZE*2, BLOCK_SIZE + BLOCK_LAYER_EXTRA);
    blocks_up_rect = GRect(22, 0, BLOCK_SIZE*2, BLOCK_SIZE + BLOCK_LAYER_EXTRA - BLOCK_SQUEEZE);
    mario_down_rect = GRect(32, 168-GROUND_HEIGHT-80, 80, 80);
    mario_up_rect = GRect(32, BLOCK_SIZE + BLOCK_LAYER_EXTRA - BLOCK_SQUEEZE, 80, 80);
    ground_rect = GRect(0, 168-GROUND_HEIGHT, 144, 168);

    hour_up_rect = GRect(5, -10, 40, 40);
    hour_normal_rect = GRect(5, 5 + BLOCK_LAYER_EXTRA, 40, 40);
    hour_down_rect = GRect(5, BLOCK_SIZE + BLOCK_LAYER_EXTRA, 40, 40);
    minute_up_rect = GRect(5+BLOCK_SIZE+BLOCK_SPACING, -10, 40, 40);
    minute_normal_rect = GRect(5+BLOCK_SIZE+BLOCK_SPACING, 5 + BLOCK_LAYER_EXTRA, 40, 40);
    minute_down_rect = GRect(5+BLOCK_SIZE+BLOCK_SPACING, BLOCK_SIZE + BLOCK_LAYER_EXTRA, 40, 40);

    blocks_layer = layer_create(blocks_down_rect);
    mario_layer = layer_create(mario_down_rect);
    ground_layer = layer_create(ground_rect);

    layer_set_update_proc(blocks_layer, &blocks_update_callback);
    layer_set_update_proc(mario_layer, &mario_update_callback);
    layer_set_update_proc(ground_layer, &ground_update_callback);

    Layer *window_layer = window_get_root_layer(window);

    layer_add_child(window_layer, blocks_layer);
    layer_add_child(window_layer, mario_layer);
    layer_add_child(window_layer, ground_layer);

    text_hour_layer = text_layer_create(hour_normal_rect);
    text_layer_set_text_color(text_hour_layer, MainColor);
    text_layer_set_background_color(text_hour_layer, GColorClear);
    text_layer_set_text_alignment(text_hour_layer, GTextAlignmentCenter);
    text_layer_set_font(text_hour_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
    layer_add_child(blocks_layer, (Layer *)text_hour_layer);

    text_minute_layer = text_layer_create(GRect(55, 5, 40, 40));
    text_layer_set_text_color(text_minute_layer, MainColor);
    text_layer_set_background_color(text_minute_layer, GColorClear);
    text_layer_set_text_alignment(text_minute_layer, GTextAlignmentCenter);
    text_layer_set_font(text_minute_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
    layer_add_child(blocks_layer, (Layer *)text_minute_layer);

    GRect date_rect = GRect(30, 6, 144-30*2, ground_rect.size.h-6*2);
    date_layer = text_layer_create(date_rect);
    text_layer_set_text_color(date_layer, BackgroundColor);
    text_layer_set_background_color(date_layer, MainColor);
    text_layer_set_text_alignment(date_layer, GTextAlignmentCenter);
    text_layer_set_font(date_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18));
    layer_add_child(ground_layer, (Layer *)date_layer);

#ifndef INVERSED_COLORS
    mario_normal_bmp = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_MARIO_NORMAL);
    mario_jump_bmp = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_MARIO_JUMP);
    ground_bmp = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_GROUND);
#else
    mario_normal_bmp = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_MARIO_NORMAL_INVERSED);
    mario_jump_bmp = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_MARIO_JUMP_INVERSED);
    ground_bmp = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_GROUND_INVERSED);
#endif

#if defined(DEMO)
    #define MARIO_TIME_UNIT SECOND_UNIT
#else
    #define MARIO_TIME_UNIT MINUTE_UNIT
#endif
    tick_timer_service_subscribe(MARIO_TIME_UNIT, handle_tick);
}
예제 #11
0
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);
}
예제 #12
0
파일: main.c 프로젝트: Wadey86/Connected_AD
void window_load(Window *window){
	
	//load bitmap for background/watchface
	face_bitmap = gbitmap_create_with_resource(RESOURCE_ID_WATCHFACE);
	//add bitmap layer
	face_layer = bitmap_layer_create(GRect(0, 0, 144, 168));
	bitmap_layer_set_bitmap(face_layer, face_bitmap);
	layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(face_layer));
	
	//create text layer for bluetooth status
	bt_layer = text_layer_create(GRect(0, 130, 144, 38));
	text_layer_set_background_color(bt_layer, GColorClear);
	text_layer_set_text_color(bt_layer, GColorWhite);
	text_layer_set_text_alignment(bt_layer, GTextAlignmentCenter);
	text_layer_set_font(bt_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14));
	layer_add_child(window_get_root_layer(window), (Layer*) bt_layer);
	
	//manually invoke bluetooth handler to refresh status on load
	bt_handler();
	
	//create text layer for 'pebble' brand at 6oclock
	brand_layer = text_layer_create(GRect(0, 145, 144, 23));
	text_layer_set_background_color(brand_layer, GColorClear);
	text_layer_set_text_color(brand_layer, GColorWhite);
	text_layer_set_text_alignment(brand_layer, GTextAlignmentCenter);
	text_layer_set_font(brand_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
	text_layer_set_text(brand_layer, "pebble");
	layer_add_child(window_get_root_layer(window), (Layer*) brand_layer);
	
	//create text layer for pebble battery status
	batt_layer = text_layer_create(GRect(5, 76, 20, 50));
	text_layer_set_background_color(batt_layer, GColorClear);
	text_layer_set_text_color(batt_layer, GColorWhite);
	text_layer_set_text_alignment(batt_layer, GTextAlignmentCenter);
	text_layer_set_font(batt_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD));
	layer_add_child(window_get_root_layer(window), (Layer*) batt_layer);
	
	//manually invoke battery status handler to refresh status on load
	batt_handler(battery_state_service_peek());
	
	//add text layer for digital time
	text_layer = text_layer_create(GRect(0, 0, 144, 168));
	text_layer_set_background_color(text_layer, GColorClear);
	text_layer_set_text_color(text_layer, GColorWhite);
	text_layer_set_text_alignment(text_layer, GTextAlignmentCenter);
	text_layer_set_font(text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD));
	layer_add_child(window_get_root_layer(window), (Layer*) text_layer);
	
	//create text layer for date
	date_layer = text_layer_create(GRect(116, 76, 25, 50));
	text_layer_set_background_color(date_layer, GColorClear);
	text_layer_set_text_color(date_layer, GColorWhite);
	text_layer_set_text_alignment(date_layer, GTextAlignmentCenter);
	text_layer_set_font(date_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD));
	layer_add_child(window_get_root_layer(window), (Layer*) date_layer);
	
	//add layers for analog clock
	hours_layer = layer_create(GRect(0, 0, 144, 168));
	layer_set_update_proc(hours_layer, hours_layer_update_proc);
	minutes_layer = layer_create(GRect(0, 0, 144, 168));
	layer_set_update_proc(minutes_layer, minutes_layer_update_proc);
	//draw hands
	hour_path = gpath_create(&HOUR_PATH_INFO);
	layer_add_child(window_get_root_layer(window), (Layer*) hours_layer);
	minute_path = gpath_create(&MINUTE_PATH_INFO);
	layer_add_child(window_get_root_layer(window), (Layer*) minutes_layer);
	
	//time struct to display time on load
	struct tm *t;
	time_t temp;
	temp = time(NULL);
	t = localtime(&temp);
	
	//manually invoke tick handler to refresh time on load
	tick_handler(t, MINUTE_UNIT);
	
	//add centre point
	centre_layer = layer_create(GRect(0, 0, 144, 168));
	layer_set_update_proc(centre_layer, centre_layer_update_proc);
	layer_add_child(window_get_root_layer(window), (Layer*) centre_layer);
}
예제 #13
0
static void result_window_load(Window *window) {
	Layer *window_layer = window_get_root_layer(window);
	GRect bounds = layer_get_bounds(window_layer);
	RestaurantInformation *ptr;
	uint8_t status;
	bool valid_result = false; // create action bar and bind key pressing only when valid result is displayed
#ifdef PBL_ROUND
	// no need for the following variables
#else
	GSize max_size, sub_max_size;
	int title_height;
	TextLayer *temp;
#endif
	
	APP_LOG(APP_LOG_LEVEL_DEBUG, "Result window load");
	status = search_result.query_status;
	switch(status){
		case QUERY_STATUS_SUCCESS:
			valid_result = true;
			// Randomly pick up the restaurant
			search_result.random_result = rand()%search_result.num_of_restaurant;
			// Collect required fields
			ptr = &(search_result.restaurant_info[search_result.random_result]);
			strncpy(title_text, ptr->name, sizeof(title_text));
			if(user_setting.unit == 0){
				snprintf(sub_text, sizeof(sub_text), "%s %u %s", direction_name[ptr->direction], 
					(unsigned int)(ptr->distance), setting_unit_option_text[user_setting.unit]);
			}
			else{
				snprintf(sub_text, sizeof(sub_text), "%s %u.%u %s", direction_name[ptr->direction], 
					(unsigned int)(ptr->distance/100), (unsigned int)(ptr->distance%100), setting_unit_option_text[user_setting.unit]);
			}
			break;
		case QUERY_STATUS_NO_RESULT:
		case QUERY_STATUS_GPS_TIMEOUT:
			// Set corresponding error messages to title and subtitle
			strncpy(title_text, query_status_error_message[status], sizeof(title_text));
			strncpy(sub_text, query_status_error_sub_message[status], sizeof(sub_text));
			break;
		case QUERY_STATUS_GOOGLE_API_ERROR:
			// Collect error message from returned information
			strncpy(title_text, query_status_error_message[status], sizeof(title_text));
			strncpy(sub_text, search_result.api_error_message, sizeof(sub_text));
			break;
		default:
			// Other query status = unknown error
			strncpy(title_text, unknown_error_message, sizeof(title_text));
			snprintf(sub_text, sizeof(sub_text), "%s %s%d", unknown_error_sub_message, "Incorrect query status:",status);
			break;
	}

#ifdef PBL_ROUND
	// action bar part
	if(valid_result == true){
		icon_agenda_bitmap = gbitmap_create_with_resource(RESOURCE_ID_ICON_AGENDA);
		text_layer_width = bounds.size.w - ACTION_BAR_WIDTH;
		s_result_action_bar_layer = action_bar_layer_create();
#ifdef PBL_COLOR
		action_bar_layer_set_background_color(s_result_action_bar_layer, highlight_alt_bg_color);
#endif
	}
	else{
		text_layer_width = bounds.size.w;
	}

	// title part
	s_result_title_layer = layer_create(bounds);
	layer_set_update_proc(s_result_title_layer, result_title_layer_update_proc);

	// subtitle part
	s_result_sub_layer = layer_create(GRect(bounds.origin.x, bounds.origin.y+120, bounds.size.w, bounds.size.h-100));
	layer_set_update_proc(s_result_sub_layer, result_sub_layer_update_proc);

	layer_add_child(window_layer, s_result_title_layer);
	layer_add_child(window_layer, s_result_sub_layer);
	action_bar_layer_add_to_window(s_result_action_bar_layer, window);
	action_bar_layer_set_icon(s_result_action_bar_layer, BUTTON_ID_SELECT, icon_agenda_bitmap);
	action_bar_layer_set_click_config_provider(s_result_action_bar_layer, result_click_config_provider);

#else // #ifdef PBL_ROUND	
	// action bar part
	if(valid_result == true){
		icon_agenda_bitmap = gbitmap_create_with_resource(RESOURCE_ID_ICON_AGENDA);
		text_layer_width = bounds.size.w - ACTION_BAR_WIDTH;
		s_result_action_bar_layer = action_bar_layer_create();
#ifdef PBL_COLOR
		action_bar_layer_set_background_color(s_result_action_bar_layer, highlight_alt_bg_color);
#endif
		action_bar_layer_add_to_window(s_result_action_bar_layer, window);
		action_bar_layer_set_icon(s_result_action_bar_layer, BUTTON_ID_SELECT, icon_agenda_bitmap);
	}
	else{
		text_layer_width = bounds.size.w;
	}
	// compute require height for sub-title
	temp = text_layer_create(GRect(bounds.origin.x, bounds.origin.y, text_layer_width, bounds.size.h));
	text_layer_set_font(temp, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
	text_layer_set_text(temp, sub_text);
	sub_max_size = text_layer_get_content_size(temp);
	text_layer_destroy(temp);

	// title part
	s_result_title_text_layer = text_layer_create(GRect(bounds.origin.x, bounds.origin.y, text_layer_width, 2000));
	text_layer_set_font(s_result_title_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
	text_layer_set_text_alignment(s_result_title_text_layer, GTextAlignmentLeft);
	text_layer_set_overflow_mode(s_result_title_text_layer, GTextOverflowModeWordWrap);
	text_layer_set_background_color(s_result_title_text_layer, bg_color);
	text_layer_set_text_color(s_result_title_text_layer, text_color);
	text_layer_set_text(s_result_title_text_layer, title_text);
	max_size = text_layer_get_content_size(s_result_title_text_layer);

	// adjust title height. Always have 10px padding for certain characters to display
	if(max_size.h > (bounds.size.h - sub_max_size.h + 10))
		title_height = (bounds.size.h - sub_max_size.h + 10);  // title is very long: leave some space for sub-title.
	else if(max_size.h < (bounds.size.h/2 + 10))
		title_height = (bounds.size.h/2 + 10);  // title is short: make it half part
	else
		title_height = max_size.h + 10;  // title is long, but not very long: use current size

	// create scroll layer
	s_result_scroll_layer = scroll_layer_create(GRect(bounds.origin.x, bounds.origin.y, text_layer_width, title_height));
	if(valid_result == true){
		scroll_layer_set_click_config_onto_window(s_result_scroll_layer, window);
		scroll_layer_set_callbacks(s_result_scroll_layer, (ScrollLayerCallbacks){.click_config_provider=result_click_config_provider});
예제 #14
0
static void main_window_load(Window *window) {
  // Create background layer.
  s_background_layer = layer_create(GRect(0, 0, 144, 168));
  layer_set_update_proc(s_background_layer, background_layer_draw);
  layer_add_child(window_get_root_layer(window), s_background_layer);
  
  // Create car layer.
  s_car_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_CAR_BLACK);
  s_car_layer = bitmap_layer_create(GRect(4, 128, 36, 36));
  bitmap_layer_set_bitmap(s_car_layer, s_car_bitmap);
  layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(s_car_layer));
  
  // Create day TextLayer.
  s_day_layer = text_layer_create(GRect(12, 4, 122, 25));
  text_layer_set_background_color(s_day_layer, GColorClear);
  text_layer_set_text_color(s_day_layer, GColorDarkGray);
  text_layer_set_text_alignment(s_day_layer, GTextAlignmentLeft);
  
  // Create custom font and add layer to window.
  s_day_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_EXO_20));
  text_layer_set_font(s_day_layer, s_day_font);
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_day_layer));
  
  // Create date TextLayer.
  s_date_layer = text_layer_create(GRect(12, 4, 122, 25));
  text_layer_set_background_color(s_date_layer, GColorClear);
  text_layer_set_text_color(s_date_layer, GColorDarkGray);
  text_layer_set_text_alignment(s_date_layer, GTextAlignmentRight);
  
  // Create custom font and add layer to window.
  s_date_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_EXO_20));
  text_layer_set_font(s_date_layer, s_date_font);
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_date_layer));
  
  // Create time TextLayer.
  s_time_layer = text_layer_create(GRect(0, 16, 144, 50));
  text_layer_set_background_color(s_time_layer, GColorClear);
  text_layer_set_text_color(s_time_layer, GColorBlack);
  text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);
  
  // Create custom font and add layer to window.
  s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_CHANGA_ONE_48));
  text_layer_set_font(s_time_layer, s_time_font);
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_time_layer));
  
  // Create distance layer.
  s_distance_layer = text_layer_create(GRect(10, 94, 134, 32));
  text_layer_set_background_color(s_distance_layer, GColorClear);
  text_layer_set_text_color(s_distance_layer, GColorWhite);
  text_layer_set_text_alignment(s_distance_layer, GTextAlignmentLeft);
  text_layer_set_text(s_distance_layer, "LOADING...");
  
  // Create custom font and add layer to window.
  s_distance_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_SQUADA_ONE_24));
  text_layer_set_font(s_distance_layer, s_distance_font);
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_distance_layer));
  
  // Create travel layer.
  s_travel_layer = text_layer_create(GRect(48, 120, 96, 48));
  text_layer_set_background_color(s_travel_layer, GColorClear);
  text_layer_set_text_color(s_travel_layer, GColorWhite);
  text_layer_set_text_alignment(s_travel_layer, GTextAlignmentLeft);
  
  // Create custom font and add layer to window.
  s_travel_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_SQUADA_ONE_36));
  text_layer_set_font(s_travel_layer, s_travel_font);
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_travel_layer));
}
예제 #15
0
static void handle_init(void) {
  time_t rawtime;
  time (&rawtime);
  struct tm * tick_time;
  tick_time = localtime(&rawtime);
  tick_time->tm_year = 2014 - 1900;
  tick_time->tm_mon = 12 - 1;
  tick_time->tm_mday = 9;
  tick_time->tm_hour = 12 - 1;
  tick_time->tm_min = 0;
  tick_time->tm_sec = 0;
  start_time = mktime(tick_time);
  tick_time = localtime(&rawtime);
  tick_time->tm_year = 2015 - 1900;
  tick_time->tm_mon = 12 - 1;
  tick_time->tm_mday = 9;
  tick_time->tm_hour = 12 - 1;
  tick_time->tm_min = 0;
  tick_time->tm_sec = 0;
  end_time = mktime(tick_time);

  strcpy(text_otslujul, "Ты отслужил");
  strcpy(text_ostalos, "До дембеля осталось");
  strcpy(text_uje, "Ты дембель уже");
  
  // Read stored settings
  if (persist_exists(MSG_START_TIME))
    start_time = persist_read_int(MSG_START_TIME);
  if (persist_exists(MSG_END_TIME))
    end_time = persist_read_int(MSG_END_TIME);
  if (persist_exists(MSG_TEXT_OTSLUJIL))
    persist_read_string(MSG_TEXT_OTSLUJIL, text_otslujul, sizeof(text_otslujul));
  if (persist_exists(MSG_TEXT_OSTALOS))
    persist_read_string(MSG_TEXT_OSTALOS, text_ostalos, sizeof(text_ostalos));
  if (persist_exists(MSG_TEXT_UJE))
    persist_read_string(MSG_TEXT_UJE, text_uje, sizeof(text_uje));
    
  // Open communication channel
  app_message_register_inbox_received(in_received_handler);
  app_message_open(256, 256);
  
	// Create a window and text layer
	window = window_create();

  // Current time layer
  time_layer = text_layer_create(GRect(0, 0, 144, 50));	
	// Set the text, font, and text alignment
	text_layer_set_font(time_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD));
  text_layer_set_background_color(time_layer, GColorClear);
	text_layer_set_text_alignment(time_layer, GTextAlignmentCenter);	
	// Add the text layer to the window
	layer_add_child(window_get_root_layer(window), text_layer_get_layer(time_layer));

  // Left time layer
  left_time_layer = text_layer_create(GRect(0, 47, 144, 80));	
	// Set the text, font, and text alignment
	text_layer_set_font(left_time_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18));
  text_layer_set_background_color(left_time_layer, GColorClear);
	text_layer_set_text_alignment(left_time_layer, GTextAlignmentCenter);	
	// Add the text layer to the window
	layer_add_child(window_get_root_layer(window), text_layer_get_layer(left_time_layer));

  // Another Left time layer
  left_time_layer2 = text_layer_create(GRect(0, 67, 144, 80));	
	// Set the text, font, and text alignment
	text_layer_set_font(left_time_layer2, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
  text_layer_set_background_color(left_time_layer2, GColorClear);
	text_layer_set_text_alignment(left_time_layer2, GTextAlignmentCenter);	
	// Add the text layer to the window
	layer_add_child(window_get_root_layer(window), text_layer_get_layer(left_time_layer2));

  // Percent layer
  percent_layer = text_layer_create(GRect(0, 130, 144, 80));	
	// Set the text, font, and text alignment
	text_layer_set_font(percent_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD));
  text_layer_set_background_color(percent_layer, GColorClear);
	text_layer_set_text_alignment(percent_layer, GTextAlignmentCenter);	
	// Add the text layer to the window
	layer_add_child(window_get_root_layer(window), text_layer_get_layer(percent_layer));

  // Create progress bar
  progress_layer = layer_create(GRect(2, 150, 140, 15));
  layer_set_update_proc(progress_layer, &progress_layer_update_callback);
  layer_add_child(window_get_root_layer(window), progress_layer);
  
  time_t now = time(NULL);
  handle_tick(localtime(&now), 0);
  
	// Push the window
	window_stack_push(window, true);

  // Subscribe to time updates
  tick_timer_service_subscribe(MINUTE_UNIT, handle_tick); 
  
  //light_enable(true); // For taking photos only!
}
예제 #16
0
void handle_init() {
  time_t clock = time(NULL);
  now = localtime(&clock);
  window = window_create();
  window_stack_push(window, true /* Animated */);
  window_set_background_color(window, BG_COLOR);

  date_layer = layer_create(GRect(0, EXTENT, EXTENT, 24));
  layer_set_update_proc(date_layer, &date_layer_update_callback);
  layer_add_child(window_get_root_layer(window), date_layer);

  background_layer = layer_create(GRect(0, 0, EXTENT, EXTENT));
  layer_set_update_proc(background_layer, &background_layer_update_callback);
  layer_add_child(window_get_root_layer(window), background_layer);

  logo = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_LOGO);
  gbitmap_set_palette(logo, bw_palette, false);
  GRect frame = gbitmap_get_bounds(logo);
  grect_align(&frame, &GRect(0, 0, EXTENT, CENTER_Y), GAlignCenter, false);
  logo_layer = bitmap_layer_create(frame);
  bitmap_layer_set_bitmap	(logo_layer, logo);
  layer_add_child(background_layer, bitmap_layer_get_layer(logo_layer));

  hands_layer = layer_create(layer_get_frame(background_layer));
  layer_set_update_proc(hands_layer, &hands_layer_update_callback);
  layer_add_child(background_layer, hands_layer);

  battery_layer = layer_create(GRect(EXTENT-22-3, 3, 22, 10));
  layer_set_update_proc(battery_layer, &battery_layer_update_callback);
  layer_add_child(window_get_root_layer(window), battery_layer);

  for (int i = 0; i < 2; i++) {
    bluetooth_images[i] = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BLUETOOTH_OFF + i);  
    gbitmap_set_palette(bluetooth_images[i], bw_palette, false);
  }
  bluetooth_layer = bitmap_layer_create(GRect(CENTER_X - 6, CENTER_Y - DOTS_RADIUS - 4, 13, 13));
  layer_add_child(background_layer, bitmap_layer_get_layer(bluetooth_layer));

#if DEBUG
  debug_layer = text_layer_create(GRect(0, 0, 32, 16));
  strcpy(debug_buffer, "");
  text_layer_set_text(debug_layer, debug_buffer);
  text_layer_set_text_color(debug_layer, FG_COLOR);
  text_layer_set_background_color(debug_layer, BG_COLOR);
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(debug_layer));
#endif
  
  hour_path = gpath_create(&HOUR_POINTS);
  gpath_move_to(hour_path, GPoint(CENTER_X, CENTER_Y));
  min_path = gpath_create(&MIN_POINTS);
  gpath_move_to(min_path, GPoint(CENTER_X, CENTER_Y));
  sec_path = gpath_create(&SEC_POINTS);
  gpath_move_to(sec_path, GPoint(CENTER_X, CENTER_Y));
  battery_path = gpath_create(&BATTERY_POINTS);
  charge_path = gpath_create(&CHARGE_POINTS);

  startup_animation = animation_create();
  animation_set_curve(startup_animation, AnimationCurveEaseOut);
  animation_set_implementation(startup_animation, &startup_animation_implementation);
  startup_animation_init();
  app_focus_service_subscribe_handlers((AppFocusHandlers){
    .did_focus = handle_app_did_focus,
  });
예제 #17
0
        .draw_row = menu_draw_row_callback,
        .select_click = menu_select_callback,
        .selection_changed = menu_selection_changed_callback,
    });

    // Bind the menu layer's click config provider to the window for interactivity
    menu_layer_set_click_config_onto_window(s_menuLayer, window);

    layer_add_child(windowLayer, menu_layer_get_layer(s_menuLayer));

    initiateScrollTimer();

    #ifdef PBL_SDK_3
    s_statusBar = status_bar_layer_create();
    layer_add_child(windowLayer, status_bar_layer_get_layer(s_statusBar));
    s_battery = layer_create(GRect(bounds.origin.x, bounds.origin.y-16, bounds.size.w, STATUS_BAR_LAYER_HEIGHT));
    layer_set_update_proc(s_battery, battery_proc);
    layer_add_child(windowLayer, s_battery);
    #endif
}

static void nearbyStopsWindow_unload(Window *window) {
    menu_layer_destroy(s_menuLayer);
    #ifdef PBL_SDK_3
    status_bar_layer_destroy(s_statusBar);
    layer_destroy(s_battery);
    #endif
}

static uint16_t menu_get_num_sections_callback2(MenuLayer *menu_layer, void *data) {
    return 1;
예제 #18
0
파일: main.c 프로젝트: palian/Metro8
static void main_window_load(Window *window) {
       
  g_Color = GColorWhite;
    if (persist_exists(COLOR_KEY)) 
{
  char colorname[20];
  persist_read_string(COLOR_KEY, colorname, sizeof(colorname));
  if(strcmp(colorname, "GColorWhite") == 0){g_Color = GColorWhite;}
  else {g_Color = GColorBlack;}
    }
  
  //Creates Colored blocks
  GRect line_frame = GRect(0, 0, 144, 168);//Position for background block
  s_line_layer = layer_create(line_frame);  
  layer_set_update_proc(s_line_layer, line_layer_update_callback);
  layer_add_child(window_get_root_layer(window), s_line_layer);
  
  GRect line_frame2 = GRect(5, 5, 134, 84);//Position for top block
  s_line_layer2 = layer_create(line_frame2);
  layer_set_update_proc(s_line_layer2, line_layer_update_callback2);
  layer_add_child(window_get_root_layer(window), s_line_layer2);
  
  GRect line_frame3 = GRect(5, 94, 67, 69);//Position for bottom left block
  s_line_layer3 = layer_create(line_frame3);
  layer_set_update_proc(s_line_layer3, line_layer_update_callback3);
  layer_add_child(window_get_root_layer(window), s_line_layer3);
  
  GRect line_frame4 = GRect(77, 94, 62, 69);//Position for bottom right block
  s_line_layer4 = layer_create(line_frame4);
  layer_set_update_proc(s_line_layer4, line_layer_update_callback4);
  layer_add_child(window_get_root_layer(window), s_line_layer4);
  
  // Create top time TextLayer
  s_time_layer = text_layer_create(GRect(0, 13, 144, 80)); //Coordinates for Top Time display
  text_layer_set_background_color(s_time_layer, GColorClear);
  text_layer_set_text_color(s_time_layer, g_Color); //Sets color for Top Time
  text_layer_set_text(s_time_layer, "15:45");
    // Improve the layout to be more like a watchface
  text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);
  // Add it as a child layer to the Window's root layer
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_time_layer));
    // Create GFont  
  s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_SEGOE_NORMAL_52));
  //s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_HELVETICA_LIGHT_50));



    // Create top time TextLayer
  s_time_layer2 = text_layer_create(GRect(67, 90, 80, 50)); //Coordinates for Bottom Right Month display
  text_layer_set_background_color(s_time_layer2, GColorClear);
  text_layer_set_text_color(s_time_layer2, g_Color); //Sets color for bottom right month
  text_layer_set_text(s_time_layer2, "Jan");
    // Improve the layout to be more like a watchface
  text_layer_set_text_alignment(s_time_layer2, GTextAlignmentCenter);
  // Add it as a child layer to the Window's root layer
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_time_layer2));
    // Create GFont  
    s_time_font3 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_SEGOE_NORMAL_30));
    //s_time_font3 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_HELVETICA_LIGHT_30));

  
    // Create top time TextLayer
  s_time_layer2a = text_layer_create(GRect(78, 118, 62, 50)); //Coordinates for Bottom right date display
  text_layer_set_background_color(s_time_layer2a, GColorClear);
  text_layer_set_text_color(s_time_layer2a, g_Color); //Sets color for bottom right date
  text_layer_set_text(s_time_layer2a, "15");
    // Improve the layout to be more like a watchface
  text_layer_set_text_alignment(s_time_layer2a, GTextAlignmentCenter);
  // Add it as a child layer to the Window's root layer
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_time_layer2a));
    s_time_font2 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_SEGOE_NORMAL_40));
    //s_time_font2 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_HELVETICA_LIGHT_45));


    // Create top time TextLayer
  s_time_layer3 = text_layer_create(GRect(8, 108, 62, 50)); //Coordinates for Bottom left day display
  text_layer_set_background_color(s_time_layer3, GColorClear);
  text_layer_set_text_color(s_time_layer3, g_Color); //Sets color for bottom left day
  text_layer_set_text(s_time_layer3, "Mon");
    // Improve the layout to be more like a watchface
  text_layer_set_text_alignment(s_time_layer3, GTextAlignmentCenter);
  // Add it as a child layer to the Window's root layer
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_time_layer3));


// Apply to TextLayer
text_layer_set_font(s_time_layer, s_time_font);
text_layer_set_font(s_time_layer2, s_time_font3);  
text_layer_set_font(s_time_layer2a, s_time_font2);  
text_layer_set_font(s_time_layer3, s_time_font3);  
  
  Layer *window_layer = window_get_root_layer(s_main_window);
  GRect bounds = layer_get_frame(window_layer);

  s_image_layer = layer_create(bounds);
  layer_set_update_proc(s_image_layer, layer_update_callback);
  layer_add_child(window_layer, s_image_layer);
  
  s_image_layer2 = layer_create(bounds);
  layer_set_update_proc(s_image_layer2, layer_update_callback2);
  layer_add_child(window_layer, s_image_layer2);
  
  if (persist_exists(BATTERY_KEY)) 
{
  char Battery_name[20];
  persist_read_string(BATTERY_KEY, Battery_name, sizeof(Battery_name));
  if(strcmp(Battery_name, "Never") == 0){}
      else if(strcmp(Battery_name, "Odd_Minutes") == 0){BatteryINT=2;}
      else if(strcmp(Battery_name, "3_Minutes") == 0){BatteryINT=3;}
      else if(strcmp(Battery_name, "5_Minutes") == 0){BatteryINT=5;}
      else if(strcmp(Battery_name, "10_Minutes") == 0){BatteryINT=10;}
      else if(strcmp(Battery_name, "15_Minutes") == 0){BatteryINT=15;}
      else {BatteryINT=2;}
}
}
예제 #19
0
파일: trekkie.c 프로젝트: CmptrGk/trekkie
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);
}
예제 #20
0
static void initialise_ui(void) {
  s_window = window_create();
  window_set_background_color(s_window, GColorBlack);
  #ifndef PBL_SDK_3
    window_set_fullscreen(s_window, true);
  #endif
  
  s_res_leco_58 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_LECO_58));
  s_res_ok = gbitmap_create_with_resource(RESOURCE_ID_OK);
  s_res_leco_14 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_LECO_16));
  s_res_parachute = gbitmap_create_with_resource(RESOURCE_ID_PARACHUTE);
  s_res_bullet = gbitmap_create_with_resource(RESOURCE_ID_BULLET);
  // s_hardaccs_bitmaplayer
  s_hardaccs_bitmaplayer = bitmap_layer_create(GRect(112, 2, 30, 30));
  bitmap_layer_set_bitmap(s_hardaccs_bitmaplayer, s_res_bullet);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_hardaccs_bitmaplayer);
  
  // s_hardbrakes_bitmaplayer
  s_hardbrakes_bitmaplayer = bitmap_layer_create(GRect(2, 2, 30, 30));
  bitmap_layer_set_bitmap(s_hardbrakes_bitmaplayer, s_res_parachute);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_hardbrakes_bitmaplayer);
  
  // s_trend_bitmaplayer
  s_trend_bitmaplayer = bitmap_layer_create(GRect(95, 70, 30, 30));
  bitmap_layer_set_bitmap(s_trend_bitmaplayer, s_res_ok);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_trend_bitmaplayer);
  
  // s_score_textlayer
  s_score_textlayer = text_layer_create(GRect(22, 49, 78, 58));
  text_layer_set_background_color(s_score_textlayer, GColorClear);
  text_layer_set_text_color(s_score_textlayer, GColorWhite);
  text_layer_set_text(s_score_textlayer, "75");
  text_layer_set_text_alignment(s_score_textlayer, GTextAlignmentCenter);
  text_layer_set_font(s_score_textlayer, s_res_leco_58);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_score_textlayer);
  
  // s_score_layer
  s_score_layer = layer_create(GRect(7, 21, 130, 130));
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_score_layer);
  
  // s_hardbrakes_textlayer
  s_hardbrakes_textlayer = text_layer_create(GRect(32, 7, 18, 18));
  text_layer_set_background_color(s_hardbrakes_textlayer, GColorClear);
  text_layer_set_text_color(s_hardbrakes_textlayer, GColorWhite);
  text_layer_set_text(s_hardbrakes_textlayer, "12");
  text_layer_set_font(s_hardbrakes_textlayer, s_res_leco_14);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_hardbrakes_textlayer);
  
  // s_hardaccs_textlayer
  s_hardaccs_textlayer = text_layer_create(GRect(95, 7, 18, 18));
  text_layer_set_background_color(s_hardaccs_textlayer, GColorClear);
  text_layer_set_text_color(s_hardaccs_textlayer, GColorWhite);
  text_layer_set_text(s_hardaccs_textlayer, "15");
  text_layer_set_text_alignment(s_hardaccs_textlayer, GTextAlignmentRight);
  text_layer_set_font(s_hardaccs_textlayer, s_res_leco_14);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_hardaccs_textlayer);
  
  // s_distance_textlayer
  s_distance_textlayer = text_layer_create(GRect(2, 150, 70, 18));
  text_layer_set_background_color(s_distance_textlayer, GColorClear);
  text_layer_set_text_color(s_distance_textlayer, GColorWhite);
  text_layer_set_text(s_distance_textlayer, "42 km");
  text_layer_set_font(s_distance_textlayer, s_res_leco_14);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_distance_textlayer);
  
  // s_duration_textlayer
  s_duration_textlayer = text_layer_create(GRect(72, 150, 70, 18));
  text_layer_set_background_color(s_duration_textlayer, GColorClear);
  text_layer_set_text_color(s_duration_textlayer, GColorWhite);
  text_layer_set_text(s_duration_textlayer, "1h 12m");
  text_layer_set_text_alignment(s_duration_textlayer, GTextAlignmentRight);
  text_layer_set_font(s_duration_textlayer, s_res_leco_14);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_duration_textlayer);
}
예제 #21
0
파일: illudere.c 프로젝트: palian/illusion3
void init(void) {
  window = window_create();
  window_stack_push(window, true /* Animated */);

  // TODO(dmnd) try another colour
  window_set_background_color(window, GColorRed);//Color3

  // TODO(dmnd) try to remember what this does...
  // init both frames to 2
  draw_rect(0, 0, TILES_X, TILES_Y, 2);
  draw_rect(0, 0, TILES_X, TILES_Y, 2);

  // Init the layer for the display
  Layer *root_layer = window_get_root_layer(window);
  GRect frame = layer_get_frame(root_layer);
  display_layer = layer_create(frame);
  layer_set_update_proc(display_layer, &display_layer_update_cb);
  layer_add_child(root_layer, display_layer);

  app_message_register_inbox_received((AppMessageInboxReceived) in_recv_handler);
  app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum());
  
  if (persist_exists(COLOR1_KEY)) 
{
  char colorname[20];
  persist_read_string(COLOR1_KEY, colorname, sizeof(colorname));
  if(strcmp(colorname, "1") == 0){g_Color1 = GColorPictonBlue;}
      else if(strcmp(colorname, "2") == 0){g_Color1 = GColorDukeBlue;}
      else if(strcmp(colorname, "3") == 0){g_Color1 = GColorOxfordBlue;}
      else if(strcmp(colorname, "4") == 0){g_Color1 = GColorWhite;}
      else if(strcmp(colorname, "5") == 0){g_Color1 = GColorLightGray;}
      else if(strcmp(colorname, "6") == 0){g_Color1 = GColorBlack;}
      else if(strcmp(colorname, "7") == 0){g_Color1 = GColorYellow;}
      else if(strcmp(colorname, "8") == 0){g_Color1 = GColorChromeYellow;}
      else if(strcmp(colorname, "9") == 0){g_Color1 = GColorRed;}
      else if(strcmp(colorname, "10") == 0){g_Color1 = GColorDarkCandyAppleRed;}
      else if(strcmp(colorname, "11") == 0){g_Color1 = GColorBrightGreen;}
      else if(strcmp(colorname, "12") == 0){g_Color1 = GColorGreen;}
      else if(strcmp(colorname, "13") == 0){g_Color1 = GColorIslamicGreen;}
      else if(strcmp(colorname, "14") == 0){g_Color1 = GColorVividViolet;}
      else if(strcmp(colorname, "15") == 0){g_Color1 = GColorPurple;}
      else if(strcmp(colorname, "16") == 0){g_Color1 = GColorImperialPurple;}

      else {g_Color1 = GColorPictonBlue;}
  }else {g_Color1 = GColorPictonBlue;}
  
    if (persist_exists(COLOR2_KEY)) 
{
  char colorname[20];
  persist_read_string(COLOR2_KEY, colorname, sizeof(colorname));
  if(strcmp(colorname, "1") == 0){g_Color2 = GColorPictonBlue;}
      else if(strcmp(colorname, "2") == 0){g_Color2 = GColorDukeBlue;}
      else if(strcmp(colorname, "3") == 0){g_Color2 = GColorOxfordBlue;}
      else if(strcmp(colorname, "4") == 0){g_Color2 = GColorWhite;}
      else if(strcmp(colorname, "5") == 0){g_Color2 = GColorLightGray;}
      else if(strcmp(colorname, "6") == 0){g_Color2 = GColorBlack;}
      else if(strcmp(colorname, "7") == 0){g_Color2 = GColorYellow;}
      else if(strcmp(colorname, "8") == 0){g_Color2 = GColorChromeYellow;}
      else if(strcmp(colorname, "9") == 0){g_Color2 = GColorRed;}
      else if(strcmp(colorname, "10") == 0){g_Color2 = GColorDarkCandyAppleRed;}
      else if(strcmp(colorname, "11") == 0){g_Color2 = GColorBrightGreen;}
      else if(strcmp(colorname, "12") == 0){g_Color2 = GColorGreen;}
      else if(strcmp(colorname, "13") == 0){g_Color2 = GColorIslamicGreen;}
      else if(strcmp(colorname, "14") == 0){g_Color2 = GColorVividViolet;}
      else if(strcmp(colorname, "15") == 0){g_Color2 = GColorPurple;}
      else if(strcmp(colorname, "16") == 0){g_Color2 = GColorImperialPurple;}

      else {g_Color2 = GColorBlack;}
  }else {g_Color2 = GColorBlack;}
  
  unsigned char units;
  if (DEBUG) {
    units = SECOND_UNIT;
  } else {
    units = MINUTE_UNIT;
  }
  tick_timer_service_subscribe(units, &handle_minute_tick);
}
예제 #22
0
파일: main.c 프로젝트: yatul/ModernExtra20
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,
			&center_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

}
예제 #23
0
/* Initialize the application.
*/
void app_init(void)
{
    
    const int inbound_size = 64;
    const int outbound_size = 64;
    app_message_open(inbound_size, outbound_size);
    
    // restore values from persistent storage in case the phone isn't around
    sunrise_time = persist_exists(SUNRISE_STORAGE_KEY) ? persist_read_int(SUNRISE_STORAGE_KEY) : DEFAULT_SUN_TIME;
    
    sunset_time = persist_exists(SUNSET_STORAGE_KEY) ? persist_read_int(SUNSET_STORAGE_KEY) : DEFAULT_SUN_TIME;
    
    Tuplet initial_values[] = {
        TupletInteger(SUNRISE_TIME_KEY, sunrise_time),
        TupletInteger(SUNSET_TIME_KEY, sunset_time),
    };
    
    app_sync_init(&sync, sync_buffer, sizeof(sync_buffer), initial_values, ARRAY_LENGTH(initial_values),
      sync_tuple_changed_callback, sync_error_callback, NULL);
    
    
    
    
    // get sunrise/set times from the phone
    send_cmd();
    
    time_t t = time(NULL);
    struct tm *tick_time = localtime(&t);
    TimeUnits units_changed = SECOND_UNIT | MINUTE_UNIT | HOUR_UNIT | DAY_UNIT;
    ResHandle res_d;
    ResHandle res_t;
    Layer *window_layer;

    window = window_create();
    window_layer = window_get_root_layer(window);
    window_set_background_color(window, GColorBlack);

    res_d = resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_21);
    res_t = resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLD_SUBSET_49);
    font_date = fonts_load_custom_font(res_d);
    font_time = fonts_load_custom_font(res_t);

    text_day_layer = text_layer_create(GRect(8, 44 + MOVE_AMOUNT, 144-8, 168-44- MOVE_AMOUNT));
    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, font_date);
    layer_add_child(window_layer, text_layer_get_layer(text_day_layer));

    text_date_layer = text_layer_create(GRect(8, 68 + MOVE_AMOUNT, 144-8, 168-68- MOVE_AMOUNT));
    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, font_date);
    layer_add_child(window_layer, text_layer_get_layer(text_date_layer));

    text_time_layer = text_layer_create(GRect(7, 92 + MOVE_AMOUNT, 144-7, 168-92- MOVE_AMOUNT));
    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, font_time);
    layer_add_child(window_layer, text_layer_get_layer(text_time_layer));
    
    text_sun_layer = text_layer_create(GRect(80, 138, 144-45, 168-80));
    text_layer_set_text_color(text_sun_layer, GColorWhite);
    text_layer_set_background_color(text_sun_layer, GColorClear);
    text_layer_set_font(text_sun_layer, font_date);
    layer_add_child(window_layer, text_layer_get_layer(text_sun_layer));
    
    line_layer = layer_create(GRect(0, 0, 144, 168));
    layer_set_update_proc(line_layer, line_layer_update_callback);
    layer_add_child(window_layer, line_layer);

    handle_minute_tick(tick_time, units_changed);
    update_sun_time(tick_time);
    
    window_stack_push(window, true /* Animated */);
    tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick);
    
}
예제 #24
0
static void window_load(Window *window) 
{
  Layer *window_layer = window_get_root_layer(window);
  //GRect bounds = layer_get_bounds(window_layer);

  // Get our fonts
  beer_font = fonts_load_custom_font(resource_get_handle(FONT_BEER_TIME));
  big_time_font = fonts_load_custom_font(resource_get_handle(FONT_BIG_TIME));
  small_font = fonts_load_custom_font(resource_get_handle(FONT_SMALL));
  // big_font = fonts_load_custom_font(resource_get_handle(FONT_BIG_TIME));
  // seconds_font = fonts_load_custom_font(resource_get_handle(FONT_SECONDS));
  // laps_font = fonts_load_custom_font(resource_get_handle(FONT_LAPS));

  // text_layer = text_layer_create((GRect) { .origin = { 0, 72 }, .size = { bounds.size.w, 20 } });
  text_beer_layer = text_layer_create(SCOTCH_HIDE_RECT);
  text_layer_set_text(text_beer_layer, s_scotch);
  //text_layer_set_text_alignment(text_beer_layer, GTextAlignmentCenter);
  text_layer_set_text_color(text_beer_layer, GColorWhite);
  text_layer_set_background_color(text_beer_layer, GColorClear);
  // text_layer_set_font(text_beer_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLD_SUBSET_36)));
  text_layer_set_font(text_beer_layer, beer_font);
  layer_add_child(window_layer, text_layer_get_layer(text_beer_layer));
   
  // OClock layer
  //text_oclock_layer = text_layer_create(GRect(8, 97, 144-8, 168-97));
  text_oclock_layer = text_layer_create(OCLOCK_HIDE_RECT);
  text_layer_set_text(text_oclock_layer, s_oclock);
  text_layer_set_text_color(text_oclock_layer, GColorWhite);
  text_layer_set_background_color(text_oclock_layer, GColorClear);
  // text_layer_set_font(text_oclock_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLD_SUBSET_36)));
  text_layer_set_font(text_oclock_layer, beer_font);
  layer_add_child(window_layer, text_layer_get_layer(text_oclock_layer));

  // big time layer
  text_time_layer = text_layer_create(TIME_RECT);
  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, big_time_font);
  layer_add_child(window_layer, text_layer_get_layer(text_time_layer));

  // day text layer
	text_day_layer = text_layer_create(DAY_RECT);
  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, small_font);
  layer_add_child(window_layer, text_layer_get_layer(text_day_layer));

  // date text layer
  text_date_layer = text_layer_create(DATE_RECT);
  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, small_font);
  layer_add_child(window_layer, text_layer_get_layer(text_date_layer));

  // Line layer
  GRect line_frame = LINE_RECT;  //GRect(8, 97, 139, 2);
  line_layer = layer_create(line_frame);
  layer_set_update_proc(line_layer, line_layer_update_callback);
  layer_add_child(window_layer, line_layer);


}
예제 #25
0
파일: traino.c 프로젝트: ronny/traino
static void set_up_battery_layer(Layer *window_layer, GRect bounds) {
  s_battery_level_layer = layer_create(GRect(0, 0, BATTERY_LEVEL_WIDTH_PX, BATTERY_LEVEL_HEIGHT_PX));
  layer_set_update_proc(s_battery_level_layer, draw_battery_level);
  layer_add_child(window_layer, s_battery_level_layer);
}
예제 #26
0
//-----------------------------------------------------------------------------------------------------------------------
static void window_load(Window *window) 
{
	Layer *window_layer = window_get_root_layer(window);
	GRect bounds = layer_get_bounds(window_layer);
	
	digitS = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_DIGITAL_23));
	bmp_mask = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_MASK);
	
	// Init layers
	face_layer = layer_create(GRect(0, 0, bounds.size.w, bounds.size.w));
	layer_set_update_proc(face_layer, face_update_proc);

	date_layer = text_layer_create(GRect(-bounds.size.w, bounds.size.h-n_bottom_margin-2, bounds.size.w, n_bottom_margin));
	text_layer_set_text_alignment(date_layer, GTextAlignmentCenter);
	text_layer_set_font(date_layer, digitS);

	//Init bluetooth radio
	radio_layer = bitmap_layer_create(GRect(1, bounds.size.h, 10, 20));
	bitmap_layer_set_background_color(radio_layer, GColorClear);
		
	//Init battery
	battery_layer = bitmap_layer_create(GRect(bounds.size.w-11, bounds.size.h, 10, 20)); 
	bitmap_layer_set_background_color(battery_layer, GColorClear);

	//Update Configuration
	update_configuration();
	
	//Start|Skip Animation
	if (CfgData.anim)
	{
		aktHH = aktMM = 0;
		timer_face = app_timer_register(500, timerCallback, (void*)TIMER_ANIM_FACE);
		
		//Animate Date
		GRect rc_from = layer_get_frame(text_layer_get_layer(date_layer));
		GRect rc_to = rc_from;
		rc_to.origin.x = 0;

		s_prop_anim_date = property_animation_create_layer_frame(text_layer_get_layer(date_layer), &rc_from, &rc_to);
		animation_set_curve((Animation*)s_prop_anim_date, AnimationCurveEaseOut);
		animation_set_delay((Animation*)s_prop_anim_date, 500);
		animation_set_duration((Animation*)s_prop_anim_date, 1000);
		animation_schedule((Animation*)s_prop_anim_date);
		
		//Animate Bluetooth
		rc_from = layer_get_frame(bitmap_layer_get_layer(radio_layer));
#if defined(PBL_RECT)
		rc_to = rc_from;
		rc_to.origin.y -= rc_from.size.h+1;
#elif defined(PBL_ROUND)
		rc_from = GRect(-rc_from.size.w, bounds.size.h/2-rc_from.size.h/2, rc_from.size.w, rc_from.size.h);
		rc_to = rc_from;
		rc_to.origin.x = 4;
#endif		
		s_prop_anim_bt = property_animation_create_layer_frame(bitmap_layer_get_layer(radio_layer), &rc_from, &rc_to);
		animation_set_curve((Animation*)s_prop_anim_bt, AnimationCurveEaseOut);
		animation_set_delay((Animation*)s_prop_anim_bt, 1500);
		animation_set_duration((Animation*)s_prop_anim_bt, 1000);
		animation_schedule((Animation*)s_prop_anim_bt);
		
		//Animate Battery
		rc_from = layer_get_frame(bitmap_layer_get_layer(battery_layer));
#if defined(PBL_RECT)
		rc_to = rc_from;
		rc_to.origin.y -= rc_from.size.h+1;
#elif defined(PBL_ROUND)
		rc_from = GRect(bounds.size.w, bounds.size.h/2-rc_from.size.h/2, rc_from.size.w, rc_from.size.h);
		rc_to = rc_from;
		rc_to.origin.x = bounds.size.w-rc_from.size.w-4;
#endif		
		s_prop_anim_batt = property_animation_create_layer_frame(bitmap_layer_get_layer(battery_layer), &rc_from, &rc_to);
		animation_set_curve((Animation*)s_prop_anim_batt, AnimationCurveEaseOut);
		animation_set_delay((Animation*)s_prop_anim_batt, 2000);
		animation_set_duration((Animation*)s_prop_anim_batt, 1000);
		animation_schedule((Animation*)s_prop_anim_batt);
	}	
	else
	{	
		GRect rc = layer_get_frame(text_layer_get_layer(date_layer));
		rc.origin.x = 0;
		layer_set_frame(text_layer_get_layer(date_layer), rc);
		
		rc = layer_get_frame(bitmap_layer_get_layer(radio_layer));
#if defined(PBL_RECT)
		rc.origin.y -= rc.size.h+1;
#elif defined(PBL_ROUND)
		rc = GRect(4, bounds.size.h/2-rc.size.h/2, rc.size.w, rc.size.h);
#endif		
		layer_set_frame(bitmap_layer_get_layer(radio_layer), rc);
		
		rc = layer_get_frame(bitmap_layer_get_layer(battery_layer));
#if defined(PBL_RECT)
		rc.origin.y -= rc.size.h+1;
#elif defined(PBL_ROUND)
		rc = GRect(bounds.size.w-rc.size.w-4, bounds.size.h/2-rc.size.h/2, rc.size.w, rc.size.h);
#endif		
		layer_set_frame(bitmap_layer_get_layer(battery_layer), rc);
		
		b_initialized = true;
	}
}
예제 #27
0
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(8, 7, 40, 40));
  layer_add_child(weather_holder, bitmap_layer_get_layer(icon_layer));

  temp_layer = text_layer_create(GRect(32, 10, 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, 47, 144-16, 2));
  layer_set_update_proc(line_layer, line_layer_update_callback);
  layer_add_child(date_holder, line_layer);
	
  line_layer = layer_create(GRect(8, 0, 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_text_alignment(text_time_layer, GTextAlignmentCenter);
  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, 53, 144-8, 30));
  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_load_custom_font(roboto_21));
  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?
}
예제 #28
0
static void main_window_load(Window *window) {
    Layer *window_layer = window_get_root_layer(window);
    static BatteryChargeState battery_state;

    /* defaults */
    settings.show_date = 0;
    settings.show_battery = 0;
    settings.use_bold_font = 0;
    settings.use_larger_font = 0;

    persist_read_data(SETTINGS_KEY, &settings, sizeof(settings));

    window_bounds = layer_get_bounds(window_layer);

    watch_bounds = window_bounds;
    if (settings.show_date || settings.show_battery) {
        if (settings.use_larger_font) {
            watch_bounds.origin.y += 18;
            watch_bounds.size.h   -= 18;
        } else {
            watch_bounds.origin.y += 14;
            watch_bounds.size.h   -= 14;
        }
    }

    tick_radius = MIN(watch_bounds.size.h, watch_bounds.size.w) / 2 - 2;
    second_hand_length = tick_radius - 3;
    minute_hand_length = ROUND(tick_radius * 0.8);
    hour_hand_length   = ROUND(tick_radius * 0.5);

    window_set_background_color(window, GColorBlack);

    s_ticks_layer = layer_create(watch_bounds);
    layer_set_update_proc(s_ticks_layer, ticks_update_proc);
    layer_add_child(window_layer, s_ticks_layer);

    inner_bounds = layer_get_bounds(s_ticks_layer);

    center = grect_center_point(&inner_bounds);

    s_wall_time_layer = layer_create(watch_bounds);
    layer_set_update_proc(s_wall_time_layer, canvas_update_proc);
    layer_add_child(window_layer, s_wall_time_layer);

    s_date_text_layer = NULL;
    s_batt_text_layer = NULL;

    if (settings.use_bold_font) {
        if (settings.use_larger_font) {
            s_font = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);
        } else {
            s_font = fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD);
        }
    } else {
        if (settings.use_larger_font) {
            s_font = fonts_get_system_font(FONT_KEY_GOTHIC_18);
        } else {
            s_font = fonts_get_system_font(FONT_KEY_GOTHIC_14);
        }
    }

    if (settings.show_date) {
        s_date_text_layer = text_layer_create(GRect(0, 0, 90, settings.use_larger_font ? 18 : 14));
        text_layer_set_background_color(s_date_text_layer, GColorBlack);
        text_layer_set_text_color(s_date_text_layer, GColorWhite);
        text_layer_set_font(s_date_text_layer, s_font);
        text_layer_set_text_alignment(s_date_text_layer, GTextAlignmentLeft);
        layer_add_child(window_layer, text_layer_get_layer(s_date_text_layer));
    }

    if (settings.show_battery) {
        s_batt_text_layer = text_layer_create(GRect(90, 0, 54, settings.use_larger_font ? 18 : 14));
        text_layer_set_background_color(s_batt_text_layer, GColorBlack);
        text_layer_set_text_color(s_batt_text_layer, GColorWhite);
        text_layer_set_font(s_batt_text_layer, s_font);
        text_layer_set_text_alignment(s_batt_text_layer, GTextAlignmentRight);
        layer_add_child(window_layer, text_layer_get_layer(s_batt_text_layer));
    }

    minute_when_last_updated = -1;

    layer_mark_dirty(s_wall_time_layer);
    tick_timer_service_subscribe(SECOND_UNIT, tick_handler);

    if (settings.show_battery) {
        battery_state = battery_state_service_peek();
        on_battery_state_change(battery_state);
        battery_state_service_subscribe(on_battery_state_change);
    }
}
예제 #29
0
파일: main.c 프로젝트: Aylr/ForecastIOFace
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));
}
예제 #30
0
//-----------------------------------------------------------------------------------------------------------------------
static void update_configuration(void)
{
    if (persist_exists(CONFIG_KEY_THEME))
    {
        int32_t theme = persist_read_int(CONFIG_KEY_THEME);
		CfgData.circle = (theme == 0);
	}
	else
		CfgData.circle = false;
	
    if (persist_exists(CONFIG_KEY_FSM))
		CfgData.fsm = persist_read_bool(CONFIG_KEY_FSM);
	else	
		CfgData.fsm = false;
	
    if (persist_exists(CONFIG_KEY_INV))
		CfgData.inv = !CfgData.circle && persist_read_bool(CONFIG_KEY_INV);
	else	
		CfgData.inv = true;
	
    if (persist_exists(CONFIG_KEY_ANIM))
		CfgData.anim = persist_read_bool(CONFIG_KEY_ANIM);
	else	
		CfgData.anim = true;
	
    if (persist_exists(CONFIG_KEY_SEP))
		CfgData.sep = persist_read_bool(CONFIG_KEY_SEP);
	else	
		CfgData.sep = true;
	
    if (persist_exists(CONFIG_KEY_DATEFMT)) 
		CfgData.datefmt = (int16_t)persist_read_int(CONFIG_KEY_DATEFMT);
	else
		CfgData.datefmt = 0;
	
    if (persist_exists(CONFIG_KEY_SMART))
		CfgData.smart = persist_read_bool(CONFIG_KEY_SMART);
	else	
		CfgData.smart = true;
	
    if (persist_exists(CONFIG_KEY_VIBR))
		CfgData.vibr = persist_read_bool(CONFIG_KEY_VIBR);
	else	
		CfgData.vibr = false;
	
	app_log(APP_LOG_LEVEL_DEBUG, __FILE__, __LINE__, "Curr Conf: circle:%d, fsm:%d, inv:%d, anim:%d, sep:%d, datefmt:%d, smart:%d, vibr:%d",
		CfgData.circle, CfgData.fsm, CfgData.inv, CfgData.anim, CfgData.sep, CfgData.datefmt, CfgData.smart, CfgData.vibr);
	
	gbitmap_destroy(batteryAll);
	batteryAll = gbitmap_create_with_resource(CfgData.inv ? RESOURCE_ID_IMAGE_BATTERY_INV : RESOURCE_ID_IMAGE_BATTERY);
	
	bitmap_layer_set_bitmap(radio_layer, NULL);
	gbitmap_destroy(bmp_radio);
	bmp_radio = gbitmap_create_as_sub_bitmap(batteryAll, GRect(110, 0, 10, 20));
	bitmap_layer_set_bitmap(radio_layer, bmp_radio);
	
	Layer *window_layer = window_get_root_layer(window);
	GRect bounds = layer_get_bounds(window_get_root_layer(window));
	window_set_background_color(window, CfgData.inv ? GColorWhite : GColorBlack);
	
	//Face Layer first on round
	layer_remove_from_parent(face_layer);
	layer_destroy(face_layer);
#if defined(PBL_RECT)
	face_layer = layer_create(GRect(0, 0, bounds.size.w, CfgData.fsm ? bounds.size.h : bounds.size.h-n_bottom_margin));
	layer_set_update_proc(face_layer, face_update_proc);
#elif defined(PBL_ROUND)
	face_layer = layer_create(GRect(0, 0, bounds.size.w, bounds.size.h));
	layer_set_update_proc(face_layer, face_update_proc);
	layer_add_child(window_layer, face_layer);
#endif		

	//Bottom Layer next, then Radio and Battery
	layer_remove_from_parent(text_layer_get_layer(date_layer));
	layer_remove_from_parent(bitmap_layer_get_layer(radio_layer));
	layer_remove_from_parent(bitmap_layer_get_layer(battery_layer));
#if defined(PBL_RECT)
	if (!CfgData.fsm)
#endif		
	{
#if defined(PBL_RECT)
		layer_add_child(window_layer, text_layer_get_layer(date_layer));
		#ifdef PBL_COLOR
			text_layer_set_text_color(date_layer, CfgData.inv ? GColorDarkGray : GColorLightGray);
		#else
			text_layer_set_text_color(date_layer, CfgData.inv ? GColorBlack : GColorWhite);
		#endif
		text_layer_set_background_color(date_layer, CfgData.inv ? GColorWhite : GColorBlack);
#endif		
		if (CfgData.smart)
		{
			layer_add_child(window_layer, bitmap_layer_get_layer(radio_layer));
			layer_add_child(window_layer, bitmap_layer_get_layer(battery_layer));
		}
	}	

	//On Rect later
#if defined(PBL_RECT)
	layer_add_child(window_layer, face_layer);
#endif		

	//Get a time structure so that it doesn't start blank
	time_t temp = time(NULL);
	struct tm *t = localtime(&temp);

	//Manually call the tick handler when the window is loading
	aktHH = t->tm_hour;
	aktMM = t->tm_min;
	handle_tick(t, MINUTE_UNIT);

	//Set Battery state
	BatteryChargeState btchg = battery_state_service_peek();
	battery_state_service_handler(btchg);
	
	//Set Bluetooth state
	bool connected = bluetooth_connection_service_peek();
	bluetooth_connection_handler(connected);
}