44 #include <avr/pgmspace.h> 45 #include "hardware/avr/HW_AVR.h" 46 #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) 47 #include "hardware/avr/HW_ATmega1280.h" 48 #elif defined(__AVR_ATmega328P__) 49 #include "hardware/avr/HW_ATmega328P.h" 50 #elif defined(__AVR_ATmega32U4__) 51 #include "hardware/avr/HW_ATmega32U4.h" 52 #elif defined(__AVR_ATmega168__) 53 #error "ATmega168 MCUs are not supported because they have too little flash memory!" 54 #elif defined(__AVR_ATmega1284P__) 55 #include "hardware/avr/HW_ATmega1284P.h" 57 #error "Unsupported AVR MCU!" 59 #elif defined(__PIC32MX__) 60 #include "hardware/pic32/HW_PIC32.h" 61 #if defined(__32MX320F128H__) 62 #pragma message("Compiling for chipKIT UNO32 (PIC32MX320F128H)") 63 #include "hardware/pic32/HW_PIC32MX320F128H.h" 64 #elif defined(__32MX340F512H__) 65 #pragma message("Compiling for chipKIT uC32 (PIC32MX340F512H)") 66 #include "hardware/pic32/HW_PIC32MX340F512H.h" 67 #elif defined(__32MX795F512L__) 68 #pragma message("Compiling for chipKIT MAX32 (PIC32MX795F512L)") 69 #include "hardware/pic32/HW_PIC32MX795F512L.h" 71 #error "Unsupported PIC32 MCU!" 73 #elif defined(__arm__) 74 #include "hardware/arm/HW_ARM.h" 75 #if defined(__SAM3X8E__) 76 #pragma message("Compiling for Arduino Due (AT91SAM3X8E)...") 77 #include "hardware/arm/HW_SAM3X8E.h" 78 #elif defined(__MK20DX128__) || defined(__MK20DX256__) 79 #pragma message("Compiling for Teensy 3.x (MK20DX128VLH7 / MK20DX256VLH7)...") 80 #include "hardware/arm/HW_MX20DX256.h" 81 #elif defined(__CC3200R1M1RGC__) 82 #pragma message("Compiling for TI CC3200 LaunchPad...") 83 #include "hardware/arm/HW_CC3200.h" 85 #error "Unsupported ARM MCU!" 88 #include "memorysaver.h" 94 UTFT::UTFT(byte model,
int RS,
int WR,
int CS,
int RST,
int SER)
96 word dsx[] = {239, 239, 239, 239, 239, 239, 175, 175, 239, 127, 127, 239, 271, 479, 239, 239, 239, 0, 0, 239, 479, 319, 239, 175, 127, 239, 239, 319, 319, 799, 127, 127};
97 word dsy[] = {319, 399, 319, 319, 319, 319, 219, 219, 399, 159, 127, 319, 479, 799, 319, 319, 319, 0, 0, 319, 799, 479, 319, 219, 159, 319, 319, 479, 479, 479, 159, 159};
98 byte dtm[] = {16, 16, 16, 8, 8, 16, 8, SERIAL_4PIN, 16, SERIAL_5PIN, SERIAL_5PIN, 16, 16, 16, 8, 16, LATCHED_16, 0, 0, 8, 16, 16, 16, 8, SERIAL_5PIN, SERIAL_5PIN, SERIAL_4PIN, 16, 16, 16, SERIAL_5PIN, SERIAL_5PIN};
100 disp_x_size = dsx[model];
101 disp_y_size = dsy[model];
102 display_transfer_mode = dtm[model];
103 display_model = model;
111 if (display_transfer_mode == SERIAL_4PIN)
113 display_transfer_mode=1;
114 display_serial_mode=SERIAL_4PIN;
116 if (display_transfer_mode == SERIAL_5PIN)
118 display_transfer_mode=1;
119 display_serial_mode=SERIAL_5PIN;
122 if (display_transfer_mode!=1)
124 _set_direction_registers(display_transfer_mode);
125 P_RS = portOutputRegister(digitalPinToPort(RS));
126 B_RS = digitalPinToBitMask(RS);
127 P_WR = portOutputRegister(digitalPinToPort(WR));
128 B_WR = digitalPinToBitMask(WR);
129 P_CS = portOutputRegister(digitalPinToPort(CS));
130 B_CS = digitalPinToBitMask(CS);
131 P_RST = portOutputRegister(digitalPinToPort(RST));
132 B_RST = digitalPinToBitMask(RST);
133 if (display_transfer_mode==LATCHED_16)
135 P_ALE = portOutputRegister(digitalPinToPort(SER));
136 B_ALE = digitalPinToBitMask(SER);
139 digitalWrite(8, LOW);
144 P_SDA = portOutputRegister(digitalPinToPort(RS));
145 B_SDA = digitalPinToBitMask(RS);
146 P_SCL = portOutputRegister(digitalPinToPort(WR));
147 B_SCL = digitalPinToBitMask(WR);
148 P_CS = portOutputRegister(digitalPinToPort(CS));
149 B_CS = digitalPinToBitMask(CS);
152 P_RST = portOutputRegister(digitalPinToPort(RST));
153 B_RST = digitalPinToBitMask(RST);
155 if (display_serial_mode!=SERIAL_4PIN)
157 P_RS = portOutputRegister(digitalPinToPort(SER));
158 B_RS = digitalPinToBitMask(SER);
163 void UTFT::LCD_Write_COM(
char VL)
165 if (display_transfer_mode!=1)
168 LCD_Writ_Bus(0x00,VL,display_transfer_mode);
171 LCD_Writ_Bus(0x00,VL,display_transfer_mode);
174 void UTFT::LCD_Write_DATA(
char VH,
char VL)
176 if (display_transfer_mode!=1)
179 LCD_Writ_Bus(VH,VL,display_transfer_mode);
183 LCD_Writ_Bus(0x01,VH,display_transfer_mode);
184 LCD_Writ_Bus(0x01,VL,display_transfer_mode);
188 void UTFT::LCD_Write_DATA(
char VL)
190 if (display_transfer_mode!=1)
193 LCD_Writ_Bus(0x00,VL,display_transfer_mode);
196 LCD_Writ_Bus(0x01,VL,display_transfer_mode);
199 void UTFT::LCD_Write_COM_DATA(
char com1,
int dat1)
202 LCD_Write_DATA(dat1>>8,dat1);
205 void UTFT::InitLCD(byte orientation)
210 pinMode(__p1,OUTPUT);
211 pinMode(__p2,OUTPUT);
212 pinMode(__p3,OUTPUT);
213 if (__p4 != NOTINUSE)
214 pinMode(__p4,OUTPUT);
215 if ((display_transfer_mode==LATCHED_16) or ((display_transfer_mode==1) and (display_serial_mode==SERIAL_5PIN)))
216 pinMode(__p5,OUTPUT);
217 if (display_transfer_mode!=1)
218 _set_direction_registers(display_transfer_mode);
229 switch(display_model)
231 #ifndef DISABLE_HX8347A 232 #include "tft_drivers/hx8347a/initlcd.h" 234 #ifndef DISABLE_ILI9327 235 #include "tft_drivers/ili9327/initlcd.h" 237 #ifndef DISABLE_SSD1289 238 #include "tft_drivers/ssd1289/initlcd.h" 240 #ifndef DISABLE_ILI9325C 241 #include "tft_drivers/ili9325c/initlcd.h" 243 #ifndef DISABLE_ILI9325D 244 #include "tft_drivers/ili9325d/default/initlcd.h" 246 #ifndef DISABLE_ILI9325D_ALT 247 #include "tft_drivers/ili9325d/alt/initlcd.h" 249 #ifndef DISABLE_HX8340B_8 250 #include "tft_drivers/hx8340b/8/initlcd.h" 252 #ifndef DISABLE_HX8340B_S 253 #include "tft_drivers/hx8340b/s/initlcd.h" 255 #ifndef DISABLE_ST7735 256 #include "tft_drivers/st7735/std/initlcd.h" 258 #ifndef DISABLE_ST7735_ALT 259 #include "tft_drivers/st7735/alt/initlcd.h" 261 #ifndef DISABLE_PCF8833 262 #include "tft_drivers/pcf8833/initlcd.h" 264 #ifndef DISABLE_S1D19122 265 #include "tft_drivers/s1d19122/initlcd.h" 267 #ifndef DISABLE_HX8352A 268 #include "tft_drivers/hx8352a/initlcd.h" 270 #ifndef DISABLE_SSD1963_480 271 #include "tft_drivers/ssd1963/480/initlcd.h" 273 #ifndef DISABLE_SSD1963_800 274 #include "tft_drivers/ssd1963/800/initlcd.h" 276 #ifndef DISABLE_SSD1963_800_ALT 277 #include "tft_drivers/ssd1963/800alt/initlcd.h" 279 #ifndef DISABLE_S6D1121 280 #include "tft_drivers/s6d1121/initlcd.h" 282 #ifndef DISABLE_ILI9481 283 #include "tft_drivers/ili9481/initlcd.h" 285 #ifndef DISABLE_S6D0164 286 #include "tft_drivers/s6d0164/initlcd.h" 288 #ifndef DISABLE_ST7735S 289 #include "tft_drivers/st7735s/initlcd.h" 291 #ifndef DISABLE_ILI9341_S4P 292 #include "tft_drivers/ili9341/s4p/initlcd.h" 294 #ifndef DISABLE_ILI9341_S5P 295 #include "tft_drivers/ili9341/s5p/initlcd.h" 297 #ifndef DISABLE_R61581 298 #include "tft_drivers/r61581/initlcd.h" 300 #ifndef DISABLE_ILI9486 301 #include "tft_drivers/ili9486/initlcd.h" 304 #include "tft_drivers/cpld/initlcd.h" 306 #ifndef DISABLE_HX8353C 307 #include "tft_drivers/hx8353c/initlcd.h" 313 setColor(255, 255, 255);
314 setBackColor(0, 0, 0);
316 _transparent =
false;
319 void UTFT::setXY(word x1, word y1, word x2, word y2)
321 if (orient==LANDSCAPE)
330 switch(display_model)
332 #ifndef DISABLE_HX8347A 333 #include "tft_drivers/hx8347a/setxy.h" 335 #ifndef DISABLE_HX8352A 336 #include "tft_drivers/hx8352a/setxy.h" 338 #ifndef DISABLE_ILI9327 339 #include "tft_drivers/ili9327/setxy.h" 341 #ifndef DISABLE_SSD1289 342 #include "tft_drivers/ssd1289/setxy.h" 344 #ifndef DISABLE_ILI9325C 345 #include "tft_drivers/ili9325c/setxy.h" 347 #ifndef DISABLE_ILI9325D 348 #include "tft_drivers/ili9325d/default/setxy.h" 350 #ifndef DISABLE_ILI9325D_ALT 351 #include "tft_drivers/ili9325d/alt/setxy.h" 353 #ifndef DISABLE_HX8340B_8 354 #include "tft_drivers/hx8340b/8/setxy.h" 356 #ifndef DISABLE_HX8340B_S 357 #include "tft_drivers/hx8340b/s/setxy.h" 359 #ifndef DISABLE_ST7735 360 #include "tft_drivers/st7735/std/setxy.h" 362 #ifndef DISABLE_ST7735_ALT 363 #include "tft_drivers/st7735/alt/setxy.h" 365 #ifndef DISABLE_S1D19122 366 #include "tft_drivers/s1d19122/setxy.h" 368 #ifndef DISABLE_PCF8833 369 #include "tft_drivers/pcf8833/setxy.h" 371 #ifndef DISABLE_SSD1963_480 372 #include "tft_drivers/ssd1963/480/setxy.h" 374 #ifndef DISABLE_SSD1963_800 375 #include "tft_drivers/ssd1963/800/setxy.h" 377 #ifndef DISABLE_SSD1963_800_ALT 378 #include "tft_drivers/ssd1963/800alt/setxy.h" 380 #ifndef DISABLE_S6D1121 381 #include "tft_drivers/s6d1121/setxy.h" 383 #ifndef DISABLE_ILI9481 384 #include "tft_drivers/ili9481/setxy.h" 386 #ifndef DISABLE_S6D0164 387 #include "tft_drivers/s6d0164/setxy.h" 389 #ifndef DISABLE_ST7735S 390 #include "tft_drivers/st7735s/setxy.h" 392 #ifndef DISABLE_ILI9341_S4P 393 #include "tft_drivers/ili9341/s4p/setxy.h" 395 #ifndef DISABLE_ILI9341_S5P 396 #include "tft_drivers/ili9341/s5p/setxy.h" 398 #ifndef DISABLE_R61581 399 #include "tft_drivers/r61581/setxy.h" 401 #ifndef DISABLE_ILI9486 402 #include "tft_drivers/ili9486/setxy.h" 405 #include "tft_drivers/cpld/setxy.h" 407 #ifndef DISABLE_HX8353C 408 #include "tft_drivers/hx8353c/setxy.h" 415 if (orient==PORTRAIT)
416 setXY(0,0,disp_x_size,disp_y_size);
418 setXY(0,0,disp_y_size,disp_x_size);
421 void UTFT::drawRect(
int x1,
int y1,
int x2,
int y2)
432 drawHLine(x1, y1, x2-x1);
433 drawHLine(x1, y2, x2-x1);
434 drawVLine(x1, y1, y2-y1);
435 drawVLine(x2, y1, y2-y1);
438 void UTFT::drawRoundRect(
int x1,
int y1,
int x2,
int y2)
448 if ((x2-x1)>4 && (y2-y1)>4)
450 drawPixel(x1+1,y1+1);
451 drawPixel(x2-1,y1+1);
452 drawPixel(x1+1,y2-1);
453 drawPixel(x2-1,y2-1);
454 drawHLine(x1+2, y1, x2-x1-4);
455 drawHLine(x1+2, y2, x2-x1-4);
456 drawVLine(x1, y1+2, y2-y1-4);
457 drawVLine(x2, y1+2, y2-y1-4);
461 void UTFT::fillRect(
int x1,
int y1,
int x2,
int y2)
471 if (display_transfer_mode==16)
474 setXY(x1, y1, x2, y2);
476 _fast_fill_16(fch,fcl,((
long(x2-x1)+1)*(
long(y2-y1)+1)));
479 else if ((display_transfer_mode==8) and (fch==fcl))
482 setXY(x1, y1, x2, y2);
484 _fast_fill_8(fch,((
long(x2-x1)+1)*(
long(y2-y1)+1)));
489 if (orient==PORTRAIT)
491 for (
int i=0; i<((y2-y1)/2)+1; i++)
493 drawHLine(x1, y1+i, x2-x1);
494 drawHLine(x1, y2-i, x2-x1);
499 for (
int i=0; i<((x2-x1)/2)+1; i++)
501 drawVLine(x1+i, y1, y2-y1);
502 drawVLine(x2-i, y1, y2-y1);
508 void UTFT::fillRoundRect(
int x1,
int y1,
int x2,
int y2)
519 if ((x2-x1)>4 && (y2-y1)>4)
521 for (
int i=0; i<((y2-y1)/2)+1; i++)
526 drawHLine(x1+2, y1+i, x2-x1-4);
527 drawHLine(x1+2, y2-i, x2-x1-4);
530 drawHLine(x1+1, y1+i, x2-x1-2);
531 drawHLine(x1+1, y2-i, x2-x1-2);
534 drawHLine(x1, y1+i, x2-x1);
535 drawHLine(x1, y2-i, x2-x1);
541 void UTFT::drawCircle(
int x,
int y,
int radius)
545 int ddF_y = -2 * radius;
550 setXY(x, y + radius, x, y + radius);
551 LCD_Write_DATA(fch,fcl);
552 setXY(x, y - radius, x, y - radius);
553 LCD_Write_DATA(fch,fcl);
554 setXY(x + radius, y, x + radius, y);
555 LCD_Write_DATA(fch,fcl);
556 setXY(x - radius, y, x - radius, y);
557 LCD_Write_DATA(fch,fcl);
570 setXY(x + x1, y + y1, x + x1, y + y1);
571 LCD_Write_DATA(fch,fcl);
572 setXY(x - x1, y + y1, x - x1, y + y1);
573 LCD_Write_DATA(fch,fcl);
574 setXY(x + x1, y - y1, x + x1, y - y1);
575 LCD_Write_DATA(fch,fcl);
576 setXY(x - x1, y - y1, x - x1, y - y1);
577 LCD_Write_DATA(fch,fcl);
578 setXY(x + y1, y + x1, x + y1, y + x1);
579 LCD_Write_DATA(fch,fcl);
580 setXY(x - y1, y + x1, x - y1, y + x1);
581 LCD_Write_DATA(fch,fcl);
582 setXY(x + y1, y - x1, x + y1, y - x1);
583 LCD_Write_DATA(fch,fcl);
584 setXY(x - y1, y - x1, x - y1, y - x1);
585 LCD_Write_DATA(fch,fcl);
591 void UTFT::fillCircle(
int x,
int y,
int radius)
593 for(
int y1=-radius; y1<=0; y1++)
594 for(
int x1=-radius; x1<=0; x1++)
595 if(x1*x1+y1*y1 <= radius*radius)
597 drawHLine(x+x1, y+y1, 2*(-x1));
598 drawHLine(x+x1, y-y1, 2*(-x1));
609 if (display_transfer_mode!=1)
611 if (display_transfer_mode==16)
612 _fast_fill_16(0,0,((disp_x_size+1)*(disp_y_size+1)));
613 else if (display_transfer_mode==8)
614 _fast_fill_8(0,((disp_x_size+1)*(disp_y_size+1)));
617 for (i=0; i<((disp_x_size+1)*(disp_y_size+1)); i++)
619 if (display_transfer_mode!=1)
620 LCD_Writ_Bus(0,0,display_transfer_mode);
623 LCD_Writ_Bus(1,0,display_transfer_mode);
624 LCD_Writ_Bus(1,0,display_transfer_mode);
631 void UTFT::fillScr(byte r, byte g, byte b)
633 word color = ((r&248)<<8 | (g&252)<<3 | (b&248)>>3);
637 void UTFT::fillScr(word color)
643 cl=byte(color & 0xFF);
647 if (display_transfer_mode!=1)
649 if (display_transfer_mode==16)
650 _fast_fill_16(ch,cl,((disp_x_size+1)*(disp_y_size+1)));
651 else if ((display_transfer_mode==8) and (ch==cl))
652 _fast_fill_8(ch,((disp_x_size+1)*(disp_y_size+1)));
655 for (i=0; i<((disp_x_size+1)*(disp_y_size+1)); i++)
657 if (display_transfer_mode!=1)
658 LCD_Writ_Bus(ch,cl,display_transfer_mode);
661 LCD_Writ_Bus(1,ch,display_transfer_mode);
662 LCD_Writ_Bus(1,cl,display_transfer_mode);
669 void UTFT::setColor(byte r, byte g, byte b)
672 fcl=((g&28)<<3|b>>3);
675 void UTFT::setColor(word color)
678 fcl=byte(color & 0xFF);
681 word UTFT::getColor()
683 return (fch<<8) | fcl;
686 void UTFT::setBackColor(byte r, byte g, byte b)
689 bcl=((g&28)<<3|b>>3);
693 void UTFT::setBackColor(uint32_t color)
695 if (color==VGA_TRANSPARENT)
700 bcl=byte(color & 0xFF);
705 word UTFT::getBackColor()
707 return (bch<<8) | bcl;
710 void UTFT::setPixel(word color)
712 LCD_Write_DATA((color>>8),(color&0xFF));
715 void UTFT::drawPixel(
int x,
int y)
719 setPixel((fch<<8)|fcl);
724 void UTFT::drawLine(
int x1,
int y1,
int x2,
int y2)
727 drawHLine(x1, y1, x2-x1);
729 drawVLine(x1, y1, y2-y1);
732 unsigned int dx = (x2 > x1 ? x2 - x1 : x1 - x2);
733 short xstep = x2 > x1 ? 1 : -1;
734 unsigned int dy = (y2 > y1 ? y2 - y1 : y1 - y2);
735 short ystep = y2 > y1 ? 1 : -1;
736 int col = x1, row = y1;
744 setXY (col, row, col, row);
745 LCD_Write_DATA (fch, fcl);
762 setXY (col, row, col, row);
763 LCD_Write_DATA (fch, fcl);
780 void UTFT::drawHLine(
int x,
int y,
int l)
789 if (display_transfer_mode == 16)
792 _fast_fill_16(fch,fcl,l);
794 else if ((display_transfer_mode==8) and (fch==fcl))
801 for (
int i=0; i<l+1; i++)
803 LCD_Write_DATA(fch, fcl);
810 void UTFT::drawVLine(
int x,
int y,
int l)
819 if (display_transfer_mode == 16)
822 _fast_fill_16(fch,fcl,l);
824 else if ((display_transfer_mode==8) and (fch==fcl))
831 for (
int i=0; i<l+1; i++)
833 LCD_Write_DATA(fch, fcl);
840 void UTFT::printChar(byte c,
int x,
int y)
850 if (orient==PORTRAIT)
852 setXY(x,y,x+cfont.x_size-1,y+cfont.y_size-1);
854 temp=((c-cfont.offset)*((cfont.x_size/8)*cfont.y_size))+4;
855 for(j=0;j<((cfont.x_size/8)*cfont.y_size);j++)
857 ch=pgm_read_byte(&cfont.font[temp]);
860 if((ch&(1<<(7-i)))!=0)
862 setPixel((fch<<8)|fcl);
866 setPixel((bch<<8)|bcl);
874 temp=((c-cfont.offset)*((cfont.x_size/8)*cfont.y_size))+4;
876 for(j=0;j<((cfont.x_size/8)*cfont.y_size);j+=(cfont.x_size/8))
878 setXY(x,y+(j/(cfont.x_size/8)),x+cfont.x_size-1,y+(j/(cfont.x_size/8)));
879 for (
int zz=(cfont.x_size/8)-1; zz>=0; zz--)
881 ch=pgm_read_byte(&cfont.font[temp+zz]);
886 setPixel((fch<<8)|fcl);
890 setPixel((bch<<8)|bcl);
894 temp+=(cfont.x_size/8);
900 temp=((c-cfont.offset)*((cfont.x_size/8)*cfont.y_size))+4;
901 for(j=0;j<cfont.y_size;j++)
903 for (
int zz=0; zz<(cfont.x_size/8); zz++)
905 ch=pgm_read_byte(&cfont.font[temp+zz]);
909 if((ch&(1<<(7-i)))!=0)
911 setXY(x+i+(zz*8),y+j,x+i+(zz*8)+1,y+j+1);
912 setPixel((fch<<8)|fcl);
916 temp+=(cfont.x_size/8);
924 void UTFT::rotateChar(byte c,
int x,
int y,
int pos,
int deg)
934 temp=((c-cfont.offset)*((cfont.x_size/8)*cfont.y_size))+4;
935 for(j=0;j<cfont.y_size;j++)
937 for (
int zz=0; zz<(cfont.x_size/8); zz++)
939 ch=pgm_read_byte(&cfont.font[temp+zz]);
942 newx=x+(((i+(zz*8)+(pos*cfont.x_size))*cos(radian))-((j)*sin(radian)));
943 newy=y+(((j)*cos(radian))+((i+(zz*8)+(pos*cfont.x_size))*sin(radian)));
945 setXY(newx,newy,newx+1,newy+1);
947 if((ch&(1<<(7-i)))!=0)
949 setPixel((fch<<8)|fcl);
954 setPixel((bch<<8)|bcl);
958 temp+=(cfont.x_size/8);
964 void UTFT::print(
char *st,
int x,
int y,
int deg)
970 if (orient==PORTRAIT)
973 x=(disp_x_size+1)-(stl*cfont.x_size);
975 x=((disp_x_size+1)-(stl*cfont.x_size))/2;
980 x=(disp_y_size+1)-(stl*cfont.x_size);
982 x=((disp_y_size+1)-(stl*cfont.x_size))/2;
985 for (i=0; i<stl; i++)
987 printChar(*st++, x + (i*(cfont.x_size)), y);
989 rotateChar(*st++, x, y, i, deg);
992 void UTFT::print(String st,
int x,
int y,
int deg)
994 char buf[st.length()+1];
996 st.toCharArray(buf, st.length()+1);
997 print(buf, x, y, deg);
1000 void UTFT::printNumI(
long num,
int x,
int y,
int length,
char filler)
1011 for (c=0; c<(length-1); c++)
1032 buf[c]=48+(num % 10);
1034 num=(num-(num % 10))/10;
1045 for (
int i=0; i<(length-c-neg); i++)
1052 for (
int i=0; i<c; i++)
1054 st[i+neg+f]=buf[c-i-1];
1063 void UTFT::printNumF(
double num, byte dec,
int x,
int y,
char divider,
int length,
char filler)
1076 _convert_float(st, num, length, dec);
1080 for (
int i=0; i<
sizeof(st); i++)
1090 for (
int i=1; i<
sizeof(st); i++)
1091 if ((st[i]==
' ') || (st[i]==
'-'))
1096 for (
int i=0; i<
sizeof(st); i++)
1105 void UTFT::setFont(uint8_t* font)
1108 cfont.x_size=fontbyte(0);
1109 cfont.y_size=fontbyte(1);
1110 cfont.offset=fontbyte(2);
1111 cfont.numchars=fontbyte(3);
1114 uint8_t* UTFT::getFont()
1119 uint8_t UTFT::getFontXsize()
1121 return cfont.x_size;
1124 uint8_t UTFT::getFontYsize()
1126 return cfont.y_size;
1129 void UTFT::drawBitmap(
int x,
int y,
int sx,
int sy, bitmapdatatype data,
int scale)
1132 int tx, ty, tc, tsx, tsy;
1136 if (orient==PORTRAIT)
1139 setXY(x, y, x+sx-1, y+sy-1);
1140 for (tc=0; tc<(sx*sy); tc++)
1142 col=pgm_read_word(&data[tc]);
1143 LCD_Write_DATA(col>>8,col & 0xff);
1150 for (ty=0; ty<sy; ty++)
1152 setXY(x, y+ty, x+sx-1, y+ty);
1153 for (tx=sx-1; tx>=0; tx--)
1155 col=pgm_read_word(&data[(ty*sx)+tx]);
1156 LCD_Write_DATA(col>>8,col & 0xff);
1164 if (orient==PORTRAIT)
1167 for (ty=0; ty<sy; ty++)
1169 setXY(x, y+(ty*scale), x+((sx*scale)-1), y+(ty*scale)+scale);
1170 for (tsy=0; tsy<scale; tsy++)
1171 for (tx=0; tx<sx; tx++)
1173 col=pgm_read_word(&data[(ty*sx)+tx]);
1174 for (tsx=0; tsx<scale; tsx++)
1175 LCD_Write_DATA(col>>8,col & 0xff);
1183 for (ty=0; ty<sy; ty++)
1185 for (tsy=0; tsy<scale; tsy++)
1187 setXY(x, y+(ty*scale)+tsy, x+((sx*scale)-1), y+(ty*scale)+tsy);
1188 for (tx=sx-1; tx>=0; tx--)
1190 col=pgm_read_word(&data[(ty*sx)+tx]);
1191 for (tsx=0; tsx<scale; tsx++)
1192 LCD_Write_DATA(col>>8,col & 0xff);
1202 void UTFT::drawBitmap(
int x,
int y,
int sx,
int sy, bitmapdatatype data,
int deg,
int rox,
int roy)
1205 int tx, ty, newx, newy;
1210 drawBitmap(x, y, sx, sy, data);
1214 for (ty=0; ty<sy; ty++)
1215 for (tx=0; tx<sx; tx++)
1217 col=pgm_read_word(&data[(ty*sx)+tx]);
1219 newx=x+rox+(((tx-rox)*cos(radian))-((ty-roy)*sin(radian)));
1220 newy=y+roy+(((ty-roy)*cos(radian))+((tx-rox)*sin(radian)));
1222 setXY(newx, newy, newx, newy);
1223 LCD_Write_DATA(col>>8,col & 0xff);
1233 switch (display_model)
1236 LCD_Write_COM(0x28);
1240 LCD_Write_COM_DATA(0x07,0x0000);
1241 LCD_Write_COM_DATA(0x00,0x0000);
1245 LCD_Write_COM_DATA(0x10,0x0001);
1248 LCD_Write_COM_DATA(0x01,0x0000);
1249 LCD_Write_COM(0x0F);
1258 switch (display_model)
1261 LCD_Write_COM(0x29);
1265 LCD_Write_COM_DATA(0x00,0x0001);
1266 LCD_Write_COM_DATA(0x07,0x0023);
1267 LCD_Write_COM_DATA(0x10,0x0000);
1269 LCD_Write_COM_DATA(0x07,0x0033);
1270 LCD_Write_COM_DATA(0x11,0x60B0);
1271 LCD_Write_COM_DATA(0x02,0x0600);
1272 LCD_Write_COM(0x22);
1278 LCD_Write_COM_DATA(0x01,0x0010);
1279 LCD_Write_COM(0x0F);
1285 void UTFT::setContrast(
char c)
1288 switch (display_model)
1292 LCD_Write_COM(0x25);
1299 int UTFT::getDisplayXSize()
1301 if (orient==PORTRAIT)
1302 return disp_x_size+1;
1304 return disp_y_size+1;
1307 int UTFT::getDisplayYSize()
1309 if (orient==PORTRAIT)
1310 return disp_y_size+1;
1312 return disp_x_size+1;
1315 void UTFT::setBrightness(byte br)
1318 switch (display_model)
1322 LCD_Write_COM_DATA(0x01,br);
1323 LCD_Write_COM(0x0F);
1329 void UTFT::setDisplayPage(byte page)
1332 switch (display_model)
1336 LCD_Write_COM_DATA(0x04,page);
1337 LCD_Write_COM(0x0F);
1343 void UTFT::setWritePage(byte page)
1346 switch (display_model)
1350 LCD_Write_COM_DATA(0x05,page);
1351 LCD_Write_COM(0x0F);