Пример #1
0
static void initialise_ui(void) {
  s_window = window_create();
  window_set_fullscreen(s_window, true);
  
  s_res_bitham_30_black = fonts_get_system_font(FONT_KEY_BITHAM_30_BLACK);
  s_res_image_01d = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_01d);
  s_res_image_02d = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_02d);
  s_res_image_03d = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_03d);
  // s_textlayer_time
  s_textlayer_time = text_layer_create(GRect(44, 133, 100, 35));
  text_layer_set_text(s_textlayer_time, "22:00");
  text_layer_set_text_alignment(s_textlayer_time, GTextAlignmentCenter);
  text_layer_set_font(s_textlayer_time, s_res_bitham_30_black);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_time);
  
  // s_textlayer_date
  s_textlayer_date = text_layer_create(GRect(22, 117, 120, 15));
  text_layer_set_text(s_textlayer_date, "23 Mar, 22°, 14kn, NW");
  text_layer_set_text_alignment(s_textlayer_date, GTextAlignmentRight);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_date);
  
  // s_condition_day1
  s_condition_day1 = bitmap_layer_create(GRect(0, 128, 40, 40));
  bitmap_layer_set_bitmap(s_condition_day1, s_res_image_01d);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_condition_day1);
  
  // s_condition_day2
  s_condition_day2 = bitmap_layer_create(GRect(0, 70, 40, 40));
  bitmap_layer_set_bitmap(s_condition_day2, s_res_image_02d);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_condition_day2);
  
  // s_condition_day3
  s_condition_day3 = bitmap_layer_create(GRect(0, 15, 40, 40));
  bitmap_layer_set_bitmap(s_condition_day3, s_res_image_03d);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_condition_day3);
  
  // s_bitmaplayer_4
  s_bitmaplayer_4 = bitmap_layer_create(GRect(0, 60, 144, 2));
  bitmap_layer_set_background_color(s_bitmaplayer_4, GColorBlack);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_bitmaplayer_4);
  
  // s_bitmaplayer_1
  s_bitmaplayer_1 = bitmap_layer_create(GRect(0, 110, 144, 2));
  bitmap_layer_set_background_color(s_bitmaplayer_1, GColorBlack);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_bitmaplayer_1);
  
  // s_textlayer_day3
  s_textlayer_day3 = text_layer_create(GRect(62, 25, 80, 15));
  text_layer_set_text(s_textlayer_day3, "22°, 14kn, NW");
  text_layer_set_text_alignment(s_textlayer_day3, GTextAlignmentRight);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_day3);
  
  // s_textlayer_day2
  s_textlayer_day2 = text_layer_create(GRect(62, 80, 80, 15));
  text_layer_set_text(s_textlayer_day2, "22°, 14kn, NW");
  text_layer_set_text_alignment(s_textlayer_day2, GTextAlignmentRight);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_day2);
}
Пример #2
0
static void window_load(Window *window) {

    Loading = 1;

    Layer *window_layer = window_get_root_layer(window);
    GRect bounds = layer_get_bounds(window_layer);

    image_layer = bitmap_layer_create(bounds);
    bitmap_layer_set_alignment(image_layer, GAlignTop);
	#ifdef PBL_COLOR
	    bitmap_layer_set_background_color(image_layer, TRMainColor);
    #else
    	bitmap_layer_set_background_color(image_layer, GColorBlack);
    #endif

	// display initial app graphic
	#ifdef PBL_COLOR
		image = gbitmap_create_with_resource(RESOURCE_ID_INIT_B);
	#else
		image = gbitmap_create_with_resource(RESOURCE_ID_INIT_A);
	#endif
	bitmap_layer_set_bitmap(image_layer, image);
	layer_add_child(window_layer, bitmap_layer_get_layer(image_layer));

    message_text_layer = text_layer_create(GRect(0, bounds.size.h - 160, bounds.size.w, bounds.size.h));
    text_layer_set_text(message_text_layer, "Loading...");
    text_layer_set_font(message_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
    text_layer_set_text_alignment(message_text_layer, GTextAlignmentCenter);
	text_layer_set_overflow_mode(message_text_layer, GTextOverflowModeWordWrap);
    #ifdef PBL_COLOR
        text_layer_set_text_color(message_text_layer, GColorBlack);
    #else
        text_layer_set_text_color(message_text_layer, GColorWhite);
    #endif
    text_layer_set_background_color(message_text_layer, GColorClear);
    layer_add_child(window_layer, text_layer_get_layer(message_text_layer));

    error_text_layer = text_layer_create(GRect(0, bounds.size.h - 148, bounds.size.w, 80));
    text_layer_set_text(error_text_layer, "");
    text_layer_set_font(error_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
    text_layer_set_text_alignment(error_text_layer, GTextAlignmentCenter);
    text_layer_set_text_color(error_text_layer, GColorWhite);
    text_layer_set_background_color(error_text_layer, GColorClear);
    layer_add_child(window_layer, text_layer_get_layer(error_text_layer));

    username_text_layer = text_layer_create(GRect(0, bounds.size.h - 25, bounds.size.w, 25));
    text_layer_set_text(username_text_layer, "");
    text_layer_set_font(username_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
    text_layer_set_text_alignment(username_text_layer, GTextAlignmentLeft);
	text_layer_set_background_color(username_text_layer, GColorClear);
	#ifdef PBL_COLOR
	    text_layer_set_text_color(username_text_layer, TRAltColor);
    #else
    	text_layer_set_text_color(username_text_layer, GColorBlack);
    #endif
    layer_add_child(window_layer, text_layer_get_layer(username_text_layer));
}
Пример #3
0
static void do_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);

	/* Background */
	Anonymous = gbitmap_create_with_resource(RESOURCE_ID_BG_ANONYMOUS);
	Anonymous_Layer = bitmap_layer_create(GRect(0, 0, WIDTH, HEIGHT));
	bitmap_layer_set_background_color(Anonymous_Layer, GColorBlack);
	bitmap_layer_set_bitmap(Anonymous_Layer, Anonymous);
	layer_add_child(root_layer, bitmap_layer_get_layer(Anonymous_Layer));

	/* Time block */
	time_layer = text_layer_create(GRect(0, 52, frame.size.w, 34));
	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_GOTHIC_28_BOLD ));
	text_layer_set_text_alignment(time_layer, GTextAlignmentCenter);

	/* Bluetooth block */
	bt_connected = gbitmap_create_with_resource(RESOURCE_ID_BT_DISCONNECTED);
	bt_connected_layer = bitmap_layer_create(GRect(WIDTH - ICON_WIDTH, 1, ICON_WIDTH, ICON_HEIGHT));
	bitmap_layer_set_background_color(bt_connected_layer, GColorBlack);
	layer_add_child(root_layer, bitmap_layer_get_layer(bt_connected_layer));

	/* Battery block */
	battery_layer = text_layer_create(GRect(2, -2, frame.size.w, 16 ));
	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, GTextAlignmentLeft);
	text_layer_set_text(battery_layer, "100% charged");

	/* Init blocks */
	time_t now = time(NULL);
	struct tm *current_time = localtime(&now);
	handle_second_tick(current_time, SECOND_UNIT);

	tick_timer_service_subscribe(SECOND_UNIT, &handle_second_tick);
	battery_state_service_subscribe(&handle_battery);

	bool connected = bluetooth_connection_service_peek();
	handle_bluetooth(connected);
	bluetooth_connection_service_subscribe(&handle_bluetooth);

	layer_add_child(root_layer, text_layer_get_layer(time_layer));
	layer_add_child(root_layer, text_layer_get_layer(battery_layer));
}
Пример #4
0
static void main_window_load(Window *window) {
  // Get information about the Window
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);
  
  // Set background
  if(watch_info_get_model() != WATCH_INFO_MODEL_PEBBLE_ORIGINAL && watch_info_get_model() != WATCH_INFO_MODEL_PEBBLE_STEEL) {
    bg_grass = gbitmap_create_with_resource(RESOURCE_ID_BG_GRASS);
    background_image = bitmap_layer_create(bounds);
    bitmap_layer_set_bitmap(background_image, bg_grass);
    layer_add_child(window_layer, bitmap_layer_get_layer(background_image));
  }
  
  // Create GBitmaps
  num0 = gbitmap_create_with_resource(RESOURCE_ID_NUM_0);
  num1left = gbitmap_create_with_resource(RESOURCE_ID_NUM_1_LEFT);
  num1right = gbitmap_create_with_resource(RESOURCE_ID_NUM_1_RIGHT);
  num2 = gbitmap_create_with_resource(RESOURCE_ID_NUM_2);
  num3 = gbitmap_create_with_resource(RESOURCE_ID_NUM_3);
  num4 = gbitmap_create_with_resource(RESOURCE_ID_NUM_4);
  num5 = gbitmap_create_with_resource(RESOURCE_ID_NUM_5);
  num6 = gbitmap_create_with_resource(RESOURCE_ID_NUM_6);
  num7 = gbitmap_create_with_resource(RESOURCE_ID_NUM_7);
  num8 = gbitmap_create_with_resource(RESOURCE_ID_NUM_8);
  num9 = gbitmap_create_with_resource(RESOURCE_ID_NUM_9);
  
  // Create BitmapLayers
  topleft_image = bitmap_layer_create(GRect(7, 5, 64, 76));
  topright_image = bitmap_layer_create(GRect(71, 5, 64, 76));
  bottomleft_image = bitmap_layer_create(GRect(7, 86, 64, 76));
  bottomright_image = bitmap_layer_create(GRect(71, 86, 64, 76));

  // Set transparency
  bitmap_layer_set_background_color(topleft_image, GColorClear);
  bitmap_layer_set_background_color(topright_image, GColorClear);
  bitmap_layer_set_background_color(bottomleft_image, GColorClear);
  bitmap_layer_set_background_color(bottomright_image, GColorClear);
  
  bitmap_layer_set_compositing_mode(topleft_image, GCompOpSet);
  bitmap_layer_set_compositing_mode(topright_image, GCompOpSet);
  bitmap_layer_set_compositing_mode(bottomleft_image, GCompOpSet);
  bitmap_layer_set_compositing_mode(bottomright_image, GCompOpSet);

  // Add BitmapLayers as child layers to the Window's root layer
  layer_add_child(window_layer, bitmap_layer_get_layer(topleft_image));
  layer_add_child(window_layer, bitmap_layer_get_layer(topright_image));
  layer_add_child(window_layer, bitmap_layer_get_layer(bottomleft_image));
  layer_add_child(window_layer, bitmap_layer_get_layer(bottomright_image));
}
Пример #5
0
static void create_logo_layer(Window *window) {
	GRect logoBounds = logo_image->bounds;

	notification_layer = layer_create(GRect(0, bounds.size.h - logoBounds.size.h, bounds.size.w, logoBounds.size.h));
	layer_add_child(window_get_root_layer(window), notification_layer);

	// display logo
	logo_layer = bitmap_layer_create(GRect(3, 0, bounds.size.w, logoBounds.size.h));
	bitmap_layer_set_background_color(logo_layer, GColorWhite);
	bitmap_layer_set_alignment(logo_layer, GAlignTopLeft);
	bitmap_layer_set_bitmap(logo_layer, logo_image);
	layer_add_child(notification_layer, bitmap_layer_get_layer(logo_layer));

	// display notofications
	int offset = 4;
	notification_text_layer = text_layer_create(GRect(logoBounds.size.w + 7, offset, bounds.size.w - logoBounds.size.w - 7, logoBounds.size.h - offset));
	//text_layer_set_background_color(notification_text_layer, GColorClear);
	text_layer_set_font(notification_text_layer, statusFont);
	text_layer_set_text_alignment(notification_text_layer, GTextAlignmentLeft);
	text_layer_set_overflow_mode(notification_text_layer, GTextOverflowModeTrailingEllipsis);
	//text_layer_set_text(notification_text_layer, "noti");
	layer_add_child(notification_layer, text_layer_get_layer(notification_text_layer));

	// hide notification bar for state item, show for other items
	layer_set_hidden(notification_layer, (current_item == 0 ? true : false));
}
Пример #6
0
// static void dayLayerUpdate(struct Layer *layer, GContext *ctx){
//  printf("Day layer update proc\n");
// }
static void main_window_load(Window *window){
//  Layer *layer;
    
  // Create GBitmap, then set to created BitmapLayer
  s_crow_bitmap = gbitmap_create_with_resource(RESOURCE_ID_CROW);
  s_background_layer = bitmap_layer_create(GRect(0, 0, 144, 168));
  bitmap_layer_set_bitmap(s_background_layer, s_crow_bitmap);
  bitmap_layer_set_background_color(s_background_layer, GColorClear);

  // Create time TextLayer
  s_time_layer = text_layer_create(GRect(0, 38, 144, 37));
  text_layer_set_background_color(s_time_layer, GColorWhite);
  text_layer_set_text_color(s_time_layer, GColorBlack);
 
  s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_DOS_FONT_36));
  text_layer_set_font(s_time_layer, s_time_font);
  text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);

   // Create day TextLayer
   s_day_layer = text_layer_create(GRect(0, 76, 144, 37));
   text_layer_set_background_color(s_day_layer, GColorWhite);
   text_layer_set_text_color(s_day_layer, GColorBlack);
 
   text_layer_set_font(s_day_layer, s_time_font);
   text_layer_set_text_alignment(s_day_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));
   layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_day_layer));
   layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(s_background_layer));
