static void window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);
  const GPoint center = grect_center_point(&bounds);
  
  //Load bitmap image
  background_layer = layer_create(bounds);
  layer_set_update_proc(background_layer, background_layer_update);
  layer_add_child(window_layer, background_layer);

  custom_font_text = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_BOXY_TEXT_20));
  custom_font_outline = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_BOXY_OUTLINE_20));
  
  //Add analog hands
  analog_init(my_window);

  // Render layer ontop for cool transparency
  render_layer = layer_create(bounds);
  layer_set_update_proc(render_layer, render_layer_update);
  layer_add_child(window_layer, render_layer);

  //Force time update
  time_t current_time = time(NULL);
  struct tm *current_tm = localtime(&current_time);
  tick_handler(current_tm, MINUTE_UNIT | DAY_UNIT);

  //Setup tick time handler
  tick_timer_service_subscribe((MINUTE_UNIT), tick_handler);
}
Exemplo n.º 2
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);
}
Exemplo n.º 3
0
void init() {

	window = window_create();
	window_set_background_color(window, GColorBlack);
	
	main_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_TERMINUS_56));
	
	time_layer = text_layer_create(GRect(0, 45, 144, 168));
	text_layer_set_text_alignment(time_layer, GTextAlignmentCenter);
	text_layer_set_background_color(time_layer, GColorClear);
	text_layer_set_text_color(time_layer, GColorWhite);
	text_layer_set_font(time_layer, main_font);
	text_layer_set_text(time_layer, "boot");
	
	layer_add_child(window_get_root_layer(window), text_layer_get_layer(time_layer));
	tick_timer_service_subscribe(MINUTE_UNIT, &tick_handler);
	window_stack_push(window, true);
	
	struct tm *t;
  	time_t temp;        
  	temp = time(NULL);        
  	t = localtime(&temp);
	
	tick_handler(t, MINUTE_UNIT);
}
Exemplo n.º 4
0
static void hint_handler(ClickRecognizerRef recognizer, void *context) {
  APP_LOG(APP_LOG_LEVEL_DEBUG, "Hint");
  if (hint_layer) {
    text_layer_destroy(hint_layer);
    hint_layer = NULL;
  } else {
    tick_handler(NULL);
  }  
}  
Exemplo n.º 5
0
static void init_layers() {
  time_t temp = time(NULL);
  struct tm *tick_time = localtime(&temp);
  // Set current date
  update_date(tick_time, MINUTE_UNIT);
  // Set current time
  tick_handler(tick_time, MINUTE_UNIT);
  
  battery_handler(battery_state_service_peek());
}
Exemplo n.º 6
0
void update_word_callback(){
	animate_word_timer = app_timer_register((main_settings.updateFreq*60*1000)-1000, fire_animation_callback, NULL);
	update_word_timer = app_timer_register(main_settings.updateFreq*60*1000, update_word_callback, NULL);
	text_layer_set_text(second_word_t, phrases_get_main_swear(altWordBuffer, false));
	change = true;
	struct tm *t;
  	time_t temp;        
  	temp = time(NULL);        
  	t = localtime(&temp);
	tick_handler(t, 0);
}
Exemplo n.º 7
0
/** start the probe **/
void battery_probe_start(Task task, vm_adc_source_type source, uint16 tick_interval) {
	
	battery_probe.task.handler = battery_probe_handler;
	battery_probe.client = task;
	battery_probe.source = source;
	battery_probe.tick_interval = tick_interval;
	battery_probe.vref_reading = 255;
	battery_probe.source_reading = 255;
	
	tick_handler();
}
Exemplo n.º 8
0
void window_load(Window *window)
{
	// Here goes the clock
	clock_layer = text_layer_create(GRect(3, 0, 80, 20));
	text_layer_set_background_color(clock_layer, GColorClear);
	text_layer_set_text_color(clock_layer, GColorBlack);
	text_layer_set_text(clock_layer, "Time");
	
	// Ship name
	name_layer = text_layer_create(GRect(52, 0, 105, 20));
	text_layer_set_background_color(name_layer, GColorClear);
	text_layer_set_text_color(name_layer, GColorBlack);
	text_layer_set_text(name_layer, "No Connection");
	
	// Altitude display
	altitude_layer = text_layer_create(GRect(3, 20, 168, 144));
	text_layer_set_background_color(altitude_layer, GColorClear);
	text_layer_set_text_color(altitude_layer, GColorBlack);
	text_layer_set_font(altitude_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
	text_layer_set_text(altitude_layer, "Altitude: N/A");
	
	// Apoapsis display
	apoapsis_layer = text_layer_create(GRect(3, 40, 168, 144));
	text_layer_set_background_color(apoapsis_layer, GColorClear);
	text_layer_set_text_color(apoapsis_layer, GColorBlack);
	text_layer_set_font(apoapsis_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
	text_layer_set_text(apoapsis_layer, "Apoapsis: N/A");
	
	periapsis_layer = text_layer_create(GRect(3, 60, 168, 144));
	text_layer_set_background_color(periapsis_layer, GColorClear);
	text_layer_set_text_color(periapsis_layer, GColorBlack);
	text_layer_set_font(periapsis_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
	text_layer_set_text(periapsis_layer, "Periap: N/A");

	// The top border lines
	topborder_bitmap = gbitmap_create_with_resource(RESOURCE_ID_TOPBORDER);
	topborder_layer = bitmap_layer_create(GRect(0, 0, 144, 20));
	bitmap_layer_set_bitmap(topborder_layer, topborder_bitmap);

	// Render everything nicely
	layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(topborder_layer));
	layer_add_child(window_get_root_layer(window), text_layer_get_layer(clock_layer));
	layer_add_child(window_get_root_layer(window), text_layer_get_layer(name_layer));
	layer_add_child(window_get_root_layer(window), text_layer_get_layer(altitude_layer));
	layer_add_child(window_get_root_layer(window), text_layer_get_layer(apoapsis_layer));
	layer_add_child(window_get_root_layer(window), text_layer_get_layer(periapsis_layer));
	
	// Clock that fires once per second
	struct tm *t;
	time_t temp;
	temp = time(NULL);
	t = localtime(&temp);
	tick_handler(t, SECOND_UNIT);
}
Exemplo n.º 9
0
static void app_timer_handler(void *data) {
	time_t tt = time(NULL);

	struct tm *t = localtime(&tt);

	APP_LOG(APP_LOG_LEVEL_INFO, "Timer expired");

	tick_handler(t, SECOND_UNIT);

	//app_timer_register(TIMER_INTERVALL,app_timer_handler, data);

}
static void main_window_load(Window *window) {
  
  s_root_layer = window_get_root_layer(window);
  
  // Time
  s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_EMULOGIC_24));
  s_time_layer = text_layer_create(POS_TIME);
  text_layer_set_background_color(s_time_layer, GColorClear);
  text_layer_set_font(s_time_layer, s_time_font);
  text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_time_layer));
  
  // Date
  s_date_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_EMULOGIC_12));
  s_date_layer = text_layer_create(POS_DATE);
  text_layer_set_background_color(s_date_layer, GColorClear);
  text_layer_set_font(s_date_layer, s_date_font);
  text_layer_set_text_alignment(s_date_layer, GTextAlignmentCenter);
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_date_layer));
  
  // Bluetooth
  s_bluetooth_layer = bitmap_layer_create(POS_BT);
  layer_add_child(s_root_layer, bitmap_layer_get_layer(s_bluetooth_layer));
  
  // Battery
  s_battery_layer = bitmap_layer_create(POS_BATT);
  layer_add_child(s_root_layer, bitmap_layer_get_layer(s_battery_layer));
  
  // Kirby
  s_kirby_layer = bitmap_layer_create(POS_KBY);
  layer_add_child(s_root_layer, bitmap_layer_get_layer(s_kirby_layer));
  
  // === First update ===
  
  // tick_handler
  time_t temp = time(NULL);
  struct tm *tick_time = localtime(&temp);
  
  srand(temp);
  cur_kirby = rand() % NUM_KIRBIES;
  
  tick_handler(tick_time, INTERVAL_UPDATE);
  
  // Go back one Kirby so the next update keeps it the same
  cur_kirby = (cur_kirby - 1 + NUM_KIRBIES) % NUM_KIRBIES;
  
  // bt_handler
  bt_handler(bluetooth_connection_service_peek());
  
  // batt_handler
  batt_handler(battery_state_service_peek());
}
Exemplo n.º 11
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);
}
Exemplo n.º 12
0
static void window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);
  const GPoint center = grect_center_point(&bounds);
  
  //Add layers from back to front (background first)

  //Create bitmap layer for background image
  bitmap_layer = bitmap_layer_create(bounds);
  //Enable alpha blending for bitmap layer
  bitmap_layer_set_compositing_mode(bitmap_layer, GCompOpSet);
  //Add bitmap_layer to window layer
  layer_add_child(window_layer, bitmap_layer_get_layer(bitmap_layer));

  //Load bitmap image
  gbitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_1);
  bitmap_layer_set_bitmap(bitmap_layer, gbitmap);

  //Setup the time outline display
  time_outline_layer = text_layer_create(GRect(0, bounds.size.h / 2 - 42 / 2, bounds.size.w, 44));
  text_layer_set_text(time_outline_layer, time_string);
	text_layer_set_font(time_outline_layer, fonts_load_custom_font(
        resource_get_handle(RESOURCE_ID_FONT_BOXY_OUTLINE_42)));
  text_layer_set_text_alignment(time_outline_layer, GTextAlignmentCenter);
  text_layer_set_background_color(time_outline_layer, GColorClear);
  text_layer_set_text_color(time_outline_layer, GColorBlack);
  
  //Add clock text second
  layer_add_child(window_layer, text_layer_get_layer(time_outline_layer));

  //Setup the time display
  time_text_layer = text_layer_create(GRect(0, bounds.size.h / 2 - 42 / 2, bounds.size.w, 44));
  text_layer_set_text(time_text_layer, time_string);
	text_layer_set_font(time_text_layer, fonts_load_custom_font(
        resource_get_handle(RESOURCE_ID_FONT_BOXY_TEXT_42)));
  text_layer_set_text_alignment(time_text_layer, GTextAlignmentCenter);
  text_layer_set_background_color(time_text_layer, GColorClear);
  text_layer_set_text_color(time_text_layer, GColorWhite);
  
  //Add clock text second
  layer_add_child(window_layer, text_layer_get_layer(time_text_layer));

  //Force time update
  time_t current_time = time(NULL);
  struct tm *current_tm = localtime(&current_time);
  tick_handler(current_tm, MINUTE_UNIT);

  //Setup tick time handler
  tick_timer_service_subscribe((MINUTE_UNIT), tick_handler);
}
Exemplo n.º 13
0
void window_load(Window *window)
{
        //Background Layer
		background_img = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BG);
        bg_layer = bitmap_layer_create(GRect(0, 0, 144, 168));
        bitmap_layer_set_background_color(bg_layer, GColorBlack);
        bitmap_layer_set_bitmap(bg_layer, background_img);
        layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(bg_layer));
	
		//Time layer
        time_layer = text_layer_create(GRect(0, 0, 144, 62));
        text_layer_set_background_color(time_layer, GColorClear);
        text_layer_set_text_color(time_layer, GColorWhite);
        text_layer_set_text_alignment(time_layer, GTextAlignmentCenter);
        text_layer_set_font(time_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD));
        layer_add_child(window_get_root_layer(window), (Layer*) time_layer);
			
		// doge_price_layer
		doge_price_layer = text_layer_create(GRect(0, 65, 144, 50));
		text_layer_set_text_color(doge_price_layer, GColorWhite);
		text_layer_set_background_color(doge_price_layer, GColorClear);
		text_layer_set_font(doge_price_layer, fonts_get_system_font(FONT_KEY_BITHAM_30_BLACK));
		text_layer_set_text_alignment(doge_price_layer, GTextAlignmentCenter);
		
		// usdk_price_layer
		usdk_price_layer = text_layer_create(GRect(0, 120, 144, 50));
		text_layer_set_text_color(usdk_price_layer, GColorWhite);
		text_layer_set_background_color(usdk_price_layer, GColorClear);
		text_layer_set_font(usdk_price_layer, fonts_get_system_font(FONT_KEY_BITHAM_30_BLACK));
		text_layer_set_text_alignment(usdk_price_layer, GTextAlignmentCenter);
        
        layer_add_child(window_get_root_layer(window), (Layer*) time_layer);
		layer_add_child(window_get_root_layer(window), (Layer*) doge_price_layer);
		layer_add_child(window_get_root_layer(window), (Layer*) usdk_price_layer);

	
	//Get a time structure so that the face doesn't start blank
        struct tm *t;
        time_t temp;        
        temp = time(NULL);        
        t = localtime(&temp);        
        
        //Manually call the tick handler when the window is loading
        tick_handler(t, MINUTE_UNIT);
		
}
Exemplo n.º 14
0
static void task_1_func()
{
    TRACE( "enter\n" );
    for( ; task_1_iteration < max_iterations; task_1_iteration++ )
    {
        TRACE( "%d\n", task_1_iteration );
        yield();
        TRACE( "task_2 is idle here\n" );
        tick_handler();
        TRACE( "task_2 is ready here; it will run after yield() at the next iteration\n" );
    }
    TRACE( "task_1_iteration=%d, task_2_iteration=%d\n",
           task_1_iteration, task_2_iteration );

    TEST_RESULT( task_1_iteration == max_iterations
                 && task_2_iteration == max_iterations - 1,
                 "task_1_iteration is greater because of post-increment in for() loop" );
}
Exemplo n.º 15
0
static void main_window_load (Window *window)
{
	Layer *window_layer = window_get_root_layer(window);
	
	// Set the lyrics layer setting...
	platformSettings.grect_lyrics_layer = PBL_IF_RECT_ELSE(GRect(0,0,144,65),layer_get_bounds(window_layer));
	
    s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_TOP_LOGO);
    s_background_bitmap_dithered = gbitmap_create_with_resource(RESOURCE_ID_TOP_LOGO_DITHER);
	s_background_bitmap_thin = gbitmap_create_with_resource(RESOURCE_ID_THIN_TOP_LOGO);
    s_background_layer = bitmap_layer_create(platformSettings.grect_background_layer);
    layer_add_child(window_layer, bitmap_layer_get_layer(s_background_layer));
    
    s_time_layer = text_layer_create(platformSettings.grect_time_layer);
    text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);
    text_layer_set_background_color(s_time_layer, GColorClear);
    text_layer_set_font(s_time_layer,fonts_get_system_font(FONT_KEY_BITHAM_34_MEDIUM_NUMBERS));
    layer_add_child(window_layer,text_layer_get_layer(s_time_layer));
    
    s_date_layer = text_layer_create(platformSettings.grect_date_layer);
    text_layer_set_text_alignment(s_date_layer, PBL_IF_RECT_ELSE(GTextAlignmentRight,GTextAlignmentLeft));
    text_layer_set_background_color(s_date_layer, GColorClear);
    text_layer_set_font(s_date_layer,fonts_get_system_font(FONT_KEY_GOTHIC_18));
    layer_add_child(window_layer,text_layer_get_layer(s_date_layer));
    
    s_dayOfWeek_layer = text_layer_create(platformSettings.grect_dayOfWeek_layer);
    text_layer_set_text_alignment(s_dayOfWeek_layer, PBL_IF_RECT_ELSE(GTextAlignmentRight,GTextAlignmentLeft));
    text_layer_set_background_color(s_dayOfWeek_layer, GColorClear);
    text_layer_set_font(s_dayOfWeek_layer,fonts_get_system_font(FONT_KEY_GOTHIC_18));
    layer_add_child(window_layer,text_layer_get_layer(s_dayOfWeek_layer));

    s_lyrics_layer = text_layer_create(platformSettings.grect_lyrics_layer);
    text_layer_set_font(s_lyrics_layer,fonts_get_system_font(FONT_KEY_GOTHIC_14));
    text_layer_set_background_color(s_lyrics_layer, GColorClear);
    text_layer_set_text_alignment(s_lyrics_layer, GTextAlignmentCenter);
    layer_add_child(window_layer,text_layer_get_layer(s_lyrics_layer));
    text_layer_enable_screen_text_flow_and_paging(s_lyrics_layer, 1);
        
    // Load time when window is loaded
    time_t now = time(NULL); 
    tick_handler(localtime(&now),MINUTE_UNIT | DAY_UNIT);
	
	update_display();
}
Exemplo n.º 16
0
void window_load(Window *window)
{
  ResHandle font_handle = resource_get_handle(RESOURCE_ID_SEAHAWKS_FONT_46);
  seahawks_bitmap = gbitmap_create_with_resource(RESOURCE_ID_SEAHAWKS_LOGO);
  feather_bitmap = gbitmap_create_with_resource(RESOURCE_ID_FEATHER);
  
  
  seahawks_layer = bitmap_layer_create(GRect(0,30,144,60));
  bitmap_layer_set_bitmap(seahawks_layer, seahawks_bitmap);
  layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(seahawks_layer));
  
  //feather
  feather_layer_bottom = bitmap_layer_create(GRect(0,144,144,24));
  bitmap_layer_set_bitmap(feather_layer_bottom, feather_bitmap);
  layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(feather_layer_bottom));
 
  feather_layer_top = bitmap_layer_create(GRect(0,0,144,24));

  bitmap_layer_set_bitmap(feather_layer_top, feather_bitmap);
  layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(feather_layer_top));
  
  
  text_layer = text_layer_create(GRect(15,85,120,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_load_custom_font(font_handle));
  
  layer_add_child(window_get_root_layer(window), (Layer*) text_layer);
  
  inv_layer = inverter_layer_create(GRect(0, 0, 144, 168));
  
  
  layer_add_child(window_get_root_layer(window), (Layer*) inv_layer);

  struct tm *t;
  time_t temp;
  temp = time(NULL);
  t= localtime(&temp);
  
  tick_handler(t, MINUTE_UNIT);
  
  //add window elements
}
Exemplo n.º 17
0
void window_load_main(Window *window){
	Layer *window_layer = window_get_root_layer(window);

	main_settings = get_settings();

	theme = inverter_layer_create(GRect(0, 0, 144, 168));
	first_word_t = text_layer_init(GRect(0, 0, 144, 168), GTextAlignmentLeft, 1);
	second_word_t = text_layer_init(GRect(0, 30, 144, 168), GTextAlignmentLeft, 2);
	third_word_t = text_layer_init(GRect(0, 63, 144, 168), GTextAlignmentLeft, 1);
	fourth_word_t = text_layer_init(GRect(0, 91, 144, 168), GTextAlignmentLeft, 1);
	slot_t = text_layer_init(GRect(0, 130, 144, 168), GTextAlignmentLeft, 3);
	seconds_t = text_layer_init(GRect(115, 0, 20, 20), GTextAlignmentRight, 4);

	battery_bar_layer = layer_create(GRect(0, 0, 144, 168));
	layer_set_update_proc(battery_bar_layer, battery_bar_proc);

	layer_add_child(window_layer, text_layer_get_layer(first_word_t));
	layer_add_child(window_layer, text_layer_get_layer(second_word_t));
	layer_add_child(window_layer, text_layer_get_layer(third_word_t));
	layer_add_child(window_layer, text_layer_get_layer(fourth_word_t));
	layer_add_child(window_layer, text_layer_get_layer(slot_t));
	layer_add_child(window_layer, text_layer_get_layer(seconds_t));
	layer_add_child(window_layer, battery_bar_layer);
	layer_add_child(window_layer, inverter_layer_get_layer(theme));
	notify_bar_create(window);

	tick_timer_service_subscribe(SECOND_UNIT, tick_handler);
	battery_state_service_subscribe(battery_handler);
	bluetooth_connection_service_subscribe(bluetooth_handler);

	BatteryChargeState state = battery_state_service_peek();
	battery_handler(state);

	struct tm *t;
  	time_t temp;        
  	temp = time(NULL);        
  	t = localtime(&temp);
	tick_handler(t, 0);

	refresh_settings();
}
Exemplo n.º 18
0
void handle_init(void) {
  my_window = window_create();
  graph_layer = layer_create(FULL_SCREEN);
  layer_set_update_proc(graph_layer, update_graph);
  
  s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_FORCED_SQUARE_10));
  
  for (int i = 0; i < 13; i++) {
    TextLayer *temp = hour_number_layer[i] = text_layer_create(GRect(0, 23 + 9 * i, 30, 30));
    layer_add_child(graph_layer, text_layer_get_layer(temp));
    text_layer_set_background_color(temp, GColorClear);
    text_layer_set_text_color(temp, TEXT_COLOR);
    text_layer_set_text(temp, "0");
    text_layer_set_font(temp, s_time_font);
    text_layer_set_text_alignment(temp, GTextAlignmentLeft);
  }
  
  for (int i = 0; i < 13; i++) {
    TextLayer *temp = minute_number_layer[i] = text_layer_create(GRect(15 - (i < 2 ? 1 : 0) + 9 * i, 9, 30, 30));
    layer_add_child(graph_layer, text_layer_get_layer(temp));
    text_layer_set_background_color(temp, GColorClear);
    text_layer_set_text_color(temp, TEXT_COLOR);
    text_layer_set_text(temp, "0");
    text_layer_set_font(temp, s_time_font);
    text_layer_set_text_alignment(temp, GTextAlignmentLeft);
  }
  
  window_stack_push(my_window, true);
  layer_add_child(window_get_root_layer(my_window), graph_layer);
  tick_timer_service_subscribe(MINUTE_UNIT | HOUR_UNIT, tick_handler);
  
  for (int i = 0; i < 13; i++)
    text_layer_set_text(hour_number_layer[i], get_string_for_hour(12 - i));
  for (int i = 0; i < 13; i++)
    text_layer_set_text(minute_number_layer[i], get_string_for_minute(i));
  
  time_t temp = time(0);
  struct tm* tick_time = localtime(&temp);
  tick_handler(tick_time, SECOND_UNIT);
}
Exemplo n.º 19
0
void pge_init() {
  s_initd = false;

  data_init();

  const int buffer_size = 64;
  comm_init(buffer_size, buffer_size);

  s_digits[0] = digit_create(GPoint(-HOURS_OFFSET, 0), 0);
  s_digits[1] = digit_create(GPoint(-HOURS_OFFSET + (5 * SEGMENT_SIZE.w), 0), 0);
  s_digits[2] = digit_create(GPoint(MINS_OFFSET, 7 * SEGMENT_SIZE.h), 0);
  s_digits[3] = digit_create(GPoint(MINS_OFFSET + (5 * SEGMENT_SIZE.w), 7 * SEGMENT_SIZE.h), 0);

  pge_isometric_set_projection_offset(PROJECTION_OFFSET);
  pge_set_framerate(FRAME_RATE_HIGH);
  pge_begin(pge_logic, pge_render, NULL);

  tick_timer_service_subscribe(MINUTE_UNIT, tick_handler);

  time_t temp = time(NULL);
  struct tm *t = localtime(&temp);
  tick_handler(t, MINUTE_UNIT);

  main_reload_config();

  // Fast forward - save power when lots of notifications
  while(digits_are_animating()) {
    pge_logic();
  }
  app_focus_service_subscribe(focus_handler);

  // If no animations
  if(!data_get_animations()) {
    pge_manual_advance();

    // Don't animate after this
    pge_pause();
  }
}
Exemplo n.º 20
0
void window_load(Window *window){     
     //setup text layer for time
     text_layer = text_layer_create(GRect(0, 120, 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_load_custom_font(resource_get_handle(RESOURCE_ID_POKEMON_GB_24)));
     layer_add_child(window_get_root_layer(window), (Layer*) text_layer);
     
     //Setup Battery Layer
     batt_layer = text_layer_create(GRect(5, 5, 144, 30));
     text_layer_set_font(batt_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_POKEMON_GB_8)));
     layer_add_child(window_get_root_layer(window), text_layer_get_layer(batt_layer));
 
     //Get info, copy to long-lived buffer and display
     BatteryChargeState state = battery_state_service_peek();
     static char buffer[] = "HP: 100/100";
     snprintf(buffer, sizeof("HP: 100/100"), "HP: %d/100", state.charge_percent);
     text_layer_set_text(batt_layer, buffer);
     
     //Subscribe to AccelerometerService (uncomment one to choose)
     //accel_tap_service_subscribe(accel_tap_handler);
     accel_data_service_subscribe(1, accel_raw_handler);
     
     //Setup Accel Layer
     accel_layer = text_layer_create(GRect(5, 15, 144, 30));
     text_layer_set_font(accel_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_POKEMON_GB_8)));
     text_layer_set_text(accel_layer, "Accel tap: N/A");
     layer_add_child(window_get_root_layer(window), text_layer_get_layer(accel_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);
}
Exemplo n.º 21
0
static void init() {
    if (!persist_exists(BACKGROUND_COLOR_KEY)) {
        persist_write_int(BACKGROUND_COLOR_KEY, pcb_background.argb);
        persist_write_int(SILKSCREEN_COLOR_KEY, pcb_silkscreen.argb);
    }
    else {
        pcb_background.argb = persist_read_int(BACKGROUND_COLOR_KEY);
        pcb_silkscreen.argb = persist_read_int(SILKSCREEN_COLOR_KEY);
    }

    time_t t = time(NULL);
    struct tm *time_now = localtime(&t);
    tick_handler(time_now, MINUTE_UNIT);

    s_ocra_font = fonts_load_custom_font(
        resource_get_handle(RESOURCE_ID_FONT_OCR_A_20));
    
    s_resistor_img = gbitmap_create_with_resource(RESOURCE_ID_RESISTOR_IMG);
    
    s_main_window = window_create();
    window_set_window_handlers(s_main_window, (WindowHandlers) {
        .load = window_load,
        .unload = window_unload,
    });
Exemplo n.º 22
0
static void battery_probe_handler(Task task, MessageId id, Message message) {
	
	switch(id) {
		
		case MESSAGE_ADC_RESULT:
			{
				MessageAdcResult* mar = (MessageAdcResult*)message;
				if (mar) {
					adc_result_handler(mar ->adc_source, mar ->reading);
				}
			}	
			break;
		
		case BATTERY_PROBE_TICK:
		
			tick_handler();
			break;
			
		default:
			
			
			break;
	}
}
Exemplo n.º 23
0
void hal_tick_handler()
{
	tick_handler();
}
Exemplo n.º 24
0
static irqreturn_t mvme147_timer_int (int irq, void *dev_id, struct pt_regs *fp)
{
	m147_pcc->t1_int_cntrl = PCC_TIMER_INT_CLR;
	m147_pcc->t1_int_cntrl = PCC_INT_ENAB|PCC_LEVEL_TIMER1;
	return tick_handler(irq, dev_id, fp);
}
Exemplo n.º 25
0
void window_load(Window *window){
	
	//load bitmap for background/watchface
	face_bitmap = gbitmap_create_with_resource(RESOURCE_ID_WATCHFACE);
	//add bitmap layer
	face_layer = bitmap_layer_create(GRect(0, 0, 144, 168));
	bitmap_layer_set_bitmap(face_layer, face_bitmap);
	layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(face_layer));
	
	//create text layer for bluetooth status
	bt_layer = text_layer_create(GRect(0, 130, 144, 38));
	text_layer_set_background_color(bt_layer, GColorClear);
	text_layer_set_text_color(bt_layer, GColorWhite);
	text_layer_set_text_alignment(bt_layer, GTextAlignmentCenter);
	text_layer_set_font(bt_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14));
	layer_add_child(window_get_root_layer(window), (Layer*) bt_layer);
	
	//manually invoke bluetooth handler to refresh status on load
	bt_handler();
	
	//create text layer for 'pebble' brand at 6oclock
	brand_layer = text_layer_create(GRect(0, 145, 144, 23));
	text_layer_set_background_color(brand_layer, GColorClear);
	text_layer_set_text_color(brand_layer, GColorWhite);
	text_layer_set_text_alignment(brand_layer, GTextAlignmentCenter);
	text_layer_set_font(brand_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
	text_layer_set_text(brand_layer, "pebble");
	layer_add_child(window_get_root_layer(window), (Layer*) brand_layer);
	
	//create text layer for pebble battery status
	batt_layer = text_layer_create(GRect(5, 76, 20, 50));
	text_layer_set_background_color(batt_layer, GColorClear);
	text_layer_set_text_color(batt_layer, GColorWhite);
	text_layer_set_text_alignment(batt_layer, GTextAlignmentCenter);
	text_layer_set_font(batt_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD));
	layer_add_child(window_get_root_layer(window), (Layer*) batt_layer);
	
	//manually invoke battery status handler to refresh status on load
	batt_handler(battery_state_service_peek());
	
	//add text layer for digital time
	text_layer = text_layer_create(GRect(0, 0, 144, 168));
	text_layer_set_background_color(text_layer, GColorClear);
	text_layer_set_text_color(text_layer, GColorWhite);
	text_layer_set_text_alignment(text_layer, GTextAlignmentCenter);
	text_layer_set_font(text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD));
	layer_add_child(window_get_root_layer(window), (Layer*) text_layer);
	
	//create text layer for date
	date_layer = text_layer_create(GRect(116, 76, 25, 50));
	text_layer_set_background_color(date_layer, GColorClear);
	text_layer_set_text_color(date_layer, GColorWhite);
	text_layer_set_text_alignment(date_layer, GTextAlignmentCenter);
	text_layer_set_font(date_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD));
	layer_add_child(window_get_root_layer(window), (Layer*) date_layer);
	
	//add layers for analog clock
	hours_layer = layer_create(GRect(0, 0, 144, 168));
	layer_set_update_proc(hours_layer, hours_layer_update_proc);
	minutes_layer = layer_create(GRect(0, 0, 144, 168));
	layer_set_update_proc(minutes_layer, minutes_layer_update_proc);
	//draw hands
	hour_path = gpath_create(&HOUR_PATH_INFO);
	layer_add_child(window_get_root_layer(window), (Layer*) hours_layer);
	minute_path = gpath_create(&MINUTE_PATH_INFO);
	layer_add_child(window_get_root_layer(window), (Layer*) minutes_layer);
	
	//time struct to display time on load
	struct tm *t;
	time_t temp;
	temp = time(NULL);
	t = localtime(&temp);
	
	//manually invoke tick handler to refresh time on load
	tick_handler(t, MINUTE_UNIT);
	
	//add centre point
	centre_layer = layer_create(GRect(0, 0, 144, 168));
	layer_set_update_proc(centre_layer, centre_layer_update_proc);
	layer_add_child(window_get_root_layer(window), (Layer*) centre_layer);
}
static void update_proc(Layer *layer, GContext *ctx) {
  int padding;
  
  PBL_IF_ROUND_ELSE(padding = 16, padding = 12);
  
  HOURS_TRACK_RADIUS = (window_bounds.size.w - padding) / 2; //66
  HOURS_TRACK_STROKE = 2;
  
  MINUTES_TRACK_RADIUS = HOURS_TRACK_RADIUS - 10; //56
  MINUTES_TRACK_STROKE = 2;
  
  SECONDS_TRACK_RADIUS = HOURS_TRACK_RADIUS - 20; //46
  SECONDS_TRACK_STROKE = 2;
  
  SECONDS_HAND_RADIUS = 2;
  MINUTES_HAND_RADIUS = 3;
  HOURS_HAND_RADIUS = 4;
  
  // Color background
  graphics_context_set_fill_color(ctx, GColorBlack);
  graphics_fill_rect(ctx, window_bounds, 0, GCornerNone);
  
  //APP_LOG(APP_LOG_LEVEL_DEBUG, "bounds: %d %d %d %d", window_bounds.origin.x, window_bounds.origin.y, window_bounds.size.h, window_bounds.size.w );
  

  //set colour for tracks
  graphics_context_set_stroke_color(ctx, GColorWhite );

  graphics_context_set_antialiased(ctx, ANTIALIASING);

  // Don't use current time while animating
  Time mode_time = s_last_time;
  
  // generate position of hands
  
  GPoint second_hand = (GPoint) {
    .x = (int16_t)(sin_lookup(TRIG_MAX_ANGLE * mode_time.seconds / 60) * (int32_t)(SECONDS_TRACK_RADIUS) / TRIG_MAX_RATIO) + s_center.x,
    .y = (int16_t)(-cos_lookup(TRIG_MAX_ANGLE * mode_time.seconds / 60) * (int32_t)(SECONDS_TRACK_RADIUS) / TRIG_MAX_RATIO) + s_center.y,
  };
	
  float minutes, hours;	
	
  if (SWEEP_MINUTES == true) {
	minutes = mode_time.minutes + (float)mode_time.seconds / 60;
  } else {
	minutes = mode_time.minutes;
  }
	
  GPoint minute_hand = (GPoint) {
    .x = (int16_t)(sin_lookup(TRIG_MAX_ANGLE * minutes / 60) * (int32_t)(MINUTES_TRACK_RADIUS) / TRIG_MAX_RATIO) + s_center.x,
    .y = (int16_t)(-cos_lookup(TRIG_MAX_ANGLE * minutes/ 60) * (int32_t)(MINUTES_TRACK_RADIUS) / TRIG_MAX_RATIO) + s_center.y,
  };

  if( SWEEP_HOURS == true) {
    hours = mode_time.hours + (float)mode_time.minutes / 60;
  } else {
	hours = mode_time.hours; 
  }

  GPoint hour_hand = (GPoint) {
    .x = (int16_t)(sin_lookup(TRIG_MAX_ANGLE * hours / 12) * (int32_t)(HOURS_TRACK_RADIUS) / TRIG_MAX_RATIO) + s_center.x,
    .y = (int16_t)(-cos_lookup(TRIG_MAX_ANGLE * hours / 12) * (int32_t)(HOURS_TRACK_RADIUS) / TRIG_MAX_RATIO) + s_center.y,
  };
	
  graphics_context_set_fill_color(ctx, GColorWhite);
  
  GRect seconds_rect = GRect(s_center.x - SECONDS_TRACK_RADIUS, s_center.y - SECONDS_TRACK_RADIUS, SECONDS_TRACK_RADIUS * 2, SECONDS_TRACK_RADIUS * 2);
  
  GRect minutes_rect = GRect(s_center.x - MINUTES_TRACK_RADIUS, s_center.y - MINUTES_TRACK_RADIUS, MINUTES_TRACK_RADIUS * 2, MINUTES_TRACK_RADIUS * 2);
  
  GRect hours_rect = GRect(s_center.x - HOURS_TRACK_RADIUS, s_center.y - HOURS_TRACK_RADIUS, HOURS_TRACK_RADIUS * 2, HOURS_TRACK_RADIUS * 2);
  
 //----------------------------------
    
  int seconds_start_angle, seconds_end_angle;
  
  int seconds_delta = 12;
  int minutes_delta = 12;
  int hours_delta = 12;
	
  get_angles_60(mode_time.seconds, 0, seconds_delta, &seconds_start_angle, &seconds_end_angle);
  
  //----------------------------------
  
  //int minutes_angle = mode_time.minutes * 360 / 60;
  int minutes_start_angle, minutes_end_angle;
    
  get_angles_60(mode_time.minutes, (SWEEP_MINUTES == true) ? mode_time.seconds : 0, minutes_delta, &minutes_start_angle, &minutes_end_angle);
  //get_angles_60(mode_time.minutes, mode_time.seconds, minutes_delta, &minutes_start_angle, &minutes_end_angle);
  
  //----------------------------------
  
  //int hours_angle = mode_time.hours * 360 / 12;
  int hours_start_angle, hours_end_angle;

  get_angles_12(mode_time.hours,(SWEEP_HOURS == true) ? mode_time.minutes : 0, hours_delta, &hours_start_angle, &hours_end_angle);
  
  //APP_LOG(APP_LOG_LEVEL_DEBUG, "seconds: %d, start: %d, end: %d",  mode_time.seconds, seconds_start_angle, seconds_end_angle);
  
   //set colour for arcs and "hands"
    graphics_context_set_fill_color(ctx, GColorWhite );
    
  //draw seconds arc
  graphics_fill_radial(ctx, seconds_rect, GOvalScaleModeFitCircle, SECONDS_TRACK_STROKE,  DEG_TO_TRIGANGLE(seconds_start_angle), DEG_TO_TRIGANGLE(seconds_end_angle));
  
  //draw minutes arc
  graphics_fill_radial(ctx, minutes_rect, GOvalScaleModeFitCircle, MINUTES_TRACK_STROKE,  DEG_TO_TRIGANGLE(minutes_start_angle), DEG_TO_TRIGANGLE(minutes_end_angle));
  
  //draw hours arc
  graphics_fill_radial(ctx, hours_rect, GOvalScaleModeFitCircle, HOURS_TRACK_STROKE,  DEG_TO_TRIGANGLE(hours_start_angle), DEG_TO_TRIGANGLE(hours_end_angle));
  
  //draw minute hand
  graphics_fill_circle(ctx, minute_hand, MINUTES_HAND_RADIUS);
  
  //draw hour hand
  graphics_fill_circle(ctx, hour_hand, HOURS_HAND_RADIUS);
  
  //draw second hand
  graphics_context_set_fill_color(ctx, GColorRed );
  graphics_fill_circle(ctx, second_hand, SECONDS_HAND_RADIUS);
	
	update_time();
}

