2 #define LCD_COLLUMNS 20
4 xdata at 0x380002 static unsigned char lcdIwr;
5 xdata at 0x38000a static unsigned char lcdDwr;
9 xdata at 0x380003 static unsigned char lcdIrd;
10 xdata at 0x38000b static unsigned char lcdDrd;
12 #define LcdWait { while (lcdIrd&0x80) ; }
16 // wait for 100us*time
17 // check this, _PLEASE_
19 static void Wait100u(long time) {
20 register long timeout=time*50;
25 #define LcdWait { Wait100u(1);}
27 #endif //#ifdef LCD_RW
29 // set the dd ram addresses for the rows
30 // this one is for a 20x4 LCD
31 xdata static unsigned char lcdLinesStart[LCD_ROWS]={0, 0x40, 0x14, 0x54};
41 Wait100u(150); // >15 ms
44 Wait100u(50); // >4.1 ms
47 Wait100u(1); // >100 us
50 Wait100u(1); // >100 u
52 lcdIwr=0x38; // interface 8 bit
55 lcdIwr=0x0c; // display on
62 lcdIwr=0x0c; // display on
67 lcdIwr=0x08; // display off
87 void LcdCharDefine() {
92 lcdIwr=0x01; // display clear
97 lcdIwr=0x80; // set dd ram address 0
101 void LcdGoto(unsigned int collumnRow) { // msb=collumn, lsb=row
103 lcdLinesStart[collumnRow&0xff] + \
108 void LcdPutChar(char c) {
113 void LcdPutString (char *string) {
115 while (c=*string++) {
120 void LcdLPutString (unsigned int collumnRow, char *string) {
122 LcdPutString(string);
125 // let's hope that no one ever printf's more than the display width,
126 // however they will :), so to be sure
127 xdata static char lcdPrintfBuffer[LCD_COLLUMNS*4];
129 void LcdPrintf (xdata const char *format, ...) reentrant {
132 va_start (arg, format);
133 vsprintf (lcdPrintfBuffer, format, arg);
135 LcdPutString(lcdPrintfBuffer);
140 void LcdLPrintf (unsigned int collumnRow, xdata const char *format, ...) reentrant {
145 // we can not just call LcdPrintf since we have no idea what is on the stack,
146 // so we have to do it all over again
147 va_start (arg, format);
148 vsprintf (lcdPrintfBuffer, format, arg);
150 LcdPutString(lcdPrintfBuffer);
156 // These don't belong here
169 void LedToggle (void) {