AD-128160-UART制御用のライブラリ http://www.aitendo.co.jp/product/3119 gingaxさんのプログラムを参考に作らせてもらっています。 http://mbed.org/users/akira/libraries/AD128160/m159hi

Dependents:   AD128160_HelloWorld

Committer:
nucho
Date:
Mon Dec 12 02:38:49 2011 +0000
Revision:
2:6f2db745808e
Parent:
0:2e2f3b389d8a
Child:
3:d15cda2a5e91

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nucho 0:2e2f3b389d8a 1 #include "AD128160.h"
nucho 0:2e2f3b389d8a 2
nucho 0:2e2f3b389d8a 3
nucho 0:2e2f3b389d8a 4 AD128160::AD128160(PinName tx,PinName reset):_device(tx,NC),_rst(reset) {
nucho 2:6f2db745808e 5 init();
nucho 0:2e2f3b389d8a 6 }
nucho 0:2e2f3b389d8a 7
nucho 0:2e2f3b389d8a 8 int AD128160::_putc(int c) {
nucho 0:2e2f3b389d8a 9 if (c == '\n') {
nucho 0:2e2f3b389d8a 10 newline();
nucho 0:2e2f3b389d8a 11 } else {
nucho 0:2e2f3b389d8a 12 int x = _column * 8; // FIXME: Char sizes
nucho 0:2e2f3b389d8a 13 int y = _row * 16;
nucho 0:2e2f3b389d8a 14
nucho 0:2e2f3b389d8a 15 unsigned char sum;
nucho 0:2e2f3b389d8a 16 unsigned char x0H;
nucho 0:2e2f3b389d8a 17 unsigned char x0L;
nucho 0:2e2f3b389d8a 18 unsigned char y0H;
nucho 0:2e2f3b389d8a 19 unsigned char y0L;
nucho 0:2e2f3b389d8a 20 unsigned char datalen;
nucho 0:2e2f3b389d8a 21 x0H = x >> 8;
nucho 0:2e2f3b389d8a 22 x0L = x & 0xFF;
nucho 0:2e2f3b389d8a 23 y0H = y >> 8;
nucho 0:2e2f3b389d8a 24 y0L = y & 0xFF;
nucho 0:2e2f3b389d8a 25 datalen = 6;
nucho 0:2e2f3b389d8a 26 _device.putc(0x55);
nucho 0:2e2f3b389d8a 27 _device.putc(datalen);
nucho 0:2e2f3b389d8a 28 _device.putc(0x0B); // command ASCII Print
nucho 0:2e2f3b389d8a 29 _device.putc(x0H); //x upper 8bit
nucho 0:2e2f3b389d8a 30 _device.putc(x0L); //x low 8bit
nucho 0:2e2f3b389d8a 31 _device.putc(y0H); //y upper 8bit
nucho 0:2e2f3b389d8a 32 _device.putc(y0L); //y low 8bit
nucho 0:2e2f3b389d8a 33 _device.putc(c);
nucho 0:2e2f3b389d8a 34 sum = c+x0H+x0L+y0H+y0L+0x0B;
nucho 0:2e2f3b389d8a 35 _device.putc(sum);//sumch
nucho 0:2e2f3b389d8a 36 _device.putc(0xAA);
nucho 0:2e2f3b389d8a 37
nucho 0:2e2f3b389d8a 38 _column++;
nucho 0:2e2f3b389d8a 39 if (_column >= LCD_COLS) {
nucho 0:2e2f3b389d8a 40 _row++;
nucho 0:2e2f3b389d8a 41 _column = 0;
nucho 0:2e2f3b389d8a 42 }
nucho 0:2e2f3b389d8a 43 if (_row >= LCD_ROWS) {
nucho 0:2e2f3b389d8a 44 _row = 0;
nucho 0:2e2f3b389d8a 45 }
nucho 0:2e2f3b389d8a 46 }
nucho 0:2e2f3b389d8a 47 return c;
nucho 0:2e2f3b389d8a 48 }
nucho 0:2e2f3b389d8a 49
nucho 0:2e2f3b389d8a 50 void AD128160::init() {
nucho 0:2e2f3b389d8a 51 reset();
nucho 0:2e2f3b389d8a 52 brightness(300);
nucho 0:2e2f3b389d8a 53 cls();
nucho 0:2e2f3b389d8a 54 locate(0,0);
nucho 0:2e2f3b389d8a 55 color(0xffff);
nucho 0:2e2f3b389d8a 56 }
nucho 0:2e2f3b389d8a 57
nucho 2:6f2db745808e 58 void AD128160::brightness(int value) {
nucho 0:2e2f3b389d8a 59 unsigned char sum=0;
nucho 0:2e2f3b389d8a 60 unsigned char byte[2];
nucho 0:2e2f3b389d8a 61
nucho 0:2e2f3b389d8a 62 byte[0] = (value & 0xff00)>>8;
nucho 0:2e2f3b389d8a 63 byte[1] = value & 0x00ff;
nucho 2:6f2db745808e 64
nucho 0:2e2f3b389d8a 65 sum+=byte[0]+byte[1]+0x89;
nucho 2:6f2db745808e 66
nucho 0:2e2f3b389d8a 67 _device.putc(0x55);//Back light On
nucho 0:2e2f3b389d8a 68 _device.putc(0x03);
nucho 2:6f2db745808e 69 _device.putc(0x89);
nucho 0:2e2f3b389d8a 70 _device.putc(byte[0]);
nucho 0:2e2f3b389d8a 71 _device.putc(byte[1]);
nucho 0:2e2f3b389d8a 72 _device.putc(sum);
nucho 0:2e2f3b389d8a 73 _device.putc(0xAA);
nucho 0:2e2f3b389d8a 74 }
nucho 0:2e2f3b389d8a 75
nucho 2:6f2db745808e 76 void AD128160::reset() {
nucho 0:2e2f3b389d8a 77 _rst = 0; //Reset
nucho 0:2e2f3b389d8a 78 wait(0.1);
nucho 0:2e2f3b389d8a 79 _rst = 1;
nucho 0:2e2f3b389d8a 80 wait(0.1);
nucho 0:2e2f3b389d8a 81 }
nucho 0:2e2f3b389d8a 82
nucho 0:2e2f3b389d8a 83
nucho 0:2e2f3b389d8a 84 void AD128160::speed(int baud) {
nucho 0:2e2f3b389d8a 85 unsigned char sum=0;
nucho 2:6f2db745808e 86
nucho 0:2e2f3b389d8a 87 unsigned char byte[4];
nucho 0:2e2f3b389d8a 88 byte[0] = (baud&0xff000000)>>24;
nucho 0:2e2f3b389d8a 89 byte[1] = (baud&0x00ff0000)>>16;
nucho 0:2e2f3b389d8a 90 byte[2] = (baud&0x0000ff00)>>8;
nucho 0:2e2f3b389d8a 91 byte[3] = baud&0x000000ff;
nucho 0:2e2f3b389d8a 92
nucho 0:2e2f3b389d8a 93 sum += byte[0]+byte[1]+byte[2]+byte[3]+0x8B;
nucho 0:2e2f3b389d8a 94
nucho 0:2e2f3b389d8a 95 _device.putc(0x55);
nucho 0:2e2f3b389d8a 96 _device.putc(0x05);
nucho 0:2e2f3b389d8a 97 _device.putc(0x8B);
nucho 0:2e2f3b389d8a 98 _device.putc(byte[0]);
nucho 0:2e2f3b389d8a 99 _device.putc(byte[1]);
nucho 0:2e2f3b389d8a 100 _device.putc(byte[2]);
nucho 0:2e2f3b389d8a 101 _device.putc(byte[3]);
nucho 2:6f2db745808e 102
nucho 0:2e2f3b389d8a 103 _device.putc(sum);
nucho 0:2e2f3b389d8a 104 _device.putc(0xAA);
nucho 0:2e2f3b389d8a 105 wait(0.1);
nucho 0:2e2f3b389d8a 106 _device.baud(baud);
nucho 2:6f2db745808e 107
nucho 2:6f2db745808e 108 }
nucho 2:6f2db745808e 109
nucho 2:6f2db745808e 110 int AD128160::width(){
nucho 2:6f2db745808e 111 return LCD_WIDTH;
nucho 2:6f2db745808e 112 }
nucho 2:6f2db745808e 113
nucho 2:6f2db745808e 114 int AD128160::height(){
nucho 2:6f2db745808e 115 return LCD_HEIGHT;
nucho 2:6f2db745808e 116 }
nucho 2:6f2db745808e 117
nucho 2:6f2db745808e 118 int AD128160::columns(){
nucho 2:6f2db745808e 119 return LCD_COLS;
nucho 2:6f2db745808e 120 }
nucho 2:6f2db745808e 121
nucho 2:6f2db745808e 122 int AD128160::rows(){
nucho 2:6f2db745808e 123 return LCD_ROWS;
nucho 0:2e2f3b389d8a 124 }
nucho 0:2e2f3b389d8a 125
nucho 0:2e2f3b389d8a 126 void AD128160::bmp(int x0,int y0,int bmp_no) {
nucho 0:2e2f3b389d8a 127 unsigned char x0H;
nucho 0:2e2f3b389d8a 128 unsigned char x0L;
nucho 0:2e2f3b389d8a 129 unsigned char y0H;
nucho 0:2e2f3b389d8a 130 unsigned char y0L;
nucho 0:2e2f3b389d8a 131 unsigned char rH;
nucho 0:2e2f3b389d8a 132 unsigned char rL;
nucho 0:2e2f3b389d8a 133 unsigned char sum;
nucho 0:2e2f3b389d8a 134
nucho 0:2e2f3b389d8a 135 x0H = x0 >> 8;
nucho 0:2e2f3b389d8a 136 x0L = x0 & 0xFF;
nucho 0:2e2f3b389d8a 137 y0H = y0 >> 8;
nucho 0:2e2f3b389d8a 138 y0L = y0 & 0xff;
nucho 0:2e2f3b389d8a 139 rH = bmp_no >> 8;
nucho 0:2e2f3b389d8a 140 rL = bmp_no & 0xFF;
nucho 0:2e2f3b389d8a 141 sum = x0H+x0L+y0H+y0L+rH+rL+0x09;
nucho 0:2e2f3b389d8a 142 _device.putc(0x55);
nucho 0:2e2f3b389d8a 143 _device.putc(0x07);
nucho 0:2e2f3b389d8a 144 _device.putc(0x09);//command
nucho 0:2e2f3b389d8a 145 _device.putc(x0H);
nucho 0:2e2f3b389d8a 146 _device.putc(x0L);
nucho 0:2e2f3b389d8a 147 _device.putc(y0H);
nucho 0:2e2f3b389d8a 148 _device.putc(y0L);
nucho 0:2e2f3b389d8a 149 _device.putc(rH);
nucho 0:2e2f3b389d8a 150 _device.putc(rL);
nucho 0:2e2f3b389d8a 151 _device.putc(sum);
nucho 0:2e2f3b389d8a 152 _device.putc(0xAA);
nucho 0:2e2f3b389d8a 153 }
nucho 0:2e2f3b389d8a 154
nucho 0:2e2f3b389d8a 155 void AD128160::cls() {
nucho 0:2e2f3b389d8a 156 _device.putc(0x55);// Clear
nucho 0:2e2f3b389d8a 157 _device.putc(0x02);
nucho 0:2e2f3b389d8a 158 _device.putc(0x80);
nucho 0:2e2f3b389d8a 159 _device.putc(0x55);
nucho 0:2e2f3b389d8a 160 _device.putc(0xD5);
nucho 0:2e2f3b389d8a 161 _device.putc(0xAA);
nucho 2:6f2db745808e 162
nucho 0:2e2f3b389d8a 163 locate(0,0);
nucho 0:2e2f3b389d8a 164 }
nucho 0:2e2f3b389d8a 165
nucho 0:2e2f3b389d8a 166 void AD128160::locate(int column, int row) {
nucho 0:2e2f3b389d8a 167 _column = column;
nucho 0:2e2f3b389d8a 168 _row = row;
nucho 0:2e2f3b389d8a 169 }
nucho 0:2e2f3b389d8a 170
nucho 0:2e2f3b389d8a 171 void AD128160::puts( char s[98]) {
nucho 0:2e2f3b389d8a 172 unsigned char sum=0;
nucho 0:2e2f3b389d8a 173 unsigned char x0H;
nucho 0:2e2f3b389d8a 174 unsigned char x0L;
nucho 0:2e2f3b389d8a 175 unsigned char y0H;
nucho 0:2e2f3b389d8a 176 unsigned char y0L;
nucho 0:2e2f3b389d8a 177 unsigned char datalen;
nucho 0:2e2f3b389d8a 178 x0H = _column >> 8;
nucho 0:2e2f3b389d8a 179 x0L = _column & 0xFF;
nucho 0:2e2f3b389d8a 180 y0H = _row >> 8;
nucho 0:2e2f3b389d8a 181 y0L = _row & 0xFF;
nucho 0:2e2f3b389d8a 182 datalen = strlen(s)+5;
nucho 0:2e2f3b389d8a 183 _device.putc(0x55);
nucho 0:2e2f3b389d8a 184 _device.putc(datalen);
nucho 0:2e2f3b389d8a 185 _device.putc(0x0B); // command ASCII Print
nucho 0:2e2f3b389d8a 186 _device.putc(x0H); //x upper 8bit
nucho 0:2e2f3b389d8a 187 _device.putc(x0L); //x low 8bit
nucho 0:2e2f3b389d8a 188 _device.putc(y0H); //y upper 8bit
nucho 0:2e2f3b389d8a 189 _device.putc(y0L); //y low 8bit
nucho 0:2e2f3b389d8a 190 for (int a=0; a<strlen(s); a++) {
nucho 0:2e2f3b389d8a 191 _device.putc(s[a]);
nucho 0:2e2f3b389d8a 192 sum = sum+s[a];
nucho 0:2e2f3b389d8a 193 }
nucho 0:2e2f3b389d8a 194 sum = sum+x0H+x0L+y0H+y0L+0x0B;
nucho 0:2e2f3b389d8a 195 _device.putc(sum);//sumcheck
nucho 0:2e2f3b389d8a 196 _device.putc(0xAA);
nucho 0:2e2f3b389d8a 197 }
nucho 0:2e2f3b389d8a 198
nucho 0:2e2f3b389d8a 199 void AD128160::backgroudColor(int rgb) {
nucho 0:2e2f3b389d8a 200 int c1;
nucho 0:2e2f3b389d8a 201 int c2;
nucho 0:2e2f3b389d8a 202 int sum;
nucho 0:2e2f3b389d8a 203 int mode=1;
nucho 0:2e2f3b389d8a 204
nucho 0:2e2f3b389d8a 205 c1=(rgb >> 8) & 0xff;
nucho 0:2e2f3b389d8a 206 c2=(rgb & 0xff);
nucho 0:2e2f3b389d8a 207 sum=mode+c1+c2+0x85;
nucho 0:2e2f3b389d8a 208 _device.putc(0x55);
nucho 0:2e2f3b389d8a 209 _device.putc(0x04);
nucho 0:2e2f3b389d8a 210 _device.putc(0x85);
nucho 0:2e2f3b389d8a 211 _device.putc(mode);
nucho 0:2e2f3b389d8a 212 _device.putc(c1);
nucho 0:2e2f3b389d8a 213 _device.putc(c2);
nucho 0:2e2f3b389d8a 214 _device.putc(sum);
nucho 0:2e2f3b389d8a 215 _device.putc(0xAA);
nucho 0:2e2f3b389d8a 216 }
nucho 0:2e2f3b389d8a 217
nucho 0:2e2f3b389d8a 218 void AD128160::color(int rgb) {
nucho 0:2e2f3b389d8a 219 int c1;
nucho 0:2e2f3b389d8a 220 int c2;
nucho 0:2e2f3b389d8a 221 int sum;
nucho 0:2e2f3b389d8a 222
nucho 0:2e2f3b389d8a 223 c1=(rgb >> 8) & 0xff;
nucho 0:2e2f3b389d8a 224 c2=(rgb & 0xff);
nucho 0:2e2f3b389d8a 225 sum=c1+c2+0x84;
nucho 0:2e2f3b389d8a 226 _device.putc(0x55);
nucho 0:2e2f3b389d8a 227 _device.putc(0x03);
nucho 0:2e2f3b389d8a 228 _device.putc(0x84);
nucho 0:2e2f3b389d8a 229 _device.putc(c1);
nucho 0:2e2f3b389d8a 230 _device.putc(c2);
nucho 0:2e2f3b389d8a 231 _device.putc(sum);
nucho 0:2e2f3b389d8a 232 _device.putc(0xAA);
nucho 0:2e2f3b389d8a 233 }
nucho 0:2e2f3b389d8a 234
nucho 0:2e2f3b389d8a 235 void AD128160::newline(void) {
nucho 0:2e2f3b389d8a 236 _column = 0;
nucho 0:2e2f3b389d8a 237 _row++;
nucho 2:6f2db745808e 238
nucho 0:2e2f3b389d8a 239 if (_row >= LCD_ROWS) {
nucho 0:2e2f3b389d8a 240 _row = 0;
nucho 0:2e2f3b389d8a 241 }
nucho 0:2e2f3b389d8a 242 }
nucho 0:2e2f3b389d8a 243
nucho 0:2e2f3b389d8a 244 void AD128160::pixel(int x0,int y0) {
nucho 0:2e2f3b389d8a 245 unsigned char x0H;
nucho 0:2e2f3b389d8a 246 unsigned char x0L;
nucho 0:2e2f3b389d8a 247 unsigned char y0H;
nucho 0:2e2f3b389d8a 248 unsigned char y0L;
nucho 0:2e2f3b389d8a 249 unsigned char sum;
nucho 0:2e2f3b389d8a 250
nucho 0:2e2f3b389d8a 251 x0H = x0 >> 8;
nucho 0:2e2f3b389d8a 252 x0L = x0 & 0xFF;
nucho 0:2e2f3b389d8a 253 y0H = y0 >> 8;
nucho 0:2e2f3b389d8a 254 y0L = y0 & 0xff;
nucho 0:2e2f3b389d8a 255
nucho 0:2e2f3b389d8a 256 sum = x0H+x0L+y0H+y0L+0x01;
nucho 0:2e2f3b389d8a 257 _device.putc(0x55);
nucho 0:2e2f3b389d8a 258 _device.putc(0x05);
nucho 0:2e2f3b389d8a 259 _device.putc(0x01);//command
nucho 0:2e2f3b389d8a 260 _device.putc(x0H);
nucho 0:2e2f3b389d8a 261 _device.putc(x0L);
nucho 0:2e2f3b389d8a 262 _device.putc(y0H);
nucho 0:2e2f3b389d8a 263 _device.putc(y0L);
nucho 0:2e2f3b389d8a 264 _device.putc(sum);
nucho 0:2e2f3b389d8a 265 _device.putc(0xAA);
nucho 0:2e2f3b389d8a 266 }
nucho 0:2e2f3b389d8a 267
nucho 0:2e2f3b389d8a 268 void AD128160::box(int x0,int y0,int x1,int y1,int paint) {
nucho 0:2e2f3b389d8a 269 unsigned char x0H;
nucho 0:2e2f3b389d8a 270 unsigned char x0L;
nucho 0:2e2f3b389d8a 271 unsigned char x1H;
nucho 0:2e2f3b389d8a 272 unsigned char x1L;
nucho 0:2e2f3b389d8a 273 unsigned char y0H;
nucho 0:2e2f3b389d8a 274 unsigned char y0L;
nucho 0:2e2f3b389d8a 275 unsigned char y1H;
nucho 0:2e2f3b389d8a 276 unsigned char y1L;
nucho 0:2e2f3b389d8a 277 unsigned char sum;
nucho 0:2e2f3b389d8a 278 unsigned char cmd;
nucho 0:2e2f3b389d8a 279 switch (paint) {
nucho 0:2e2f3b389d8a 280 case 1:
nucho 0:2e2f3b389d8a 281 cmd = 0x04;
nucho 0:2e2f3b389d8a 282 break;
nucho 0:2e2f3b389d8a 283 default:
nucho 0:2e2f3b389d8a 284 cmd =0x03;
nucho 0:2e2f3b389d8a 285 break;
nucho 0:2e2f3b389d8a 286 }
nucho 0:2e2f3b389d8a 287 x0H = x0 >> 8;
nucho 0:2e2f3b389d8a 288 x0L = x0 & 0xFF;
nucho 0:2e2f3b389d8a 289 y0H = y0 >> 8;
nucho 0:2e2f3b389d8a 290 y0L = y0 & 0xff;
nucho 0:2e2f3b389d8a 291 x1H = x1 >> 8;
nucho 0:2e2f3b389d8a 292 x1L = x1 & 0xFF;
nucho 0:2e2f3b389d8a 293 y1H = y1 >> 8;
nucho 0:2e2f3b389d8a 294 y1L = y1 & 0xff;
nucho 0:2e2f3b389d8a 295 sum = x0H+x0L+y0H+y0L+x1H+x1L+y1H+y1L+cmd;
nucho 0:2e2f3b389d8a 296 _device.putc(0x55);//Box
nucho 0:2e2f3b389d8a 297 _device.putc(0x09);
nucho 0:2e2f3b389d8a 298 _device.putc(cmd);//command
nucho 0:2e2f3b389d8a 299 _device.putc(x0H);
nucho 0:2e2f3b389d8a 300 _device.putc(x0L);
nucho 0:2e2f3b389d8a 301 _device.putc(y0H);
nucho 0:2e2f3b389d8a 302 _device.putc(y0L);
nucho 0:2e2f3b389d8a 303 _device.putc(x1H);
nucho 0:2e2f3b389d8a 304 _device.putc(x1L);
nucho 0:2e2f3b389d8a 305 _device.putc(y1H);
nucho 0:2e2f3b389d8a 306 _device.putc(y1L);
nucho 0:2e2f3b389d8a 307 _device.putc(sum);
nucho 0:2e2f3b389d8a 308 _device.putc(0xAA);
nucho 0:2e2f3b389d8a 309 }
nucho 0:2e2f3b389d8a 310
nucho 0:2e2f3b389d8a 311 void AD128160::circle(int x0,int y0,int r,int paint) {
nucho 0:2e2f3b389d8a 312 unsigned char x0H;
nucho 0:2e2f3b389d8a 313 unsigned char x0L;
nucho 0:2e2f3b389d8a 314 unsigned char y0H;
nucho 0:2e2f3b389d8a 315 unsigned char y0L;
nucho 0:2e2f3b389d8a 316 unsigned char rH;
nucho 0:2e2f3b389d8a 317 unsigned char rL;
nucho 0:2e2f3b389d8a 318 unsigned char sum;
nucho 0:2e2f3b389d8a 319 unsigned char cmd;
nucho 0:2e2f3b389d8a 320 switch (paint) {
nucho 0:2e2f3b389d8a 321 case 0:
nucho 0:2e2f3b389d8a 322 cmd = 0x05;
nucho 0:2e2f3b389d8a 323 break;
nucho 0:2e2f3b389d8a 324 case 1:
nucho 0:2e2f3b389d8a 325 cmd = 0x06;
nucho 0:2e2f3b389d8a 326 break;
nucho 0:2e2f3b389d8a 327 default:
nucho 0:2e2f3b389d8a 328 cmd =0x05;
nucho 0:2e2f3b389d8a 329 break;
nucho 0:2e2f3b389d8a 330 }
nucho 0:2e2f3b389d8a 331 x0H = x0 >> 8;
nucho 0:2e2f3b389d8a 332 x0L = x0 & 0xFF;
nucho 0:2e2f3b389d8a 333 y0H = y0 >> 8;
nucho 0:2e2f3b389d8a 334 y0L = y0 & 0xff;
nucho 0:2e2f3b389d8a 335 rH = r >> 8;
nucho 0:2e2f3b389d8a 336 rL = r & 0xFF;
nucho 0:2e2f3b389d8a 337 sum = x0H+x0L+y0H+y0L+rH+rL+cmd;
nucho 0:2e2f3b389d8a 338 _device.putc(0x55);
nucho 0:2e2f3b389d8a 339 _device.putc(0x07);
nucho 0:2e2f3b389d8a 340 _device.putc(cmd);//command
nucho 0:2e2f3b389d8a 341 _device.putc(x0H);
nucho 0:2e2f3b389d8a 342 _device.putc(x0L);
nucho 0:2e2f3b389d8a 343 _device.putc(y0H);
nucho 0:2e2f3b389d8a 344 _device.putc(y0L);
nucho 0:2e2f3b389d8a 345 _device.putc(rH);
nucho 0:2e2f3b389d8a 346 _device.putc(rL);
nucho 0:2e2f3b389d8a 347 _device.putc(sum);
nucho 0:2e2f3b389d8a 348 _device.putc(0xAA);
nucho 0:2e2f3b389d8a 349 }
nucho 0:2e2f3b389d8a 350
nucho 0:2e2f3b389d8a 351 void AD128160::line(int x0,int y0,int x1,int y1) {
nucho 0:2e2f3b389d8a 352 unsigned char x0H;
nucho 0:2e2f3b389d8a 353 unsigned char x0L;
nucho 0:2e2f3b389d8a 354 unsigned char x1H;
nucho 0:2e2f3b389d8a 355 unsigned char x1L;
nucho 0:2e2f3b389d8a 356 unsigned char y0H;
nucho 0:2e2f3b389d8a 357 unsigned char y0L;
nucho 0:2e2f3b389d8a 358 unsigned char y1H;
nucho 0:2e2f3b389d8a 359 unsigned char y1L;
nucho 0:2e2f3b389d8a 360 unsigned char sum;
nucho 0:2e2f3b389d8a 361
nucho 0:2e2f3b389d8a 362 x0H = x0 >> 8;
nucho 0:2e2f3b389d8a 363 x0L = x0 & 0xFF;
nucho 0:2e2f3b389d8a 364 y0H = y0 >> 8;
nucho 0:2e2f3b389d8a 365 y0L = y0 & 0xff;
nucho 0:2e2f3b389d8a 366 x1H = x1 >> 8;
nucho 0:2e2f3b389d8a 367 x1L = x1 & 0xFF;
nucho 0:2e2f3b389d8a 368 y1H = y1 >> 8;
nucho 0:2e2f3b389d8a 369 y1L = y1 & 0xff;
nucho 0:2e2f3b389d8a 370 sum = x0H+x0L+y0H+y0L+x1H+x1L+y1H+y1L+02;
nucho 0:2e2f3b389d8a 371 _device.putc(0x55);
nucho 0:2e2f3b389d8a 372 _device.putc(0x09);
nucho 0:2e2f3b389d8a 373 _device.putc(0x02);//command
nucho 0:2e2f3b389d8a 374 _device.putc(x0H);
nucho 0:2e2f3b389d8a 375 _device.putc(x0L);
nucho 0:2e2f3b389d8a 376 _device.putc(y0H);
nucho 0:2e2f3b389d8a 377 _device.putc(y0L);
nucho 0:2e2f3b389d8a 378 _device.putc(x1H);
nucho 0:2e2f3b389d8a 379 _device.putc(x1L);
nucho 0:2e2f3b389d8a 380 _device.putc(y1H);
nucho 0:2e2f3b389d8a 381 _device.putc(y1L);
nucho 0:2e2f3b389d8a 382 _device.putc(sum);
nucho 0:2e2f3b389d8a 383 _device.putc(0xAA);
nucho 0:2e2f3b389d8a 384 }