static void window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  
  window_bounds = layer_get_bounds(window_layer);
  
  //APP_LOG(APP_LOG_LEVEL_DEBUG, "bounds: %d %d %d %d", window_bounds.origin.x, window_bounds.origin.y, window_bounds.size.h, window_bounds.size.w );

  s_center = grect_center_point(&window_bounds);
  
  s_canvas_layer = layer_create(window_bounds);
  layer_set_update_proc(s_canvas_layer, update_proc);
  layer_add_child(window_layer, s_canvas_layer);
	
// Create time TextLayer
  
  int font_height;
  
  PBL_IF_ROUND_ELSE(font_height = 45, font_height = 36); //fudge factor to get text vertically centred
  
  s_time_layer = text_layer_create(GRect(window_bounds.origin.x, (window_bounds.size.h-font_height)/2, window_bounds.size.w, font_height));
	
  //s_center.y - MINUTES_TRACK_RADIUS + 18 + 18;
		
  s_day_layer = text_layer_create(GRect(0, s_center.y - 18 - 18  , window_bounds.size.w, 18)); //need to calculate proper y-location
  s_month_layer = text_layer_create(GRect(0, s_center.y +36 , window_bounds.size.w, 18)); //need to calculate proper y-location
  
  text_layer_set_background_color(s_day_layer, GColorRed);
  text_layer_set_text_color(s_day_layer, GColorLightGray  );
  text_layer_set_text(s_day_layer, "00");
  
  text_layer_set_background_color(s_time_layer, GColorClear);
  text_layer_set_text_color(s_time_layer, GColorWhite);
  text_layer_set_text(s_time_layer, "00:00");
	
  text_layer_set_background_color(s_month_layer, GColorClear);
  text_layer_set_text_color(s_month_layer, GColorLightGray );
  text_layer_set_text(s_month_layer, "XXX");
  
  PBL_IF_ROUND_ELSE(s_custom_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_DOSIS_SEMIBOLD_40)), s_custom_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_DOSIS_SEMIBOLD_30)));

  text_layer_set_font(s_time_layer, s_custom_font);
  text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);
	
  text_layer_set_font(s_day_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_DOSIS_SEMIBOLD_18)));
  text_layer_set_text_alignment(s_day_layer, GTextAlignmentCenter);

  text_layer_set_font(s_month_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_DOSIS_SEMIBOLD_18)));
  text_layer_set_text_alignment(s_month_layer, GTextAlignmentCenter);
  
  // Add it as a child layer to the Window's root layer
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_time_layer));
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_day_layer));
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_month_layer));
	// Make sure the time is displayed from the start
  update_time();
}

