Example #1
0
void init() {
  memset(&time_digits_layers, 0, sizeof(time_digits_layers));
  memset(&time_digits_images, 0, sizeof(time_digits_images));
	
  const int inbound_size = 160;
  const int outbound_size = 160;
  app_message_open(inbound_size, outbound_size);  

  window = window_create();
  if (window == NULL) {
      return;
  }
	
    window_stack_push(window, true);
  
	background_color  = GColorBlack;
    window_set_background_color(window, background_color);
		
	Layer *window_layer = window_get_root_layer(window);

    GRect bounds = layer_get_frame(window_layer);
    path_layer = layer_create(bounds);
    layer_set_update_proc(path_layer, path_layer_update_callback);
    layer_add_child(window_layer, path_layer);

    // Pass the corresponding GPathInfo to initialize a GPath
    batt10 = gpath_create(&BATT10);
    batt20 = gpath_create(&BATT20);
    batt30 = gpath_create(&BATT30);
    batt40 = gpath_create(&BATT40);
    batt50 = gpath_create(&BATT50);
    batt60 = gpath_create(&BATT60);
    batt70 = gpath_create(&BATT70);
    batt80 = gpath_create(&BATT80);
    batt90 = gpath_create(&BATT90);
    batt100 = gpath_create(&BATT100);
  
	// Create time and date layers
    GRect dummy_frame = { {0, 0}, {0, 0} };
	
  for (int i = 0; i < TOTAL_TIME_DIGITS; ++i) {
    time_digits_layers[i] = bitmap_layer_create(dummy_frame);
    layer_add_child(window_layer, bitmap_layer_get_layer(time_digits_layers[i]));
  }

  time1_text_layer = text_layer_create(GRect(0, 64, 147, 30));
  text_layer_set_background_color(time1_text_layer, GColorClear);
  text_layer_set_text_color(time1_text_layer, GColorWhite);
  text_layer_set_text_alignment(time1_text_layer, GTextAlignmentCenter);
  text_layer_set_font(time1_text_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_HELVETICA_BOLD_24)));
  text_layer_set_text(time1_text_layer, time1_buffer);
  layer_add_child(window_get_root_layer(window), (Layer*) time1_text_layer);
  

  date_text_layer = text_layer_create(GRect(0, 128, 144, 20));
  text_layer_set_background_color(date_text_layer, GColorClear);
  text_layer_set_text_color(date_text_layer, GColorWhite);
  text_layer_set_text_alignment(date_text_layer, GTextAlignmentCenter);
  text_layer_set_font(date_text_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_HELVETICA_16)));
  text_layer_set_text(date_text_layer, date_buffer);
  layer_add_child(window_get_root_layer(window), (Layer*) date_text_layer);
  
  toggle_bluetooth(bluetooth_connection_service_peek());
  battery_state_service_subscribe(&update_battery_state);

  Tuplet initial_values[] = {
    TupletInteger(SWAP_KEY, persist_read_bool(SWAP_KEY)),
    TupletInteger(INVERT_KEY, persist_read_bool(INVERT_KEY)),
    TupletInteger(BLUETOOTHVIBE_KEY, persist_read_bool(BLUETOOTHVIBE_KEY)),
    TupletInteger(HOURLYVIBE_KEY, persist_read_bool(HOURLYVIBE_KEY)),
  };
  
  app_sync_init(&sync, sync_buffer, sizeof(sync_buffer), initial_values, ARRAY_LENGTH(initial_values),
      sync_tuple_changed_callback, NULL, NULL);
   
  appStarted = true;
  
  // Avoids a blank screen on watch start.
  time_t now = time(NULL);
  tick_handler(localtime(&now), DAY_UNIT + HOUR_UNIT + MINUTE_UNIT);
  tick_timer_service_subscribe(MINUTE_UNIT, (TickHandler) tick_handler);
	
  // update the battery on launch
  update_battery_state(battery_state_service_peek());
  bluetooth_connection_service_subscribe(bluetooth_connection_callback);
		
}
Example #2
0
static void window_load(Window *window) {
    Layer *window_layer = window_get_root_layer(window);

    GRect plus_frame = GRect(0, INPUT_TOP_Y-FIELD_HEIGHT, 144, FIELD_HEIGHT);
    s_plus_layer = layer_create(plus_frame);
    layer_set_bounds(s_plus_layer, (GRect){ .size = GSize(FIELD_WIDTH, FIELD_HEIGHT) });
Example #3
0
void init() {

	// Window
	window = window_create();
	window_stack_push(window, true /* Animated */);
	window_layer = window_get_root_layer(window);

	// Background image
	background_image_container = gbitmap_create_with_resource(
			RESOURCE_ID_IMAGE_BACKGROUND);
	background_layer = layer_create(GRECT_FULL_WINDOW);
	layer_set_update_proc(background_layer, &draw_background_callback);
	layer_add_child(window_layer, background_layer);

	// Date setup
	date_layer = text_layer_create(GRect(27, 115, 90, 21));
	text_layer_set_text_color(date_layer, GColorWhite);
	text_layer_set_text_alignment(date_layer, GTextAlignmentCenter);
	text_layer_set_background_color(date_layer, GColorClear);
	text_layer_set_font(date_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18));
	layer_add_child(window_layer, text_layer_get_layer(date_layer));

  init_double_time();
	draw_date();
  update_double_time();

	// Status setup
	icon_battery = gbitmap_create_with_resource(RESOURCE_ID_BATTERY_ICON);
	icon_battery_charge = gbitmap_create_with_resource(RESOURCE_ID_BATTERY_CHARGE);
	icon_bt = gbitmap_create_with_resource(RESOURCE_ID_BLUETOOTH);

	BatteryChargeState initial = battery_state_service_peek();
	battery_level = initial.charge_percent;
	battery_plugged = initial.is_plugged;
	battery_layer = layer_create(GRect(5,132,24,12)); //24*12
	layer_set_update_proc(battery_layer, &battery_layer_update_callback);
	layer_add_child(window_layer, battery_layer);

	bt_ok = bluetooth_connection_service_peek();
	bt_layer = layer_create(GRect(9,147,9,12)); //9*12
	layer_set_update_proc(bt_layer, &bt_layer_update_callback);
	layer_add_child(window_layer, bt_layer);

	// Hands setup
	hour_display_layer = layer_create(GRECT_FULL_WINDOW);
	layer_set_update_proc(hour_display_layer,
			&hour_display_layer_update_callback);
	layer_add_child(window_layer, hour_display_layer);

	hour_hand_path = gpath_create(&HOUR_HAND_PATH_POINTS);
	gpath_move_to(hour_hand_path, grect_center_point(&GRECT_FULL_WINDOW));

	minute_display_layer = layer_create(GRECT_FULL_WINDOW);
	layer_set_update_proc(minute_display_layer,
			&minute_display_layer_update_callback);
	layer_add_child(window_layer, minute_display_layer);

	minute_hand_path = gpath_create(&MINUTE_HAND_PATH_POINTS);
	gpath_move_to(minute_hand_path, grect_center_point(&GRECT_FULL_WINDOW));

	center_display_layer = layer_create(GRECT_FULL_WINDOW);
	layer_set_update_proc(center_display_layer,
			&center_display_layer_update_callback);
	layer_add_child(window_layer, center_display_layer);

	second_display_layer = layer_create(GRECT_FULL_WINDOW);
	layer_set_update_proc(second_display_layer,
			&second_display_layer_update_callback);
	layer_add_child(window_layer, second_display_layer);

	// Configurable inverse
#ifdef INVERSE
	full_inverse_layer = inverter_layer_create(GRECT_FULL_WINDOW);
	layer_add_child(window_layer, inverter_layer_get_layer(full_inverse_layer));
#endif

}
Example #4
0
        .showClock = false,
        .autoContinue = false,
        .annoyAfterRestExceeded = false,
    };
    PomTimer defaultTimer = (PomTimer){
        .completedPoms = 0,
        .lastPomHour = 0,
        .end = 0,
        .state = PomStateReady,
    };

    app.mainWindow = window_create();
    window_set_background_color(app.mainWindow, GColorWhite);
    window_set_click_config_provider(app.mainWindow, pomMainWindowClickProvider);
    
    app.workingTextLayer = text_layer_create(GRect(2, 2, windowSize.w, 50));
    text_layer_set_font(app.workingTextLayer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD));
    text_layer_set_background_color(app.workingTextLayer, GColorClear);
    
    app.timeTextLayer = text_layer_create(GRect(4, 45, 80, 30));
    text_layer_set_font(app.timeTextLayer, fonts_get_system_font(FONT_KEY_FONT_FALLBACK));
    text_layer_set_background_color(app.timeTextLayer, GColorClear);

    app.statusBarLayer = status_bar_layer_create();
    app.batteryLayer = layer_create(GRect(0, 0, 144, STATUS_BAR_LAYER_HEIGHT));
    layer_set_update_proc(app.batteryLayer, pomUpdateBatteryLayer);
    
    layer_add_child(window_get_root_layer(app.mainWindow), text_layer_get_layer(app.workingTextLayer));
    layer_add_child(window_get_root_layer(app.mainWindow), text_layer_get_layer(app.timeTextLayer));

