예제 #1
0
void handle_init(void) {
  window = window_create();
  window_stack_push(window, true /* Animated */);
  window_set_background_color(window, GColorBlack);
  
  fontRobotoCondensed19  = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_19));
  
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);

  triangle_overlay_layer = layer_create(bounds);
	layer_set_update_proc(triangle_overlay_layer, triangle_display_layer_update_callback);
	layer_add_child(window_layer, triangle_overlay_layer);
	triangle_overlay_path = gpath_create(&TRIANGLE_OVERLAY_POINTS);
	gpath_move_to(triangle_overlay_path, grect_center_point(&bounds));
  
  // init hand paths
  minute_arrow_path = gpath_create(&MINUTE_HAND_POINTS);
  gpath_move_to(minute_arrow_path, grect_center_point(&bounds));
  
  hour_arrow_path = gpath_create(&HOUR_HAND_POINTS);
  gpath_move_to(hour_arrow_path, grect_center_point(&bounds));

  tick_timer_service_subscribe(MINUTE_UNIT, handle_tick);
  

  s_hands_layer = layer_create(bounds);

  layer_set_update_proc(s_hands_layer, hands_update_proc);
  layer_add_child(window_layer, s_hands_layer);
  
  // Battery Line Basalt
   #ifdef PBL_PLATFORM_BASALT
      GRect line_frame = GRect(22, 160, 104, 6);
      LineLayer = layer_create(line_frame);
      layer_set_update_proc(LineLayer, line_layer_update_callback);
      layer_add_child(window_layer, LineLayer);
   #else //Chalk
      GRect line_round_frame = GRect(1, 1, 180, 180);
      RoundBatteryLayer = layer_create(line_round_frame);
      layer_set_update_proc(RoundBatteryLayer, RoundBatteryLayer_update_callback);
      layer_add_child(window_layer,RoundBatteryLayer);
   #endif
     
  //Service subscribes:
  battery_state_service_subscribe(&handle_battery);
  
  handle_battery(battery_state_service_peek());
  
  bluetooth_connection_service_subscribe(&handle_bluetooth);
  handle_bluetooth(bluetooth_connection_service_peek());
     
  app_focus_service_subscribe(&handle_appfocus);

}
예제 #2
0
static void handle_init(void) {
    // Migrate DB
    migrate_version();

    accel_data_service_subscribe(0, NULL);
	show_sleep_window();
    int inbox_size = app_message_inbox_size_maximum();
    int outbox_size = app_message_outbox_size_maximum();
    app_message_open(inbox_size, outbox_size);
    set_outbox_size(outbox_size);

    app_message_register_inbox_received(in_received_handler);
    app_message_register_inbox_dropped(in_dropped_handler);
    app_message_register_outbox_sent(out_sent_handler);
    app_message_register_outbox_failed(out_failed_handler);

    // Subscribe to Worker messages
    app_worker_message_subscribe(worker_message_handler);
    app_focus_service_subscribe(focus_handler);
}
예제 #3
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();
  }
}
예제 #4
0
void handle_init() {
	
	INFO_LOG("Starting MiniDungeon");
	time_t now = time(NULL);
	
	srand(now);
	DEBUG_LOG("Srand");
	
	handle_minute_tick(NULL, MINUTE_UNIT);
	DEBUG_LOG("First handle second");
	
	InitializeGameData();

#if ALLOW_WORKER_APP
	app_worker_message_subscribe(WorkerMessageHandler);
	AppAwake();
#endif
	DEBUG_LOG("InitializeGameData");
	ShowAdventureWindow();
	tick_timer_service_subscribe(MINUTE_UNIT, &handle_minute_tick);
	app_focus_service_subscribe(focus_handler);
}
예제 #5
0
파일: WA1OUI.c 프로젝트: DHKaplan/WA1OUI
//********************************** Handle Init **************************
void handle_init(void) {

  if (quiet_time_is_active()) {
     QuietTimeColor = GColorYellow;
     }
     else
     {  
     QuietTimeColor = GColorRed;
     }
  
  GColor BGCOLOR   = COLOR_FALLBACK(GColorDukeBlue, GColorBlack);
  BGColorHold = BGCOLOR;

  GColor TEXTCOLOR = COLOR_FALLBACK(GColorWhite, GColorWhite);
  TextColorHold = TEXTCOLOR;

  window = window_create();
  window_set_background_color(window, BGCOLOR);
  window_stack_push(window, true /* Animated */);

  fontHelvNewLight20 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_HELV_NEW_LIGHT_20));
  fontRobotoCondensed20  = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_20));
  fontRobotoCondensed21  = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_21));
  fontRobotoBoldSubset37 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLD_SUBSET_37));
  fontRobotoBoldSubset49 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLD_SUBSET_49));

  Layer *window_layer = window_get_root_layer(window);

  // Register callbacks
  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);

  // Open AppMessage
  app_message_open(128, 128);

  //degrees
  text_degrees_layer = text_layer_create(GRect(30, 1, 60, 200));
  text_layer_set_text_alignment(text_degrees_layer, GTextAlignmentCenter);
  text_layer_set_text(text_degrees_layer, degreesstr);
  text_layer_set_font(text_degrees_layer, fontRobotoCondensed20);
  text_layer_set_background_color(text_degrees_layer, BGCOLOR);
  text_layer_set_text_color(text_degrees_layer, TEXTCOLOR);
  layer_add_child(window_layer, text_layer_get_layer(text_degrees_layer));

  //degrees inside
  text_degrees_inside_layer = text_layer_create(GRect(85, 2, 55, 26));
  text_layer_set_text_alignment(text_degrees_inside_layer, GTextAlignmentRight);
  text_layer_set_text(text_degrees_inside_layer, degreesstr);
  text_layer_set_font(text_degrees_inside_layer, fontRobotoCondensed20);
  text_layer_set_background_color(text_degrees_inside_layer, BGCOLOR);
  text_layer_set_text_color(text_degrees_inside_layer, TEXTCOLOR);
  layer_add_child(window_layer, text_layer_get_layer(text_degrees_inside_layer));


  // WA1OUI
  text_wa1oui_layer = text_layer_create(GRect(1,25, 144, 148));
  text_layer_set_text_alignment(text_wa1oui_layer, GTextAlignmentCenter);
  text_layer_set_text(text_wa1oui_layer, "WA1OUI");
  text_layer_set_font(text_wa1oui_layer, fontRobotoBoldSubset37);
  text_layer_set_text_color(text_wa1oui_layer, TEXTCOLOR);
  text_layer_set_background_color(text_wa1oui_layer, BGCOLOR);
  layer_add_child(window_layer, text_layer_get_layer(text_wa1oui_layer));


  // Dayname
  text_dayname_layer = text_layer_create(GRect(1, 65, 35, 168-65));
  text_layer_set_text_alignment(text_dayname_layer, GTextAlignmentLeft);
  text_layer_set_font(text_dayname_layer, fontRobotoCondensed20);
  text_layer_set_text_color(text_dayname_layer, TEXTCOLOR);
  text_layer_set_background_color(text_dayname_layer, BGCOLOR);
  layer_add_child(window_layer, text_layer_get_layer(text_dayname_layer));
  
  
  // wind
  text_wind_layer = text_layer_create(GRect(37, 65, 60, 168-65));
  text_layer_set_text_alignment(text_wind_layer, GTextAlignmentCenter);
  text_layer_set_font(text_wind_layer, fontRobotoCondensed20);
  text_layer_set_text_color(text_wind_layer, TEXTCOLOR);
  text_layer_set_background_color(text_wind_layer, BGCOLOR);
  layer_add_child(window_layer, text_layer_get_layer(text_wind_layer));
  
  // Rain
  text_rain_layer = text_layer_create(GRect(95, 65, 49, 168-65));
  text_layer_set_text_alignment(text_rain_layer, GTextAlignmentRight);
  text_layer_set_font(text_rain_layer, fontRobotoCondensed21);
  text_layer_set_text_color(text_rain_layer, TEXTCOLOR);
  text_layer_set_background_color(text_rain_layer, BGCOLOR);
  layer_add_child(window_layer, text_layer_get_layer(text_rain_layer));
  

  // Date
  text_date_layer = text_layer_create(GRect(8, 88, 144-8, 168-88));
  text_layer_set_text_alignment(text_date_layer, GTextAlignmentCenter);
  text_layer_set_font(text_date_layer, fontRobotoCondensed21);
  text_layer_set_text_color(text_date_layer, TEXTCOLOR);
  text_layer_set_background_color(text_date_layer, BGCOLOR);
  layer_add_child(window_layer, text_layer_get_layer(text_date_layer));


  // Time of Day
  text_time_layer = text_layer_create(GRect(7, 116, 144-7, 168-116));
  text_layer_set_text_alignment(text_time_layer, GTextAlignmentCenter);
  text_layer_set_font(text_time_layer, fontRobotoBoldSubset49);
  text_layer_set_text_color(text_time_layer, TEXTCOLOR);
  text_layer_set_background_color(text_time_layer, BGCOLOR);
  layer_add_child(window_layer, text_layer_get_layer(text_time_layer));

  // Red Line
  GRect red_line_frame = GRect(10, 28, 124, 2);
  RedLineLayer = layer_create(red_line_frame);
  layer_set_update_proc(RedLineLayer, red_line_layer_update_callback);
  layer_add_child(window_layer, RedLineLayer);

  // Battery Line
  GRect line_frame = GRect(22, 118, 104, 6);
  LineLayer = layer_create(line_frame);
  layer_set_update_proc(LineLayer, line_layer_update_callback);
  layer_add_child(window_layer, LineLayer);

  tick_timer_service_subscribe(MINUTE_UNIT, handle_tick);

  //Bluetooth Logo Setup area
  GRect BTArea = GRect(1, 5, 20, 20);
  BTLayer1 = layer_create(BTArea);

  layer_add_child(window_layer, BTLayer1);

  layer_set_update_proc(BTLayer1, BTLine_update_callback);

  bluetooth_connection_service_subscribe(&handle_bluetooth);

 
  handle_bluetooth(bluetooth_connection_service_peek());
  handle_battery(battery_state_service_peek());

  //app focus service subscribe
  app_focus_service_subscribe(&handle_appfocus);
  
  // 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_tick(current_time, SECOND_UNIT);
}
예제 #6
0
void handle_init(void) {
  APP_LOG(APP_LOG_LEVEL_ERROR, "In Init * * * * * ");
  
  GColor BGCOLOR   = COLOR_FALLBACK(GColorDukeBlue, GColorBlack);
  BGColorHold = BGCOLOR;

  GColor TEXTCOLOR = COLOR_FALLBACK(GColorWhite, GColorWhite);
  TextColorHold = TEXTCOLOR;

  window = window_create();
  window_stack_push(window, true /* Animated */);
  window_set_background_color(window, BGCOLOR);

  fontHelvNewLight20     = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_HELV_NEW_LIGHT_20));
  fontRobotoBoldSubset40 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLD_SUBSET_40));
  fontRobotoBoldSubset45 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLD_SUBSET_45));
  Layer *window_layer = window_get_root_layer(window);

  // Register callbacks
  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);

  // Open AppMessage
  app_message_open(64, 64);

