void set_invert_color(bool invert) {
  if (invert && inverter_layer != NULL) {
    Layer *window_layer = window_get_root_layer(window);
    inverter_layer = inverter_layer_create(GRect(0, 0, 144, 168));
    layer_add_child(window_layer, inverter_layer_get_layer(inverter_layer));
  } else if (!invert && inverter_layer == NULL) { // Doesnt invert
    Layer *window_layer = window_get_root_layer(window);
    inverter_layer = inverter_layer_create(GRect(0, 0, 144, 40));
    layer_add_child(window_layer, inverter_layer_get_layer(inverter_layer));
  }
  // No action required
}
Beispiel #2
0
static void set_invert() {
    if (!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));
		layer_mark_dirty(inverter_layer_get_layer(inverter_layer));
    }
}
Beispiel #3
0
static void display_time(struct tm *tick_time) {
    
    // TODO: Use `units_changed` and more intelligence to reduce
    //       redundant digit unload/load?
	
	// This is to make sure the screen is not refreshed every second
	if (tick_time->tm_min != min)  {
		if (was_BTconnected_last_time)  {
			window_set_background_color(window, background_color);
			display_value(get_display_hour(tick_time->tm_hour), 0, false);
			display_value(tick_time->tm_min, 1, true);
			min = tick_time->tm_min;
		}
		else  {
			// Destroy previous inverter layer to make sure there's no inverted spot if first digit is missing (ie: " 0:12")
			inverter_layer_destroy(inv_layer);
			window_set_background_color(window, background_color);
			display_value(get_display_hour(tick_time->tm_hour), 0, false);
			display_value(tick_time->tm_min, 1, true);
			min = tick_time->tm_min;
			//Inverter layer
			inv_layer = inverter_layer_create(GRect(0, 0, 144, 168));
			layer_add_child(window_get_root_layer(window), (Layer*) inv_layer);	
		}		
	}
}
Beispiel #4
0
void handle_init(void) {
  my_window = window_create();

  week_day_layer = text_layer_create(GRect(0, 10, 144, 42));
  text_layer_set_background_color(week_day_layer, GColorClear);
  layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(week_day_layer));

  day_of_month_layer = text_layer_create(GRect(0,42,144,95));
  text_layer_set_background_color(day_of_month_layer, GColorClear);
  layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(day_of_month_layer));

  month_layer = text_layer_create(GRect(0,110,144,58));
  text_layer_set_background_color(month_layer, GColorClear);
  layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(month_layer));
  
  time_t now = time(NULL);
  set_strings(localtime(&now));
  render();
  
  inverter_layer = inverter_layer_create(GRect(0, 0, 144, 168));
	layer_add_child(window_get_root_layer(my_window), inverter_layer_get_layer(inverter_layer));
  
  window_stack_push(my_window, true);

  tick_timer_service_subscribe(DAY_UNIT, handle_time_change);
}
Beispiel #5
0
void window_load(Window *window)
{
	text_layer = text_layer_create(GRect(0, 53, 132, 168));
	text_layer_set_background_color(text_layer, GColorClear);
	text_layer_set_text_color(text_layer, GColorBlack);
	text_layer_set_text_alignment(text_layer, GTextAlignmentCenter);
	text_layer_set_font(text_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD));
	 
	layer_add_child(window_get_root_layer(window), (Layer*) text_layer);
	//simple text on screen
	//text_layer_set_text(text_layer, "Anything you want, as long as it is in quotes!");
	
	//Inverter layer
	inv_layer = inverter_layer_create(GRect(0, 50, 144, 62));
	layer_add_child(window_get_root_layer(window), (Layer*) inv_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);
}
Beispiel #6
0
void setup_frame(void){
	Layer *window_layer = window_get_root_layer(window);
	
	sine_layer = bitmap_layer_create(GRect(0, 84, 144, 64));
	sine_thin = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_SINE_THIN);
	sine_thick = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_SINE);
	
	layer_add_child(window_layer, bitmap_layer_get_layer(sine_layer));
	
	horizon_layer = inverter_layer_create(horizon_pos);
	layer_add_child(window_layer, inverter_layer_get_layer(horizon_layer));
	layer_set_hidden(inverter_layer_get_layer(horizon_layer), true);
	
	horizon_line_layer = layer_create(horizon_pos);
	layer_set_update_proc(horizon_line_layer, horizon_line_update_callback);
	layer_add_child(window_layer, horizon_line_layer);
	layer_set_hidden(horizon_line_layer, true);
	
	current_hor_layer = horizon_line_layer;
	
	sun_layer = layer_create(sun_pos);
	layer_set_update_proc(sun_layer, draw_sun);
	layer_add_child(window_layer, sun_layer);
	layer_set_hidden(sun_layer, true);
}
// Setup the scroll layer on window load
// We do this here in order to be able to get the max used text size
static void window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_frame(window_layer);
  GRect max_text_bounds = GRect(0, 0, bounds.size.w, 2000);

  // Initialize the scroll layer
  scroll_layer = scroll_layer_create(bounds);

  // This binds the scroll layer to the window so that up and down map to scrolling
  // You may use scroll_layer_set_callbacks to add or override interactivity
  scroll_layer_set_click_config_onto_window(scroll_layer, window);

  // Initialize the text layer
  text_layer = text_layer_create(max_text_bounds);
  text_layer_set_text(text_layer, scroll_text);

  // Change the font to a nice readable one
  // This is system font; you can inspect pebble_fonts.h for all system fonts
  // or you can take a look at feature_custom_font to add your own font
  text_layer_set_font(text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));

  // Trim text layer and scroll content to fit text box
  GSize max_size = text_layer_get_content_size(text_layer);
  text_layer_set_size(text_layer, max_size);
  scroll_layer_set_content_size(scroll_layer, GSize(bounds.size.w, max_size.h + vert_scroll_text_padding));

  // Add the layers for display
  scroll_layer_add_child(scroll_layer, text_layer_get_layer(text_layer));

  // The inverter layer will highlight some text
  inverter_layer = inverter_layer_create(GRect(0, 28, bounds.size.w, 28));
  scroll_layer_add_child(scroll_layer, inverter_layer_get_layer(inverter_layer));

  layer_add_child(window_layer, scroll_layer_get_layer(scroll_layer));
}
static void window_load(Window *window) 
{
  //Font
  ResHandle font_handle = resource_get_handle(RESOURCE_ID_FONT_LUCIDA_16);

  //Time 
  time_label = cl_init_text_layer(GRect(5, 5, 144, 30), GColorWhite, GColorClear, font_handle, GTextAlignmentLeft);
  text_layer_set_text(time_label, "");
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(time_label));

  time_layer = cl_init_text_layer(GRect(5, 24, 144, 30), GColorWhite, GColorClear, font_handle, GTextAlignmentLeft);
  text_layer_set_text(time_layer, "");
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(time_layer));

  //Date
  date_label = cl_init_text_layer(GRect(5, 53, 144, 30), GColorWhite, GColorClear, font_handle, GTextAlignmentLeft);
  text_layer_set_text(date_label, "");
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(date_label));

  date_layer = cl_init_text_layer(GRect(5, 70, 144, 30), GColorWhite, GColorClear, font_handle, GTextAlignmentLeft);
  text_layer_set_text(date_layer, "");
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(date_layer));

  //Prompt
  prompt_label = cl_init_text_layer(GRect(5, 99, 144, 30), GColorWhite, GColorClear, font_handle, GTextAlignmentLeft);
  text_layer_set_text(prompt_label, "");
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(prompt_label));

  prompt_layer = inverter_layer_create(GRect(45, 115, 12, 2));
  
}
Beispiel #9
0
void window_load(Window *me) {
	Layer *window_layer = window_get_root_layer(me);
	switch (current_level) {
		case 0:
		case 1:
		if (current_level == 1)
			for (int i = 0; i < item_count; i++)
				memset(item_names[i], 0, TITLE_SIZE);
			menu_layer[current_level] = menu_layer_create(layer_get_bounds(window_layer));
			menu_layer_set_callbacks(menu_layer[current_level], NULL, (MenuLayerCallbacks){
				.get_cell_height = menu_get_cell_height_callback,
				.get_num_rows = menu_get_num_rows_callback,
				.draw_row = menu_draw_row_callback,
				.select_click = menu_select_callback,
			});
			menu_layer_set_click_config_onto_window(menu_layer[current_level], me);
			layer_set_hidden(menu_layer_get_layer(menu_layer[current_level]), true);
			layer_add_child(window_layer, menu_layer_get_layer(menu_layer[current_level]));
			break;
		case 2:
			messageheader_layer = text_layer_create(GRect(0, 0, 144, INT16_MAX));
			messageseparator_layer = inverter_layer_create(GRect(0, 0, 144, INT16_MAX));
			messagetext_layer = text_layer_create(GRect(0, 0, 144, INT16_MAX));
			message_layer = scroll_layer_create(layer_get_bounds(window_layer));
			scroll_layer_add_child(message_layer, text_layer_get_layer(messageheader_layer));
			scroll_layer_add_child(message_layer, inverter_layer_get_layer(messageseparator_layer));
			scroll_layer_add_child(message_layer, text_layer_get_layer(messagetext_layer));
			scroll_layer_set_callbacks(message_layer, (ScrollLayerCallbacks){
				.click_config_provider = message_click_config_provider
			});
Beispiel #10
0
void set_day_layer(int day)
{
  int startX = 20;
 
  switch(day)
    {
    case 1: startX = 20; break;
    case 2: startX = 35; break;
    case 3: startX = 50; break;
    case 4: startX = 65; break;
    case 5: startX = 80; break;
    case 6: startX = 95; break;
    case 0: startX = 110; break;
  }
  // Create Layer
  
   //Monday
  
  draw_day(20,"M");
  draw_day(35,"T");
  draw_day(50,"W");
  draw_day(65,"T");
  draw_day(80,"F");
  draw_day(95,"S");
  draw_day(110,"S");

  
  //Add Inverted Layer
  i_date_layer = inverter_layer_create(GRect (startX, dayY, dayW, dayH)); //(x,y,w,h) (x,y,144*168)
	layer_add_child(window_get_root_layer(window), inverter_layer_get_layer(i_date_layer));
  
  
}
Beispiel #11
0
static void main_window_load(Window *window) {
	//get root layer of window
	Layer *window_layer = window_get_root_layer(window);

	//get window dimensions
	GRect bounds = layer_get_bounds(window_layer);

	//add drawing layers
	s_clock_layer_outer = layer_create(GRect(EDGE, EDGE, bounds.size.w - (EDGE * 2), bounds.size.h - (EDGE * 2)));
	layer_set_update_proc(s_clock_layer_outer, draw_clock_layer_outer);
	layer_add_child(window_layer, s_clock_layer_outer);

	s_clock_layer_center = layer_create(GRect(EDGE, EDGE, bounds.size.w - (EDGE * 2), bounds.size.h - (EDGE * 2)));
	layer_set_update_proc(s_clock_layer_center, draw_clock_layer_center);
	layer_add_child(window_layer, s_clock_layer_center);

	s_clock_layer_inner = layer_create(GRect(EDGE, EDGE, bounds.size.w - (EDGE * 2), bounds.size.h - (EDGE * 2)));
	layer_set_update_proc(s_clock_layer_inner, draw_clock_layer_inner);
	layer_add_child(window_layer, s_clock_layer_inner);

	//init text time layer
	GSize max_size = graphics_text_layout_get_content_size(
		"00:00",
		fonts_get_system_font(FONT_KEY_GOTHIC_14),
		GRect(0, 0, bounds.size.w, bounds.size.h),
		GTextOverflowModeTrailingEllipsis,
		GTextAlignmentCenter
	);
	s_text_time = text_layer_create(GRect(
		(bounds.size.w / 2) - (max_size.w / 2),
		(bounds.size.h / 2) - (max_size.h / 2),
		max_size.w,
		max_size.h)
	);
	text_layer_set_background_color(s_text_time, GColorClear);
	text_layer_set_text_color(s_text_time, GColorBlack);
	text_layer_set_font(s_text_time, fonts_get_system_font(FONT_KEY_GOTHIC_14));
	text_layer_set_text_alignment(s_text_time, GTextAlignmentCenter);
	layer_add_child(window_layer, text_layer_get_layer(s_text_time));
	toggle_text_time();

	//init inverter layer
	s_layer_invert = inverter_layer_create(GRect(0, 0, bounds.size.w, bounds.size.h));
	layer_add_child(window_layer, inverter_layer_get_layer(s_layer_invert));
	invert_face();

	//store clock layer bounds
	s_clock_bounds = layer_get_bounds(s_clock_layer_outer);
	s_clock_center = grect_center_point(&s_clock_bounds);

	//init hand paths
	s_hand_path_outer = gpath_create(&OUTER_HAND_POINTS);
	gpath_move_to(s_hand_path_outer, s_clock_center);

	s_hand_path_center = gpath_create(&CENTER_HAND_POINTS);
	gpath_move_to(s_hand_path_center, s_clock_center);

	s_hand_path_inner = gpath_create(&INNER_HAND_POINTS);
	gpath_move_to(s_hand_path_inner, s_clock_center);
}
// 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 initialise_ui(void) {
  s_window = window_create();
  window_set_fullscreen(s_window, false);
  
  s_res_gothic_24_bold = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
  s_res_gothic_18 = fonts_get_system_font(FONT_KEY_GOTHIC_18);
  // s_inverterlayer_1
  s_inverterlayer_1 = inverter_layer_create(GRect(0, 0, 144, 35));
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_inverterlayer_1);
  
  // s_stop_name_layer
  s_stop_name_layer = text_layer_create(GRect(0, -7, 144, 29));
  text_layer_set_background_color(s_stop_name_layer, GColorClear);
  text_layer_set_text_color(s_stop_name_layer, GColorWhite);
  text_layer_set_text(s_stop_name_layer, "Mountain View");
  text_layer_set_text_alignment(s_stop_name_layer, GTextAlignmentCenter);
  text_layer_set_font(s_stop_name_layer, s_res_gothic_24_bold);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_stop_name_layer);
  
  // s_direction_layer
  s_direction_layer = text_layer_create(GRect(0, 14, 144, 19));
  text_layer_set_background_color(s_direction_layer, GColorClear);
  text_layer_set_text_color(s_direction_layer, GColorWhite);
  text_layer_set_text(s_direction_layer, "Southbound");
  text_layer_set_text_alignment(s_direction_layer, GTextAlignmentCenter);
  text_layer_set_font(s_direction_layer, s_res_gothic_18);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_direction_layer);
  
  // s_train_menu
  s_train_menu = menu_layer_create(GRect(0, 35, 144, 117));
  menu_layer_set_click_config_onto_window(s_train_menu, s_window);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_train_menu);
}
Beispiel #14
0
void handle_init() {
  autoconfig_init();

  window = window_create();
  
  window_set_background_color(window, GColorWhite);
  window_stack_push(window, true);

  app_message_register_inbox_received(in_received_handler);

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

  for (int i = 0; i < TOTAL_IMAGE_SLOTS; i++) {
    bitmaps[i] = NULL;
    image_containers[i] = bitmap_layer_create(GRect(
      ((i % 4) * 36),
      ((i / 4) * 70)+15,
      36,70));
    layer_add_child(window_layer, bitmap_layer_get_layer(image_containers[i]));
  }

  inverter_layer = inverter_layer_create  (bounds);
  layer_set_hidden(inverter_layer_get_layer(inverter_layer), !getInverted());
  layer_add_child(window_layer, inverter_layer_get_layer(inverter_layer));

  tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick);
}
Beispiel #15
0
void handle_init(void) {
	// Create a window and text layer
	window = window_create();
	text_layer = text_layer_create(GRect(0, TIME_HEIGHT, 144, 168 - TIME_HEIGHT));

	show_seconds = persist_read_bool(KEY_SHOW_SECONDS);
	invert_face = persist_read_bool(KEY_INVERT);
	metric_units = persist_read_bool(KEY_UNITS);
	
	latitude[0] = 0;
	longitude[0] = 0;
	location[0] = 0;
	weather[0] = 0;
	// Set the text, font, and text alignment
	//text_layer_set_text(text_layer, "");
	// http://www.openweathermap.org/current
	// https://developer.getpebble.com/blog/2013/07/24/Using-Pebble-System-Fonts/
	// https://github.com/JvetS/PebbleSimulator/blob/master/PebbleSimulator/pebble_fonts.h
	text_layer_set_font(text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14));
	// https://developer.getpebble.com/2/api-reference/group___graphics_types.html
	text_layer_set_text_alignment(text_layer, GTextAlignmentLeft);

	// Add the text layer to the window
	layer_add_child(window_get_root_layer(window), text_layer_get_layer(text_layer));