#if USE_CONSOLE
Example #5
0
void m_MenuLayerDrawRowCallback(GContext *ctx, const Layer *cell_layer, MenuIndex *cell_index, void *callback_context)
{
    graphics_context_set_text_color(ctx, GColorBlack);

    if (md_unread(cell_index->row))
    {
    	graphics_text_draw(ctx, "U", fonts_get_system_font(FONT_KEY_GOTHIC_14), GRect(0,10,11,14), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
    }
    if (md_isNew(cell_index->row))
    {
    	graphics_text_draw(ctx, "N", fonts_get_system_font(FONT_KEY_GOTHIC_14), GRect(0,45-18,11,14), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
    }

    GFont fSender;
    int fSenderHeight;
    GFont fSubject;
    int fSubjectHeight;
    switch (md_inboxTextSize())
    {
    case eSize_Small:
    	fSender = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);
    	fSubject = fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD);
        fSenderHeight = 18;
        fSubjectHeight = 16;
    	break;
    case eSize_Large:
    	fSender = fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD);
    	fSubject = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
        fSenderHeight = 28;
        fSubjectHeight = 26;
    	break;
    case eSize_Regular:
    default:
    	fSender = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
    	fSubject = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);
        fSenderHeight = 24;
        fSubjectHeight = 20;
    	break;
    }

	graphics_text_draw(ctx, md_sender(cell_index->row),
			fSender,
			GRect(12,0,cell_layer->bounds.size.w - 12,fSenderHeight),
			GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
	graphics_text_draw(ctx, md_subject(cell_index->row),
			fSubject,
			GRect(12,fSenderHeight + 1,cell_layer->bounds.size.w - 12,fSubjectHeight),
			GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);

    if (md_isDeleted(cell_index->row))
    {
    	int SenlinePos = fSenderHeight + fSenderHeight/2;
    	int SublinePos = (fSubjectHeight/3) *2;
		graphics_context_set_stroke_color(ctx, GColorBlack);
		graphics_draw_line(ctx, GPoint(12, SenlinePos), GPoint(cell_layer->bounds.size.w - 12, SenlinePos));
		graphics_draw_line(ctx, GPoint(12, SenlinePos + 1), GPoint(cell_layer->bounds.size.w - 12, SenlinePos + 1));
		graphics_draw_line(ctx, GPoint(12, SublinePos), GPoint(cell_layer->bounds.size.w - 12, SublinePos));
		graphics_draw_line(ctx, GPoint(12, SublinePos+1), GPoint(cell_layer->bounds.size.w - 12, SublinePos + 1));
    }
	//menu_cell_basic_draw(ctx, cell_layer, md_sender(cell_index->row), md_subject(cell_index->row),
	//		&N_IMG.bmp // icon, tod
	//	);
/*	menu_cell_basic_draw(ctx, cell_layer,
			"Foo",
			"Bar",
			0 // icon, todo
		);
*/
}
Example #6
0
static void background_update(Layer *layer, GContext *ctx) {
  #ifdef PBL_COLOR
    graphics_context_set_fill_color(ctx, GColorMidnightGreen);
    graphics_fill_rect(ctx, GRect(5,130,5,15), 0, GCornersAll);    
    graphics_fill_rect(ctx, GRect(5,110,5,15), 0, GCornersAll);    
    graphics_fill_rect(ctx, GRect(5,90,5,15), 0, GCornersAll);    
    graphics_fill_rect(ctx, GRect(5,70,5,15), 0, GCornersAll);    
    graphics_fill_rect(ctx, GRect(5,50,5,15), 0, GCornersAll);    
    graphics_fill_rect(ctx, GRect(5,29,5,15), 0, GCornersAll);  
    gpath_draw_filled(ctx, level1);
    gpath_draw_filled(ctx, level2);
    gpath_draw_filled(ctx, level3);
    gpath_draw_filled(ctx, level4);
    gpath_draw_filled(ctx, level5);
    gpath_draw_filled(ctx, level6);
  #else
    graphics_context_set_stroke_color(ctx, GColorWhite);
    graphics_draw_rect(ctx, GRect(5,130,5,15));    
    graphics_draw_rect(ctx, GRect(5,110,5,15));    
    graphics_draw_rect(ctx, GRect(5,90,5,15));    
    graphics_draw_rect(ctx, GRect(5,70,5,15));    
    graphics_draw_rect(ctx, GRect(5,50,5,15));    
    graphics_draw_rect(ctx, GRect(5,29,5,15));  
    gpath_draw_outline(ctx, level1);
    gpath_draw_outline(ctx, level2);
    gpath_draw_outline(ctx, level3);
    gpath_draw_outline(ctx, level4);
    gpath_draw_outline(ctx, level5);
    gpath_draw_outline(ctx, level6);
  #endif
}
Example #7
0
void handle_init(AppContextRef ctx) { 
  if (clock_is_24h_style()) {
    format_time = "%H:%M";
    format_date = "%d-%m-%Y";
  }
  else {
    format_time = "%I:%M";
    format_date = "%m/%d/%Y";
  }
  
  update_time();

  resource_init_current_app(&APP_RESOURCES);
  ubuntu_time = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_UBUNTU_BOLD_50));
  ubuntu_date = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_UBUNTU_16));
  ubuntu_text = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_UBUNTU_10));

  window_init(&window, MY_NAME);
  window_stack_push(&window, true);

  text_layer_init(&layer_time, GRect(0, 20, 144, 54));
  text_layer_set_font(&layer_time, ubuntu_time);
  text_layer_set_text(&layer_time, (const char*)&string_time);
  text_layer_set_text_alignment(&layer_time, GTextAlignmentCenter);
  layer_add_child(window_get_root_layer(&window), &layer_time.layer);

  text_layer_init(&layer_date, GRect(0, 74, 144, 20));
  text_layer_set_font(&layer_date, ubuntu_date);
  text_layer_set_text(&layer_date, (const char*)&string_date);
  text_layer_set_text_alignment(&layer_date, GTextAlignmentCenter);
  layer_add_child(window_get_root_layer(&window), &layer_date.layer);
    
  bitmap_layer_init(&layer_battery, GRect(8, 140, 14, 8));
  bitmap_layer_set_bitmap(&layer_battery, &bitmap_battery.bmp);
  layer_add_child(window_get_root_layer(&window), &layer_battery.layer);

  bitmap_layer_init(&layer_signal, GRect(8, 150, 14, 8));
  bitmap_layer_set_bitmap(&layer_signal, &bitmap_signal.bmp);
  layer_add_child(window_get_root_layer(&window), &layer_signal.layer);
  
  bmp_init_container(RESOURCE_ID_PNG_CALL, &layer_call);
  layer_call.layer.layer.frame.origin.x = 142 - 8 - 9;
  layer_call.layer.layer.frame.origin.y = 140;
  layer_add_child(window_get_root_layer(&window), &layer_call.layer.layer);

  bmp_init_container(RESOURCE_ID_PNG_MESSAGE, &layer_message);
  layer_message.layer.layer.frame.origin.x = 142 - 8 - 9;
  layer_message.layer.layer.frame.origin.y = 150;
  layer_add_child(window_get_root_layer(&window), &layer_message.layer.layer);
  
  text_layer_init(&layer_numbercall, GRect(101, 138, 22, 10));
  text_layer_set_font(&layer_numbercall, ubuntu_text);
  text_layer_set_text(&layer_numbercall, (const char*)&string_call);
  text_layer_set_text_alignment(&layer_numbercall, GTextAlignmentRight);
  layer_add_child(window_get_root_layer(&window), &layer_numbercall.layer);

  text_layer_init(&layer_numbermessage, GRect(101, 148, 22, 10));
  text_layer_set_font(&layer_numbermessage, ubuntu_text);
  text_layer_set_text(&layer_numbermessage, (const char*)&string_message);
  text_layer_set_text_alignment(&layer_numbermessage, GTextAlignmentRight);
  layer_add_child(window_get_root_layer(&window), &layer_numbermessage.layer);  
  
  update_stats();
 
  request_command(REACTOR_COMMAND_REFRESH);
}
// --------------------------------------------------------
//			page_start_tick()
//		(called from TempusFugit tick handler)
// --------------------------------------------------------
void page_start_tick(int tick_count) {

	if(tick_count < (NUMBER_OF_IMAGES - 1)) {		// Increment tick_count & Animate Logo
		layer_remove_from_parent(&page_start_logo_data.image_container[tick_count].layer.layer);
		page_start_logo_data.current_logo = page_start_logo_data.current_logo+1;
		layer_set_frame(&page_start_logo_data.image_container[page_start_logo_data.current_logo].layer.layer, GRect(24,2,100,115));
		layer_add_child(&tf_start_window.layer, &page_start_logo_data.image_container[page_start_logo_data.current_logo].layer.layer);
	}

	else if (tick_count == NUMBER_OF_IMAGES){		// Show "Tempus" field
		layer_add_child(&tf_start_window.layer, &tempus_layer.layer);	
	}
	else if (tick_count == (NUMBER_OF_IMAGES+1)){	// Show "Fugit" field
		layer_add_child(&tf_start_window.layer, &fugit_layer.layer);	
	}	
	else if (tick_count == (NUMBER_OF_IMAGES+2)){	// Show version field
		layer_add_child(&tf_start_window.layer, &version_layer.layer);	
	}


}  // page_start_tick(int tick_count)
Example #9
0
void calendar_layer_update_callback(Layer *me, GContext* ctx) {
  (void)me;

  int mon = currentTime->tm_mon;
  int year = currentTime->tm_year + 1900;
  int daysLastMonth = daysInMonth(mon-1, year);
  int daysThisMonth = daysInMonth(mon, year);
  int calendarDays[21];
  
  for (int i = 0; i < 21; i++) {
    int day = currentTime->tm_mday - currentTime->tm_wday + i;
    if (day <= 0) {
      calendarDays[i] = day + daysLastMonth;
    
    }
    else if (day > daysThisMonth) {
      calendarDays[i] = day - daysThisMonth;
    }
    else {
      calendarDays[i] = day;
    }
  }
  
// ---------------------------
// Now that we've calculated which days go where, we'll move on to the display logic.
// ---------------------------

  int weeks  =  3;  // always display 3 weeks: # previous, current, # next
    
  GFont normal = fonts_get_system_font(FONT_KEY_GOTHIC_14); // fh = 16
  GFont bold   = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD); // fh = 22
  GFont current = normal;
  int font_vert_offset = 0;
  
  char daysOfWeek[7][3] = {
    "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"
  };

  // generate a light background for the calendar grid
  setInvColors(ctx);
  graphics_fill_rect(ctx, GRect (CAL_LEFT + CAL_GAP, CAL_HEIGHT - CAL_GAP, DEVICE_WIDTH - 2 * (CAL_LEFT + CAL_GAP), CAL_HEIGHT * weeks), 0, GCornerNone);
  setColors(ctx);

  for (int col = 0; col < CAL_DAYS; col++) {
  // Adjust labels by specified offset
    int weekday = col;
    if (weekday > 6) { weekday -= 7; }

    if (col == currentTime->tm_wday) {
      current = bold;
      font_vert_offset = -3;
    }

    // draw the cell text
    graphics_draw_text(ctx, daysOfWeek[weekday], current, GRect(CAL_WIDTH * col + CAL_LEFT + CAL_GAP, CAL_GAP + font_vert_offset, CAL_WIDTH, CAL_HEIGHT), GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL); 
    if (col == currentTime->tm_wday) {
      current = normal;
      font_vert_offset = 0;
    }
  }
    
  current = normal;
  font_vert_offset = 0;

  int show_last = 0;
  
  // draw the individual calendar rows/columns
  int week = 0;
  int specialRow = show_last+1;
    
  for (int row = 1; row <= 3; row++) {
    week++;
    for (int col = 0; col < CAL_DAYS; col++) {
      if ( row == specialRow && col == currentTime->tm_wday) {
        setInvColors(ctx);
        current = bold;
        font_vert_offset = -3;
      }

      // draw the cell background
      graphics_fill_rect(ctx, GRect (CAL_WIDTH * col + CAL_LEFT + CAL_GAP, CAL_HEIGHT * week, CAL_WIDTH - CAL_GAP, CAL_HEIGHT - CAL_GAP), 0, GCornerNone);

      // draw the cell text
      char date_text[3];
      snprintf(date_text, sizeof(date_text), "%d", calendarDays[col + 7 * (row - 1)]);
      graphics_draw_text(ctx, date_text, current, GRect(CAL_WIDTH * col + CAL_LEFT, CAL_HEIGHT * week - CAL_GAP + font_vert_offset, CAL_WIDTH, CAL_HEIGHT), GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL); 

      if ( row == specialRow && col == currentTime->tm_wday) {
        setColors(ctx);
        current = normal;
        font_vert_offset = 0;
      }
    }
  }
}
Example #10
0
static void main_window_load(Window *window) {
  
  //APP_LOG(APP_LOG_LEVEL_ERROR, "In Main_window_load");
  // Use system font, apply it and add to Window
  s_3_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_PTN_64));
  s_2_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_PTN_59));
  s_4_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_PTN_50));
  s_6_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_PTN_47));
 
  
  s_title_font = fonts_get_system_font(FONT_KEY_GOTHIC_14);
  s_large_title_font = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
  s_medium_title_font = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);

  inverter = inverter_layer_create(GRect(0,0,144,168));
  layer_set_bounds(inverter_layer_get_layer(inverter),GRectZero);
  
  flash = inverter_layer_create(GRect(2,7,7,7));
  
  int jj;
  for (jj = 0; jj < 6; jj++) {
  dataInverter[jj] = inverter_layer_create(GRect(0,0,144,168));
  layer_set_bounds(inverter_layer_get_layer(dataInverter[jj]),GRectZero);  
  }
  
  // Create Display RectAngles
  
  // Six data fields & their titles
  #define SIX_FIELD_INDEX 0
  #define SIX_FIELD_MAX 5
  s_data_layer[0] = text_layer_create(GRect(0, 2, 71, 49));
  s_data_title[0] = text_layer_create(GRect(0, 49, 71, 15));

  s_data_layer[1] = text_layer_create(GRect(73, 2, 71, 49));
  s_data_title[1] = text_layer_create(GRect(73, 49, 71, 15));
  
  s_data_layer[2] = text_layer_create(GRect(0, 53, 71, 49));
  s_data_title[2] = text_layer_create(GRect(0, 102, 71, 14));
  
  s_data_layer[3] = text_layer_create(GRect(73, 53, 71, 49));
  s_data_title[3] = text_layer_create(GRect(73, 102, 71, 14));
  
  s_data_layer[4] = text_layer_create(GRect(0, 105, 71, 49));
  s_data_title[4] = text_layer_create(GRect(0, 154, 71, 15));
  
  s_data_layer[5] = text_layer_create(GRect(73, 105, 71, 49));
  s_data_title[5] = text_layer_create(GRect(73, 154, 71, 15));
  
  // Two data fields & their titles
  #define TWO_FIELD_INDEX 6
  #define TWO_FIELD_MAX 7
  s_data_layer[6] = text_layer_create(GRect(0, 2, 288, 60));
  layer_set_frame((Layer *) s_data_layer[6], GRect(0, 2, 144, 60));
  s_data_title[6] = text_layer_create(GRect(0, 64, 144, 28));
  
  s_data_layer[7] = text_layer_create(GRect(0, 79, 288, 60));
  layer_set_frame((Layer *) s_data_layer[7], GRect(0, 79, 144, 60));
  s_data_title[7] = text_layer_create(GRect(0, 140, 144, 28));

  
  // Four data fields & their titles
  #define FOUR_FIELD_INDEX 8
  #define FOUR_FIELD_MAX 11
  s_data_layer[8] = text_layer_create(GRect(0, 12, 142, 51));
  layer_set_frame((Layer *) s_data_layer[8], GRect(0, 12, 71, 51));
  s_data_title[8] = text_layer_create(GRect(0, 65, 71, 24));
  
  s_data_layer[9] = text_layer_create(GRect(73, 12, 71, 51));
  s_data_title[9] = text_layer_create(GRect(73, 65, 71, 24));
  
  s_data_layer[10] = text_layer_create(GRect(0, 91, 142, 51));
  layer_set_frame((Layer *) s_data_layer[10], GRect(0, 91, 71, 51));
  s_data_title[10] = text_layer_create(GRect(0, 144, 71, 24));
  
  s_data_layer[11] = text_layer_create(GRect(73, 91,  71, 51));
  s_data_title[11] = text_layer_create(GRect(73, 144, 71, 24));
  
  // Three fields - One big, two small
  //#define THREE_FIELD_INDEX 12
  #define THREE_FIELD_MAX 14
  s_data_layer[12] = text_layer_create(GRect(0, 10, 432, 65));
  layer_set_frame((Layer *) s_data_layer[12], GRect(0, 10, 144, 65));
  s_data_title[12] = text_layer_create(GRect(0, 75, 144, 28));

  s_data_layer[13] = text_layer_create(GRect(0, 91, 150, 51));
  layer_set_frame((Layer *) s_data_layer[13], GRect(0, 91, 71, 51));
  s_data_title[13] = text_layer_create(GRect(0, 144, 71, 24));
  
  
  //s_data_layer[14] = text_layer_create(GRect(73, 91, 142, 51));
  //layer_set_frame((Layer *) s_data_layer[14], GRect(73, 91, 71, 51));
  s_data_layer[14] = text_layer_create(GRect(73, 91,  71, 51));
  s_data_title[14] = text_layer_create(GRect(73, 144, 71, 24));
  
  
  // Top title
  s_data_layer[TITLE_INDEX] = text_layer_create(GRect(0, 0, 144, 16));
  
  

  // Set up top title area
    text_layer_set_background_color(s_data_layer[TITLE_INDEX], GColorBlack);
    text_layer_set_text_color(s_data_layer[TITLE_INDEX], GColorWhite);
    text_layer_set_text_alignment(s_data_layer[TITLE_INDEX], GTextAlignmentCenter);
    text_layer_set_text(s_data_layer[TITLE_INDEX], "StartLine");
    text_layer_set_font(s_data_layer[TITLE_INDEX], s_title_font);
    layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_data_layer[TITLE_INDEX])); 
 
  window_set_background_color(window, GColorBlack);
  // Set up the messgage layer
  messageLayer = text_layer_create(GRect(10,30,124,120));
  text_layer_set_background_color(messageLayer, GColorClear);
  text_layer_set_text_color(messageLayer, GColorWhite);
  text_layer_set_text_alignment(messageLayer, GTextAlignmentCenter);
  text_layer_set_font(messageLayer, s_large_title_font);
  
  

  
  titleLayer = layer_create(GRect(0, 0, 144, 168));
  layer_insert_below_sibling(titleLayer, (Layer *)s_data_layer[TITLE_INDEX]);
  
  
  dataLayer = layer_create(GRect(0, 0, 144, 168));
  layer_insert_below_sibling(dataLayer, titleLayer); 
 
  
  int i;
  for (i =0; i < TITLE_INDEX; i++)
    {
    //Data

    text_layer_set_background_color(s_data_layer[i], GColorClear);
    text_layer_set_text_color(s_data_layer[i], GColorWhite);
    text_layer_set_text_alignment(s_data_layer[i], GTextAlignmentCenter);
    text_layer_set_overflow_mode(s_data_layer[i], GTextOverflowModeWordWrap);
    layer_add_child(dataLayer, text_layer_get_layer(s_data_layer[i]));
    
    //Title

    text_layer_set_background_color(s_data_title[i], GColorClear);
    text_layer_set_text_color(s_data_title[i], GColorWhite);
    text_layer_set_text_alignment(s_data_title[i], GTextAlignmentCenter);
    
    if (i >= SIX_FIELD_INDEX && i <= SIX_FIELD_MAX) // Small title fonts on the 6 field layout
      {
      text_layer_set_font(s_data_layer[i], s_6_font);    
      text_layer_set_font(s_data_title[i], s_title_font);
    }
    else if (i >= TWO_FIELD_INDEX && i <= TWO_FIELD_MAX) // This is 2 fields
      {
      text_layer_set_font(s_data_layer[i], s_2_font); 
      text_layer_set_font(s_data_title[i], s_large_title_font);
    }

    else if (i >= FOUR_FIELD_INDEX && i <= FOUR_FIELD_MAX) // 4 field layout
      {
      text_layer_set_font(s_data_layer[i], s_4_font); 
      text_layer_set_font(s_data_title[i], s_medium_title_font);
    }
    else if (i >= THREE_FIELD_INDEX && i <= THREE_FIELD_MAX)
      {
      if (i == THREE_FIELD_INDEX) // First field is big
        {
        text_layer_set_font(s_data_layer[i], s_3_font); 
        text_layer_set_font(s_data_title[i], s_large_title_font);
      } else
        {
        text_layer_set_font(s_data_layer[i], s_4_font);    
        text_layer_set_font(s_data_title[i], s_medium_title_font);        
      }
    }      
   
    layer_add_child(titleLayer, text_layer_get_layer(s_data_title[i]));
    
  }
  
 layer_add_child(window_get_root_layer(window), inverter_layer_get_layer(inverter));


  int ii;
  for (ii = 0; ii < 6; ii++) {
     layer_add_child(window_get_root_layer(window), inverter_layer_get_layer(dataInverter[ii]));
  }
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(messageLayer)); 

   layer_add_child(window_get_root_layer(window), inverter_layer_get_layer(flash));

  
  // Go find a screen with some fields in use
  for (currentScreen = 0; screens[currentScreen].num_fields == 0; currentScreen++)
    ;

  // Add the padlock icon - steals the rest of my heap!!
  s_padlockLayer = bitmap_layer_create(GRect(133, 3, 8, 11));
  s_res_padlock = gbitmap_create_with_resource(RESOURCE_ID_PADLOCK);
  bitmap_layer_set_bitmap(s_padlockLayer, s_res_padlock);
  layer_add_child(window_get_root_layer(window), (Layer *)s_padlockLayer);
  layer_set_hidden((Layer *)s_padlockLayer, configLock == 1);
  
  // And make it the current screen
  updatescreen(currentScreen,"00");
}
        .disappear = (WindowHandler)handle_disappear,
		.load = handle_load,
		.unload = handle_unload,
    });

	window_set_fullscreen(&tf_start_window, true);	// remove top bar and replace with debug layer 
	window_set_background_color(&tf_start_window, GColorBlack);

	window_set_click_config_provider(&tf_start_window, (ClickConfigProvider) click_config_provider);
	

