예제 #1
0
static void init() {
  init_mem_log();
  // accel_data_service_subscribe(SMP_HZ, accel_data_handler);
  // accel_service_set_sampling_rate(ACCEL_SAMPLING_25HZ);

  // subscribe the summ_datalog tick handler
  // NOTE : we need to be sure to have second-level accuracy, so given the bugs
  // with the MINUTE_UNIT timer, we assume that we need to call every second
  // NOTE! we use SECOND_UNIT, SECOND_UNIT is CORRECT!!
  tick_timer_service_subscribe(MINUTE_UNIT, tick_summ_datalog_second_hander);

  // subscribe to the accelerometer handler
  accel_data_service_subscribe(SMP_HZ, accel_data_handler);
  accel_service_set_sampling_rate(ACCEL_SAMPLING_25HZ);

  // set the bluetooth state change to also send the data
  bluetooth_connection_service_subscribe(worker_bt_service_handler);

  // init the learning algorithms params, if HAS NOT been init'ed
  // struct acticlass_learn_alg_state aclas;
  // persist_read_data(ACTICLASS_LEARN_ALG_STATE_PERSIST_KEY, &aclas, sizeof(aclas));
  // if( !aclas.init_alg){
  //   init_learn_alg1_stepc_posts_ps();
  // }
}
예제 #2
0
static void main_window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_frame(window_layer);

  s_text_layer = text_layer_create(GRect(0, 1, bounds.size.w, bounds.size.h - 20));
  text_layer_set_background_color(s_text_layer, GColorBlack);
  text_layer_set_text_color(s_text_layer, GColorWhite);
  text_layer_set_font(s_text_layer, fonts_get_system_font(FONT_KEY_DROID_SERIF_28_BOLD));
  layer_add_child(window_layer, text_layer_get_layer(s_text_layer));
  
  s_connection_layer = text_layer_create(GRect(0, 135, bounds.size.w, 34));
  text_layer_set_text_color(s_connection_layer, GColorWhite);
  text_layer_set_background_color(s_connection_layer, GColorClear);
  text_layer_set_font(s_connection_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD));
  text_layer_set_text_alignment(s_connection_layer, GTextAlignmentRight);
  handle_bluetooth(bluetooth_connection_service_peek());

  s_battery_layer = text_layer_create(GRect(0, 150, bounds.size.w, 34));
  text_layer_set_text_color(s_battery_layer, GColorWhite);
  text_layer_set_background_color(s_battery_layer, GColorClear);
  text_layer_set_font(s_battery_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD));
  text_layer_set_text_alignment(s_battery_layer, GTextAlignmentRight);
  text_layer_set_text(s_battery_layer, "100% charged");
  
  time_t now = time(NULL);
  struct tm *t = localtime(&now);
  update_time(t);

  tick_timer_service_subscribe(MINUTE_UNIT, &handle_minute_tick);
  battery_state_service_subscribe(handle_battery);
  bluetooth_connection_service_subscribe(handle_bluetooth);

  layer_add_child(window_layer, text_layer_get_layer(s_connection_layer));
  layer_add_child(window_layer, text_layer_get_layer(s_battery_layer));
}
예제 #3
0
void show_watchface(void) {
  initialise_ui();
  
  s_res_charging = gbitmap_create_with_resource(RESOURCE_ID_CHARGING);
  s_res_battery_20 = gbitmap_create_with_resource(RESOURCE_ID_BATTERY_20);
  s_res_battery_40 = gbitmap_create_with_resource(RESOURCE_ID_BATTERY_40);
  s_res_battery_60 = gbitmap_create_with_resource(RESOURCE_ID_BATTERY_60);
  s_res_battery_80 = gbitmap_create_with_resource(RESOURCE_ID_BATTERY_80);
  s_res_battery_100 = gbitmap_create_with_resource(RESOURCE_ID_BATTERY_100);
  
  layer_set_update_proc(sCalendarLayer, calendar_layer_update_callback);
  tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick);
  battery_state_service_subscribe(handle_battery);
  bluetooth_connection_service_subscribe(handle_bluetooth);
  
  sTimer = NULL;
  
  btStatus = bluetooth_connection_service_peek();
  handle_battery(battery_state_service_peek());
  
  currentTime = get_time();
  update_time_text();
  update_date_text();
  layer_mark_dirty(sCalendarLayer);
  
  window_set_window_handlers(s_window, (WindowHandlers) {
    .unload = handle_window_unload,
  });
