#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <pthread.h>
#include <sys/time.h>
#include <rfb/rfb.h>
#include "display.h"
#include "font.h"
#include "timeutil.h"
Data Structures | |
struct | display_message |
Display message data. More... | |
Defines | |
#define | DISPLAY_DEV_FB "/dev/fb0" |
#define | MESSAGE_FONT medium_font |
#define | MESSAGE_BORDER_PX 1 |
#define | MESSAGE_TEXT_EDGE_PX 10 |
#define | MESSAGE_LINE_SPACING_PX 2 |
Functions | |
static int | display_read (unsigned char *buffer, struct fb_var_screeninfo *info) |
static int | display_fill_rect (int x, int y, int width, int height, int color, unsigned char *display_buffer) |
static int | display_blit_char (int x, int y, char c, int color, struct font *font, unsigned char *display_buffer) |
static int | display_blit_text (int x, int y, char *text, int color, struct font *font, unsigned char *display_buffer) |
static int | display_draw_message (struct display_message *msg, unsigned char *display_buffer) |
static void | display_message_cleanup (struct display_message *msg) |
static char * | display_shorten_message_line (char *line) |
int | display_show_message (char *message, int duration) |
struct display_data * | display_get_data () |
static void | display_update_regions_cleanup (struct display_data *data) |
int | display_update (struct display_data *data) |
void | display_cleanup (struct display_data *data) |
Variables | |
static struct display_message * | msg_pending = NULL |
static pthread_mutex_t | msg_mutex = PTHREAD_MUTEX_INITIALIZER |
#define DISPLAY_DEV_FB "/dev/fb0" |
Display device (framebuffer).
Display data is represented with 8 pixels per byte, 50 bytes per row and 160 rows.
#define MESSAGE_FONT medium_font |
#define MESSAGE_BORDER_PX 1 |
Line thickness of message border (pixels).
#define MESSAGE_TEXT_EDGE_PX 10 |
Distance between message border and text (pixels).
#define MESSAGE_LINE_SPACING_PX 2 |
Distance between message lines (pixels).
static int display_read | ( | unsigned char * | buffer, | |
struct fb_var_screeninfo * | info | |||
) | [static] |
Reads the display content into a given buffer.
The content is stored with 8 pixels per byte.
buffer | buffer to store the display content | |
info | framebuffer device information |
static int display_fill_rect | ( | int | x, | |
int | y, | |||
int | width, | |||
int | height, | |||
int | color, | |||
unsigned char * | display_buffer | |||
) | [static] |
Fills a rectangle in a display buffer with the given color value.
x | upper left x-coordinate of rectangle | |
y | upper left y-coordinate of rectangle | |
width | width of rectangle | |
height | height of rectangle | |
color | color value; 0 = dark, 1 = light | |
display_buffer | display buffer |
static int display_blit_char | ( | int | x, | |
int | y, | |||
char | c, | |||
int | color, | |||
struct font * | font, | |||
unsigned char * | display_buffer | |||
) | [static] |
Blits a character with a given font and color into a display buffer.
x | upper left x-coordinate of character | |
y | upper left y-coordinate of character | |
c | the character | |
color | color value; 0 = dark, 1 = light | |
font | the font to use | |
display_buffer | display buffer |
static int display_blit_text | ( | int | x, | |
int | y, | |||
char * | text, | |||
int | color, | |||
struct font * | font, | |||
unsigned char * | display_buffer | |||
) | [static] |
static int display_draw_message | ( | struct display_message * | msg, | |
unsigned char * | display_buffer | |||
) | [static] |
Draws a message with the given text into a display buffer.
msg | display message | |
display_buffer | display buffer |
static void display_message_cleanup | ( | struct display_message * | msg | ) | [static] |
Message data cleanup.
Frees allocated memory.
msg | message data |
static char* display_shorten_message_line | ( | char * | line | ) | [static] |
Cuts a message line, if it doesn't fits on the display.
line | the message line |
int display_show_message | ( | char * | message, | |
int | duration | |||
) |
Prepares a message to be shown on the virtual display.
message | the message | |
duration | display duration of message in milliseconds |
struct display_data* display_get_data | ( | ) | [read] |
Initialize display data structure.
static void display_update_regions_cleanup | ( | struct display_data * | data | ) | [static] |
Frees the memory associated with display update regions.
data | display data |
int display_update | ( | struct display_data * | data | ) |
Reads the display content and identifies the update regions.
data | display data |
void display_cleanup | ( | struct display_data * | data | ) |
Display data cleanup.
Frees allocated memory.
data | display data |
struct display_message* msg_pending = NULL [static] |
Currently displayed message.
pthread_mutex_t msg_mutex = PTHREAD_MUTEX_INITIALIZER [static] |
Mutex variable to synchronize access to msg_pending.