void main_app_init() { printf("Starting the\ntimer."); pulse_register_timer(3000, &display_message, "3 seconds."); pulse_register_timer(5000, &display_message, "5 seconds."); pulse_register_timer(7000, &display_message, "7 seconds."); }
void main_app_handle_button_down() { if(current_screen == SCREEN_CLOCK) { current_screen = SCREEN_NOTIFICATION_LIST; cancel_sleep(); notification_list_first_draw = true; notification_selected = 0xFF; } else if(current_screen == SCREEN_NOTIFICATION_LIST) { if(notification_list_size == 0) { return_to_clock_screen(); } else { // Set timer for button hold button_timer_id = pulse_register_timer(BUTTON_HOLD_TIME, &handle_pulse_protocol_notification, notification_id); } } else { return_to_clock_screen(); } }
void main_app_handle_button_down() { if (current_screen == SCREEN_GAME_OVER)// || current_screen == SCREEN_CLOCK) button_timer_id = pulse_register_timer(BUTTON_HOLD_TIME, &long_press, 0); else if (current_screen == SCREEN_GAMEPLAY) press = true; }
void main_app_handle_button_down() { //if (current_screen == SCREEN_CLOCK || current_screen == SCREEN_GAME_OVER) if ( current_screen == SCREEN_GAME_OVER) button_timer_id = pulse_register_timer(BUTTON_HOLD_TIME, &long_press, 0); else if ((current_screen == SCREEN_GAMEPLAY) && (jumps_available > 0)) { press = true; jump_ticks = 15; jumps_available--; } }
void get_ready() { pulse_blank_canvas(); state = 1; printf("Wait for it...\n\n"); int wait_time = 1000 + rand()%5000; hold_timer_value = pulse_register_timer(wait_time, &go, wait_time); }
// This is called regularly to stop the watch "going to sleep"; all we // want to do here is cancel our existing timer and create a new one void mode_displaysleep_update_power_down(int iPowerDownMS) { multi_debug("mode_displaysleep_update_power_down %i\n", iPowerDownMS); // Ensure our own personal "active" loop is cancelled pulse_cancel_timer(&modeDisplaysleepingTimerID); assert(modeDisplaysleepingTimerID == -1); pulse_cancel_timer(&modeDisplaysleepPowerDownTimerID); // pulse assert(modeDisplaysleepPowerDownTimerID == -1); modeDisplaysleepPowerDownTimerID = pulse_register_timer(iPowerDownMS, &mode_displaysleep_power_down, 0); // pulse assert(modeDisplaysleepPowerDownTimerID != -1); }
// Print the time to the screen to and set a timer to call // this function on the minute mark void update_time() { print_time_into_text_buffer(); // Draw a black box over the text area to clear it // There are other more effecient solutions pulse_set_draw_window(0,0, SCREEN_WIDTH, 30); for (int i = 0; i < 30 * SCREEN_WIDTH; i++) { pulse_draw_point24(COLOR_BLACK24); } pulse_render_text(&clock_text_box, &clock_text_widget); // Register a timer to update the time on the minute mark pulse_register_timer(60000 - current_time.tm_sec * 1000, &update_time, 0); }
void mode_displaysleep_tick_tock() { multi_debug("mode_displaysleep_tick_tock\n"); pulse_cancel_timer(&modeDisplaysleepingTimerID); assert(modeDisplaysleepingTimerID == -1); modeDisplaysleepingTimerID = pulse_register_timer(10000, // slow &mode_displaysleep_tick_tock, 0); // pulse assert(modeDisplaysleepingTimerID != -1); mode_displaysleep_draw_digit(0, multiTimeNow.tm_hour / 10); // Digit *?:?? mode_displaysleep_draw_digit(1, multiTimeNow.tm_hour % 10); // Digit ?*:?? // position 2 has the colon! mode_displaysleep_draw_digit(3, multiTimeNow.tm_min / 10); // Digit ??:*? mode_displaysleep_draw_digit(4, multiTimeNow.tm_min % 10); // Digit ??:?* }
// Will put processor to sleep in predetermined number of ms void prepare_to_sleep() { pulse_cancel_timer(&sleep_timer_id); sleep_timer_id = pulse_register_timer(TIME_BEFORE_SLEEP, &pulse_update_power_down_timer, 0); }