예제 #4
0
//=====================================
// initiliase/tear down
static void init() {
  // register with the time service
  tick_timer_service_subscribe(SECOND_UNIT, tick_handler);

  //register for battery info updates
  battery_state_service_subscribe(battery_callback);

  // register for bluetooth events
  bluetooth_connection_service_subscribe(bluetooth_callback);

  // 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 app message
  app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum());

  //create main window element and assign to pointer
  s_main_window = window_create();
  window_set_background_color(s_main_window, GColorCadetBlue);

  //set handlers to manage elements inside Window
  window_set_window_handlers(s_main_window, (WindowHandlers){
    .load = main_window_load,
    .unload = main_window_unload
  });
void handle_init() {
	Layer *rootLayer;
	int i;
	
	window = window_create();
	window_set_background_color(window, GColorWhite);
	window_stack_push(window, true);
	
	readConfig();
	app_message_init();

	rootLayer = window_get_root_layer(window);
	
	for (i=0; i<NUMSLOTS; i++) {
		initSlot(i, rootLayer);
	}
		
	animImpl.setup = NULL;
	animImpl.update = animateDigits;
	animImpl.teardown = NULL;
	
	anim = animation_create();
	animation_set_delay(anim, 0);
	animation_set_duration(anim, DIGIT_CHANGE_ANIM_DURATION);
	animation_set_implementation(anim, &animImpl);
	
	app_timer_register(STARTDELAY, handle_timer, NULL);

	tick_timer_service_subscribe(MINUTE_UNIT, handle_tick);
	
	accel_tap_service_subscribe(handle_tap);
	
	lastBluetoothStatus = bluetooth_connection_service_peek();
	bluetooth_connection_service_subscribe(handle_bluetooth);
}
void handle_init() {

  // Configure window
  window = window_create();
  window_stack_push(window, true /* Animated */);
  window_set_background_color(window, BKGD_COLOR);
  window_set_fullscreen(window, true);
  Layer *window_layer = window_get_root_layer(window);

  // Dynamic allocation of assets
  minuteFrame = GRect(53, 16, 40, 40);
  minuteLayer = text_layer_create(minuteFrame);
  hourLayer = bitmap_layer_create(GRect(0, 0, 144, 148));
  batteryLogoLayer = bitmap_layer_create(GRect(65, 151, 10, 15));
  batteryPercentLayer = text_layer_create(GRect(78, 150, 30, 167-150));
  dateLayer = text_layer_create(GRect(3, 150, 38, 167-150));
  dayLayer = text_layer_create(GRect(141-30, 150, 30, 167-150));
  text_layer_set_text_alignment(dayLayer, GTextAlignmentRight);
  bottomBarLayer = layer_create(GRect(1, 149, 142, 18));

  // Setup minute layer
  text_layer_set_text_color(minuteLayer, TEXT_COLOR);
  text_layer_set_background_color(minuteLayer, GColorClear);
  text_layer_set_font(minuteLayer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_MINUTE_38)));

  // Setup date & day layer
  text_layer_set_text_color(dateLayer, TEXT_COLOR);
  text_layer_set_background_color(dateLayer, GColorClear);
  text_layer_set_text_color(dayLayer, TEXT_COLOR);
  text_layer_set_background_color(dayLayer, GColorClear);

  // Setup battery layers
  text_layer_set_text_color(batteryPercentLayer, TEXT_COLOR);
  text_layer_set_background_color(batteryPercentLayer, GColorClear);

  // Setup line layer
  layer_set_update_proc(bottomBarLayer, bottom_bar_layer_update_callback);

  // Add layers into hierachy
  layer_add_child(bitmap_layer_get_layer(hourLayer), text_layer_get_layer(minuteLayer));
  layer_add_child(window_layer, bitmap_layer_get_layer(hourLayer));
  layer_add_child(window_layer, bottomBarLayer);
  layer_add_child(window_layer, bitmap_layer_get_layer(batteryLogoLayer));
  layer_add_child(window_layer, text_layer_get_layer(batteryPercentLayer));
  layer_add_child(window_layer, text_layer_get_layer(dateLayer));
  layer_add_child(window_layer, text_layer_get_layer(dayLayer));

  // Avoids a blank screen on watch start.
  time_t tick_time = time(NULL);
  display_time(localtime(&tick_time));
  handle_battery(battery_state_service_peek());
  handle_bluetooth(bluetooth_connection_service_peek());

  tick_timer_service_subscribe(MINUTE_UNIT, &handle_minute_tick);
  battery_state_service_subscribe(&handle_battery);
  bluetooth_connection_service_subscribe(&handle_bluetooth);

  initialized = true;
}
예제 #7
0
static void init() {
	s_main_window = window_create();
	window_handlers(s_main_window, main_window_load, main_window_unload);
	window_stack_push(s_main_window, true);
	
	tick_timer_service_subscribe(MINUTE_UNIT, tick_handler);
	bluetooth_connection_service_subscribe(bt_handler);
}
예제 #8
0
/*
 * Main - or main as it is known
 */
