annotate target-utils/pirexplore/lcd.c @ 1034:405b5469abc4 default tip

top README: repository change notice
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 12 Jun 2016 19:06:34 +0000
parents b26b7459bd44
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
78
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
1 /*
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
2 * Almost all of this Pirelli LCD black magic has been lifted from OsmocomBB.
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
3 */
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
4
74
8138a6380ae3 pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 #include <sys/types.h>
8138a6380ae3 pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include "types.h"
8138a6380ae3 pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7
76
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
8 #define GPIO_OUT_REG (*(volatile u16 *)0xFFFE4802)
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
9 #define nCS4_ADDR0 (*(volatile u16 *)0x02800000)
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
10 #define nCS4_ADDR2 (*(volatile u16 *)0x02800002)
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
11
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
12 fb_spca_write(addr, data)
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
13 {
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
14 GPIO_OUT_REG &= 0xFF7F;
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
15 nCS4_ADDR0 = addr;
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
16 nCS4_ADDR2 = data;
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
17 }
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
18
74
8138a6380ae3 pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 void
8138a6380ae3 pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 cmd_spca(argbulk)
8138a6380ae3 pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 char *argbulk;
8138a6380ae3 pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 {
8138a6380ae3 pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 char *argv[3];
8138a6380ae3 pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 u_long addr, data;
8138a6380ae3 pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25
8138a6380ae3 pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 if (parse_args(argbulk, 2, 2, argv, 0) < 0)
8138a6380ae3 pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 return;
8138a6380ae3 pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 if (parse_hexarg(argv[0], 4, &addr) < 0) {
8138a6380ae3 pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 printf("ERROR: arg1 must be a valid 16-bit hex value\n");
8138a6380ae3 pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 return;
8138a6380ae3 pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 }
8138a6380ae3 pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 if (parse_hexarg(argv[1], 4, &data) < 0) {
8138a6380ae3 pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 printf("ERROR: arg2 must be a valid 16-bit hex value\n");
8138a6380ae3 pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 return;
8138a6380ae3 pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 }
76
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
36 fb_spca_write(addr, data);
74
8138a6380ae3 pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 }
76
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
38
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
39 void
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
40 cmd_spcainit()
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
41 {
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
42 /*
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
43 * Apparently we have to give it a reset pulse, then immediately
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
44 * do the black magic register write sequence.
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
45 */
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
46 GPIO_OUT_REG = 0x0000;
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
47 GPIO_OUT_REG = 0x0012;
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
48 /* non-understandable voodoo copied from OsmocomBB */
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
49 fb_spca_write(0x7e, 0x00); /* internal register access */
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
50 osmo_delay_ms(10);
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
51 fb_spca_write(0x7a, 0x00); /* keep CPU in reset state */
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
52 osmo_delay_ms(10);
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
53 fb_spca_write(0x7f, 0x00); /* select main page */
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
54 osmo_delay_ms(5);
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
55 fb_spca_write(0x72, 0x07); /* don't reshape timing, 16 bit mode */
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
56 fb_spca_write(0x14, 0x03);
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
57 fb_spca_write(0x7f, 0x00); /* select main page */
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
58 osmo_delay_ms(5);
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
59 fb_spca_write(0x06, 0xff);
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
60 fb_spca_write(0x7f, 0x09);
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
61 fb_spca_write(0x19, 0x08); /* backlight: 0x08 is on, 0x0c is off */
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
62 fb_spca_write(0x23, 0x18);
07b686248ab7 pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 74
diff changeset
63 }
77
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
64
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
65 enum s6b33b1x_cmdflag { CMD, DATA, END };
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
66
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
67 struct s6b33b1x_cmdlist {
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
68 enum s6b33b1x_cmdflag is_cmd:8; /* 1: is a command, 0: is data, 2: end marker! */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
69 u_char data; /* 8 bit to send to LC display */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
70 };
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
71
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
72 static const struct s6b33b1x_cmdlist
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
73 s6b33b1x_initdata[] = {
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
74 { CMD, 0x26 }, /* CMD DCDC and AMP ON/OFF set */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
75 { DATA, 0x00 }, /* DATA: everything off */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
76 { CMD, 0x02 }, /* CMD Oscillation Mode Set */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
77 { DATA, 0x00 }, /* DATA: oscillator off */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
78 { CMD, 0x2c }, /* CMD Standby Mode off */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
79 { CMD, 0x50 }, /* CMD Display off */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
80 { CMD, 0x02 }, /* CMD Oscillation Mode Set */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
81 { DATA, 0x01 }, /* DATA: oscillator on */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
82 { CMD, 0x26 }, /* CMD DCDC and AMP ON/OFF set */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
83 { DATA, 0x01 }, /* DATA: Booster 1 on */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
84 { CMD, 0x26 }, /* CMD DCDC and AMP ON/OFF set */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
85 { DATA, 0x09 }, /* DATA: Booster 1 on, OP-AMP on */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
86 { CMD, 0x26 }, /* CMD DCDC and AMP ON/OFF set */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
87 { DATA, 0x0b }, /* DATA: Booster 1 + 2 on, OP-AMP on */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
88 { CMD, 0x26 }, /* CMD DCDC and AMP ON/OFF set */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
89 { DATA, 0x0f }, /* DATA: Booster 1 + 2 + 3 on, OP-AMP on */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
90 { CMD, 0x20 }, /* CMD DC-DC Select */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
91 { DATA, 0x01 }, /* DATA: step up x1.5 */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
92 { CMD, 0x24 }, /* CMD DCDC Clock Division Set */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
93 { DATA, 0x0a }, /* DATA: fPCK = fOSC/6 */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
94 { CMD, 0x2a }, /* CMD Contrast Control */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
95 { DATA, 0x2d }, /* DATA: default contrast */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
96 { CMD, 0x30 }, /* CMD Adressing mode set */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
97 { DATA, 0x0b }, /* DATA: 65536 color mode */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
98 { CMD, 0x10 }, /* CMD Driver output mode set */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
99 { DATA, 0x03 }, /* DATA: Display duty: 1/132 */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
100 { CMD, 0x34 }, /* CMD N-line inversion set */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
101 { DATA, 0x88 }, /* DATA: inversion on, one frame, every 8 blocks */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
102 { CMD, 0x40 }, /* CMD Entry mode set */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
103 { DATA, 0x00 }, /* DATA: Y address counter mode */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
104 { CMD, 0x28 }, /* CMD Temperature Compensation set */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
105 { DATA, 0x01 }, /* DATA: slope -0.05%/degC */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
106 { CMD, 0x32 }, /* CMD ROW vector mode set */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
107 { DATA, 0x01 }, /* DATA: every 2 subgroup */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
108 { CMD, 0x51 }, /* CMD Display on */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
109 { END, 0x00 }, /* MARKER: end of list */
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
110 };
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
111
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
112 static void
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
113 fb_s6b33b1x_send_cmdlist(p)
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
114 struct s6b33b1x_cmdlist *p;
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
115 {
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
116 while(p->is_cmd != END) {
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
117 nCS4_ADDR0 = p->data;
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
118 p++;
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
119 }
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
120 }
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
121
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
122 void
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
123 cmd_lcdinit()
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
124 {
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
125 GPIO_OUT_REG |= 0x0080;
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
126 fb_s6b33b1x_send_cmdlist(s6b33b1x_initdata);
fcbe1332b197 pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 76
diff changeset
127 }
78
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
128
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
129 set_lcd_addr_region(xstart, xend, ystart, yend)
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
130 {
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
131 GPIO_OUT_REG |= 0x0080;
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
132 nCS4_ADDR0 = 0x42;
104
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
133 nCS4_ADDR0 = ystart + 4;
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
134 nCS4_ADDR0 = yend + 4;
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
135 nCS4_ADDR0 = 0x43;
78
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
136 nCS4_ADDR0 = xstart;
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
137 nCS4_ADDR0 = xend;
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
138 }
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
139
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
140 void
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
141 cmd_lcdfill(argbulk)
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
142 char *argbulk;
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
143 {
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
144 int argc;
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
145 char *argv[6];
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
146 u_long pixval;
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
147 int xstart, xend, ystart, yend;
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
148 int npix;
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
149
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
150 if (parse_args(argbulk, 1, 5, argv, &argc) < 0)
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
151 return;
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
152 if (parse_hexarg(argv[0], 4, &pixval) < 0) {
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
153 printf("ERROR: arg1 must be a valid 16-bit hex value\n");
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
154 return;
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
155 }
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
156 switch (argc) {
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
157 case 1:
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
158 xstart = ystart = 0;
104
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
159 xend = yend = 127;
78
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
160 break;
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
161 case 5:
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
162 xstart = atoi(argv[1]);
104
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
163 if (xstart < 0 || xstart > 127) {
78
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
164 range_err: printf("ERROR: coordinate arg out of range\n");
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
165 return;
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
166 }
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
167 xend = atoi(argv[2]);
104
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
168 if (xend < 0 || xend > 127)
78
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
169 goto range_err;
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
170 ystart = atoi(argv[3]);
104
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
171 if (ystart < 0 || ystart > 127)
78
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
172 goto range_err;
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
173 yend = atoi(argv[4]);
104
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
174 if (yend < 0 || yend > 127)
78
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
175 goto range_err;
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
176 if (xend < xstart || yend < ystart) {
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
177 printf("ERROR: negative range\n");
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
178 return;
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
179 }
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
180 break;
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
181 default:
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
182 printf("ERROR: wrong number of arguments\n");
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
183 return;
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
184 }
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
185 set_lcd_addr_region(xstart, xend, ystart, yend);
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
186 npix = (xend + 1 - xstart) * (yend + 1 - ystart);
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
187 while (npix--)
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
188 nCS4_ADDR2 = pixval;
2c266d4339ff pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
189 }
104
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
190
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
191 void
202
b26b7459bd44 pirexplore: lcdramp command renamed to lcdtest: the bars aren't a ramp
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 104
diff changeset
192 cmd_lcdtest()
104
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
193 {
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
194 int i, j, k, p;
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
195
202
b26b7459bd44 pirexplore: lcdramp command renamed to lcdtest: the bars aren't a ramp
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 104
diff changeset
196 /*
b26b7459bd44 pirexplore: lcdramp command renamed to lcdtest: the bars aren't a ramp
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 104
diff changeset
197 * The result of this command should be 8 vertical bars
b26b7459bd44 pirexplore: lcdramp command renamed to lcdtest: the bars aren't a ramp
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 104
diff changeset
198 * in the natural RGB order.
b26b7459bd44 pirexplore: lcdramp command renamed to lcdtest: the bars aren't a ramp
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 104
diff changeset
199 */
104
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
200 set_lcd_addr_region(10, 89, 10, 89);
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
201 for (i = 0; i < 80; i++) {
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
202 for (j = 0; j < 8; j++) {
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
203 p = 0;
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
204 if (j & 4)
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
205 p |= 0xF800;
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
206 if (j & 2)
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
207 p |= 0x07E0;
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
208 if (j & 1)
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
209 p |= 0x001F;
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
210 for (k = 0; k < 10; k++)
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
211 nCS4_ADDR2 = p;
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
212 }
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
213 }
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
214 }
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
215
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
216 void
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
217 cmd_blit(argbulk)
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
218 char *argbulk;
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
219 {
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
220 int argc;
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
221 char *argv[6];
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
222 u16 imgbuf[16384];
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
223 size_t img_file_size;
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
224 int xstart, ystart, width, height;
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
225 int npix, i;
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
226
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
227 if (parse_args(argbulk, 1, 5, argv, &argc) < 0)
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
228 return;
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
229 if (mpffs_read_into_ram(argv[0], imgbuf, 32768, &img_file_size) < 0)
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
230 return;
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
231 switch (argc) {
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
232 case 1:
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
233 xstart = ystart = 0;
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
234 width = height = 128;
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
235 break;
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
236 case 3:
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
237 xstart = ystart = 0;
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
238 goto widthheight;
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
239 case 5:
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
240 xstart = atoi(argv[3]);
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
241 if (xstart < 0 || xstart > 127) {
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
242 range_err: printf("ERROR: coordinate arg out of range\n");
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
243 return;
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
244 }
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
245 ystart = atoi(argv[4]);
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
246 if (ystart < 0 || ystart > 127)
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
247 goto range_err;
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
248 /* FALL THRU */
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
249 widthheight:
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
250 width = atoi(argv[1]);
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
251 if (width < 1 || width > 128)
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
252 goto range_err;
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
253 height = atoi(argv[2]);
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
254 if (height < 1 || height > 128)
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
255 goto range_err;
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
256 if (xstart + width > 128)
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
257 goto range_err;
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
258 if (ystart + height > 128)
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
259 goto range_err;
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
260 break;
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
261 default:
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
262 printf("ERROR: wrong number of arguments\n");
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
263 return;
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
264 }
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
265 npix = width * height;
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
266 if (img_file_size != npix * 2) {
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
267 printf("ERROR: image file size (%u bytes) does not match WxH\n",
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
268 img_file_size);
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
269 return;
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
270 }
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
271 set_lcd_addr_region(xstart, xstart + width - 1,
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
272 ystart, ystart + height - 1);
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
273 /* the artwork images in Pirelli's FFS appear to be inverted */
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
274 for (i = 0; i < npix; i++)
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
275 nCS4_ADDR2 = ~imgbuf[i];
f65df1d640aa pirexplore: approaching sanity with the LCD
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 78
diff changeset
276 }