//   layer = bitmap_layer_get_layer(s_background_layer);
   layer_set_update_proc(bitmap_layer_get_layer(s_background_layer), bitmapLayerUpdate);
//   layer_set_update_proc(text_layer_get_layer(s_day_layer), dayLayerUpdate);
}
static void updateChecklistDisplayOutput() {
	// Updates the display output layers with the current checklist ordering and status
	// As the process steps sequentially through the number of items, do everything together
	strcpy(globalBuffer, "");
#ifdef PBL_PLATFORM_CHALK
    strcpy(globalBufferRoundDisp, "\n");
#endif
	int displayNumber = 0;
	int itemNumber = 0;
	for (displayNumber = 0; displayNumber < numItems; displayNumber++) {
		itemNumber = checklistOrderArr[displayNumber];		// For the display number, get the item number
		// Update text
		strcat(globalBuffer, checklistItems[itemNumber]);
		strcat(globalBuffer, "\n");
		// Update check icon
		bitmap_layer_set_background_color(s_checkIcons_layers[displayNumber], GColorWhite);
		if (checklistStatusArr[itemNumber] == 0) {
			bitmap_layer_set_bitmap(s_checkIcons_layers[displayNumber], s_uncheckedIcon_unselected);		// Unchecked
		} else {
			bitmap_layer_set_bitmap(s_checkIcons_layers[displayNumber], s_checkedIcon_unselected);		// Checked
		}
	}
	//APP_LOG(APP_LOG_LEVEL_INFO, "Current heap usage: %d", (int)heap_bytes_used());
#ifdef PBL_PLATFORM_CHALK
	strcat(globalBufferRoundDisp, globalBuffer);
#endif
}
Пример #8
0
// Initialise UI
static void init(void)
{
	srand(time(NULL));
	inverter_timer 	= app_timer_register(INVERTER_TIMEOUT, inverter_timer_callback, 0);
	time_timer 			= app_timer_register(TIME_TIMEOUT, update_time, 0);
	
  window 					= window_create();
	
	window_set_fullscreen(window, true);
  window_stack_push(window, false);
	
	// Assign resources
  s_res_tv_image 				= gbitmap_create_with_resource(RESOURCE_ID_TV_IMAGE);
  s_res_static_1_image 	= gbitmap_create_with_resource(RESOURCE_ID_STATIC_2_IMAGE);
	s_res_bitham_42_bold 	= fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD);
	s_res_gothic_14 			= fonts_get_system_font(FONT_KEY_GOTHIC_14);
		
	// tv_bitmap
	tv_bitmap = bitmap_layer_create(GRect(0,0,144,168));
	bitmap_layer_set_bitmap(tv_bitmap, s_res_tv_image);
	bitmap_layer_set_background_color(tv_bitmap, GColorClear);
	bitmap_layer_set_compositing_mode(tv_bitmap, GCompOpAssign);
	layer_add_child(window_get_root_layer(window), (Layer *) tv_bitmap);
	
  // static_1_bitmap
  static_1_bitmap = bitmap_layer_create(GRect(14, 42, 115, 87));
  bitmap_layer_set_bitmap(static_1_bitmap, s_res_static_1_image);
	bitmap_layer_set_compositing_mode(static_1_bitmap, GCompOpOr);
  layer_add_child(window_get_root_layer(window), (Layer *)static_1_bitmap);
  
  // inverter_layer
  static_inverter_layer = inverter_layer_create(GRect(14, 42, 115, 0));
  layer_add_child(window_get_root_layer(window), (Layer *)static_inverter_layer);
	layer_set_hidden(inverter_layer_get_layer(static_inverter_layer), false);
	
	// Screen On layer
  screen_on_layer = text_layer_create(GRect(14, 42, 115, 87));
  text_layer_set_background_color(screen_on_layer, GColorWhite);
  layer_set_hidden(text_layer_get_layer(screen_on_layer), true);
	layer_add_child(window_get_root_layer(window), text_layer_get_layer(screen_on_layer));
	
	// ch_layer
	ch_layer = text_layer_create(GRect(102, 46, 24, 14));
	text_layer_set_background_color(ch_layer, GColorClear);
	text_layer_set_text(ch_layer, "Ch 3");
	text_layer_set_font(ch_layer, s_res_gothic_14);
	layer_add_child(window_get_root_layer(window), text_layer_get_layer(ch_layer));
	
  // time_layer
	clock_copy_time_string(buffer, 12);
  time_layer = text_layer_create(GRect(0, 56, 144, 42));
  text_layer_set_background_color(time_layer, GColorClear);
  text_layer_set_text(time_layer, buffer);
  text_layer_set_text_alignment(time_layer, GTextAlignmentCenter);
  text_layer_set_font(time_layer, s_res_bitham_42_bold);
	layer_set_hidden(text_layer_get_layer(time_layer), true);
  layer_add_child(window_get_root_layer(window), (Layer *)time_layer);
	
	accel_tap_service_subscribe(tap_handler); // Subcribe to the tap event service
}
static void typicalIconLayerCreate(uint8_t layerNumber) {
	// A lot is assumed here, could be a source of problems
	s_checkIcons_layers[layerNumber] = bitmap_layer_create(GRect(0, CHECK_ICON_START + PBL_IF_RECT_ELSE(layerNumber, layerNumber + 1) * CHECK_ICON_HEIGHT, CHECK_ICON_HEIGHT, CHECK_ICON_HEIGHT));
	bitmap_layer_set_background_color(s_checkIcons_layers[layerNumber], GColorWhite);
	bitmap_layer_set_alignment(s_checkIcons_layers[layerNumber], GAlignCenter);
	scroll_layer_add_child(s_checklist_scroll, bitmap_layer_get_layer(s_checkIcons_layers[layerNumber]));		// Adds the root layer to the window
}
Пример #10
0
static void main_window_load(Window *window) {
  // Get information about the Window
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);

  // Create the TextLayer with specific bounds
  s_time_layer = text_layer_create(
      GRect(PBL_IF_ROUND_ELSE(32, 28), PBL_IF_ROUND_ELSE(65, 60), bounds.size.w, 60));
  
  // Improve the layout to be more like a watchface
  text_layer_set_background_color(s_time_layer, GColorClear);
  text_layer_set_text_color(s_time_layer, GColorWhite);
  text_layer_set_text(s_time_layer, "00:00");
  text_layer_set_font(s_time_layer, fonts_get_system_font(PBL_IF_ROUND_ELSE(FONT_KEY_LECO_32_BOLD_NUMBERS, FONT_KEY_LECO_26_BOLD_NUMBERS_AM_PM)));
  text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);
  

  
  // Add to Window 
  s_bitmap = gbitmap_create_with_resource(PBL_IF_ROUND_ELSE(RESOURCE_ID_TORI, RESOURCE_ID_TORIS));
  s_bitmap_layer = bitmap_layer_create(bounds);
  bitmap_layer_set_background_color(s_bitmap_layer, GColorTiffanyBlue);
  bitmap_layer_set_bitmap(s_bitmap_layer, s_bitmap);
  bitmap_layer_set_compositing_mode(s_bitmap_layer, GCompOpSet);
  layer_add_child(window_layer, bitmap_layer_get_layer(s_bitmap_layer));
  
  
  // Add it as a child layer to the Window's root layer
  layer_add_child(window_layer, text_layer_get_layer(s_time_layer));

}
Пример #11
0
static void highlightChecklistItem(uint16_t checkListNumber) {
	// The idea here is to highlight the checklist number check icon layer, and unhighlight the above and below one.
	int i = checklistOrderArr[checkListNumber];		// Get the checklist item number
	int iAbove = checklistOrderArr[checkListNumber + 1];
	int iBelow = checklistOrderArr[checkListNumber - 1];
	if (numItems != 1) {		// The differing highlighting only will occur when there is more than one item.
		if (checkListNumber == 0) {
			// The top selection has to be treated differently
			if (checklistStatusArr[iAbove] == 0) {
				bitmap_layer_set_bitmap(s_checkIcons_layers[checkListNumber + 1], s_uncheckedIcon_unselected);
			} else {
				bitmap_layer_set_bitmap(s_checkIcons_layers[checkListNumber + 1], s_checkedIcon_unselected);
			}
			bitmap_layer_set_background_color(s_checkIcons_layers[checkListNumber + 1], GColorWhite);		// Set layer below as white/unselected
		} else if (checkListNumber == (numItems - 1)) {
			// The bottom selection has to be treated differently
			if (checklistStatusArr[iBelow] == 0) {
				bitmap_layer_set_bitmap(s_checkIcons_layers[checkListNumber - 1], s_uncheckedIcon_unselected);
			} else {
				bitmap_layer_set_bitmap(s_checkIcons_layers[checkListNumber - 1], s_checkedIcon_unselected);
			}
			bitmap_layer_set_background_color(s_checkIcons_layers[checkListNumber - 1], GColorWhite);		// Set layer above as white/unselected
		} else {
			if (checklistStatusArr[iBelow] == 0) {
				bitmap_layer_set_bitmap(s_checkIcons_layers[checkListNumber - 1], s_uncheckedIcon_unselected);
			} else {
				bitmap_layer_set_bitmap(s_checkIcons_layers[checkListNumber - 1], s_checkedIcon_unselected);
			}
			if (checklistStatusArr[iAbove] == 0) {
				bitmap_layer_set_bitmap(s_checkIcons_layers[checkListNumber + 1], s_uncheckedIcon_unselected);
			} else {
				bitmap_layer_set_bitmap(s_checkIcons_layers[checkListNumber + 1], s_checkedIcon_unselected);
			}
			bitmap_layer_set_background_color(s_checkIcons_layers[checkListNumber - 1], GColorWhite);		// Set layer above as white/unselected
			bitmap_layer_set_background_color(s_checkIcons_layers[checkListNumber + 1], GColorWhite);		// Set layer below as white/unselected
		}
	}
	// Highlight the layer
	bitmap_layer_set_background_color(s_checkIcons_layers[checkListNumber], GColorBlack);		// Set layer as black and selected
	if (checklistStatusArr[i] == 0) {
			bitmap_layer_set_bitmap(s_checkIcons_layers[checkListNumber], s_uncheckedIcon_selected);
		} else {
			bitmap_layer_set_bitmap(s_checkIcons_layers[checkListNumber], s_checkedIcon_selected);
		}
}
static void window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);

  s_icon_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_ICONO_PRINCIPAL);
  GRect bitmap_bounds = gbitmap_get_bounds(s_icon_bitmap);


  s_fondo_layer = bitmap_layer_create(GRect(0, 0, 144, 40));
  bitmap_layer_set_background_color(s_fondo_layer, COLOR_CABECERA);
  layer_add_child(window_layer, bitmap_layer_get_layer(s_fondo_layer));



  s_scroll_layer = scroll_layer_create(GRect(10, 10 + bitmap_bounds.size.h + 5, 124, 168 - (10 + bitmap_bounds.size.h + 10)));
  scroll_layer_set_click_config_onto_window(s_scroll_layer, window);
  
  GRect bounds = layer_get_frame(window_layer);
  GRect max_text_bounds = GRect(0, 0, 120, 2000);
  s_label_layer = text_layer_create(max_text_bounds);
  text_layer_set_text(s_label_layer, i_lineas);
  text_layer_set_text_color(s_label_layer, COLOR_TEXTO_CUERPO);  
  text_layer_set_background_color(s_label_layer, GColorClear);
  if (i_total_lineas> 3)
    text_layer_set_font(s_label_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
  else
    text_layer_set_font(s_label_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28));
    
  //layer_add_child(window_layer, text_layer_get_layer(s_label_layer));
  
  
  
    // Trim text layer and scroll content to fit text box
  GSize max_size = text_layer_get_content_size(s_label_layer);
  text_layer_set_size(s_label_layer, max_size);
  scroll_layer_set_content_size(s_scroll_layer, GSize(bounds.size.w, max_size.h + 4));
  scroll_layer_set_shadow_hidden(s_scroll_layer, true);
  scroll_layer_add_child(s_scroll_layer, text_layer_get_layer(s_label_layer));
  layer_add_child(window_layer, scroll_layer_get_layer(s_scroll_layer));

  // CAPA DE LA PARADA
  s_titulo_layer = text_layer_create(GRect(38, 0 , 101, 40));
  text_layer_set_text(s_titulo_layer, string_parada);
  text_layer_set_background_color(s_titulo_layer, GColorClear );
  text_layer_set_text_color(s_titulo_layer, COLOR_TEXTO_CABECERA );
  text_layer_set_text_alignment(s_titulo_layer, GTextAlignmentCenter);
  text_layer_set_font(s_titulo_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
  layer_add_child(window_layer, text_layer_get_layer(s_titulo_layer));
  // FIN DE CAPA DE LA PARADA
  
  // CAPA DEL ICONO DEL BUS
  s_icon_layer = bitmap_layer_create(GRect(5, 5, bitmap_bounds.size.w, bitmap_bounds.size.h));
  bitmap_layer_set_bitmap(s_icon_layer, s_icon_bitmap);
  layer_add_child(window_layer, bitmap_layer_get_layer(s_icon_layer));
  // FIN DE LA CAPA
}
Пример #13
0
static void do_init(void) {
	window = window_create();
	window_stack_push(window, true);
	window_set_background_color(window, GColorBlack);
	window_layer = window_get_root_layer(window);
	
	GRect line_frame = GRect(8, 120, 139, 2);
	line_layer = layer_create(line_frame);
	layer_set_update_proc(line_layer, draw_line);
	layer_add_child(window_layer, line_layer);
	
	time_layer = text_layer_create(GRect(5, 66, 118, 70));
	text_layer_set_text_color(time_layer, GColorWhite);
	text_layer_set_background_color(time_layer, GColorClear);
	text_layer_set_font(time_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_font_droid_44)));
	text_layer_set_text_alignment(time_layer,GTextAlignmentRight);
	layer_add_child(window_layer, text_layer_get_layer(time_layer));
	
	date_layer = text_layer_create(GRect(65, 125, 79, 25));
	text_layer_set_text_color(date_layer, GColorWhite);
	text_layer_set_background_color(date_layer, GColorClear);
	text_layer_set_font(date_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_font_droid_18)));
	layer_add_child(window_layer, text_layer_get_layer(date_layer));
	
	wday_layer = text_layer_create(GRect(60, 143, 50, 25));
	text_layer_set_text_color(wday_layer, GColorWhite);
	text_layer_set_background_color(wday_layer, GColorClear);
	text_layer_set_font(wday_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_font_droid_18)));
	layer_add_child(window_layer, text_layer_get_layer(wday_layer));
	
	//+時間のNULL回避?(わかってない→調べる
	
	time_t now = time(NULL);
	struct tm *current_time = localtime(&now);
	handle_time_tick(current_time, SECOND_UNIT);
	
	tick_timer_service_subscribe(SECOND_UNIT, &handle_time_tick);

	batt_layer = bitmap_layer_create(GRect(123, 151, 14, 10));
	layer_add_child(window_layer, bitmap_layer_get_layer(batt_layer)); //親レイヤに載せる 
	
	watchicon_layer = bitmap_layer_create(GRect(131, 151, 6, 10));
	layer_add_child(window_layer, bitmap_layer_get_layer(watchicon_layer));
	bitmap_layer_set_background_color(watchicon_layer, GColorClear);
	
	bt_layer = bitmap_layer_create(GRect(110, 151, 11, 10));
	layer_add_child(window_layer, bitmap_layer_get_layer(bt_layer));
	
	handle_battery(battery_state_service_peek());
	battery_state_service_subscribe(&handle_battery);

	handle_bluetooth(bluetooth_connection_service_peek());
	bluetooth_connection_service_subscribe(&handle_bluetooth);
}
Пример #14
0
void common_create_h_icon( BitmapLayer** bitmap_layer, Window* window )
{
    GBitmap* h_icon = gbitmap_create_with_resource( RESOURCE_ID_ICON_H );
    *bitmap_layer = bitmap_layer_create( GRect( 3, 3, 18, 18 ) );
    bitmap_layer_set_compositing_mode( *bitmap_layer, GCompOpSet );
    bitmap_layer_set_background_color( *bitmap_layer, GColorClear );
    bitmap_layer_set_bitmap( *bitmap_layer, h_icon );
  
    layer_add_child( window_get_root_layer( window ), bitmap_layer_get_layer( *bitmap_layer ) );
    layer_set_update_proc( window_get_root_layer ( window ), update_proc );    
}
Пример #15
0
void show_loading() {
	Layer *window_layer = window_get_root_layer(window[current_level]);
	if (refresh_layer == NULL) {
		refresh_layer = bitmap_layer_create(layer_get_bounds(window_layer));
		refresh_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_REFRESH);
		bitmap_layer_set_alignment(refresh_layer, GAlignCenter);
		bitmap_layer_set_background_color(refresh_layer, GColorClear);
		bitmap_layer_set_bitmap(refresh_layer, refresh_bitmap);
	}
	layer_set_hidden(bitmap_layer_get_layer(refresh_layer), false);
	layer_add_child(window_layer, bitmap_layer_get_layer(refresh_layer));
}
Пример #16
0
void window_load(Window *window)
{
        //Background Layer
		background_img = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BG);
        bg_layer = bitmap_layer_create(GRect(0, 0, 144, 168));
        bitmap_layer_set_background_color(bg_layer, GColorBlack);
        bitmap_layer_set_bitmap(bg_layer, background_img);
        layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(bg_layer));
	
		//Time layer
        time_layer = text_layer_create(GRect(0, 0, 144, 62));
        text_layer_set_background_color(time_layer, GColorClear);
        text_layer_set_text_color(time_layer, GColorWhite);
        text_layer_set_text_alignment(time_layer, GTextAlignmentCenter);
        text_layer_set_font(time_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD));
        layer_add_child(window_get_root_layer(window), (Layer*) time_layer);
			
		// doge_price_layer
		doge_price_layer = text_layer_create(GRect(0, 65, 144, 50));
		text_layer_set_text_color(doge_price_layer, GColorWhite);
		text_layer_set_background_color(doge_price_layer, GColorClear);
		text_layer_set_font(doge_price_layer, fonts_get_system_font(FONT_KEY_BITHAM_30_BLACK));
		text_layer_set_text_alignment(doge_price_layer, GTextAlignmentCenter);
		
		// usdk_price_layer
		usdk_price_layer = text_layer_create(GRect(0, 120, 144, 50));
		text_layer_set_text_color(usdk_price_layer, GColorWhite);
		text_layer_set_background_color(usdk_price_layer, GColorClear);
		text_layer_set_font(usdk_price_layer, fonts_get_system_font(FONT_KEY_BITHAM_30_BLACK));
		text_layer_set_text_alignment(usdk_price_layer, GTextAlignmentCenter);
        
        layer_add_child(window_get_root_layer(window), (Layer*) time_layer);
		layer_add_child(window_get_root_layer(window), (Layer*) doge_price_layer);
		layer_add_child(window_get_root_layer(window), (Layer*) usdk_price_layer);

	
	//Get a time structure so that the face doesn't start blank
        struct tm *t;
        time_t temp;        
        temp = time(NULL);        
        t = localtime(&temp);        
        
        //Manually call the tick handler when the window is loading
        tick_handler(t, MINUTE_UNIT);
		
}
Пример #17
0
static void main_window_load(Window *window) {
  // Create GBitmap, then set to created BitmapLayer
  s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_DOCTOR_WHO_LOGO);
  s_background_layer = bitmap_layer_create(GRect(0, 0, 140, 82));
  bitmap_layer_set_bitmap(s_background_layer, s_background_bitmap);
  bitmap_layer_set_background_color(s_background_layer, GColorBlack);
  bitmap_layer_set_compositing_mode(s_background_layer, GCompOpAssignInverted);
    
  // Create time TextLayer
  s_time_layer = text_layer_create(GRect(0, 54, 144, 56));
  text_layer_set_background_color(s_time_layer, GColorClear);
  text_layer_set_text_color(s_time_layer, GColorWhite);
  text_layer_set_text(s_time_layer, "00:00");
   
  // Create date TextLayer  
  s_date_layer = text_layer_create(GRect(0, 110, 144, 30));
  text_layer_set_background_color(s_date_layer, GColorClear);
  text_layer_set_text_color(s_date_layer, GColorWhite);
  text_layer_set_text(s_date_layer, "Thu Aug 23");  

  // Improve the layout to be more like a watchface
  // Create GFont
  s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_DOCTOR_WHO_56));
  s_date_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_DOCTOR_WHO_30));

  // Apply to TextLayer
  text_layer_set_font(s_time_layer, s_time_font);
  text_layer_set_font(s_date_layer, s_date_font);
  text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);
  text_layer_set_text_alignment(s_date_layer, GTextAlignmentCenter);
    
  // Inverter Layer
  inverter_layer = inverter_layer_create(GRect(0,0,144,168));
  layer_add_child(window_get_root_layer(window), inverter_layer_get_layer(inverter_layer));
  

  // Add it as a child layer to the Window's root layer
  layer_add_child(inverter_layer_get_layer(inverter_layer), bitmap_layer_get_layer(s_background_layer));
  layer_add_child(inverter_layer_get_layer(inverter_layer), text_layer_get_layer(s_time_layer));
  layer_add_child(inverter_layer_get_layer(inverter_layer), text_layer_get_layer(s_date_layer));

  //layer_set_hidden(inverter_layer_get_layer(inverter_layer), false);
  // Make sure the time is displayed from the start
  update_time();
}
Пример #18
0
// Show loading screen
static void show_loading_icon(void) {
  Layer *window_layer = window_get_root_layer(s_window);

  GRect bounds = layer_get_frame(window_layer);

  loading_icon_layer = bitmap_layer_create(GRect(0, 0, bounds.size.w, bounds.size.h));
  bitmap_layer_set_background_color(loading_icon_layer, GColorBlack);
  layer_add_child(window_layer, bitmap_layer_get_layer(loading_icon_layer));

  text_layer = text_layer_create(GRect(0, 60, bounds.size.w, 30));
  text_layer_set_text_alignment(text_layer, GTextAlignmentCenter);
  text_layer_set_overflow_mode(text_layer, GTextOverflowModeWordWrap);
  text_layer_set_font(text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
  text_layer_set_background_color(text_layer, GColorBlack);
  text_layer_set_text_color(text_layer, GColorWhite);
  text_layer_set_text(text_layer, "Loading...");
  layer_add_child(window_layer, text_layer_get_layer(text_layer));
}
Пример #19
0
void window_load(Window *window) {	
	// Load Fonts
	font_hour = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_LATO_BLACK_24));
	font_minute = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_LATO_REGULAR_18));
	font_date = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_LATO_REGULAR_12));
	
	// Create Background Layer
	layer_background = bitmap_layer_create(GRect(0, 0, 144, 168));
	bitmap_layer_set_background_color(layer_background, GColorBlack);
	layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(layer_background));
	
	// Create Hours Text Layer
	layer_hour = text_layer_create(GRect(4,42,136,32));
	text_layer_set_background_color(layer_hour, GColorClear);
	text_layer_set_text_color(layer_hour, GColorWhite);
	text_layer_set_text(layer_hour, "mille");
	text_layer_set_font(layer_hour, font_hour);
	text_layer_set_text_alignment(layer_hour, GTextAlignmentRight);
	layer_add_child(window_get_root_layer(window), text_layer_get_layer(layer_hour));
	
	// Create Minutes Text Layer
	layer_minute = text_layer_create(GRect(4,68,136,64));
	text_layer_set_background_color(layer_minute, GColorClear);
	text_layer_set_text_color(layer_minute, GColorWhite);
	text_layer_set_text(layer_minute, "heures moins mille");
	text_layer_set_font(layer_minute, font_minute);
	text_layer_set_text_alignment(layer_minute, GTextAlignmentRight);
	layer_add_child(window_get_root_layer(window), text_layer_get_layer(layer_minute));
	
	// Create Dates Text Layer
	layer_date = text_layer_create(GRect(4,150,136,32));
	text_layer_set_background_color(layer_date, GColorClear);
	text_layer_set_text_color(layer_date, GColorWhite);
	text_layer_set_text(layer_date, "mille movembre");
	text_layer_set_font(layer_date, font_date);
	text_layer_set_text_alignment(layer_date, GTextAlignmentCenter);
	layer_add_child(window_get_root_layer(window), text_layer_get_layer(layer_date));
	
	// Create Battery Layer
	bitmap_battery = gbitmap_create_with_resource(RESOURCE_ID_BATTERY_00);
	layer_battery = bitmap_layer_create(GRect(59, 4, 26, 10));
	bitmap_layer_set_bitmap(layer_battery, bitmap_battery);
	layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(layer_battery));
}
Пример #20
0
static void main_window_load(Window *window){
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);
  GRect weather_bounds = GRect(0,PBL_IF_ROUND_ELSE(115,105), bounds.size.w, 50);

  s_status_bar = text_layer_create(GRect(0, PBL_IF_ROUND_ELSE(18,5), bounds.size.w, 50));
  s_time_layer = text_layer_create(GRect(0, PBL_IF_ROUND_ELSE(43,35), bounds.size.w, 50));

  //Load custom minimal font
  s_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_ROBOTO_REGULAR_DOS_48));
  s_font_small = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_ROBOTO_REGULAR_DOS_12));

  s_weather_bitmap = gbitmap_create_with_resource(getImageId(temperature));
  s_weather_icon = bitmap_layer_create(weather_bounds);

  window_set_background_color(s_main_window, GColorVividCerulean);

  //Set time text layer attributes
  text_layer_set_background_color(s_time_layer, GColorClear);
  text_layer_set_text_color(s_time_layer, GColorWhite);
  text_layer_set_text(s_time_layer, "00:00");
  text_layer_set_font(s_time_layer, s_font);
  text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);

  //Set status bar layer attributes
  text_layer_set_background_color(s_status_bar, GColorClear);
  text_layer_set_text_color(s_status_bar, GColorWhite);
  //text_layer_set_text(s_status_bar, "Battery status");
  text_layer_set_font(s_status_bar, s_font_small);
  text_layer_set_text_alignment(s_status_bar, GTextAlignmentCenter);

  bitmap_layer_set_alignment(s_weather_icon, GAlignCenter);
  bitmap_layer_set_background_color(s_weather_icon, GColorClear);
  bitmap_layer_set_compositing_mode(s_weather_icon, GCompOpSet);

  layer_add_child(window_layer, text_layer_get_layer(s_time_layer));
  layer_add_child(window_layer, text_layer_get_layer(s_status_bar));
  bitmap_layer_set_bitmap(s_weather_icon, s_weather_bitmap);
  layer_add_child(window_layer, bitmap_layer_get_layer(s_weather_icon));

  battery_handler(battery_state_service_peek());
}
Пример #21
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;
	}
}
Пример #22
0
void init() {

    big_bold_font = fonts_get_system_font(FONT_KEY_BITHAM_30_BLACK);
    med_bold_font = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
    small_bold_font = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);
  
    conditions[WEATHER_UNKNOWN] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_UNKNOWN);
    conditions[WEATHER_CLEAR_DAY] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_CLEAR_DAY);
    conditions[WEATHER_CLEAR_NIGHT] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_CLEAR_NIGHT);
    conditions[WEATHER_RAIN] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_RAIN);
    conditions[WEATHER_SNOW] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_SNOW);