int main(void) {
    init();
    tick_timer_service_subscribe(SECOND_UNIT, &handle_tick);
    bluetooth_connection_service_subscribe(&bt_connection_handler);
    battery_state_service_subscribe	(&battery_state_handler);
    app_event_loop();
    deinit();
}
예제 #9
0
파일: config.c 프로젝트: phardy/DualTZ
void set_btdisco_notification(bool state) {
  watch_config.btdisco = state;
  if (state) {
    bluetooth_connection_service_subscribe(bluetooth_connection_handler);
  } else {
    bluetooth_connection_service_unsubscribe();
  }
}
예제 #10
0
파일: main.c 프로젝트: zenwheel/zenface
void handle_init(void) {
	// Create a window and text layer
	window = window_create();
	text_layer = text_layer_create(GRect(0, TIME_HEIGHT, 144, 168 - TIME_HEIGHT));

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

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

//	date_layer = text_layer_create(GRect(0, 112, 144, 56));
//	text_layer_set_text_alignment(date_layer, GTextAlignmentCenter);
//	text_layer_set_font(date_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD));
//	layer_add_child(window_get_root_layer(window), text_layer_get_layer(date_layer));
	time_layer = text_layer_create(GRect(0, 0, 144, TIME_HEIGHT));
	text_layer_set_text_alignment(time_layer, GTextAlignmentCenter);
	text_layer_set_font(time_layer, fonts_get_system_font(FONT_PRO_32));
	layer_add_child(window_get_root_layer(window), text_layer_get_layer(time_layer));

	inverter_layer = inverter_layer_create(GRect(0, 0, 144, 168));
	layer_add_child(window_get_root_layer(window), inverter_layer_get_layer(inverter_layer));
	layer_set_hidden(inverter_layer_get_layer(inverter_layer), invert_face);
	
	battery_state_service_subscribe(handle_battery_change);
	handle_battery_change(battery_state_service_peek());

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

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

	// App Logging!
	//APP_LOG(APP_LOG_LEVEL_DEBUG, "Hello World from the applogs!");
}
예제 #11
0
static void do_init(void) {
  window = window_create();

  window_stack_push(window, true);
  window_layer = window_get_root_layer(window);
  
  date_layer = text_layer_create(GRect(layers[0][0][0],layers[0][0][1],layers[0][1][0],layers[0][1][1]));
  text_layer_set_text_alignment(date_layer, GTextAlignmentCenter);
  text_layer_set_text(date_layer, "");
  
  ampm_layer = text_layer_create(GRect(layers[3][0][0],layers[3][0][1],layers[3][1][0],layers[3][1][1]));
  text_layer_set_text_alignment(ampm_layer, GTextAlignmentCenter);
  text_layer_set_text(ampm_layer, "");
  text_layer_set_text_color(date_layer, GColorBlack);
  text_layer_set_background_color(date_layer, GColorWhite);
  text_layer_set_font(date_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_ROBOTO_BOLD_16)));
  
  conn_layer = bitmap_layer_create(
    GRect(layers[1][0][0],layers[1][0][1],layers[1][1][0],layers[1][1][1]));
  load_icon_into_layer(0, bitmap_layer_get_layer(conn_layer));
  
  battery_layer = bitmap_layer_create(
    GRect(layers[2][0][0],layers[2][0][1],layers[2][1][0],layers[2][1][1]));
  load_icon_into_layer(0, bitmap_layer_get_layer(battery_layer));
  
  int adj = 0;
  for (int slot_number = 0; slot_number < TOTAL_IMAGE_SLOTS; slot_number++) {
    digit_slot[slot_number] = bitmap_layer_create(
        GRect(position[slot_number][0][0], position[slot_number][0][1], position[slot_number][1][0], position[slot_number][1][1]));
    
    load_digit_image_into_slot(slot_number, slot_number);
    layer_add_child(window_layer, bitmap_layer_get_layer(digit_slot[slot_number]));
  }
  
    time_t now = time(NULL);
  struct tm *current_time = localtime(&now);
  
  handle_second_tick(current_time, SECOND_UNIT);
  handle_bluetooth(bluetooth_connection_service_peek());
  handle_battery(battery_state_service_peek());
  
  tick_timer_service_subscribe(SECOND_UNIT, &handle_second_tick);
  battery_state_service_subscribe(&handle_battery);
  bluetooth_connection_service_subscribe(&handle_bluetooth);
  
  layer_add_child(window_layer, text_layer_get_layer(date_layer));
  
  window_set_background_color(window, GColorWhite);
  text_layer_set_text_color(date_layer, GColorBlack);
  text_layer_set_background_color(date_layer, GColorWhite);
  text_layer_set_font(date_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_ROBOTO_BOLD_16)));

  layer_add_child(window_layer, bitmap_layer_get_layer(conn_layer));
  layer_add_child(window_layer, bitmap_layer_get_layer(battery_layer));
  
  layer_add_child(window_layer, text_layer_get_layer(ampm_layer));
}
예제 #12
0
/*----------------------------------------------------------------------------*/
int main(void)
{
  APP_LOG(APP_LOG_LEVEL_INFO, "main: entry:  %s %s", __TIME__, __DATE__);

  /*
   *   Commission App
   */
  window = window_create();

  WindowHandlers handlers = {.load = window_load, .unload = window_unload };
  window_set_window_handlers(window, handlers);

  const bool animated = true;
  window_stack_push(window, animated);

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

  /* Display the simple splash screen to indicate PebblePointer is running. */
  image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_PEBBLEPOINTER);
  image_layer = bitmap_layer_create(bounds);
  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));

  /* Basic accelerometer initialization.  Enable Tap-Tap functionality. */
  accel_service_set_sampling_rate( SAMPLING_RATE );
  accel_tap_service_subscribe( (AccelTapHandler) accel_tap_callback );
  app_message_open(SYNC_BUFFER_SIZE, SYNC_BUFFER_SIZE);

  /* Request notfication on Bluetooth connectivity changes.  */
  bluetooth_connection_service_subscribe( bluetooth_connection_callback );
  isConnected = bluetooth_connection_service_peek();
  APP_LOG(APP_LOG_LEVEL_INFO, "initially %sonnected", (isConnected) ? "c" : "disc");

  /*
   *   Event Processing
   */
  app_event_loop();

  /*
   *   Decommission App
   */
  if (tapSwitchState == true) {
    accel_data_service_unsubscribe();
  }

  /* Remove the Tap-Tap callback */
  accel_tap_service_unsubscribe();

  /* Release splash-screen resources */
  gbitmap_destroy(image);
  bitmap_layer_destroy(image_layer);
  window_destroy(window);

  APP_LOG(APP_LOG_LEVEL_INFO, "main: exit");
}
예제 #13
0
Layer* bluetooth_init() {
  s_bt_layer = layer_create(GRect(25, 4, 20, 20));
  layer_set_update_proc(s_bt_layer, draw_bt);

  s_bt_path = gpath_create(&BT_PATH_INFO);

  bluetooth_connection_service_subscribe(on_bluetooth);
  return s_bt_layer;
}
예제 #14
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);

}
예제 #15
0
static void do_init(void) {
	window = window_create();
	window_stack_push(window, true);
	window_set_background_color(window, GColorBlack);
	window_layer = window_get_root_layer(window);
	
	GRect line_frame = GRect(8, 120, 139, 2);
	line_layer = layer_create(line_frame);
	layer_set_update_proc(line_layer, draw_line);
	layer_add_child(window_layer, line_layer);
	
	time_layer = text_layer_create(GRect(5, 66, 118, 70));
	text_layer_set_text_color(time_layer, GColorWhite);
	text_layer_set_background_color(time_layer, GColorClear);
	text_layer_set_font(time_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_font_droid_44)));
	text_layer_set_text_alignment(time_layer,GTextAlignmentRight);
	layer_add_child(window_layer, text_layer_get_layer(time_layer));
	
	date_layer = text_layer_create(GRect(65, 125, 79, 25));
	text_layer_set_text_color(date_layer, GColorWhite);
	text_layer_set_background_color(date_layer, GColorClear);
	text_layer_set_font(date_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_font_droid_18)));
	layer_add_child(window_layer, text_layer_get_layer(date_layer));
	
	wday_layer = text_layer_create(GRect(60, 143, 50, 25));
	text_layer_set_text_color(wday_layer, GColorWhite);
	text_layer_set_background_color(wday_layer, GColorClear);
	text_layer_set_font(wday_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_font_droid_18)));
	layer_add_child(window_layer, text_layer_get_layer(wday_layer));
	
	//+時間のNULL回避?(わかってない→調べる
	
	time_t now = time(NULL);
	struct tm *current_time = localtime(&now);
	handle_time_tick(current_time, SECOND_UNIT);
	
	tick_timer_service_subscribe(SECOND_UNIT, &handle_time_tick);

	batt_layer = bitmap_layer_create(GRect(123, 151, 14, 10));
	layer_add_child(window_layer, bitmap_layer_get_layer(batt_layer)); //親レイヤに載せる 
	
	watchicon_layer = bitmap_layer_create(GRect(131, 151, 6, 10));
	layer_add_child(window_layer, bitmap_layer_get_layer(watchicon_layer));
	bitmap_layer_set_background_color(watchicon_layer, GColorClear);
	
	bt_layer = bitmap_layer_create(GRect(110, 151, 11, 10));
	layer_add_child(window_layer, bitmap_layer_get_layer(bt_layer));
	
	handle_battery(battery_state_service_peek());
	battery_state_service_subscribe(&handle_battery);

	handle_bluetooth(bluetooth_connection_service_peek());
	bluetooth_connection_service_subscribe(&handle_bluetooth);
}
static void init() {
  
  tick_timer_service_subscribe(INTERVAL_UPDATE, tick_handler);
  bluetooth_connection_service_subscribe(bt_handler);
  battery_state_service_subscribe(batt_handler);
  
  s_main_window = window_create();
  
  window_set_window_handlers(s_main_window, (WindowHandlers) {
    .load = main_window_load,
    .unload = main_window_unload
  });
예제 #17
0
파일: main.c 프로젝트: setazer/setowatch
//Инициализация
void init()
{
  //Подписка на события ежеминутного "тика" и смены состояний батареи/блютуза
  tick_timer_service_subscribe(MINUTE_UNIT, (TickHandler) tick_handler);
  battery_state_service_subscribe(batt_handler);
  bluetooth_connection_service_subscribe(bt_handler);
  //Создание окна и задание обработчиков
  window = window_create();
  window_set_window_handlers(window, (WindowHandlers) {
    .load = window_load,
    .unload = window_unload,
  });
예제 #18
0
파일: main.c 프로젝트: dexif/Pebblemous
static void do_init(void) {

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

	/* Background */
	Anonymous = gbitmap_create_with_resource(RESOURCE_ID_BG_ANONYMOUS);
	Anonymous_Layer = bitmap_layer_create(GRect(0, 0, WIDTH, HEIGHT));
	bitmap_layer_set_background_color(Anonymous_Layer, GColorBlack);
	bitmap_layer_set_bitmap(Anonymous_Layer, Anonymous);
	layer_add_child(root_layer, bitmap_layer_get_layer(Anonymous_Layer));

	/* Time block */
	time_layer = text_layer_create(GRect(0, 52, frame.size.w, 34));
	text_layer_set_text_color(time_layer, GColorBlack);
	text_layer_set_background_color(time_layer, GColorClear);
	text_layer_set_font(time_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD ));
	text_layer_set_text_alignment(time_layer, GTextAlignmentCenter);

	/* Bluetooth block */
	bt_connected = gbitmap_create_with_resource(RESOURCE_ID_BT_DISCONNECTED);
	bt_connected_layer = bitmap_layer_create(GRect(WIDTH - ICON_WIDTH, 1, ICON_WIDTH, ICON_HEIGHT));
	bitmap_layer_set_background_color(bt_connected_layer, GColorBlack);
	layer_add_child(root_layer, bitmap_layer_get_layer(bt_connected_layer));

	/* Battery block */
	battery_layer = text_layer_create(GRect(2, -2, frame.size.w, 16 ));
	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_14));
	text_layer_set_text_alignment(battery_layer, GTextAlignmentLeft);
	text_layer_set_text(battery_layer, "100% charged");

	/* Init blocks */
	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);

	bool connected = bluetooth_connection_service_peek();
	handle_bluetooth(connected);
	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(battery_layer));
}
예제 #19
0
파일: main.c 프로젝트: dermaxe/blue_connect
static void do_init(void) {
  s_data.window = window_create();
  const bool animated = true;
  window_stack_push(s_data.window, animated);

  window_set_background_color(s_data.window, GColorBlack);
  GFont font = fonts_get_system_font(FONT_KEY_DROID_SERIF_28_BOLD);

  Layer *root_layer = window_get_root_layer(s_data.window);
  GRect frame = layer_get_frame(root_layer);

  s_data.label = text_layer_create(GRect(0, 0, frame.size.w, frame.size.h));
  text_layer_set_background_color(s_data.label, GColorBlack);
  text_layer_set_text_color(s_data.label, GColorWhite);
  text_layer_set_font(s_data.label, font);
  text_layer_set_text_alignment(s_data.label, GTextAlignmentLeft);
  layer_add_child(root_layer, text_layer_get_layer(s_data.label));

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

  tick_timer_service_subscribe(SECOND_UNIT, &handle_minute_tick);


  bluetoothstatus_layer = text_layer_create(GRect(0, 100, frame.size.w, frame.size.h));
  text_layer_set_text_color(bluetoothstatus_layer, GColorWhite);
  text_layer_set_background_color(bluetoothstatus_layer, GColorBlack);
  text_layer_set_font(bluetoothstatus_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14));
  text_layer_set_text_alignment(bluetoothstatus_layer, GTextAlignmentCenter);	
  layer_add_child(root_layer, text_layer_get_layer(bluetoothstatus_layer));
  
  bluetooth_connection_service_subscribe(bluetooth_connection_callback);	
 
  update_bluetooth(bluetooth_connection_service_peek());
	
  batterystatus_layer = text_layer_create(GRect(0, 120, frame.size.w, frame.size.h));
  text_layer_set_text_color(batterystatus_layer, GColorWhite);
  text_layer_set_background_color(batterystatus_layer, GColorBlack);
  text_layer_set_font(batterystatus_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14));
  text_layer_set_text_alignment(batterystatus_layer, GTextAlignmentCenter);	
  layer_add_child(root_layer, text_layer_get_layer(batterystatus_layer));
  
  BatteryChargeState pb_bat = battery_state_service_peek();
  pebble_batteryPercent = pb_bat.charge_percent;  
  battery_state_service_subscribe(pebble_battery_callback);
  update_pebble_battery(battery_state_service_peek());
	
  icon_bt_on  = gbitmap_create_with_resource( RESOURCE_ID_IMAGE_BT_ON_ICON );
}
예제 #20
0
파일: main.c 프로젝트: waful/target-pebble
static void init() {
  APP_LOG(APP_LOG_LEVEL_DEBUG, "start of init");
  autoconfig_init(512, 512);
  app_message_register_inbox_received(in_received_handler);
  main_window_set_config(getMinutes_color(), getMinutes_no_bt_color(), getHours_color(), getHours_no_bt_color(), getText_color(), getText_low_battery_color(), getBg_color(), getBar_radius(), getBar_offset(), getRing_markings(), getLow_bat_threshold());
  BT_VIBE = getBt_vibe();
  main_window_init();
  tick_timer_service_subscribe(MINUTE_UNIT, tick_handler);
  battery_state_service_subscribe(battery_callback);
  battery_callback(battery_state_service_peek());
  bluetooth_connection_service_subscribe(bluetooth_callback);
  bluetooth_callback(bluetooth_connection_service_peek());
  APP_LOG(APP_LOG_LEVEL_DEBUG, "end of init");
}
예제 #21
0
파일: main.c 프로젝트: Prieni/revolving
static void init(void) {
  //(void)ctx;
	
  app_message_register_inbox_received(in_received_handler);
  app_message_register_inbox_dropped(in_dropped_handler);
  app_message_open(64, 0);

  if(persist_exists(KEY_24H)) SHOW_24H = persist_read_bool(KEY_24H);
  if(persist_exists(KEY_DATE)) SHOW_TEXT_DATE = persist_read_bool(KEY_DATE);
  if(persist_exists(KEY_VIBE)) BT_VIBE = persist_read_bool(KEY_VIBE);
  if(persist_exists(KEY_INVERT)) INVERT = persist_read_bool(KEY_INVERT);
	
  if(INVERT) {
	  BACKGROUND_COLOR = GColorWhite;
	  FOREGROUND_COLOR = GColorBlack;
  }
  else {
	  BACKGROUND_COLOR = GColorBlack;
	  FOREGROUND_COLOR = GColorWhite;		 		 
  }
	
  window = window_create();
  window_set_background_color(window, BACKGROUND_COLOR);
  window_stack_push(window, true);

 
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);
	
  // Init the layer for the minute display
  minute_display_layer = layer_create(bounds);
  layer_set_update_proc(minute_display_layer, minute_display_layer_update_callback);
  layer_add_child(window_layer, minute_display_layer);

  // Init the layer for the hour display
  hour_display_layer = layer_create(bounds);
  layer_set_update_proc(hour_display_layer, hour_display_layer_update_callback);
  layer_add_child(window_layer, hour_display_layer);

  // Init the layer for the battery display
  battery_display_layer = layer_create(bounds);
  layer_set_update_proc(battery_display_layer, battery_display_layer_update_callback);
  layer_add_child(window_layer, battery_display_layer);
  
  setup_time_date_layers();
	
  tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick);
  bluetooth_connection_service_subscribe(handle_bluetooth_event); 
}
예제 #22
0
void handle_init() {
  int i;

  srand(time(NULL));
  initColors();

  readConfig();
  swapDigitShapes();
  app_message_init();

  initSplash();

  window = window_create();
  if (invertStatus) {
    window_set_background_color(window, GColorWhite);
  } else {
    window_set_background_color(window, GColorBlack);
  }
  window_stack_push(window, true);

  rootLayer = window_get_root_layer(window);
  mainLayer = layer_create(layer_get_bounds(rootLayer));
  layer_add_child(rootLayer, mainLayer);
  layer_set_update_proc(mainLayer, updateMainLayer);

  for (i=0; i<NUMSLOTS; i++) {
    initSlot(i, mainLayer);
  }

  initDigitCorners();

  animImpl.setup = NULL;
  animImpl.update = animateDigits;
#ifdef PBL_PLATFORM_APLITE
  animImpl.teardown = destroyAnim;
#else
  animImpl.teardown = NULL;
#endif
  createAnim();

  timer = app_timer_register(STARTDELAY, handle_timer, NULL);

  tick_timer_service_subscribe(MINUTE_UNIT, handle_tick);

  accel_tap_service_subscribe(handle_tap);

  lastBluetoothStatus = bluetooth_connection_service_peek();
  bluetooth_connection_service_subscribe(handle_bluetooth);
}
예제 #23
0
파일: main.c 프로젝트: manelto/pizarra
void init() {
	
	tick_timer_service_subscribe(MINUTE_UNIT, &handle_time);
	bluetooth_connection_service_subscribe(&handle_bluetooth);
	battery_state_service_subscribe(&handle_battery);
	app_message_register_inbox_received((AppMessageInboxReceived) in_recv_handler);
	app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum());
	
	pwindow = window_create();
	//window_set_click_config_provider(pwindow, click_config_provider);
	
	window_set_window_handlers(pwindow, (WindowHandlers) {
		.load = window_load,
		.unload = window_unload,
	});
