this is kazushi's branch of AD128160

Fork of AD128160 by Gingax x

Committer:
kazushi2008
Date:
Mon Jan 07 04:15:00 2013 +0000
Revision:
7:227b64bf8fb1
Parent:
6:96576c9c7828
Child:
8:5b2cbd7120d3
customized for twitterMbed

Who changed what in which revision?

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