//    conditions[WEATHER_SLEET] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_SLEET);
    conditions[WEATHER_WIND] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_WIND);
    conditions[WEATHER_FOG] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_FOG);
    conditions[WEATHER_CLOUDY] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_CLOUDY);
    conditions[WEATHER_PARTLY_CLOUDY_DAY] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_PARTLY_CLOUDY_DAY);
    conditions[WEATHER_PARTLY_CLOUDY_NIGHT] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_PARTLY_CLOUDY_NIGHT);
  
    // Set up main window
    mainwindow = window_create();
    window_set_background_color(mainwindow, GColorBlack);
    window_set_fullscreen(mainwindow, true);
  
    for ( int i = 0; i < MAX_WATCH_FACES; i++) {
  
        // This layer displays the time. 12-hour, 24-hour or how the watch is configured
        watchfaces[i].main_time_layer = text_layer_create(GRect(0, i*56, 144, 32));
        text_layer_set_text(watchfaces[i].main_time_layer, watchfaces[i].time_text);
        text_layer_set_text_color(watchfaces[i].main_time_layer, GColorWhite);
        text_layer_set_background_color(watchfaces[i].main_time_layer, GColorClear);
        text_layer_set_font(watchfaces[i].main_time_layer, big_bold_font);
        text_layer_set_text_alignment(watchfaces[i].main_time_layer, GTextAlignmentCenter);
        layer_add_child(window_get_root_layer(mainwindow), (Layer *)watchfaces[i].main_time_layer);

        // This layer displays the selected time zone city, including GMT offset
        watchfaces[i].main_city_layer = text_layer_create(GRect(0, (i*56)+32, 144, 24));
        text_layer_set_text_color(watchfaces[i].main_city_layer, GColorWhite);
        text_layer_set_background_color(watchfaces[i].main_city_layer, GColorClear);
        text_layer_set_font(watchfaces[i].main_city_layer, small_bold_font);
        text_layer_set_text_alignment(watchfaces[i].main_city_layer, GTextAlignmentCenter);
        layer_add_child(window_get_root_layer(mainwindow), (Layer *)watchfaces[i].main_city_layer);
    
        watchfaces[i].window = window_create();  
        window_set_background_color(watchfaces[i].window, GColorBlack);
        window_set_fullscreen(watchfaces[i].window, true);
        window_set_click_config_provider(watchfaces[i].window,
                                         (ClickConfigProvider) watchface_click_config_provider);

        // This layer displays the time. 12-hour, 24-hour or how the watch is configured
        watchfaces[i].text_time_layer = text_layer_create(GRect(0, 6, 144, 44));
        text_layer_set_text(watchfaces[i].text_time_layer, watchfaces[i].time_text);
        text_layer_set_text_color(watchfaces[i].text_time_layer, GColorWhite);
        text_layer_set_background_color(watchfaces[i].text_time_layer, GColorClear);
        text_layer_set_font(watchfaces[i].text_time_layer, big_bold_font);
        text_layer_set_text_alignment(watchfaces[i].text_time_layer, GTextAlignmentCenter);
        layer_add_child(window_get_root_layer(watchfaces[i].window), (Layer *)watchfaces[i].text_time_layer);
    
        // This layer displays the date
        watchfaces[i].text_date_layer = text_layer_create(GRect(0, 44, 144, 28));
        text_layer_set_text(watchfaces[i].text_date_layer, watchfaces[i].date_text);
        text_layer_set_text_color(watchfaces[i].text_date_layer, GColorWhite);
        text_layer_set_background_color(watchfaces[i].text_date_layer, GColorClear);
        text_layer_set_font(watchfaces[i].text_date_layer, med_bold_font);
        text_layer_set_text_alignment(watchfaces[i].text_date_layer, GTextAlignmentCenter);
        layer_add_child(window_get_root_layer(watchfaces[i].window), (Layer *)watchfaces[i].text_date_layer);
    
        // This layer displays the selected time zone city, including GMT offset
        watchfaces[i].text_city_layer = text_layer_create(GRect(0, 72, 146, 22));
        text_layer_set_text_color(watchfaces[i].text_city_layer, GColorWhite);
        text_layer_set_background_color(watchfaces[i].text_city_layer, GColorClear);
        text_layer_set_font(watchfaces[i].text_city_layer, small_bold_font);
        text_layer_set_text_alignment(watchfaces[i].text_city_layer, GTextAlignmentCenter);
        layer_add_child(window_get_root_layer(watchfaces[i].window), (Layer *)watchfaces[i].text_city_layer);
    
        for ( int j = 0; j < MAX_WEATHER_DAYS; j++ ) {
            // This layer displays a weather image, if available.
            watchfaces[i].bitmap_weather_layer[j] = bitmap_layer_create(GRect(9+(j*(36+9)), 94, 36, 36));
            bitmap_layer_set_background_color(watchfaces[i].bitmap_weather_layer[j], GColorClear);
            bitmap_layer_set_alignment(watchfaces[i].bitmap_weather_layer[j], GAlignCenter);
            bitmap_layer_set_compositing_mode(watchfaces[i].bitmap_weather_layer[j], GCompOpAssignInverted);
            bitmap_layer_set_bitmap(watchfaces[i].bitmap_weather_layer[j], conditions[WEATHER_UNKNOWN]);
            layer_add_child(window_get_root_layer(watchfaces[i].window), (Layer *)watchfaces[i].bitmap_weather_layer[j]);

            // This layer displays the time zone temperature, high and low, below the weather icon
            watchfaces[i].text_temp_layer[j] = text_layer_create(GRect(9+(j*(36+9)), 130, 36, 38));
            text_layer_set_text(watchfaces[i].text_temp_layer[j], watchfaces[i].temps[j]);
            text_layer_set_text_color(watchfaces[i].text_temp_layer[j], GColorWhite);
            text_layer_set_background_color(watchfaces[i].text_temp_layer[j], GColorClear);
            text_layer_set_font(watchfaces[i].text_temp_layer[j], small_bold_font);
            text_layer_set_text_alignment(watchfaces[i].text_temp_layer[j], GTextAlignmentCenter);
            layer_add_child(window_get_root_layer(watchfaces[i].window), (Layer *)watchfaces[i].text_temp_layer[j]);
        }
    }
    Tuplet initial_values[] = {
        TupletInteger(LOCAL_WATCH_OFFSET+PBCOMM_GMT_SEC_OFFSET_KEY, (int32_t) -28800),
        TupletInteger(LOCAL_WATCH_OFFSET+PBCOMM_BACKGROUND_KEY,     (uint8_t) BACKGROUND_SUNS),
        TupletInteger(LOCAL_WATCH_OFFSET+PBCOMM_12_24_DISPLAY_KEY,  (uint8_t) DISPLAY_WATCH_CONFIG_TIME),
        TupletCString(LOCAL_WATCH_OFFSET+PBCOMM_CITY_KEY,                     "Watch Time"),
        TupletBytes(  LOCAL_WATCH_OFFSET+PBCOMM_WEATHER_KEY,        weather,  WEATHER_KEY_LEN),
          
        TupletInteger(TZ1_WATCH_OFFSET+PBCOMM_GMT_SEC_OFFSET_KEY,   (int32_t) 0),
        TupletInteger(TZ1_WATCH_OFFSET+PBCOMM_BACKGROUND_KEY,       (uint8_t) BACKGROUND_SUNS),
        TupletInteger(TZ1_WATCH_OFFSET+PBCOMM_12_24_DISPLAY_KEY,    (uint8_t) DISPLAY_24_HOUR_TIME),
        TupletCString(TZ1_WATCH_OFFSET+PBCOMM_CITY_KEY,                       "London, England"),
        TupletBytes(  TZ1_WATCH_OFFSET+PBCOMM_WEATHER_KEY,          weather,  WEATHER_KEY_LEN),
          
        TupletInteger(TZ2_WATCH_OFFSET+PBCOMM_GMT_SEC_OFFSET_KEY,   (int32_t) 32400),
        TupletInteger(TZ2_WATCH_OFFSET+PBCOMM_BACKGROUND_KEY,       (uint8_t) BACKGROUND_SUNS),
        TupletInteger(TZ2_WATCH_OFFSET+PBCOMM_12_24_DISPLAY_KEY,    (uint8_t) DISPLAY_24_HOUR_TIME),
        TupletCString(TZ2_WATCH_OFFSET+PBCOMM_CITY_KEY,                       "Tokyo, Japan"),
        TupletBytes(  TZ2_WATCH_OFFSET+PBCOMM_WEATHER_KEY,          weather,  WEATHER_KEY_LEN)
    };
    
    // Initialize watchfaces[].time_format as it may be used before sync_tuple_changed_callback
    // is executed to set up the proper value.
    for (int i = 0; i < MAX_WATCH_FACES; i++) {
        strncpy (watchfaces[i].time_format, time_12h_format, sizeof(time_12h_format));
    }
    
    // Initialize status window, but don't populate unless it's requested via tap
    statuswindow = window_create();
    window_set_background_color(statuswindow, GColorBlack);
    window_set_window_handlers(statuswindow, (WindowHandlers) {
        .load = statuswindow_load,
        .unload = statuswindow_unload
    });