static void window_unload(Window *window) {
  layer_destroy(s_canvas_layer);
  // Destroy TextLayer
  text_layer_destroy(s_time_layer);
  text_layer_destroy(s_day_layer);
  text_layer_destroy(s_month_layer);
  fonts_unload_custom_font(s_custom_font);
}

/*********************************** App **************************************/

static void init() {
  srand(time(NULL));

  time_t t = time(NULL);
  struct tm *time_now = localtime(&t);
  tick_handler(time_now, SECOND_UNIT);

  s_main_window = window_create();
  window_set_window_handlers(s_main_window, (WindowHandlers) {
    .load = window_load,
    .unload = window_unload,
  });
Exemplo n.º 27
0
HandlerResult DomainProperty::operation(LocatedEntity * e, const Operation & op, OpVector & res)
{
    return tick_handler(e, op, res);
}
Exemplo n.º 28
0
static void main_window_load(Window *window) {
  
  window_set_background_color(s_my_window, GColorBlack);

  tick_timer_service_subscribe(MINUTE_UNIT, tick_handler);

  bluetooth_connection_service_subscribe(bluetooth_handler);

  s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_LIGHT_72));

  s_minute_layer = text_layer_create(GRect(15, 56, 144, 80));
  text_layer_set_text(s_minute_layer, "");
  text_layer_set_text_alignment(s_minute_layer, GTextAlignmentCenter);
  text_layer_set_font(s_minute_layer, s_time_font);
  text_layer_set_background_color(s_minute_layer, GColorClear);

  s_hour_layer = text_layer_create(GRect(-23, 19, 154, 61));
  text_layer_set_font(s_hour_layer, s_time_font);
  text_layer_set_text(s_hour_layer, "");
  text_layer_set_text_alignment(s_hour_layer, GTextAlignmentCenter);
  text_layer_set_background_color(s_hour_layer, GColorBlack);
  
  date_layer = text_layer_create(GRect(0, 0, 144, 20));
  text_layer_set_font(date_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18));
  text_layer_set_text_alignment(date_layer, GTextAlignmentCenter);
  text_layer_set_background_color(date_layer, GColorBlack);
  text_layer_set_text_color(date_layer, GColorWhite);
 
  s_line_layer = layer_create(GRect(0 , 0, 144, 168));
  layer_set_update_proc(s_line_layer, s_layer_update_proc);
  
  #ifdef PBL_BW
  s_inv_layer = inverter_layer_create(GRect(0, 0, 144, 168));

    text_layer_set_text_color(s_minute_layer , GColorWhite);
    text_layer_set_text_color(s_hour_layer , GColorWhite);
  #else 
    text_layer_set_text_color(s_minute_layer , GColorSpringBud);
    text_layer_set_text_color(s_hour_layer , GColorGreen);
    
    #endif
  
      
  
  layer_add_child(window_get_root_layer(s_my_window), text_layer_get_layer(s_minute_layer));
  layer_add_child(window_get_root_layer(s_my_window), text_layer_get_layer(s_hour_layer));
  layer_add_child(window_get_root_layer(s_my_window), s_line_layer);
  layer_add_child(window_get_root_layer(s_my_window), text_layer_get_layer(date_layer));
  #ifdef PBL_BW
  layer_add_child(window_get_root_layer(window), inverter_layer_get_layer(s_inv_layer));
  #endif  
       
  if(persist_exists(KEY_INVERT_FACE)){
      invert_face = persist_read_int(KEY_INVERT_FACE);
    APP_LOG(APP_LOG_LEVEL_INFO, "Read Invert");
    }
  
   if(persist_exists(KEY_BLUETOOTH_VIBRATION)){
    bluetooth_vibration = persist_read_int(KEY_BLUETOOTH_VIBRATION);
    APP_LOG(APP_LOG_LEVEL_INFO,"Bluetooth read");
   }
  if(persist_exists(KEY_SHOW_DATE)){
    show_date = persist_read_int(KEY_SHOW_DATE);
    APP_LOG(APP_LOG_LEVEL_INFO, "Read Date");
  }
      

