void main_app_handle_button_up() { if (!button_held) { pulse_cancel_timer(&button_timer_id); if (current_screen == SCREEN_CLOCK) { cancel_sleep(); reset_game(); pulse_blank_canvas(); current_screen = SCREEN_GAME_OVER; printf("Click to start.\n\n\nClick while \nyou're in the \nair to do a \ndouble jump!"); prepare_to_sleep(); } else if (current_screen == SCREEN_GAME_OVER) { time_now_ms = pulse_get_millis(); if (time_now_ms - time_last_box_drawn_ms >= 500) { cancel_sleep(); pulse_blank_canvas(); current_screen = SCREEN_GAMEPLAY; } } else if (current_screen == SCREEN_GAMEPLAY) press = false; } else button_held = false; }
void main_app_handle_button_up() { if (!button_held) { pulse_cancel_timer(&button_timer_id); if (current_screen == SCREEN_CLOCK) { cancel_sleep(); pulse_blank_canvas(); reset_game(); current_screen = SCREEN_GAME_OVER; printf("\n\n\n\n\n Click to start"); prepare_to_sleep(); } else if (current_screen == SCREEN_GAME_OVER) { time_now_ms = pulse_get_millis(); // Check if it's been at least 500 ms since the game ended to prevent accidental clicks if (time_now_ms - time_last_box_drawn_ms > 500) { cancel_sleep(); pulse_blank_canvas(); current_screen = SCREEN_GAMEPLAY; } } else if (current_screen == SCREEN_GAMEPLAY) press = false; } else button_held = false; }
// Gets the notification based on the id and prints the messages to the screen void handle_new_pulse_protocol_notification(PulseNotificationId id) { pulse_blank_canvas(); struct PulseNotification *notification = pulse_get_notification(id); printf("Sender:\n%s\n\n", notification->sender); printf("Body:\n%s\n", notification->body); }
void display_message(string message) { uint32_t interval = pulse_get_millis(); pulse_blank_canvas(); printf("%s\n", message); printf("Main timer:\n%d\n", interval); }
// Gets the notification based on the id and prints the messages to the screen void handle_pulse_protocol_notification(PulseNotificationId id) { current_screen = SCREEN_NOTIFICATION_READ; cancel_sleep(); pulse_blank_canvas(); struct PulseNotification *notification = pulse_get_notification(id); char body_text[150]; // Set font and color text_widget.font.resource_id = FONT_GEORGIA_10; text_widget.font.color = COLOR_WHITE24; // Render and draw header pulse_draw_image(IMAGE_FULLSCREEN_EMAIL, 0, 0); text_box.top = 5; text_box.right = SCREEN_WIDTH; text_box.left = 28; text_box.bottom = 20; enum PWTextStyle style = PWTS_TRUNCATE; pulse_init_dynamic_text_widget(&text_widget, text_buffer, FONT_GEORGIA_10, COLOR_WHITE24, style); sprintf(text_buffer, "%s", notification->sender); pulse_render_text(&text_box, &text_widget); // Render and draw body text_box.top = 28; text_box.right = SCREEN_WIDTH; text_box.left = 0; text_box.bottom = SCREEN_HEIGHT; style = PWTS_WRAP_AT_SPACE; pulse_init_dynamic_text_widget(&text_widget, body_text, FONT_GEORGIA_10, COLOR_WHITE24, style); sprintf(body_text, "%s", notification->body); pulse_render_text(&text_box, &text_widget); }
void main_app_handle_button_down() { pulse_blank_canvas(); if (state == 0) get_ready(); else if (state == 1) { pulse_cancel_timer(&hold_timer_value); state = 0; printf("XXX Too soon XXX\n\n"); printf("click to try \nagain"); printf("\n\n\n\n\n\n\n\n\n\n\nBest: %dms",best_time); } else if (state == 2) { state = 0; int reaction_time = (int)pulse_get_millis() - start_time; printf("You reacted in \n\n%d millisecs\n\n",reaction_time); printf("Click to try \nagain"); if (reaction_time < best_time) best_time = reaction_time; printf("\n\n\n\n\n\n\n\n\n\nBest: %dms",best_time); } }
void update_time_display() { pulse_blank_canvas(); pulse_get_time_date(¤t_time); printf("The time is\n%d:%0.2d:%0.2d\n", current_time.tm_hour, current_time.tm_min, current_time.tm_sec); }
static void wakeup(void *arg) { pulse_oled_set_brightness(100); pulse_blank_canvas(); not_charging = pulse_get_millis(); shutdown_scheduled = 0; //srand(pulse_get_millis()); }
void return_to_clock_screen() { pulse_blank_canvas(); current_screen = SCREEN_CLOCK; render_time(clock_color); render_date(clock_color); prepare_to_sleep(); }
void return_to_clock_screen() { pulse_blank_canvas(); current_screen = SCREEN_CLOCK; // Draw clock render_clock(clock_color); // Draw bluetooth status icon update_bluetooth_icon(bt_connected); prepare_to_sleep(); }
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); }
void game_over() { pulse_vibe_on(); pulse_mdelay(60); pulse_vibe_off(); //int vib_timer = pulse_register_timer(75, &pulse_vibe_off, 0); current_screen = SCREEN_GAME_OVER; pulse_blank_canvas(); if (score > highscore) highscore = score; printf ("GAME OVER\n\nScore: %d\n\nHighscore: %d\n\nClick to restart",score,highscore); reset_game(); prepare_to_sleep(); }
// Main loop. This function is called frequently. // No blocking calls are allowed in this function or else the watch will reset. // The inPulse watchdog timer will kick in after 5 seconds if a blocking // call is made. void main_app_loop() { pulse_get_time_date(¤t_time); if(current_screen == SCREEN_CLOCK) { // Update once a minute if(current_min != current_time.tm_min) { current_min = current_time.tm_min; pulse_blank_canvas(); // Draw clock render_clock(clock_color); update_bluetooth_icon(bt_connected); } } }
void mode_btlostphone_draw_watch_face() { pulse_blank_canvas(); // printf("Time %02i:%02i\n\n", multiTimeNow.tm_hour, multiTimeNow.tm_min); printf("=BT LOST PHONE=\n\n"); if (multiBluetoothIsConnected) { printf("BT connected\n"); } else { printf("BT not connected"); } if (mode_btlostphone_alarm_ignore) { printf("Alarm: disabled"); } else { // !alarm_ignore && !alarm_triggered printf("Alarm: armed"); } }
// It's time to sleep! void mode_displaysleep_power_down() { multi_debug("mode_displaysleep_power_down - time to sleep\n"); // Immediately stop the watch doing anything else multi_external_sleep_init(); pulse_cancel_timer(&modeDisplaysleepPowerDownTimerID); // pulse // Clear the display pulse_blank_canvas(); pulse_oled_set_brightness(0); // dark // Clear our positions for (int i=0; i<MODE_DISPLAYSLEEP_DIGIT_POS_SIZE; i++) { modeDisplaysleepCurrentlyDisplayed[i] = MODE_DISPLAYSLEEP_NO_DIGIT; } // Display the colon mode_displaysleep_draw_digit(2, 10); // Digit ??*?? <-- colon // Now start the proper loop mode_displaysleep_tick_tock(); }
void main_app_handle_button_down() { // Create an array to hold the PulseNotificationIds PulseNotificationId latest_notifications[MAX_NOTIFICATIONS_PER_LIST]; // Call a function to populate the array pulse_get_notification_list_by_type(PNT_ALL, latest_notifications); // Clear the screen pulse_blank_canvas(); // Print the latest notification ids to the screen printf("Latest\nNotification IDs\n\n"); for (int i = 0; i < MAX_NOTIFICATIONS_PER_LIST; i++) { // If less than 8 notifications have been received, the array will // contains NULLs if (latest_notifications[i] == NULL) { break; } printf("0x%x\n", latest_notifications[i]); } }
void display_prequote_message() { pulse_blank_canvas(); printf("Think of a yes-\nor-no question.\n"); }
void display_answer() { pulse_blank_canvas(); printf("The 8-ball says:\n\"%s\"\n", random_magic_8ball_quote()); }
void main_app_loop(void) { uint8_t umpl_got; const uint64_t millis = pulse_get_millis(); // If the not-charging state has not been toggled in the last // 30 seconds, schedule a power down soon. if (not_charging && millis - not_charging > 60000) { if (!shutdown_scheduled) pulse_update_power_down_timer(1); shutdown_scheduled = 1; return; } /* The umpl_input_handler is nonblocking. * It will read a packet off the debug serial * port, and copy the rotation matrix payload * to the provided buffer. */ umpl_got = umpl_input_handler(default_m); if (umpl_got) dbg_putc((char)0); // (for debugging) camera_setup_rmat(&camera, 4000, rmats[selected_mat]); #if 1 pixel_t temp_pixels[ARRAY_COUNT(pixels)]; wireframe_draw( &camera, ARRAY_COUNT(vertices), vertices, ARRAY_COUNT(edges), edges, pixels, temp_pixels ); #else for (int i = 0 ; i < ARRAY_COUNT(vertices) ; i++) { const vertex_t * const v = &vertices[i]; pixel_t * const p = &pixels[i]; draw_pixel(COLOR_BLACK24, p->x, p->y); camera_project(&camera, v, p); draw_pixel(COLOR_GREEN, p->x, p->y); } #endif // Update the clock once per minute struct pulse_time_tm now; pulse_get_time_date(&now); if (last_sec == now.tm_sec) return; last_sec = now.tm_sec; if (last_min != now.tm_min) pulse_blank_canvas(); last_min = now.tm_min; char buf[16]; sprintf(buf, "%02d:%02d", now.tm_hour, now.tm_min ); draw_monostring(8, VSCREEN_HEIGHT - FONT_HEIGHT - 1, COLOR_GREEN, buf); }
// Shows the most recent notifications void latest_notifications_screen(uint8_t index) { // Create an array to hold the PulseNotificationIds PulseNotificationId latest_notifications[MAX_NOTIFICATIONS_PER_LIST]; // Call a function to populate the array pulse_get_notification_list_by_type(PNT_ALL, latest_notifications); // Get size of the list for(int i = 0; i < MAX_NOTIFICATIONS_PER_LIST; i++) { if (latest_notifications[i] == NULL) { break; } notification_list_size = i + 1; } // Draw screen if(notification_list_size != 0) { // Screen initialized for first time if(notification_list_first_draw) { pulse_blank_canvas(); notification_list_first_draw = false; for(int i = 0; i < notification_list_size; i++) { struct PulseNotification * list_item = pulse_get_notification(latest_notifications[i]); // Draw item icon if(i == index) { pulse_draw_image(IMAGE_MSGLIST_EMAIL_GLOW, 0, i * 16); notification_id = latest_notifications[i]; } else { pulse_draw_image(IMAGE_MSGLIST_EMAIL_NOGLOW, 0, i * 16); } // Print item sender draw_notification_list_item_header(i, list_item->sender); } } else { // Only redraw current selected and previously selected notifications if(notification_list_size > 1) { struct PulseNotification * list_item; uint8_t notification_previously_selected = notification_selected - 1; if(notification_previously_selected == 0xFF) { notification_previously_selected = notification_list_size - 1; } // Highlight and redraw new selected item list_item = pulse_get_notification(latest_notifications[notification_selected]); pulse_draw_image(IMAGE_MSGLIST_EMAIL_GLOW, 0, notification_selected * 16); draw_notification_list_item_header(notification_selected, list_item->sender); notification_id = latest_notifications[notification_selected]; // Unhighlight and redraw previously selected item list_item = pulse_get_notification(latest_notifications[notification_previously_selected]); pulse_draw_image(IMAGE_MSGLIST_EMAIL_NOGLOW, 0, notification_previously_selected * 16); draw_notification_list_item_header(notification_previously_selected, list_item->sender); } } } else { pulse_blank_canvas(); printf("No notifications"); } }