1 | FontX=16;
|
2 | FontY=16;
|
3 | for (;;)
|
4 |
|
5 | {
|
6 | c = uart_getchar();
|
7 | if (c>31)//Display Text
|
8 | {
|
9 | LCDSoftCharProp(c,xpos,ypos);
|
10 | xpos+=xpos;//FontX
|
11 | if (xpos>=XSIZE-FontX)
|
12 | { xpos=0;
|
13 | ypos+=FontY;
|
14 | if (ypos>=YSIZE)
|
15 | ypos=0;
|
16 | }
|
17 | }
|
18 | }
|
19 |
|
20 | int LCDSoftCharProp(unsigned char ch, unsigned short xpos, unsigned short ypos)
|
21 | //########################################################################
|
22 | {
|
23 | unsigned int fontoffset,fontstart;
|
24 | unsigned char i,j,k,by,mask, fontvbytes;
|
25 |
|
26 | //fontwidth, fontheight je nach Zeichen setzen zur Cursorberechnung
|
27 | //fontheight setzen
|
28 | //SPACE ist als Zeichen nicht in der Tabelle !
|
29 |
|
30 | fontheight = pgm_read_byte(&font_s[3]);
|
31 |
|
32 | //SPACE nicht zeichnen, oder besser doch ? Hätte APE doch bloß ein SPACE in die Tabelle mit reingelegt ;)
|
33 | if(ch==' ') { fontwidth = pgm_read_byte(&font_s[2]); return; }
|
34 |
|
35 | if(ch < pgm_read_byte(&font_s[4]) ) return; // Zeichennummer zu klein
|
36 | if(ch > ( pgm_read_byte(&font_s[4]) + pgm_read_byte(&font_s[5]) ) ) return; // Zeichennummer zu groß
|
37 |
|
38 | fontwidth = pgm_read_byte(&font_s[6 + ch - ' ']);
|
39 |
|
40 | fontstart = 6 + (unsigned int)pgm_read_byte(&font_s[5]); // Beginn der Fontdaten
|
41 |
|
42 | // addiere alle Zeichenbreiten bis zum aktuellen Zeichen
|
43 | fontoffset = 0;
|
44 | for(i=0; i<(ch - ' '); i++) fontoffset += pgm_read_byte(&font_s[6 + (unsigned int)i]);
|
45 |
|
46 | //Quickhack, muss man mal besser machen
|
47 | //Zeichenhöhe in Bytes
|
48 | if(fontheight<=8) fontvbytes=1;
|
49 | if(fontheight>8 && fontheight<=16) fontvbytes=2;
|
50 | if(fontheight>16 && fontheight<=24) fontvbytes=3;
|
51 | if(fontheight>24 && fontheight<=32) fontvbytes=4;
|
52 | if(fontheight>32 && fontheight<=40) fontvbytes=5;
|
53 | if(fontheight>40 && fontheight<=48) fontvbytes=6;
|
54 | if(fontheight>48 && fontheight<=56) fontvbytes=7;
|
55 | if(fontheight>56 && fontheight<=64) fontvbytes=8;
|
56 |
|
57 | fontoffset *= fontvbytes; // alle davorliegenden Zeichen überspringen
|
58 | fontoffset += fontstart; // Nun haben wir die Startaddresse des Zeichens
|
59 |
|
60 | for(k=0; k<fontvbytes; k++)
|
61 | {
|
62 | for(i=0; i<fontwidth; i++) //Über die Breite des Zeichens
|
63 | {
|
64 | by=pgm_read_byte(&font_s[fontoffset++]); //Ein Byte des Zeichens holen
|
65 |
|
66 | mask=0x01; //Bei D0 anfangen
|
67 | for(j=0; j<8; j++)
|
68 | {
|
69 | lcd_setpixel(xpos+i,ypos + k * 8 + j,(by&mask));
|
70 |
|
71 | mask<<=1; //Nächstes Bit
|
72 |
|
73 | }//for j
|
74 |
|
75 | }//for i
|
76 |
|
77 | for(j=0; j<8; j++) // virtual spacing Spalte, 1 pixel addieren
|
78 | {
|
79 | lcd_setpixel(xpos+i,ypos + k * 8 + j,0);
|
80 |
|
81 | }//for j
|
82 |
|
83 | }//for k
|
84 |
|
85 | fontwidth++; // virtual spacing Spalte, 1 pixel addieren
|
86 | return xpos;
|
87 |
|
88 | }
|