예제 #24
0
// Setup the action bar on the side of the app
static void action_bar_init(){
    s_play_icon = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_PLAY);
    s_pause_icon = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_PAUSE);
    s_refresh_icon = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_REFRESH);
    s_share_icon = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_SHARE);

    if(timer.paused) s_select_button_icon = s_play_icon;
    else s_select_button_icon = s_pause_icon;

    action_bar_layer_set_icon(action_bar, BUTTON_ID_UP, s_refresh_icon);
    action_bar_layer_set_icon(action_bar, BUTTON_ID_SELECT, s_select_button_icon);

    if(bluetooth_connection_service_peek()){
        action_bar_layer_set_icon(action_bar, BUTTON_ID_DOWN, s_share_icon);
    }
    bluetooth_connection_service_subscribe(bluetooth_connection_handler);
}
예제 #25
0
/*
 * Common stuff we always do at the end of setup
 */
EXTFN void morpheuz_load_standard_postamble() {
  read_internal_data();
  read_config_data();
  
  // Start clock
  tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick);
  
  battery_state_handler(battery_state_service_peek());
  battery_state_service_subscribe(&battery_state_handler);

  bluetooth_state_handler(bluetooth_connection_service_peek());
  bluetooth_connection_service_subscribe(bluetooth_state_handler);

  init_morpheuz();

  light_enable_interaction();
}
예제 #26
0
파일: mason.c 프로젝트: gen1us/pebble-mason
int main(void) {
  autoconfig_init();

  app_message_register_inbox_received(in_received_handler);

  center = GPoint(72, 74);

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

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

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

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

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

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

  bluetooth_connected = bluetooth_connection_service_peek();

  app_event_loop();

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

  autoconfig_deinit();
}
예제 #27
0
/* Initialize listeners to show and hide Quick Tap Plus as well as update data */
void qtp_setup() {
	qtp_is_showing = false;
	accel_tap_service_subscribe(&qtp_tap_handler);
	qtp_battery_images[0] = gbitmap_create_with_resource(RESOURCE_ID_QTP_IMG_BATE);
	qtp_battery_images[1] = gbitmap_create_with_resource(RESOURCE_ID_QTP_IMG_BATP);
	qtp_battery_images[2] = gbitmap_create_with_resource(RESOURCE_ID_QTP_IMG_BAT);
	qtp_battery_image = qtp_battery_images[0];
	qtp_bluetooth_image = gbitmap_create_with_resource(RESOURCE_ID_QTP_IMG_BT);

#ifdef QTP_K_SUBSCRIBE
	qtp_bluetooth_status = bluetooth_connection_service_peek();
	bluetooth_connection_service_subscribe( qtp_bluetooth_callback );
#endif

#ifdef QTP_K_SHOW_WEATHER
	qtp_setup_app_message();
#endif
}
예제 #28
0
void handle_init(void) {
	show_window();
	app_message_register_inbox_received(Process_Received_Data);
	app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum());
	window_stack_push(s_window, true);
	
	
	tick_timer_service_subscribe(MINUTE_UNIT, &Update_Time);
	
	Update_Battery(battery_state_service_peek());
	
	battery_state_service_subscribe(Update_Battery);
	
	
	Update_Connection(bluetooth_connection_service_peek());
	bluetooth_connection_service_subscribe(Update_Connection);
	
}
예제 #29
0
void notify_init(bool subscribe,
		 Window *window) {

    Layer *window_layer = window_get_root_layer(window);

    /*
    ** Load graphics...
    */
    tick = gbitmap_create_with_resource(RESOURCE_ID_TICK);

    /*
    ** Initialize the layers.
    */
    warn_layer = bitmap_layer_create(GRect(0, 0, 144, 168));
    layer_set_hidden(bitmap_layer_get_layer(warn_layer), true);
    layer_add_child(window_layer, bitmap_layer_get_layer(warn_layer));

    warn_text_layer = text_layer_create(GRect(0, 100, 144, 68));
    text_layer_set_background_color(warn_text_layer, GColorClear);
    text_layer_set_font(warn_text_layer,
                        fonts_get_system_font(FONT_KEY_GOTHIC_28));
    text_layer_set_text_alignment(warn_text_layer, GTextAlignmentCenter);
    text_layer_set_text_color(warn_text_layer, GColorWhite);
    layer_add_child(bitmap_layer_get_layer(warn_layer),
		    text_layer_get_layer(warn_text_layer));

    if (subscribe) {
	subscribed = true;

    	/*
    	** Load graphics...
    	*/
    	lowbatt = gbitmap_create_with_resource(RESOURCE_ID_LOWBATT);
    	btdisc = gbitmap_create_with_resource(RESOURCE_ID_BTDISC);

        /*
    	** Subscribe to event services.
    	*/
    	battery_state_service_subscribe(handle_battery);
    	bluetooth_connection_service_subscribe(handle_bluetooth);
    }
}
예제 #30
0
파일: Arc_2.0.c 프로젝트: linuxq/Arc_2.0
static void init(void) {
	time_t t;
	struct tm *tm;
	
	initRadiuses();

	readConfig();
	app_message_init();

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

	rootLayer = window_get_root_layer(window);

	t = time(NULL);
	tm = localtime(&t);
	
	layer = layer_create(GRect(0, 0, 144, 168));
	layer_set_update_proc(layer, updateScreen);
	layer_add_child(rootLayer, layer);
	
	font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_TIMEBURNER_20));
	
	textFrame = GRect(72-innerCircleInnerRadius, 60, 2*innerCircleInnerRadius, 60);
	textLayer = text_layer_create(textFrame);
	text_layer_set_text_alignment(textLayer, GTextAlignmentCenter);
	text_layer_set_overflow_mode(textLayer, GTextOverflowModeWordWrap);
	text_layer_set_background_color(textLayer, GColorClear);
	text_layer_set_text_color(textLayer, GColorWhite);
	text_layer_set_font(textLayer, font);
	layer_set_hidden(text_layer_get_layer(textLayer), true);
	layer_add_child(rootLayer, text_layer_get_layer(textLayer));
	
	setDate(tm);
	calcAngles(tm);

	tick_timer_service_subscribe(MINUTE_UNIT, handleTick);
	
	accel_tap_service_subscribe(tapHandler);
	bluetooth_connection_service_subscribe(&handle_bluetooth);
}