3 * Text-based LCD driver.
4 * This is designed to drive the parallel interface LCD drivers
5 * based in the Hitachi HD44780U controller and compatables.
7 * Copyright (c) 2012 Gordon Henderson.
8 ***********************************************************************
9 * This file is part of wiringPi:
10 * https://projects.drogon.net/raspberry-pi/wiringpi/
12 * wiringPi is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
17 * wiringPi is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
24 ***********************************************************************
51 printf ("Raspberry Pi LCD test program\n") ;
53 if (wiringPiSetup () == -1)
56 fd1 = lcdInit (4, 20, 4, 8, 9, 4,5,6,7,0,0,0,0) ;
57 fd2 = lcdInit (2, 16, 4, 8, 10, 4,5,6,7,0,0,0,0) ;
59 //fd1 = lcdInit (4, 20, 8, 8, 9, 0,1,2,3,4,5,6,7) ;
60 //fd2 = lcdInit (2, 16, 8, 8, 10, 0,1,2,3,4,5,6,7) ;
64 printf ("lcdInit 1 failed\n") ;
70 printf ("lcdInit 2 failed\n") ;
76 lcdPosition (fd1, 0, 0) ; lcdPuts (fd1, " Gordon Henderson") ;
77 lcdPosition (fd1, 0, 1) ; lcdPuts (fd1, " --------------") ;
79 lcdPosition (fd1, 0, 2) ; lcdPuts (fd1, " 00:00:00") ;
80 lcdPosition (fd1, 0, 3) ; lcdPuts (fd1, " DD:MM:YY") ;
83 lcdPosition (fd2, 0, 0) ; lcdPuts (fd2, "Gordon Henderson") ;
84 lcdPosition (fd2, 0, 1) ; lcdPuts (fd2, "----------------") ;
88 sprintf (message1, "%s", " http://projects.drogon.net/ ") ;
89 sprintf (message2, "%s", " This is a long message to go into the smaller display just for a demonstration of what we can do. ") ;
97 strncpy (buf1, &message1 [i], 20) ;
99 lcdPosition (fd1, 0, 1) ;
100 lcdPuts (fd1, buf1) ;
102 if (i == strlen (message1) - 20)
105 strncpy (buf2, &message2 [j], 16) ;
107 lcdPosition (fd2, 0, 1) ;
108 lcdPuts (fd2, buf2) ;
110 if (j == strlen (message2) - 16)
114 t = localtime (&tim) ;
116 sprintf (buf1, "%02d:%02d:%02d", t->tm_hour, t->tm_min, t->tm_sec) ;
117 lcdPosition (fd1, 5, 2) ;
118 lcdPuts (fd1, buf1) ;
120 sprintf (buf1, "%02d/%02d/%02d", t->tm_mday, t->tm_mon + 1, t->tm_year+1900) ;
121 lcdPosition (fd1, 4, 3) ;
122 lcdPuts (fd1, buf1) ;