FreeCalypso > hg > freecalypso-tools
comparison target-utils/lunadrv/lcdout.c @ 700:db9a8e88e63f
target-utils lunadrv program written, compiles
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 07 May 2020 02:19:51 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
699:c354c261f635 | 700:db9a8e88e63f |
---|---|
1 /* | |
2 * Generic LCD output operations are implemented here. All of the basic | |
3 * LCD controller registers needed for these operations are the same | |
4 * between ILI9225, ILI9225G and ST7775R controllers. | |
5 */ | |
6 | |
7 #include <sys/types.h> | |
8 #include "types.h" | |
9 #include "luna.h" | |
10 | |
11 set_lcd_addr_region(xstart, xend, ystart, yend) | |
12 { | |
13 /* set window area */ | |
14 LCD_REG_WR(0x36, xend); | |
15 LCD_REG_WR(0x37, xstart); | |
16 LCD_REG_WR(0x38, yend); | |
17 LCD_REG_WR(0x39, ystart); | |
18 /* set current write address */ | |
19 LCD_REG_WR(0x20, xstart); | |
20 LCD_REG_WR(0x21, ystart); | |
21 /* set up for GRAM write */ | |
22 LCD_IR = 0x22; | |
23 } | |
24 | |
25 void | |
26 cmd_fill(argbulk) | |
27 char *argbulk; | |
28 { | |
29 char *argv[2]; | |
30 u_long pixval; | |
31 unsigned n; | |
32 | |
33 if (parse_args(argbulk, 1, 1, argv, 0) < 0) | |
34 return; | |
35 if (parse_hexarg(argv[0], 4, &pixval) < 0) { | |
36 printf("ERROR: arg must be a valid 16-bit hex value\n"); | |
37 return; | |
38 } | |
39 set_lcd_addr_region(0, 175, 0, 219); | |
40 for (n = 0; n < 176 * 220; n++) | |
41 LCD_DR = pixval; | |
42 } | |
43 | |
44 void | |
45 cmd_rect(argbulk) | |
46 char *argbulk; | |
47 { | |
48 char *argv[6]; | |
49 u_long pixval; | |
50 int xstart, xend, ystart, yend; | |
51 int npix; | |
52 | |
53 if (parse_args(argbulk, 5, 5, argv, 0) < 0) | |
54 return; | |
55 xstart = atoi(argv[0]); | |
56 if (xstart < 0 || xstart > 175) { | |
57 range_err: printf("ERROR: coordinate arg out of range\n"); | |
58 return; | |
59 } | |
60 xend = atoi(argv[1]); | |
61 if (xend < 0 || xend > 175) | |
62 goto range_err; | |
63 ystart = atoi(argv[2]); | |
64 if (ystart < 0 || ystart > 219) | |
65 goto range_err; | |
66 yend = atoi(argv[3]); | |
67 if (yend < 0 || yend > 219) | |
68 goto range_err; | |
69 if (xend < xstart || yend < ystart) { | |
70 printf("ERROR: negative range\n"); | |
71 return; | |
72 } | |
73 if (parse_hexarg(argv[4], 4, &pixval) < 0) { | |
74 printf("ERROR: pixel arg must be a valid 16-bit hex value\n"); | |
75 return; | |
76 } | |
77 set_lcd_addr_region(xstart, xend, ystart, yend); | |
78 npix = (xend + 1 - xstart) * (yend + 1 - ystart); | |
79 while (npix--) | |
80 LCD_DR = pixval; | |
81 } | |
82 | |
83 void | |
84 cmd_mem2lcd(argbulk) | |
85 char *argbulk; | |
86 { | |
87 char *argv[2]; | |
88 u_long addr; | |
89 const u16 *rdmem; | |
90 unsigned n; | |
91 | |
92 if (parse_args(argbulk, 1, 1, argv, 0) < 0) | |
93 return; | |
94 if (parse_hexarg(argv[0], 8, &addr) < 0) { | |
95 printf("ERROR: argument must be a valid 32-bit hex address\n"); | |
96 return; | |
97 } | |
98 if (addr & 1) { | |
99 printf("ERROR: unaligned address\n"); | |
100 return; | |
101 } | |
102 rdmem = (const u16 *) addr; | |
103 set_lcd_addr_region(0, 175, 0, 219); | |
104 for (n = 0; n < 176 * 220; n++) | |
105 LCD_DR = *rdmem++; | |
106 } |