Example #1
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);

#if DISPLAY_DATE_ANALOG
  bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND_DATEBOX, &background_image_container);
#elif INVERTED
  bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND_INVERTED, &background_image_container);
#else
  bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND, &background_image_container);
#endif
  layer_add_child(&window.layer, &background_image_container.layer.layer);

#if DISPLAY_DATE_ANALOG
  date_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ORBITRON_MEDIUM_12));
  text_layer_init(&date_layer, GRect(116, 77, 20, 20));
#else
  date_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_DIGITALDREAM_NARROW_12));
  text_layer_init(&date_layer, GRect(27, 110, 90, 30));
#endif
#if DISPLAY_DATE_ANALOG
  text_layer_set_text_color(&date_layer, GColorBlack);
#elif INVERTED
  text_layer_set_text_color(&date_layer, GColorBlack);
#else
  text_layer_set_text_color(&date_layer, GColorWhite);
#endif
  text_layer_set_text_alignment(&date_layer, GTextAlignmentCenter);
  text_layer_set_background_color(&date_layer, GColorClear);
  text_layer_set_font(&date_layer, date_font);
  layer_add_child(&window.layer, &date_layer.layer);

  draw_date();

  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);
#if DISPLAY_SECONDS
  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);
#endif
}
Example #2
0
void handle_init(AppContextRef ctx) {
	(void)ctx;
	
	app_ctx = ctx;

	window_init(&window, "Vibe");
	window_stack_push(&window, true /* Animated */);
    
	power = 3;
	on = false;
	
	resource_init_current_app(&APP_RESOURCES);
	
	layer_init(&controls_layer, GRect(124, 3, 20, 146));
	controls_layer.update_proc = &controls_update_callback;
	layer_add_child(&window.layer, &controls_layer);
	
	layer_init(&bars_layer, GRect(22, 22, 85, 115));
	bars_layer.update_proc = &bars_update_callback;
	layer_add_child(&window.layer, &bars_layer);
	
	bmp_init_container(RESOURCE_ID_IMAGE_CONTROLS, &controls);
	bmp_init_container(RESOURCE_ID_IMAGE_BAR_ON,   &bar_on);
	bmp_init_container(RESOURCE_ID_IMAGE_BAR_OFF,  &bar_off);
	
	window_set_click_config_provider(&window, (ClickConfigProvider) click_config_provider);
}
Example #3
0
//
// sets up the display
//
void handle_init(AppContextRef ctx) {
  (void)ctx;

    window_init(&window, "Simplicity");
    window_stack_push(&window, true /* Animated */);
    window_set_background_color(&window, GColorBlack);
    resource_init_current_app(&APP_RESOURCES);
    
    //
    // Load the bitmaps
    //
    bmp_init_container( RESOURCE_ID_IMAGE_PIC1, &_pic1 );
    bmp_init_container( RESOURCE_ID_IMAGE_PIC2, &_pic2 );
    bmp_init_container( RESOURCE_ID_IMAGE_PIC3, &_pic3 );

    //
    // create the bitmap layer at the back
    //
    bitmap_layer_init( &_currentPicture, GRect(0,0, 144, 168) );
    layer_add_child( &window.layer, &_currentPicture.layer );
    
    //
    // load the font we are using
    //
    GFont font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_21));
    
    //
    // create the text layers
    //
    setupTextLayer( &_currentDate, &window, 2, 168-21, 144-4, 21, font );
    setupTextLayer( &_currentTime, &window, 2, 168-42, 144-4, 21, font );
}
Example #4
0
void handle_init(AppContextRef ctx) {
    (void)ctx;

    window_init(&window, "Brown Watch");
    window_stack_push(&window, true /* Animated */);

    resource_init_current_app(&APP_RESOURCES);
#if DISPLAY_DATE_SHORT
    bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND_BOX, &background_image_container);
#else
    bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND, &background_image_container);
#endif
    layer_add_child(&window.layer, &background_image_container.layer.layer);


#if DISPLAY_DATE_SHORT || DISPLAY_DATE_LONG
    date_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_OPENSANS_REGULAR_14));
    text_layer_init(&date_layer, GRect(27, 110, 90, 30));
    text_layer_set_text_alignment(&date_layer, GTextAlignmentCenter);
    text_layer_set_text_color(&date_layer, GColorWhite);
    text_layer_set_background_color(&date_layer, GColorClear);
    text_layer_set_font(&date_layer, date_font);
    layer_add_child(&window.layer, &date_layer.layer);
    draw_date();