Пример #23
0
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);
}
Пример #24
0
static void window_load(Window *window) {
	
	static time_t tm;
	
	window_layer = window_get_root_layer(window);
	
	time_layer = text_layer_create(GRect(0, 0, 144, 55));
	text_layer_set_text_color(time_layer, GColorWhite);
	text_layer_set_background_color(time_layer, GColorBlack);
	text_layer_set_font(time_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FUTURA_CONDENSED_53)));
	text_layer_set_text_alignment(time_layer, GTextAlignmentCenter);
	layer_add_child(window_layer, text_layer_get_layer(time_layer));

	date_layer = text_layer_create(GRect(0, 55, 144, 33));
	text_layer_set_text_color(date_layer, GColorWhite);
	text_layer_set_background_color(date_layer, GColorBlack);
	text_layer_set_font(date_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
	text_layer_set_text_alignment(date_layer, GTextAlignmentCenter);
	layer_add_child(window_layer, text_layer_get_layer(date_layer));
	
	icon_layer = bitmap_layer_create(GRect(0, 88, 60, 60));
	layer_add_child(window_layer, bitmap_layer_get_layer(icon_layer));
	
	temperature_layer = text_layer_create(GRect(61, 88, 83, 60));
	text_layer_set_text_color(temperature_layer, GColorBlack);
	text_layer_set_background_color(temperature_layer, GColorWhite);
	//text_layer_set_font(temperature_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FUTURA_40)));
	text_layer_set_font(temperature_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD));
	text_layer_set_text_alignment(temperature_layer, GTextAlignmentCenter);
	layer_add_child(window_layer, text_layer_get_layer(temperature_layer));
	
	city_layer = text_layer_create(GRect(0, 142, 144, 28));
	text_layer_set_text_color(city_layer, GColorBlack);
	text_layer_set_background_color(city_layer, GColorWhite);
	text_layer_set_font(city_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
//	text_layer_set_font(city_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FUTURA_18)));
	text_layer_set_text_alignment(city_layer, GTextAlignmentLeft);
	layer_add_child(window_layer, text_layer_get_layer(city_layer));

	// Status setup
	icon_battery = gbitmap_create_with_resource(RESOURCE_ID_BATTERY_ICON);
	icon_battery_charge = gbitmap_create_with_resource(RESOURCE_ID_BATTERY_CHARGE);
	icon_bluetooth = 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(0,70,24,12)); //24*12
	layer_set_update_proc(battery_layer, &battery_layer_update_callback);
	layer_add_child(window_layer, battery_layer);
	
	bluetooth_ok = bluetooth_connection_service_peek();
	bluetooth_layer = layer_create(GRect(130,70,9,12)); //9*12
	layer_set_update_proc(bluetooth_layer, &bluetooth_layer_update_callback);
	layer_add_child(window_layer, bluetooth_layer);

	// Initial Weather Display
	//icon_bitmap = gbitmap_create_with_resource(RESOURCE_ID_ICON_CLOUD_ERROR);
	//bitmap_layer_set_bitmap(icon_layer, icon_bitmap);

	// Init notification icons
	icon_refresh = gbitmap_create_with_resource(RESOURCE_ID_REFRESH);
	icon_warning = gbitmap_create_with_resource(RESOURCE_ID_WARNING);
	icon_error = gbitmap_create_with_resource(RESOURCE_ID_ERROR);
	icon_waiting = gbitmap_create_with_resource(RESOURCE_ID_WAITING);
	icon_empty = gbitmap_create_with_resource(RESOURCE_ID_EMPTY);

	// Init notification layer
	notify_layer = bitmap_layer_create(GRect(124, 148, 20, 20));
	bitmap_layer_set_background_color(notify_layer, GColorClear);
	bitmap_layer_set_alignment(notify_layer, GAlignTop);
	layer_add_child(window_layer, bitmap_layer_get_layer(notify_layer));
	
	// Force Refresh time
	handle_tick(localtime(&tm), SECOND_UNIT | MINUTE_UNIT | HOUR_UNIT | DAY_UNIT);
}
Пример #25
0
static void main_window_load(Window *window) {
  
  s_background_layer = bitmap_layer_create(GRect(0, 0, 144, 180));
  bitmap_layer_set_bitmap(s_background_layer, s_background_bitmap);
  layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(s_background_layer));
  

  //time layer
  s_time_layer = text_layer_create(GRect(0, 50, 144, 180));
  bitmap_layer_set_background_color(s_background_layer, GColorBlack);
  text_layer_set_background_color(s_time_layer, GColorBlack);
  text_layer_set_text_color(s_time_layer, GColorWhite);
  
  // Use a system font in a TextLayer
  text_layer_set_font(s_time_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_LIGHT));
  text_layer_set_text(s_time_layer, "00:00");

  // 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 battery meter Layer
  s_battery_layer = layer_create(GRect(5, 10, 100, 10));
  //background_layer_set_background_color(s_background_layer, GColorRed)
  layer_set_update_proc(s_battery_layer, battery_update_proc);

  // Add to Window

	
	
  bitmap_image = gbitmap_create_with_resource(RESOURCE_ID_BATTERY_ICON);
    // This resource is set up to be different for each platform, so it will look good on both Color and Black & White displayer
  