// Date
  #ifdef PBL_PLATFORM_CHALK
     text_date_layer = text_layer_create(GRect(1, 94, 180, 28));
  #else
     text_date_layer = text_layer_create(GRect(1, 94, 144, 28));
  #endif
  
  text_layer_set_text_color(text_date_layer, TEXTCOLOR);
  text_layer_set_background_color(text_date_layer, BGCOLOR);
  text_layer_set_text_alignment(text_date_layer, GTextAlignmentCenter);;
  text_layer_set_font(text_date_layer, fonts_get_system_font(FONT_KEY_ROBOTO_CONDENSED_21));
  layer_add_child(window_layer, text_layer_get_layer(text_date_layer));

 //Persistent Value Date Format:
  if (persist_exists(MESSAGE_KEY_DATE_FORMAT_KEY)) {
     persist_read_string(MESSAGE_KEY_DATE_FORMAT_KEY  , PersistDateFormat, sizeof(PersistDateFormat));
     APP_LOG(APP_LOG_LEVEL_INFO, "    Set Date Format to                    %s - Persistent - 0 = US, 1 = Int'l", PersistDateFormat);
  }  else {
     APP_LOG(APP_LOG_LEVEL_INFO, "    Set Date Format to                    0 - Default - US");
     strcpy(PersistDateFormat, "0"); //Default
  }

  if (strcmp(PersistDateFormat, "0") == 0) {     // US
     strcpy(date_format, "%b %e %Y");
  } else {
     strcpy(date_format, "%e %b %Y");
  }

  //Persistent Value Vib On BTLoss
  if(persist_exists(MESSAGE_KEY_BT_VIBRATE_KEY)) {
     PersistBTLoss = persist_read_int(MESSAGE_KEY_BT_VIBRATE_KEY);
     APP_LOG(APP_LOG_LEVEL_INFO, "    Set BT Vibrate To                     %d - Persistent - 0 = NO Vib, 1 = Vib", PersistBTLoss);
  }  else {
     PersistBTLoss = 0; // Default
     APP_LOG(APP_LOG_LEVEL_INFO, "    Set BT Vibrate To                     0 - Default - No Vibrate");

  }

  //Persistent Value Vib on Low Batt
  if(persist_exists(MESSAGE_KEY_LOW_BATTERY_KEY)) {
     PersistLow_Batt = persist_read_int(MESSAGE_KEY_LOW_BATTERY_KEY);
     APP_LOG(APP_LOG_LEVEL_INFO, "    Set Low Batt Vibrate To               %d - Persistent - 0 = NO Vib, 1 = Vib", PersistLow_Batt);
  }  else {
     PersistLow_Batt = 0; // Default
     APP_LOG(APP_LOG_LEVEL_INFO, "    Set Low Batt Vibrate To               0 - Default - No Vibrate");

  }
 
  // Time of Day
  #ifdef PBL_PLATFORM_CHALK
      text_time_layer = text_layer_create(GRect(1, 120, 180, 45));
      text_layer_set_font(text_time_layer,fontRobotoBoldSubset40);
  #else
      text_time_layer = text_layer_create(GRect(1, 120, 144, 45));
      text_layer_set_font(text_time_layer,fontRobotoBoldSubset45);
  #endif 
    
  text_layer_set_text_color(text_time_layer, TEXTCOLOR);
  text_layer_set_background_color(text_time_layer, BGCOLOR);
  text_layer_set_text_alignment(text_time_layer, GTextAlignmentCenter);
  layer_add_child(window_layer, text_layer_get_layer(text_time_layer));

   // Dayname
  #ifdef PBL_PLATFORM_CHALK
      text_dayname_layer = text_layer_create(GRect(1, 74, 180, 26));
  #else
      text_dayname_layer = text_layer_create(GRect(1, 74, 144, 26));
  #endif
    
  text_layer_set_text_color(text_dayname_layer, TEXTCOLOR);
  text_layer_set_text_alignment(text_dayname_layer, GTextAlignmentCenter);
  text_layer_set_background_color(text_dayname_layer, BGCOLOR);
  text_layer_set_font(text_dayname_layer, fonts_get_system_font(FONT_KEY_ROBOTO_CONDENSED_21));
  layer_add_child(window_layer, text_layer_get_layer(text_dayname_layer));

  // Planetary Logo

  image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_PLANETARY_LOGO);
 
  #ifdef PBL_PLATFORM_CHALK
      image_layer = bitmap_layer_create(GRect(1, 29, 180, 49)); 
  #else
      image_layer = bitmap_layer_create(GRect(1, 29, 144, 49)); 
  #endif  
    
  bitmap_layer_set_bitmap(image_layer, image);
  bitmap_layer_set_alignment(image_layer, GAlignCenter);
  layer_add_child(window_layer, bitmap_layer_get_layer(image_layer));

   // Line
  #ifdef PBL_PLATFORM_CHALK
      GRect line_frame = GRect(38, 122, 104, 6);
  #else
      GRect line_frame = GRect(22, 122, 104, 6);
  #endif 
    
  BatteryLineLayer = layer_create(line_frame);
  layer_set_update_proc(BatteryLineLayer, battery_line_layer_update_callback);
  layer_add_child(window_layer, BatteryLineLayer);

  tick_timer_service_subscribe(SECOND_UNIT, handle_tick);

  //Bluetooth Logo Setup area
  #ifdef PBL_PLATFORM_CHALK
      GRect BTArea = GRect(55, 5, 20, 20);
  #else
      GRect BTArea = GRect(1, 5, 20, 20);
  #endif 
    
  BTLayer = layer_create(BTArea);

  layer_add_child(window_layer, BTLayer);

  layer_set_update_proc(BTLayer, BTLine_update_callback);

  bluetooth_connection_service_subscribe(&handle_bluetooth);


  //Battery Text
  #ifdef PBL_PLATFORM_CHALK
      text_battery_layer = text_layer_create(GRect(80,2,55,28));
  #else
      text_battery_layer = text_layer_create(GRect(85,2,55,28));
  #endif
    
  text_layer_set_text_color(text_battery_layer, TEXTCOLOR);
  text_layer_set_background_color(text_battery_layer, BGCOLOR);
  text_layer_set_font(text_battery_layer,  fontHelvNewLight20 );
  text_layer_set_text_alignment(text_battery_layer, GTextAlignmentRight);

  layer_add_child(window_layer, text_layer_get_layer(text_battery_layer));

  battery_state_service_subscribe(&handle_battery);
  bluetooth_connection_service_subscribe(&handle_bluetooth);
  app_focus_service_subscribe(&handle_appfocus);

  handle_battery(battery_state_service_peek());
  handle_bluetooth(bluetooth_connection_service_peek());
  
  // 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_tick(current_time, SECOND_UNIT);


}