#endif

    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_outline_path, &HOUR_HAND_OUTLINE_PATH_POINTS);
    gpath_move_to(&hour_hand_outline_path, grect_center_point(&hour_display_layer.frame));
    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_outline_path, &MINUTE_HAND_OUTLINE_PATH_POINTS);
    gpath_move_to(&minute_hand_outline_path, grect_center_point(&minute_display_layer.frame));
    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);

#if DISPLAY_SECONDS
    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);
#endif
}
void load_digit_image_into_slot(int slot_number, int digit_value)
{
   /*

     Loads the digit image from the application's resources and
     displays it on-screen in the correct location.

     Each slot is a quarter of the screen.

   */

  // TODO: Signal these error(s)?

 if((slot_number < 0) || (slot_number >= TOTAL_IMAGE_SLOTS))
  {
	return;
  }
 
 if((digit_value < 0) || (digit_value > 9)) { return; }
 if(image_slot_state[slot_number] != EMPTY_SLOT) { return; }
 
 image_slot_state[slot_number] = digit_value;
 bmp_init_container(IMAGE_RESOURCE_IDS[digit_value], &image_containers[slot_number]);
 image_containers[slot_number].layer.layer.frame.origin.x = (slot_number % 2) * 72;
 image_containers[slot_number].layer.layer.frame.origin.y = (slot_number % 2) * 84;
 layer_add_child(&window.layer, &image_containers[slot_number].layer.layer);

} //end of load_digit function 
Example #6
0
void handle_init(AppContextRef ctx) {
  (void)ctx;

  window_init(&window, "Orbit");
  window_stack_push(&window, false /* Not Animated */);
  window_set_background_color(&window, GColorBlack);

  resource_init_current_app(&RESOURCES);

  bmp_init_container(RESOURCE_ID_IMAGE_FACE, &faceImage);
  layer_add_child(&window.layer, &faceImage.layer.layer);

  rotbmp_pair_init_container(RESOURCE_ID_IMAGE_MINUTE_PLANET_WHITE, RESOURCE_ID_IMAGE_MINUTE_PLANET_BLACK, &minuteImage);
  layer_add_child(&window.layer, &minuteImage.layer.layer);

  rotbmp_pair_init_container(RESOURCE_ID_IMAGE_HOUR_PLANET_WHITE, RESOURCE_ID_IMAGE_HOUR_PLANET_BLACK, &hourImage);
  layer_add_child(&window.layer, &hourImage.layer.layer);

  text_layer_init(&minuteText, GRect(0,0,0,0));
  text_layer_set_text_color(&minuteText, GColorWhite);
  text_layer_set_background_color(&minuteText, GColorClear);
  text_layer_set_text_alignment(&minuteText, GTextAlignmentCenter);
  text_layer_set_font(&minuteText, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_14)));
  layer_add_child(&window.layer, &minuteText.layer);

  text_layer_init(&hourText, GRect(0,0,0,0));
  text_layer_set_text_color(&hourText, GColorWhite);
  text_layer_set_background_color(&hourText, GColorClear);
  text_layer_set_text_alignment(&hourText, GTextAlignmentCenter);
  text_layer_set_font(&hourText, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_22)));
  layer_add_child(&window.layer, &hourText.layer);

  update_rings();
}
Example #7
0
void load_hangout_image(Layer* layer, GContext* ctx) {
	unload_hangout_image();
	bmp_init_container(RESOURCE_ID_IMAGE_HANGOUT, &messageLayer.hangoutImageContainer);
	layer_set_frame(&messageLayer.hangoutImageContainer.layer.layer,GRect(0,0,26,25));
	layer_add_child(layer, &messageLayer.hangoutImageContainer.layer.layer);
	messageLayer.hangoutImageLoaded = true;
}
Example #8
0
void load_gmail_image(Layer* layer, GContext* ctx) {
	unload_gmail_image();
	bmp_init_container(RESOURCE_ID_IMAGE_ENVELOPE, &messageLayer.gmailImageContainer);
	layer_set_frame(&messageLayer.gmailImageContainer.layer.layer,GRect(0,0,26,25));
	layer_add_child(layer, &messageLayer.gmailImageContainer.layer.layer);
	messageLayer.gmailImageLoaded = true;
}
Example #9
0
void load_phone_image(Layer* layer, GContext* ctx) {
	unload_phone_image();
	bmp_init_container(RESOURCE_ID_IMAGE_PHONE, &messageLayer.missedCallImageContainer);
	layer_set_frame(&messageLayer.missedCallImageContainer.layer.layer,GRect(0,0,26,25));
	layer_add_child(layer, &messageLayer.missedCallImageContainer.layer.layer);
	messageLayer.missedCallImageLoaded = true;
}
Example #10
0
void handle_init(AppContextRef ctx) {
  // Create the main window and push it in fullscreen mode
  window_init(&window, "Window Name");
  window_stack_push(&window, true /* Animated */);
  window_set_fullscreen(&window, true);

  // Initialize ressources and load the background image
  resource_init_current_app(&APP_RESOURCES);
  bmp_init_container(RESOURCE_ID_BACKGROUND_IMAGE, &background_image);
  layer_add_child(&window.layer, &background_image.layer.layer);

  // Create a text field to display the time until the next pass
  text_layer_init(&nextpass_text_layer, GRect(0, 126, 144, 34));
  text_layer_set_font(&nextpass_text_layer, fonts_get_system_font(FONT_KEY_BITHAM_34_MEDIUM_NUMBERS));
  text_layer_set_text_alignment(&nextpass_text_layer, GTextAlignmentCenter);
  text_layer_set_background_color(&nextpass_text_layer, GColorClear);
  layer_add_child(window_get_root_layer(&window), (Layer*)&time_text_layer);

  // Create a text field to display the current time
  text_layer_init(&time_text_layer, GRect(37, 0, 70, 24));
  text_layer_set_font(&time_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
  text_layer_set_text_alignment(&time_text_layer, GTextAlignmentCenter);
  text_layer_set_background_color(&time_text_layer, GColorClear);
  layer_add_child(window_get_root_layer(&window), (Layer*)&nextpass_text_layer);


  // Add background and both text fields to the window

  // Start an HTTP Request
  start_http_request();
}
Example #11
0
void handle_init(AppContextRef ctx) {
  (void)ctx;

  window_init(&window, "Bar Graph");
  window_stack_push(&window, true /* Animated */);

  resource_init_current_app(&APP_RESOURCES);

  bmp_init_container(RESOURCE_ID_IMAGE_FACE, &faceImage);
  layer_add_child(&window.layer, &faceImage.layer.layer);

  layer_init(&hourLayer, window.layer.frame);
  hourLayer.update_proc = &update_hour;
  layer_add_child(&window.layer, &hourLayer);

  layer_init(&minLayer, window.layer.frame);
  minLayer.update_proc = &update_minute;
  layer_add_child(&window.layer, &minLayer);

  text_layer_init(&dateText, GRect(0,138,144,30));
  text_layer_set_text_color(&dateText, GColorWhite);
  text_layer_set_background_color(&dateText, GColorClear);
  text_layer_set_text_alignment(&dateText, GTextAlignmentCenter);
  text_layer_set_font(&dateText, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ARIAL_22)));
  layer_add_child(&window.layer, &dateText.layer);

  update_date();
}
// Handle the start-up of the app
void handle_init(AppContextRef app_ctx) {

	// Create our app's base window
	window_init(&window, "Silly Walk");
	window_stack_push(&window, true);
	window_set_background_color(&window, GColorBlack);

	resource_init_current_app(&APP_RESOURCES);

	// Set up a layer for the static watch face background
	bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND, &background_image_container);
	layer_add_child(&window.layer, &background_image_container.layer.layer);


	// Set up a layer for the hour hand
	rotbmp_pair_init_container(RESOURCE_ID_IMAGE_HOUR_HAND_WHITE, RESOURCE_ID_IMAGE_HOUR_HAND_BLACK, &hour_hand_image_container);
	rotbmp_pair_layer_set_src_ic(&hour_hand_image_container.layer, GPoint(33, 40));
	layer_add_child(&window.layer, &hour_hand_image_container.layer.layer);


	// Set up a layer for the minute hand
	rotbmp_pair_init_container(RESOURCE_ID_IMAGE_MINUTE_HAND_WHITE, RESOURCE_ID_IMAGE_MINUTE_HAND_BLACK, &minute_hand_image_container);
	rotbmp_pair_layer_set_src_ic(&minute_hand_image_container.layer, GPoint(16, 60));
	layer_add_child(&window.layer, &minute_hand_image_container.layer.layer);


	PblTm t;
	get_time(&t);
	update_watch(&t);

}
Example #13
0
void handle_init(AppContextRef ctx) {
    memset(&background_image, 0, sizeof(background_image));
    memset(&day_name_image, 0, sizeof(day_name_image));
    memset(&date_digits_images, 0, sizeof(date_digits_images));
    memset(&time_digits_images, 0, sizeof(time_digits_images));
    memset(&digits, 0, sizeof(digits));
    memset(&display_layer, 0, sizeof(display_layer));
    
    
    window_init(&window, "LCAR");
    window_stack_push(&window, true /* Animated */);
    
    resource_init_current_app(&APP_RESOURCES);
    
    bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND, &background_image);
    layer_init(&display_layer, GRect(43, 110, 82, 35));
    display_layer.update_proc = &display_layer_update_callback;
    
    layer_add_child(&window.layer, &background_image.layer.layer);
    
    
    layer_add_child(&window.layer, &background_image.layer.layer);
    layer_add_child(&window.layer,&display_layer);
    
 
    
    
    // Avoids a blank screen on watch start.
    PblTm tick_time;
    
    get_time(&tick_time);
    update_display(&tick_time);
    
}
Example #14
0
void handle_init(AppContextRef ctx) {
  (void) ctx;

  window_init(&window, "Totoro");
  window_stack_push(&window, true);

  resource_init_current_app(&APP_RESOURCES);

  // Set up a layer for the static watch face background
  bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND, &background_image_container);
  layer_add_child(&window.layer, &background_image_container.layer.layer);


  // Date
  // Initialises the date and sets the text, font and background colour
  text_layer_init(&text_date_layer, window.layer.frame);
  text_layer_set_text_color(&text_date_layer, GColorBlack);
  text_layer_set_background_color(&text_date_layer, GColorClear);
  layer_set_frame(&text_date_layer.layer, GRect(69, 150, 80, 15));

  text_layer_set_font(&text_date_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_GOTHIC_REGULAR_12)));
  layer_add_child(&window.layer, &text_date_layer.layer);

  // Time
  // Initialises the time and sets the text, font and background colour
  text_layer_init(&text_time_layer, window.layer.frame);
  text_layer_set_text_color(&text_time_layer, GColorBlack);
  text_layer_set_background_color(&text_time_layer, GColorClear);
  layer_set_frame(&text_time_layer.layer, GRect(0, 0, 144, 44));

  text_layer_set_font(&text_time_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_GOTHIC_REGULAR_36)));
  text_layer_set_text_alignment(&text_time_layer, GTextAlignmentCenter);
  layer_add_child(&window.layer, &text_time_layer.layer);

}
Example #15
0
static void
handle_init( AppContextRef ctx)
{
	(void)ctx;

	// Fonts will NOT work without this!
	resource_init_current_app(&APP_RESOURCES);
	
	window_init(&window, "Hello, Pebble");
	window_stack_push(&window, true /* Animated */);
		
	// Create a container for the static background image (recovery symbol)
	bmp_init_container(RESOURCE_ID_IMAGE_FANCY_FRAME, &bg_img);
	// place image
	bg_img.layer.layer.frame.origin.x = 0;
	bg_img.layer.layer.frame.origin.y = 0;

	layer_add_child(&window.layer, &bg_img.layer.layer);
	// draw the image
	layer_mark_dirty(&bg_img.layer.layer);
	
	// Tell it what font to use
	myfont = fonts_load_custom_font(
		resource_get_handle(RESOURCE_ID_FONT_QUMPELLKA_20));

	// Add TIME
	// GRect takes x,y,w,h
	text_layer_init(&text_time, GRect(30,70,80,30));
	text_layer_set_font(&text_time, myfont);
	text_layer_set_text(&text_time, "");
	text_layer_set_background_color(&text_time, GColorClear);
	text_layer_set_text_color(&text_time, GColorWhite);
	text_layer_set_text_alignment(&text_time, GTextAlignmentCenter);
	layer_add_child(&window.layer, &text_time.layer);
	
	/*********************** CODE FOR INCLUDING DATE ****************
	// Add DAY OF THE MONTH
	// GRect takes x,y,w,h
	text_layer_init(&text_day, GRect(75,118,73,58));
	text_layer_set_font(&text_day, myfont);
	text_layer_set_text(&text_day, "");
	text_layer_set_background_color(&text_day, GColorClear);
	text_layer_set_text_color(&text_day, GColorBlack);
	layer_add_child(&window.layer, &text_day.layer);
	
	// Change fonts so the month won't be too big'
	myfont = fonts_load_custom_font(
		resource_get_handle(RESOURCE_ID_FONT_QARMIC_SANS_18));
	
	// Add MONTH
	// GRect takes x,y,w,h
	text_layer_init(&text_month, GRect(75,144,73,58));
	text_layer_set_font(&text_month, myfont);
	text_layer_set_text(&text_month, "");
	text_layer_set_background_color(&text_month, GColorClear);
	text_layer_set_text_color(&text_month, GColorBlack);
	layer_add_child(&window.layer, &text_month.layer);
	*****************************************************************/
}
Example #16
0
void handle_init(AppContextRef ctx) {
    (void)ctx;

    window_init(&window, "Watchface");
    window_stack_push(&window, true /* Animated */);
    window_set_background_color(&window, GColorBlack);
        
    PblTm t;
    get_time(&t);
    setPhase(daysSinceNewMoon(t.tm_year+1900,t.tm_yday,t.tm_hour));
    
    curHour=t.tm_hour;
    curMin=t.tm_min;
    curSec=t.tm_sec;
    
    if(showDetailedMoonGraphic){
        
        resource_init_current_app(&LUNARCLOCK_IMAGE_RESOURCES);
        bmp_init_container(RESOURCE_ID_IMAGE_MOON, &moonimage_container);
        layer_add_child(&window.layer, &moonimage_container.layer.layer);
    }else{
        layer_init(&moon_layer, window.layer.frame);
        moon_layer.update_proc = &moon_layer_update_callback;
        layer_add_child(&window.layer, &moon_layer);
    }
    layer_init(&shadow_layer, window.layer.frame);
    shadow_layer.update_proc = &shadow_layer_update_callback;
    layer_add_child(&window.layer, &shadow_layer);
    
    layer_init(&phase_layer, window.layer.frame);
    phase_layer.update_proc = &phase_layer_update_callback;
    layer_add_child(&window.layer, &phase_layer);
    
    if(showHours){
        layer_init(&hour_layer, window.layer.frame);
        hour_layer.update_proc = &hour_layer_update_callback;
        layer_add_child(&window.layer, &hour_layer);
        
        gpath_init(&hour_hand, &hour_hand_info);
        gpath_move_to(&hour_hand, GPoint(centerx, centery));
        
    }
    if(showMinutes){
        layer_init(&minute_layer, window.layer.frame);
        minute_layer.update_proc = &minute_layer_update_callback;
        layer_add_child(&window.layer, &minute_layer);
        
        gpath_init(&minute_hand, &minute_hand_info);
        gpath_move_to(&minute_hand, GPoint(centerx, centery));
    }
    if(showSeconds){
        layer_init(&second_layer, window.layer.frame);
        second_layer.update_proc = &second_layer_update_callback;
        layer_add_child(&window.layer, &second_layer);
    }
    layer_init(&top_layer, window.layer.frame);
    top_layer.update_proc = &top_layer_update_callback;
    layer_add_child(&window.layer, &top_layer);
}
void handle_init(AppContextRef ctx) {
  (void)ctx;
  window_init(&window, "PowerSave");
  window_stack_push(&window, false /* NOT Animated */);
  resource_init_current_app(&APP_RESOURCES);
  bmp_init_container(RESOURCE_ID_IMAGE, &bmp_cont);
  layer_add_child(&window.layer, &bmp_cont.layer.layer);
}
Example #18
0
void set_background_image(BmpContainer *bmp_container, const int resource_id) {
    //Remove the old image
    layer_remove_from_parent(&bmp_container->layer.layer);
    bmp_deinit_container(bmp_container);
    //Display the new image
    bmp_init_container(resource_id, bmp_container);
    layer_add_child(&background_layer, &bmp_container->layer.layer);
}
void handle_init(AppContextRef ctx) {
  (void)ctx;

  window_init(&window, "Beer O Clock");
  window_stack_push(&window, true);

  window_set_background_color(&window, GColorBlack);

  resource_init_current_app(&APP_RESOURCES);

  // Mug
  bmp_init_container(RESOURCE_ID_IMAGE_MUG, &imageMug);
  imageMug.layer.layer.frame.origin.x = 25;
  imageMug.layer.layer.frame.origin.y = 11;  
  layer_add_child(&window.layer, &imageMug.layer.layer);

  // Beer and its container
  layer_init(&beerContainer, GRect(25, 0, 66, 125));
  bmp_init_container(RESOURCE_ID_IMAGE_BEER, &imageBeer);
  bitmap_layer_set_compositing_mode(&imageBeer.layer, GCompOpOr);
  imageBeer.layer.layer.frame.origin.x = 0;
  imageBeer.layer.layer.frame.origin.y = BEER_STARTING_Y;  
  layer_add_child(&window.layer, &beerContainer);
  layer_add_child(&beerContainer, &imageBeer.layer.layer);

  // BOC
  rotbmp_pair_init_container(RESOURCE_ID_IMAGE_TEXT_WHITE, RESOURCE_ID_IMAGE_TEXT_BLACK, &imageBOC);
  imageBOC.layer.layer.frame.origin.x = 3;
  imageBOC.layer.layer.frame.origin.y = 65;
  layer_add_child(&window.layer, &imageBOC.layer.layer);

  // Time display
  text_layer_init(&timeLayer, GRect(40, 140, 80, 40));
  text_layer_set_text_color(&timeLayer, GColorWhite);
  text_layer_set_background_color(&timeLayer, GColorClear);
  text_layer_set_font(&timeLayer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
  layer_add_child(&window.layer, &timeLayer.layer);

  // Avoid a blank screen on watch start
  PblTm tick_time;
  get_time(&tick_time);
  update_display(&tick_time);
}
Example #20
0
void handle_init(AppContextRef ctx) {
	(void)ctx;
    	
	window_init(&window, "Dragon Clock");
	window_stack_push(&window, true /* Animated */);
	
	resource_init_current_app(&APP_RESOURCES);
    
    // Set up layer for the hour hand
	rotbmp_init_container(RESOURCE_ID_DRAGON_HOUR_HAND, &hour_hand_image_container);
	rot_bitmap_set_src_ic(&hour_hand_image_container.layer, GPoint(2, 28));
	layer_add_child(&window.layer, &hour_hand_image_container.layer.layer);
	
	// Set up layer for the minute hand
	rotbmp_init_container(RESOURCE_ID_DRAGON_MINUTE_HAND, &minute_hand_image_container);
	rot_bitmap_set_src_ic(&minute_hand_image_container.layer, GPoint(0, 45));
	layer_add_child(&window.layer, &minute_hand_image_container.layer.layer);
    
    // Set up layer for dragon background image
	layer_init(&background_layer, window.layer.frame);

	// Using a "hack" to get a transparent png to render without slowing the watch down to a crawl.
	// Usually a transparent png needs a RotBmpPairContainer, but in this case we are taking both
	// the white part and the black part and rendering them in separate BmpContainers, then setting
	// the compositing of each, and finally putting images on the same layer, thus creating a 
	// "transparent" bitmap. Thanks to Philip from Pebble for this "completely un-endorsed, 
	// un-official, don't-actually-do-this-in-production-code" suggestion :)
    bmp_init_container(RESOURCE_ID_DRAGON_BACKGROUND_WHITE, &background_image_container_white);
    background_image_container_white.layer.compositing_mode = GCompOpOr;
    layer_add_child(&background_layer, &background_image_container_white.layer.layer);
    
    bmp_init_container(RESOURCE_ID_DRAGON_BACKGROUND_BLACK, &background_image_container_black);
    background_image_container_black.layer.compositing_mode = GCompOpClear;
    layer_add_child(&background_layer, &background_image_container_black.layer.layer);
    
    layer_add_child(&window.layer, &background_layer);

    // Set up layer that will hold the blink animation
   	frame_animation_init(&blink_animation, &window.layer, GPoint(11, 111), RESOURCE_ID_DRAGON_BLINK_1_WHITE, 4, true, true);

	update_hand_positions(&hour_hand_image_container, &minute_hand_image_container);	
}
Example #21
0
void LoadBackgroundImage(Window *window, int id)
{
	int resourceId = id;
	if(!backgroundLoaded)
	{
		bmp_init_container(resourceId, &backgroundImage);
		backgroundLoaded = true;
	}
	
	layer_add_child(&window->layer, &backgroundImage.layer.layer);		
}
Example #22
0
void weather_layer_set_icon(WeatherLayer* weather_layer, WeatherIcon icon) {
	if(weather_layer->has_weather_icon) {
		layer_remove_from_parent(&weather_layer->icon_layer.layer.layer);
		bmp_deinit_container(&weather_layer->icon_layer);
		weather_layer->has_weather_icon = false;
	}
	bmp_init_container(WEATHER_ICONS[icon], &weather_layer->icon_layer);
	layer_add_child(&weather_layer->layer, &weather_layer->icon_layer.layer.layer);
	layer_set_frame(&weather_layer->icon_layer.layer.layer, GRect(10, 4, 60,60));
	weather_layer->has_weather_icon = true;
}
Example #23
0
void set_container_image(BmpContainer *bmp_container, const int resource_id, GPoint origin) {
  layer_remove_from_parent(&bmp_container->layer.layer);
  bmp_deinit_container(bmp_container);

  bmp_init_container(resource_id, bmp_container);

  GRect frame = layer_get_frame(&bmp_container->layer.layer);
  frame.origin.x = origin.x;
  frame.origin.y = origin.y;
  layer_set_frame(&bmp_container->layer.layer, frame);

  layer_add_child(&window.layer, &bmp_container->layer.layer);
}
Example #24
0
void set_container_image(BmpContainer *bmp_container, const int resource_id, GPoint origin, Layer *targetLayer) {
    
    remove_container(bmp_container);
    
    bmp_init_container(resource_id, bmp_container);                   //init the container with the new image
    
    GRect frame = layer_get_frame(&bmp_container->layer.layer);       //posiiton the new image with the supplied coordinates.
    frame.origin.x = origin.x;
    frame.origin.y = origin.y;
    layer_set_frame(&bmp_container->layer.layer, frame);

    layer_add_child(targetLayer, &bmp_container->layer.layer);        //add the new image to the target layer.
}
Example #25
0
void weather_layer_set_icon(WeatherLayer* weather_layer, WeatherIcon icon) {
	
	// Remove any possible existing weather icon
	if(weather_layer->has_weather_icon) {
		layer_remove_from_parent(&weather_layer->icon_layer.layer.layer);
		bmp_deinit_container(&weather_layer->icon_layer);
		weather_layer->has_weather_icon = false;
	}
	
	// Add weather icon
	bmp_init_container(WEATHER_ICONS[icon], &weather_layer->icon_layer);
	layer_add_child(&weather_layer->layer, &weather_layer->icon_layer.layer.layer);
	layer_set_frame(&weather_layer->icon_layer.layer.layer, GRect(75,2, 40, 40));
	weather_layer->has_weather_icon = true;
}
void handle_init(AppContextRef ctx) {
    (void)ctx;

    window_init(&window, "Unix Time");
    window_stack_push(&window, true);

    resource_init_current_app(&APP_RESOURCES);

    bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND, &background);
    layer_add_child(&window.layer, &background.layer.layer);

    PblTm tick_time;
    get_time(&tick_time);
    update_display(&tick_time);
}
Example #27
0
void handle_init(AppContextRef ctx) {

  window_init(&window, "91 Dub");
  window_stack_push(&window, true /* Animated */);

  resource_init_current_app(&APP_RESOURCES);

  bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND, &background_image);
  layer_add_child(&window.layer, &background_image.layer.layer);


  bmp_init_container(RESOURCE_ID_IMAGE_METER_BAR, &meter_bar_image);

  meter_bar_image.layer.layer.frame.origin.x = 17;
  meter_bar_image.layer.layer.frame.origin.y = 43;

  layer_add_child(&window.layer, &meter_bar_image.layer.layer);


  if (clock_is_24h_style()) {
    bmp_init_container(RESOURCE_ID_IMAGE_24_HOUR_MODE, &time_format_image);

    time_format_image.layer.layer.frame.origin.x = 17;
    time_format_image.layer.layer.frame.origin.y = 68;

    layer_add_child(&window.layer, &time_format_image.layer.layer);
  }


  // Avoids a blank screen on watch start.
  PblTm tick_time;

  get_time(&tick_time);
  update_display(&tick_time);

}
Example #28
0
void handle_init(AppContextRef ctx) {
  (void)ctx;

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

  resource_init_current_app(&APP_RESOURCES);

  // draw background
  bmp_init_container(RESOURCE_ID_BACKGROUND, &background_image);
  layer_add_child(&window.layer, &background_image.layer.layer);

  // avoid a blank screen on watch start
  PblTm tick_time;
  get_time(&tick_time);
  update_display(&tick_time);
}
Example #29
0
void handle_init( AppContextRef ctx )
{
	(void) ctx;

	window_init( &window, "Timberwolf" );
	window_stack_push( &window, true );

	resource_init_current_app( &APP_RESOURCES );

	// Init the background image layer.
	bmp_init_container( RESOURCE_ID_IMAGE_BACKGROUND, &background_image );
	layer_add_child( &window.layer, &background_image.layer.layer );

	// Init the text layer used to show the time.
	text_layer_init( &time_layer, GRect( 2, -5, 144, 168 ) );
	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) );
	layer_add_child( &window.layer, &time_layer.layer );

	// Init the text layer used to show the date.
	text_layer_init( &date_layer, GRect( 83, 0, 144, 168 ) );
	text_layer_set_text_color( &date_layer, GColorBlack );
	text_layer_set_background_color( &date_layer, GColorClear );
	text_layer_set_font( &date_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14) );
	layer_add_child( &window.layer, &date_layer.layer );

	// Init the text layer used to show the weekday.
	text_layer_init( &wday_layer, GRect( 118, 13, 144, 168 ) );
	text_layer_set_text_color( &wday_layer, GColorBlack );
	text_layer_set_background_color( &wday_layer, GColorClear );
	text_layer_set_font( &wday_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14) );
	layer_add_child( &window.layer, &wday_layer.layer );

	// Init the text layer used to show AM/PM in 12-hour mode.
	text_layer_init( &ampm_layer, GRect( 2, 22, 144, 168 ) );
	text_layer_set_text_color( &ampm_layer, GColorBlack );
	text_layer_set_background_color( &ampm_layer, GColorClear );
	text_layer_set_font( &ampm_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14) );
	layer_add_child( &window.layer, &ampm_layer.layer );

	// Avoid a blank screen on watch start.
	PblTm tick_time;
	get_time( &tick_time );
	update_display( &tick_time );
}
// Handle the start-up of the app
void handle_init(AppContextRef app_ctx) {

    // Create our app's base window
    window_init(&window, "Peanut Butter Jelly Time");
    window_stack_push(&window, true);
    window_set_background_color(&window, GColorBlack);

    GFont font_date;

    resource_init_current_app(&APP_RESOURCES);

    font_date = fonts_get_system_font(FONT_KEY_GOTHIC_14);

    // Set up a layer for the static watch face background
    bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND, &background_image_container);
    layer_add_child(&window.layer, &background_image_container.layer.layer);


    // Set up a layer for the hour hand
    rotbmp_pair_init_container(RESOURCE_ID_IMAGE_HOUR_HAND_WHITE, RESOURCE_ID_IMAGE_HOUR_HAND_BLACK, &hour_hand_image_container);
    rotbmp_pair_layer_set_src_ic(&hour_hand_image_container.layer, GPoint(33, 40));
    layer_add_child(&window.layer, &hour_hand_image_container.layer.layer);


    // Set up a layer for the minute hand
    rotbmp_pair_init_container(RESOURCE_ID_IMAGE_MINUTE_HAND_WHITE, RESOURCE_ID_IMAGE_MINUTE_HAND_BLACK, &minute_hand_image_container);
    rotbmp_pair_layer_set_src_ic(&minute_hand_image_container.layer, GPoint(16, 60));
    layer_add_child(&window.layer, &minute_hand_image_container.layer.layer);

    // Set up a layer for the date
    text_layer_init(&text_date_layer, window.layer.frame);
    text_layer_set_text_color(&text_date_layer, GColorWhite);
    text_layer_set_background_color(&text_date_layer, GColorClear);
    layer_set_frame(&text_date_layer.layer, GRect(8, 152, 144-8, 168-92));
    text_layer_set_font(&text_date_layer, font_date);
    text_layer_set_text_alignment(&text_date_layer,GTextAlignmentCenter);
    layer_add_child(&window.layer, &text_date_layer.layer);


    PblTm t;
    get_time(&t);
    update_watch(&t);

    last_wday = -1;

}