コード例 #1
0
// 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);
}
コード例 #2
0
// A not very beautiful example of how notifications can be handled
// Probably no need to pause in this function as the function
// multi_external_notification_hander_complete() does that to allow the
// vibrate to occur properly
void mode_simple_notifications_new_notification(PulseNotificationId id) {
  struct PulseNotification *notification = pulse_get_notification(id);
  printf("Type: ", notification->type);
  switch(notification->type) {
    case PNT_MAIL:
      printf("Mail");
      break;
    case PNT_SMS:
      printf("SMS");
      break;
    case PNT_CALENDAR:
      printf("Calendar");
      break;
    case PNT_PHONE:
      printf("Phone");
      break;
    default: // rest are not well described!
      printf("%i - unsure", notification->type);
      break;
  }
    
  printf("\n\n\nMessage:\n\n%s\n\n", notification->sender);
  if (notification->body) { 
    printf("Body:\n%s\n", notification->body);
  }

  // Pass back control to the framework; should be the last thing our
  // handler does. 
  multi_external_notification_handler_complete();
}
コード例 #3
0
ファイル: pulse_app.c プロジェクト: NotAj/inPulse-SmartWatch
// 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);
}
コード例 #4
0
ファイル: pulse_app.c プロジェクト: NotAj/inPulse-SmartWatch
// This function was registered to receive pulse protocol notifications
// Write the message to the message text buffer
void handle_message(PulseNotificationId id)
{
    struct PulseNotification * p = pulse_get_notification(id);
    sprintf(message_text_buffer, "%s\n%s", p->body, p->sender);
    dbg_printf("%s\n", message_text_buffer);
    update_server_ping_message();
}
コード例 #5
0
ファイル: pulse_app.c プロジェクト: NotAj/inPulse-SmartWatch
// 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");
    }
}