Exemplo n.º 1
0
void handle_init(AppContextRef ctx) {
	Layer *rootLayer;
	int i;
	
	window_init(&window, "Minimalist");
	window_stack_push(&window, true /* Animated */);
	window_set_background_color(&window, GColorBlack);
	
	clock12 = !clock_is_24h_style();
	
	resource_init_current_app(&APP_RESOURCES);
	
	for (i=0; i<NUM_IMAGES; i++) {
		heap_bitmap_init(&digitBmp[i], digitId[i]);
#if WHITE_BACKGROUND
		bmpNegative(&digitBmp[i].bmp);
#endif
	}
	
	rootLayer = window_get_root_layer(&window);
	layer_init(&layer, GRect(0,0,SCREENW,SCREENH));
	layer_set_update_proc(&layer, &update_display);
	layer_add_child(rootLayer, &layer);
	
	handle_tick(ctx, NULL);
	//layer_mark_dirty(&layer);
}
Exemplo n.º 2
0
void update_stats() {
  snprintf(string_call, sizeof(string_call), "%d", number_call);
  layer_mark_dirty(&layer_numbercall.layer);

  snprintf(string_message, sizeof(string_message), "%d", number_message);
  layer_mark_dirty(&layer_numbermessage.layer);
  
  int battery_id;
  if (level_battery > 0)
    battery_id = RESOURCE_ID_PNG_BATTERY_20;	
  if (level_battery > 20)
    battery_id = RESOURCE_ID_PNG_BATTERY_40;
  if (level_battery > 40)
    battery_id = RESOURCE_ID_PNG_BATTERY_60;
  if (level_battery > 60)
    battery_id = RESOURCE_ID_PNG_BATTERY_80;
  if (level_battery > 80)
    battery_id = RESOURCE_ID_PNG_BATTERY_100;  
  if (&bitmap_battery.bmp)
    heap_bitmap_deinit(&bitmap_battery);
  heap_bitmap_init(&bitmap_battery, battery_id);
  layer_mark_dirty(&layer_battery.layer);
  
  int signal_id;
  if (level_signal > 0)
    signal_id = RESOURCE_ID_PNG_SIGNAL_20;	
  if (level_signal > 20)
    signal_id = RESOURCE_ID_PNG_SIGNAL_40;
  if (level_signal > 40)
    signal_id = RESOURCE_ID_PNG_SIGNAL_60;
  if (level_signal > 60)
    signal_id = RESOURCE_ID_PNG_SIGNAL_80;
  if (level_signal > 80)
    signal_id = RESOURCE_ID_PNG_SIGNAL_100;
  if (&bitmap_battery.bmp)
    heap_bitmap_deinit(&bitmap_signal);
  heap_bitmap_init(&bitmap_signal, signal_id);
  layer_mark_dirty(&layer_signal.layer);  
}
Exemplo n.º 3
0
static void load_bitmap(uint32_t resource_id) {

  // If that resource is already the current icon, we don't need to reload it
  if (s_data.current_icon == resource_id) {
    return;
  }

  // Only deinit the current bitmap if a bitmap was previously loaded
  if (s_data.current_icon != 0) {
    heap_bitmap_deinit(&s_data.icon_bitmap);
  }

  // Keep track of what the current icon is
  s_data.current_icon = resource_id;

  // Load the new icon
  heap_bitmap_init(&s_data.icon_bitmap, resource_id);

}
void handle_init(AppContextRef ctx) {
    // If you specified resources in resource_map.json, use this
    // to prepare the resources for use within your app
    resource_init_current_app(&APP_RESOURCES);

    // Then use the respective resource loader to obtain the resource for use
    // In this case, we load the image
    heap_bitmap_init(&image, RESOURCE_ID_IMAGE_PUG);

    window_init(&window, "Draw Bitmap");
    window_stack_push(&window, true /* Animated */);

    // Initialize the layer
    layer_init(&layer, window.layer.frame);

    // Set up the update layer callback
    layer_set_update_proc(&layer, layer_update_callback);

    // Add the layer to the window for display
    layer_add_child(&window.layer, &layer);
}
Exemplo n.º 5
0
void handle_init(AppContextRef ctx) {
  (void)ctx;

  window_init(&window, "Modern Watch");
  window_stack_push(&window, true /* Animated */);
  resource_init_current_app(&APP_RESOURCES);

  bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND, &background_image_container);
  layer_add_child(&window.layer, &background_image_container.layer.layer);
	
  heap_bitmap_init(&icon_status_1, RESOURCE_ID_IMAGE_STATUS_1);
  heap_bitmap_init(&icon_status_2, RESOURCE_ID_IMAGE_STATUS_2);
  heap_bitmap_init(&icon_status_3, RESOURCE_ID_IMAGE_STATUS_3);

  text_layer_init(&date_layer, GRect(27, 112, 90, 21));
  text_layer_set_text_color(&date_layer, GColorWhite);
  text_layer_set_text_alignment(&date_layer, GTextAlignmentCenter);
  text_layer_set_background_color(&date_layer, GColorClear);
  text_layer_set_font(&date_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18));
  layer_add_child(&window.layer, &date_layer.layer);
	
  text_layer_init(&date_layer2, GRect(27, 93, 90, 21));
  text_layer_set_text_color(&date_layer2, GColorWhite);
  text_layer_set_text_alignment(&date_layer2, GTextAlignmentCenter);
  text_layer_set_background_color(&date_layer2, GColorClear);
  text_layer_set_font(&date_layer2, fonts_get_system_font(FONT_KEY_GOTHIC_18));
  layer_add_child(&window.layer, &date_layer2.layer);

  draw_date();
	
  GRect sframe;
  sframe.origin.x = 54;
  sframe.origin.y = 56;
  sframe.size.w = 38;
  sframe.size.h = 9;

  layer_init(&status_layer, sframe);
  status_layer.update_proc = &status_layer_update_callback;
  layer_add_child(&window.layer, &status_layer);

  layer_init(&hour_display_layer, window.layer.frame);
  hour_display_layer.update_proc = &hour_display_layer_update_callback;
  layer_add_child(&window.layer, &hour_display_layer);

  gpath_init(&hour_hand_path, &HOUR_HAND_PATH_POINTS);
  gpath_move_to(&hour_hand_path, grect_center_point(&hour_display_layer.frame));

  layer_init(&minute_display_layer, window.layer.frame);
  minute_display_layer.update_proc = &minute_display_layer_update_callback;
  layer_add_child(&window.layer, &minute_display_layer);

  gpath_init(&minute_hand_path, &MINUTE_HAND_PATH_POINTS);
  gpath_move_to(&minute_hand_path, grect_center_point(&minute_display_layer.frame));

  layer_init(&center_display_layer, window.layer.frame);
  center_display_layer.update_proc = &center_display_layer_update_callback;
  layer_add_child(&window.layer, &center_display_layer);

  layer_init(&second_display_layer, window.layer.frame);
  second_display_layer.update_proc = &second_display_layer_update_callback;
  layer_add_child(&window.layer, &second_display_layer);
	
  // Configurable inverse
  #ifdef INVERSE
  inverter_layer_init(&full_inverse_layer, GRect(0, 0, window.layer.bounds.size.w, window.layer.bounds.size.h));
  layer_add_child(&window.layer, &full_inverse_layer.layer);
  #endif
	
  calendar_init(ctx);
}