// Set the size of the bitmap layer to the size of the screen, or the "bounds"
  bitmap_layer = bitmap_layer_create(GRect(5, 0, 105, 30));
  
// Put the bitmap image in the bitmap layer
  bitmap_layer_set_bitmap(bitmap_layer, bitmap_image);
  
// Put the image in the center of the screen
  bitmap_layer_set_alignment(bitmap_layer, GAlignLeft);
  bitmap_layer_set_background_color(bitmap_layer, GColorClear);
  
// Set the compositing mode so that transparent images are transparent
  bitmap_layer_set_compositing_mode(bitmap_layer, GCompOpSet);
	
  s_battery_percentage = text_layer_create(GRect(23, 6, 144, 168));
  text_layer_set_background_color(s_battery_percentage, GColorClear);
  text_layer_set_text_color(s_battery_percentage, GColorWhite);
	
  text_layer_set_font(s_battery_percentage, fonts_load_custom_font(
                          resource_get_handle(RESOURCE_ID_GEOSANS_13)));
	
	
  //text_layer_set_text(s_battery_percentage, "");
    
// Add the bitmap layer to the window
 layer_add_child(window_get_root_layer(window), s_battery_layer);
 layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_battery_percentage));
 layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(bitmap_layer));


}
Пример #26
0
/*:
 * Handle window loading.
 */
