1 // This header contains low level code to export from hd44780.c to "lower" HW
2 // implementation dependent files.
11 # if TIME_WITH_SYS_TIME
12 # include <sys/time.h>
16 # include <sys/time.h>
23 //struct hwDependentFns;
25 // Maximum sizes of the keypad
26 // DO NOT CHANGE THESE 2 VALUES, unless you change the functions too
28 #define KEYPAD_MAXY 11
30 /* Constants for userdefchar_mode */
31 #define NUM_CCs 8 /* number of custom characters */
34 standard
, /* only char 0 is used for heartbeat */
35 vbar
, /* vertical bars */
36 hbar
, /* horizontal bars */
37 bignum
, /* big numbers */
38 bigchar
/* big characters */
41 typedef struct cgram_cache
{
42 unsigned char cache
[LCD_DEFAULT_CELLHEIGHT
];
46 typedef struct ConnectionMapping
{
48 int (*init_fn
)(Driver
*drvthis
);
52 typedef struct driver_private_data
{
56 /* for serial connection type */
63 int cellwidth
, cellheight
;
68 // For incremental updates store last lcd contents
71 // The defineable characters
75 // Connection type data
76 int connectiontype_index
;
77 struct hwDependentFns
*hd44780_functions
;
79 // spanList[line number] = display line number is in
83 // dispVOffset is a cumulative sized array of line numbers for each display.
84 // use this to determine the vertical positioning on a given display
88 // dispSizes is the vertical size of each display. This is the same as the
89 // input span list but is kept to save some cpu cycles.
92 // Keypad, backlight extended interface and delay options
93 char have_keypad
; // off by default
94 char have_backlight
; // off by default
95 char have_output
; // have extra output port (off by default)
96 char ext_mode
; // use of extended mode required for some weird controllers
97 int delayMult
; // Delay multiplier for slow displays
98 char delayBus
; // Delay if the computer can send data too fast over
99 // its bus to LPT port
100 char lastline
; // lastline controls the use of the last line, if pixel addressable (true, default) or
101 // underline effect (false). To avoid the underline effect, last line is always zeroed
102 // for whatever redefined character
104 // keyMapDirect contains an array of the ascii-codes that should be generated
105 // when a directly connected key is pressed (not in matrix).
106 char *keyMapDirect
[KEYPAD_MAXX
];
108 // keyMapMatrix contrains an array with arrays of the ascii-codes that should be generated
109 // when a key in the matrix is pressed.
110 char *keyMapMatrix
[KEYPAD_MAXY
][KEYPAD_MAXX
];
113 int pressed_key_repetitions
;
114 struct timeval pressed_key_time
;
120 // force full refresh of display
122 int refreshdisplay
; // When >0 make a full display update every <refreshdisplay> seconds
123 time_t nextkeepalive
;
124 int keepalivedisplay
; // When >0 refresh upper left char every <keepalivedisplay> seconds to keep display alive
126 int output_state
; // what was most recently output to the output port
129 // Structures holding pointers to HD44780 specific functions
130 typedef struct hwDependentFns
{
132 void (*uPause
)(PrivateData
*p
, int usecs
);
134 // Senddata to the LCD
135 // dispID - display to send data to (0 = all displays)
136 // flags - data or instruction command (RS_DATA | RS_INSTR)
137 // ch - character to display or instruction value
138 void (*senddata
)(PrivateData
*p
, unsigned char dispID
, unsigned char flags
, unsigned char ch
);
140 // Switch the backlight on or off
141 // state - to be or not to be on
142 void (*backlight
)(PrivateData
*p
, unsigned char state
);
145 // Ydata - the up to 11 bits that should be put on the Y side of the matrix
146 // return - the up to 5 bits that are read out on the X side of the matrix
147 unsigned char (*readkeypad
)(PrivateData
*p
, unsigned int Ydata
);
149 // Scan the keypad and return a scancode.
150 // The code is the Yvalue in the high nibble and the Xvalue in the low nibble.
151 // A subdriver should do only one of two things:
152 // - set readkeypad; or
153 // - override scankeypad.
154 unsigned char (*scankeypad
)(PrivateData
*p
);
156 // Output "data" to output latch if there is one
157 void (*output
)(PrivateData
*p
, int data
);
159 // Close the interface on shutdown
160 void (*close
)(PrivateData
*p
);
162 } HD44780_functions
; /* for want of a better name :-) */
165 void common_init(PrivateData
*p
, unsigned char if_bit
);
168 // commands for senddata
170 #define RS_INSTR 0x01
174 #define HOMECURSOR 0x02
176 #define ENTRYMODE 0x04
177 #define E_MOVERIGHT 0x02
178 #define E_MOVELEFT 0x00
179 #define EDGESCROLL 0x01
180 #define NOSCROLL 0x00
182 #define ONOFFCTRL 0x08 /* Only reachable with EXTREG clear */
185 #define CURSORON 0x02
186 #define CURSOROFF 0x00
187 #define CURSORBLINK 0x01
188 #define CURSORNOBLINK 0x00
190 #define EXTMODESET 0x08 /* Only reachable with EXTREG set */
191 #define FONT6WIDE 0x04
192 #define INVCURSOR 0x02
193 #define FOURLINE 0x01
195 #define CURSORSHIFT 0x10 /* Only reachable with EXTREG clear */
196 #define SCROLLDISP 0x08
197 #define MOVECURSOR 0x00
198 #define MOVERIGHT 0x04
199 #define MOVELEFT 0x00
201 #define HSCROLLEN 0x10 /* Only reachable with EXTREG set */
208 #define LARGECHAR 0x04 /* 5x11 characters */
209 #define SMALLCHAR 0x00 /* 5x8 characters */
210 #define EXTREG 0x04 /* Select ext. registers (Yes, the same bits)*/
211 #define SEGBLINK 0x02 /* Only reachable with EXTREG set */
212 #define POWERDOWN 0x01 /* Only reachable with EXTREG set */
214 #define SETCHAR 0x40 /* Only reachable with EXTREG clear */
216 #define SETSEG 0x40 /* Only reachable with EXTREG set */
218 #define POSITION 0x80 /* Only reachable with EXTREG clear */
220 #define HSCROLLAMOUNT 0x80 /* Only reachable with EXTREG set */