GPANEL(3)

NAME
gpanel_open, gpanel_close, gpanel_clear, gpanel_pixel, gpanel_line, gpanel_rect, gpanel_fill, gpanel_circle, gpanel_image, gpanel_char, gpanel_text, panel_text_width - graphics panel routines

SYNOPSIS

#include <sys/gpanel.h>

int gpanel_open(const char *devname);

void gpanel_close(void);

void gpanel_clear(int color, int *xsize, int *ysize);

void gpanel_pixel(int color, int x, int y);

void gpanel_line(int color, int x0, int y0, int x1, int y1);

void gpanel_rect(int color, int x0, int y0, int x1, int y1);

void gpanel_fill(int color, int x0, int y0, int x1, int y1);

void gpanel_circle(int color, int x, int y, int radius);

void gpanel_image(int x, int y, int width, int height,
                  const unsigned short *data);

void gpanel_char(const struct gpanel_font_t *font, int color,
                 int background, int x, int y, int sym);

void gpanel_text(const struct gpanel_font_t *font, int color,
                 int background, int x, int y, const char *text);

int gpanel_text_width(const struct gpanel_font_t *font,
                      const char *text, int nchars);

DESCRIPTION
This library provides a set of routines for access to a graphics panel like TFT LCD or OLED displays. HX8357 display on a Picadillo-35T board is an example of such display. Use cc option -lgpanel to link the gpanel library.

gpanel_open - This routine opens a connection to the display driver. The argument to this function is the name of the device, like "/dev/tft0". Negative value is returned in case of error.

gpanel_close - Close a connection to the device.

gpanel_clear - This routine is used to clear the whole screen to a given color, optionally switch the display resolution and orientation, and get the display size in pixels. On input, parameters xsize and ysize should contain the desired dimensions of the display, or zeros to use the default screen size and orientation. On output, xsize and ysize are set to the current display size.

gpanel_pixel - Draw a single pixel of a specified color.

gpanel_line - Draw a line.

gpanel_rect - Draw a rectangular frame (not filled).

gpanel_fill - Draw a rectangle filled with specified color.

gpanel_circle - Draw a circle with a given center and radius.

gpanel_image - Draw an arbitrary image: fill a rectangular area with pixel values from a user-supplied data.

gpanel_char - Draw a single character with a specified Unicode encoding.

gpanel_text - Draw a text string in UTF-8 encoding.

gpanel_text_width - Compute a width in pixels for a text string in UTF-8 encoding.

EXAMPLE
#include <stdio.h>
#include <sys/gpanel.h> int main()
{
    int xsize, ysize;
    if (gpanel_open("/dev/tft0") < 0) {
        printf("Cannot open display);
        exit(-1);
    }
    /* Get screen size */
    gpanel_clear(0, &xsize, &ysize);
    /* Draw a white rectangle of max size */
    gpanel_rect(0xffff, 0, 0, xsize-1, ysize-1);
    return 0;
}

FONTS
struct gpanel_font_t {
    const char * name; /* font name */
    int maxwidth; /* max width in pixels */
    unsigned int height; /* height in pixels */
    int ascent; /* ascent (baseline) height */
    int firstchar; /* first character in bitmap */
    int size; /* font size in characters */
    const unsigned short *bits; /* 16-bit right-padded bitmap data */
    const unsigned short *offset; /* offsets into bitmap data */
    const unsigned char *width; /* character widths or 0 if fixed */
    int defaultchar; /* default char (not glyph index) */
    long bits_size; /* number of words of bits */
};

Fonts are specified via a data structure struct gpanel_font_t , which defines character sizez and glyph images. Font data for some commonly used fonts are available in /share/examples/gpanel/fonts directory. A utility convbdf can be used to convert XWindows BDF fonts to a struct gpanel_font_t data. When combined with otf2bdf utility, this allows to generate font data for any TrueType font, like Verdana or Lucida Sans Unicode.

BUGS
Data and font pointers in gpanel_image and gpanel_text routines are not checked for validity, and can cause unexpected errors when not correct.

FILES
/share/examples/gpanel Examples of using the libgpanel library.

/dev/tft0 Device name for hx8357 TFT display driver.