static void load_cb(Window *window) {

	// Right Margin
	static int m = 4;
	// Font Size
	static int s = 31;
	// First Row Offset
	static int o = 0;
	// Row Top Padding
	static int p = 2;

	// Screen Size
	static int w = 144;
	static int h = 168;

	// Load resources we'll have to destroy later.
	s_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_TARGA_MS_31));

	// NO DESCENDERS FOR YOU
#define make_row(x) text_layer_create(GRect(m, (x - 1) * (s + p) + o, w, s))

	// Window Background
	//
	s_bg_layer = bitmap_layer_create(GRect(0, 0, w, h));
	bitmap_layer_set_background_color(s_bg_layer, GColorBlack);
	layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(s_bg_layer));

	s_cldr_layer = make_row(1);
	text_layer_set_background_color(s_cldr_layer, GColorClear);
	text_layer_set_text_color(s_cldr_layer, theme_tertiary);
	text_layer_set_font(s_cldr_layer, s_font);
	text_layer_set_text_alignment(s_cldr_layer, GTextAlignmentLeft);
	layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_cldr_layer));

	s_date_layer = make_row(2);
	text_layer_set_background_color(s_date_layer, GColorClear);
	text_layer_set_text_color(s_date_layer, theme_secondary);
	text_layer_set_font(s_date_layer, s_font);
	text_layer_set_text_alignment(s_date_layer, GTextAlignmentLeft);
	layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_date_layer));

	s_time_layer = make_row(3);
	text_layer_set_background_color(s_time_layer, GColorClear);
	text_layer_set_text_color(s_time_layer, theme_primary);
	text_layer_set_font(s_time_layer, s_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));

	s_wthr_layer = make_row(4);
	text_layer_set_background_color(s_wthr_layer, GColorClear);
	text_layer_set_text_color(s_wthr_layer, theme_info);
	text_layer_set_font(s_wthr_layer, s_font);
	text_layer_set_text_alignment(s_wthr_layer, GTextAlignmentLeft);
	layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_wthr_layer));

	s_blth_layer = make_row(5);
	text_layer_set_background_color(s_blth_layer, GColorClear);
	text_layer_set_text_color(s_blth_layer, theme_tertiary);
	text_layer_set_font(s_blth_layer, s_font);
	text_layer_set_text_alignment(s_blth_layer, GTextAlignmentLeft);
	layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_blth_layer));

	s_batt_layer = make_row(5);
	text_layer_set_background_color(s_batt_layer, GColorClear);
	text_layer_set_text_color(s_batt_layer, theme_tertiary);
	text_layer_set_font(s_batt_layer, s_font);
	text_layer_set_text_alignment(s_batt_layer, GTextAlignmentLeft);
	layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_batt_layer));

#undef make_row

}
Пример #27
0
/**
 * Window load handler function
 */
