comparison target-utils/c139explore/lcd.c @ 950:cd34e0d534b9

c139explore: LCD output implemented, does not work
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Wed, 04 Nov 2015 01:43:44 +0000
parents
children eb27543ce18e
comparison
equal deleted inserted replaced
949:df1dccc0ef9c 950:cd34e0d534b9
1 #include <sys/types.h>
2 #include "types.h"
3
4 static void
5 send_cmd_data(cmdbyte, databyte)
6 {
7 send_via_uwire(cmdbyte);
8 send_via_uwire(databyte | 0x100);
9 }
10
11 void
12 cmd_lcdinit()
13 {
14 /* from OsmocomBB */
15 send_cmd_data(0x3F, 0x01);
16 send_cmd_data(0x20, 0x03);
17 send_cmd_data(0x31, 0x03);
18 }
19
20 static void
21 set_lcd_addr_region(xstart, xend, ystart, yend)
22 {
23 send_cmd_data(0x10, xstart);
24 send_cmd_data(0x11, ystart);
25 send_cmd_data(0x12, xend);
26 send_cmd_data(0x13, yend);
27 send_cmd_data(0x14, xstart);
28 send_cmd_data(0x15, ystart);
29 }
30
31 static void
32 send_pixel_value(pix)
33 {
34 send_via_uwire((pix >> 8) | 0x100);
35 send_via_uwire((pix & 0xFF) | 0x100);
36 }
37
38 void
39 cmd_lcdfill(argbulk)
40 char *argbulk;
41 {
42 int argc;
43 char *argv[6];
44 u_long pixval;
45 int xstart, xend, ystart, yend;
46 int npix;
47
48 if (parse_args(argbulk, 1, 5, argv, &argc) < 0)
49 return;
50 if (parse_hexarg(argv[0], 4, &pixval) < 0) {
51 printf("ERROR: arg1 must be a valid 16-bit hex value\n");
52 return;
53 }
54 switch (argc) {
55 case 1:
56 xstart = ystart = 0;
57 xend = 95;
58 yend = 63;
59 break;
60 case 5:
61 xstart = atoi(argv[1]);
62 if (xstart < 0 || xstart > 95) {
63 range_err: printf("ERROR: coordinate arg out of range\n");
64 return;
65 }
66 xend = atoi(argv[2]);
67 if (xend < 0 || xend > 95)
68 goto range_err;
69 ystart = atoi(argv[3]);
70 if (ystart < 0 || ystart > 63)
71 goto range_err;
72 yend = atoi(argv[4]);
73 if (yend < 0 || yend > 63)
74 goto range_err;
75 if (xend < xstart || yend < ystart) {
76 printf("ERROR: negative range\n");
77 return;
78 }
79 break;
80 default:
81 printf("ERROR: wrong number of arguments\n");
82 return;
83 }
84 set_lcd_addr_region(xstart, xend, ystart, yend);
85 npix = (xend + 1 - xstart) * (yend + 1 - ystart);
86 while (npix--)
87 send_pixel_value(pixval);
88 }