this is kazushi's branch of AD128160
Fork of AD128160 by
s_Lcd.cpp@5:39b01a6f0f75, 2011-11-23 (annotated)
- Committer:
- akira
- Date:
- Wed Nov 23 12:12:11 2011 +0000
- Revision:
- 5:39b01a6f0f75
- Parent:
- 4:1f72df1a88e0
- Child:
- 6:96576c9c7828
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
akira | 2:5d8d5291b4cd | 1 | #include "mbed.h" |
akira | 2:5d8d5291b4cd | 2 | |
akira | 5:39b01a6f0f75 | 3 | Serial device(p9, p10); // tx, rx |
akira | 5:39b01a6f0f75 | 4 | //Serial pc(USBTX, USBRX); // tx, rx |
akira | 2:5d8d5291b4cd | 5 | DigitalOut rst(p20); //P20 --> LCD RST (Reset) |
akira | 2:5d8d5291b4cd | 6 | |
akira | 4:1f72df1a88e0 | 7 | LocalFileSystem local("local"); |
akira | 5:39b01a6f0f75 | 8 | //Serial pc(USBTX, USBRX); |
akira | 5:39b01a6f0f75 | 9 | int csrx = 0; |
akira | 5:39b01a6f0f75 | 10 | int csry = 16; |
akira | 4:1f72df1a88e0 | 11 | |
akira | 5:39b01a6f0f75 | 12 | FILE *fp; |
akira | 4:1f72df1a88e0 | 13 | |
akira | 4:1f72df1a88e0 | 14 | unsigned short start[92], end[92]; |
akira | 4:1f72df1a88e0 | 15 | unsigned char font[64]; |
akira | 4:1f72df1a88e0 | 16 | |
akira | 4:1f72df1a88e0 | 17 | char Identifier[6+1]; |
akira | 4:1f72df1a88e0 | 18 | char FontName[8+1]; |
akira | 4:1f72df1a88e0 | 19 | unsigned char XSize; |
akira | 4:1f72df1a88e0 | 20 | unsigned char YSize; |
akira | 4:1f72df1a88e0 | 21 | unsigned char Size; |
akira | 4:1f72df1a88e0 | 22 | unsigned char CodeType; |
akira | 4:1f72df1a88e0 | 23 | unsigned char Tnum; |
akira | 4:1f72df1a88e0 | 24 | |
akira | 4:1f72df1a88e0 | 25 | #define FONT_XBYTE ((XSize + 7) >> 3) |
akira | 4:1f72df1a88e0 | 26 | #define FONT_YBYTE ((YSize + 7) >> 3) |
akira | 4:1f72df1a88e0 | 27 | |
akira | 2:5d8d5291b4cd | 28 | void lcdspeed() |
akira | 2:5d8d5291b4cd | 29 | { |
akira | 2:5d8d5291b4cd | 30 | device.putc(0x55);// UART Speed 115200bps |
akira | 2:5d8d5291b4cd | 31 | device.putc(0x05); |
akira | 2:5d8d5291b4cd | 32 | device.putc(0x8B); |
akira | 2:5d8d5291b4cd | 33 | device.putc(0x00); |
akira | 2:5d8d5291b4cd | 34 | device.putc(0x01); |
akira | 2:5d8d5291b4cd | 35 | device.putc(0xC2); |
akira | 2:5d8d5291b4cd | 36 | device.putc(0x00); |
akira | 2:5d8d5291b4cd | 37 | device.putc(0x4E); |
akira | 2:5d8d5291b4cd | 38 | device.putc(0xAA); |
akira | 2:5d8d5291b4cd | 39 | } |
akira | 2:5d8d5291b4cd | 40 | |
akira | 2:5d8d5291b4cd | 41 | void cls() |
akira | 2:5d8d5291b4cd | 42 | { |
akira | 2:5d8d5291b4cd | 43 | device.putc(0x55);// Clear |
akira | 2:5d8d5291b4cd | 44 | device.putc(0x02); |
akira | 2:5d8d5291b4cd | 45 | device.putc(0x80); |
akira | 2:5d8d5291b4cd | 46 | device.putc(0x55); |
akira | 2:5d8d5291b4cd | 47 | device.putc(0xD5); |
akira | 2:5d8d5291b4cd | 48 | device.putc(0xAA); |
akira | 2:5d8d5291b4cd | 49 | } |
akira | 4:1f72df1a88e0 | 50 | |
akira | 4:1f72df1a88e0 | 51 | void lcdputs( char data[98],int x,int y) |
akira | 2:5d8d5291b4cd | 52 | { |
akira | 5:39b01a6f0f75 | 53 | unsigned char s; |
akira | 4:1f72df1a88e0 | 54 | unsigned char x0H; |
akira | 4:1f72df1a88e0 | 55 | unsigned char x0L; |
akira | 4:1f72df1a88e0 | 56 | unsigned char y0H; |
akira | 4:1f72df1a88e0 | 57 | unsigned char y0L; |
akira | 4:1f72df1a88e0 | 58 | unsigned char datalen; |
akira | 4:1f72df1a88e0 | 59 | x0H = x >> 8; |
akira | 4:1f72df1a88e0 | 60 | x0L = x & 0xFF; |
akira | 4:1f72df1a88e0 | 61 | y0H = y >> 8; |
akira | 4:1f72df1a88e0 | 62 | y0L = y & 0xFF; |
akira | 4:1f72df1a88e0 | 63 | datalen = strlen(data)+5; |
akira | 4:1f72df1a88e0 | 64 | device.putc(0x55); |
akira | 4:1f72df1a88e0 | 65 | device.putc(datalen); |
akira | 4:1f72df1a88e0 | 66 | device.putc(0x0B); // command ASCII Print |
akira | 4:1f72df1a88e0 | 67 | device.putc(x0H); //x upper 8bit |
akira | 4:1f72df1a88e0 | 68 | device.putc(x0L); //x low 8bit |
akira | 4:1f72df1a88e0 | 69 | device.putc(y0H); //y upper 8bit |
akira | 4:1f72df1a88e0 | 70 | device.putc(y0L); //y low 8bit |
akira | 4:1f72df1a88e0 | 71 | for(int a=0;a<strlen(data);a++) |
akira | 4:1f72df1a88e0 | 72 | { |
akira | 4:1f72df1a88e0 | 73 | device.putc(data[a]); |
akira | 4:1f72df1a88e0 | 74 | s = s+data[a]; |
akira | 5:39b01a6f0f75 | 75 | // pc.printf("%x:",data[a]); |
akira | 4:1f72df1a88e0 | 76 | } |
akira | 4:1f72df1a88e0 | 77 | s = s+x0H+x0L+y0H+y0L+0x0B; |
akira | 4:1f72df1a88e0 | 78 | device.putc(s);//sumcheck |
akira | 3:f5576943e216 | 79 | device.putc(0xAA); |
akira | 5:39b01a6f0f75 | 80 | // pc.printf("print %x %x %x %x %x %d ",x0H,x0L,y0H,y0L,s,datalen); |
akira | 2:5d8d5291b4cd | 81 | } |
akira | 2:5d8d5291b4cd | 82 | |
akira | 2:5d8d5291b4cd | 83 | void color(int rgb) |
akira | 2:5d8d5291b4cd | 84 | { |
akira | 2:5d8d5291b4cd | 85 | int c1; |
akira | 2:5d8d5291b4cd | 86 | int c2; |
akira | 2:5d8d5291b4cd | 87 | int sum; |
akira | 2:5d8d5291b4cd | 88 | |
akira | 2:5d8d5291b4cd | 89 | c1=(rgb >> 8) & 0xff; |
akira | 2:5d8d5291b4cd | 90 | c2=(rgb & 0xff); |
akira | 2:5d8d5291b4cd | 91 | sum=c1+c2+0x84; |
akira | 2:5d8d5291b4cd | 92 | device.putc(0x55); |
akira | 2:5d8d5291b4cd | 93 | device.putc(0x03); |
akira | 2:5d8d5291b4cd | 94 | device.putc(0x84); |
akira | 2:5d8d5291b4cd | 95 | device.putc(c1); |
akira | 2:5d8d5291b4cd | 96 | device.putc(c2); |
akira | 2:5d8d5291b4cd | 97 | device.putc(sum); |
akira | 2:5d8d5291b4cd | 98 | device.putc(0xAA); |
akira | 5:39b01a6f0f75 | 99 | //pc.printf("color %x %x %x ",c1,c2,sum); |
akira | 2:5d8d5291b4cd | 100 | } |
akira | 2:5d8d5291b4cd | 101 | |
akira | 2:5d8d5291b4cd | 102 | void pixel(int x0,int y0) |
akira | 2:5d8d5291b4cd | 103 | { |
akira | 2:5d8d5291b4cd | 104 | unsigned char x0H; |
akira | 2:5d8d5291b4cd | 105 | unsigned char x0L; |
akira | 2:5d8d5291b4cd | 106 | unsigned char y0H; |
akira | 2:5d8d5291b4cd | 107 | unsigned char y0L; |
akira | 2:5d8d5291b4cd | 108 | unsigned char sum; |
akira | 2:5d8d5291b4cd | 109 | |
akira | 2:5d8d5291b4cd | 110 | x0H = x0 >> 8; |
akira | 2:5d8d5291b4cd | 111 | x0L = x0 & 0xFF; |
akira | 2:5d8d5291b4cd | 112 | y0H = y0 >> 8; |
akira | 2:5d8d5291b4cd | 113 | y0L = y0 & 0xff; |
akira | 2:5d8d5291b4cd | 114 | |
akira | 2:5d8d5291b4cd | 115 | sum = x0H+x0L+y0H+y0L+0x01; |
akira | 2:5d8d5291b4cd | 116 | device.putc(0x55); |
akira | 2:5d8d5291b4cd | 117 | device.putc(0x05); |
akira | 2:5d8d5291b4cd | 118 | device.putc(0x01);//command |
akira | 2:5d8d5291b4cd | 119 | device.putc(x0H); |
akira | 2:5d8d5291b4cd | 120 | device.putc(x0L); |
akira | 2:5d8d5291b4cd | 121 | device.putc(y0H); |
akira | 2:5d8d5291b4cd | 122 | device.putc(y0L); |
akira | 2:5d8d5291b4cd | 123 | device.putc(sum); |
akira | 2:5d8d5291b4cd | 124 | device.putc(0xAA); |
akira | 2:5d8d5291b4cd | 125 | } |
akira | 2:5d8d5291b4cd | 126 | |
akira | 2:5d8d5291b4cd | 127 | void box(int x0,int y0,int x1,int y1,int paint) |
akira | 2:5d8d5291b4cd | 128 | { |
akira | 2:5d8d5291b4cd | 129 | unsigned char x0H; |
akira | 2:5d8d5291b4cd | 130 | unsigned char x0L; |
akira | 2:5d8d5291b4cd | 131 | unsigned char x1H; |
akira | 2:5d8d5291b4cd | 132 | unsigned char x1L; |
akira | 2:5d8d5291b4cd | 133 | unsigned char y0H; |
akira | 2:5d8d5291b4cd | 134 | unsigned char y0L; |
akira | 2:5d8d5291b4cd | 135 | unsigned char y1H; |
akira | 2:5d8d5291b4cd | 136 | unsigned char y1L; |
akira | 2:5d8d5291b4cd | 137 | unsigned char sum; |
akira | 2:5d8d5291b4cd | 138 | unsigned char cmd; |
akira | 2:5d8d5291b4cd | 139 | switch (paint) |
akira | 2:5d8d5291b4cd | 140 | { |
akira | 2:5d8d5291b4cd | 141 | case 1: |
akira | 2:5d8d5291b4cd | 142 | cmd = 0x04; |
akira | 2:5d8d5291b4cd | 143 | break; |
akira | 2:5d8d5291b4cd | 144 | default: |
akira | 2:5d8d5291b4cd | 145 | cmd =0x03; |
akira | 2:5d8d5291b4cd | 146 | break; |
akira | 2:5d8d5291b4cd | 147 | } |
akira | 2:5d8d5291b4cd | 148 | x0H = x0 >> 8; |
akira | 2:5d8d5291b4cd | 149 | x0L = x0 & 0xFF; |
akira | 2:5d8d5291b4cd | 150 | y0H = y0 >> 8; |
akira | 2:5d8d5291b4cd | 151 | y0L = y0 & 0xff; |
akira | 2:5d8d5291b4cd | 152 | x1H = x1 >> 8; |
akira | 2:5d8d5291b4cd | 153 | x1L = x1 & 0xFF; |
akira | 2:5d8d5291b4cd | 154 | y1H = y1 >> 8; |
akira | 2:5d8d5291b4cd | 155 | y1L = y1 & 0xff; |
akira | 2:5d8d5291b4cd | 156 | sum = x0H+x0L+y0H+y0L+x1H+x1L+y1H+y1L+cmd; |
akira | 2:5d8d5291b4cd | 157 | device.putc(0x55);//Box |
akira | 2:5d8d5291b4cd | 158 | device.putc(0x09); |
akira | 2:5d8d5291b4cd | 159 | device.putc(cmd);//command |
akira | 2:5d8d5291b4cd | 160 | device.putc(x0H); |
akira | 2:5d8d5291b4cd | 161 | device.putc(x0L); |
akira | 2:5d8d5291b4cd | 162 | device.putc(y0H); |
akira | 2:5d8d5291b4cd | 163 | device.putc(y0L); |
akira | 2:5d8d5291b4cd | 164 | device.putc(x1H); |
akira | 2:5d8d5291b4cd | 165 | device.putc(x1L); |
akira | 2:5d8d5291b4cd | 166 | device.putc(y1H); |
akira | 2:5d8d5291b4cd | 167 | device.putc(y1L); |
akira | 2:5d8d5291b4cd | 168 | device.putc(sum); |
akira | 2:5d8d5291b4cd | 169 | device.putc(0xAA); |
akira | 2:5d8d5291b4cd | 170 | } |
akira | 2:5d8d5291b4cd | 171 | |
akira | 2:5d8d5291b4cd | 172 | void circle(int x0,int y0,int r,int paint) |
akira | 2:5d8d5291b4cd | 173 | { |
akira | 2:5d8d5291b4cd | 174 | unsigned char x0H; |
akira | 2:5d8d5291b4cd | 175 | unsigned char x0L; |
akira | 2:5d8d5291b4cd | 176 | unsigned char y0H; |
akira | 2:5d8d5291b4cd | 177 | unsigned char y0L; |
akira | 2:5d8d5291b4cd | 178 | unsigned char rH; |
akira | 2:5d8d5291b4cd | 179 | unsigned char rL; |
akira | 2:5d8d5291b4cd | 180 | unsigned char sum; |
akira | 2:5d8d5291b4cd | 181 | unsigned char cmd; |
akira | 2:5d8d5291b4cd | 182 | switch (paint) |
akira | 2:5d8d5291b4cd | 183 | { |
akira | 2:5d8d5291b4cd | 184 | case 0: |
akira | 2:5d8d5291b4cd | 185 | cmd = 0x05; |
akira | 2:5d8d5291b4cd | 186 | break; |
akira | 2:5d8d5291b4cd | 187 | case 1: |
akira | 2:5d8d5291b4cd | 188 | cmd = 0x06; |
akira | 2:5d8d5291b4cd | 189 | break; |
akira | 2:5d8d5291b4cd | 190 | default: |
akira | 2:5d8d5291b4cd | 191 | cmd =0x05; |
akira | 2:5d8d5291b4cd | 192 | break; |
akira | 2:5d8d5291b4cd | 193 | } |
akira | 2:5d8d5291b4cd | 194 | x0H = x0 >> 8; |
akira | 2:5d8d5291b4cd | 195 | x0L = x0 & 0xFF; |
akira | 2:5d8d5291b4cd | 196 | y0H = y0 >> 8; |
akira | 2:5d8d5291b4cd | 197 | y0L = y0 & 0xff; |
akira | 2:5d8d5291b4cd | 198 | rH = r >> 8; |
akira | 2:5d8d5291b4cd | 199 | rL = r & 0xFF; |
akira | 2:5d8d5291b4cd | 200 | sum = x0H+x0L+y0H+y0L+rH+rL+cmd; |
akira | 2:5d8d5291b4cd | 201 | device.putc(0x55); |
akira | 2:5d8d5291b4cd | 202 | device.putc(0x07); |
akira | 2:5d8d5291b4cd | 203 | device.putc(cmd);//command |
akira | 2:5d8d5291b4cd | 204 | device.putc(x0H); |
akira | 2:5d8d5291b4cd | 205 | device.putc(x0L); |
akira | 2:5d8d5291b4cd | 206 | device.putc(y0H); |
akira | 2:5d8d5291b4cd | 207 | device.putc(y0L); |
akira | 2:5d8d5291b4cd | 208 | device.putc(rH); |
akira | 2:5d8d5291b4cd | 209 | device.putc(rL); |
akira | 2:5d8d5291b4cd | 210 | device.putc(sum); |
akira | 2:5d8d5291b4cd | 211 | device.putc(0xAA); |
akira | 2:5d8d5291b4cd | 212 | } |
akira | 2:5d8d5291b4cd | 213 | |
akira | 2:5d8d5291b4cd | 214 | void line(int x0,int y0,int x1,int y1) |
akira | 2:5d8d5291b4cd | 215 | { |
akira | 2:5d8d5291b4cd | 216 | unsigned char x0H; |
akira | 2:5d8d5291b4cd | 217 | unsigned char x0L; |
akira | 2:5d8d5291b4cd | 218 | unsigned char x1H; |
akira | 2:5d8d5291b4cd | 219 | unsigned char x1L; |
akira | 2:5d8d5291b4cd | 220 | unsigned char y0H; |
akira | 2:5d8d5291b4cd | 221 | unsigned char y0L; |
akira | 2:5d8d5291b4cd | 222 | unsigned char y1H; |
akira | 2:5d8d5291b4cd | 223 | unsigned char y1L; |
akira | 2:5d8d5291b4cd | 224 | unsigned char sum; |
akira | 2:5d8d5291b4cd | 225 | |
akira | 2:5d8d5291b4cd | 226 | x0H = x0 >> 8; |
akira | 2:5d8d5291b4cd | 227 | x0L = x0 & 0xFF; |
akira | 2:5d8d5291b4cd | 228 | y0H = y0 >> 8; |
akira | 2:5d8d5291b4cd | 229 | y0L = y0 & 0xff; |
akira | 2:5d8d5291b4cd | 230 | x1H = x1 >> 8; |
akira | 2:5d8d5291b4cd | 231 | x1L = x1 & 0xFF; |
akira | 2:5d8d5291b4cd | 232 | y1H = y1 >> 8; |
akira | 2:5d8d5291b4cd | 233 | y1L = y1 & 0xff; |
akira | 2:5d8d5291b4cd | 234 | sum = x0H+x0L+y0H+y0L+x1H+x1L+y1H+y1L+02; |
akira | 2:5d8d5291b4cd | 235 | device.putc(0x55); |
akira | 2:5d8d5291b4cd | 236 | device.putc(0x09); |
akira | 2:5d8d5291b4cd | 237 | device.putc(0x02);//command |
akira | 2:5d8d5291b4cd | 238 | device.putc(x0H); |
akira | 2:5d8d5291b4cd | 239 | device.putc(x0L); |
akira | 2:5d8d5291b4cd | 240 | device.putc(y0H); |
akira | 2:5d8d5291b4cd | 241 | device.putc(y0L); |
akira | 2:5d8d5291b4cd | 242 | device.putc(x1H); |
akira | 2:5d8d5291b4cd | 243 | device.putc(x1L); |
akira | 2:5d8d5291b4cd | 244 | device.putc(y1H); |
akira | 2:5d8d5291b4cd | 245 | device.putc(y1L); |
akira | 2:5d8d5291b4cd | 246 | device.putc(sum); |
akira | 2:5d8d5291b4cd | 247 | device.putc(0xAA); |
akira | 2:5d8d5291b4cd | 248 | } |
akira | 4:1f72df1a88e0 | 249 | void lcdput(unsigned char data,int x,int y) |
akira | 2:5d8d5291b4cd | 250 | { |
akira | 2:5d8d5291b4cd | 251 | unsigned char s; |
akira | 2:5d8d5291b4cd | 252 | unsigned char x0H; |
akira | 2:5d8d5291b4cd | 253 | unsigned char x0L; |
akira | 2:5d8d5291b4cd | 254 | unsigned char y0H; |
akira | 2:5d8d5291b4cd | 255 | unsigned char y0L; |
akira | 2:5d8d5291b4cd | 256 | unsigned char datalen; |
akira | 2:5d8d5291b4cd | 257 | x0H = x >> 8; |
akira | 2:5d8d5291b4cd | 258 | x0L = x & 0xFF; |
akira | 2:5d8d5291b4cd | 259 | y0H = y >> 8; |
akira | 2:5d8d5291b4cd | 260 | y0L = y & 0xFF; |
akira | 4:1f72df1a88e0 | 261 | datalen = 6; |
akira | 2:5d8d5291b4cd | 262 | device.putc(0x55); |
akira | 2:5d8d5291b4cd | 263 | device.putc(datalen); |
akira | 2:5d8d5291b4cd | 264 | device.putc(0x0B); // command ASCII Print |
akira | 2:5d8d5291b4cd | 265 | device.putc(x0H); //x upper 8bit |
akira | 2:5d8d5291b4cd | 266 | device.putc(x0L); //x low 8bit |
akira | 2:5d8d5291b4cd | 267 | device.putc(y0H); //y upper 8bit |
akira | 2:5d8d5291b4cd | 268 | device.putc(y0L); //y low 8bit |
akira | 4:1f72df1a88e0 | 269 | device.putc(data); |
akira | 4:1f72df1a88e0 | 270 | s = data+x0H+x0L+y0H+y0L+0x0B; |
akira | 2:5d8d5291b4cd | 271 | device.putc(s);//sumcheck |
akira | 2:5d8d5291b4cd | 272 | device.putc(0xAA); |
akira | 5:39b01a6f0f75 | 273 | // pc.printf("print %x %x %x %x %x %d ",x0H,x0L,y0H,y0L,s,datalen); |
akira | 4:1f72df1a88e0 | 274 | } |
akira | 4:1f72df1a88e0 | 275 | |
akira | 4:1f72df1a88e0 | 276 | |
akira | 4:1f72df1a88e0 | 277 | void s_Lcdinit() |
akira | 4:1f72df1a88e0 | 278 | { |
akira | 4:1f72df1a88e0 | 279 | // device.baud(9600); |
akira | 4:1f72df1a88e0 | 280 | rst = 0; //Reset |
akira | 4:1f72df1a88e0 | 281 | wait(0.1); |
akira | 4:1f72df1a88e0 | 282 | rst = 1; |
akira | 4:1f72df1a88e0 | 283 | wait(0.1); |
akira | 4:1f72df1a88e0 | 284 | lcdspeed();//speed 115200 |
akira | 4:1f72df1a88e0 | 285 | wait(0.1); |
akira | 4:1f72df1a88e0 | 286 | device.baud(115200); |
akira | 4:1f72df1a88e0 | 287 | device.putc(0x55);//Back light On |
akira | 4:1f72df1a88e0 | 288 | device.putc(0x03); |
akira | 4:1f72df1a88e0 | 289 | device.putc(0x89); |
akira | 4:1f72df1a88e0 | 290 | device.putc(0x01); |
akira | 4:1f72df1a88e0 | 291 | device.putc(0x2C); |
akira | 4:1f72df1a88e0 | 292 | device.putc(0xB6); |
akira | 4:1f72df1a88e0 | 293 | device.putc(0xAA); |
akira | 4:1f72df1a88e0 | 294 | cls(); |
akira | 5:39b01a6f0f75 | 295 | |
akira | 5:39b01a6f0f75 | 296 | } |
akira | 5:39b01a6f0f75 | 297 | |
akira | 5:39b01a6f0f75 | 298 | void kanji_init(){ |
akira | 5:39b01a6f0f75 | 299 | printf("Open File...\n"); // Drive should be marked as removed |
akira | 5:39b01a6f0f75 | 300 | //move cursor |
akira | 5:39b01a6f0f75 | 301 | fp = fopen("/local/SHMZN16X.FNT", "r"); |
akira | 5:39b01a6f0f75 | 302 | //FILE *fp = fopen("/local/k12x10.fnt", "r"); |
akira | 5:39b01a6f0f75 | 303 | |
akira | 5:39b01a6f0f75 | 304 | if(!fp) { |
akira | 5:39b01a6f0f75 | 305 | printf("File could not be opened!\n"); |
akira | 5:39b01a6f0f75 | 306 | exit(1); |
akira | 4:1f72df1a88e0 | 307 | } |
akira | 4:1f72df1a88e0 | 308 | |
akira | 5:39b01a6f0f75 | 309 | fgets(Identifier, 6+1, fp); // FONTX2 |
akira | 5:39b01a6f0f75 | 310 | fgets(FontName, 8+1, fp); |
akira | 5:39b01a6f0f75 | 311 | fread(&XSize, 1, 1, fp); |
akira | 5:39b01a6f0f75 | 312 | fread(&YSize, 1, 1, fp); |
akira | 5:39b01a6f0f75 | 313 | fread(&CodeType, 1, 1, fp); |
akira | 5:39b01a6f0f75 | 314 | fread(&Tnum, 1, 1, fp); |
akira | 5:39b01a6f0f75 | 315 | |
akira | 5:39b01a6f0f75 | 316 | Size = FONT_XBYTE*YSize; |
akira | 5:39b01a6f0f75 | 317 | printf("\nfget[%d]\n",fgetc( fp )); |
akira | 5:39b01a6f0f75 | 318 | // Table read |
akira | 5:39b01a6f0f75 | 319 | for(int a=0;a<=Size*4;a++){ |
akira | 5:39b01a6f0f75 | 320 | fread(&start[a],1,2,fp); |
akira | 5:39b01a6f0f75 | 321 | fread(&end[a] ,1,2,fp); |
akira | 5:39b01a6f0f75 | 322 | } |
akira | 5:39b01a6f0f75 | 323 | } |
akira | 5:39b01a6f0f75 | 324 | |
akira | 5:39b01a6f0f75 | 325 | //Kanji puts cr = kanji address |
akira | 5:39b01a6f0f75 | 326 | void k_puts(int cr){ |
akira | 5:39b01a6f0f75 | 327 | int c; |
akira | 5:39b01a6f0f75 | 328 | /* fp = fopen("/local/SHMZN16X.FNT", "r"); |
akira | 5:39b01a6f0f75 | 329 | if(!fp) { |
akira | 5:39b01a6f0f75 | 330 | pc.printf("File could not be opened!\n"); |
akira | 5:39b01a6f0f75 | 331 | exit(1); |
akira | 5:39b01a6f0f75 | 332 | } |
akira | 5:39b01a6f0f75 | 333 | */ |
akira | 5:39b01a6f0f75 | 334 | // Kanji image Read |
akira | 5:39b01a6f0f75 | 335 | fseek( fp, Tnum*4+18+32*cr, SEEK_SET ); |
akira | 5:39b01a6f0f75 | 336 | fread(&font,1,32,fp); |
akira | 5:39b01a6f0f75 | 337 | // kanji put |
akira | 5:39b01a6f0f75 | 338 | c=0; |
akira | 5:39b01a6f0f75 | 339 | for (int y=0;y<16;y++){ |
akira | 5:39b01a6f0f75 | 340 | for (int x=0;x<8;x++){ |
akira | 5:39b01a6f0f75 | 341 | if((font[c] & 0x80)==0x80){ |
akira | 5:39b01a6f0f75 | 342 | pixel(csrx+x,csry+y); |
akira | 5:39b01a6f0f75 | 343 | } |
akira | 5:39b01a6f0f75 | 344 | font[c] = font[c] << 1; |
akira | 5:39b01a6f0f75 | 345 | if((font[c+1] & 0x80)==0x80){ |
akira | 5:39b01a6f0f75 | 346 | pixel(csrx+x+8,csry+y); |
akira | 5:39b01a6f0f75 | 347 | } |
akira | 5:39b01a6f0f75 | 348 | font[c+1] = font[c+1] << 1; |
akira | 5:39b01a6f0f75 | 349 | } |
akira | 5:39b01a6f0f75 | 350 | c+=2; |
akira | 5:39b01a6f0f75 | 351 | } |
akira | 5:39b01a6f0f75 | 352 | //move cursor |
akira | 5:39b01a6f0f75 | 353 | csrx+=16; |
akira | 5:39b01a6f0f75 | 354 | if(csrx>128){ //LF control |
akira | 5:39b01a6f0f75 | 355 | csrx=0; |
akira | 5:39b01a6f0f75 | 356 | csry+=16; |
akira | 5:39b01a6f0f75 | 357 | } |
akira | 5:39b01a6f0f75 | 358 | } |
akira | 5:39b01a6f0f75 | 359 | |
akira | 5:39b01a6f0f75 | 360 | void kanji_end(){ |
akira | 5:39b01a6f0f75 | 361 | fclose(fp); |
akira | 5:39b01a6f0f75 | 362 | } |