static void mainWindowLoad(Window *w)
{
  init_hardware_icons();
  
  // Get information about the root window
  Layer *windowLayer = window_get_root_layer(w);
  GRect bounds = layer_get_bounds(windowLayer);
  
  // Set sleepy time flag
  time_t temp_time = time(NULL);
  struct tm *cur_time = localtime(&temp_time); 
  s_is_sleepy_time = (cur_time->tm_hour <= SLEEPY_TIME_END_HOUR && cur_time->tm_hour >= SLEEPY_TIME_START_HOUR);
  
  //////////////////////////////////////////
  // Battery
  
  GRect bat_icon_bounds = get_battery_icon_bounds();
  
  // Create BitmapLayer to display the GBitmap
  s_powerIconLayer = bitmap_layer_create(GRect(bounds.size.w - (bat_icon_bounds.size.w + 2),
                                               0, bat_icon_bounds.size.w, bat_icon_bounds.size.h));

  // set background colout and compositing mode 
  bitmap_layer_set_background_color(s_powerIconLayer, POWER_ICON_BACK_COLOR);
  bitmap_layer_set_compositing_mode(s_powerIconLayer, GCompOpSet);
  
  update_power_status(battery_state_service_peek());
  
  // add the bitmap layer to the window
  layer_add_child(windowLayer, bitmap_layer_get_layer(s_powerIconLayer));
  
  //////////////////////////////////////////
  // BT connection

  GRect bt_icon_bounds = get_bt_icon_bounds();
  
  // Create BitmapLayer to display the GBitmap
  s_btIconLayer = bitmap_layer_create(GRect(bounds.size.w - (bat_icon_bounds.size.w + bt_icon_bounds.size.w + 4), 4, bt_icon_bounds.size.w, bt_icon_bounds.size.h));

  // set background colout and compositing mode 
  bitmap_layer_set_background_color(s_btIconLayer, BT_ICON_BACK_COLOR);
  bitmap_layer_set_compositing_mode(s_btIconLayer, GCompOpSet);
  
  update_bt_status(connection_service_peek_pebble_app_connection());
  
  // add the bitmap layer to the window
  layer_add_child(windowLayer, bitmap_layer_get_layer(s_btIconLayer));
  
  ////////////////////////////////////
  // Create the time text layers
  
  // time accuracy text layer
  s_timeAccText = text_layer_create(GRect(2, PBL_IF_ROUND_ELSE(-2, -6), 94, 28));
  
  // Improve the layout to be more like a watchface
  text_layer_set_background_color(s_timeAccText, TIME_TEXT_BACK_COLOR);
  text_layer_set_text_color(s_timeAccText, (s_is_sleepy_time ? TIME_TEXT_FORE_COLOR_NIGHT : TIME_TEXT_FORE_COLOR_DAY));
  
  //s_timeFont = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_FFF_TUSJ_42));
  GFont timeFont = fonts_get_system_font(FONT_KEY_GOTHIC_24);
  
  text_layer_set_font(s_timeAccText, timeFont);
  text_layer_set_text_alignment(s_timeAccText, GTextAlignmentLeft);

  // Add it as a child layer to the Window's root layer
  layer_add_child(windowLayer, text_layer_get_layer(s_timeAccText));
    
  // time text layer
  s_timeText = text_layer_create(GRect(2, PBL_IF_ROUND_ELSE(20, 16), bounds.size.w-4, 100));
  
  // Improve the layout to be more like a watchface
  text_layer_set_background_color(s_timeText, TIME_TEXT_BACK_COLOR);
  text_layer_set_text_color(s_timeText, (s_is_sleepy_time ? TIME_TEXT_FORE_COLOR_NIGHT : TIME_TEXT_FORE_COLOR_DAY));

  update_timeish(s_timeText,s_timeAccText);
  
  //s_timeFont = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_FFF_TUSJ_42));
  timeFont = fonts_get_system_font(FONT_KEY_BITHAM_30_BLACK);
  
  text_layer_set_font(s_timeText, timeFont);
  text_layer_set_text_alignment(s_timeText, GTextAlignmentLeft);

  // Add it as a child layer to the Window's root layer
  layer_add_child(windowLayer, text_layer_get_layer(s_timeText));
  
  ///////////////////////////////////
  // Create the date text layer
  s_dateText = text_layer_create(GRect(2, PBL_IF_ROUND_ELSE(128, 122), bounds.size.w-4, 16));
  
   // Improve the layout to be more like a watchface
  text_layer_set_background_color(s_dateText, TIME_TEXT_BACK_COLOR);
  text_layer_set_text_color(s_dateText, (s_is_sleepy_time ? TIME_TEXT_FORE_COLOR_NIGHT : TIME_TEXT_FORE_COLOR_DAY));

  update_date(s_dateText);
  
  //s_dateFont = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_FFF_TUSJ_24));
  GFont dateFont = fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD);
  
  text_layer_set_font(s_dateText, dateFont);
  text_layer_set_text_alignment(s_dateText, GTextAlignmentLeft);

  // Add it as a child layer to the Window's root layer
  layer_add_child(windowLayer, text_layer_get_layer(s_dateText));
  
  //////////////////////////////////
  // Create the weather text layer
  s_weatherText = text_layer_create(GRect(2, PBL_IF_ROUND_ELSE(112, 108), bounds.size.w-4, 18));
  
   // Improve the layout to be more like a watchface
  text_layer_set_background_color(s_weatherText, TIME_TEXT_BACK_COLOR);

  update_weather((Tuple *)NULL,(Tuple *)NULL, (Tuple *)NULL);
  
  GFont weatherFont = fonts_get_system_font(FONT_KEY_GOTHIC_14);
  
  text_layer_set_font(s_weatherText, weatherFont);
  text_layer_set_text_alignment(s_weatherText, GTextAlignmentLeft);
  
  // Set weather text colour
  set_weather_text_colour();

  // Add it as a child layer to the Window's root layer
  layer_add_child(windowLayer, text_layer_get_layer(s_weatherText));
  
  //////////////////////////////////
  // Create the news text layer
  s_newsText = text_layer_create(GRect(2, PBL_IF_ROUND_ELSE(142, 136), bounds.size.w-4, 30));
  
   // Improve the layout to be more like a watchface
  text_layer_set_background_color(s_newsText, TIME_TEXT_BACK_COLOR);
  text_layer_set_text_color(s_newsText, (s_is_sleepy_time ? TIME_TEXT_FORE_COLOR_NIGHT : TIME_TEXT_FORE_COLOR_DAY));

  display_news_weather();
  
  text_layer_set_font(s_newsText, weatherFont);
  text_layer_set_text_alignment(s_newsText, GTextAlignmentLeft);

  // Add it as a child layer to the Window's root layer
  layer_add_child(windowLayer, text_layer_get_layer(s_newsText));
  
}
Пример #28
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);
}
Пример #29
0
static void main_window_load(Window *window) {
  int textStartY = 80;
  int timeWidth = 110;
  
  if(clock_is_24h_style() == true) {
    timeWidth = 134;
  }
  
  // Create time TextLayer
  s_time_layer = text_layer_create(GRect(0, textStartY, timeWidth, 50));
  text_layer_set_background_color(s_time_layer, GColorClear);
  text_layer_set_text_color(s_time_layer, GColorWhite);
  text_layer_set_text(s_time_layer, "00:00");
  text_layer_set_font(s_time_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_MEDIUM_NUMBERS));
  text_layer_set_text_alignment(s_time_layer, GTextAlignmentRight);
  
  
  s_suffix_layer = text_layer_create(GRect(114, textStartY+24, 40, 50));
  text_layer_set_background_color(s_suffix_layer, GColorClear);
  text_layer_set_text_color(s_suffix_layer, GColorWhite);
  text_layer_set_text(s_suffix_layer, "am");
  text_layer_set_font(s_suffix_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
  text_layer_set_text_alignment(s_suffix_layer, GTextAlignmentLeft);
  
  s_date_layer = text_layer_create(GRect(10, textStartY+41, 124, 50));
  text_layer_set_background_color(s_date_layer, GColorClear);
  #ifdef PBL_COLOR
    text_layer_set_text_color(s_date_layer, GColorPictonBlue);
  #else
    text_layer_set_text_color(s_date_layer, GColorWhite);
  #endif
  text_layer_set_text(s_date_layer, "Mon Jan 01");
  text_layer_set_font(s_date_layer, fonts_get_system_font(FONT_KEY_ROBOTO_CONDENSED_21));
  text_layer_set_text_alignment(s_date_layer, GTextAlignmentRight);

  layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_time_layer));
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_suffix_layer));
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_date_layer));
  
  // Battery
  s_battery_container = bitmap_layer_create(GRect(7, 7, 14, 60));
  bitmap_layer_set_background_color(s_battery_container, GColorClear);
  bitmap_layer_set_bitmap(s_battery_container, battery_container_bitmap);
  bitmap_layer_set_compositing_mode(s_battery_container, GCompOpAssign);
  layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer (s_battery_container));
  
  // Battery Pellets
  for(int i=0; i<20; i++) {
    s_battery_pellet[i] = bitmap_layer_create(GRect(11, 9 + (20 - i) * 2, 6, 1));
    bitmap_layer_set_background_color(s_battery_pellet[i], GColorClear);
    bitmap_layer_set_bitmap(s_battery_pellet[i], battery_pellet_bitmap);
    bitmap_layer_set_compositing_mode(s_battery_pellet[i], GCompOpAssign);
    layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer (s_battery_pellet[i]));
  }
  update_battery_status(battery_state_service_peek());
  battery_state_service_subscribe(update_battery_status);
  
  // BT 
  s_bt_icon_layer = bitmap_layer_create(GRect(10, 53, 8, 11));
  bitmap_layer_set_background_color(s_bt_icon_layer, GColorClear);
  bitmap_layer_set_bitmap(s_bt_icon_layer, bt_icon_bitmap);
  #ifdef PBL_COLOR
    bitmap_layer_set_compositing_mode(s_bt_icon_layer, GCompOpSet);
  #else
    bitmap_layer_set_compositing_mode(s_bt_icon_layer, GCompOpAssign);
  #endif
  layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer (s_bt_icon_layer));
  
	bt_status = bluetooth_connection_service_peek();
	bluetooth_connection_service_subscribe( bluetooth_callback );
  
  // Make sure the time is displayed from the start
  update_time();
}
Пример #30
0
static void draw_watchface(Layer *layer, GContext *ctx) {
	GRect bounds = layer_get_bounds(layer);
	uint16_t width = bounds.size.w - (2 * PADDING);
	uint16_t max_height = bounds.size.h - (2 * PADDING);

	//set the colour
	graphics_context_set_fill_color(ctx, COLOR_FALLBACK(GColorRed, GColorWhite));	

	//display the seconds
	graphics_fill_rect(ctx, GRect(((s_sec * width)/60) + PADDING, 84 - 10, 2, 19), 0 ,0);

	//display the hours

	//left hours------------------------------ 
	int8_t cur_hours = s_hour % 12;
	if (cur_hours == 0) {
		cur_hours = 12;
	}

	int8_t left_hours = cur_hours;
	if (cur_hours > 6) {
		left_hours = 6;
	}
	GPathInfo HOURS_LEFT_PATH_INFO = {
		.num_points = 4,
		.points = (GPoint []) {{0,0},{(left_hours*width/12) + 2,0},{(left_hours*width/12) + 2,27},{0,27}}
	};

	GPath *s_hours_path_left = gpath_create(&HOURS_LEFT_PATH_INFO);
	gpath_rotate_to(s_hours_path_left, DEG_TO_TRIGANGLE(-45));
	gpath_move_to(s_hours_path_left, GPoint(3,32 + PADDING));
	gpath_draw_filled(ctx, s_hours_path_left);

	//right hours------------------------------ 
	
	int8_t right_hours = cur_hours;
	if (cur_hours < 6) {
		right_hours = 0;
	} else {
		right_hours = cur_hours - 6;
	}

	GPathInfo HOURS_RIGHT_PATH_INFO = {
		.num_points = 4,
		.points = (GPoint []) {{0,0},{(right_hours*width/12) + 2,0},{(right_hours*width/12) + 2,27},{0,27}}
	};

	GPath *s_hours_path_right = gpath_create(&HOURS_RIGHT_PATH_INFO);
	gpath_rotate_to(s_hours_path_right, DEG_TO_TRIGANGLE(45));
	gpath_move_to(s_hours_path_right, GPoint(width - 32 + 8, 1));
	gpath_draw_filled(ctx, s_hours_path_right);

	//display the minutes
	
	//left minutes------------------------------ 
	int8_t left_mins = s_min;
	if (s_min > 30) {
		left_mins = 30;
	}

	GPathInfo MINS_LEFT_PATH_INFO = {
		.num_points = 4,
		.points = (GPoint []) {{0,0},{(left_mins*width/60) + 1,0},{(left_mins*width/60) + 1, 27},{0,27}}
	};
	
	GPath *s_mins_path_left = gpath_create(&MINS_LEFT_PATH_INFO);
	gpath_rotate_to(s_mins_path_left, DEG_TO_TRIGANGLE(45));
	gpath_move_to(s_mins_path_left, GPoint(PADDING + 10, max_height - 32 - 11));
	gpath_draw_filled(ctx, s_mins_path_left);

	//right minutes------------------------------ 
	int8_t right_mins = s_min;
	if (s_min < 30) {
		right_mins = 0;
	} else {
		right_mins = s_min - 30;
	}

	GPathInfo MINS_RIGHT_PATH_INFO = {
		.num_points = 4,
		.points = (GPoint []) {{0,0},{(right_mins*width/60) + 1,0},{(right_mins*width/60) + 1, 27},{0,27}}
	};

	GPath *s_mins_path_right = gpath_create(&MINS_RIGHT_PATH_INFO);
	gpath_rotate_to(s_mins_path_right, DEG_TO_TRIGANGLE(-45));
	gpath_move_to(s_mins_path_right, GPoint(width - 32 - PADDING + 1, max_height));
	gpath_draw_filled(ctx, s_mins_path_right);
}