// Init child_a layer at (0,0) and size (40, 46):
//	layer_init(&page_start_logo_data.image_container[0].layer.layer, GRect(0, 0, 40, 46));

	page_start_logo_data.current_logo = 0;		// initialize logo tracking
	layer_set_frame(&page_start_logo_data.image_container[0].layer.layer, GRect(24,2,100,115));
	layer_add_child(&tf_start_window.layer, &page_start_logo_data.image_container[0].layer.layer);

// set up Text layers
//TextLayer tempus_layer;
//TextLayer fugit_layer;

	text_layer_init(&tempus_layer, GRect (21, 108, 70, 28));
	text_layer_set_text(&tempus_layer, "Tempus");
	text_layer_set_background_color(&tempus_layer, GColorBlack);
	text_layer_set_text_color(&tempus_layer, GColorWhite);
	text_layer_set_font(&tempus_layer, norm24);

	text_layer_init(&fugit_layer, GRect (86, 108, 75, 28));
	text_layer_set_text(&fugit_layer, "Fugit");
	text_layer_set_background_color(&fugit_layer, GColorBlack);
Example #12
0
void doDataRevert(int field)
  {
  layer_set_bounds(inverter_layer_get_layer(dataInverter[field]), GRect(0,0,0,0));
}
Example #13
0
// Program initializer
void init(void){
  // Create a window and text layer
  window = window_create();
  window_set_background_color(window, GColorBlack);
  
  // Read settings
  if (persist_exists(KEY_MILITARY_TIME)) {
    militaryTime = persist_read_bool(KEY_MILITARY_TIME);
  }
  
  if (persist_exists(KEY_TEMPC)) {
    tempC = persist_read_bool(KEY_TEMPC);
  }
  
  if (persist_exists(KEY_DATEDDMM)) {
    dateDDMM = persist_read_bool(KEY_DATEDDMM);
  }
  
  // Initialize font for time
  s_orbitron_font_36 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ORBITRON_LIGHT_36));
  s_orbitron_font_20 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ORBITRON_LIGHT_20));
  s_orbitron_font_15 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ORBITRON_LIGHT_15));
  
  // Initialize time angles decorations
  s_time_angles_bmp = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_TIME_ANGLES);
  s_seconds_arows_layer = bitmap_layer_create(GRect(0, 56, 144, 38));
  bitmap_layer_set_bitmap(s_seconds_arows_layer, s_time_angles_bmp);
  layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(s_seconds_arows_layer));
  
  // Initialize secnods arows decorations
  s_time_angles_bmp = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_SECOND_AROWS1);
  s_time_angles_layer = bitmap_layer_create(GRect(43, 107, 55, 5));
  bitmap_layer_set_bitmap(s_time_angles_layer, s_time_angles_bmp);
  layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(s_time_angles_layer));
  
  // Initialize hours layers
  init_text_layer(&hours_1st_layer, GRect(4, 54, 32, 36), s_orbitron_font_36);
  init_text_layer(&hours_2nd_layer, GRect(35, 54, 32, 36), s_orbitron_font_36);
  
  init_text_layer(&minutes_1st_layer, GRect(75, 54, 32, 36), s_orbitron_font_36);
  init_text_layer(&minutes_2nd_layer, GRect(105, 54, 32, 36), s_orbitron_font_36);
  
  init_text_layer(&seconds_1st_layer, GRect(53, 95, 18, 20), s_orbitron_font_20);
  init_text_layer(&seconds_2nd_layer, GRect(71, 95, 18, 20), s_orbitron_font_20);
  
  init_text_layer(&date_1st_layer, GRect(6, 140, 18, 20), s_orbitron_font_20);
  init_text_layer(&date_2nd_layer, GRect(19, 140, 28, 20), s_orbitron_font_20);
  
  init_text_layer(&date_delimiter_layer, GRect(35, 140, 28, 20), s_orbitron_font_20);
      
  init_text_layer(&date_3rd_layer, GRect(57, 140, 18, 20), s_orbitron_font_20);
  init_text_layer(&date_4th_layer, GRect(75, 140, 18, 20), s_orbitron_font_20);
  
  init_text_layer(&day_of_week_layer, GRect(98, 140, 40, 20), s_orbitron_font_20);

  // Initialize weather layer
  s_weather_layer = text_layer_create(GRect(0, -2, 144, 25));
  text_layer_set_background_color(s_weather_layer, GColorClear);
  text_layer_set_text_color(s_weather_layer, GColorWhite);
  text_layer_set_text_alignment(s_weather_layer, GTextAlignmentCenter);
  text_layer_set_font(s_weather_layer, s_orbitron_font_20);
  text_layer_set_text(s_weather_layer, "Loading...");
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_weather_layer));
   weatherCountdown = weatherCountdownInit; // Time to re-read weather values
  
  // Initialize battery lightning
  s_battery_lightning_bmp = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BATTERY_LIGHTNING);
  s_battery_lightning_layer = bitmap_layer_create(GRect(40, 39, 17, 14));
  bitmap_layer_set_bitmap(s_battery_lightning_layer, s_battery_lightning_bmp);
  layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(s_battery_lightning_layer));

  // Initialize battery layer
  s_battery_info_layer = text_layer_create(GRect(60, 36, 47, 25));
  text_layer_set_background_color(s_battery_info_layer, GColorClear);
  text_layer_set_text_color(s_battery_info_layer, GColorWhite);
  text_layer_set_text_alignment(s_battery_info_layer, GTextAlignmentLeft);
  text_layer_set_font(s_battery_info_layer, s_orbitron_font_15);
  text_layer_set_text(s_battery_info_layer, "--%");
  
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_battery_info_layer));
  
  // To launch time changing handler
  time_t now = time(NULL);
  handle_timechanges(localtime(&now), SECOND_UNIT);
  
  // Subscribe to time changing events
  tick_timer_service_subscribe(SECOND_UNIT, handle_timechanges);
  
  // Push the window
  window_stack_push(window, true);

  // Register callbacks for messages system AppMessage
  app_message_register_inbox_received(inbox_received_callback);
  app_message_register_inbox_dropped(inbox_dropped_calback);
  app_message_register_outbox_failed(outbox_failed_callback);
  app_message_register_outbox_sent(outbox_sent_callback);
  
  // Register battery state callback
  battery_state_service_subscribe(battery_callback);
  battery_callback(battery_state_service_peek()); // get initial value
  
  // Open AppMessage
  app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum());
}
void weather_layer_create(GRect frame, Window *window)
{
  // Create a new layer with some extra space to save our custom Layer infos
  weather_layer = layer_create_with_data(frame, sizeof(WeatherLayerData));
  WeatherLayerData *wld = layer_get_data(weather_layer);

  large_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FUTURA_30));
  small_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FUTURA_17));

  wld->primary_icon_size = 45;
  wld->hourly_icon_size = 30;

  // Add background layer
  wld->temp_layer_background = text_layer_create(GRect(0, 0, 144, 80));
  text_layer_set_background_color(wld->temp_layer_background, GColorCyan);
  layer_add_child(weather_layer, text_layer_get_layer(wld->temp_layer_background));

  // Primary temperature layer
  wld->primary_temp_layer = text_layer_create(GRect(2, 38, 70, 35));
  text_layer_set_background_color(wld->primary_temp_layer, GColorClear);
  text_layer_set_text_alignment(wld->primary_temp_layer, GTextAlignmentCenter);
  text_layer_set_font(wld->primary_temp_layer, large_font);
  layer_add_child(weather_layer, text_layer_get_layer(wld->primary_temp_layer));

  
  wld->h1_time_layer = text_layer_create(GRect(68, 5, 30, 20));
  text_layer_set_text_color(wld->h1_time_layer, GColorBlack);
  text_layer_set_background_color(wld->h1_time_layer, GColorClear);
  text_layer_set_text_alignment(wld->h1_time_layer, GTextAlignmentCenter);
  layer_add_child(weather_layer, text_layer_get_layer(wld->h1_time_layer));

  wld->h1_temp_layer = text_layer_create(GRect(67, 47, 38, 20));
  text_layer_set_text_color(wld->h1_temp_layer, GColorBlack);
  text_layer_set_background_color(wld->h1_temp_layer, GColorClear);
  text_layer_set_text_alignment(wld->h1_temp_layer, GTextAlignmentCenter);
  text_layer_set_font(wld->h1_temp_layer, small_font);
  layer_add_child(weather_layer, text_layer_get_layer(wld->h1_temp_layer));
  
  // Hour1 bitmap layer
  wld->h1_icon_layer = bitmap_layer_create(GRect(68, 20, wld->hourly_icon_size, wld->hourly_icon_size));
  bitmap_layer_set_background_color(wld->h1_icon_layer, GColorClear);
  layer_add_child(weather_layer, bitmap_layer_get_layer(wld->h1_icon_layer));

  
  wld->h2_time_layer = text_layer_create(GRect(108, 5, 30, 20));
  text_layer_set_text_color(wld->h2_time_layer, GColorBlack);
  text_layer_set_background_color(wld->h2_time_layer, GColorClear);
  text_layer_set_text_alignment(wld->h2_time_layer, GTextAlignmentCenter);
  layer_add_child(weather_layer, text_layer_get_layer(wld->h2_time_layer));

  wld->h2_temp_layer = text_layer_create(GRect(106, 47, 38, 20));
  text_layer_set_text_color(wld->h2_temp_layer, GColorBlack);
  text_layer_set_background_color(wld->h2_temp_layer, GColorClear);
  text_layer_set_text_alignment(wld->h2_temp_layer, GTextAlignmentCenter);
  text_layer_set_font(wld->h2_temp_layer, small_font);
  layer_add_child(weather_layer, text_layer_get_layer(wld->h2_temp_layer));
   
  // Hour2 bitmap layer
  wld->h2_icon_layer = bitmap_layer_create(GRect(107, 20, wld->hourly_icon_size, wld->hourly_icon_size));
  bitmap_layer_set_background_color(wld->h2_icon_layer, GColorClear);
  layer_add_child(weather_layer, bitmap_layer_get_layer(wld->h2_icon_layer));

  // Primary bitmap layer
  wld->primary_icon_layer = bitmap_layer_create(PRIMARY_ICON_NORMAL_FRAME);
  bitmap_layer_set_background_color(wld->primary_icon_layer, GColorClear);
  layer_add_child(weather_layer, bitmap_layer_get_layer(wld->primary_icon_layer));

  wld->loading_layer = layer_create(GRect(43, 27, 50, 20));
  layer_set_update_proc(wld->loading_layer, weather_animate_update);
  layer_add_child(weather_layer, wld->loading_layer);

  wld->primary_icons = gbitmap_create_with_resource(RESOURCE_ID_ICON_45X45);
  wld->hourly_icons  = gbitmap_create_with_resource(RESOURCE_ID_ICON_30X30);

  wld->primary_icon = NULL;
  wld->h1_icon = NULL;
  wld->h2_icon = NULL;

  layer_add_child(window_get_root_layer(window), weather_layer);
}
void handle_init(AppContextRef ctx) {
  (void)ctx;

  window_init(&window, "Circling Hours");
  window_stack_push(&window, true);
	window_set_background_color(&window, GColorBlack);

  resource_init_current_app(&APP_RESOURCES);

	first_run = "true";
	hours_word.old_text = hours_word.text;

  bmp_init_container(RESOURCE_ID_IMAGE_HOUR_BG, &background_image_container);
  layer_add_child(&window.layer, &background_image_container.layer.layer);


//	font_minutes = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ARIAL_BLACK_50));
//	text_layer(&font_minutes_word, GRect(0, 40, 143, 100), font_minutes);
/*  add to resource_map.json:
  {
				"type":"font",
				"defName":"FONT_ARIAL_BLACK_50",
				"file":"fonts/Arial-Black.ttf"
  }
*/

// much less space needed because font is built in
//	font_minutes = fonts_get_system_font(FONT_KEY_GOTHAM_42_MEDIUM_NUMBERS);
	font_minutes = fonts_get_system_font(FONT_KEY_GOTHAM_42_BOLD);
	text_layer(&font_minutes_word, GRect(0, 58, 143, 50), font_minutes);

	text_layer_set_text_alignment(&font_minutes_word.layer, GTextAlignmentCenter);
	
	rotbmp_init_container(RESOURCE_ID_IMAGE_HOUR_1, &hour_image_container_1);
	rotbmp_init_container(RESOURCE_ID_IMAGE_HOUR_2, &hour_image_container_2);
	rotbmp_init_container(RESOURCE_ID_IMAGE_HOUR_3, &hour_image_container_3);
	rotbmp_init_container(RESOURCE_ID_IMAGE_HOUR_4, &hour_image_container_4);
	rotbmp_init_container(RESOURCE_ID_IMAGE_HOUR_5, &hour_image_container_5);
	rotbmp_init_container(RESOURCE_ID_IMAGE_HOUR_6, &hour_image_container_6);
	rotbmp_init_container(RESOURCE_ID_IMAGE_HOUR_7, &hour_image_container_7);
	rotbmp_init_container(RESOURCE_ID_IMAGE_HOUR_8, &hour_image_container_8);
	rotbmp_init_container(RESOURCE_ID_IMAGE_HOUR_9, &hour_image_container_9);
	rotbmp_init_container(RESOURCE_ID_IMAGE_HOUR_10, &hour_image_container_10);
	rotbmp_init_container(RESOURCE_ID_IMAGE_HOUR_11, &hour_image_container_11);
	rotbmp_init_container(RESOURCE_ID_IMAGE_HOUR_12, &hour_image_container_12);

	//GCompOpAssign, GCompOpAssignInverted, GCompOpOr, GCompOpAnd, GCompOpClear
	GCompOp mode = GCompOpAssign;
  hour_image_container_1.layer.compositing_mode = mode;
  hour_image_container_2.layer.compositing_mode = mode;
  hour_image_container_3.layer.compositing_mode = mode;
  hour_image_container_4.layer.compositing_mode = mode;
  hour_image_container_5.layer.compositing_mode = mode;
  hour_image_container_6.layer.compositing_mode = mode;
  hour_image_container_7.layer.compositing_mode = mode;
  hour_image_container_8.layer.compositing_mode = mode;
  hour_image_container_9.layer.compositing_mode = mode;
  hour_image_container_10.layer.compositing_mode = mode;
  hour_image_container_11.layer.compositing_mode = mode;
  hour_image_container_12.layer.compositing_mode = mode;

	//GPoint pointxy = GPoint(-73, -75);
	GPoint pointxy = GPoint(14, 70);
  rot_bitmap_set_src_ic(&hour_image_container_1.layer, pointxy);
  rot_bitmap_set_src_ic(&hour_image_container_2.layer, pointxy);
  rot_bitmap_set_src_ic(&hour_image_container_3.layer, pointxy);
  rot_bitmap_set_src_ic(&hour_image_container_4.layer, pointxy);
  rot_bitmap_set_src_ic(&hour_image_container_5.layer, pointxy);
  rot_bitmap_set_src_ic(&hour_image_container_6.layer, pointxy);
  rot_bitmap_set_src_ic(&hour_image_container_7.layer, pointxy);
  rot_bitmap_set_src_ic(&hour_image_container_8.layer, pointxy);
  rot_bitmap_set_src_ic(&hour_image_container_9.layer, pointxy);
  rot_bitmap_set_src_ic(&hour_image_container_10.layer, pointxy);
  rot_bitmap_set_src_ic(&hour_image_container_11.layer, pointxy);
  rot_bitmap_set_src_ic(&hour_image_container_12.layer, pointxy);

  layer_add_child(&window.layer, &hour_image_container_1.layer.layer);
  layer_add_child(&window.layer, &hour_image_container_2.layer.layer);
  layer_add_child(&window.layer, &hour_image_container_3.layer.layer);
  layer_add_child(&window.layer, &hour_image_container_4.layer.layer);
  layer_add_child(&window.layer, &hour_image_container_5.layer.layer);
  layer_add_child(&window.layer, &hour_image_container_6.layer.layer);
  layer_add_child(&window.layer, &hour_image_container_7.layer.layer);
  layer_add_child(&window.layer, &hour_image_container_8.layer.layer);
  layer_add_child(&window.layer, &hour_image_container_9.layer.layer);
  layer_add_child(&window.layer, &hour_image_container_10.layer.layer);
  layer_add_child(&window.layer, &hour_image_container_11.layer.layer);
  layer_add_child(&window.layer, &hour_image_container_12.layer.layer);


  update_hand_positions();


}
DateTimeLayer* date_time_layer_create(Watchface* watchface) {
    DateTimeLayer* date_time_layer = malloc(sizeof(DateTimeLayer));
    date_time_layer->watchface = watchface;
    
    GRect frame = layer_get_frame(watchface_get_layer(watchface));
    
    date_time_layer->layer = layer_create(frame);
    
    default_time_frame = GRect(0, 2, frame.size.w, frame.size.h-6);
    default_date_frame = GRect(1, 74, frame.size.w, frame.size.h-62);
    nudged_up_date_frame = GRect(
        default_date_frame.origin.x, default_date_frame.origin.y - 8,
        default_date_frame.size.w,   default_date_frame.size.h
    );
    if(HAS_LIGHT_WEATHER) {
        default_date_frame = nudged_up_date_frame;
    }
    
    date_time_layer->time_layer = text_layer_create(default_time_frame);
    date_time_layer->date_layer = text_layer_create(default_date_frame);
    
    text_layer_set_text_alignment(
        date_time_layer->time_layer, GTextAlignmentCenter
    );
    text_layer_set_background_color(
        date_time_layer->time_layer, GColorClear
    );
    text_layer_set_text_color(
        date_time_layer->time_layer, GColorWhite
    );
    text_layer_set_font(
        date_time_layer->time_layer, watchface_get_fonts(watchface)->futura_53
    );
    text_layer_set_text(date_time_layer->time_layer, "(null)");
    
    text_layer_set_text_alignment(
        date_time_layer->date_layer, GTextAlignmentCenter
    );
    text_layer_set_background_color(
        date_time_layer->date_layer, GColorClear
    );
    text_layer_set_text_color(
        date_time_layer->date_layer, GColorWhite
    );
    text_layer_set_font(
        date_time_layer->date_layer, watchface_get_fonts(watchface)->futura_18
    );
    
    layer_add_child(
        date_time_layer->layer,
        text_layer_get_layer(date_time_layer->time_layer)
    );
    layer_add_child(
        date_time_layer->layer,
        text_layer_get_layer(date_time_layer->date_layer)
    );
    
    date_time_layer_update_frame(date_time_layer);
    
    return date_time_layer;
}
Example #17
0
static void initialise_ui(void) {
  s_window = window_create();
  window_set_background_color(s_window, GColorBlack);
  window_set_fullscreen(s_window, true);
  
  s_res_background_image = gbitmap_create_with_resource(RESOURCE_ID_BACKGROUND_IMAGE);
  // s_bitmaplayer_1
  s_bitmaplayer_1 = bitmap_layer_create(GRect(0, 0, 144, 168));
  bitmap_layer_set_bitmap(s_bitmaplayer_1, s_res_background_image);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_bitmaplayer_1);
  
  //background_layer
  background_layer = layer_create(GRect(0,0,144,168));
  layer_set_update_proc(background_layer, background_update);
  layer_add_child(window_get_root_layer(s_window), (Layer*)background_layer);
  
  // s_layer_1
  s_layer_1 = layer_create(GRect(0, 0, 144, 168));
  layer_set_update_proc(s_layer_1, levels_update);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_layer_1);
  
  time_layer = text_layer_create(GRect(40,90,100,40));
  text_layer_set_text(time_layer, "141.12");
  #ifdef PBL_COLOR
    text_layer_set_text_color(time_layer, GColorElectricBlue);
  #else
    text_layer_set_text_color(time_layer, GColorWhite);
  #endif
  text_layer_set_background_color(time_layer, GColorClear);
  text_layer_set_text_alignment(time_layer, GTextAlignmentRight);
  text_layer_set_font(time_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_METAL_GEAR_17)));
  layer_add_child(window_get_root_layer(s_window), (Layer*)time_layer);
  
  charge_layer = text_layer_create(GRect(52,115,88,21));
  text_layer_set_text(charge_layer, "CHRG");
  #ifdef PBL_COLOR
    text_layer_set_background_color(charge_layer, GColorRed);
    text_layer_set_text_color(charge_layer, GColorBlack);
  #else
    text_layer_set_background_color(charge_layer, GColorWhite);
    text_layer_set_text_color(charge_layer, GColorBlack);
  #endif
  text_layer_set_text_alignment(charge_layer, GTextAlignmentCenter);
  text_layer_set_font(charge_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_METAL_GEAR_16)));
  layer_add_child(window_get_root_layer(s_window), (Layer*)charge_layer);
  layer_set_hidden((Layer*)charge_layer, true);
  
  bluetooth_layer = text_layer_create(GRect(16,10,100,40));
  text_layer_set_text(bluetooth_layer, "PTT");
  #ifdef PBL_COLOR
    text_layer_set_text_color(bluetooth_layer, GColorElectricBlue);
  #else
    text_layer_set_text_color(bluetooth_layer, GColorWhite);
  #endif
  text_layer_set_background_color(bluetooth_layer, GColorClear);
  text_layer_set_font(bluetooth_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_METAL_GEAR_13)));
  layer_add_child(window_get_root_layer(s_window), (Layer*)bluetooth_layer);
  
  level1 = gpath_create(&LEVEL_1_POINTS);
  level2 = gpath_create(&LEVEL_2_POINTS);
  level3 = gpath_create(&LEVEL_3_POINTS);
  level4 = gpath_create(&LEVEL_4_POINTS);
  level5 = gpath_create(&LEVEL_5_POINTS);
  level6 = gpath_create(&LEVEL_6_POINTS);
  
  handle_battery(battery_state_service_peek());
  handle_bluetooth(bluetooth_connection_service_peek());
}
Example #18
0
// build up the pieces that make up background layer
static void create_background_layer() {
  s_background_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BACKGROUND);
  s_background_layer = bitmap_layer_create(GRect(0, 0, 144, 168));
  bitmap_layer_set_bitmap(s_background_layer, s_background_image);

}
Example #19
0
void handle_init(AppContextRef ctx) {
  (void)ctx;

  window_init(&window, "Brains Watch");
  window_stack_push(&window, true);

  resource_init_current_app(&APP_RESOURCES);

//    rotbmp_pair_init_container(RESOURCE_ID_IMAGE_PANDA_WHITE, RESOURCE_ID_IMAGE_PANDA_BLACK, &bitmap_container);


  // Set up a layer for the static watch face background
  bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND, &background_image_container);
  layer_add_child(&window.layer, &background_image_container.layer.layer);


