Example #1
0
void irq_dispatch(uint32_t status_reg) {
    // Currently we only handle timer interrupts, ignore all others:
    if (irq_controller()->irq_basic_pending && IRQ_BASIC_ARM_TIMER == 0) {
        uart_puts("skipping IRQ...\n");
        return;
    }
    // OK, now we know we're in timer interrupt, proceed:
    handle_time_tick(status_reg);
}
Example #2
0
static void do_init(void) {
	window = window_create();
	window_stack_push(window, true);
	window_set_background_color(window, GColorBlack);
	window_layer = window_get_root_layer(window);
	
	GRect line_frame = GRect(8, 120, 139, 2);
	line_layer = layer_create(line_frame);
	layer_set_update_proc(line_layer, draw_line);
	layer_add_child(window_layer, line_layer);
	
	time_layer = text_layer_create(GRect(5, 66, 118, 70));
	text_layer_set_text_color(time_layer, GColorWhite);
	text_layer_set_background_color(time_layer, GColorClear);
	text_layer_set_font(time_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_font_droid_44)));
	text_layer_set_text_alignment(time_layer,GTextAlignmentRight);
	layer_add_child(window_layer, text_layer_get_layer(time_layer));
	
	date_layer = text_layer_create(GRect(65, 125, 79, 25));
	text_layer_set_text_color(date_layer, GColorWhite);
	text_layer_set_background_color(date_layer, GColorClear);
	text_layer_set_font(date_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_font_droid_18)));
	layer_add_child(window_layer, text_layer_get_layer(date_layer));
	
	wday_layer = text_layer_create(GRect(60, 143, 50, 25));
	text_layer_set_text_color(wday_layer, GColorWhite);
	text_layer_set_background_color(wday_layer, GColorClear);
	text_layer_set_font(wday_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_font_droid_18)));
	layer_add_child(window_layer, text_layer_get_layer(wday_layer));
	
	//+時間のNULL回避?(わかってない→調べる
	
	time_t now = time(NULL);
	struct tm *current_time = localtime(&now);
	handle_time_tick(current_time, SECOND_UNIT);
	
	tick_timer_service_subscribe(SECOND_UNIT, &handle_time_tick);

	batt_layer = bitmap_layer_create(GRect(123, 151, 14, 10));
	layer_add_child(window_layer, bitmap_layer_get_layer(batt_layer)); //親レイヤに載せる 
	
	watchicon_layer = bitmap_layer_create(GRect(131, 151, 6, 10));
	layer_add_child(window_layer, bitmap_layer_get_layer(watchicon_layer));
	bitmap_layer_set_background_color(watchicon_layer, GColorClear);
	
	bt_layer = bitmap_layer_create(GRect(110, 151, 11, 10));
	layer_add_child(window_layer, bitmap_layer_get_layer(bt_layer));
	
	handle_battery(battery_state_service_peek());
	battery_state_service_subscribe(&handle_battery);

	handle_bluetooth(bluetooth_connection_service_peek());
	bluetooth_connection_service_subscribe(&handle_bluetooth);
}