annotate lcdtest/showppm.c @ 17:43cc53581975

lcdtest: PPM image display implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 07 Apr 2018 21:57:54 +0000
parents
children f3671d3ad953
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 #include <stdio.h>
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 #include <ctype.h>
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 #include <stdlib.h>
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 char *ppm_filename;
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 FILE *ppmfile;
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 int ppm_is_ascii; /* P3 format instead of P6 */
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 /*
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 * This function reads one ASCII-encoded integer from a PPM file.
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 * It handles the white space and comment rules of the PPM format.
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 */
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 static int
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 ppm_get_ascii_number()
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 {
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 int accum, c;
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 do {
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 c = getc(ppmfile);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 if (c < 0) {
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 badeof: fprintf(stderr, "%s: unexpected EOF\n", ppm_filename);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 return(-1);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 }
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 if (c == '#') {
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 do
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 c = getc(ppmfile);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 while (c >= 0 && c != '\n');
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 if (c != '\n')
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 goto badeof;
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 }
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 } while (isspace(c));
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 if (!isdigit(c)) {
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 fprintf(stderr,
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 "%s: unexpected data where a number was expected\n",
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 ppm_filename);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 return(-1);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 }
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 for (accum = c - '0'; ; ) {
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 c = getc(ppmfile);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 if (c < 0 || isspace(c))
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 break;
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 if (!isdigit(c)) {
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 fprintf(stderr,
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 "%s: bad character in the middle of a number\n",
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 ppm_filename);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 return(-1);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 }
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 accum = accum * 10 + c - '0';
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 }
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 return accum;
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 }
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 /*
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 * This function reads and parses the PPM header of our input file.
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 */
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 static int
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 ppm_read_header()
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 {
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 int magic1, magic2;
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 int rd;
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 magic1 = getc(ppmfile);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 magic2 = getc(ppmfile);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 if (magic1 == 'P' && magic2 == '3')
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 ppm_is_ascii = 1;
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 else if (magic1 == 'P' && magic2 == '6')
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 ppm_is_ascii = 0;
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 else {
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 fprintf(stderr, "%s: P3 or P6 format expected\n", ppm_filename);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 return(-1);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 }
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 rd = ppm_get_ascii_number();
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 if (rd < 0)
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 return(-1);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 if (rd != 176) {
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 fprintf(stderr, "%s: width is not 176\n", ppm_filename);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 return(-1);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 }
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 rd = ppm_get_ascii_number();
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 if (rd < 0)
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 return(-1);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 if (rd != 220) {
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 fprintf(stderr, "%s: height is not 220\n", ppm_filename);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 return(-1);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 }
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 rd = ppm_get_ascii_number();
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 if (rd < 0)
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 return(-1);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 if (rd != 255) {
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 fprintf(stderr, "%s: maxval is not 255\n", ppm_filename);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 return(-1);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 }
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 return(0);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 }
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 /*
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 * This function reads a single R, G or B value from a PPM file.
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 */
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 static int
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 ppm_get_pixval()
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 {
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 int c;
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 if (ppm_is_ascii)
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 return ppm_get_ascii_number();
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 c = getc(ppmfile);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 if (c < 0) {
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 fprintf(stderr, "%s: EOF while reading binary pixel data\n",
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 ppm_filename);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 return(-1);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 }
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 return c;
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 }
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 static int
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 ppm_get_rgb()
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 {
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 int r, g, b;
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 r = ppm_get_pixval();
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 if (r < 0)
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 return(-1);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 g = ppm_get_pixval();
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 if (g < 0)
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 return(-1);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 b = ppm_get_pixval();
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 if (b < 0)
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 return(-1);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 /* convert to 5:6:5 */
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 r >>= 3;
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 g >>= 2;
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 b >>= 3;
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 return (r << 11) | (g << 5) | b;
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 }
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 cmd_show(argc, argv)
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 char **argv;
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 {
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 int rc;
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 unsigned n;
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 ppm_filename = argv[1];
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 ppmfile = fopen(ppm_filename, "r");
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 if (!ppmfile) {
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 perror(ppm_filename);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 return(-1);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 }
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 rc = ppm_read_header();
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149 if (rc < 0) {
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 fclose(ppmfile);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 return(-1);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 }
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 write_ir(0x20);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 write_dr(0);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 write_ir(0x21);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156 write_dr(0);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157 write_ir(0x22);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 for (n = 0; n < 176*220; n++) {
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159 rc = ppm_get_rgb();
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 if (rc < 0) {
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161 fclose(ppmfile);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 return(-1);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163 }
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 write_dr(rc);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165 }
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166 fclose(ppmfile);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167 return(0);
43cc53581975 lcdtest: PPM image display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168 }