// 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_init() { // Draw the radar image to the screen pulse_dimensions_t d = pulse_get_image_info(IMAGE_RADAR); pulse_draw_image(IMAGE_RADAR, (SCREEN_WIDTH - d.width) / 2, 32); // Put a default into the message text buffer sprintf(message_text_buffer, "Example.com\n??? ms"); // Set up the text box positions clock_text_box.top = 0; clock_text_box.bottom = pulse_get_font_height(FONT_CLOCKOPIA_30); clock_text_box.left = 0; clock_text_box.right = SCREEN_WIDTH - 5; message_text_box.top = 105; message_text_box.bottom = SCREEN_HEIGHT - 1; message_text_box.left = 0; message_text_box.right = SCREEN_WIDTH - 1; // Initialize the text widgets pulse_init_dynamic_text_widget(&clock_text_widget, clock_text_buffer, FONT_CLOCKOPIA_30, COLOR_WHITE24, clock_text_style); pulse_init_dynamic_text_widget(&message_text_widget, message_text_buffer, FONT_EASTA_10, COLOR_WHITE24, message_text_style); // Register a callback so that we're notified of new pulse protocol notifications // (over bluetooth) pulse_register_callback(ACTION_NEW_PULSE_PROTOCOL_NOTIFICATION, &handle_message); // Write the text widgets to the screen update_time(); update_server_ping_message(); }
void mode_displaysleep_draw_digit(int iPosition, int iDigit) { multi_debug("digit %i %i\n", iPosition, iDigit); if(modeDisplaysleepCurrentlyDisplayed[iPosition] != iDigit) { modeDisplaysleepCurrentlyDisplayed[iPosition] = iDigit; pulse_draw_image(modeDisplaySleepWatchDigits[iDigit], SCREEN_WIDTH - 12, 50 + (7 * iPosition)); } }
// Redraw bluetooth icon void update_bluetooth_icon(bool connected) { if(connected) { pulse_set_draw_window(0, 0, 19, 19); for(int i = 0; i < 400; i++) { pulse_draw_point24(COLOR_BLACK24); } } else { pulse_draw_image(IMAGE_BLUETOOTH_NO, 0, 0); } }
void draw_ball(int x, int y, color24_t color) { pulse_draw_image(IMAGE_SPRITE, x, y-15); }
// 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"); } }