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

}
Esempio n. 2
0
static void watch_toggled(DBusWatch *dbus_watch, void *userdata) {
    ConnectionData *d = userdata;

    assert(dbus_watch);
    assert(d);

    update_watch(d->poll_api, dbus_watch);
}
Esempio n. 3
0
static dbus_bool_t add_watch(DBusWatch *dbus_watch, void *userdata) {
    ConnectionData *d = userdata;

    assert(dbus_watch);
    assert(d);

    return update_watch(d->poll_api, dbus_watch);
}
Esempio n. 4
0
int main() {
	init_lcd();
	init_watch(&watch_state);
	disp_watch(&watch_state);
	P1 = 0x0F;										// LEDs as outputs, switches as inputs.
	while(1) {
		update_watch(&watch_state);
		disp_watch(&watch_state);
	}
}
// 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;

}
Esempio n. 6
0
// Handle the start-up of the app
void handle_init() {

  // Create our app's base window
  window = window_create();
  Layer *root_window_layer = window_get_root_layer(window);
  GRect root_window_bounds = layer_get_bounds(root_window_layer);

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

  // Set up a layer for the static watch face background
  background_layer = bitmap_layer_create(root_window_bounds);
  background_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BACKGROUND);
  bitmap_layer_set_bitmap(background_layer, background_image);
  layer_add_child(root_window_layer,
		  bitmap_layer_get_layer(background_layer));

  // Set up a layer for the minute hand.
  // Compositing tricks take the place of PNG transparency.
  minute_hand_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_MINUTE_TRAIL);
  minute_hand_layer = rot_bitmap_layer_create(minute_hand_image);

  // Default frame for RotBitmapLayers is according to some
  // opaque algorithm. Automatically centre it now.
  GRect minute_frame = layer_get_frame(bitmap_layer_get_layer((BitmapLayer *)minute_hand_layer));
  GRect new_minute_frame = GRect((144-minute_frame.size.w)/2,
				 (168-minute_frame.size.h)/2,
				 minute_frame.size.w, minute_frame.size.h);
  APP_LOG(APP_LOG_LEVEL_DEBUG, "minute frame: %i, %i, %i, %i",
	  minute_frame.origin.x, minute_frame.origin.y,
	  minute_frame.size.w, minute_frame.size.h);
  layer_set_frame(bitmap_layer_get_layer((BitmapLayer *)minute_hand_layer),
		  new_minute_frame);

  rot_bitmap_set_compositing_mode(minute_hand_layer, GCompOpOr);
  layer_add_child(root_window_layer,
		  bitmap_layer_get_layer((BitmapLayer *)minute_hand_layer));


  // Set up a layer for the hour hand.
  // Compositing tricks take the place of PNG transparency.
  hour_hand_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_HOUR_TRAIL);
  hour_hand_layer = rot_bitmap_layer_create(hour_hand_image);

  GRect hour_frame = layer_get_frame(bitmap_layer_get_layer((BitmapLayer *)hour_hand_layer));
  // The current images seem to look best if this frame is offset
  // one more pixel. Still not perfect though.
  GRect new_hour_frame = GRect((144-hour_frame.size.w)/2 + 1,
			       (168-hour_frame.size.h)/2 + 1,
			       hour_frame.size.w, hour_frame.size.h);
  APP_LOG(APP_LOG_LEVEL_DEBUG, "hour frame: %i, %i, %i, %i",
	  hour_frame.origin.x, hour_frame.origin.y,
	  hour_frame.size.w, hour_frame.size.h);
  layer_set_frame(bitmap_layer_get_layer((BitmapLayer *)hour_hand_layer),
		  new_hour_frame);
  rot_bitmap_set_compositing_mode(hour_hand_layer, GCompOpOr);
  layer_add_child(root_window_layer,
		  bitmap_layer_get_layer((BitmapLayer *)hour_hand_layer));

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

  tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick);

}
Esempio n. 7
0
// Called once per second
void handle_minute_tick(struct tm *t, TimeUnits units_changed) {
  (void)units_changed;
  update_watch(t);
}
// Called once per second
void handle_minute_tick(AppContextRef ctx, PebbleTickEvent *t) {
	update_watch(t->tick_time);
}