this is kazushi's branch of AD128160

Fork of AD128160 by Gingax x

Committer:
akira
Date:
Sun Oct 23 02:06:34 2011 +0000
Revision:
4:1f72df1a88e0
Parent:
3:f5576943e216
Child:
5:39b01a6f0f75

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
akira 2:5d8d5291b4cd 1 #include "mbed.h"
akira 2:5d8d5291b4cd 2
akira 4:1f72df1a88e0 3 #define kanji_file "/local/SHMZN16X.FNT"
akira 4:1f72df1a88e0 4 //#defin kanji_file "/local/k12x10.fnt"
akira 4:1f72df1a88e0 5
akira 4:1f72df1a88e0 6 Serial device(p9, p10); // tx, rx LCD
akira 2:5d8d5291b4cd 7 DigitalOut rst(p20); //P20 --> LCD RST (Reset)
akira 2:5d8d5291b4cd 8
akira 4:1f72df1a88e0 9 LocalFileSystem local("local");
akira 4:1f72df1a88e0 10
akira 4:1f72df1a88e0 11 int cx = 0;
akira 4:1f72df1a88e0 12 int cy = 0;
akira 4:1f72df1a88e0 13 int offsety = 0;
akira 4:1f72df1a88e0 14 bool kstate = false;
akira 4:1f72df1a88e0 15 unsigned char kbuf;
akira 4:1f72df1a88e0 16
akira 4:1f72df1a88e0 17 FILE *fp; //File open buffer
akira 4:1f72df1a88e0 18
akira 4:1f72df1a88e0 19 unsigned short start[92], end[92];
akira 4:1f72df1a88e0 20 unsigned char font[64];
akira 4:1f72df1a88e0 21
akira 4:1f72df1a88e0 22 char Identifier[6+1];
akira 4:1f72df1a88e0 23 char FontName[8+1];
akira 4:1f72df1a88e0 24 unsigned char XSize;
akira 4:1f72df1a88e0 25 unsigned char YSize;
akira 4:1f72df1a88e0 26 unsigned char Size;
akira 4:1f72df1a88e0 27 unsigned char CodeType;
akira 4:1f72df1a88e0 28 unsigned char Tnum;
akira 4:1f72df1a88e0 29
akira 4:1f72df1a88e0 30 #define FONT_XBYTE ((XSize + 7) >> 3)
akira 4:1f72df1a88e0 31 #define FONT_YBYTE ((YSize + 7) >> 3)
akira 4:1f72df1a88e0 32
akira 2:5d8d5291b4cd 33 void lcdspeed()
akira 2:5d8d5291b4cd 34 {
akira 2:5d8d5291b4cd 35 device.putc(0x55);// UART Speed 115200bps
akira 2:5d8d5291b4cd 36 device.putc(0x05);
akira 2:5d8d5291b4cd 37 device.putc(0x8B);
akira 2:5d8d5291b4cd 38 device.putc(0x00);
akira 2:5d8d5291b4cd 39 device.putc(0x01);
akira 2:5d8d5291b4cd 40 device.putc(0xC2);
akira 2:5d8d5291b4cd 41 device.putc(0x00);
akira 2:5d8d5291b4cd 42 device.putc(0x4E);
akira 2:5d8d5291b4cd 43 device.putc(0xAA);
akira 2:5d8d5291b4cd 44 }
akira 4:1f72df1a88e0 45 void bmp(int x0,int y0,int bmp_no)
akira 4:1f72df1a88e0 46 {
akira 4:1f72df1a88e0 47 unsigned char x0H;
akira 4:1f72df1a88e0 48 unsigned char x0L;
akira 4:1f72df1a88e0 49 unsigned char y0H;
akira 4:1f72df1a88e0 50 unsigned char y0L;
akira 4:1f72df1a88e0 51 unsigned char rH;
akira 4:1f72df1a88e0 52 unsigned char rL;
akira 4:1f72df1a88e0 53 unsigned char sum;
akira 4:1f72df1a88e0 54
akira 4:1f72df1a88e0 55 x0H = x0 >> 8;
akira 4:1f72df1a88e0 56 x0L = x0 & 0xFF;
akira 4:1f72df1a88e0 57 y0H = y0 >> 8;
akira 4:1f72df1a88e0 58 y0L = y0 & 0xff;
akira 4:1f72df1a88e0 59 rH = bmp_no >> 8;
akira 4:1f72df1a88e0 60 rL = bmp_no & 0xFF;
akira 4:1f72df1a88e0 61 sum = x0H+x0L+y0H+y0L+rH+rL+0x09;
akira 4:1f72df1a88e0 62 device.putc(0x55);
akira 4:1f72df1a88e0 63 device.putc(0x07);
akira 4:1f72df1a88e0 64 device.putc(0x09);//command
akira 4:1f72df1a88e0 65 device.putc(x0H);
akira 4:1f72df1a88e0 66 device.putc(x0L);
akira 4:1f72df1a88e0 67 device.putc(y0H);
akira 4:1f72df1a88e0 68 device.putc(y0L);
akira 4:1f72df1a88e0 69 device.putc(rH);
akira 4:1f72df1a88e0 70 device.putc(rL);
akira 4:1f72df1a88e0 71 device.putc(sum);
akira 4:1f72df1a88e0 72 device.putc(0xAA);
akira 4:1f72df1a88e0 73 }
akira 2:5d8d5291b4cd 74
akira 2:5d8d5291b4cd 75 void cls()
akira 2:5d8d5291b4cd 76 {
akira 2:5d8d5291b4cd 77 device.putc(0x55);// Clear
akira 2:5d8d5291b4cd 78 device.putc(0x02);
akira 2:5d8d5291b4cd 79 device.putc(0x80);
akira 2:5d8d5291b4cd 80 device.putc(0x55);
akira 2:5d8d5291b4cd 81 device.putc(0xD5);
akira 2:5d8d5291b4cd 82 device.putc(0xAA);
akira 2:5d8d5291b4cd 83 }
akira 4:1f72df1a88e0 84 void scroll(void){
akira 2:5d8d5291b4cd 85
akira 4:1f72df1a88e0 86 }
akira 4:1f72df1a88e0 87
akira 4:1f72df1a88e0 88
akira 4:1f72df1a88e0 89
akira 4:1f72df1a88e0 90
akira 4:1f72df1a88e0 91 void lcdputs( char data[98],int x,int y)
akira 2:5d8d5291b4cd 92 {
akira 4:1f72df1a88e0 93 unsigned char s=0;
akira 4:1f72df1a88e0 94 unsigned char x0H;
akira 4:1f72df1a88e0 95 unsigned char x0L;
akira 4:1f72df1a88e0 96 unsigned char y0H;
akira 4:1f72df1a88e0 97 unsigned char y0L;
akira 4:1f72df1a88e0 98 unsigned char datalen;
akira 4:1f72df1a88e0 99 x0H = x >> 8;
akira 4:1f72df1a88e0 100 x0L = x & 0xFF;
akira 4:1f72df1a88e0 101 y0H = y >> 8;
akira 4:1f72df1a88e0 102 y0L = y & 0xFF;
akira 4:1f72df1a88e0 103 datalen = strlen(data)+5;
akira 4:1f72df1a88e0 104 device.putc(0x55);
akira 4:1f72df1a88e0 105 device.putc(datalen);
akira 4:1f72df1a88e0 106 device.putc(0x0B); // command ASCII Print
akira 4:1f72df1a88e0 107 device.putc(x0H); //x upper 8bit
akira 4:1f72df1a88e0 108 device.putc(x0L); //x low 8bit
akira 4:1f72df1a88e0 109 device.putc(y0H); //y upper 8bit
akira 4:1f72df1a88e0 110 device.putc(y0L); //y low 8bit
akira 4:1f72df1a88e0 111 for(int a=0;a<strlen(data);a++)
akira 4:1f72df1a88e0 112 {
akira 4:1f72df1a88e0 113 device.putc(data[a]);
akira 4:1f72df1a88e0 114 s = s+data[a];
akira 4:1f72df1a88e0 115 }
akira 4:1f72df1a88e0 116 s = s+x0H+x0L+y0H+y0L+0x0B;
akira 4:1f72df1a88e0 117 device.putc(s);//sumcheck
akira 3:f5576943e216 118 device.putc(0xAA);
akira 2:5d8d5291b4cd 119 }
akira 2:5d8d5291b4cd 120
akira 2:5d8d5291b4cd 121 void color(int rgb)
akira 2:5d8d5291b4cd 122 {
akira 2:5d8d5291b4cd 123 int c1;
akira 2:5d8d5291b4cd 124 int c2;
akira 2:5d8d5291b4cd 125 int sum;
akira 2:5d8d5291b4cd 126
akira 2:5d8d5291b4cd 127 c1=(rgb >> 8) & 0xff;
akira 2:5d8d5291b4cd 128 c2=(rgb & 0xff);
akira 2:5d8d5291b4cd 129 sum=c1+c2+0x84;
akira 2:5d8d5291b4cd 130 device.putc(0x55);
akira 2:5d8d5291b4cd 131 device.putc(0x03);
akira 2:5d8d5291b4cd 132 device.putc(0x84);
akira 2:5d8d5291b4cd 133 device.putc(c1);
akira 2:5d8d5291b4cd 134 device.putc(c2);
akira 2:5d8d5291b4cd 135 device.putc(sum);
akira 2:5d8d5291b4cd 136 device.putc(0xAA);
akira 2:5d8d5291b4cd 137 }
akira 2:5d8d5291b4cd 138
akira 4:1f72df1a88e0 139 void newline(void){
akira 4:1f72df1a88e0 140 cx = 0;
akira 4:1f72df1a88e0 141 cy += 16;
akira 4:1f72df1a88e0 142 if(cy > 160){
akira 4:1f72df1a88e0 143 scroll();
akira 4:1f72df1a88e0 144 cy = 0;
akira 4:1f72df1a88e0 145 color(0x001f);
akira 4:1f72df1a88e0 146 cls();
akira 4:1f72df1a88e0 147 color(0xffff);
akira 4:1f72df1a88e0 148 }
akira 4:1f72df1a88e0 149 }
akira 4:1f72df1a88e0 150
akira 4:1f72df1a88e0 151 void movecorsor(int a)
akira 4:1f72df1a88e0 152 {
akira 4:1f72df1a88e0 153 cx+=8*a;
akira 4:1f72df1a88e0 154 if(cx>=128) newline();
akira 4:1f72df1a88e0 155 }
akira 4:1f72df1a88e0 156
akira 4:1f72df1a88e0 157
akira 2:5d8d5291b4cd 158 void pixel(int x0,int y0)
akira 2:5d8d5291b4cd 159 {
akira 2:5d8d5291b4cd 160 unsigned char x0H;
akira 2:5d8d5291b4cd 161 unsigned char x0L;
akira 2:5d8d5291b4cd 162 unsigned char y0H;
akira 2:5d8d5291b4cd 163 unsigned char y0L;
akira 2:5d8d5291b4cd 164 unsigned char sum;
akira 2:5d8d5291b4cd 165
akira 2:5d8d5291b4cd 166 x0H = x0 >> 8;
akira 2:5d8d5291b4cd 167 x0L = x0 & 0xFF;
akira 2:5d8d5291b4cd 168 y0H = y0 >> 8;
akira 2:5d8d5291b4cd 169 y0L = y0 & 0xff;
akira 2:5d8d5291b4cd 170
akira 2:5d8d5291b4cd 171 sum = x0H+x0L+y0H+y0L+0x01;
akira 2:5d8d5291b4cd 172 device.putc(0x55);
akira 2:5d8d5291b4cd 173 device.putc(0x05);
akira 2:5d8d5291b4cd 174 device.putc(0x01);//command
akira 2:5d8d5291b4cd 175 device.putc(x0H);
akira 2:5d8d5291b4cd 176 device.putc(x0L);
akira 2:5d8d5291b4cd 177 device.putc(y0H);
akira 2:5d8d5291b4cd 178 device.putc(y0L);
akira 2:5d8d5291b4cd 179 device.putc(sum);
akira 2:5d8d5291b4cd 180 device.putc(0xAA);
akira 2:5d8d5291b4cd 181 }
akira 2:5d8d5291b4cd 182
akira 2:5d8d5291b4cd 183 void box(int x0,int y0,int x1,int y1,int paint)
akira 2:5d8d5291b4cd 184 {
akira 2:5d8d5291b4cd 185 unsigned char x0H;
akira 2:5d8d5291b4cd 186 unsigned char x0L;
akira 2:5d8d5291b4cd 187 unsigned char x1H;
akira 2:5d8d5291b4cd 188 unsigned char x1L;
akira 2:5d8d5291b4cd 189 unsigned char y0H;
akira 2:5d8d5291b4cd 190 unsigned char y0L;
akira 2:5d8d5291b4cd 191 unsigned char y1H;
akira 2:5d8d5291b4cd 192 unsigned char y1L;
akira 2:5d8d5291b4cd 193 unsigned char sum;
akira 2:5d8d5291b4cd 194 unsigned char cmd;
akira 2:5d8d5291b4cd 195 switch (paint)
akira 2:5d8d5291b4cd 196 {
akira 2:5d8d5291b4cd 197 case 1:
akira 2:5d8d5291b4cd 198 cmd = 0x04;
akira 2:5d8d5291b4cd 199 break;
akira 2:5d8d5291b4cd 200 default:
akira 2:5d8d5291b4cd 201 cmd =0x03;
akira 2:5d8d5291b4cd 202 break;
akira 2:5d8d5291b4cd 203 }
akira 2:5d8d5291b4cd 204 x0H = x0 >> 8;
akira 2:5d8d5291b4cd 205 x0L = x0 & 0xFF;
akira 2:5d8d5291b4cd 206 y0H = y0 >> 8;
akira 2:5d8d5291b4cd 207 y0L = y0 & 0xff;
akira 2:5d8d5291b4cd 208 x1H = x1 >> 8;
akira 2:5d8d5291b4cd 209 x1L = x1 & 0xFF;
akira 2:5d8d5291b4cd 210 y1H = y1 >> 8;
akira 2:5d8d5291b4cd 211 y1L = y1 & 0xff;
akira 2:5d8d5291b4cd 212 sum = x0H+x0L+y0H+y0L+x1H+x1L+y1H+y1L+cmd;
akira 2:5d8d5291b4cd 213 device.putc(0x55);//Box
akira 2:5d8d5291b4cd 214 device.putc(0x09);
akira 2:5d8d5291b4cd 215 device.putc(cmd);//command
akira 2:5d8d5291b4cd 216 device.putc(x0H);
akira 2:5d8d5291b4cd 217 device.putc(x0L);
akira 2:5d8d5291b4cd 218 device.putc(y0H);
akira 2:5d8d5291b4cd 219 device.putc(y0L);
akira 2:5d8d5291b4cd 220 device.putc(x1H);
akira 2:5d8d5291b4cd 221 device.putc(x1L);
akira 2:5d8d5291b4cd 222 device.putc(y1H);
akira 2:5d8d5291b4cd 223 device.putc(y1L);
akira 2:5d8d5291b4cd 224 device.putc(sum);
akira 2:5d8d5291b4cd 225 device.putc(0xAA);
akira 2:5d8d5291b4cd 226 }
akira 2:5d8d5291b4cd 227
akira 2:5d8d5291b4cd 228 void circle(int x0,int y0,int r,int paint)
akira 2:5d8d5291b4cd 229 {
akira 2:5d8d5291b4cd 230 unsigned char x0H;
akira 2:5d8d5291b4cd 231 unsigned char x0L;
akira 2:5d8d5291b4cd 232 unsigned char y0H;
akira 2:5d8d5291b4cd 233 unsigned char y0L;
akira 2:5d8d5291b4cd 234 unsigned char rH;
akira 2:5d8d5291b4cd 235 unsigned char rL;
akira 2:5d8d5291b4cd 236 unsigned char sum;
akira 2:5d8d5291b4cd 237 unsigned char cmd;
akira 2:5d8d5291b4cd 238 switch (paint)
akira 2:5d8d5291b4cd 239 {
akira 2:5d8d5291b4cd 240 case 0:
akira 2:5d8d5291b4cd 241 cmd = 0x05;
akira 2:5d8d5291b4cd 242 break;
akira 2:5d8d5291b4cd 243 case 1:
akira 2:5d8d5291b4cd 244 cmd = 0x06;
akira 2:5d8d5291b4cd 245 break;
akira 2:5d8d5291b4cd 246 default:
akira 2:5d8d5291b4cd 247 cmd =0x05;
akira 2:5d8d5291b4cd 248 break;
akira 2:5d8d5291b4cd 249 }
akira 2:5d8d5291b4cd 250 x0H = x0 >> 8;
akira 2:5d8d5291b4cd 251 x0L = x0 & 0xFF;
akira 2:5d8d5291b4cd 252 y0H = y0 >> 8;
akira 2:5d8d5291b4cd 253 y0L = y0 & 0xff;
akira 2:5d8d5291b4cd 254 rH = r >> 8;
akira 2:5d8d5291b4cd 255 rL = r & 0xFF;
akira 2:5d8d5291b4cd 256 sum = x0H+x0L+y0H+y0L+rH+rL+cmd;
akira 2:5d8d5291b4cd 257 device.putc(0x55);
akira 2:5d8d5291b4cd 258 device.putc(0x07);
akira 2:5d8d5291b4cd 259 device.putc(cmd);//command
akira 2:5d8d5291b4cd 260 device.putc(x0H);
akira 2:5d8d5291b4cd 261 device.putc(x0L);
akira 2:5d8d5291b4cd 262 device.putc(y0H);
akira 2:5d8d5291b4cd 263 device.putc(y0L);
akira 2:5d8d5291b4cd 264 device.putc(rH);
akira 2:5d8d5291b4cd 265 device.putc(rL);
akira 2:5d8d5291b4cd 266 device.putc(sum);
akira 2:5d8d5291b4cd 267 device.putc(0xAA);
akira 2:5d8d5291b4cd 268 }
akira 2:5d8d5291b4cd 269
akira 2:5d8d5291b4cd 270 void line(int x0,int y0,int x1,int y1)
akira 2:5d8d5291b4cd 271 {
akira 2:5d8d5291b4cd 272 unsigned char x0H;
akira 2:5d8d5291b4cd 273 unsigned char x0L;
akira 2:5d8d5291b4cd 274 unsigned char x1H;
akira 2:5d8d5291b4cd 275 unsigned char x1L;
akira 2:5d8d5291b4cd 276 unsigned char y0H;
akira 2:5d8d5291b4cd 277 unsigned char y0L;
akira 2:5d8d5291b4cd 278 unsigned char y1H;
akira 2:5d8d5291b4cd 279 unsigned char y1L;
akira 2:5d8d5291b4cd 280 unsigned char sum;
akira 2:5d8d5291b4cd 281
akira 2:5d8d5291b4cd 282 x0H = x0 >> 8;
akira 2:5d8d5291b4cd 283 x0L = x0 & 0xFF;
akira 2:5d8d5291b4cd 284 y0H = y0 >> 8;
akira 2:5d8d5291b4cd 285 y0L = y0 & 0xff;
akira 2:5d8d5291b4cd 286 x1H = x1 >> 8;
akira 2:5d8d5291b4cd 287 x1L = x1 & 0xFF;
akira 2:5d8d5291b4cd 288 y1H = y1 >> 8;
akira 2:5d8d5291b4cd 289 y1L = y1 & 0xff;
akira 2:5d8d5291b4cd 290 sum = x0H+x0L+y0H+y0L+x1H+x1L+y1H+y1L+02;
akira 2:5d8d5291b4cd 291 device.putc(0x55);
akira 2:5d8d5291b4cd 292 device.putc(0x09);
akira 2:5d8d5291b4cd 293 device.putc(0x02);//command
akira 2:5d8d5291b4cd 294 device.putc(x0H);
akira 2:5d8d5291b4cd 295 device.putc(x0L);
akira 2:5d8d5291b4cd 296 device.putc(y0H);
akira 2:5d8d5291b4cd 297 device.putc(y0L);
akira 2:5d8d5291b4cd 298 device.putc(x1H);
akira 2:5d8d5291b4cd 299 device.putc(x1L);
akira 2:5d8d5291b4cd 300 device.putc(y1H);
akira 2:5d8d5291b4cd 301 device.putc(y1L);
akira 2:5d8d5291b4cd 302 device.putc(sum);
akira 2:5d8d5291b4cd 303 device.putc(0xAA);
akira 2:5d8d5291b4cd 304 }
akira 4:1f72df1a88e0 305 void lcdput(unsigned char data,int x,int y)
akira 2:5d8d5291b4cd 306 {
akira 2:5d8d5291b4cd 307 unsigned char s;
akira 2:5d8d5291b4cd 308 unsigned char x0H;
akira 2:5d8d5291b4cd 309 unsigned char x0L;
akira 2:5d8d5291b4cd 310 unsigned char y0H;
akira 2:5d8d5291b4cd 311 unsigned char y0L;
akira 2:5d8d5291b4cd 312 unsigned char datalen;
akira 2:5d8d5291b4cd 313 x0H = x >> 8;
akira 2:5d8d5291b4cd 314 x0L = x & 0xFF;
akira 2:5d8d5291b4cd 315 y0H = y >> 8;
akira 2:5d8d5291b4cd 316 y0L = y & 0xFF;
akira 4:1f72df1a88e0 317 datalen = 6;
akira 2:5d8d5291b4cd 318 device.putc(0x55);
akira 2:5d8d5291b4cd 319 device.putc(datalen);
akira 2:5d8d5291b4cd 320 device.putc(0x0B); // command ASCII Print
akira 2:5d8d5291b4cd 321 device.putc(x0H); //x upper 8bit
akira 2:5d8d5291b4cd 322 device.putc(x0L); //x low 8bit
akira 2:5d8d5291b4cd 323 device.putc(y0H); //y upper 8bit
akira 2:5d8d5291b4cd 324 device.putc(y0L); //y low 8bit
akira 4:1f72df1a88e0 325 device.putc(data);
akira 4:1f72df1a88e0 326 s = data+x0H+x0L+y0H+y0L+0x0B;
akira 2:5d8d5291b4cd 327 device.putc(s);//sumcheck
akira 2:5d8d5291b4cd 328 device.putc(0xAA);
akira 4:1f72df1a88e0 329 }
akira 4:1f72df1a88e0 330
akira 4:1f72df1a88e0 331
akira 4:1f72df1a88e0 332
akira 4:1f72df1a88e0 333 void kanji_init(){
akira 4:1f72df1a88e0 334 //move cursor
akira 4:1f72df1a88e0 335 fp = fopen(kanji_file , "r");
akira 4:1f72df1a88e0 336
akira 4:1f72df1a88e0 337
akira 4:1f72df1a88e0 338 if(!fp) {
akira 4:1f72df1a88e0 339 printf("File could not be opened!\n");
akira 4:1f72df1a88e0 340 exit(1);
akira 4:1f72df1a88e0 341 }
akira 4:1f72df1a88e0 342
akira 4:1f72df1a88e0 343 fgets(Identifier, 6+1, fp); // FONTX2
akira 4:1f72df1a88e0 344 fgets(FontName, 8+1, fp);
akira 4:1f72df1a88e0 345 fread(&XSize, 1, 1, fp);
akira 4:1f72df1a88e0 346 fread(&YSize, 1, 1, fp);
akira 4:1f72df1a88e0 347 fread(&CodeType, 1, 1, fp);
akira 4:1f72df1a88e0 348 fread(&Tnum, 1, 1, fp);
akira 4:1f72df1a88e0 349
akira 4:1f72df1a88e0 350 // Table read
akira 4:1f72df1a88e0 351 for(int a=0;a< Tnum ;a++){
akira 4:1f72df1a88e0 352 fread(&start[a],1,2,fp);
akira 4:1f72df1a88e0 353 fread(&end[a] ,1,2,fp);
akira 4:1f72df1a88e0 354 }
akira 4:1f72df1a88e0 355 }
akira 4:1f72df1a88e0 356
akira 4:1f72df1a88e0 357 //Kanji puts cr = kanji cord
akira 4:1f72df1a88e0 358 void k_puts(int cr){
akira 4:1f72df1a88e0 359 //kanji address
akira 4:1f72df1a88e0 360 int c;
akira 4:1f72df1a88e0 361 int adrs;
akira 4:1f72df1a88e0 362 c=0;
akira 4:1f72df1a88e0 363 adrs=0;
akira 4:1f72df1a88e0 364 while(cr>start[c]){
akira 4:1f72df1a88e0 365 if(cr > end[c]){
akira 4:1f72df1a88e0 366 adrs += end[c]-start[c]+1;
akira 4:1f72df1a88e0 367 }
akira 4:1f72df1a88e0 368 else{
akira 4:1f72df1a88e0 369 adrs += cr - start[c];
akira 4:1f72df1a88e0 370 }
akira 4:1f72df1a88e0 371 c++;
akira 2:5d8d5291b4cd 372 }
akira 4:1f72df1a88e0 373 c--;
akira 4:1f72df1a88e0 374 //printf("C=%d,adrs=%d cr=%X ",c,adrs,cr);
akira 4:1f72df1a88e0 375 // Kanji image Read
akira 4:1f72df1a88e0 376 fseek( fp, Tnum*4+18+32*adrs, SEEK_SET );
akira 4:1f72df1a88e0 377 fread(&font,1,32,fp);
akira 4:1f72df1a88e0 378 // kanji put
akira 4:1f72df1a88e0 379 c=0;
akira 4:1f72df1a88e0 380 for (int y=0;y<16;y++){
akira 4:1f72df1a88e0 381 for (int x=0;x<8;x++){
akira 4:1f72df1a88e0 382 if((font[c] & 0x80)==0x80){
akira 4:1f72df1a88e0 383 pixel(cx+x,cy+y);
akira 4:1f72df1a88e0 384 }
akira 4:1f72df1a88e0 385 font[c] = font[c] << 1;
akira 4:1f72df1a88e0 386 if((font[c+1] & 0x80)==0x80){
akira 4:1f72df1a88e0 387 pixel(cx+x+8,cy+y);
akira 4:1f72df1a88e0 388 }
akira 4:1f72df1a88e0 389 font[c+1] = font[c+1] << 1;
akira 4:1f72df1a88e0 390 }
akira 4:1f72df1a88e0 391 c+=2;
akira 4:1f72df1a88e0 392 }
akira 4:1f72df1a88e0 393 //move cursor
akira 4:1f72df1a88e0 394 cx+=16;
akira 4:1f72df1a88e0 395 if(cx>=128){ //LF control
akira 4:1f72df1a88e0 396 cx=0;
akira 4:1f72df1a88e0 397 cy+=16;
akira 4:1f72df1a88e0 398 }
akira 4:1f72df1a88e0 399 }
akira 4:1f72df1a88e0 400
akira 4:1f72df1a88e0 401 void kanji_end(){
akira 4:1f72df1a88e0 402 fclose(fp);
akira 4:1f72df1a88e0 403 }
akira 4:1f72df1a88e0 404
akira 4:1f72df1a88e0 405 void drawc(unsigned char c){
akira 4:1f72df1a88e0 406 if(kstate){ // 2nd byte of shift-jis
akira 4:1f72df1a88e0 407 kstate = false;
akira 4:1f72df1a88e0 408
akira 4:1f72df1a88e0 409 k_puts(kbuf << 8 | c);
akira 4:1f72df1a88e0 410 } else if((0x81 <= c && c <= 0x9f) || (0xe0 <= c && c <= 0xfc)){ // 1st byte of shift-jis
akira 4:1f72df1a88e0 411 kstate = true;
akira 4:1f72df1a88e0 412 kbuf = c;
akira 4:1f72df1a88e0 413 } else { // Ascii Out
akira 4:1f72df1a88e0 414 lcdput(c,cx,cy);
akira 4:1f72df1a88e0 415 movecorsor(1); // 1byte Move
akira 4:1f72df1a88e0 416 }
akira 4:1f72df1a88e0 417 }
akira 4:1f72df1a88e0 418
akira 4:1f72df1a88e0 419
akira 4:1f72df1a88e0 420 void s_Lcdinit()
akira 4:1f72df1a88e0 421 {
akira 4:1f72df1a88e0 422 // device.baud(9600);
akira 4:1f72df1a88e0 423 rst = 0; //Reset
akira 4:1f72df1a88e0 424 wait(0.1);
akira 4:1f72df1a88e0 425 rst = 1;
akira 4:1f72df1a88e0 426 wait(0.1);
akira 4:1f72df1a88e0 427 lcdspeed();//speed 115200
akira 4:1f72df1a88e0 428 wait(0.1);
akira 4:1f72df1a88e0 429 device.baud(115200);
akira 4:1f72df1a88e0 430 device.putc(0x55);//Back light On
akira 4:1f72df1a88e0 431 device.putc(0x03);
akira 4:1f72df1a88e0 432 device.putc(0x89);
akira 4:1f72df1a88e0 433 device.putc(0x01);
akira 4:1f72df1a88e0 434 device.putc(0x2C);
akira 4:1f72df1a88e0 435 device.putc(0xB6);
akira 4:1f72df1a88e0 436 device.putc(0xAA);
akira 4:1f72df1a88e0 437 bmp(0,0,1);
akira 4:1f72df1a88e0 438 lcdputs(" GingaX ",20,140);
akira 4:1f72df1a88e0 439 wait(3);
akira 4:1f72df1a88e0 440 bmp(0,0,0);
akira 4:1f72df1a88e0 441 wait(3);
akira 4:1f72df1a88e0 442 cls();
akira 4:1f72df1a88e0 443 color(0xffff);
akira 4:1f72df1a88e0 444 kanji_init();
akira 4:1f72df1a88e0 445 }
akira 4:1f72df1a88e0 446