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