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:09:19 2011 +0000
Revision:
0:2e2f3b389d8a
Child:
2:6f2db745808e

        

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 0:2e2f3b389d8a 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 0:2e2f3b389d8a 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 0:2e2f3b389d8a 64
nucho 0:2e2f3b389d8a 65 sum+=byte[0]+byte[1]+0x89;
nucho 0:2e2f3b389d8a 66
nucho 0:2e2f3b389d8a 67 _device.putc(0x55);//Back light On
nucho 0:2e2f3b389d8a 68 _device.putc(0x03);
nucho 0:2e2f3b389d8a 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 0:2e2f3b389d8a 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 0:2e2f3b389d8a 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 0:2e2f3b389d8a 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 0:2e2f3b389d8a 107
nucho 0:2e2f3b389d8a 108 }
nucho 0:2e2f3b389d8a 109
nucho 0:2e2f3b389d8a 110 void AD128160::bmp(int x0,int y0,int bmp_no) {
nucho 0:2e2f3b389d8a 111 unsigned char x0H;
nucho 0:2e2f3b389d8a 112 unsigned char x0L;
nucho 0:2e2f3b389d8a 113 unsigned char y0H;
nucho 0:2e2f3b389d8a 114 unsigned char y0L;
nucho 0:2e2f3b389d8a 115 unsigned char rH;
nucho 0:2e2f3b389d8a 116 unsigned char rL;
nucho 0:2e2f3b389d8a 117 unsigned char sum;
nucho 0:2e2f3b389d8a 118
nucho 0:2e2f3b389d8a 119 x0H = x0 >> 8;
nucho 0:2e2f3b389d8a 120 x0L = x0 & 0xFF;
nucho 0:2e2f3b389d8a 121 y0H = y0 >> 8;
nucho 0:2e2f3b389d8a 122 y0L = y0 & 0xff;
nucho 0:2e2f3b389d8a 123 rH = bmp_no >> 8;
nucho 0:2e2f3b389d8a 124 rL = bmp_no & 0xFF;
nucho 0:2e2f3b389d8a 125 sum = x0H+x0L+y0H+y0L+rH+rL+0x09;
nucho 0:2e2f3b389d8a 126 _device.putc(0x55);
nucho 0:2e2f3b389d8a 127 _device.putc(0x07);
nucho 0:2e2f3b389d8a 128 _device.putc(0x09);//command
nucho 0:2e2f3b389d8a 129 _device.putc(x0H);
nucho 0:2e2f3b389d8a 130 _device.putc(x0L);
nucho 0:2e2f3b389d8a 131 _device.putc(y0H);
nucho 0:2e2f3b389d8a 132 _device.putc(y0L);
nucho 0:2e2f3b389d8a 133 _device.putc(rH);
nucho 0:2e2f3b389d8a 134 _device.putc(rL);
nucho 0:2e2f3b389d8a 135 _device.putc(sum);
nucho 0:2e2f3b389d8a 136 _device.putc(0xAA);
nucho 0:2e2f3b389d8a 137 }
nucho 0:2e2f3b389d8a 138
nucho 0:2e2f3b389d8a 139 void AD128160::cls() {
nucho 0:2e2f3b389d8a 140 _device.putc(0x55);// Clear
nucho 0:2e2f3b389d8a 141 _device.putc(0x02);
nucho 0:2e2f3b389d8a 142 _device.putc(0x80);
nucho 0:2e2f3b389d8a 143 _device.putc(0x55);
nucho 0:2e2f3b389d8a 144 _device.putc(0xD5);
nucho 0:2e2f3b389d8a 145 _device.putc(0xAA);
nucho 0:2e2f3b389d8a 146
nucho 0:2e2f3b389d8a 147 locate(0,0);
nucho 0:2e2f3b389d8a 148 }
nucho 0:2e2f3b389d8a 149
nucho 0:2e2f3b389d8a 150 void AD128160::locate(int column, int row) {
nucho 0:2e2f3b389d8a 151 _column = column;
nucho 0:2e2f3b389d8a 152 _row = row;
nucho 0:2e2f3b389d8a 153 }
nucho 0:2e2f3b389d8a 154
nucho 0:2e2f3b389d8a 155 void AD128160::puts( char s[98]) {
nucho 0:2e2f3b389d8a 156 unsigned char sum=0;
nucho 0:2e2f3b389d8a 157 unsigned char x0H;
nucho 0:2e2f3b389d8a 158 unsigned char x0L;
nucho 0:2e2f3b389d8a 159 unsigned char y0H;
nucho 0:2e2f3b389d8a 160 unsigned char y0L;
nucho 0:2e2f3b389d8a 161 unsigned char datalen;
nucho 0:2e2f3b389d8a 162 x0H = _column >> 8;
nucho 0:2e2f3b389d8a 163 x0L = _column & 0xFF;
nucho 0:2e2f3b389d8a 164 y0H = _row >> 8;
nucho 0:2e2f3b389d8a 165 y0L = _row & 0xFF;
nucho 0:2e2f3b389d8a 166 datalen = strlen(s)+5;
nucho 0:2e2f3b389d8a 167 _device.putc(0x55);
nucho 0:2e2f3b389d8a 168 _device.putc(datalen);
nucho 0:2e2f3b389d8a 169 _device.putc(0x0B); // command ASCII Print
nucho 0:2e2f3b389d8a 170 _device.putc(x0H); //x upper 8bit
nucho 0:2e2f3b389d8a 171 _device.putc(x0L); //x low 8bit
nucho 0:2e2f3b389d8a 172 _device.putc(y0H); //y upper 8bit
nucho 0:2e2f3b389d8a 173 _device.putc(y0L); //y low 8bit
nucho 0:2e2f3b389d8a 174 for (int a=0; a<strlen(s); a++) {
nucho 0:2e2f3b389d8a 175 _device.putc(s[a]);
nucho 0:2e2f3b389d8a 176 sum = sum+s[a];
nucho 0:2e2f3b389d8a 177 }
nucho 0:2e2f3b389d8a 178 sum = sum+x0H+x0L+y0H+y0L+0x0B;
nucho 0:2e2f3b389d8a 179 _device.putc(sum);//sumcheck
nucho 0:2e2f3b389d8a 180 _device.putc(0xAA);
nucho 0:2e2f3b389d8a 181 }
nucho 0:2e2f3b389d8a 182
nucho 0:2e2f3b389d8a 183
nucho 0:2e2f3b389d8a 184 void AD128160::color2(int c1,int c2) {
nucho 0:2e2f3b389d8a 185 //int c1;
nucho 0:2e2f3b389d8a 186 //int c2;
nucho 0:2e2f3b389d8a 187 int sum;
nucho 0:2e2f3b389d8a 188
nucho 0:2e2f3b389d8a 189 //c1=(rgb >> 8) & 0xff;
nucho 0:2e2f3b389d8a 190 //c2=(rgb & 0xff);
nucho 0:2e2f3b389d8a 191 sum=c1+c2+0x84;
nucho 0:2e2f3b389d8a 192 _device.putc(0x55);
nucho 0:2e2f3b389d8a 193 _device.putc(0x03);
nucho 0:2e2f3b389d8a 194 _device.putc(0x84);
nucho 0:2e2f3b389d8a 195 _device.putc(c1);
nucho 0:2e2f3b389d8a 196 _device.putc(c2);
nucho 0:2e2f3b389d8a 197 _device.putc(sum);
nucho 0:2e2f3b389d8a 198 _device.putc(0xAA);
nucho 0:2e2f3b389d8a 199 }
nucho 0:2e2f3b389d8a 200
nucho 0:2e2f3b389d8a 201 void AD128160::backgroudColor(int rgb) {
nucho 0:2e2f3b389d8a 202 int c1;
nucho 0:2e2f3b389d8a 203 int c2;
nucho 0:2e2f3b389d8a 204 int sum;
nucho 0:2e2f3b389d8a 205 int mode=1;
nucho 0:2e2f3b389d8a 206
nucho 0:2e2f3b389d8a 207 c1=(rgb >> 8) & 0xff;
nucho 0:2e2f3b389d8a 208 c2=(rgb & 0xff);
nucho 0:2e2f3b389d8a 209 sum=mode+c1+c2+0x85;
nucho 0:2e2f3b389d8a 210 _device.putc(0x55);
nucho 0:2e2f3b389d8a 211 _device.putc(0x04);
nucho 0:2e2f3b389d8a 212 _device.putc(0x85);
nucho 0:2e2f3b389d8a 213 _device.putc(mode);
nucho 0:2e2f3b389d8a 214 _device.putc(c1);
nucho 0:2e2f3b389d8a 215 _device.putc(c2);
nucho 0:2e2f3b389d8a 216 _device.putc(sum);
nucho 0:2e2f3b389d8a 217 _device.putc(0xAA);
nucho 0:2e2f3b389d8a 218 }
nucho 0:2e2f3b389d8a 219
nucho 0:2e2f3b389d8a 220 void AD128160::color(int rgb) {
nucho 0:2e2f3b389d8a 221 int c1;
nucho 0:2e2f3b389d8a 222 int c2;
nucho 0:2e2f3b389d8a 223 int sum;
nucho 0:2e2f3b389d8a 224
nucho 0:2e2f3b389d8a 225 c1=(rgb >> 8) & 0xff;
nucho 0:2e2f3b389d8a 226 c2=(rgb & 0xff);
nucho 0:2e2f3b389d8a 227 sum=c1+c2+0x84;
nucho 0:2e2f3b389d8a 228 _device.putc(0x55);
nucho 0:2e2f3b389d8a 229 _device.putc(0x03);
nucho 0:2e2f3b389d8a 230 _device.putc(0x84);
nucho 0:2e2f3b389d8a 231 _device.putc(c1);
nucho 0:2e2f3b389d8a 232 _device.putc(c2);
nucho 0:2e2f3b389d8a 233 _device.putc(sum);
nucho 0:2e2f3b389d8a 234 _device.putc(0xAA);
nucho 0:2e2f3b389d8a 235 }
nucho 0:2e2f3b389d8a 236
nucho 0:2e2f3b389d8a 237 void AD128160::newline(void) {
nucho 0:2e2f3b389d8a 238 _column = 0;
nucho 0:2e2f3b389d8a 239 _row++;
nucho 0:2e2f3b389d8a 240
nucho 0:2e2f3b389d8a 241 if (_row >= LCD_ROWS) {
nucho 0:2e2f3b389d8a 242 _row = 0;
nucho 0:2e2f3b389d8a 243 }
nucho 0:2e2f3b389d8a 244 }
nucho 0:2e2f3b389d8a 245
nucho 0:2e2f3b389d8a 246 void AD128160::pixel(int x0,int y0) {
nucho 0:2e2f3b389d8a 247 unsigned char x0H;
nucho 0:2e2f3b389d8a 248 unsigned char x0L;
nucho 0:2e2f3b389d8a 249 unsigned char y0H;
nucho 0:2e2f3b389d8a 250 unsigned char y0L;
nucho 0:2e2f3b389d8a 251 unsigned char sum;
nucho 0:2e2f3b389d8a 252
nucho 0:2e2f3b389d8a 253 x0H = x0 >> 8;
nucho 0:2e2f3b389d8a 254 x0L = x0 & 0xFF;
nucho 0:2e2f3b389d8a 255 y0H = y0 >> 8;
nucho 0:2e2f3b389d8a 256 y0L = y0 & 0xff;
nucho 0:2e2f3b389d8a 257
nucho 0:2e2f3b389d8a 258 sum = x0H+x0L+y0H+y0L+0x01;
nucho 0:2e2f3b389d8a 259 _device.putc(0x55);
nucho 0:2e2f3b389d8a 260 _device.putc(0x05);
nucho 0:2e2f3b389d8a 261 _device.putc(0x01);//command
nucho 0:2e2f3b389d8a 262 _device.putc(x0H);
nucho 0:2e2f3b389d8a 263 _device.putc(x0L);
nucho 0:2e2f3b389d8a 264 _device.putc(y0H);
nucho 0:2e2f3b389d8a 265 _device.putc(y0L);
nucho 0:2e2f3b389d8a 266 _device.putc(sum);
nucho 0:2e2f3b389d8a 267 _device.putc(0xAA);
nucho 0:2e2f3b389d8a 268 }
nucho 0:2e2f3b389d8a 269
nucho 0:2e2f3b389d8a 270 void AD128160::box(int x0,int y0,int x1,int y1,int paint) {
nucho 0:2e2f3b389d8a 271 unsigned char x0H;
nucho 0:2e2f3b389d8a 272 unsigned char x0L;
nucho 0:2e2f3b389d8a 273 unsigned char x1H;
nucho 0:2e2f3b389d8a 274 unsigned char x1L;
nucho 0:2e2f3b389d8a 275 unsigned char y0H;
nucho 0:2e2f3b389d8a 276 unsigned char y0L;
nucho 0:2e2f3b389d8a 277 unsigned char y1H;
nucho 0:2e2f3b389d8a 278 unsigned char y1L;
nucho 0:2e2f3b389d8a 279 unsigned char sum;
nucho 0:2e2f3b389d8a 280 unsigned char cmd;
nucho 0:2e2f3b389d8a 281 switch (paint) {
nucho 0:2e2f3b389d8a 282 case 1:
nucho 0:2e2f3b389d8a 283 cmd = 0x04;
nucho 0:2e2f3b389d8a 284 break;
nucho 0:2e2f3b389d8a 285 default:
nucho 0:2e2f3b389d8a 286 cmd =0x03;
nucho 0:2e2f3b389d8a 287 break;
nucho 0:2e2f3b389d8a 288 }
nucho 0:2e2f3b389d8a 289 x0H = x0 >> 8;
nucho 0:2e2f3b389d8a 290 x0L = x0 & 0xFF;
nucho 0:2e2f3b389d8a 291 y0H = y0 >> 8;
nucho 0:2e2f3b389d8a 292 y0L = y0 & 0xff;
nucho 0:2e2f3b389d8a 293 x1H = x1 >> 8;
nucho 0:2e2f3b389d8a 294 x1L = x1 & 0xFF;
nucho 0:2e2f3b389d8a 295 y1H = y1 >> 8;
nucho 0:2e2f3b389d8a 296 y1L = y1 & 0xff;
nucho 0:2e2f3b389d8a 297 sum = x0H+x0L+y0H+y0L+x1H+x1L+y1H+y1L+cmd;
nucho 0:2e2f3b389d8a 298 _device.putc(0x55);//Box
nucho 0:2e2f3b389d8a 299 _device.putc(0x09);
nucho 0:2e2f3b389d8a 300 _device.putc(cmd);//command
nucho 0:2e2f3b389d8a 301 _device.putc(x0H);
nucho 0:2e2f3b389d8a 302 _device.putc(x0L);
nucho 0:2e2f3b389d8a 303 _device.putc(y0H);
nucho 0:2e2f3b389d8a 304 _device.putc(y0L);
nucho 0:2e2f3b389d8a 305 _device.putc(x1H);
nucho 0:2e2f3b389d8a 306 _device.putc(x1L);
nucho 0:2e2f3b389d8a 307 _device.putc(y1H);
nucho 0:2e2f3b389d8a 308 _device.putc(y1L);
nucho 0:2e2f3b389d8a 309 _device.putc(sum);
nucho 0:2e2f3b389d8a 310 _device.putc(0xAA);
nucho 0:2e2f3b389d8a 311 }
nucho 0:2e2f3b389d8a 312
nucho 0:2e2f3b389d8a 313 void AD128160::circle(int x0,int y0,int r,int paint) {
nucho 0:2e2f3b389d8a 314 unsigned char x0H;
nucho 0:2e2f3b389d8a 315 unsigned char x0L;
nucho 0:2e2f3b389d8a 316 unsigned char y0H;
nucho 0:2e2f3b389d8a 317 unsigned char y0L;
nucho 0:2e2f3b389d8a 318 unsigned char rH;
nucho 0:2e2f3b389d8a 319 unsigned char rL;
nucho 0:2e2f3b389d8a 320 unsigned char sum;
nucho 0:2e2f3b389d8a 321 unsigned char cmd;
nucho 0:2e2f3b389d8a 322 switch (paint) {
nucho 0:2e2f3b389d8a 323 case 0:
nucho 0:2e2f3b389d8a 324 cmd = 0x05;
nucho 0:2e2f3b389d8a 325 break;
nucho 0:2e2f3b389d8a 326 case 1:
nucho 0:2e2f3b389d8a 327 cmd = 0x06;
nucho 0:2e2f3b389d8a 328 break;
nucho 0:2e2f3b389d8a 329 default:
nucho 0:2e2f3b389d8a 330 cmd =0x05;
nucho 0:2e2f3b389d8a 331 break;
nucho 0:2e2f3b389d8a 332 }
nucho 0:2e2f3b389d8a 333 x0H = x0 >> 8;
nucho 0:2e2f3b389d8a 334 x0L = x0 & 0xFF;
nucho 0:2e2f3b389d8a 335 y0H = y0 >> 8;
nucho 0:2e2f3b389d8a 336 y0L = y0 & 0xff;
nucho 0:2e2f3b389d8a 337 rH = r >> 8;
nucho 0:2e2f3b389d8a 338 rL = r & 0xFF;
nucho 0:2e2f3b389d8a 339 sum = x0H+x0L+y0H+y0L+rH+rL+cmd;
nucho 0:2e2f3b389d8a 340 _device.putc(0x55);
nucho 0:2e2f3b389d8a 341 _device.putc(0x07);
nucho 0:2e2f3b389d8a 342 _device.putc(cmd);//command
nucho 0:2e2f3b389d8a 343 _device.putc(x0H);
nucho 0:2e2f3b389d8a 344 _device.putc(x0L);
nucho 0:2e2f3b389d8a 345 _device.putc(y0H);
nucho 0:2e2f3b389d8a 346 _device.putc(y0L);
nucho 0:2e2f3b389d8a 347 _device.putc(rH);
nucho 0:2e2f3b389d8a 348 _device.putc(rL);
nucho 0:2e2f3b389d8a 349 _device.putc(sum);
nucho 0:2e2f3b389d8a 350 _device.putc(0xAA);
nucho 0:2e2f3b389d8a 351 }
nucho 0:2e2f3b389d8a 352
nucho 0:2e2f3b389d8a 353 void AD128160::line(int x0,int y0,int x1,int y1) {
nucho 0:2e2f3b389d8a 354 unsigned char x0H;
nucho 0:2e2f3b389d8a 355 unsigned char x0L;
nucho 0:2e2f3b389d8a 356 unsigned char x1H;
nucho 0:2e2f3b389d8a 357 unsigned char x1L;
nucho 0:2e2f3b389d8a 358 unsigned char y0H;
nucho 0:2e2f3b389d8a 359 unsigned char y0L;
nucho 0:2e2f3b389d8a 360 unsigned char y1H;
nucho 0:2e2f3b389d8a 361 unsigned char y1L;
nucho 0:2e2f3b389d8a 362 unsigned char sum;
nucho 0:2e2f3b389d8a 363
nucho 0:2e2f3b389d8a 364 x0H = x0 >> 8;
nucho 0:2e2f3b389d8a 365 x0L = x0 & 0xFF;
nucho 0:2e2f3b389d8a 366 y0H = y0 >> 8;
nucho 0:2e2f3b389d8a 367 y0L = y0 & 0xff;
nucho 0:2e2f3b389d8a 368 x1H = x1 >> 8;
nucho 0:2e2f3b389d8a 369 x1L = x1 & 0xFF;
nucho 0:2e2f3b389d8a 370 y1H = y1 >> 8;
nucho 0:2e2f3b389d8a 371 y1L = y1 & 0xff;
nucho 0:2e2f3b389d8a 372 sum = x0H+x0L+y0H+y0L+x1H+x1L+y1H+y1L+02;
nucho 0:2e2f3b389d8a 373 _device.putc(0x55);
nucho 0:2e2f3b389d8a 374 _device.putc(0x09);
nucho 0:2e2f3b389d8a 375 _device.putc(0x02);//command
nucho 0:2e2f3b389d8a 376 _device.putc(x0H);
nucho 0:2e2f3b389d8a 377 _device.putc(x0L);
nucho 0:2e2f3b389d8a 378 _device.putc(y0H);
nucho 0:2e2f3b389d8a 379 _device.putc(y0L);
nucho 0:2e2f3b389d8a 380 _device.putc(x1H);
nucho 0:2e2f3b389d8a 381 _device.putc(x1L);
nucho 0:2e2f3b389d8a 382 _device.putc(y1H);
nucho 0:2e2f3b389d8a 383 _device.putc(y1L);
nucho 0:2e2f3b389d8a 384 _device.putc(sum);
nucho 0:2e2f3b389d8a 385 _device.putc(0xAA);
nucho 0:2e2f3b389d8a 386 }