3 * Demo of the 128x64 graphics based LCD driver.
4 * This is designed to drive the parallel interface LCD drivers
5 * based on the popular 12864H controller chip.
7 * This test program assumes the following:
8 * (Which is currently hard-wired into the driver)
10 * GPIO 0-7 is connected to display data pins 0-7.
16 * Copyright (c) 2012-2013 Gordon Henderson.
17 ***********************************************************************
18 * This file is part of wiringPi:
19 * https://projects.drogon.net/raspberry-pi/wiringpi/
21 * wiringPi is free software: you can redistribute it and/or modify
22 * it under the terms of the GNU Lesser General Public License as published by
23 * the Free Software Foundation, either version 3 of the License, or
24 * (at your option) any later version.
26 * wiringPi is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU Lesser General Public License for more details.
31 * You should have received a copy of the GNU Lesser General Public License
32 * along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
33 ***********************************************************************
46 #include <lcd128x64.h>
54 double thickness, barLen ;
57 double rads (double degs)
59 return degs * M_PI / 180.0 ;
62 void drawClockHands (void)
66 double angle, p, x0, y0, x1, y1 ;
71 now = localtime (&t) ;
83 angle = h * 30 + m * 0.5 ;
84 x0 = sin (rads (angle)) * (clockRadius * 0.75) ;
85 y0 = cos (rads (angle)) * (clockRadius * 0.75) ;
86 for (p = -3.0 ; p <= 3.0 ; p += 0.2)
88 x1 = sin (rads (angle + p)) * (clockRadius * 0.7) ;
89 y1 = cos (rads (angle + p)) * (clockRadius * 0.7) ;
90 lcd128x64line (0, 0, x1, y1, 1) ;
91 lcd128x64lineTo (x0, y0, 1) ;
97 x0 = sin (rads (angle)) * (clockRadius * 0.9) ;
98 y0 = cos (rads (angle)) * (clockRadius * 0.9) ;
99 for (p = -1.0 ; p <= 1.0 ; p += 0.2)
101 x1 = sin (rads (angle + p)) * (clockRadius * 0.85) ;
102 y1 = cos (rads (angle + p)) * (clockRadius * 0.85) ;
103 lcd128x64line (0, 0, x1, y1, 1) ;
104 lcd128x64lineTo (x0, y0, 1) ;
110 x0 = sin (rads (angle)) * (clockRadius * 0.2) ;
111 y0 = cos (rads (angle)) * (clockRadius * 0.2) ;
112 x1 = sin (rads (angle)) * (clockRadius * 0.95) ;
113 y1 = cos (rads (angle)) * (clockRadius * 0.95) ;
114 lcd128x64line (0 - x0, 0 - y0, x1, y1, 1) ;
115 lcd128x64circle (0, 0, clockRadius * 0.1, 0, 1) ;
116 lcd128x64circle (0, 0, clockRadius * 0.05, 1, 1) ;
120 sprintf (text, "%02d:%02d:%02d", h24, m, s) ;
121 lcd128x64puts (32, 24, text, 0, 1) ;
123 sprintf (text, "%2d/%2d/%2d", now->tm_mday, now->tm_mon + 1, now->tm_year - 100) ;
124 lcd128x64puts (32, -23, text, 0, 1) ;
127 void drawClockFace (void)
130 double d, px1, py1, px2, py2 ;
133 lcd128x64circle (0,0, clockRadius, 1, TRUE) ;
134 lcd128x64circle (0,0, clockRadius - thickness, 0, TRUE) ;
136 // The four big indicators for 12,15,30 and 45
138 lcd128x64rectangle (- 3, clockRadius - barLen, 3, clockRadius, 1, TRUE) ; // 12
139 lcd128x64rectangle (clockRadius - barLen, 3, clockRadius, -3, 1, TRUE) ; // 3
140 lcd128x64rectangle (- 3, -clockRadius + barLen, 3, -clockRadius, 1, TRUE) ; // 6
141 lcd128x64rectangle (-clockRadius + barLen, 3, -clockRadius, -3, 1, TRUE) ; // 9
144 // Smaller 5 and 1 minute ticks
146 for (m = 0 ; m < 60 ; ++m)
148 px1 = sin (rads (m * 6)) * clockRadius ;
149 py1 = cos (rads (m * 6)) * clockRadius ;
155 px2 = sin (rads (m * 6)) * (clockRadius - d) ;
156 py2 = cos (rads (m * 6)) * (clockRadius - d) ;
157 lcd128x64line (px1, py1, px2, py2, 1) ;
163 lcd128x64getScreenSize (&maxX, &maxY) ;
164 clockRadius = maxY / 2 - 1 ;
165 thickness = maxX / 48 ;
166 barLen = thickness * 4 ;
167 lcd128x64setOrigin (32, 32) ;
174 ***********************************************************************
176 ***********************************************************************
179 int main (int argc, char *argv [])
195 while (time (NULL) == now)