/vhost/mculabs/snippet_db/lcd-gui/lcd-gui.c
1 // note: this calls the functions in the EA-DOGM driver
2
3 // sets up the programmable chr's for use as a bar graph
4 //uses custom chrs 1 to 5
5 void gBarGraphIni(void)
6 {
7 int i;
8 for (i=0; i<8; i++) { eaDogM_WriteByteToCGRAM(0b00001000 + i,0b0010000); }
9 for (i=0; i<8; i++) { eaDogM_WriteByteToCGRAM(0b00010000 + i,0b0011000); }
10 for (i=0; i<8; i++) { eaDogM_WriteByteToCGRAM(0b00011000 + i,0b0011100); }
11 for (i=0; i<8; i++) { eaDogM_WriteByteToCGRAM(0b00100000 + i,0b0011110); }
12 for (i=0; i<8; i++) { eaDogM_WriteByteToCGRAM(0b00101000 + i,0b0011111); }
13 }
14
15 void gBarGraph(char row, unsigned int16 pos, unsigned int16 max)
16 {
17 int8 i,m,r;
18 int32 n;
19
20 eaDogM_SetPos(row,0);
21 n = ( (pos * 80) / max );
22 m = n / 5; // i love integer math, 6/5 = 1 not 1.2 :)
23 r = n - (m * 5); // get the remainder
24 for (i=0; i<m; i++) { eaDogM_WriteChr(5); } // block chr
25 eaDogM_WriteChr(r);
26 for (i=(m+1); i<16; i++) { eaDogM_WriteChr(0x20); } // end spaces
27 }
28
29 void gAdvBarGraph(char row, char col, char width, unsigned int16 pos, unsigned int16 max)
30 {
31 int8 i,m,r;
32 int32 n;
33
34 eaDogM_SetPos(row,col);
35 n = ( (pos * (width*5)) / max );
36 m = n / 5; // i love integer math, 6/5 = 1 not 1.2 :)
37 r = n - (m * 5); // get the remainder
38 for (i=0; i<m; i++) { eaDogM_WriteChr(5); } // block chr
39 eaDogM_WriteChr(r);
40 for (i=(m+1); i<width; i++) { eaDogM_WriteChr(0x20); } // end spaces
41 }
|