41 }; |
40 }; |
42 |
41 |
43 extern struct lcdDataStruct *lcds [MAX_LCDS]; |
42 extern struct lcdDataStruct *lcds [MAX_LCDS]; |
44 extern sys_config Config; |
43 extern sys_config Config; |
45 |
44 |
46 |
|
47 |
|
48 /* |
|
49 * Some LCD functions are extended shadow copies of the wiringPi functions. |
|
50 * The difference is that the lcdbuf will be updated with the contents on |
|
51 * the hardware display. This copy can then be used for a remote display |
|
52 */ |
|
53 |
45 |
54 |
46 |
55 /* |
47 /* |
56 * setBacklight: |
48 * setBacklight: |
57 ********************************************************************************* |
49 ********************************************************************************* |
70 ********************************************************************************* |
62 ********************************************************************************* |
71 */ |
63 */ |
72 |
64 |
73 int initLCD (int cols, int rows) |
65 int initLCD (int cols, int rows) |
74 { |
66 { |
75 int x, y; |
|
76 |
|
77 if (!((rows == 1) || (rows == 2) || (rows == 4))) { |
67 if (!((rows == 1) || (rows == 2) || (rows == 4))) { |
78 fprintf (stderr, "rows must be 1, 2 or 4\n") ; |
68 fprintf (stderr, "rows must be 1, 2 or 4\n") ; |
79 return EXIT_FAILURE ; |
69 return EXIT_FAILURE ; |
80 } |
70 } |
81 |
71 |
96 fprintf (stderr, "lcdInit failed\n") ; |
86 fprintf (stderr, "lcdInit failed\n") ; |
97 return -1 ; |
87 return -1 ; |
98 } |
88 } |
99 |
89 |
100 lcdClear (lcdHandle) ; |
90 lcdClear (lcdHandle) ; |
101 for (x = 0; x < Config.lcd_cols; x++) |
|
102 for (y = 0; y < Config.lcd_rows; y++) |
|
103 lcdbuf[lcdHandle][x][y] = ' '; |
|
104 |
|
105 setBacklight (1) ; |
91 setBacklight (1) ; |
106 |
92 |
107 return 0 ; |
93 return 0 ; |
108 } |
94 } |
109 |
95 |
110 |
96 |
111 |
|
112 void mb_lcdPutchar(const int fd, unsigned char data) |
|
113 { |
|
114 struct lcdDataStruct *lcd = lcds[fd]; |
|
115 |
|
116 /* |
|
117 * Write to our buffer first, then to the wiringPi driver. |
|
118 * Writing to wiringPi updates the cursor position. |
|
119 */ |
|
120 lcdbuf[fd][lcd->cx][lcd->cy] = data; |
|
121 lcdPutchar(fd, data); |
|
122 } |
|
123 |
|
124 |
|
125 |
|
126 void mb_lcdPuts(const int fd, const char *string) |
|
127 { |
|
128 while (*string) |
|
129 mb_lcdPutchar (fd, *string++); |
|
130 } |
|
131 |
|
132 |
|
133 |
|
134 void mb_lcdClear(const int fd) |
|
135 { |
|
136 int x, y; |
|
137 |
|
138 lcdClear(fd); |
|
139 for (x = 0; x < Config.lcd_cols; x++) |
|
140 for (y = 0; y < Config.lcd_rows; y++) |
|
141 lcdbuf[fd][x][y] = ' '; |
|
142 } |
|
143 |
|
144 |
|
145 |
|
146 #endif |
97 #endif |
147 |
|