Пример #1
0
// 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);
}
Пример #2
0
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();
}
Пример #3
0
// Render clock text and draw to screen
void render_date(color24_t clock_color)
{
    // Initialize the text box parameters
    text_box.top = SCREEN_HEIGHT/2+4;
    text_box.right = SCREEN_WIDTH;
    text_box.left = 0;
    text_box.bottom = SCREEN_HEIGHT;

    // Configure the text style
    // We want it to be centered both vertically and horizontally in the text box
    // and to truncate any text if it won't fit in the text box
    enum PWTextStyle style = (PWTS_TRUNCATE | PWTS_CENTER );

    // Initialize the text widget
    pulse_init_dynamic_text_widget(&text_widget, text_buffer, FONT_GOOD_TIMES_10, date_color, style);

    // Print the time from the RTC (real time clock) in to the text buffer
    print_date_into_text_buffer();

    // Set font resource for clock
    text_widget.font.resource_id =  FONT_GOOD_TIMES_10;

    // Set the font color to be psuedo-random
    text_widget.font.color = date_color;

    // Render the text in the text box area
    pulse_render_text(&text_box, &text_widget);
}
Пример #4
0
// Prints the sender of a notification list item
void draw_notification_list_item_header(uint8_t index, char item_header[])
{
    text_box.top = index * 16 + 3;
    text_box.right = SCREEN_WIDTH;
    text_box.left = 18;
    text_box.bottom = (index + 1) * 16;
    enum PWTextStyle style = PWTS_TRUNCATE;
    pulse_init_dynamic_text_widget(&text_widget, text_buffer, FONT_GEORGIA_10, COLOR_WHITE24, style);
    sprintf(text_buffer, "%s", item_header);
    pulse_render_text(&text_box, &text_widget);
}
Пример #5
0
// Render clock text and draw to screen
void render_time(color24_t clock_color)
{
    // Initialize the text box parameters
    text_box.top = 0;
    text_box.right = SCREEN_WIDTH;
    text_box.left = 0;
    text_box.bottom = SCREEN_HEIGHT-26;

    // Configure the text style
    enum PWTextStyle style = (PWTS_TRUNCATE | PWTS_CENTER | PWTS_VERTICAL_CENTER);
    // Initialize the text widget
    pulse_init_dynamic_text_widget(&text_widget, text_buffer, FONT_GOOD_TIMES_26, clock_color, style);
    // Print the time from the RTC (real time clock) in to the text buffer
    print_time_into_text_buffer();

    // Render the text in the text box area
    pulse_render_text(&text_box, &text_widget);
}
Пример #6
0
void
draw_monostring(
	uint32_t x,
	uint32_t y,
	color24_t color,
	const char * s
)
{
	pulse_init_dynamic_text_widget(
		&font,
		buf,
		FONT,
		color,
		PWTS_TRUNCATE
	);

	uint32_t orig_x = x >> VSCREEN_SHIFT;

	struct PWTextBox box = {
		.left		= orig_x,
		.top		= y >> VSCREEN_SHIFT,
		.right		= SCREEN_WIDTH - 1,
		.bottom		= SCREEN_HEIGHT - 1,
	};

	buf[1] = '\0';

	while ((buf[0] = *s++))
	{
		if (buf[0] == '\n')
		{
			box.left = orig_x;
			box.top += FONT_HEIGHT;
		} else {
			pulse_render_text(&box, &font);
			box.left += FONT_WIDTH;
		}
	}
}