示例#1
0
void init_compass_service(Window * watchface) {
    if (is_module_enabled(MODULE_COMPASS)) {
        compass_service_subscribe((CompassHeadingHandler)compass_handler);
        compass_service_set_heading_filter(TRIG_MAX_ANGLE/64);
    } else {
        compass_service_unsubscribe();
    }
}
示例#2
0
static void init ()
{
	app_message_register_inbox_received(inbox_received_callback);
	app_message_register_inbox_dropped(inbox_dropped_callback);
	app_message_register_outbox_failed(outbox_failed_callback);
	app_message_register_outbox_sent(outbox_sent_callback);
	app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum());
	compass_service_set_heading_filter(10);
	compass_service_subscribe(&compass_handler); 
	main_window = window_create();
	window_set_window_handlers(main_window, (WindowHandlers)
	{
		.load = main_window_load,
		.unload = main_window_unload
	});
示例#3
0
static void main_window_load(Window *window) {
  // Set click config handler
  window_set_click_config_provider(s_spin_window, (ClickConfigProvider) start_spin_click_config_provider);
  
  // Window layer properties
  Layer *window_layer = window_get_root_layer(window);
  GRect window_bounds = layer_get_bounds(window_layer);
  
  // Points
  s_center = grect_center_point(&window_bounds);
  s_spin_circle_center = GPoint(s_center.x, s_center.y + 10);
  
  // Rects
  s_welcome_rect = GRect(112, s_center.y, 10, 10);
  
  // Welcome arrow
  s_welcome_arrow_path = gpath_create(&SPIN_ARROW_PATH_INFO);
  gpath_move_to(s_welcome_arrow_path, GPoint(120, s_center.y + 15));
  s_welcome_canvas_layer = layer_create(window_bounds);
  layer_set_update_proc(s_welcome_canvas_layer, update_welcome_proc);
  layer_add_child(window_layer, s_welcome_canvas_layer);
  
  // Welcome text layer
  s_welcome_text_layer = text_layer_create(GRect(10, s_center.y - 12, 144, 50));
  text_layer_set_text(s_welcome_text_layer, "Press and hold");
  text_layer_set_background_color(s_welcome_text_layer, GColorClear);
  text_layer_set_text_color(s_welcome_text_layer, GColorWhite);
  text_layer_set_font(s_welcome_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
  layer_add_child(window_layer, text_layer_get_layer(s_welcome_text_layer));
  
  // Spin circle Layer
  s_spin_circle_canvas_layer = layer_create(window_bounds);
  layer_set_update_proc(s_spin_circle_canvas_layer, update_spin_circle_proc);
  layer_add_child(window_layer, s_spin_circle_canvas_layer);
  
   // Spin triangle / arrow Layer
  s_spin_arrow_path = gpath_create(&SPIN_ARROW_PATH_INFO);
  s_spin_triangle_path = gpath_create(&BOLT_PATH_INFO);
  gpath_move_to(s_spin_triangle_path, s_spin_circle_center);
  s_spin_triangle_canvas_layer = layer_create(window_bounds);
  layer_set_update_proc(s_spin_triangle_canvas_layer, update_triangle_proc);
  layer_add_child(window_layer, s_spin_triangle_canvas_layer);
  
  // Spin heading TextLayer
  s_spin_heading_text_layer = text_layer_create(GRect(0, 5, 144, 50));
  text_layer_set_text(s_spin_heading_text_layer, "To turn off alarm");
  text_layer_set_background_color(s_spin_heading_text_layer, GColorClear);
  text_layer_set_text_color(s_spin_heading_text_layer, GColorWhite);
  text_layer_set_font(s_spin_heading_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14));
  text_layer_set_text_alignment(s_spin_heading_text_layer, GTextAlignmentCenter);
  layer_add_child(window_layer, text_layer_get_layer(s_spin_heading_text_layer));
  
  // Spin top text TextLayer
  s_spin_top_text_layer = text_layer_create(GRect(0, s_spin_circle_center.y - 30, 144, 50));
  text_layer_set_text(s_spin_top_text_layer, "Spin Around");
  text_layer_set_background_color(s_spin_top_text_layer, GColorClear);
  text_layer_set_text_color(s_spin_top_text_layer, GColorWhite);
  text_layer_set_font(s_spin_top_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14));
  text_layer_set_text_alignment(s_spin_top_text_layer, GTextAlignmentCenter);
  layer_add_child(window_layer, text_layer_get_layer(s_spin_top_text_layer));
  
  // Spin spins TextLayer
  s_spin_spins_text_layer = text_layer_create(GRect(0, s_spin_circle_center.y - 14, 144, 50));
  text_layer_set_text(s_spin_spins_text_layer, "2");
  text_layer_set_background_color(s_spin_spins_text_layer, GColorClear);
  text_layer_set_text_color(s_spin_spins_text_layer, GColorWhite);
  text_layer_set_font(s_spin_spins_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28));
  text_layer_set_text_alignment(s_spin_spins_text_layer, GTextAlignmentCenter);
  layer_add_child(window_layer, text_layer_get_layer(s_spin_spins_text_layer));
  
  // Spin bottom text TextLayer
  s_spin_bottom_text_layer = text_layer_create(GRect(0, s_spin_circle_center.y + 34 - 14, 144, 50));
  text_layer_set_text(s_spin_bottom_text_layer, "Times!");
  text_layer_set_background_color(s_spin_bottom_text_layer, GColorClear);
  text_layer_set_text_color(s_spin_bottom_text_layer, GColorWhite);
  text_layer_set_font(s_spin_bottom_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14));
  text_layer_set_text_alignment(s_spin_bottom_text_layer, GTextAlignmentCenter);
  layer_add_child(window_layer, text_layer_get_layer(s_spin_bottom_text_layer));
  
  // Spin time TextLayer
  s_spin_time_layer = text_layer_create(GRect(0, s_spin_circle_center.y + 38, 144, 50));
  text_layer_set_background_color(s_spin_time_layer, GColorClear);
  text_layer_set_text_color(s_spin_time_layer, GColorWhite);
  text_layer_set_font(s_spin_time_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD));
  text_layer_set_text_alignment(s_spin_time_layer, GTextAlignmentCenter);
//   layer_add_child(window_layer, text_layer_get_layer(s_spin_time_layer));
  
  // Register with TickTimerService
  tick_timer_service_subscribe(MINUTE_UNIT, tick_handler);
  
  // Subscribe to the compass data service when angle changes by 5 degrees
  compass_service_subscribe(compass_handler);
  compass_service_set_heading_filter(5);
  
  // Make sure the time is displayed from the start
  update_time();
  
  // TODO: remove this
  set_alarm_on(true);
}