dice = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_VISITOR_16));

  text_layer_init(&date_layer, GRect(53, 105, 40, 40));
  text_layer_set_text_alignment(&date_layer, GTextAlignmentCenter);
  text_layer_set_text_color(&date_layer, GColorBlack);
  text_layer_set_background_color(&date_layer, GColorClear);
  text_layer_set_font(&date_layer, dice);
  layer_add_child(&window.layer, &date_layer.layer);

 PblTm ti;
 get_time(&ti);
  
 string_format_time(date_text, sizeof(date_text), "%d", &ti);
 text_layer_set_text(&date_layer, date_text);




  // Set up a layer for the hour hand
  rotbmp_init_container(RESOURCE_ID_IMAGE_HOUR_HAND, &hour_hand_image_container);

    //  hour_hand_image_container.layer.compositing_mode = GCompOpClear;

  rot_bitmap_set_src_ic(&hour_hand_image_container.layer, GPoint(3, 42));

  layer_add_child(&window.layer, &hour_hand_image_container.layer.layer);


  // Set up a layer for the minute hand
  rotbmp_init_container(RESOURCE_ID_IMAGE_MINUTE_HAND, &minute_hand_image_container);

 // minute_hand_image_container.layer.compositing_mode = GCompOpClear;

  rot_bitmap_set_src_ic(&minute_hand_image_container.layer, GPoint(3, 58));

  layer_add_child(&window.layer, &minute_hand_image_container.layer.layer);






  update_hand_positions();


  // Setup the black and white circle in the centre of the watch face
  // (We use a bitmap rather than just drawing it because it means not having
  // to stuff around with working out the circle center etc.)
  rotbmp_pair_init_container(RESOURCE_ID_IMAGE_CENTER_CIRCLE_WHITE, RESOURCE_ID_IMAGE_CENTER_CIRCLE_BLACK,
			     &center_circle_image_container);

  // TODO: Do this properly with a GRect().
  // (144 = screen width, 168 = screen height)
  center_circle_image_container.layer.layer.frame.origin.x = (144/2) - (center_circle_image_container.layer.layer.frame.size.w/2);
  center_circle_image_container.layer.layer.frame.origin.y = (168/2) - (center_circle_image_container.layer.layer.frame.size.h/2);


  layer_add_child(&window.layer, &center_circle_image_container.layer.layer);

  layer_init(&second_display_layer, window.layer.frame);
  second_display_layer.update_proc = &second_display_layer_update_callback;
  layer_add_child(&window.layer, &second_display_layer);

}
Example #20
0
static void build_date_layer(GRect bounds){
  s_date_layer = text_layer_create(
      GRect(0, PBL_IF_ROUND_ELSE(108, 102), bounds.size.w, 50));

  draw_date_later();
}
Example #21
0
Window* window;
BitmapLayer* bmp_layer;
AppTimer* vibe_timer = NULL;
bool is_visible = false;

