1 | /*
|
---|
2 | =============================================================================
|
---|
3 | barbadj.c -- MIDAS-VII -- GLC bar graph drivers
|
---|
4 | Version 8 -- 1988-10-27 -- D.N. Lynx Crowe
|
---|
5 |
|
---|
6 | BarBadj(bar, val)
|
---|
7 | short bar, val;
|
---|
8 |
|
---|
9 | Adjusts a bottom-zero bar graph, 'bar',
|
---|
10 | to read 'val'.
|
---|
11 |
|
---|
12 | BarBset(bar, val)
|
---|
13 | short bar, val;
|
---|
14 |
|
---|
15 | Sets a bottom-zero bar graph, 'bar',
|
---|
16 | to an intial value, 'val'.
|
---|
17 |
|
---|
18 | BarCadj(bar, val)
|
---|
19 | short bar, val;
|
---|
20 |
|
---|
21 | Adjusts a centered-zero bar graph, 'bar',
|
---|
22 | to read 'val'.
|
---|
23 |
|
---|
24 | BarCset(bar, val)
|
---|
25 | short bar, val;
|
---|
26 |
|
---|
27 | Sets a centered-zero bar graph, 'bar',
|
---|
28 | to an intial value, 'val'.
|
---|
29 | =============================================================================
|
---|
30 | */
|
---|
31 |
|
---|
32 | #include "stddefs.h"
|
---|
33 | #include "hwdefs.h"
|
---|
34 | #include "glcfns.h"
|
---|
35 | #include "glcdefs.h"
|
---|
36 |
|
---|
37 | extern short BarBcur[];
|
---|
38 | extern short BarCcur[];
|
---|
39 |
|
---|
40 | /* left-most bar columns */
|
---|
41 |
|
---|
42 | short BarCols[14] = { 2, 8, 14, 20, 26, 32, 38, 44, 50, 56, 62, 68, 74, 80 };
|
---|
43 |
|
---|
44 | /* bar dot data */
|
---|
45 |
|
---|
46 | short BarDots[3] = { 0x1C, 0xFC, 0xE0 };
|
---|
47 |
|
---|
48 | #include "glcbars.h" /* bar graph driver constant definitions */
|
---|
49 |
|
---|
50 | /* |
---|
51 |
|
---|
52 | */
|
---|
53 |
|
---|
54 | /*
|
---|
55 | =============================================================================
|
---|
56 | BarBadj() -- adjust a bottom-zero bar graph to a new value
|
---|
57 | =============================================================================
|
---|
58 | */
|
---|
59 |
|
---|
60 | void BarBadj(short bar, short val)
|
---|
61 | {
|
---|
62 | register short bardot, barpos, curdif;
|
---|
63 | register unsigned baradr;
|
---|
64 | short barcol, bardif, curbar, i, newbar;
|
---|
65 |
|
---|
66 | newbar = BarBLn[val]; /* look up the new bar position */
|
---|
67 | curbar = BarBcur[bar]; /* get the current bar position */
|
---|
68 | bardif = newbar - curbar; /* calculate how far to move the bar */
|
---|
69 |
|
---|
70 | if (0 EQ bardif) /* done if bar doesn't need to be moved */
|
---|
71 | return;
|
---|
72 |
|
---|
73 | GLCcurs(G_ON); /* turn on GLC cursor to enable writing */
|
---|
74 | barcol = BarCols[bar]; /* find leftmost column of bar */
|
---|
75 |
|
---|
76 | if (bardif > 0) { /* increasing value */
|
---|
77 |
|
---|
78 | /* calculate initial GLC RAM write address */
|
---|
79 |
|
---|
80 | baradr = barcol + (85 * (63 - (curbar + 1))) + G_PLANE2;
|
---|
81 |
|
---|
82 | LCD_WC = G_CRSMUP; /* set cursor motion "up" */
|
---|
83 |
|
---|
84 | for (i = 0; i < 3; i++) { /* for each bar column ... */
|
---|
85 |
|
---|
86 | curdif = bardif; /* set difference counter */
|
---|
87 | bardot = BarDots[i]; /* get the column dot value */
|
---|
88 |
|
---|
89 | LCD_WC = G_CRSWR; /* set cursor address */
|
---|
90 | LCD_WD = baradr & 0xFF;
|
---|
91 | LCD_WD = (baradr >> 8) & 0xFF;
|
---|
92 |
|
---|
93 | ++baradr; /* update GLC start address */
|
---|
94 |
|
---|
95 | LCD_WC = G_MWRITE; /* setup to write */
|
---|
96 |
|
---|
97 | while (curdif--) /* write new dots */
|
---|
98 | LCD_WD = bardot;
|
---|
99 | }
|
---|
100 | /* |
---|
101 |
|
---|
102 | */
|
---|
103 | } else { /* decreasing value */
|
---|
104 |
|
---|
105 | /* calculate initial GLC RAM write address */
|
---|
106 |
|
---|
107 | baradr = barcol + (85 * (63 - curbar)) + G_PLANE2;
|
---|
108 |
|
---|
109 | LCD_WC = G_CRSMDN; /* set cursor motion "down" */
|
---|
110 |
|
---|
111 | for (i = 0; i < 3; i++) { /* for each bar column ... */
|
---|
112 |
|
---|
113 | curdif = -bardif; /* set difference counter */
|
---|
114 |
|
---|
115 | LCD_WC = G_CRSWR; /* set cursor address */
|
---|
116 | LCD_WD = baradr & 0xFF;
|
---|
117 | LCD_WD = (baradr >> 8) & 0xFF;
|
---|
118 |
|
---|
119 | ++baradr; /* update GLC start address */
|
---|
120 |
|
---|
121 | LCD_WC = G_MWRITE; /* setup to write */
|
---|
122 |
|
---|
123 | while (curdif--) /* erase old dots */
|
---|
124 | LCD_WD = 0x00;
|
---|
125 | }
|
---|
126 | }
|
---|
127 |
|
---|
128 | LCD_WC = G_CRSMRT; /* set cursor motion = "right" */
|
---|
129 | GLCcurs(G_OFF); /* turn off the cursor */
|
---|
130 |
|
---|
131 | BarBcur[bar] = newbar; /* update current bar position */
|
---|
132 | }
|
---|
133 |
|
---|
134 | /* |
---|
135 |
|
---|
136 | */
|
---|
137 |
|
---|
138 | /*
|
---|
139 | =============================================================================
|
---|
140 | BarBset() -- set a bottom-zero bar graph to an initial value
|
---|
141 | =============================================================================
|
---|
142 | */
|
---|
143 |
|
---|
144 | void BarBset(short bar, short val)
|
---|
145 | {
|
---|
146 | register short bardot, barpos, newbar;
|
---|
147 | register unsigned baradr;
|
---|
148 | short barcol, i;
|
---|
149 |
|
---|
150 | newbar = BarBLn[val]; /* look up the new bar position */
|
---|
151 | barcol = BarCols[bar]; /* find leftmost column of bar */
|
---|
152 |
|
---|
153 | GLCcurs(G_ON); /* turn on GLC cursor to enable writing */
|
---|
154 |
|
---|
155 | /* calculate initial GLC RAM write address */
|
---|
156 |
|
---|
157 | baradr = barcol + (85 * (63 - BBase)) + G_PLANE2;
|
---|
158 |
|
---|
159 | LCD_WC = G_CRSMUP; /* set cursor motion = "up" */
|
---|
160 |
|
---|
161 | for (i = 0; i < 3; i++) { /* for each bar column ... */
|
---|
162 |
|
---|
163 | bardot = BarDots[i]; /* get the column dot value */
|
---|
164 | barpos = BBase; /* get base of bar */
|
---|
165 |
|
---|
166 | LCD_WC = G_CRSWR; /* set cursor address */
|
---|
167 | LCD_WD = baradr & 0xFF;
|
---|
168 | LCD_WD = (baradr >> 8) & 0xFF;
|
---|
169 |
|
---|
170 | ++baradr; /* update GLC start address */
|
---|
171 |
|
---|
172 | LCD_WC = G_MWRITE; /* setup to write */
|
---|
173 |
|
---|
174 | while (barpos++ LE newbar) /* write new dots */
|
---|
175 | LCD_WD = bardot;
|
---|
176 |
|
---|
177 | while (barpos++ < BTop) /* erase old dots */
|
---|
178 | LCD_WD = 0x00;
|
---|
179 | }
|
---|
180 |
|
---|
181 | LCD_WC = G_CRSMRT; /* set cursor motion = "right" */
|
---|
182 | GLCcurs(G_OFF); /* turn off the cursor */
|
---|
183 |
|
---|
184 | BarBcur[bar] = newbar; /* update current bar position */
|
---|
185 | }
|
---|
186 |
|
---|
187 | /* |
---|
188 |
|
---|
189 | */
|
---|
190 |
|
---|
191 | /*
|
---|
192 | =============================================================================
|
---|
193 | BarCadj() -- adjust a centered-zero bar graph to a new value
|
---|
194 | =============================================================================
|
---|
195 | */
|
---|
196 |
|
---|
197 | void BarCadj(short bar, short val)
|
---|
198 | {
|
---|
199 | register short bardot, barpos, newbar;
|
---|
200 | register unsigned baradr;
|
---|
201 | short barcol, bardif, curbar, i;
|
---|
202 |
|
---|
203 | newbar = BarCLn[val + BOffset]; /* look up the new bar position */
|
---|
204 | curbar = BarCcur[bar]; /* get the current bar position */
|
---|
205 | bardif = newbar - curbar; /* calculate how far to move the bar */
|
---|
206 |
|
---|
207 | if (0 EQ bardif) /* done if bar doesn't need to be moved */
|
---|
208 | return;
|
---|
209 |
|
---|
210 | GLCcurs(G_ON); /* turn on GLC cursor to enable writing */
|
---|
211 |
|
---|
212 | barcol = BarCols[bar]; /* find leftmost column of bar */
|
---|
213 |
|
---|
214 | /* calculate initial GLC RAM write address */
|
---|
215 |
|
---|
216 | baradr = barcol + (85 * (63 - curbar)) + G_PLANE2;
|
---|
217 |
|
---|
218 | /* |
---|
219 |
|
---|
220 | */
|
---|
221 | if (newbar > curbar) { /* increasing value */
|
---|
222 |
|
---|
223 | LCD_WC = G_CRSMUP; /* set cursor motion "up" */
|
---|
224 |
|
---|
225 | for (i = 0; i < 3; i++) { /* for each bar column ... */
|
---|
226 |
|
---|
227 | bardot = BarDots[i]; /* get the column dot value */
|
---|
228 | barpos = curbar; /* set current vert. position */
|
---|
229 |
|
---|
230 | LCD_WC = G_CRSWR; /* set cursor address */
|
---|
231 | LCD_WD = baradr & 0xFF;
|
---|
232 | LCD_WD = (baradr >> 8) & 0xFF;
|
---|
233 |
|
---|
234 | LCD_WC = G_MWRITE; /* setup to write */
|
---|
235 |
|
---|
236 | while (barpos NE newbar) /* write bar on LCD */
|
---|
237 | if (barpos++ < BCenter)
|
---|
238 | LCD_WD = 0x00; /* dots off */
|
---|
239 | else
|
---|
240 | LCD_WD = bardot; /* dots on */
|
---|
241 |
|
---|
242 | ++baradr; /* update GLC start address */
|
---|
243 | }
|
---|
244 | /* |
---|
245 |
|
---|
246 | */
|
---|
247 | } else { /* decreasing value */
|
---|
248 |
|
---|
249 | LCD_WC = G_CRSMDN; /* set cursor motion "down" */
|
---|
250 |
|
---|
251 | for (i = 0; i < 3; i++) { /* for each bar column ... */
|
---|
252 |
|
---|
253 | bardot = BarDots[i]; /* get column dot value */
|
---|
254 | barpos = curbar; /* set current bar location */
|
---|
255 |
|
---|
256 | LCD_WC = G_CRSWR; /* set cursor address */
|
---|
257 | LCD_WD = baradr & 0xFF;
|
---|
258 | LCD_WD = (baradr >> 8) & 0xFF;
|
---|
259 |
|
---|
260 | LCD_WC = G_MWRITE; /* setup to write */
|
---|
261 |
|
---|
262 | while (barpos NE newbar) /* write bar to LCD */
|
---|
263 | if (barpos-- > BCenter)
|
---|
264 | LCD_WD= 0x00; /* dots off */
|
---|
265 | else
|
---|
266 | LCD_WD = bardot; /* dots on */
|
---|
267 |
|
---|
268 | ++baradr; /* update GLC start address */
|
---|
269 | }
|
---|
270 | }
|
---|
271 |
|
---|
272 | LCD_WC = G_CRSMRT; /* set cursor motion = "right" */
|
---|
273 | GLCcurs(G_OFF); /* turn off the cursor */
|
---|
274 |
|
---|
275 | BarCcur[bar] = newbar; /* update current bar position */
|
---|
276 | }
|
---|
277 |
|
---|
278 | /* |
---|
279 |
|
---|
280 | */
|
---|
281 |
|
---|
282 | /*
|
---|
283 | =============================================================================
|
---|
284 | BarCset() -- set a centered-zero bar graph to an initial value
|
---|
285 | =============================================================================
|
---|
286 | */
|
---|
287 |
|
---|
288 | void BarCset(short bar, short val)
|
---|
289 | {
|
---|
290 | register short bardot, barpos, barloc1, barloc2;
|
---|
291 | register unsigned baradr;
|
---|
292 | short barcol, i, newbar;
|
---|
293 |
|
---|
294 | GLCcurs(G_ON); /* turn on GLC cursor to enable writing */
|
---|
295 |
|
---|
296 | newbar = BarCLn[val + BOffset]; /* look up the new bar position */
|
---|
297 | barcol = BarCols[bar]; /* find leftmost column of bar */
|
---|
298 |
|
---|
299 | /* calculate initial GLC RAM write address */
|
---|
300 |
|
---|
301 | baradr = barcol + (85 * (63 - BBase)) + G_PLANE2;
|
---|
302 |
|
---|
303 | if (newbar < BCenter) { /* target below center */
|
---|
304 |
|
---|
305 | barloc1 = newbar; /* off limit */
|
---|
306 | barloc2 = BCenter; /* on limit */
|
---|
307 |
|
---|
308 | } else { /* target at or above center */
|
---|
309 |
|
---|
310 | barloc1 = BCenter; /* off limit */
|
---|
311 | barloc2 = newbar; /* on limit */
|
---|
312 | }
|
---|
313 |
|
---|
314 | LCD_WC = G_CRSMUP; /* set cursor motion "up" */
|
---|
315 |
|
---|
316 | /* |
---|
317 |
|
---|
318 | */
|
---|
319 | for (i = 0; i < 3; i++) { /* for each bar column ... */
|
---|
320 |
|
---|
321 | bardot = BarDots[i]; /* get the column dot value */
|
---|
322 | barpos = BBase; /* set current vert. position */
|
---|
323 |
|
---|
324 | LCD_WC = G_CRSWR; /* set cursor address */
|
---|
325 | LCD_WD = baradr & 0xFF;
|
---|
326 | LCD_WD = (baradr >> 8) & 0xFF;
|
---|
327 |
|
---|
328 | LCD_WC = G_MWRITE; /* setup to write */
|
---|
329 |
|
---|
330 | while (barpos < barloc1) { /* write "off" dots */
|
---|
331 |
|
---|
332 | LCD_WD = 0x00;
|
---|
333 | barpos++;
|
---|
334 | }
|
---|
335 |
|
---|
336 | while (barpos LE barloc2) { /* write "on" dots */
|
---|
337 |
|
---|
338 | LCD_WD = bardot;
|
---|
339 | barpos++;
|
---|
340 | }
|
---|
341 |
|
---|
342 | while (barpos LE BTop) { /* write "off" dots */
|
---|
343 |
|
---|
344 | LCD_WD = 0x00;
|
---|
345 | barpos++;
|
---|
346 | }
|
---|
347 |
|
---|
348 | ++baradr; /* update GLC start address */
|
---|
349 | }
|
---|
350 |
|
---|
351 | LCD_WC = G_CRSMRT; /* set cursor motion = "right" */
|
---|
352 | GLCcurs(G_OFF); /* turn off the cursor */
|
---|
353 |
|
---|
354 | BarCcur[bar] = newbar; /* update current bar position */
|
---|
355 | }
|
---|