static void set_background_color(int color) {
	GColor background_color = GColorFromHEX(color);
	window_set_background_color(window, background_color);
}

static void inbox_received_handler(DictionaryIterator *iter, void *context) {
	APP_LOG(APP_LOG_LEVEL_DEBUG, "inbox received handler");
	Tuple *background_color_t = dict_find(iter, KEY_BACKGROUND_COLOR);

	if (background_color_t) {
		int background_color = background_color_t->value->int32;
		if (background_color == 0) { //quick fix so that black colour persists
			background_color++;
		}
		persist_write_int(KEY_BACKGROUND_COLOR, background_color);
		set_background_color(background_color);

		APP_LOG(APP_LOG_LEVEL_DEBUG, "background color: %d", background_color);
	}
}

static void window_load(Window *window) {
	Layer *window_layer = window_get_root_layer(window);
	GRect bounds = layer_get_bounds(window_layer);

	s_layer = layer_create(layer_get_bounds(window_get_root_layer(window)));
	layer_add_child(window_get_root_layer(window), s_layer);
	layer_set_update_proc(s_layer, draw_watchface);

	uint16_t width = bounds.size.w - (2 * PADDING);
	uint16_t max_height = bounds.size.h - (2 * PADDING);

	//create the ternary seconds image
	s_ternary_seconds_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_SECONDS_TERNARY_REFLECT);
	s_ternary_seconds_layer = bitmap_layer_create(GRect(PADDING, 0, width + 1, 168));
	bitmap_layer_set_background_color(s_ternary_seconds_layer, GColorClear);
	bitmap_layer_set_bitmap(s_ternary_seconds_layer, s_ternary_seconds_bitmap);
	bitmap_layer_set_compositing_mode(s_ternary_seconds_layer, GCompOpSet);
	layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(s_ternary_seconds_layer));

	//create the left hours image
	s_unary_hours_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_6_SINGLE_BLOCKS);
	s_unary_hours_layer_left = rot_bitmap_layer_create(s_unary_hours_bitmap);
	rot_bitmap_layer_set_corner_clip_color(s_unary_hours_layer_left, GColorClear);
	rot_bitmap_set_compositing_mode(s_unary_hours_layer_left, GCompOpSet);
	rot_bitmap_layer_set_angle(s_unary_hours_layer_left, DEG_TO_TRIGANGLE(-45));

	//position the frame
	GRect r = layer_get_frame((Layer *) s_unary_hours_layer_left);
	r.origin.x = 2;
	layer_set_frame((Layer *) s_unary_hours_layer_left, r);
	layer_add_child(window_get_root_layer(window), (Layer *) s_unary_hours_layer_left);

	//create the right hours image
	s_unary_hours_layer_right = rot_bitmap_layer_create(s_unary_hours_bitmap);
	rot_bitmap_layer_set_corner_clip_color(s_unary_hours_layer_right, GColorClear);
	rot_bitmap_set_compositing_mode(s_unary_hours_layer_right, GCompOpSet);
	rot_bitmap_layer_set_angle(s_unary_hours_layer_right, DEG_TO_TRIGANGLE(45));

	//position the frame
	r = layer_get_frame((Layer *) s_unary_hours_layer_right);
	r.origin.x = width - 32 - PADDING; 
	layer_set_frame((Layer *) s_unary_hours_layer_right, r);
	layer_add_child(window_get_root_layer(window), (Layer *) s_unary_hours_layer_right);

	//create the left minutes image
	s_ternary_minutes_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_30_TERNARY);	
	s_ternary_minutes_layer_left = rot_bitmap_layer_create(s_ternary_minutes_bitmap);
	rot_bitmap_layer_set_corner_clip_color(s_ternary_minutes_layer_left, GColorClear);
	rot_bitmap_set_compositing_mode(s_ternary_minutes_layer_left, GCompOpSet);
	rot_bitmap_layer_set_angle(s_ternary_minutes_layer_left, DEG_TO_TRIGANGLE(45));

	//position the frame
	r = layer_get_frame((Layer *) s_ternary_minutes_layer_left);
	r.origin.x = 2;
	r.origin.y = max_height - 32 - PADDING;
	layer_set_frame((Layer *) s_ternary_minutes_layer_left, r);
	layer_add_child(window_get_root_layer(window), (Layer *) s_ternary_minutes_layer_left);

	//create the right minutes image
	s_ternary_minutes_layer_right = rot_bitmap_layer_create(s_ternary_minutes_bitmap);
	rot_bitmap_layer_set_corner_clip_color(s_ternary_minutes_layer_right, GColorClear);
	rot_bitmap_set_compositing_mode(s_ternary_minutes_layer_right, GCompOpSet);
	rot_bitmap_layer_set_angle(s_ternary_minutes_layer_right, DEG_TO_TRIGANGLE(-45));

	//position the frame
	r = layer_get_frame((Layer *) s_ternary_minutes_layer_right);
	r.origin.x = width - 32 - PADDING;
	r.origin.y = max_height - 32 - PADDING;
	layer_set_frame((Layer *) s_ternary_minutes_layer_right, r);
	layer_add_child(window_get_root_layer(window), (Layer *) s_ternary_minutes_layer_right);

	if (persist_read_int(KEY_BACKGROUND_COLOR)) {
		set_background_color(persist_read_int(KEY_BACKGROUND_COLOR));
	}
}

static void window_unload(Window *window) {
	gbitmap_destroy(s_ternary_seconds_bitmap);
	bitmap_layer_destroy(s_ternary_seconds_layer);

	gbitmap_destroy(s_unary_hours_bitmap);
	rot_bitmap_layer_destroy(s_unary_hours_layer_left);
	rot_bitmap_layer_destroy(s_unary_hours_layer_right);

	gbitmap_destroy(s_ternary_minutes_bitmap);
	rot_bitmap_layer_destroy(s_ternary_minutes_layer_left);
	rot_bitmap_layer_destroy(s_ternary_minutes_layer_right);
}