void win_vibrate_init(void) {
  window = window_create();
  window_set_background_color(window, GColorBlack);
  window_set_click_config_provider(window, (ClickConfigProvider)click_config_provider);
  window_set_window_handlers(window, (WindowHandlers) {
    .appear = window_appear,
    .disappear = window_disappear
  });

  bmp_layer = bitmap_layer_create(GRect(40, 44, 64, 64));
  bitmap_layer_set_compositing_mode(bmp_layer, GCompOpAssignInverted);
  bitmap_layer_set_bitmap(bmp_layer, bitmaps_get_bitmap(RESOURCE_ID_IMG_ALARM));
  bitmap_layer_add_to_window(bmp_layer, window);
}

void win_vibrate_show(void) {
  window_stack_push(window, true);
}

void win_vibrate_destroy(void) {
  bitmap_layer_destroy(bmp_layer);
  window_destroy(window);
}

bool win_vibrate_is_visible(void) {
Example #22
0
static void main_window_load(Window *window) {
  GRect bounds = layer_get_bounds(window_get_root_layer(window));
  
  action_bar = action_bar_layer_create();
  action_bar_layer_set_click_config_provider(action_bar, click_config_provider);
  bool topbutton_dismiss = load_persistent_storage_bool(TOP_BUTTON_DISMISS_KEY, true);

  action_bar_layer_set_icon_animated(action_bar,topbutton_dismiss?BUTTON_ID_UP:BUTTON_ID_DOWN,gbitmap_create_with_resource(RESOURCE_ID_IMAGE_ACTION_ICON_CROSS_INV),true);
  action_bar_layer_set_icon_animated(action_bar,topbutton_dismiss?BUTTON_ID_DOWN:BUTTON_ID_UP,gbitmap_create_with_resource(RESOURCE_ID_IMAGE_ACTION_ICON_ZZ_INV),true);

  action_bar_layer_add_to_window(action_bar,window);
  
  // Create output TextLayer
  
  s_output_layer = text_layer_create(GRect(0, bounds.size.h/2-(is_24h()?0:4), bounds.size.w-ACTION_BAR_WIDTH, bounds.size.h));
  text_layer_set_text_alignment(s_output_layer, GTextAlignmentCenter);
  text_layer_set_font(s_output_layer,fonts_get_system_font(FONT_KEY_BITHAM_42_LIGHT));

  //snprintf(output_text, sizeof(output_text), "00:00");
  text_layer_set_text(s_output_layer, output_text);
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_output_layer));
  
  //snprintf(output_text, sizeof(output_text), "00:00");
  if(alarm_has_description(s_alarm))
  {
    // Create Description
    s_description_layer = text_layer_create(GRect(PBL_IF_ROUND_ELSE(20,0), PBL_IF_ROUND_ELSE(20,6), bounds.size.w-ACTION_BAR_WIDTH-PBL_IF_ROUND_ELSE(20,0), bounds.size.h/2-10));
    text_layer_set_text_alignment(s_description_layer, GTextAlignmentCenter);
    text_layer_set_font(s_description_layer,fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
    text_layer_set_text(s_description_layer, s_alarm->description);
    layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_description_layer));
  }
  else
  {
#ifndef PBL_PLATFORM_APLITE
    s_command_seq = gdraw_command_sequence_create_with_resource(RESOURCE_ID_CLOCK_SEQUENCE);
    // Create the canvas Layer
    s_canvas_layer = layer_create(GRect(PBL_IF_ROUND_ELSE(60,30)-ACTION_BAR_WIDTH/2, 0, bounds.size.w, bounds.size.h));
    // Set the LayerUpdateProc
    layer_set_update_proc(s_canvas_layer, update_proc);

    // Add to parent Window
    layer_add_child(window_get_root_layer(window), s_canvas_layer);
    
#else
    // Create Bitmap
    s_bitmap_layer = bitmap_layer_create(GRect(0,10,bounds.size.w-ACTION_BAR_WIDTH, bounds.size.h));
    s_logo = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_LOGO);
    bitmap_layer_set_bitmap(s_bitmap_layer,s_logo);
    bitmap_layer_set_alignment(s_bitmap_layer,GAlignTop);
    layer_add_child(window_get_root_layer(window),bitmap_layer_get_layer(s_bitmap_layer));
    s_pat.durations = s_segments;
    s_pat.num_segments = 2;

