display.c File Reference

Hifidelio display access. More...

#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"

Include dependency graph for display.c:


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_datadisplay_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_messagemsg_pending = NULL
static pthread_mutex_t msg_mutex = PTHREAD_MUTEX_INITIALIZER

Detailed Description

Reads the display content into a display buffer, identifies update regions and allows its manipulation with drawing routines.

Define Documentation

#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

Message font corresponding to include file font.h.

#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).


Function Documentation

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.

Parameters:
buffer buffer to store the display content
info framebuffer device information
Returns:
0 on success or -1 if an error occured

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.

Parameters:
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
Returns:
0 on success or -1 if an error occured

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.

Parameters:
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
Returns:
0 on success or -1 if an error occured

static int display_blit_text ( int  x,
int  y,
char *  text,
int  color,
struct font font,
unsigned char *  display_buffer 
) [static]

Blits text with a given font and color into a display buffer.

Parameters:
x upper left x-coordinate of text
y upper left y-coordinate of text
text text string
color color value; 0 = dark, 1 = light
font the font to use
display_buffer display buffer
Returns:
0 on success or -1 if an error occured

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.

Parameters:
msg display message
display_buffer display buffer
Returns:
0 on success or -1 if an error occured

static void display_message_cleanup ( struct display_message msg  )  [static]

Message data cleanup.

Frees allocated memory.

Parameters:
msg message data

static char* display_shorten_message_line ( char *  line  )  [static]

Cuts a message line, if it doesn't fits on the display.

Parameters:
line the message line
Returns:
formatted message line

int display_show_message ( char *  message,
int  duration 
)

Prepares a message to be shown on the virtual display.

Parameters:
message the message
duration display duration of message in milliseconds
Returns:
0 on success or -1 if an error occured

struct display_data* display_get_data (  )  [read]

Initialize display data structure.

Returns:
a display data structure or NULL if an error occured

static void display_update_regions_cleanup ( struct display_data data  )  [static]

Frees the memory associated with display update regions.

Parameters:
data display data

int display_update ( struct display_data data  ) 

Reads the display content and identifies the update regions.

Parameters:
data display data
Returns:
0 on success or -1 if an error occured

void display_cleanup ( struct display_data data  ) 

Display data cleanup.

Frees allocated memory.

Parameters:
data display data


Variable Documentation

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.


Generated on Mon Mar 29 01:39:27 2010 for Veronica by  doxygen 1.5.8