//	date_layer = text_layer_create(GRect(0, 112, 144, 56));
//	text_layer_set_text_alignment(date_layer, GTextAlignmentCenter);
//	text_layer_set_font(date_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD));
//	layer_add_child(window_get_root_layer(window), text_layer_get_layer(date_layer));
	time_layer = text_layer_create(GRect(0, 0, 144, TIME_HEIGHT));
	text_layer_set_text_alignment(time_layer, GTextAlignmentCenter);
	text_layer_set_font(time_layer, fonts_get_system_font(FONT_PRO_32));
	layer_add_child(window_get_root_layer(window), text_layer_get_layer(time_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));
	layer_set_hidden(inverter_layer_get_layer(inverter_layer), invert_face);
	
	battery_state_service_subscribe(handle_battery_change);
	handle_battery_change(battery_state_service_peek());

	bluetooth_connection_service_subscribe(handle_bluetooth_change);
	handle_bluetooth_change(bluetooth_connection_service_peek());
	
	app_message_register_inbox_received(in_received_handler);
	app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum());

	time_t current_time = time(0);
	handle_timechanges(localtime(&current_time), SECOND_UNIT);
	
	tick_timer_service_subscribe(SECOND_UNIT, handle_timechanges);
	
	// Push the window
	window_stack_push(window, true);

	// App Logging!
	//APP_LOG(APP_LOG_LEVEL_DEBUG, "Hello World from the applogs!");
}
static void rdLoad(Window *window) {
  //APP_LOG(APP_LOG_LEVEL_DEBUG, "Enter rdLoad()");
  setCommonLoad("Race Distance");

  // Units
  rdIntegerLayer = text_layer_create(rdIntegerGRect);
  text_layer_set_text_alignment(rdIntegerLayer, GTextAlignmentCenter);
  text_layer_set_font(rdIntegerLayer, fonts_get_system_font(FONT_KEY_GOTHIC_28));
  text_layer_set_background_color(rdIntegerLayer, GColorWhite);
  text_layer_set_text_color(rdIntegerLayer, GColorBlack);
  rdSetIntegerDisplay();
  layer_add_child(text_layer_get_layer(setDataLayer), text_layer_get_layer(rdIntegerLayer));

  rdIntegerInverterLayer = inverter_layer_create(rdIntegerGRect);
  layer_add_child(text_layer_get_layer(setDataLayer), inverter_layer_get_layer(rdIntegerInverterLayer));
  layer_set_hidden(inverter_layer_get_layer(rdIntegerInverterLayer), false);

  // Decimal point "."
  rdDecimalPointLayer = text_layer_create(rdIntegerDecimalPointGRect);
  text_layer_set_text_alignment(rdDecimalPointLayer, GTextAlignmentCenter);
  text_layer_set_font(rdDecimalPointLayer, fonts_get_system_font(FONT_KEY_GOTHIC_28));
  text_layer_set_background_color(rdDecimalPointLayer, GColorWhite);
  text_layer_set_text_color(rdDecimalPointLayer, GColorBlack);
  text_layer_set_text(rdDecimalPointLayer, ".");
  layer_add_child(text_layer_get_layer(setDataLayer), text_layer_get_layer(rdDecimalPointLayer));

  // Tenths
  rdTenthsLayer = text_layer_create(rdTenthsGRect);
  text_layer_set_text_alignment(rdTenthsLayer, GTextAlignmentCenter);
  text_layer_set_font(rdTenthsLayer, fonts_get_system_font(FONT_KEY_GOTHIC_28));
  text_layer_set_background_color(rdTenthsLayer, GColorWhite);
  text_layer_set_text_color(rdTenthsLayer, GColorBlack);
  rdSetTenthsDisplay();
  layer_add_child(text_layer_get_layer(setDataLayer), text_layer_get_layer(rdTenthsLayer));

  rdTenthsInverterLayer = inverter_layer_create(rdTenthsGRect);
  layer_add_child(text_layer_get_layer(setDataLayer), inverter_layer_get_layer(rdTenthsInverterLayer));
  layer_set_hidden(inverter_layer_get_layer(rdTenthsInverterLayer), true);

  // Set integer field to be updated.
  setFieldNbr = 1;

  //APP_LOG(APP_LOG_LEVEL_DEBUG, "about to set rd_click_config_provider()");
  window_set_click_config_provider(setWindow, (ClickConfigProvider) rd_click_config_provider);
}
static void ftLoad(Window *window) {
  //APP_LOG(APP_LOG_LEVEL_DEBUG, "Enter ftLoad()");
  setCommonLoad("Finish Time");

  // Hours
  ftHoursLayer = text_layer_create(ftHoursGRect);
  text_layer_set_text_alignment(ftHoursLayer, GTextAlignmentCenter);
  text_layer_set_font(ftHoursLayer, fonts_get_system_font(FONT_KEY_GOTHIC_28));
  text_layer_set_background_color(ftHoursLayer, GColorWhite);
  text_layer_set_text_color(ftHoursLayer, GColorBlack);
  ftSetHoursDisplay();
  layer_add_child(text_layer_get_layer(setDataLayer), text_layer_get_layer(ftHoursLayer));

  ftHoursInverterLayer = inverter_layer_create(ftHoursGRect);
  layer_add_child(text_layer_get_layer(setDataLayer), inverter_layer_get_layer(ftHoursInverterLayer));
  layer_set_hidden(inverter_layer_get_layer(ftHoursInverterLayer), false);

  // Colon ":"
  ftColonLayer = text_layer_create(ftColonGRect);
  text_layer_set_text_alignment(ftColonLayer, GTextAlignmentCenter);
  text_layer_set_font(ftColonLayer, fonts_get_system_font(FONT_KEY_GOTHIC_28));
  text_layer_set_background_color(ftColonLayer, GColorWhite);
  text_layer_set_text_color(ftColonLayer, GColorBlack);
  text_layer_set_text(ftColonLayer, ":");
  layer_add_child(text_layer_get_layer(setDataLayer), text_layer_get_layer(ftColonLayer));

  // Minutes
  ftMinsLayer = text_layer_create(ftMinsGRect);
  text_layer_set_text_alignment(ftMinsLayer, GTextAlignmentCenter);
  text_layer_set_font(ftMinsLayer, fonts_get_system_font(FONT_KEY_GOTHIC_28));
  text_layer_set_background_color(ftMinsLayer, GColorWhite);
  text_layer_set_text_color(ftMinsLayer, GColorBlack);
  ftSetMinsDisplay();
  layer_add_child(text_layer_get_layer(setDataLayer), text_layer_get_layer(ftMinsLayer));

  ftMinsInverterLayer = inverter_layer_create(ftMinsGRect);
  layer_add_child(text_layer_get_layer(setDataLayer), inverter_layer_get_layer(ftMinsInverterLayer));
  layer_set_hidden(inverter_layer_get_layer(ftMinsInverterLayer), true);

  // Set integer field to be updated.
  setFieldNbr = 1;

  //APP_LOG(APP_LOG_LEVEL_DEBUG, "about to set ft_click_config_provider()");
  window_set_click_config_provider(setWindow, (ClickConfigProvider) ft_click_config_provider);
}
Beispiel #18
0
void thread_window_load(Window *window)
{
	struct ThreadData *thread = GetSelectedThread();
	
	thread_scroll_layer = scroll_layer_create(window_frame);

	scroll_layer_set_shadow_hidden(thread_scroll_layer, true);
	scroll_layer_set_click_config_onto_window(thread_scroll_layer, window);
	scroll_layer_set_content_size(thread_scroll_layer, GSize(window_frame.size.w, 0));
	scroll_layer_set_content_offset(thread_scroll_layer, GPoint(0, 0), false);

	ScrollLayerCallbacks scrollOverride =
	{
		.click_config_provider = &thread_click_config,
		.content_offset_changed_handler = &thread_offset_changed_handler
	};
	scroll_layer_set_callbacks(thread_scroll_layer, scrollOverride);

	thread_title_layer = layer_create(GRect(0, 0, window_frame.size.w, 22));
	layer_set_update_proc(thread_title_layer, thread_title_layer_update_proc);
	scroll_layer_add_child(thread_scroll_layer, thread_title_layer);

	layer_add_child(window_get_root_layer(window), scroll_layer_get_layer(thread_scroll_layer));

	thread_view_comments_layer = text_layer_create(GRect(0, 0, window_frame.size.w, LOAD_COMMENTS_HEIGHT));
	text_layer_set_text(thread_view_comments_layer, "View Comments");
	text_layer_set_font(thread_view_comments_layer, GetBiggerFont());
	text_layer_set_text_alignment(thread_view_comments_layer, GTextAlignmentCenter);
	scroll_layer_add_child(thread_scroll_layer, text_layer_get_layer(thread_view_comments_layer));

	thread_inverter_hidden = true;
	thread_inverter_layer = inverter_layer_create(GRect(0, 0, window_frame.size.w, LOAD_COMMENTS_HEIGHT));
	layer_set_hidden(inverter_layer_get_layer(thread_inverter_layer), true);
	scroll_layer_add_child(thread_scroll_layer, inverter_layer_get_layer(thread_inverter_layer));

	if(thread->type == 1)
	{
		// we are an image
		thread_body_layer = NULL;

		thread_bitmap_layer = bitmap_layer_create(GRect(0, 22, window_frame.size.w, window_frame.size.h));
		scroll_layer_add_child(thread_scroll_layer, bitmap_layer_get_layer(thread_bitmap_layer));

		scroll_layer_set_content_size(thread_scroll_layer, GSize(window_frame.size.w, 22 + window_frame.size.h + 10));

		thread_update_comments_position();
	}
	else
	{
		//current_thread.image = NULL;
		thread_bitmap_layer = NULL;

		thread_body_layer = text_layer_create(GRect(0, 22, window_frame.size.w, 10000));
		text_layer_set_font(thread_body_layer, GetFont());
		scroll_layer_add_child(thread_scroll_layer, text_layer_get_layer(thread_body_layer));
	}
}
Beispiel #19
0
static void main_window_load(Window *window) {
  
  // Create root layer
  Layer *window_layer = window_get_root_layer(window);
  GRect window_bounds = layer_get_bounds(window_layer);
  
    // Create time TextLayer
  s_time_layer = text_layer_create(GRect(0, 35, window_bounds.size.w, 44));
  text_layer_set_background_color(s_time_layer, GColorClear);
  text_layer_set_text_color(s_time_layer, GColorWhite);
  text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);
  
  // Create date TextLayer
  s_date_layer = text_layer_create(GRect(0, 82, window_bounds.size.w, 26));
  text_layer_set_background_color(s_date_layer, GColorClear);
  text_layer_set_text_color(s_date_layer, GColorWhite);
  text_layer_set_text_alignment(s_date_layer, GTextAlignmentCenter);
  text_layer_set_font(s_date_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
  
  // Create battery TextLayer
  s_battery_layer = text_layer_create(GRect(window_bounds.size.w / 2, 0, (window_bounds.size.w / 2) - 2, 18));
  text_layer_set_background_color(s_battery_layer, GColorClear);
  text_layer_set_text_color(s_battery_layer, GColorWhite);
  text_layer_set_text_alignment(s_battery_layer, GTextAlignmentRight);
  text_layer_set_font(s_battery_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14));
  
  // Create Pi time BitmapLayer
  s_pi_bitmap = gbitmap_create_with_resource(RESOURCE_ID_PI_BACKGROUND);
  s_pi_layer = bitmap_layer_create(GRect(0,17,144,150));
  bitmap_layer_set_bitmap(s_pi_layer, s_pi_bitmap);
  layer_set_hidden(bitmap_layer_get_layer(s_pi_layer), true);
  
  // Create bluetooth BitmapLayer
  s_bt_connected_bitmap = gbitmap_create_with_resource(RESOURCE_ID_BT_CONNECTED);
  s_bt_disconnected_bitmap = gbitmap_create_with_resource(RESOURCE_ID_BT_DISCONNECTED);
  s_bt_layer = bitmap_layer_create(GRect(3,3,12,11));
 
  
  // Create bluetooth connected InverterLayer
  s_inv_layer = inverter_layer_create(GRect(0,0,window_bounds.size.w,window_bounds.size.h));
      
  // Initialize watch state
  s_show_seconds_bool = true;
  battery_handler(battery_state_service_peek());
  bluetooth_handler(bluetooth_connection_service_peek());
  format_time();

  // Add all layers to the Window's root layer
  layer_add_child(window_layer, text_layer_get_layer(s_time_layer));
  layer_add_child(window_layer, text_layer_get_layer(s_battery_layer));
  layer_add_child(window_layer, text_layer_get_layer(s_date_layer));
  layer_add_child(window_layer, bitmap_layer_get_layer(s_bt_layer));
  layer_add_child(window_layer, bitmap_layer_get_layer(s_pi_layer));
  layer_add_child(window_layer, inverter_layer_get_layer(s_inv_layer));
    
}
Beispiel #20
0
static void initialise_ui(void) {
  s_window = window_create();
  window_set_fullscreen(s_window, false);
  
  s_res_gothic_24_bold = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
  // s_station_name
  s_station_name = text_layer_create(GRect(0, -7, 144, 29));
  text_layer_set_background_color(s_station_name, GColorClear);
  text_layer_set_text(s_station_name, "Mountain View");
  text_layer_set_text_alignment(s_station_name, GTextAlignmentCenter);
  text_layer_set_font(s_station_name, s_res_gothic_24_bold);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_station_name);
  
  // s_inverterlayer_2
  s_inverterlayer_2 = inverter_layer_create(GRect(0, 0, 145, 21));
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_inverterlayer_2);
  
  // s_inverterlayer_1
  s_inverterlayer_1 = inverter_layer_create(GRect(0, 86, 144, 2));
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_inverterlayer_1);
}
Beispiel #21
0
void handle_init(void) {
  // Creates images resource
  bitmap_1 = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_GROUND_TEMPLATE);
  bitmap_2 = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_YL0);
  bitmap_3 = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_YF0);
  bitmap_4 = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_YR0);
  
	// Create a window and text layer
	window = window_create();
	text_layer = text_layer_create(GRect(0, 0, 144, 154));
	
	// Set the text, font, and text alignment
	text_layer_set_text(text_layer, "Hello World!");
	text_layer_set_font(text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
	text_layer_set_text_alignment(text_layer, GTextAlignmentCenter);
	
	// Add the text layer to the window
	layer_add_child(window_get_root_layer(window), text_layer_get_layer(text_layer));
  
  date_layer = text_layer_create(GRect(0, 112, 144, 56));
  text_layer_set_text_alignment(date_layer, GTextAlignmentCenter);
  text_layer_set_font(date_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_LIGHT));
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(date_layer));
  
  inverter_layer = inverter_layer_create(GRect(0, 112, 144, 56));
  layer_add_child(window_get_root_layer(window), inverter_layer_get_layer(inverter_layer));
  
  // Draws ground
  ground = bitmap_layer_create(GRect(0, 56, 144, 56));
  yorp_left = bitmap_layer_create(r1);
  yorp_front = bitmap_layer_create(r2);
  yorp_right = bitmap_layer_create(r3);
  bitmap_layer_set_bitmap(ground, bitmap_1);
  bitmap_layer_set_bitmap(yorp_left, bitmap_2);
  bitmap_layer_set_bitmap(yorp_front, bitmap_3);
  bitmap_layer_set_bitmap(yorp_right, bitmap_4);
  Layer * l = window_get_root_layer(window);
  layer_add_child(l, bitmap_layer_get_layer(ground));
  layer_add_child(l, bitmap_layer_get_layer(yorp_left));
  layer_add_child(l, bitmap_layer_get_layer(yorp_front));
  layer_add_child(l, bitmap_layer_get_layer(yorp_right));
  
  time_t now = time(NULL);
  handle_timechanges(localtime(&now), SECOND_UNIT);
  
  tick_timer_service_subscribe(SECOND_UNIT, handle_timechanges);
    
	// Push the window
	window_stack_push(window, true);
	
	// App Logging!
	APP_LOG(APP_LOG_LEVEL_DEBUG, "Hello World from the applogs!");
}
Beispiel #22
0
void window_load(Window *window) {
  s_text_layer = text_layer_create(GRect(0, 83, 132, 168));
  text_layer_set_background_color(s_text_layer, GColorClear);
  text_layer_set_text(s_text_layer, GColorBlack);
  text_layer_set_text_alignment(s_text_layer, GTextAlignmentCenter);
  text_layer_set_font(s_text_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD));
  
  layer_add_child(window_get_root_layer(s_window), text_layer_get_layer(s_text_layer));
  
  // Create battery layer
  s_battery_layer = text_layer_create(GRect(0, 0, 144, 20));
  text_layer_set_text_alignment(s_battery_layer, GTextAlignmentCenter);
  layer_add_child(window_get_root_layer(s_window), text_layer_get_layer(s_battery_layer));
  
  // Add inverter layer
  s_inv_layer = inverter_layer_create(GRect(0, 80, 144, 62));
  layer_add_child(window_get_root_layer(s_window), inverter_layer_get_layer(s_inv_layer));
  
  // Mult kirb layers
  s_kirbwalk0_bitmap = gbitmap_create_with_resource(RESOURCE_ID_KIRB_WALK_0);
  s_kirbwalk0_layer = bitmap_layer_create(GRect(-16, 60, 16, 16));
  bitmap_layer_set_bitmap(s_kirbwalk0_layer, s_kirbwalk0_bitmap);
  
  s_kirbwalk1_bitmap = gbitmap_create_with_resource(RESOURCE_ID_KIRB_WALK_1);
  s_kirbwalk1_layer = bitmap_layer_create(GRect(63, 60, 16, 16));
  bitmap_layer_set_bitmap(s_kirbwalk1_layer, s_kirbwalk1_bitmap);
  
  s_kirbwalk2_bitmap = gbitmap_create_with_resource(RESOURCE_ID_KIRB_WALK_2);
  s_kirbwalk2_layer = bitmap_layer_create(GRect(-16, 60, 16, 16));
  bitmap_layer_set_bitmap(s_kirbwalk2_layer, s_kirbwalk2_bitmap);
  active_kirb = &s_kirbwalk1_layer;
  active_frame = 1;
  dx = 1;
  
  layer_add_child(window_get_root_layer(s_window), bitmap_layer_get_layer(s_kirbwalk0_layer));
  layer_add_child(window_get_root_layer(s_window), bitmap_layer_get_layer(s_kirbwalk1_layer));
  layer_add_child(window_get_root_layer(s_window), bitmap_layer_get_layer(s_kirbwalk2_layer));
  
  struct tm *t;
  time_t temp;
  temp = time(NULL);
  t = localtime(&temp);
  
  // Manually call the tick handler when window is done loading
  tick_handler(t, MINUTE_UNIT);
  
  // Manually call battery handler
  battery_handler(battery_state_service_peek());
  
  // Start kirb moving
  timer = app_timer_register(delta, (AppTimerCallback) timer_callback, NULL);
}
void window_load(Window *window)
{
    inverter_layer = inverter_layer_create(GRect(0, 0, 144, 13));
    slider_layer = bitmap_layer_create(GRect(49, 1, 46, 10));
    slider0_bitmap = gbitmap_create_with_resource(RESOURCE_ID_SLIDER0);
    slider1_bitmap = gbitmap_create_with_resource(RESOURCE_ID_SLIDER1);
    slider2_bitmap = gbitmap_create_with_resource(RESOURCE_ID_SLIDER2);
    slider3_bitmap = gbitmap_create_with_resource(RESOURCE_ID_SLIDER3);

    /////////////////////
    slide_start = layer_create(GRect(0, 0, 144, 168));
    layer_add_child(window_get_root_layer(window), (Layer *)slide_start);

    logo_layer = bitmap_layer_create(GRect(32, 10, 80, 103));
    logo_bitmap = gbitmap_create_with_resource(RESOURCE_ID_LOGO);
    bitmap_layer_set_bitmap(logo_layer, logo_bitmap);
    layer_add_child((Layer *)slide_start, bitmap_layer_get_layer(logo_layer));

    caption_text_layer = init_text_layer(GRect(0, 105, 144, 40), GColorBlack, GColorClear, "RESOURCE_ID_GOTHIC_28_BOLD", GTextAlignmentCenter);
    text_layer_set_text(caption_text_layer, "RPi-Monitor");
    layer_add_child((Layer *)slide_start, text_layer_get_layer(caption_text_layer));

    status_text_layer = init_text_layer(GRect(0, 135, 144, 25), GColorBlack, GColorClear, "RESOURCE_ID_GOTHIC_18", GTextAlignmentCenter);
    text_layer_set_text(status_text_layer, "Loading...");
    layer_add_child((Layer *)slide_start, text_layer_get_layer(status_text_layer));

    /////////////////////
    slide0 = layer_create(GRect(0, 0, 144, 168));
    layer_add_child(window_get_root_layer(window), (Layer *)slide0);
    layer_set_hidden((Layer *)slide0, true);

    cpu_title_text_layer = init_text_layer(GRect(0, 12, 144, 20), GColorBlack, GColorClear, "RESOURCE_ID_GOTHIC_18_BOLD", GTextAlignmentCenter);
    text_layer_set_text(cpu_title_text_layer, "CPU");
    layer_add_child((Layer *)slide0, text_layer_get_layer(cpu_title_text_layer));

    cpu_text_layer = init_text_layer(GRect(2, 32, 140, 136), GColorBlack, GColorClear, "RESOURCE_ID_GOTHIC_14", GTextAlignmentLeft);
    layer_add_child((Layer *)slide0, text_layer_get_layer(cpu_text_layer));

    /////////////////////
    slide1 = layer_create(GRect(0, 0, 144, 168));
    layer_add_child(window_get_root_layer(window), (Layer *)slide1);
    layer_set_hidden((Layer *)slide1, true);

    memory_title_text_layer = init_text_layer(GRect(0, 12, 144, 20), GColorBlack, GColorClear, "RESOURCE_ID_GOTHIC_18_BOLD", GTextAlignmentCenter);
    text_layer_set_text(memory_title_text_layer, "MEMORY");
    layer_add_child((Layer *)slide1, text_layer_get_layer(memory_title_text_layer));

    memory_bar = progress_bar_layer_create((GRect) {
        .origin = { 5, 37 }, .size = { 134, 5 }
    });
void set_invert_color(bool invert) {
  if (invert && inverter_layer == NULL) {
    // Add inverter layer
    Layer *window_layer = window_get_root_layer(window);

    inverter_layer = inverter_layer_create(GRect(0, 0, 144, 168));
    layer_add_child(window_layer, inverter_layer_get_layer(inverter_layer));
  } else if (!invert && inverter_layer != NULL) {
    // Remove Inverter layer
    layer_remove_from_parent(inverter_layer_get_layer(inverter_layer));
    inverter_layer_destroy(inverter_layer);
    inverter_layer = NULL;
  }
  // No action required
}
Beispiel #25
0
static void setupBackground() {
   if (backgroundBlack) {
      if (inverterLayer) {
         layer_remove_from_parent(inverter_layer_get_layer(inverterLayer));
         inverter_layer_destroy(inverterLayer);
         inverterLayer = NULL;
      }
   } else {
      if (inverterLayer == NULL) {
         Layer *root_layer = window_get_root_layer(window);
         inverterLayer = inverter_layer_create(layer_get_frame(root_layer));
         layer_add_child(root_layer, inverter_layer_get_layer(inverterLayer));
      }
   }
}
Beispiel #26
0
void change_background(bool invert_format) {
  if (invert_format && trekinverter_layer == NULL) {
    // Add inverter layer
    Layer *window_layer = window_get_root_layer(window);

    trekinverter_layer = inverter_layer_create(GRect(0, 0, 144, 168));
    layer_add_child(window_layer, inverter_layer_get_layer(trekinverter_layer));
  } else if (!invert_format && trekinverter_layer != NULL) {
    // Remove Inverter layer
    layer_remove_from_parent(inverter_layer_get_layer(trekinverter_layer));
    inverter_layer_destroy(trekinverter_layer);
    trekinverter_layer = NULL;
  }
  // No action required
}
int main(void) {
	app_message_register_inbox_received(received_data);
	app_message_register_outbox_sent(data_sent);
	app_message_open(124, 50);

  
	inverter_layer = inverter_layer_create(GRect(0, 0, 144, 168));
	switchWindow(0);

	app_timer_register(300, timerTriggered, NULL);

	app_event_loop();

  inverter_layer_destroy(inverter_layer);
	window_stack_pop_all(false);
	return 0;
}
Beispiel #28
0
int main(void) {
  autoconfig_init();

  app_message_register_inbox_received(in_received_handler);

  center = GPoint(72, 74);

  window = window_create();
  window_stack_push(window, true);
  window_set_background_color(window, GColorBlack);

  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_frame(window_layer);
  layer = layer_create(bounds);
  layer_set_update_proc(layer, update_layer_callback);
  layer_add_child(window_layer, layer);

  inverter_layer = inverter_layer_create(bounds);
  layer_set_hidden(inverter_layer_get_layer(inverter_layer), !getInverted());
  layer_add_child(window_layer, inverter_layer_get_layer(inverter_layer));

  custom_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_UNSTEADY_OVERSTEER_22));
  image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_PATTERN);

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

  handle_minute_tick(tick_time, MINUTE_UNIT);
  tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick);
  bluetooth_connection_service_subscribe(bluetooth_connection_handler);

  bluetooth_connected = bluetooth_connection_service_peek();

  app_event_loop();

  layer_destroy(layer);
  inverter_layer_destroy(inverter_layer);
  window_destroy(window);
  gbitmap_destroy(image);
  fonts_unload_custom_font(custom_font);
  tick_timer_service_unsubscribe();
  bluetooth_connection_service_unsubscribe();

  autoconfig_deinit();
}
Beispiel #29
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();
}
AuxiliaryLayer* auxiliary_layer_create(
    Watchface* watchface, bool visible, bool inverted
) {
    // This is a global variable because the frame of
    // `auxiliary->root_layer` is the size of Pebble's
    // screen (to remove hard-coded screen contsants)
    screen_size = layer_get_frame(watchface_get_layer(watchface));
    default_auxiliary_frame = GRect(0, 100, screen_size.size.w, 70);
    
    AuxiliaryLayer* auxiliary_layer = malloc(sizeof(AuxiliaryLayer));
    auxiliary_layer->watchface = watchface;
    
    auxiliary_layer->root_layer = layer_create(default_auxiliary_frame);
    
    GRect child_layer = GRect(
        0,                              0,
        default_auxiliary_frame.size.w, default_auxiliary_frame.size.h
    );
    
    auxiliary_layer->layer = layer_create(child_layer);
    
    layer_add_child(
        auxiliary_layer->root_layer,
        auxiliary_layer->layer
    );
    
    if(inverted) {
        auxiliary_layer->inverter_layer = inverter_layer_create(child_layer);
        
        layer_add_child(
            auxiliary_layer->root_layer,
            inverter_layer_get_layer(
                auxiliary_layer->inverter_layer
            )
        );
    }
    
    auxiliary_layer_set_visible(
        auxiliary_layer,
        watchface_get_ui_state(watchface)->weather_visible
    );
    
    
    return auxiliary_layer;
}