#endif
  }
  s_vibration_pattern = load_persistent_storage_int(VIBRATION_PATTERN_KEY,0);
  s_vibration_duration = load_persistent_storage_int(VIBRATION_DURATION_KEY, 2);
  s_konami_dismiss = load_persistent_storage_bool(KONAMI_DISMISS_KEY,false);

  s_auto_snooze = load_persistent_storage_bool(AUTO_SNOOZE_KEY, true);
  // do smart-alarmy stuff here
#ifdef PBL_HEALTH
  if(s_alarm->smart_alarm_minutes>0)
  {
    // Attempt to subscribe
    if(!health_service_events_subscribe(health_handler, NULL)) {
      APP_LOG(APP_LOG_LEVEL_ERROR, "Health not available!");
      start_vibration(NULL);
    }
    else {
      // Check which activities are available
      HealthServiceAccessibilityMask activity_mask = health_service_any_activity_accessible(HealthActivityMaskAll,time(NULL)-SECONDS_PER_HOUR,time(NULL));
      
      if(activity_mask & HealthServiceAccessibilityMaskAvailable){
        APP_LOG(APP_LOG_LEVEL_INFO, "We can read activities!");
        // Get an activities mask
        HealthActivityMask activities = health_service_peek_current_activities();
        
        // Determine if the user is sleeping
        if(activities & HealthActivitySleep) { // give him time to wake
          APP_LOG(APP_LOG_LEVEL_INFO, "User is sleeping!");
          s_start_smart_alarm_timer = app_timer_register(1000*60*s_alarm->smart_alarm_minutes,start_vibration,NULL);
        } else { // just vibrate
          start_vibration(NULL);
        }
      }
      else { // we don't get the current activity, so just vibrate
        start_vibration(NULL);
      }
    }
  }
  else {
    start_vibration(NULL);
  }
  
#else
  start_vibration(NULL);
