source: npl/mediabox/lcdproc_edwin/src/server/drivers/drv_base.h

Last change on this file was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100644
File size: 4.9 KB
Line 
1#ifndef LCD_DRV_BASE_H
2#define LCD_DRV_BASE_H
3
4/********************************************************************
5  How to make a driver for LCDproc
6
7  Note: Insert the name of your driver in place of the phrase "new_driver".
8 
9  1. Copy drv_base.c and drv_base.h to new_driver.c and new_driver.h.
10
11  2. Decide which functions you want to override, which ones you want
12     to leave alone, and which ones you don't want at all.  If you
13     write your own driver functions, they will get called when
14     appropriate.  Or, you can let the default driver "drv_base"
15     handle a function for you.  But, if you really don't want a
16     function, you can completely prevent your driver from providing
17     it.  This is discussed in step 5.
18 
19  2.1. Remove all functions which you don't want to override, and the
20     ones you don't want at all.
21
22  3. Rename all functions from "drv_base_*" to "new_driver_*".
23
24  4. Write the new driver functions.
25     Be sure to do one of the following in/for your new_driver_close():
26        - free the framebuffer lcd.framebuf
27        - let the default driver handle close()
28        - call drv_base_close()
29     This will ensure that the frame buffer gets freed.
30
31  5. Register your functions in your new_driver_init(), like the following:
32       driver->clear = new_driver_clear;    // We want to handle this one
33       driver->string = (void *)-1;         // Leave this to the default
34       driver->getkey = NULL;               // This should never get called
35
36     The convention here is to set NULL for all the functions which
37     your driver doesn't handle (and which you don't want the default
38     functions to be called for).  Or, set -1 to indicate that the
39     driver should support the function but can use the default
40     behavior in drv_base.c.  Or, to indicate that your driver should
41     handle a function, just set it like clear() above.
42       
43  6. Add the driver to lcd.c, in the physical drivers section, protected
44     by an #ifdef like the rest of the drivers are.
45
46  7. Add your driver to the Makefile, and Makefile.config, in the same
47     style as the existing ones.
48
49
50  Notes:
51
52  Don't call lcd.whatever() functions within your driver.  This causes
53  a lot of potentially puzzling problems.
54
55  However, feel free to access lcd.framebuf in your driver (but not in
56  your init() function!).  It will always point to the frame buffer
57  you should be writing to.  This will usually be your own frame
58  buffer, but could potentially be another frame buffer, if another
59  driver wants to access your functions.
60
61  Your driver will be provided with a frame buffer which contains one
62  byte per character on the LCD.  The default is a 20x4, so that's 80
63  bytes.  You can free this and reallocate it to something else if you
64  need to.  A graphical driver may want to do this, for example.
65
66  If you don't set a function pointer, it will default to NULL, since
67  they get nullified before the driver's init() is called.
68
69  Assume that your driver may be added or removed dynamically, and
70  that more than one instance may exist at a time.  In other words, it
71  should init and close cleanly, and not depend on global variables.
72
73  Special arguments will be passed through the "args" variable to your
74  _init() function.  This is just a string, and you determine the
75  syntax of it.  Please document the syntax so that it can easily be
76  included in the lcdproc config file.  I suggest arguments such as
77  "port=0x378" or "-device /dev/ttyS0".  These come directly from the
78  lcdproc server config file, so they should be human-readable.  An
79  example may look like this:
80
81    # Set up two MtxOrb LCD's and a curses display on VT 2
82    Driver MtxOrb -device /dev/ttyS0 -keypad on
83    Driver curses -color off -size 20x4 -vt 2
84    Driver MtxOrb -device /dev/ttyS3 -size 20x2 -keypad off
85    # Before you ask, no, not all of these options are implemented yet.
86
87  Also, the driver API (if it can be called that) may change soon.
88  There seem to be several functions which just don't do anything
89  important...  and there are other potential improvements too.
90
91  And...  When in doubt, look at how the other drivers do it.  :)
92   
93******************************************************************/
94
95extern lcd_logical_driver *drv_base;
96
97int drv_base_init(struct lcd_logical_driver *driver, char *args);
98void drv_base_close();
99void drv_base_clear();
100void drv_base_flush();
101void drv_base_string(int x, int y, char string[]);
102void drv_base_chr(int x, int y, char c);
103int drv_base_contrast(int contrast);
104void drv_base_backlight(int on);
105void drv_base_output(int on);
106void drv_base_vbar(int x, int len);
107void drv_base_init_vbar();
108void drv_base_hbar(int x, int y, int len);
109void drv_base_init_hbar();
110void drv_base_num(int x, int num);
111void drv_base_init_num();
112void drv_base_set_char(int n, char *dat);
113void drv_base_icon(int which, char dest);
114void drv_base_flush_box(int lft, int top, int rgt, int bot);
115void drv_base_draw_frame(char *dat);
116char drv_base_getkey();
117
118
119#endif
Note: See TracBrowser for help on using the repository browser.