DIGILIGHT
lcd.c
1 /****************************************************************************
2  Title : HD44780U LCD library
3  Author: Peter Fleury <pfleury@gmx.ch> http://jump.to/fleury
4  File: $Id: lcd.c,v 1.14.2.1 2006/01/29 12:16:41 peter Exp $
5  Software: AVR-GCC 3.3
6  Target: any AVR device, memory mapped mode only for AT90S4414/8515/Mega
7 
8  DESCRIPTION
9  Basic routines for interfacing a HD44780U-based text lcd display
10 
11  Originally based on Volker Oth's lcd library,
12  changed lcd_init(), added additional constants for lcd_command(),
13  added 4-bit I/O mode, improved and optimized code.
14 
15  Library can be operated in memory mapped mode (LCD_IO_MODE=0) or in
16  4-bit IO port mode (LCD_IO_MODE=1). 8-bit IO port mode not supported.
17 
18  Memory mapped mode compatible with Kanda STK200, but supports also
19  generation of R/W signal through A8 address line.
20 
21  USAGE
22  See the C include lcd.h file for a description of each function
23 
24 *****************************************************************************/
25 #include <avr/io.h>
26 #include <avr/pgmspace.h>
27 #include "avr_helper.h"
28 #include "lcd.h"
29 
30 /*
31 ** constants/macros
32 */
33 #define D_D_R(x) (*(&x - 1)) /* address of data direction register of port x */
34 #if defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__)
35  /* on ATmega64/128 PINF is on port 0x00 and not 0x60 */
36  #define P_I_N(x) ( &PORTF==&(x) ? _SFR_IO8(0x00) : (*(&x - 2)) )
37 #else
38  #define P_I_N(x) (*(&x - 2)) /* address of input register of port x */
39 #endif
40 
41 
42 #if LCD_IO_MODE
43 #define lcd_e_delay() __asm__ __volatile__( "rjmp 1f\n 1:" );
44 #define lcd_e_high() LCD_E_PORT |= _BV(LCD_E_PIN);
45 #define lcd_e_low() LCD_E_PORT &= ~_BV(LCD_E_PIN);
46 #define lcd_e_toggle() toggle_e()
47 #define lcd_rw_high() LCD_RW_PORT |= _BV(LCD_RW_PIN)
48 #define lcd_rw_low() LCD_RW_PORT &= ~_BV(LCD_RW_PIN)
49 #define lcd_rs_high() LCD_RS_PORT |= _BV(LCD_RS_PIN)
50 #define lcd_rs_low() LCD_RS_PORT &= ~_BV(LCD_RS_PIN)
51 #endif
52 
53 #if LCD_IO_MODE
54 #if LCD_LINES==1
55 #define LCD_FUNCTION_DEFAULT LCD_FUNCTION_4BIT_1LINE
56 #else
57 #define LCD_FUNCTION_DEFAULT LCD_FUNCTION_4BIT_2LINES
58 #endif
59 #else
60 #if LCD_LINES==1
61 #define LCD_FUNCTION_DEFAULT LCD_FUNCTION_8BIT_1LINE
62 #else
63 #define LCD_FUNCTION_DEFAULT LCD_FUNCTION_8BIT_2LINES
64 #endif
65 #endif
66 
67 #if LCD_CONTROLLER_KS0073
68 #if LCD_LINES==4
69 
70 #define KS0073_EXTENDED_FUNCTION_REGISTER_ON 0x24 /* |0|010|0100 4-bit mode extension-bit RE = 1 */
71 #define KS0073_EXTENDED_FUNCTION_REGISTER_OFF 0x20 /* |0|000|1001 4 lines mode */
72 #define KS0073_4LINES_MODE 0x09 /* |0|001|0000 4-bit mode, extension-bit RE = 0 */
73 
74 #endif
75 #endif
76 
77 /*
78 ** function prototypes
79 */
80 #if LCD_IO_MODE
81 static void toggle_e(void);
82 #endif
83 
84 /*
85 ** local functions
86 */
87 
88 
89 
90 /*************************************************************************
91  delay loop for small accurate delays: 16-bit counter, 4 cycles/loop
92 *************************************************************************/
93 static inline void _delayFourCycles(unsigned int __count)
94 {
95  if ( __count == 0 )
96  __asm__ __volatile__( "rjmp 1f\n 1:" ); // 2 cycles
97  else
98  __asm__ __volatile__ (
99  "1: sbiw %0,1" "\n\t"
100  "brne 1b" // 4 cycles/loop
101  : "=w" (__count)
102  : "0" (__count)
103  );
104 }
105 
106 
107 /*************************************************************************
108 delay for a minimum of <us> microseconds
109 the number of loops is calculated at compile-time from MCU clock frequency
110 *************************************************************************/
111 #define delay(us) _delayFourCycles( ( ( 1*(XTAL/4000) )*us)/1000 )
112 
113 
114 #if LCD_IO_MODE
115 /* toggle Enable Pin to initiate write */
116 static void toggle_e(void)
117 {
118  lcd_e_high();
119  lcd_e_delay();
120  lcd_e_low();
121 }
122 #endif
123 
124 
125 /*************************************************************************
126 Low-level function to write byte to LCD controller
127 Input: data byte to write to LCD
128  rs 1: write data
129  0: write instruction
130 Returns: none
131 *************************************************************************/
132 #if LCD_IO_MODE
133 static void lcd_write(uint8_t data,uint8_t rs)
134 {
135  unsigned char dataBits ;
136 
137 
138  if (rs) { /* write data (RS=1, RW=0) */
139  lcd_rs_high();
140  } else { /* write instruction (RS=0, RW=0) */
141  lcd_rs_low();
142  }
143  lcd_rw_low();
144 
146  && (LCD_DATA0_PIN == 0) && (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3) )
147  {
148  /* configure data pins as output */
149  D_D_R(LCD_DATA0_PORT) |= 0x0F;
150 
151  /* output high nibble first */
152  dataBits = LCD_DATA0_PORT & 0xF0;
153  LCD_DATA0_PORT = dataBits |((data>>4)&0x0F);
154  lcd_e_toggle();
155 
156  /* output low nibble */
157  LCD_DATA0_PORT = dataBits | (data&0x0F);
158  lcd_e_toggle();
159 
160  /* all data pins high (inactive) */
161  LCD_DATA0_PORT = dataBits | 0x0F;
162  }
163  else
164  {
165  /* configure data pins as output */
166  D_D_R(LCD_DATA0_PORT) |= _BV(LCD_DATA0_PIN);
167  D_D_R(LCD_DATA1_PORT) |= _BV(LCD_DATA1_PIN);
168  D_D_R(LCD_DATA2_PORT) |= _BV(LCD_DATA2_PIN);
169  D_D_R(LCD_DATA3_PORT) |= _BV(LCD_DATA3_PIN);
170 
171  /* output high nibble first */
172  LCD_DATA3_PORT &= ~_BV(LCD_DATA3_PIN);
173  LCD_DATA2_PORT &= ~_BV(LCD_DATA2_PIN);
174  LCD_DATA1_PORT &= ~_BV(LCD_DATA1_PIN);
175  LCD_DATA0_PORT &= ~_BV(LCD_DATA0_PIN);
176  if(data & 0x80) LCD_DATA3_PORT |= _BV(LCD_DATA3_PIN);
177  if(data & 0x40) LCD_DATA2_PORT |= _BV(LCD_DATA2_PIN);
178  if(data & 0x20) LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN);
179  if(data & 0x10) LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN);
180  lcd_e_toggle();
181 
182  /* output low nibble */
183  LCD_DATA3_PORT &= ~_BV(LCD_DATA3_PIN);
184  LCD_DATA2_PORT &= ~_BV(LCD_DATA2_PIN);
185  LCD_DATA1_PORT &= ~_BV(LCD_DATA1_PIN);
186  LCD_DATA0_PORT &= ~_BV(LCD_DATA0_PIN);
187  if(data & 0x08) LCD_DATA3_PORT |= _BV(LCD_DATA3_PIN);
188  if(data & 0x04) LCD_DATA2_PORT |= _BV(LCD_DATA2_PIN);
189  if(data & 0x02) LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN);
190  if(data & 0x01) LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN);
191  lcd_e_toggle();
192 
193  /* all data pins high (inactive) */
198  }
199 }
200 #else
201 #define lcd_write(d,rs) if (rs) *(volatile uint8_t*)(LCD_IO_DATA) = d; else *(volatile uint8_t*)(LCD_IO_FUNCTION) = d;
202 /* rs==0 -> write instruction to LCD_IO_FUNCTION */
203 /* rs==1 -> write data to LCD_IO_DATA */
204 #endif
205 
206 
207 /*************************************************************************
208 Low-level function to read byte from LCD controller
209 Input: rs 1: read data
210  0: read busy flag / address counter
211 Returns: byte read from LCD controller
212 *************************************************************************/
213 #if LCD_IO_MODE
214 //static
215 uint8_t lcd_read(uint8_t rs)
216 {
217  uint8_t data;
218 
219 
220  if (rs)
221  lcd_rs_high(); /* RS=1: read data */
222  else
223  lcd_rs_low(); /* RS=0: read busy flag */
224  lcd_rw_high(); /* RW=1 read mode */
225 
227  && ( LCD_DATA0_PIN == 0 )&& (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3) )
228  {
229  D_D_R(LCD_DATA0_PORT) &= 0xF0; /* configure data pins as input */
230 
231  lcd_e_high();
232  lcd_e_delay();
233  data = P_I_N(LCD_DATA0_PORT) << 4; /* read high nibble first */
234  lcd_e_low();
235 
236  lcd_e_delay(); /* Enable 500ns low */
237 
238  lcd_e_high();
239  lcd_e_delay();
240  data |= P_I_N(LCD_DATA0_PORT)&0x0F; /* read low nibble */
241  lcd_e_low();
242  }
243  else
244  {
245  /* configure data pins as input */
246  D_D_R(LCD_DATA0_PORT) &= ~_BV(LCD_DATA0_PIN);
247  D_D_R(LCD_DATA1_PORT) &= ~_BV(LCD_DATA1_PIN);
248  D_D_R(LCD_DATA2_PORT) &= ~_BV(LCD_DATA2_PIN);
249  D_D_R(LCD_DATA3_PORT) &= ~_BV(LCD_DATA3_PIN);
250 
251  /* read high nibble first */
252  lcd_e_high();
253  lcd_e_delay();
254  data = 0;
255  if ( P_I_N(LCD_DATA0_PORT) & _BV(LCD_DATA0_PIN) ) data |= 0x10;
256  if ( P_I_N(LCD_DATA1_PORT) & _BV(LCD_DATA1_PIN) ) data |= 0x20;
257  if ( P_I_N(LCD_DATA2_PORT) & _BV(LCD_DATA2_PIN) ) data |= 0x40;
258  if ( P_I_N(LCD_DATA3_PORT) & _BV(LCD_DATA3_PIN) ) data |= 0x80;
259  lcd_e_low();
260 
261  lcd_e_delay(); /* Enable 500ns low */
262 
263  /* read low nibble */
264  lcd_e_high();
265  lcd_e_delay();
266  if ( P_I_N(LCD_DATA0_PORT) & _BV(LCD_DATA0_PIN) ) data |= 0x01;
267  if ( P_I_N(LCD_DATA1_PORT) & _BV(LCD_DATA1_PIN) ) data |= 0x02;
268  if ( P_I_N(LCD_DATA2_PORT) & _BV(LCD_DATA2_PIN) ) data |= 0x04;
269  if ( P_I_N(LCD_DATA3_PORT) & _BV(LCD_DATA3_PIN) ) data |= 0x08;
270  lcd_e_low();
271  }
272  return data;
273 }
274 #else
275 #define lcd_read(rs) (rs) ? *(volatile uint8_t*)(LCD_IO_DATA+LCD_IO_READ) : *(volatile uint8_t*)(LCD_IO_FUNCTION+LCD_IO_READ)
276 /* rs==0 -> read instruction from LCD_IO_FUNCTION */
277 /* rs==1 -> read data from LCD_IO_DATA */
278 #endif
279 
280 
281 /*************************************************************************
282 loops while lcd is busy, returns address counter
283 *************************************************************************/
284 static uint8_t lcd_waitbusy(void)
285 
286 {
287  register uint8_t c;
288 
289  /* wait until busy flag is cleared */
290  while ( (c=lcd_read(0)) & (1<<LCD_BUSY)) {}
291 
292  /* the address counter is updated 4us after the busy flag is cleared */
293  delay(2);
294 
295  /* now read the address counter */
296  return (lcd_read(0)); // return address counter
297 
298 }/* lcd_waitbusy */
299 
300 
301 /*************************************************************************
302 Move cursor to the start of next line or to the first line if the cursor
303 is already on the last line.
304 *************************************************************************/
305 static inline void lcd_newline(uint8_t pos)
306 {
307  register uint8_t addressCounter;
308 
309 
310 #if LCD_LINES==1
311  addressCounter = 0;
312 #endif
313 #if LCD_LINES==2
314  if ( pos < (LCD_START_LINE2) )
315  addressCounter = LCD_START_LINE2;
316  else
317  addressCounter = LCD_START_LINE1;
318 #endif
319 #if LCD_LINES==4
320 #if KS0073_4LINES_MODE
321  if ( pos < LCD_START_LINE2 )
322  addressCounter = LCD_START_LINE2;
323  else if ( (pos >= LCD_START_LINE2) && (pos < LCD_START_LINE3) )
324  addressCounter = LCD_START_LINE3;
325  else if ( (pos >= LCD_START_LINE3) && (pos < LCD_START_LINE4) )
326  addressCounter = LCD_START_LINE4;
327  else
328  addressCounter = LCD_START_LINE1;
329 #else
330  if ( pos < LCD_START_LINE3 )
331  addressCounter = LCD_START_LINE2;
332  else if ( (pos >= LCD_START_LINE2) && (pos < LCD_START_LINE4) )
333  addressCounter = LCD_START_LINE3;
334  else if ( (pos >= LCD_START_LINE3) && (pos < LCD_START_LINE2) )
335  addressCounter = LCD_START_LINE4;
336  else
337  addressCounter = LCD_START_LINE1;
338 #endif
339 #endif
340  lcd_command((1<<LCD_DDRAM)+addressCounter);
341 
342 }/* lcd_newline */
343 
344 
345 /*
346 ** PUBLIC FUNCTIONS
347 */
348 
349 /*************************************************************************
350 Send LCD controller instruction command
351 Input: instruction to send to LCD controller, see HD44780 data sheet
352 Returns: none
353 *************************************************************************/
354 void lcd_command(uint8_t cmd)
355 {
356  lcd_waitbusy();
357  lcd_write(cmd,0);
358 }
359 
360 
361 /*************************************************************************
362 Send data byte to LCD controller
363 Input: data to send to LCD controller, see HD44780 data sheet
364 Returns: none
365 *************************************************************************/
366 void lcd_data(uint8_t data)
367 {
368  lcd_waitbusy();
369  lcd_write(data,1);
370 }
371 
372 
373 
374 /*************************************************************************
375 Set cursor to specified position
376 Input: x horizontal position (0: left most position)
377  y vertical position (0: first line)
378 Returns: none
379 *************************************************************************/
380 void lcd_gotoxy(uint8_t x, uint8_t y)
381 {
382 #if LCD_LINES==1
383  lcd_command((1<<LCD_DDRAM)+LCD_START_LINE1+x);
384 #endif
385 #if LCD_LINES==2
386  if ( y==0 )
387  lcd_command((1<<LCD_DDRAM)+LCD_START_LINE1+x);
388  else
389  lcd_command((1<<LCD_DDRAM)+LCD_START_LINE2+x);
390 #endif
391 #if LCD_LINES==4
392  if ( y==0 )
393  lcd_command((1<<LCD_DDRAM)+LCD_START_LINE1+x);
394  else if ( y==1)
395  lcd_command((1<<LCD_DDRAM)+LCD_START_LINE2+x);
396  else if ( y==2)
397  lcd_command((1<<LCD_DDRAM)+LCD_START_LINE3+x);
398  else /* y==3 */
399  lcd_command((1<<LCD_DDRAM)+LCD_START_LINE4+x);
400 #endif
401 
402 }/* lcd_gotoxy */
403 
404 
405 /*************************************************************************
406 *************************************************************************/
407 uint8_t lcd_getxy(void)
408 {
409  return lcd_waitbusy();
410 }
411 
412 
413 /*************************************************************************
414 Clear display and set cursor to home position
415 *************************************************************************/
416 void lcd_clrscr(void)
417 {
418  lcd_command(1<<LCD_CLR);
419 }
420 
421 
422 /*************************************************************************
423 Set cursor to home position
424 *************************************************************************/
425 void lcd_home(void)
426 {
427  lcd_command(1<<LCD_HOME);
428 }
429 
430 
431 /*************************************************************************
432 Display character at current cursor position
433 Input: character to be displayed
434 Returns: none
435 *************************************************************************/
436 void lcd_putc(char c)
437 {
438  uint8_t pos;
439 
440 
441  pos = lcd_waitbusy(); // read busy-flag and address counter
442  if (c=='\n')
443  {
444  lcd_newline(pos);
445  }
446  else
447  {
448 #if LCD_WRAP_LINES==1
449 #if LCD_LINES==1
450  if ( pos == LCD_START_LINE1+LCD_DISP_LENGTH ) {
451  lcd_write((1<<LCD_DDRAM)+LCD_START_LINE1,0);
452  }
453 #elif LCD_LINES==2
454  if ( pos == LCD_START_LINE1+LCD_DISP_LENGTH ) {
455  lcd_write((1<<LCD_DDRAM)+LCD_START_LINE2,0);
456  }else if ( pos == LCD_START_LINE2+LCD_DISP_LENGTH ){
457  lcd_write((1<<LCD_DDRAM)+LCD_START_LINE1,0);
458  }
459 #elif LCD_LINES==4
460  if ( pos == LCD_START_LINE1+LCD_DISP_LENGTH ) {
461  lcd_write((1<<LCD_DDRAM)+LCD_START_LINE2,0);
462  }else if ( pos == LCD_START_LINE2+LCD_DISP_LENGTH ) {
463  lcd_write((1<<LCD_DDRAM)+LCD_START_LINE3,0);
464  }else if ( pos == LCD_START_LINE3+LCD_DISP_LENGTH ) {
465  lcd_write((1<<LCD_DDRAM)+LCD_START_LINE4,0);
466  }else if ( pos == LCD_START_LINE4+LCD_DISP_LENGTH ) {
467  lcd_write((1<<LCD_DDRAM)+LCD_START_LINE1,0);
468  }
469 #endif
470  lcd_waitbusy();
471 #endif
472  lcd_write(c, 1);
473  }
474 
475 }/* lcd_putc */
476 
477 
478 /*************************************************************************
479 Display string without auto linefeed
480 Input: string to be displayed
481 Returns: none
482 *************************************************************************/
483 void lcd_puts(const char *s)
484 /* print string on lcd (no auto linefeed) */
485 {
486  register char c;
487 
488  while ( (c = *s++) ) {
489  lcd_putc(c);
490  }
491 
492 }/* lcd_puts */
493 
494 
495 /*************************************************************************
496 Display string from program memory without auto linefeed
497 Input: string from program memory be be displayed
498 Returns: none
499 *************************************************************************/
500 void lcd_puts_p(const char *progmem_s)
501 /* print string from program memory on lcd (no auto linefeed) */
502 {
503  register char c;
504 
505  while ( (c = pgm_read_byte(progmem_s++)) ) {
506  lcd_putc(c);
507  }
508 
509 }/* lcd_puts_p */
510 
511 
512 /*************************************************************************
513 Initialize display and select type of cursor
514 Input: dispAttr LCD_DISP_OFF display off
515  LCD_DISP_ON display on, cursor off
516  LCD_DISP_ON_CURSOR display on, cursor on
517  LCD_DISP_CURSOR_BLINK display on, cursor on flashing
518 Returns: none
519 *************************************************************************/
520 void lcd_init(void)
521 //void lcd_init(uint8_t dispAttr)
522 {
523 #if LCD_IO_MODE
524  /*
525  * Initialize LCD to 4 bit I/O mode
526  */
527 
530  && (LCD_DATA0_PIN == 0 ) && (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3)
531  && (LCD_RS_PIN == 4 ) && (LCD_RW_PIN == 5) && (LCD_E_PIN == 6 ) )
532  {
533  /* configure all port bits as output (all LCD lines on same port) */
534  D_D_R(LCD_DATA0_PORT) |= 0x7F;
535  }
537  && (LCD_DATA0_PIN == 0 ) && (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3) )
538  {
539  /* configure all port bits as output (all LCD data lines on same port, but control lines on different ports) */
540  D_D_R(LCD_DATA0_PORT) |= 0x0F;
541  D_D_R(LCD_RS_PORT) |= _BV(LCD_RS_PIN);
542  D_D_R(LCD_RW_PORT) |= _BV(LCD_RW_PIN);
543  D_D_R(LCD_E_PORT) |= _BV(LCD_E_PIN);
544  }
545  else
546  {
547  /* configure all port bits as output (LCD data and control lines on different ports */
548  D_D_R(LCD_RS_PORT) |= _BV(LCD_RS_PIN);
549  D_D_R(LCD_RW_PORT) |= _BV(LCD_RW_PIN);
550  D_D_R(LCD_E_PORT) |= _BV(LCD_E_PIN);
551  D_D_R(LCD_DATA0_PORT) |= _BV(LCD_DATA0_PIN);
552  D_D_R(LCD_DATA1_PORT) |= _BV(LCD_DATA1_PIN);
553  D_D_R(LCD_DATA2_PORT) |= _BV(LCD_DATA2_PIN);
554  D_D_R(LCD_DATA3_PORT) |= _BV(LCD_DATA3_PIN);
555  }
556  delay(16000); /* wait 16ms or more after power-on */
557 
558  /* initial write to lcd is 8bit */
559  LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN); // _BV(LCD_FUNCTION)>>4;
560  LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN); // _BV(LCD_FUNCTION_8BIT)>>4;
561  lcd_e_toggle();
562  delay(4992); /* delay, busy flag can't be checked here */
563 
564  /* repeat last command */
565  lcd_e_toggle();
566  delay(64); /* delay, busy flag can't be checked here */
567 
568  /* repeat last command a third time */
569  lcd_e_toggle();
570  delay(64); /* delay, busy flag can't be checked here */
571 
572  /* now configure for 4bit mode */
573  LCD_DATA0_PORT &= ~_BV(LCD_DATA0_PIN); // LCD_FUNCTION_4BIT_1LINE>>4
574  lcd_e_toggle();
575  delay(64); /* some displays need this additional delay */
576 
577  /* from now the LCD only accepts 4 bit I/O, we can use lcd_command() */
578 #else
579  /*
580  * Initialize LCD to 8 bit memory mapped mode
581  */
582 
583  /* enable external SRAM (memory mapped lcd) and one wait state */
584  MCUCR = _BV(SRE) | _BV(SRW);
585 
586  /* reset LCD */
587  delay(16000); /* wait 16ms after power-on */
588  lcd_write(LCD_FUNCTION_8BIT_1LINE,0); /* function set: 8bit interface */
589  delay(4992); /* wait 5ms */
590  lcd_write(LCD_FUNCTION_8BIT_1LINE,0); /* function set: 8bit interface */
591  delay(64); /* wait 64us */
592  lcd_write(LCD_FUNCTION_8BIT_1LINE,0); /* function set: 8bit interface */
593  delay(64); /* wait 64us */
594 #endif
595 
596 #if KS0073_4LINES_MODE
597  /* Display with KS0073 controller requires special commands for enabling 4 line mode */
598  lcd_command(KS0073_EXTENDED_FUNCTION_REGISTER_ON);
599  lcd_command(KS0073_4LINES_MODE);
600  lcd_command(KS0073_EXTENDED_FUNCTION_REGISTER_OFF);
601 #else
602  lcd_command(LCD_FUNCTION_DEFAULT); /* function set: display lines */
603 #endif
604  lcd_command(LCD_DISP_OFF); /* display off */
605  lcd_clrscr(); /* display clear */
606  lcd_command(LCD_MODE_DEFAULT); /* set entry mode */
607  lcd_command(LCD_DISP_ON); /* display/cursor control */
608 
609 }/* lcd_init */
void lcd_puts_p(const char *progmem_s)
Display string from program memory without auto linefeed.
Definition: lcd.c:500
void lcd_gotoxy(uint8_t x, uint8_t y)
Set cursor to specified position.
Definition: lcd.c:380
#define LCD_DATA1_PIN
Definition: hardware.h:62
#define LCD_DATA0_PORT
Definition: hardware.h:57
#define LCD_DATA1_PORT
Definition: hardware.h:58
#define LCD_START_LINE2
Definition: lcd.h:68
void lcd_clrscr(void)
Clear display and set cursor to home position.
Definition: lcd.c:416
#define LCD_DATA3_PIN
Definition: hardware.h:64
#define LCD_E_PORT
Definition: hardware.h:69
#define LCD_DATA2_PORT
Definition: hardware.h:59
void lcd_home(void)
Set cursor to home position.
Definition: lcd.c:425
#define LCD_RS_PIN
Definition: hardware.h:66
#define LCD_START_LINE3
Definition: lcd.h:69
#define LCD_E_PIN
Definition: hardware.h:70
#define LCD_START_LINE1
Definition: lcd.h:67
void lcd_command(uint8_t cmd)
Send LCD controller instruction command.
Definition: lcd.c:354
#define LCD_DATA3_PORT
Definition: hardware.h:60
#define LCD_DISP_LENGTH
Definition: lcd.h:65
#define LCD_START_LINE4
Definition: lcd.h:70
#define LCD_RW_PORT
Definition: hardware.h:67
void lcd_data(uint8_t data)
Send data byte to LCD controller.
Definition: lcd.c:366
#define LCD_DATA2_PIN
Definition: hardware.h:63
#define LCD_RW_PIN
Definition: hardware.h:68
void lcd_puts(const char *s)
Display string without auto linefeed.
Definition: lcd.c:483
void lcd_init(void)
Initialize display and select type of cursor.
Definition: lcd.c:520
#define LCD_RS_PORT
Definition: hardware.h:65
void lcd_putc(char c)
Display character at current cursor position.
Definition: lcd.c:436
#define LCD_DATA0_PIN
Definition: hardware.h:61