#endif
  // test snoozing with the accelerometer
  /*if(s_flip_to_snooze)
  {
    accel_tap_service_subscribe(&accel_tap_handler);
  }*/
}
Example #23
0
static void boardUpdateProc(Layer* this_layer, GContext *ctx) {
  GRect b = layer_get_bounds(this_layer);
  graphics_context_set_antialiased(ctx, 0);

  // Fill grey back (white on BW)
  graphics_context_set_fill_color(ctx, COLOR_FALLBACK(GColorLightGray, GColorWhite));
  graphics_context_set_stroke_color(ctx, GColorBlack);
  graphics_fill_rect(ctx, b, 0, GCornersAll);

  // Frame highlight around currently selected square colours is gray w white highlight, BW is wite w black highight
  graphics_context_set_fill_color(ctx, COLOR_FALLBACK(GColorDarkGray, GColorWhite));
  graphics_context_set_stroke_color(ctx, COLOR_FALLBACK(GColorWhite, GColorBlack));
  GRect highlightR = GRect(s_cursor.x*PIECE_PIXELS, s_cursor.y*PIECE_PIXELS, PIECE_PIXELS+1, PIECE_PIXELS+1);
  graphics_fill_rect(ctx, highlightR, 0, GCornersAll);
  graphics_draw_rect(ctx, highlightR);

  // Draw all board shapes
  for (int x = 0; x < BOARD_PIECES_X; ++x) {
    for (int y = 0; y < BOARD_PIECES_Y; ++y) {
      int xy = XY(x,y);
      if (s_gameState == kFlashRemoved && (s_pieces[xy].match != kUnmatched || s_pieces[XY(x,y)].exploded == true)) {
        // Highlight squares which have just been matched
        GColor highlight = COLOR_FALLBACK(GColorRed, GColorBlack);
        if (s_pieces[xy].match == kMatchedTwice) highlight = COLOR_FALLBACK(GColorDarkCandyAppleRed, GColorBlack);
        graphics_context_set_fill_color(ctx, highlight);
        graphics_context_set_stroke_color(ctx, COLOR_FALLBACK(GColorBlack, GColorLightGray));
        highlightR = GRect((s_pieces[xy].loc.x/SUB_PIXEL), (s_pieces[xy].loc.y/SUB_PIXEL), PIECE_PIXELS+1, PIECE_PIXELS+1);
        graphics_fill_rect(ctx, highlightR, 0, GCornersAll);
        graphics_draw_rect(ctx, highlightR);
      }
      // Draw the shape itself
      graphics_context_set_fill_color(ctx, COLOURS[ s_pieces[xy].colour ]);
      if (getShape( s_pieces[xy].colour ) != NULL) {
        static const bool bw = PBL_IF_BW_ELSE(true,false);
        if (bw == false && s_pieces[xy].colour == kBlack ) {
          graphics_context_set_stroke_color(ctx, GColorWhite);
        } else if (bw == true
          && (s_pieces[xy].match != kUnmatched || s_pieces[XY(x,y)].exploded == true)
          && COLOURS[ s_pieces[xy].colour ].argb != GColorWhite.argb ) {
          graphics_context_set_stroke_color(ctx, GColorWhite);
        } else {
          graphics_context_set_stroke_color(ctx, GColorBlack);
        }
        gpath_move_to(getShape( s_pieces[xy].colour ), GPoint(s_pieces[xy].loc.x/SUB_PIXEL, s_pieces[xy].loc.y/SUB_PIXEL));
        gpath_draw_filled(ctx, getShape( s_pieces[xy].colour ));
        gpath_draw_outline(ctx, getShape( s_pieces[xy].colour ));
      } else {
        // White rectangle of debug - we should not have the case where we render a NULL square
        graphics_fill_rect(ctx, GRect((s_pieces[xy].loc.x/SUB_PIXEL)+2, (s_pieces[xy].loc.y/SUB_PIXEL)+2, PIECE_PIXELS-3, PIECE_PIXELS-3), 2, GCornersAll);
      }
    }
  }

  // Move Arrows
  if (s_flashArrows == true && s_gameState == kAwaitingDirection) {
    graphics_context_set_fill_color(ctx, GColorWhite);
    for (int d = 0; d < N_CARDINAL; ++d) {
      gpath_move_to(getArrow(d), GPoint(s_cursor.x * PIECE_PIXELS, s_cursor.y * PIECE_PIXELS));
      gpath_draw_filled(ctx, getArrow(d));
      gpath_draw_outline(ctx, getArrow(d));
    }
  }

  // Cursor
  if (s_tiltMode > 0) {
    graphics_context_set_fill_color(ctx, GColorWhite);
    graphics_context_set_stroke_color(ctx, GColorBlack);
    graphics_fill_circle(ctx, GPoint(s_motionCursor.x/SUB_PIXEL,s_motionCursor.y/SUB_PIXEL), 3);
    graphics_draw_circle(ctx, GPoint(s_motionCursor.x/SUB_PIXEL,s_motionCursor.y/SUB_PIXEL), 3);
  }

  // Next move
  if (s_hintOn && s_availableMove.x != -1 && s_gameState == kIdle && s_hintStatus == true) {
    graphics_context_set_stroke_color(ctx, COLOR_FALLBACK(GColorDarkCandyAppleRed,GColorBlack) );
    graphics_context_set_stroke_width(ctx, 3);
    graphics_draw_circle(ctx, GPoint(s_availableMove.x*PIECE_PIXELS + PIECE_PIXELS/2, s_availableMove.y*PIECE_PIXELS + PIECE_PIXELS/2), PIECE_PIXELS);
    graphics_context_set_stroke_width(ctx, 1);
  }

  // Redo border
  graphics_context_set_stroke_color(ctx, GColorBlack);
  graphics_draw_rect(ctx, b);

}
Example #24
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 Layers
	s_time_textLayer = text_layer_create(
	    GRect(0, PBL_IF_ROUND_ELSE(58, 52), bounds.size.w, 50));
	s_weather_textLayer = text_layer_create(
		GRect(PBL_IF_ROUND_ELSE(65, 5), PBL_IF_ROUND_ELSE(0, 2), PBL_IF_ROUND_ELSE(70, bounds.size.w), 50));
	s_dayOfWeek_textLayer = text_layer_create(
		GRect(PBL_IF_ROUND_ELSE(30, -5), PBL_IF_ROUND_ELSE(25, 2), bounds.size.w, 50));
	s_date_textLayer = text_layer_create(
		GRect(0, PBL_IF_ROUND_ELSE(105, 115), PBL_IF_ROUND_ELSE(bounds.size.w-31, bounds.size.w-3), 50));
	// UI Layers
	s_ui_top = text_layer_create(
		GRect(0,0,bounds.size.w,PBL_IF_ROUND_ELSE(70,52)));
	s_ui_bottom = text_layer_create(
		GRect(0,PBL_IF_ROUND_ELSE(110,117),bounds.size.w,100));

	// Setup Background colors
	text_layer_set_background_color(s_time_textLayer, 		GColorClear);
	text_layer_set_background_color(s_weather_textLayer, 	GColorClear);
	text_layer_set_background_color(s_dayOfWeek_textLayer,	GColorClear);
	text_layer_set_background_color(s_date_textLayer,		GColorClear);

	// Setup Text Colors
	text_layer_set_text_color(s_time_textLayer, 			GColorBlack);
	text_layer_set_text_color(s_weather_textLayer,			GColorWhite);
	text_layer_set_text_color(s_dayOfWeek_textLayer,		GColorWhite);
	text_layer_set_text_color(s_date_textLayer,				GColorWhite);

	// Setup Font Styles
	time_font = fonts_get_system_font(FONT_KEY_ROBOTO_BOLD_SUBSET_49);
	nonTime_font = fonts_get_system_font(FONT_KEY_BITHAM_42_LIGHT);
	text_layer_set_font(s_time_textLayer, time_font);
	// text_layer_set_font(s_time_textLayer, s_time_gfont);
	text_layer_set_font(s_weather_textLayer, nonTime_font);
	text_layer_set_font(s_dayOfWeek_textLayer, nonTime_font);
	text_layer_set_font(s_date_textLayer, nonTime_font);

	// Format Text alignments
	text_layer_set_text_alignment(s_time_textLayer, 		GTextAlignmentCenter);
	text_layer_set_text_alignment(s_weather_textLayer,		GTextAlignmentRight);
	text_layer_set_text_alignment(s_dayOfWeek_textLayer,	GTextAlignmentLeft);
	text_layer_set_text_alignment(s_date_textLayer,			GTextAlignmentRight);

	// Optionally, Add Text to the layer as a placeholder
	text_layer_set_text(s_weather_textLayer, "...");
		
	// Perform Color Changes!
	#if defined(PBL_BW)
		text_layer_set_background_color(s_ui_top,				GColorBlack);
		text_layer_set_background_color(s_ui_bottom,			GColorBlack);
  	#elif defined(PBL_COLOR)
	    // Accent Color Setting
	    int red_accent = persist_read_int(KEY_COLOR_RED_ACCENT);
	    int green_accent = persist_read_int(KEY_COLOR_GREEN_ACCENT);
	    int blue_accent = persist_read_int(KEY_COLOR_BLUE_ACCENT);

	    // APP_LOG(APP_LOG_LEVEL_INFO, "color is %d". bg_color_accent);
		// APP_LOG(APP_LOG_LEVEL_INFO, "accent color is rgb %d %d %d", red_accent, green_accent,blue_accent);
	    if(red_accent >= 0 && green_accent >= 0 && blue_accent >= 0) {
	    	GColor bg_color_accent = GColorFromRGB(red_accent, green_accent, blue_accent);
	    	
	    	text_layer_set_background_color(s_ui_top, bg_color_accent);
	    	text_layer_set_background_color(s_ui_bottom, bg_color_accent);
	    	text_layer_set_text_color(s_dayOfWeek_textLayer, gcolor_is_dark(bg_color_accent) ? GColorWhite : GColorBlack);
	    	text_layer_set_text_color(s_date_textLayer, gcolor_is_dark(bg_color_accent) ? GColorWhite : GColorBlack);
	    	text_layer_set_text_color(s_weather_textLayer, gcolor_is_dark(bg_color_accent) ? GColorWhite : GColorBlack);
	    }
	    // Time Color Setting
	    int red_time = persist_read_int(KEY_COLOR_RED_TIME);
	    int green_time = persist_read_int(KEY_COLOR_GREEN_TIME);
	    int blue_time = persist_read_int(KEY_COLOR_BLUE_TIME);

	    if(red_time >= 0 && green_time >= 0 && blue_time >= 0) {
	    	GColor bg_color_time = GColorFromRGB(red_time, green_time, blue_time);
	    	
	    	window_set_background_color(s_main_window, bg_color_time);
	    	text_layer_set_text_color(s_time_textLayer, gcolor_is_dark(bg_color_time) ? GColorWhite : GColorBlack);
	    }
    #endif

	// UI
	layer_add_child(window_layer, text_layer_get_layer(s_ui_top));
	layer_add_child(window_layer, text_layer_get_layer(s_ui_bottom));
	// Add Layers as Children to window.
	layer_add_child(window_layer, text_layer_get_layer(s_time_textLayer));
	layer_add_child(window_layer, text_layer_get_layer(s_weather_textLayer));
	layer_add_child(window_layer, text_layer_get_layer(s_dayOfWeek_textLayer));
	layer_add_child(window_layer, text_layer_get_layer(s_date_textLayer));
	// Don't forget to destroy all layers below.
}
Example #25
0
    window_single_repeating_click_subscribe(BUTTON_ID_UP, 50, click_up_handler);
    window_single_repeating_click_subscribe(BUTTON_ID_SELECT, 200, click_select_handler);
    window_single_click_subscribe(BUTTON_ID_BACK, click_handler);
}


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

    GRect plus_frame = GRect(0, INPUT_TOP_Y-FIELD_HEIGHT, 144, FIELD_HEIGHT);
    s_plus_layer = layer_create(plus_frame);
    layer_set_bounds(s_plus_layer, (GRect){ .size = GSize(FIELD_WIDTH, FIELD_HEIGHT) });
    layer_set_update_proc(s_plus_layer, render_plus);
    layer_add_child(window_layer, s_plus_layer);

    GRect minus_frame = GRect(0, INPUT_TOP_Y+FIELD_HEIGHT, 144, FIELD_HEIGHT);
    s_minus_layer = layer_create(minus_frame);
    layer_set_bounds(s_minus_layer, (GRect){ .size = GSize(FIELD_WIDTH, FIELD_HEIGHT) });
    layer_set_update_proc(s_minus_layer, render_minus);
    layer_add_child(window_layer, s_minus_layer);

    s_top_layer = text_layer_create(GRect(0,10,144,30));
    text_layer_set_text(s_top_layer, "Enter IP:");
    text_layer_set_text_alignment(s_top_layer, GTextAlignmentCenter);
    text_layer_set_font(s_top_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
    layer_add_child(window_layer, text_layer_get_layer(s_top_layer));

    for (int i = 0; i<4; i++) {
        s_ip_layers[i] = text_layer_create(GRect(i * FIELD_SPACING, INPUT_TOP_Y, FIELD_WIDTH, FIELD_HEIGHT));
        text_layer_set_text_color(s_ip_layers[i], GColorWhite);
        text_layer_set_text(s_ip_layers[i], "0");
Example #26
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_BACKGROUND);
    s_background_layer = bitmap_layer_create(GRect(0, 0, 144, 168));
    //bitmap_layer_set_bitmap(s_background_layer, s_background_bitmap);
    
    bitmap_layer_set_background_color(s_background_layer,GColorBlack);
    
    layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(s_background_layer));
    
    Layer *window_layer = window_get_root_layer(window);
    GRect window_bounds = layer_get_bounds(window_layer);
    
    
    s_current_session_layer = text_layer_create(GRect(5, 0, 144, 40));
    
    // Create time TextLayer
    //  s_time_layer = text_layer_create(GRect(0, 55, 144, 50));
    s_time_layer = text_layer_create(GRect(5, 52, 139, 50));
    
    
    s_upcoming_session_layer = text_layer_create(GRect(5, 130, 144, 40));
    
    text_layer_set_background_color(s_time_layer, GColorClear);
    text_layer_set_text_color(s_time_layer, GColorWhite);
    
    // Create GFont
    s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_PERFECT_DOS_48));
    
    // Apply to TextLayer
    text_layer_set_font(s_time_layer, s_time_font);
    
    
    // Improve the layout to be more like a watchface
    // text_layer_set_font(s_time_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD));
    text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);
    
    
    
    
    text_layer_set_font(s_current_session_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
    text_layer_set_overflow_mode(s_current_session_layer, GTextOverflowModeTrailingEllipsis);
    text_layer_set_text_color(s_current_session_layer, GColorWhite);
    text_layer_set_background_color(s_current_session_layer, GColorClear);
    
    layer_add_child(window_layer, text_layer_get_layer(s_current_session_layer));
    
    
    
    text_layer_set_font(s_upcoming_session_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
    text_layer_set_text_color(s_upcoming_session_layer, GColorWhite);
    text_layer_set_overflow_mode(s_upcoming_session_layer, GTextOverflowModeTrailingEllipsis);
    text_layer_set_background_color(s_upcoming_session_layer, GColorClear);
    
    layer_add_child(window_layer, text_layer_get_layer(s_upcoming_session_layer));
    
    
    
    char *currentSession = "                                                     ";
    char *nextSession = "                                                     ";
  
    if (persist_exists(PERSIST_VALUE_1)) {
        persist_read_string(PERSIST_VALUE_1, currentSession, 30);
    }
    
    if (persist_exists(PERSIST_VALUE_2)) {
        persist_read_string(PERSIST_VALUE_2, nextSession,30);
    }
    
    Tuplet initial_values[] = {
        TupletCString(VALUE_1, currentSession),
        TupletCString(VALUE_2, nextSession),
    };
    
    app_sync_init(&sync, sync_buffer, sizeof(sync_buffer), initial_values, ARRAY_LENGTH(initial_values),
                  sync_tuple_changed_callback, sync_error_callback, NULL);
    
    
    
    
    // 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));
}
Example #27
0
                      left_start.y - (sin_lookup(angle_left) * length_left) / TRIG_MAX_RATIO);

    right_end = GPoint(right_start.x + (cos_lookup(angle_right) * length_right) / TRIG_MAX_RATIO,
                       right_start.y - (sin_lookup(angle_right) * length_right) / TRIG_MAX_RATIO);
    layer_mark_dirty(graphics_layer);
}

