libg19 Reference

libg19 is the library that is used to interface with the g19.  It will control the back-lighting color, M-Key leds, M-Key presses, G-Key presses, L-Key presses and sending data to the LCD.







The major version of libg19. (x.0.0)


The minor version of libg19. (0.x.0)


The micro version of libg19. (0.0.x)


The verion of libg19 as a string.


The size of the BMP data sent to the LCD with header data.


The size of the BMP data with with out hdata that is sent to the LCD.


enum G19UpdateFlags

Flags that are used by g19_update_lcd.


G19_SCREEN_DEFAULT Specifies the default. You don’t have to specify this. Will be used in the future.
G19_PREPEND_HDATA Specifies that the header data should be applied to the data before it is sent.
G19_DATA_TYPE_RAW Specifies that nothing is to be done to the data and it should be directly sent to the LCD.
G19_DATA_TYPE_BMP Flags the data as being 4 bytes per pixel data. This is what libg19draw produces. Use this option if you updating from libg19draw data.


enum G19Keys

The keys used by various things.


G19_KEY_G1 The G1 key.
G19_KEY_G2 The G2 key.
G19_KEY_G3 The G3 key.
G19_KEY_G4 The G4 key.
G19_KEY_G5 The G5 key.
G19_KEY_G6 The G6 key.
G19_KEY_G7 The G7 key.
G19_KEY_G8 The G8 key.
G19_KEY_G9 The G9 key.
G19_KEY_G10 The G10 key.
G19_KEY_G11 The G11 key.
G19_KEY_G12 The G12 key.
G19_KEY_M1 The M1 key.
G19_KEY_M2 The M2 key.
G19_KEY_M3 The M3 key.
G19_KEY_MR The MR key.
G19_KEY_LHOME The home key. The key that has a square with a gray gear in the lower right.
G19_KEY_LCANCEL The cancel key. The that looks lie <-
G19_KEY_LMENU The menu key.
G19_KEY_LOK The OK key.
G19_KEY_LRIGHT The right arrow key.
G19_KEY_LLEFT The left arrow key.
G19_KEY_LDOWN The down arrow key.
G19_KEY_LUP The up arrow key.


typedef void(* g19_keys_cb)(unsigned int keys)

Callback function for a keypress of either a L-Key(s) or G-Key(s). You can set the callback to be called with either g19_set_gkeys_cb or g19_set_lkeys_cb.


unsigned int keys The key(s) that invoked the function. The keys are joined with a bitwise OR. Use a bitwise AND to see if the key you are looking for was pressed.


int g19_init(int level)

Initializes the g19 library. During this process it looks for a g19 device. If one is found, it claims it and detaches the OS’s driver.


int level
  • 0: no messages ever printed by the library (default)
  • 1: error messages are printed to stderr
  • 2: warning and error messages are printed to stderr
  • 3: informational messages are printed to stdout, warning and error messages are printed to stderr


Non-Zero on error.


void g19_deinit(void)

This frees up things on the libraries end, releases the device, and resets the devie to the OS.


void g19_set_gkeys_cb(g19_keys_cb cb)

Sets a callback that will be invoked when a G-Key or an M-Key is pressed.


g19_keys_cb cb The callback function to be invoked.


void g19_set_leys_cb(g19_keys_cb cb)

Sets a callback that will be invoked when a L-Key is pressed.


g19_keys_cb cb The callback function to be invoked.


void g19_update_lcd(unsigned char * data, size_t size, unsigned int flags)

Sends screen data to the LCD.


unsigned char * data The data to be sent to the LCD.
size_t size The size of the data to be sent to the LCD.
unsigned int flags The flags that should be applied to the data.


int g19_set_backlight(unsigned char r, unsigned char g, unsigned char b)

Sets the keyboards backlight. Note that the keyboard’s default white color is not 255, 255, 255. It’s 110, 255, 110. Thanks to dutchfish for this.


unsigned char r The amount of red. (0 – 255)
unsigned char g The amount of green. (0 – 255)
unsigned char b The amount of blue. (0 – 255)


Non-zero on error.


int g19_set_mkey_led(unsigned int keys)

Sets the M-Keys led lights.


unsigned int keys The key(s) to set the led on for. You can use G19_KEY_M1, G19_KEY_M2, G19_KEY_M3, and G19_KEY_MR. For more than one use bitwise OR.


Non-zero on error.


Leave a comment


  1. Hi dude! Where can I read additional resources on this topic?

Leave a Reply

[ Ctrl + Enter ]