Esempio n. 1
0
void handle_init() {
  autoconfig_init();

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

  app_message_register_inbox_received(in_received_handler);

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

  for (int i = 0; i < TOTAL_IMAGE_SLOTS; i++) {
    bitmaps[i] = NULL;
    image_containers[i] = bitmap_layer_create(GRect(
      ((i % 4) * 36),
      ((i / 4) * 70)+15,
      36,70));
    layer_add_child(window_layer, bitmap_layer_get_layer(image_containers[i]));
  }

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

  tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick);
}
static void init(void) {
	// Initialize Pebble Autoconfig to register App Message handlers and restores settings
	autoconfig_init();

	// Here the restored or defaulted settings are available
	logSettings("restored");

	// Register our custom receive handler which in turn will call Pebble Autoconfigs receive handler
	app_message_register_inbox_received(in_received_handler);
	
	window = window_create();
	Layer *window_layer = window_get_root_layer(window);
	GRect bounds = layer_get_frame(window_layer);

	for (int i = 0; i < SETTING_COUNT; ++i) {
		layer[i] = text_layer_create(GRect(10, 10 + i*35, bounds.size.w - 10, 28));
		layer_add_child(window_layer, text_layer_get_layer(layer[i]));
	}

	updateDisplay();

	// Attach our desired button functionality
	window_set_click_config_provider(window, (ClickConfigProvider) click_config_provider);

	window_stack_push(window, true);
}
Esempio n. 3
0
static void init(void) {
  autoconfig_init();
  
  window = window_create();
  window_set_background_color(window,GColorBlack);
  window_set_window_handlers(window, (WindowHandlers) {
    .load = window_load,
    .unload = window_unload,
  });
Esempio n. 4
0
static void init(void) {
  autoconfig_init();
  app_message_register_inbox_received(in_received_handler);
  accel_tap_service_subscribe(&accel_tap_handler);

  window = window_create();
  window_set_window_handlers(window, (WindowHandlers) {
    .load = window_load,
    .unload = window_unload,
  });
Esempio n. 5
0
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");
}
Esempio n. 6
0
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();
}