update_time();
update_layers();
    
  struct tm *t;
  time_t temp;
  temp = time(NULL);
  t = localtime(&temp);
  
  tick_handler(t, MINUTE_UNIT);
  
  
  
 
}
Exemplo n.º 29
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);
		
}
Exemplo n.º 30
0
void window_load(Window *window)
{
    // changing placement of items based on the shape of the device
    #if defined(PBL_RECT)
      //bg_layer = bitmap_layer_create(GRect(0, 0, 144, 168));
      time_layer = text_layer_create(GRect(0, 20, 144, 62));
      eastbound_label_layer = text_layer_create(GRect(0, 95, 24, 24));
      westbound_label_layer = text_layer_create(GRect(0, 120, 24, 24));
      nearestStationLayer = text_layer_create(GRect(0, 70, 144, 24));
      eastboundLayer = text_layer_create(GRect(25, 95, 119, 24));
      westboundLayer = text_layer_create(GRect(25, 120, 119, 24));
    #elif defined(PBL_ROUND)
      //bg_layer = bitmap_layer_create(GRect(0, 0, 180, 180));
      time_layer = text_layer_create(GRect(20, 20, 144, 62));
      eastbound_label_layer = text_layer_create(GRect(30, 95, 24, 24));
      westbound_label_layer = text_layer_create(GRect(30, 120, 24, 24));
      nearestStationLayer = text_layer_create(GRect(30, 70, 144, 24));
      eastboundLayer = text_layer_create(GRect(55, 95, 119, 24));
      westboundLayer = text_layer_create(GRect(55, 120, 119, 24));
    #endif
  
    //Background Layer
		//background_img = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BG);
    //GRect bounds = bitmap_layer_get_bounds(bg_layer);
    //bg_layer = bitmap_layer_create(GRect(0, 0, 144, 168));
    #ifdef PBL_COLOR
      //have a config file for choosing colors
      //window_set_background_color(window, GColorIslamicGreen);
      window_set_background_color(window, GColorBlack);
    #else
      window_set_background_color(window, GColorBlack);
    #endif
//     bitmap_layer_set_background_color(bg_layer, GColorBlack);
//     bitmap_layer_set_bitmap(bg_layer, background_img);
//     layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(bg_layer));
    

		//Time layer
    //time_layer = text_layer_create(GRect(0, 20, 144, 62));
    text_layer_set_background_color(time_layer, GColorClear);
    text_layer_set_text_color(time_layer, GColorWhite);
    text_layer_set_text_alignment(time_layer, GTextAlignmentCenter);
    text_layer_set_font(time_layer, fonts_get_system_font(FONT_KEY_BITHAM_30_BLACK));
    

	
    //text_layer_set_font(usdk_price_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_COMIC_SANS_20)));
    //text_layer_set_font(time_layer, fonts_get_system_font(FONT_KEY_LECO_20_BOLD_NUMBERS));


    //layer for the station label
//     station_label_layer = text_layer_create(GRect(0, 70, 55, 24));
//     text_layer_set_background_color(station_label_layer, GColorClear);
//     text_layer_set_text_color(station_label_layer, GColorWhite);
//     text_layer_set_text_alignment(station_label_layer, GTextAlignmentLeft);
//     text_layer_set_font(station_label_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));


    // eastbound label
    //eastbound_label_layer = text_layer_create(GRect(0, 95, 24, 24));
    text_layer_set_background_color(eastbound_label_layer, GColorClear);
    text_layer_set_text_color(eastbound_label_layer, GColorWhite);
    text_layer_set_text_alignment(eastbound_label_layer, GTextAlignmentLeft);
    text_layer_set_font(eastbound_label_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
    

    // westbound label
    //westbound_label_layer = text_layer_create(GRect(0, 120, 24, 24));
    text_layer_set_background_color(westbound_label_layer, GColorClear);
    text_layer_set_text_color(westbound_label_layer, GColorWhite);
    text_layer_set_text_alignment(westbound_label_layer, GTextAlignmentLeft);
    text_layer_set_font(westbound_label_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
    
  
    //naerestStationLayer
		//nearestStationLayer = text_layer_create(GRect(0, 70, 144, 24));
		text_layer_set_text_color(nearestStationLayer, GColorWhite);
		text_layer_set_background_color(nearestStationLayer, GColorClear);
    text_layer_set_font(nearestStationLayer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
		text_layer_set_text_alignment(nearestStationLayer, GTextAlignmentLeft);
    
    
	  // eastboundLayer
		//eastboundLayer = text_layer_create(GRect(25, 95, 119, 24));
		text_layer_set_text_color(eastboundLayer, GColorWhite);
		text_layer_set_background_color(eastboundLayer, GColorClear);
    text_layer_set_font(eastboundLayer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
		text_layer_set_text_alignment(eastboundLayer, GTextAlignmentLeft);
    

		// westboundLayer
		//westboundLayer = text_layer_create(GRect(25, 120, 119, 24));
		text_layer_set_text_color(westboundLayer, GColorWhite);
		text_layer_set_background_color(westboundLayer, GColorClear);
    text_layer_set_font(westboundLayer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
		text_layer_set_text_alignment(westboundLayer, GTextAlignmentLeft);
    
    //adding all the layers
    layer_add_child(window_get_root_layer(window), (Layer*) time_layer);
		layer_add_child(window_get_root_layer(window), (Layer*) nearestStationLayer);
		layer_add_child(window_get_root_layer(window), (Layer*) eastboundLayer);
		layer_add_child(window_get_root_layer(window), (Layer*) westboundLayer);
    //layer_add_child(window_get_root_layer(window), (Layer*) station_label_layer);  
    layer_add_child(window_get_root_layer(window), (Layer*) eastbound_label_layer);
    layer_add_child(window_get_root_layer(window), (Layer*) westbound_label_layer);
    
    // setting the text for all the numbers
    text_layer_set_text(nearestStationLayer, "");
    text_layer_set_text(eastboundLayer, "");
    text_layer_set_text(westboundLayer, "");
    //setting the labels for the numbers.
    //text_layer_set_text(station_label_layer, "Station:");
    text_layer_set_text(eastbound_label_layer,"E:");
    text_layer_set_text(westbound_label_layer,"W:");
  
    

	  //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);
}