示例#1
0
void tick_handler(struct tm *tick_time, TimeUnits units_changed) {
    if (units_changed & SECOND_UNIT) {
        g_stat_timer++;

        if (g_stat_timer == 8) {        
            set_new_stat_text();
            g_stat_timer = 0;
        }
    }
    if (units_changed & MINUTE_UNIT) {
#ifndef LOCK_SHIP
        int new_craft_index = rand() % (c_craft_info_count - 1);
        if (new_craft_index >= g_current_craft) {
            new_craft_index++;
        }
        
        load_holomesh(new_craft_index);
        update_title_and_info();
#endif

        update_time_display(tick_time);
    }
    if (units_changed & DAY_UNIT) {
        update_date_display(tick_time);
    }
}
示例#2
0
// Handle the start-up of the app
void handle_init_app(AppContextRef app_ctx) {

  // Create our app's base window
  window_init(&window, "Tic Tock Toe watch");
  window_stack_push(&window, true);

  window_set_background_color(&window, COLOR_BACKGROUND);

  // Init the layer that shows the board
  layer_init(&boardLayer, window.layer.frame); // Associate with layer object and set dimensions
  boardLayer.update_proc = &boardLayer_update_callback; // Set the drawing callback function for the layer.
  layer_add_child(&window.layer, &boardLayer); // Add the child to the app's base window

  // Init the layer that shows the player marks
  // TODO: Wrap this boilerplate in a function?
  layer_init(&playersLayer, window.layer.frame);
  playersLayer.update_proc = &playersLayer_update_callback;
  layer_add_child(&window.layer, &playersLayer);

  // Init the text layer used to show the time
  // TODO: Determine best practice for text. e.g. TextLayer with standard update proc vs Layer with custom update proc
  // TODO: Wrap this boilerplate in a function?
  text_layer_init(&timeLayer, GRect(0, 168-42, 144 /* width */, 42 /* height */));
  text_layer_set_text_alignment(&timeLayer, GTextAlignmentCenter);
  text_layer_set_text_color(&timeLayer, COLOR_FOREGROUND);
  text_layer_set_background_color(&timeLayer, GColorClear);
  text_layer_set_font(&timeLayer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));

  update_time_display();

  layer_add_child(&window.layer, &timeLayer.layer);
}
void main_app_loop()
{
    now_ms = pulse_get_millis();
    if (now_ms - interval_start_time_ms > interval_length_ms) {
        if (display_mode == ANSWER_MODE) {
            set_time_mode();
        }
        update_time_display();
    }
}
示例#4
0
文件: o3.c 项目: niklasmh/ntnu
int main() {

	init();

	init_io();
	update_time_display();

	while (true);
	return 0;
}
示例#5
0
// Called once per second
static void handle_second_tick(AppContextRef ctx, PebbleTickEvent *t) {

  // Causes a redraw of the layer (via the
  // associated layer update callback)
  // Note: This will cause the entire layer to be cleared first so it needs
  //       to be redrawn in its entirety--if you want to preserve drawn
  //       content you must have it on a different layer. e.g. board vs player layers.
  layer_mark_dirty(&playersLayer);

  // TODO: Find out when the redraw actually occurs. Does it make any difference about order of these calls?
  update_time_display();
}
示例#6
0
文件: o3.c 项目: niklasmh/ntnu
void SysTick_Handler() {
	if (state == STATE_COUNT_DOWN) {
		if (time.s <= 0) {
			if (time.m <= 0) {
				if (time.h <= 0) {
					state = STATE_ALARM;
					clock_stop();
					GPIO->ports[LED_PORT].DOUTSET = 1 << LED_PIN;
					update_time_display();
					return;
				}
				--time.h;
				time.m = 61;
			}
			--time.m;
			time.s = 61;
		}
		--time.s;
		update_time_display();
	}
}
示例#7
0
文件: o3.c 项目: niklasmh/ntnu
// For PB0
void GPIO_ODD_IRQHandler() {
	switch (state) {
		case STATE_SET_SEC: {
			increment_sec();
			update_time_display();
		} break;
		case STATE_SET_MIN: {
			increment_min();
			update_time_display();
		} break;
		case STATE_SET_HOUR: {
			increment_hour();
			update_time_display();
		} break;
		case STATE_COUNT_DOWN: break;
		case STATE_ALARM: break;
			GPIO->ports[LED_PORT].DOUTSET = 1 << LED_PIN;
	}

	GPIO->IFC = 1 << PB0_PIN;
}
示例#8
0
void handle_init(AppContextRef ctx) {
  (void)ctx;

  window_init(&window, "Triforce");
  window_stack_push(&window, true /*animated */);
  window_set_background_color(&window,GColorBlack);
    
  // Display the black and white image with transparency.
  resource_init_current_app(&APP_RESOURCES);

  rotbmp_pair_init_container(RESOURCE_ID_IMAGE_TRIFORCE_WHITE, RESOURCE_ID_IMAGE_TRIFORCE_BLACK, &triforce);
  triforce.layer.layer.frame.origin.x = 5;
  triforce.layer.layer.frame.origin.y = -10;
  
  layer_add_child(&window.layer, &triforce.layer.layer);
  
  rotbmp_pair_init_container(RESOURCE_ID_IMAGE_DOTS_WHITE, RESOURCE_ID_IMAGE_DOTS_BLACK, &dots);
  dots.layer.layer.frame.origin.x = 5;
  dots.layer.layer.frame.origin.y = -10;
  
  layer_add_child(&window.layer, &dots.layer.layer);
  	
  //Initializes the timeLayer  
  text_layer_init(&timeLayer, GRect(0, 168-42, 144 /* width */, 42 /* height */));
  text_layer_set_text_alignment(&timeLayer, GTextAlignmentCenter);
  text_layer_set_text_color(&timeLayer, GColorWhite);
  layer_set_frame(&timeLayer.layer, GRect(0, 100, 144, 168-100));
  text_layer_set_background_color(&timeLayer, GColorClear);
  text_layer_set_font(&timeLayer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_TRIFORCE_30)));

  layer_add_child(&window.layer, &timeLayer.layer);
  
  //Initializes the Date layer
  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(40, 140, 144-40, 168-140));
  text_layer_set_font(&text_date_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_TRIFORCE_20)));
  layer_add_child(&window.layer, &text_date_layer.layer);
  
  //Initializes the AM/PM layer
  text_layer_init(&AMPM, window.layer.frame);
  text_layer_set_text_color(&AMPM, GColorWhite);
  text_layer_set_background_color(&AMPM, GColorClear);
  layer_set_frame(&AMPM.layer, GRect(110, 107, 144-110, 168-107));
  layer_add_child(&window.layer, &AMPM.layer);

  update_time_display();

}
示例#9
0
文件: ppf.c 项目: saulricardo/PPF
void handle_init(AppContextRef ctx) {
  (void)ctx;

  window_init(&window, "PPF");
  window_stack_push(&window, true /* Animated */);
  
  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);
  
  //Initializes the timePastLayer  
  text_layer_init(&timePastLayer, GRect(0, 168-42, 60 /* width */, 45 /* height */));
  text_layer_set_text_alignment(&timePastLayer, GTextAlignmentCenter);
  text_layer_set_text_color(&timePastLayer, GColorBlack);
  layer_set_frame(&timePastLayer.layer, GRect(0, 18, 144, 168-18));
  text_layer_set_background_color(&timePastLayer, GColorClear);
  text_layer_set_font(&timePastLayer, fonts_get_system_font(FONT_KEY_GOTHAM_30_BLACK));
  layer_add_child(&window.layer, &timePastLayer.layer);
  
  //Initializes the timePresentLayer  
  text_layer_init(&timePresentLayer, GRect(0, 168-42, 60 /* width */, 45 /* height */));
  text_layer_set_text_alignment(&timePresentLayer, GTextAlignmentCenter);
  text_layer_set_text_color(&timePresentLayer, GColorBlack);
  layer_set_frame(&timePresentLayer.layer, GRect(0, 65, 144, 168-65));
  text_layer_set_background_color(&timePresentLayer, GColorClear);
  text_layer_set_font(&timePresentLayer, fonts_get_system_font(FONT_KEY_GOTHAM_30_BLACK));
  layer_add_child(&window.layer, &timePresentLayer.layer);
  
  //Initializes the timeFutureLayer  
  text_layer_init(&timeFutureLayer, GRect(0, 168-42, 60 /* width */, 45 /* height */));
  text_layer_set_text_alignment(&timeFutureLayer, GTextAlignmentCenter);
  text_layer_set_text_color(&timeFutureLayer, GColorBlack);
  layer_set_frame(&timeFutureLayer.layer, GRect(0, 110, 144, 168-110));
  text_layer_set_background_color(&timeFutureLayer, GColorClear);
  text_layer_set_font(&timeFutureLayer, fonts_get_system_font(FONT_KEY_GOTHAM_30_BLACK));
  layer_add_child(&window.layer, &timeFutureLayer.layer);
  
  update_time_display();
}
示例#10
0
文件: traino.c 项目: ronny/traino
static void on_tick(struct tm *tick_time, TimeUnits units_changed) {
  update_event_image();
  update_time_display();
}
void main_app_init()
{
    initialize_8ball_answers();
    set_time_mode();
    update_time_display();
}
示例#12
0
// Called once per second
static void handle_second_tick(AppContextRef ctx, PebbleTickEvent *t) {
  (void)ctx;
  (void)t;
  update_time_display();
}
示例#13
0
//Hippo Command, I put my pants on backwards!
void handle_init(void) {
    APP_LOG(APP_LOG_LEVEL_DEBUG, "INIT MEMORY: %u bytes used, %u bytes free", (unsigned) heap_bytes_used(), (unsigned) heap_bytes_free());
    
    // TODO: restore this once done profiling
#ifndef LOCK_SHIP
    srand(time(NULL));
    load_holomesh(rand() % c_craft_info_count);
#else
    load_holomesh(LOCK_SHIP);
#endif
    
    APP_LOG(APP_LOG_LEVEL_DEBUG, "UI MEMORY: %u bytes used, %u bytes free", (unsigned) heap_bytes_used(), (unsigned) heap_bytes_free());

    my_window = window_create();
    window_set_background_color(my_window, GColorBlack);

    GRect logoRect = GRect(0, 12, c_viewportWidth, c_viewportWidth);
    logoLayer = bitmap_layer_create(logoRect);
    bitmap_layer_set_bitmap(logoLayer, logoBitmap);
    layer_add_child(window_get_root_layer(my_window), bitmap_layer_get_layer(logoLayer));

    // Fonts    
    g_font_sw = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_14));
    g_font_sw_symbol = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_SYMBOL_14));
    g_font_time = fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD);
    g_font_info = fonts_get_system_font(FONT_KEY_GOTHIC_14);
    
    // Paint layer
    frameBufferLayer = bitmap_layer_create(GRect(0, 0, c_viewportWidth, c_viewportHeight));
    layer_add_child(window_get_root_layer(my_window), bitmap_layer_get_layer(frameBufferLayer));
    
    frameBufferBitmap = gbitmap_create_blank_with_palette(
        GSize(c_viewportWidth, c_viewportHeight),
        GBitmapFormat2BitPalette,
        c_palette,
        false);
    bitmap_layer_set_bitmap(frameBufferLayer, frameBufferBitmap);
    bitmap_layer_set_compositing_mode(frameBufferLayer, GCompOpSet);
    
    paint();

    GRect layerSize = GRect(0, 0, c_viewportWidth, c_viewportHeight);

    // Two small text layers
    textLayer = text_layer_create(layerSize);
    text_layer_set_background_color(textLayer, GColorClear);
    text_layer_set_text_color(textLayer, GColorYellow);
    text_layer_set_font(textLayer, g_font_sw);
    layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(textLayer));

    //Jet Force Push-up, you silly-billy.   
    textLayerSym = text_layer_create(layerSize);
    text_layer_set_background_color(textLayerSym, GColorClear);
    text_layer_set_text_color(textLayerSym, GColorYellow);
    text_layer_set_font(textLayerSym, g_font_sw_symbol);
    layer_set_hidden(text_layer_get_layer(textLayerSym), true);
    layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(textLayerSym));

    //Hippo Command, I also put my watch on backwards!

    // Info text layer
    infoTextLayer = text_layer_create(layerSize);
    text_layer_set_background_color(infoTextLayer, GColorClear);
    text_layer_set_text_color(infoTextLayer, GColorYellow);
    text_layer_set_font(infoTextLayer, g_font_info);
    layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(infoTextLayer));
    
    // Time
    GSize timeSize = graphics_text_layout_get_content_size(
        "00:00 AM",
        g_font_time,
        layerSize,
        0,
        GTextAlignmentLeft);
    GRect timeRect = { GPoint(DT_EDGE_PAD, c_viewportHeight - timeSize.h), GSize(c_viewportWidth, timeSize.h) };
    timeLayer = text_layer_create(timeRect);
    text_layer_set_background_color(timeLayer, GColorClear);
    text_layer_set_text_color(timeLayer, GColorYellow);
    text_layer_set_font(timeLayer, g_font_time);
    //text_layer_set_text(timeLayer, "23:45 AM");
    layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(timeLayer));
    
    // Date
    dateLayer = text_layer_create(layerSize);
    text_layer_set_background_color(dateLayer, GColorClear);
    text_layer_set_text_color(dateLayer, GColorYellow);
    text_layer_set_font(dateLayer, g_font_info);
    layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(dateLayer));
    


    time_t t = time(NULL);
    update_time_display(localtime(&t));
    update_date_display(localtime(&t));
    update_title_and_info();
    
    APP_LOG(APP_LOG_LEVEL_DEBUG, "FINAL MEMORY: %u bytes used, %u bytes free", (unsigned) heap_bytes_used(), (unsigned) heap_bytes_free());
    
    window_stack_push(my_window, true);
    tick_timer_service_subscribe(SECOND_UNIT | MINUTE_UNIT, tick_handler);
    
    g_timer = app_timer_register(c_refreshTimer, animation_timer_trigger, NULL);
    
    accel_data_service_subscribe(c_accelSampleCount, accel_data_handler);
    accel_service_set_sampling_rate(ACCEL_SAMPLING_25HZ);
}