1 | #include <stdlib.h> |
---|
2 | #include <stdio.h> |
---|
3 | #include <unistd.h> |
---|
4 | #include <termios.h> |
---|
5 | #include <fcntl.h> |
---|
6 | #include <string.h> |
---|
7 | #include <errno.h> |
---|
8 | #include "lcd.h" |
---|
9 | #include "MtxOrb.h" |
---|
10 | #include "drv_base.h" |
---|
11 | |
---|
12 | #include "../../shared/debug.h" |
---|
13 | #include "../../shared/str.h" |
---|
14 | |
---|
15 | static int custom=0; |
---|
16 | typedef enum { |
---|
17 | hbar = 1, |
---|
18 | vbar = 2, |
---|
19 | bign = 4, |
---|
20 | beat = 8 } custom_type; |
---|
21 | |
---|
22 | static int fd; |
---|
23 | |
---|
24 | static void MtxOrb_linewrap(int on); |
---|
25 | static void MtxOrb_autoscroll(int on); |
---|
26 | |
---|
27 | // TODO: Get rid of this variable? |
---|
28 | lcd_logical_driver *MtxOrb; |
---|
29 | // TODO: Get the frame buffers working right |
---|
30 | |
---|
31 | ///////////////////////////////////////////////////////////////// |
---|
32 | // Opens com port and sets baud correctly... |
---|
33 | // |
---|
34 | int MtxOrb_init(lcd_logical_driver *driver, char *args) |
---|
35 | { |
---|
36 | char *argv[64]; |
---|
37 | int argc; |
---|
38 | struct termios portset; |
---|
39 | int i; |
---|
40 | int tmp; |
---|
41 | |
---|
42 | int contrast=140; |
---|
43 | char device[256] = "/dev/lcd"; |
---|
44 | int speed=B19200; |
---|
45 | |
---|
46 | MtxOrb = driver; |
---|
47 | |
---|
48 | |
---|
49 | //debug("MtxOrb_init: Args(all): %s\n", args); |
---|
50 | |
---|
51 | argc = get_args(argv, args, 64); |
---|
52 | |
---|
53 | /* |
---|
54 | for(i=0; i<argc; i++) |
---|
55 | { |
---|
56 | printf("Arg(%i): %s\n", i, argv[i]); |
---|
57 | } |
---|
58 | */ |
---|
59 | |
---|
60 | for(i=0; i<argc; i++) |
---|
61 | { |
---|
62 | //printf("Arg(%i): %s\n", i, argv[i]); |
---|
63 | if(0 == strcmp(argv[i], "-d") || |
---|
64 | 0 == strcmp(argv[i], "--device")) |
---|
65 | { |
---|
66 | if(i + 1 > argc) { |
---|
67 | fprintf(stderr, "MtxOrb_init: %s requires an argument\n", |
---|
68 | argv[i]); |
---|
69 | return -1; |
---|
70 | } |
---|
71 | strcpy(device, argv[++i]); |
---|
72 | } |
---|
73 | else if(0 == strcmp(argv[i], "-c") || |
---|
74 | 0 == strcmp(argv[i], "--contrast")) |
---|
75 | { |
---|
76 | if(i + 1 > argc) { |
---|
77 | fprintf(stderr, "MtxOrb_init: %s requires an argument\n", |
---|
78 | argv[i]); |
---|
79 | return -1; |
---|
80 | } |
---|
81 | tmp = atoi(argv[++i]); |
---|
82 | if((tmp < 0) || (tmp > 255)){ |
---|
83 | fprintf(stderr, "MtxOrb_init: %s argument must between 0 and 255. Ussing default value.\n", |
---|
84 | argv[i]); |
---|
85 | } else contrast = tmp; |
---|
86 | } |
---|
87 | else if(0 == strcmp(argv[i], "-s") || |
---|
88 | 0 == strcmp(argv[i], "--speed")) |
---|
89 | { |
---|
90 | if(i + 1 > argc) { |
---|
91 | fprintf(stderr, "MtxOrb_init: %s requires an argument\n", |
---|
92 | argv[i]); |
---|
93 | return -1; |
---|
94 | } |
---|
95 | tmp = atoi(argv[++i]); |
---|
96 | if(tmp==1200) speed=B1200; |
---|
97 | else if(tmp==2400) speed=B2400; |
---|
98 | else if(tmp==9600) speed=B9600; |
---|
99 | else if(tmp==19200) speed=B19200; |
---|
100 | else { |
---|
101 | fprintf(stderr, "MtxOrb_init: %s argument must be 1200, 2400, 9600 or 19200. Ussing default value.\n", |
---|
102 | argv[i]); |
---|
103 | } |
---|
104 | } |
---|
105 | else if(0 == strcmp(argv[i], "-h") || |
---|
106 | 0 == strcmp(argv[i], "--help")) |
---|
107 | { |
---|
108 | printf("LCDproc Matrix-Orbital LCD driver\n" |
---|
109 | "\t-d\t--device\tSelect the output device to use [/dev/lcd]\n" |
---|
110 | "\t-c\t--contrast\tSet the initial contrast [140]\n" |
---|
111 | "\t-s\t--speed\t\tSet the communication speed [19200]\n" |
---|
112 | "\t-h\t--help\t\tShow this help information\n"); |
---|
113 | return -1; |
---|
114 | } |
---|
115 | else |
---|
116 | { |
---|
117 | printf("Invalid parameter: %s\n", argv[i]); |
---|
118 | } |
---|
119 | |
---|
120 | } |
---|
121 | |
---|
122 | // Set up io port correctly, and open it... |
---|
123 | fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY); |
---|
124 | if (fd == -1) |
---|
125 | { |
---|
126 | fprintf(stderr, "MtxOrb_init: failed (%s)\n", strerror(errno)); |
---|
127 | return -1; |
---|
128 | } |
---|
129 | //else fprintf(stderr, "MtxOrb_init: opened device %s\n", device); |
---|
130 | tcgetattr(fd, &portset); |
---|
131 | // This is necessary in Linux, but does not exist in irix. |
---|
132 | #ifndef IRIX |
---|
133 | cfmakeraw(&portset); |
---|
134 | #endif |
---|
135 | cfsetospeed(&portset, speed); |
---|
136 | tcsetattr(fd, TCSANOW, &portset); |
---|
137 | |
---|
138 | |
---|
139 | // Set display-specific stuff.. |
---|
140 | MtxOrb_linewrap(1); |
---|
141 | MtxOrb_autoscroll(1); |
---|
142 | |
---|
143 | |
---|
144 | if(!driver->framebuf) |
---|
145 | { |
---|
146 | fprintf(stderr, "MtxOrb_init: No frame buffer.\n"); |
---|
147 | driver->close(); |
---|
148 | return -1; |
---|
149 | } |
---|
150 | |
---|
151 | |
---|
152 | // Set the functions the driver supports... |
---|
153 | |
---|
154 | driver->clear = (void *)-1; |
---|
155 | driver->string = (void *)-1; |
---|
156 | // driver->chr = MtxOrb_chr; |
---|
157 | driver->chr = (void *)-1; |
---|
158 | driver->vbar = MtxOrb_vbar; |
---|
159 | driver->init_vbar = MtxOrb_init_vbar; |
---|
160 | driver->hbar = MtxOrb_hbar; |
---|
161 | driver->init_hbar = MtxOrb_init_hbar; |
---|
162 | driver->num = MtxOrb_num; |
---|
163 | driver->init_num = MtxOrb_init_num; |
---|
164 | |
---|
165 | driver->init = MtxOrb_init; |
---|
166 | driver->close = MtxOrb_close; |
---|
167 | driver->flush = MtxOrb_flush; |
---|
168 | driver->flush_box = MtxOrb_flush_box; |
---|
169 | driver->contrast = MtxOrb_contrast; |
---|
170 | driver->backlight = MtxOrb_backlight; |
---|
171 | driver->set_char = MtxOrb_set_char; |
---|
172 | driver->icon = MtxOrb_icon; |
---|
173 | driver->draw_frame = MtxOrb_draw_frame; |
---|
174 | |
---|
175 | driver->getkey = MtxOrb_getkey; |
---|
176 | |
---|
177 | MtxOrb_contrast(contrast); |
---|
178 | |
---|
179 | return fd; |
---|
180 | } |
---|
181 | |
---|
182 | |
---|
183 | |
---|
184 | ///////////////////////////////////////////////////////////////// |
---|
185 | // Clean-up |
---|
186 | // |
---|
187 | void MtxOrb_close() |
---|
188 | { |
---|
189 | close (fd); |
---|
190 | |
---|
191 | if(MtxOrb->framebuf) free(MtxOrb->framebuf); |
---|
192 | |
---|
193 | MtxOrb->framebuf = NULL; |
---|
194 | } |
---|
195 | |
---|
196 | |
---|
197 | void MtxOrb_flush() |
---|
198 | { |
---|
199 | MtxOrb_draw_frame(lcd.framebuf); |
---|
200 | } |
---|
201 | |
---|
202 | |
---|
203 | |
---|
204 | void MtxOrb_flush_box(int lft, int top, int rgt, int bot) |
---|
205 | { |
---|
206 | int y; |
---|
207 | char out[LCD_MAX_WIDTH]; |
---|
208 | |
---|
209 | |
---|
210 | // printf("Flush (%i,%i)-(%i,%i)\n", lft, top, rgt, bot); |
---|
211 | |
---|
212 | for(y=top; y<=bot; y++) |
---|
213 | { |
---|
214 | sprintf(out, "%cG%c%c", 254, lft, y); |
---|
215 | write(fd, out, 4); |
---|
216 | write(fd, lcd.framebuf+(y*lcd.wid)+lft, rgt-lft+1); |
---|
217 | |
---|
218 | } |
---|
219 | |
---|
220 | |
---|
221 | } |
---|
222 | |
---|
223 | |
---|
224 | ///////////////////////////////////////////////////////////////// |
---|
225 | // Prints a character on the lcd display, at position (x,y). The |
---|
226 | // upper-left is (1,1), and the lower right should be (20,4). |
---|
227 | // |
---|
228 | void MtxOrb_chr(int x, int y, char c) |
---|
229 | { |
---|
230 | y--; |
---|
231 | x--; |
---|
232 | |
---|
233 | lcd.framebuf[(y*lcd.wid) + x] = c; |
---|
234 | } |
---|
235 | |
---|
236 | |
---|
237 | ///////////////////////////////////////////////////////////////// |
---|
238 | // Changes screen contrast (0-255; 140 seems good) |
---|
239 | // |
---|
240 | int MtxOrb_contrast(int contrast) |
---|
241 | { |
---|
242 | char out[4]; |
---|
243 | static int status=140; |
---|
244 | |
---|
245 | if(contrast > 0) |
---|
246 | { |
---|
247 | status=contrast; |
---|
248 | sprintf(out, "%cP%c", 254, status); |
---|
249 | write(fd, out, 3); |
---|
250 | } |
---|
251 | |
---|
252 | return status; |
---|
253 | } |
---|
254 | |
---|
255 | |
---|
256 | ///////////////////////////////////////////////////////////////// |
---|
257 | // Sets the backlight on or off -- can be done quickly for |
---|
258 | // an intermediate brightness... |
---|
259 | // |
---|
260 | void MtxOrb_backlight(int on) |
---|
261 | { |
---|
262 | char out[4]; |
---|
263 | if(on) |
---|
264 | { |
---|
265 | sprintf(out, "%cB%c", 254, 0); |
---|
266 | write(fd, out, 3); |
---|
267 | } |
---|
268 | else |
---|
269 | { |
---|
270 | sprintf(out, "%cF", 254); |
---|
271 | write(fd, out, 2); |
---|
272 | } |
---|
273 | } |
---|
274 | |
---|
275 | |
---|
276 | ///////////////////////////////////////////////////////////////// |
---|
277 | // Toggle the built-in linewrapping feature |
---|
278 | // |
---|
279 | static void MtxOrb_linewrap(int on) |
---|
280 | { |
---|
281 | char out[4]; |
---|
282 | if(on) |
---|
283 | sprintf(out, "%cC", 254); |
---|
284 | else |
---|
285 | sprintf(out, "%cD", 254); |
---|
286 | write(fd, out, 2); |
---|
287 | } |
---|
288 | |
---|
289 | ///////////////////////////////////////////////////////////////// |
---|
290 | // Toggle the built-in automatic scrolling feature |
---|
291 | // |
---|
292 | static void MtxOrb_autoscroll(int on) |
---|
293 | { |
---|
294 | char out[4]; |
---|
295 | if(on) |
---|
296 | sprintf(out, "%cQ", 254); |
---|
297 | else |
---|
298 | sprintf(out, "%cR", 254); |
---|
299 | write(fd, out, 2); |
---|
300 | } |
---|
301 | |
---|
302 | |
---|
303 | ///////////////////////////////////////////////////////////////// |
---|
304 | // Sets up for vertical bars. Call before lcd.vbar() |
---|
305 | // |
---|
306 | void MtxOrb_init_vbar() |
---|
307 | { |
---|
308 | char a[] = { |
---|
309 | 0,0,0,0,0, |
---|
310 | 0,0,0,0,0, |
---|
311 | 0,0,0,0,0, |
---|
312 | 0,0,0,0,0, |
---|
313 | 0,0,0,0,0, |
---|
314 | 0,0,0,0,0, |
---|
315 | 0,0,0,0,0, |
---|
316 | 1,1,1,1,1, |
---|
317 | }; |
---|
318 | char b[] = { |
---|
319 | 0,0,0,0,0, |
---|
320 | 0,0,0,0,0, |
---|
321 | 0,0,0,0,0, |
---|
322 | 0,0,0,0,0, |
---|
323 | 0,0,0,0,0, |
---|
324 | 0,0,0,0,0, |
---|
325 | 1,1,1,1,1, |
---|
326 | 1,1,1,1,1, |
---|
327 | }; |
---|
328 | char c[] = { |
---|
329 | 0,0,0,0,0, |
---|
330 | 0,0,0,0,0, |
---|
331 | 0,0,0,0,0, |
---|
332 | 0,0,0,0,0, |
---|
333 | 0,0,0,0,0, |
---|
334 | 1,1,1,1,1, |
---|
335 | 1,1,1,1,1, |
---|
336 | 1,1,1,1,1, |
---|
337 | }; |
---|
338 | char d[] = { |
---|
339 | 0,0,0,0,0, |
---|
340 | 0,0,0,0,0, |
---|
341 | 0,0,0,0,0, |
---|
342 | 0,0,0,0,0, |
---|
343 | 1,1,1,1,1, |
---|
344 | 1,1,1,1,1, |
---|
345 | 1,1,1,1,1, |
---|
346 | 1,1,1,1,1, |
---|
347 | }; |
---|
348 | char e[] = { |
---|
349 | 0,0,0,0,0, |
---|
350 | 0,0,0,0,0, |
---|
351 | 0,0,0,0,0, |
---|
352 | 1,1,1,1,1, |
---|
353 | 1,1,1,1,1, |
---|
354 | 1,1,1,1,1, |
---|
355 | 1,1,1,1,1, |
---|
356 | 1,1,1,1,1, |
---|
357 | }; |
---|
358 | char f[] = { |
---|
359 | 0,0,0,0,0, |
---|
360 | 0,0,0,0,0, |
---|
361 | 1,1,1,1,1, |
---|
362 | 1,1,1,1,1, |
---|
363 | 1,1,1,1,1, |
---|
364 | 1,1,1,1,1, |
---|
365 | 1,1,1,1,1, |
---|
366 | 1,1,1,1,1, |
---|
367 | }; |
---|
368 | char g[] = { |
---|
369 | 0,0,0,0,0, |
---|
370 | 1,1,1,1,1, |
---|
371 | 1,1,1,1,1, |
---|
372 | 1,1,1,1,1, |
---|
373 | 1,1,1,1,1, |
---|
374 | 1,1,1,1,1, |
---|
375 | 1,1,1,1,1, |
---|
376 | 1,1,1,1,1, |
---|
377 | }; |
---|
378 | |
---|
379 | if(custom!=vbar) { |
---|
380 | MtxOrb_set_char(1,a); |
---|
381 | MtxOrb_set_char(2,b); |
---|
382 | MtxOrb_set_char(3,c); |
---|
383 | MtxOrb_set_char(4,d); |
---|
384 | MtxOrb_set_char(5,e); |
---|
385 | MtxOrb_set_char(6,f); |
---|
386 | MtxOrb_set_char(7,g); |
---|
387 | custom=vbar; |
---|
388 | } |
---|
389 | } |
---|
390 | |
---|
391 | ///////////////////////////////////////////////////////////////// |
---|
392 | // Inits horizontal bars... |
---|
393 | // |
---|
394 | void MtxOrb_init_hbar() |
---|
395 | { |
---|
396 | |
---|
397 | char a[] = { |
---|
398 | 1,0,0,0,0, |
---|
399 | 1,0,0,0,0, |
---|
400 | 1,0,0,0,0, |
---|
401 | 1,0,0,0,0, |
---|
402 | 1,0,0,0,0, |
---|
403 | 1,0,0,0,0, |
---|
404 | 1,0,0,0,0, |
---|
405 | 1,0,0,0,0, |
---|
406 | }; |
---|
407 | char b[] = { |
---|
408 | 1,1,0,0,0, |
---|
409 | 1,1,0,0,0, |
---|
410 | 1,1,0,0,0, |
---|
411 | 1,1,0,0,0, |
---|
412 | 1,1,0,0,0, |
---|
413 | 1,1,0,0,0, |
---|
414 | 1,1,0,0,0, |
---|
415 | 1,1,0,0,0, |
---|
416 | }; |
---|
417 | char c[] = { |
---|
418 | 1,1,1,0,0, |
---|
419 | 1,1,1,0,0, |
---|
420 | 1,1,1,0,0, |
---|
421 | 1,1,1,0,0, |
---|
422 | 1,1,1,0,0, |
---|
423 | 1,1,1,0,0, |
---|
424 | 1,1,1,0,0, |
---|
425 | 1,1,1,0,0, |
---|
426 | }; |
---|
427 | char d[] = { |
---|
428 | 1,1,1,1,0, |
---|
429 | 1,1,1,1,0, |
---|
430 | 1,1,1,1,0, |
---|
431 | 1,1,1,1,0, |
---|
432 | 1,1,1,1,0, |
---|
433 | 1,1,1,1,0, |
---|
434 | 1,1,1,1,0, |
---|
435 | 1,1,1,1,0, |
---|
436 | }; |
---|
437 | |
---|
438 | if(custom!=hbar) { |
---|
439 | MtxOrb_set_char(1,a); |
---|
440 | MtxOrb_set_char(2,b); |
---|
441 | MtxOrb_set_char(3,c); |
---|
442 | MtxOrb_set_char(4,d); |
---|
443 | custom=hbar; |
---|
444 | } |
---|
445 | } |
---|
446 | |
---|
447 | ///////////////////////////////////////////////////////////////// |
---|
448 | // Draws a vertical bar... |
---|
449 | // |
---|
450 | void MtxOrb_vbar(int x, int len) |
---|
451 | { |
---|
452 | char map[9] = {32, 1, 2, 3, 4, 5, 6, 7, 255 }; |
---|
453 | |
---|
454 | |
---|
455 | int y; |
---|
456 | for(y=lcd.hgt; y > 0 && len>0; y--) |
---|
457 | { |
---|
458 | if(len >= lcd.cellhgt) MtxOrb_chr(x, y, 255); |
---|
459 | else MtxOrb_chr(x, y, map[len]); |
---|
460 | |
---|
461 | len -= lcd.cellhgt; |
---|
462 | } |
---|
463 | |
---|
464 | } |
---|
465 | |
---|
466 | ///////////////////////////////////////////////////////////////// |
---|
467 | // Draws a horizontal bar to the right. |
---|
468 | // |
---|
469 | void MtxOrb_hbar(int x, int y, int len) |
---|
470 | { |
---|
471 | char map[6] = { 32, 1, 2, 3, 4, 255 }; |
---|
472 | |
---|
473 | for(; x<=lcd.wid && len>0; x++) |
---|
474 | { |
---|
475 | if(len >= lcd.cellwid) MtxOrb_chr(x,y,255); |
---|
476 | else MtxOrb_chr(x, y, map[len]); |
---|
477 | |
---|
478 | len -= lcd.cellwid; |
---|
479 | |
---|
480 | } |
---|
481 | |
---|
482 | } |
---|
483 | |
---|
484 | |
---|
485 | ///////////////////////////////////////////////////////////////// |
---|
486 | // Sets up for big numbers. |
---|
487 | // |
---|
488 | void MtxOrb_init_num() |
---|
489 | { |
---|
490 | char out[3]; |
---|
491 | if(custom!=bign) { |
---|
492 | sprintf(out, "%cn", 254); |
---|
493 | write(fd, out, 2); |
---|
494 | custom=bign; |
---|
495 | } |
---|
496 | } |
---|
497 | |
---|
498 | |
---|
499 | ///////////////////////////////////////////////////////////////// |
---|
500 | // Writes a big number. |
---|
501 | // |
---|
502 | void MtxOrb_num(int x, int num) |
---|
503 | { |
---|
504 | char out[5]; |
---|
505 | sprintf(out, "%c#%c%c", 254, x, num); |
---|
506 | write(fd, out, 4); |
---|
507 | } |
---|
508 | |
---|
509 | |
---|
510 | ///////////////////////////////////////////////////////////////// |
---|
511 | // Sets a custom character from 0-7... |
---|
512 | // |
---|
513 | // For input, values > 0 mean "on" and values <= 0 are "off". |
---|
514 | // |
---|
515 | // The input is just an array of characters... |
---|
516 | // |
---|
517 | void MtxOrb_set_char(int n, char *dat) |
---|
518 | { |
---|
519 | char out[4]; |
---|
520 | int row, col; |
---|
521 | int letter; |
---|
522 | |
---|
523 | if(n < 0 || n > 7) return; |
---|
524 | if(!dat) return; |
---|
525 | |
---|
526 | sprintf(out, "%cN%c", 254, n); |
---|
527 | write(fd, out, 3); |
---|
528 | |
---|
529 | |
---|
530 | for(row=0; row<lcd.cellhgt; row++) |
---|
531 | { |
---|
532 | letter = 0; |
---|
533 | for(col=0; col<lcd.cellwid; col++) |
---|
534 | { |
---|
535 | letter <<= 1; |
---|
536 | letter |= (dat[(row*lcd.cellwid) + col] > 0); |
---|
537 | } |
---|
538 | write(fd, &letter, 1); |
---|
539 | } |
---|
540 | } |
---|
541 | |
---|
542 | |
---|
543 | void MtxOrb_icon(int which, char dest) |
---|
544 | { |
---|
545 | char icons[3][5*8] = { |
---|
546 | { |
---|
547 | 1,1,1,1,1, // Empty Heart |
---|
548 | 1,0,1,0,1, |
---|
549 | 0,0,0,0,0, |
---|
550 | 0,0,0,0,0, |
---|
551 | 0,0,0,0,0, |
---|
552 | 1,0,0,0,1, |
---|
553 | 1,1,0,1,1, |
---|
554 | 1,1,1,1,1, |
---|
555 | }, |
---|
556 | |
---|
557 | { |
---|
558 | 1,1,1,1,1, // Filled Heart |
---|
559 | 1,0,1,0,1, |
---|
560 | 0,1,0,1,0, |
---|
561 | 0,1,1,1,0, |
---|
562 | 0,1,1,1,0, |
---|
563 | 1,0,1,0,1, |
---|
564 | 1,1,0,1,1, |
---|
565 | 1,1,1,1,1, |
---|
566 | }, |
---|
567 | |
---|
568 | { |
---|
569 | 0,0,0,0,0, // Ellipsis |
---|
570 | 0,0,0,0,0, |
---|
571 | 0,0,0,0,0, |
---|
572 | 0,0,0,0,0, |
---|
573 | 0,0,0,0,0, |
---|
574 | 0,0,0,0,0, |
---|
575 | 0,0,0,0,0, |
---|
576 | 1,0,1,0,1, |
---|
577 | }, |
---|
578 | |
---|
579 | }; |
---|
580 | |
---|
581 | if(custom==bign) custom=beat; |
---|
582 | MtxOrb_set_char(dest, &icons[which][0]); |
---|
583 | } |
---|
584 | |
---|
585 | |
---|
586 | ///////////////////////////////////////////////////////////// |
---|
587 | // Blasts a single frame onscreen, to the lcd... |
---|
588 | // |
---|
589 | // Input is a character array, sized lcd.wid*lcd.hgt |
---|
590 | // |
---|
591 | void MtxOrb_draw_frame(char *dat) |
---|
592 | { |
---|
593 | char out[LCD_MAX_WIDTH * LCD_MAX_HEIGHT]; |
---|
594 | |
---|
595 | if(!dat) return; |
---|
596 | |
---|
597 | sprintf(out, "%cG%c%c", 254, 1, 1); |
---|
598 | write(fd, out, 4); |
---|
599 | write(fd, dat, lcd.wid*lcd.hgt); |
---|
600 | |
---|
601 | } |
---|
602 | |
---|
603 | |
---|
604 | |
---|
605 | ///////////////////////////////////////////////////////////// |
---|
606 | // returns one character from the keypad... |
---|
607 | // (A-Z) on success, 0 on failure... |
---|
608 | // |
---|
609 | char MtxOrb_getkey() |
---|
610 | { |
---|
611 | char in = 0; |
---|
612 | read(fd, &in, 1); |
---|
613 | return in; |
---|
614 | } |
---|
615 | |
---|
616 | void MtxOrb_led(int which, int on) |
---|
617 | { |
---|
618 | char out[4]; |
---|
619 | |
---|
620 | if(which < 0 || which > 7) return; |
---|
621 | |
---|
622 | if(!which){ |
---|
623 | if(on) |
---|
624 | sprintf(out, "%cV", 254); |
---|
625 | else |
---|
626 | sprintf(out, "%cW", 254); |
---|
627 | write(fd, out, 2); |
---|
628 | } |
---|
629 | else{ |
---|
630 | if(on) |
---|
631 | sprintf(out, "%cV%c", 254, which); |
---|
632 | else |
---|
633 | sprintf(out, "%cW%c", 254, which); |
---|
634 | write(fd, out, 3); |
---|
635 | } |
---|
636 | } |
---|
637 | |
---|