static void update_proc(Layer *this, GContext *ctx) {
    graphics_context_set_stroke_width(ctx, 12);
    graphics_context_set_stroke_color(ctx, GColorIslamicGreen);
    graphics_draw_line(ctx, left_start, left_end);
    graphics_draw_line(ctx, right_start, right_end);
    GRect frame = layer_get_frame(this);
    graphics_context_set_text_color(ctx, GColorBlack);
    graphics_draw_text(ctx, locale[LOCALE_KEY_SCHEME_UPDATED], fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD),
                       GRect(0, frame.size.h / 2 + 20, 144, frame.size.h / 2 - 20),
                       GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
}

static void load(Window *win) {
    window_layer = window_get_root_layer(window);
    GRect frame = layer_get_frame(window_layer);
    graphics_layer = layer_create(frame);
    layer_set_update_proc(graphics_layer, update_proc);
    layer_add_child(window_layer, graphics_layer);
    anim = animation_create();
    animation_set_implementation(anim, &anim_impl);
    left_length = 30;
    right_length = 60;
    left_start = GPoint(frame.size.w / 2, frame.size.h / 2);
    right_start = GPoint(frame.size.w / 2, frame.size.h / 2);
Example #28
0
void moon_LayerUpdateProc(struct Layer *layer, GContext *ctx) {
/*
	GPath shadow;
	GPathInfo shadow_points = {
		5,
		(GPoint []) {
			{0, 0},
			{0, 0},
			{0, 0},
			{0, 0},
			{0, 0},
		}
	};
*/
	int radius;
	int x, y, error;
	int mx, my;
	GPoint center;
	int edge;

	if(phase == 1) {
		graphics_context_set_fill_color(ctx, GColorBlack);
		graphics_fill_rect(ctx, GRect(0, 0, layer->frame.size.w, layer->frame.size.h), 0, GCornerNone);
		return;
	}
	if(phase == 15)
		return;
	graphics_context_set_fill_color(ctx, GColorWhite);
	center.x = layer->frame.size.w / 2;
	center.y = layer->frame.size.h / 2;
	radius = (layer->frame.size.w > layer->frame.size.h ?
		layer->frame.size.h / 2 :
		layer->frame.size.w / 2) - 4;
//	graphics_fill_circle(ctx, center, radius);

	graphics_context_set_stroke_color(ctx, GColorBlack);
	// circle algo from: http://en.wikipedia.org/wiki/Midpoint_circle_algorithm
	// Even though I studied it in school, it still feels like magic
	error = -radius;
	x = radius;
	y = 0;
	while ( x >= y) {
		if(phase < 15) {
			mx = x * (cos_lookup(TRIG_MAX_ANGLE * (phase / 28.0)) / (0xffff * 1.0));
			my = y * (cos_lookup(TRIG_MAX_ANGLE * (phase / 28.0)) / (0xffff * 1.0));
			edge = 0;
		}
		if(phase > 15) {
			mx = x * (cos_lookup(TRIG_MAX_ANGLE * ((phase - 15) / 32.0)) / (0xffff * 1.0));
			my = y * (cos_lookup(TRIG_MAX_ANGLE * ((phase - 15) / 32.0)) / (0xffff * 1.0));
			edge = layer->frame.size.w;
		}
		graphics_draw_line(ctx, GPoint(center.x + mx, center.y + y), GPoint(edge, center.y + y));
		graphics_draw_line(ctx, GPoint(center.x + mx, center.y - y), GPoint(edge, center.y - y));
		graphics_draw_line(ctx, GPoint(center.x + my, center.y + x), GPoint(edge, center.y + x));
		graphics_draw_line(ctx, GPoint(center.x + my, center.y - x), GPoint(edge, center.y - x));

		error += y;
		++y;
		error += y;
		if( error >= 0) {
			error -= x;
			--x;
			error -= x;
		}
	}
}
Example #29
0
static void storage_error(Window *window) {
  TextLayer *text_layer = text_layer_create(GRect(0,0,144,152));
  text_layer_set_text(text_layer, "ERROR: Storage failed to initialize.");
  layer_add_child(window_get_root_layer(window), (Layer *) text_layer);
  window_stack_push(window, false);
}
Example #30
0
File: run.c Project: manelto/steps
void inicio(void)
{
  // Create our app's base window
  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);
  
  
  //parte accelerometer

  text_layer_1 = text_layer_create(GRect(0, 0, frame.size.w, 22));
  text_layer_2 = text_layer_create(GRect(0, 22, frame.size.w, 18));
  text_layer_set_text_color(text_layer_1, GColorWhite);
  text_layer_set_background_color(text_layer_1, GColorClear);
  text_layer_set_text_color(text_layer_2, GColorWhite);
  text_layer_set_background_color(text_layer_2, GColorClear);
  layer_add_child(root_layer, text_layer_get_layer(text_layer_1));
  layer_add_child(root_layer, text_layer_get_layer(text_layer_2));
 
  accel_data_service_subscribe(1, accel_handler);
  accel_service_set_sampling_rate(ACCEL_SAMPLING_25HZ);
 
  accel_tap_service_subscribe(tap_handler);
  //----------------------
  

  // Init the text layer used to show the time
  time_layer = text_layer_create(GRect(0, 40, frame.size.w /* width */, 35/* height */));
  text_layer_set_text_color(time_layer, GColorWhite);
  text_layer_set_background_color(time_layer, GColorClear);
  text_layer_set_font(time_layer, fonts_get_system_font(FONT_KEY_BITHAM_34_MEDIUM_NUMBERS));
  text_layer_set_text_alignment(time_layer, GTextAlignmentCenter);
  
  day_layer = text_layer_create(GRect(0, 75, frame.size.w /* width */, 30/* height */));
  text_layer_set_text_color(day_layer, GColorWhite);
  text_layer_set_background_color(day_layer, GColorClear);
  text_layer_set_font(day_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28));
  text_layer_set_text_alignment(day_layer, GTextAlignmentCenter);

  connection_layer = text_layer_create(GRect(0, 98, /* width */ frame.size.w, 24 /* height */));
  text_layer_set_text_color(connection_layer, GColorWhite);
  text_layer_set_background_color(connection_layer, GColorClear);
  text_layer_set_font(connection_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
  text_layer_set_text_alignment(connection_layer, GTextAlignmentCenter);
  handle_bluetooth(bluetooth_connection_service_peek());

  battery_layer = text_layer_create(GRect(0, 120, /* width */ frame.size.w, 34 /* 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_24));
  text_layer_set_text_alignment(battery_layer, GTextAlignmentCenter);
  text_layer_set_text(battery_layer, "100% cargado");

  // Ensures time is displayed immediately (will break if NULL tick event accessed).
  // (This is why it's a good idea to have a separate routine to do the update itself.)
  time_t now = time(NULL);
  struct tm *current_time = localtime(&now);
  handle_second_tick(current_time, SECOND_UNIT);

  tick_timer_service_subscribe(SECOND_UNIT, &handle_second_tick);
  battery_state_service_subscribe(&handle_battery);
  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(day_layer));
  layer_add_child(root_layer, text_layer_get_layer(connection_layer));
  layer_add_child(root_layer, text_layer_get_layer(battery_layer));
}