├── README.txt ├── library.properties ├── keywords.txt ├── examples ├── ILI9341_lib_HelloWorld │ └── ILI9341_lib_HelloWorld.ino ├── ILI9341_lib_Rotation │ └── ILI9341_lib_Rotation.ino ├── ILI9341_lib_Bitmap │ ├── ILI9341_lib_Bitmap.ino │ └── bitmap.h ├── ILI9341_lib_MovingText │ └── ILI9341_lib_MovingText.ino ├── ILI9341_lib_Lines │ └── ILI9341_lib_Lines.ino ├── ILI9341_lib_Watch_2bit │ ├── rtc.h │ └── ILI9341_lib_Watch_2bit.ino ├── ILI9341_lib_ControllerModes │ └── ILI9341_lib_ControllerModes.ino ├── ILI9341_lib_BigScroll │ └── ILI9341_lib_BigScroll.ino ├── ILI9341_lib_AmigaBall │ ├── ILI9341_lib_AmigaBall.ino │ └── ball.h ├── ILI9341_lib_Numeric_display │ └── ILI9341_lib_Numeric_display.ino ├── ILI9341_lib_Gauges │ └── ILI9341_lib_Gauges.ino └── ILI9341_lib_AdafruitBenchmark │ └── ILI9341_lib_AdafruitBenchmark.ino ├── README.md ├── ILI9341_Fast.h ├── ILI9341_Fast.cpp └── LICENSE /README.txt: -------------------------------------------------------------------------------- 1 | This is fast SPI library for ILI9341 320x240 SPI display. 2 | 3 | Optimized for the best performance for 16MHz AVR Arduino boards. 4 | Requires Adafruit_GFX library for Arduino. 5 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=Fast ILI9341 Library 2 | version=1.0.2 3 | author=Pawel A. Hernik 4 | maintainer=Pawel A. Hernik 5 | sentence=Fast SPI library for ILI9341 320x240 LCD 6 | paragraph=Fast SPI library for ILI9341 320x240 LCD 7 | category=Display 8 | url=https://github.com/cbm80amiga/ILI9341_Fast 9 | architectures=* 10 | -------------------------------------------------------------------------------- /keywords.txt: -------------------------------------------------------------------------------- 1 | ILI9341 KEYWORD3 2 | 3 | init KEYWORD2 4 | invertDisplay KEYWORD2 5 | partialDisplay KEYWORD2 6 | sleepDisplay KEYWORD2 7 | enableDisplay KEYWORD2 8 | idleDisplay KEYWORD2 9 | resetDisplay KEYWORD2 10 | setScrollArea KEYWORD2 11 | setScroll KEYWORD2 12 | setPartArea KEYWORD2 13 | powerSave KEYWORD2 14 | rgbWheel KEYWORD2 15 | RGBto565 KEYWORD2 16 | drawImage KEYWORD2 17 | drawImageF KEYWORD2 18 | -------------------------------------------------------------------------------- /examples/ILI9341_lib_HelloWorld/ILI9341_lib_HelloWorld.ino: -------------------------------------------------------------------------------- 1 | // ILI9341 library example 2 | // (c) 2020 Pawel A. Hernik 3 | 4 | /* 5 | ILI9341 240x320 2.2" LCD pinout (header at the top, from left): 6 | #1 MISO -> NC 7 | #2 LED -> 3.3V 8 | #3 SCK -> SCL/D13/PA5 9 | #4 SDI -> MOSI/D11/PA7 10 | #5 DC -> D8/PA1 or any digital 11 | #6 RESET -> D9/PA0 or any digital 12 | #7 CS -> D10/PA2 or any digital 13 | #8 GND -> GND 14 | #9 VCC -> 3.3V 15 | */ 16 | 17 | #define SCR_WD 240 18 | #define SCR_HT 320 19 | #include 20 | #include 21 | 22 | #if (__STM32F1__) // bluepill 23 | #define TFT_CS PA2 24 | #define TFT_DC PA1 25 | #define TFT_RST PA0 26 | //#include 27 | #else 28 | #define TFT_CS 10 29 | #define TFT_DC 8 30 | #define TFT_RST 9 31 | #include 32 | #endif 33 | 34 | ILI9341 lcd = ILI9341(TFT_DC, TFT_RST, TFT_CS); 35 | 36 | void setup(void) 37 | { 38 | Serial.begin(9600); 39 | lcd.init(); 40 | lcd.fillScreen(BLACK); 41 | lcd.setTextColor(WHITE,BLUE); 42 | int xt=(SCR_WD-11*6)/2, yt=(SCR_HT-8)/2; 43 | lcd.setCursor(xt, yt); 44 | lcd.println("HELLO WORLD"); 45 | lcd.drawRect(xt-10,yt-10,11*6+20,8+20,GREEN); 46 | } 47 | 48 | void loop() 49 | { 50 | } 51 | 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ILI9341_Fast 2 | Fast SPI library for the ILI9341 240x320 TFT display 3 | 4 | Significantly optimized for 16MHz AVR Arduino boards (2.5-3x faster than other libraries) 5 | 6 | Achieved 6.9Mbps SPI transfer rate (at DIV2/16MHz clock) 7 | 8 | YouTube video: 9 | 10 | https://youtu.be/0RnzPXBY3SM 11 | 12 | ## Recent optimizations 13 | 14 | After recent optimizations (more AVR assembler) all fill and copy operations work with max speed of about 7.1Mbps for 16MHz Arduino and the library flash memory usage is reduced by about 800-900 bytes 15 | 16 | ## Configuration 17 | 18 | Use "define COMPATIBILITY_MODE" - then the library should work on all Arduino compatible boards 19 | Remove above for the best performance on 16MHz AVR 20 | 21 | Use "#define CS_ALWAYS_LOW" if CS pin is connected to the ground, it gives little better performance 22 | 23 | Tested with **Arduino IDE 1.6.5 and Adafruit_GFX 1.5.6** 24 | 25 | ## Extra Features 26 | - invertDisplay() 27 | - sleepDisplay() 28 | - enableDisplay() 29 | - resetDisplay() - software reset 30 | - partialDisplay() and setPartArea() - limiting display area for power saving 31 | - setScrollArea() and setScroll() - smooth vertical scrolling 32 | - very fast drawImage() from RAM 33 | - fast drawImage() from flash (PROGMEM) 34 | 35 | ## Connections: 36 | 37 | |LCD pin|LCD pin name|Arduino| 38 | |--|--|--| 39 | |#1| MISO|NC or MISO| 40 | |#2| LED |3.3V| 41 | |#3| SCK|SCL/D13| 42 | |#4| SDI|MOSI/D11| 43 | |#5| DC |D8 or any digital| 44 | |#6| RESET|D9 or any digital| 45 | |#7| CS |D10 or any digital| 46 | |#8| GND|GND| 47 | |#9| VCC|3.3V| 48 | 49 | If you find it useful and want to buy me a coffee or a beer: 50 | 51 | https://www.paypal.me/cbm80amiga 52 | -------------------------------------------------------------------------------- /examples/ILI9341_lib_Rotation/ILI9341_lib_Rotation.ino: -------------------------------------------------------------------------------- 1 | // ILI9341 library example 2 | // (c) 2020 Pawel A. Hernik 3 | 4 | /* 5 | ILI9341 240x320 2.2" LCD pinout (header at the top, from left): 6 | #1 MISO -> NC 7 | #2 LED -> 3.3V 8 | #3 SCK -> SCL/D13/PA5 9 | #4 SDI -> MOSI/D11/PA7 10 | #5 DC -> D8/PA1 or any digital 11 | #6 RESET -> D9/PA0 or any digital 12 | #7 CS -> D10/PA2 or any digital 13 | #8 GND -> GND 14 | #9 VCC -> 3.3V 15 | */ 16 | 17 | #define SCR_WD 240 18 | #define SCR_HT 320 19 | #include 20 | #include 21 | 22 | #if (__STM32F1__) // bluepill 23 | #define TFT_CS PA2 24 | #define TFT_DC PA1 25 | #define TFT_RST PA0 26 | //#include 27 | #else 28 | #define TFT_CS 10 29 | #define TFT_DC 8 30 | #define TFT_RST 9 31 | #include 32 | #endif 33 | 34 | ILI9341 lcd = ILI9341(TFT_DC, TFT_RST, TFT_CS); 35 | 36 | void setup() 37 | { 38 | Serial.begin(9600); 39 | lcd.init(); 40 | } 41 | 42 | void loop(void) 43 | { 44 | for(uint8_t rot = 0; rot < 4; rot++) { 45 | testText(rot); 46 | delay(2000); 47 | } 48 | } 49 | 50 | unsigned long testText(int rot) 51 | { 52 | lcd.setRotation(rot); 53 | lcd.fillScreen(BLACK); 54 | lcd.setCursor(0, 0); 55 | lcd.setTextColor(BLUE); 56 | lcd.setTextSize(1); 57 | lcd.println("Hello World!"); 58 | lcd.setTextColor(WHITE); 59 | lcd.print("Rotation = "); 60 | lcd.println(rot); 61 | lcd.setTextColor(YELLOW); 62 | lcd.setTextSize(2); 63 | lcd.println(1234.56); 64 | lcd.setTextColor(RED); 65 | lcd.setTextSize(3); 66 | lcd.println(0xDEAD, HEX); 67 | lcd.println(); 68 | lcd.setTextColor(GREEN); 69 | lcd.setTextSize(4); 70 | lcd.println("Hello"); 71 | } 72 | 73 | 74 | -------------------------------------------------------------------------------- /examples/ILI9341_lib_Bitmap/ILI9341_lib_Bitmap.ino: -------------------------------------------------------------------------------- 1 | // ILI9341 library example 2 | // (c) 2020 Pawel A. Hernik 3 | 4 | /* 5 | ILI9341 240x320 2.2" LCD pinout (header at the top, from left): 6 | #1 MISO -> NC 7 | #2 LED -> 3.3V 8 | #3 SCK -> SCL/D13/PA5 9 | #4 SDI -> MOSI/D11/PA7 10 | #5 DC -> D8/PA1 or any digital 11 | #6 RESET -> D9/PA0 or any digital 12 | #7 CS -> D10/PA2 or any digital 13 | #8 GND -> GND 14 | #9 VCC -> 3.3V 15 | */ 16 | 17 | #define SCR_WD 240 18 | #define SCR_HT 320 19 | #include 20 | #include 21 | 22 | #if (__STM32F1__) // bluepill 23 | #define TFT_CS PA2 24 | #define TFT_DC PA1 25 | #define TFT_RST PA0 26 | //#include 27 | #else 28 | #define TFT_CS 10 29 | #define TFT_DC 8 30 | #define TFT_RST 9 31 | #include 32 | #endif 33 | 34 | ILI9341 lcd = ILI9341(TFT_DC, TFT_RST, TFT_CS); 35 | 36 | #include "bitmap.h" 37 | 38 | #define BARWD 24 39 | uint16_t colorBar[BARWD]; 40 | 41 | void setup(void) 42 | { 43 | Serial.begin(9600); 44 | lcd.init(); 45 | lcd.fillScreen(BLACK); 46 | 47 | int i,j; 48 | for(j=0;j NC 10 | #2 LED -> 3.3V 11 | #3 SCK -> SCL/D13/PA5 12 | #4 SDI -> MOSI/D11/PA7 13 | #5 DC -> D8/PA1 or any digital 14 | #6 RESET -> D9/PA0 or any digital 15 | #7 CS -> D10/PA2 or any digital 16 | #8 GND -> GND 17 | #9 VCC -> 3.3V 18 | */ 19 | 20 | #define SCR_WD 240 21 | #define SCR_HT 320 22 | #include 23 | #include 24 | 25 | #if (__STM32F1__) // bluepill 26 | #define TFT_CS PA2 27 | #define TFT_DC PA1 28 | #define TFT_RST PA0 29 | //#include 30 | #else 31 | #define TFT_CS 10 32 | #define TFT_DC 8 33 | #define TFT_RST 9 34 | #include 35 | #endif 36 | 37 | ILI9341 lcd = ILI9341(TFT_DC, TFT_RST, TFT_CS); 38 | 39 | #include "RREFont.h" 40 | #include "rre_chicago_20x24.h" 41 | 42 | RREFont font; 43 | 44 | // needed for RREFont library initialization, define your fillRect 45 | void customRect(int x, int y, int w, int h, int c) { return lcd.fillRect(x, y, w, h, c); } 46 | 47 | void setup() 48 | { 49 | Serial.begin(9600); 50 | lcd.init(); 51 | lcd.fillScreen(BLACK); 52 | 53 | font.init(customRect, SCR_WD, SCR_HT); // custom fillRect function and screen width and height values 54 | font.setFont(&rre_chicago_20x24); 55 | 56 | int i; 57 | for(i=0;i<10;i++) { 58 | font.setColor(RGBto565(i*15,i*15,i*15)); 59 | font.printStr(70+i,40+i,"Hello"); 60 | } 61 | font.setColor(WHITE); 62 | font.printStr(70+i,40+i,"Hello"); 63 | 64 | for(i=0;i<10;i++) { 65 | font.setColor(lcd.rgbWheel(0+i*8)); 66 | font.printStr(60+i,120+i,"World"); 67 | } 68 | font.setColor(WHITE); 69 | font.printStr(60+i,120+i,"World"); 70 | delay(4000); 71 | lcd.fillScreen(); 72 | } 73 | 74 | #define MAX_TXT 32 75 | int tx[MAX_TXT]; 76 | int ty[MAX_TXT]; 77 | byte cur=0; 78 | int numTxt=16; 79 | int x=0,y=0; 80 | int dx=6,dy=5; 81 | int i,ii,cc=0; 82 | 83 | void loop() 84 | { 85 | x+=dx; 86 | y+=dy; 87 | if(x>SCR_WD-20) { dx=-dx; x=SCR_WD-20; } 88 | if(x<1) { dx=-dx; x=0; } 89 | if(y>SCR_HT-20) { dy=-dy; y=SCR_HT-20; } 90 | if(y<1) { dy=-dy; y=0; } 91 | int i=cur; 92 | //font.setColor(BLACK); 93 | //font.printStr(tx[i],ty[i],"Hello!"); 94 | tx[cur]=x; 95 | ty[cur]=y; 96 | if(++cur>=numTxt) cur=0; 97 | for(i=0;i=numTxt) ii-=numTxt; 100 | font.setColor(RGBto565(i*15,i*5,0)); 101 | if(i==numTxt-1) font.setColor(WHITE); 102 | font.printStr(tx[ii],ty[ii],"Hello!"); 103 | cc++; 104 | } 105 | delay(20); 106 | } 107 | 108 | -------------------------------------------------------------------------------- /examples/ILI9341_lib_Lines/ILI9341_lib_Lines.ino: -------------------------------------------------------------------------------- 1 | // ILI9341 library example 2 | // (c) 2020 Pawel A. Hernik 3 | 4 | /* 5 | ILI9341 240x320 2.2" LCD pinout (header at the top, from left): 6 | #1 MISO -> NC 7 | #2 LED -> 3.3V 8 | #3 SCK -> SCL/D13/PA5 9 | #4 SDI -> MOSI/D11/PA7 10 | #5 DC -> D8/PA1 or any digital 11 | #6 RESET -> D9/PA0 or any digital 12 | #7 CS -> D10/PA2 or any digital 13 | #8 GND -> GND 14 | #9 VCC -> 3.3V 15 | */ 16 | 17 | #define SCR_WD 240 18 | #define SCR_HT 320 19 | #include 20 | #include 21 | 22 | #if (__STM32F1__) // bluepill 23 | #define TFT_CS PA2 24 | #define TFT_DC PA1 25 | #define TFT_RST PA0 26 | //#include 27 | #else 28 | #define TFT_CS 10 29 | #define TFT_DC 8 30 | #define TFT_RST 9 31 | #include 32 | #endif 33 | 34 | ILI9341 lcd = ILI9341(TFT_DC, TFT_RST, TFT_CS); 35 | 36 | void setup() 37 | { 38 | Serial.begin(9600); 39 | lcd.init(); 40 | lcd.fillScreen(BLACK); 41 | /* 42 | for(int i=0;i<128;i++) { 43 | lcd.fillRect(32*0,i,32,1,RGBto565(i*2,0,0)); 44 | lcd.fillRect(32*1,i,32,1,RGBto565(0,i*2,0)); 45 | lcd.fillRect(32*2,i,32,1,RGBto565(0,0,i*2)); 46 | lcd.fillRect(32*3,i,32,1,RGBto565(i*2,i*2,i*2)); 47 | } 48 | delay(2000); 49 | */ 50 | } 51 | 52 | void circles() 53 | { 54 | int x,y; 55 | x = 15+random(SCR_WD-30); 56 | y = 15+random(SCR_HT-30); 57 | lcd.fillCircle(x,y,15,random()); 58 | lcd.drawCircle(x,y,16,YELLOW); 59 | } 60 | 61 | #define MAX_LINES 16 62 | int lx0[MAX_LINES]; 63 | int lx1[MAX_LINES]; 64 | int ly0[MAX_LINES]; 65 | int ly1[MAX_LINES]; 66 | int curLine=0; 67 | int x0=40,y0=0; 68 | int dx0=6,dy0=5; 69 | int x1=80,y1=40; 70 | int dx1=9,dy1=8; 71 | int cc=0; 72 | int numLines=12; 73 | 74 | void animLines(int mode) 75 | { 76 | uint16_t c; 77 | x0+=dx0; 78 | y0+=dy0; 79 | x1+=dx1; 80 | y1+=dy1; 81 | if(x0>SCR_WD-1) { dx0=-dx0; x0=SCR_WD-1; } 82 | if(x0<1) { dx0=-dx0; x0=0; } 83 | if(y0>SCR_HT-1) { dy0=-dy0; y0=SCR_HT-1; } 84 | if(y0<1) { dy0=-dy0; y0=0; } 85 | if(x1>SCR_WD-1) { dx1=-dx1; x1=SCR_WD-1; } 86 | if(x1<1) { dx1=-dx1; x1=0; } 87 | if(y1>SCR_HT-1) { dy1=-dy1; y1=SCR_HT-1; } 88 | if(y1<1) { dy1=-dy1; y1=0; } 89 | int i=curLine; 90 | if(mode&1) lcd.drawLine(lx0[i],ly0[i],lx1[i],ly1[i], 0); 91 | if(mode&2) lcd.drawLine(SCR_WD-1-lx0[i],ly0[i],SCR_WD-1-lx1[i],ly1[i],0); 92 | if(mode&4) lcd.drawLine(lx0[i],SCR_HT-1-ly0[i],lx1[i],SCR_HT-1-ly1[i],0); 93 | if(mode&8) lcd.drawLine(SCR_WD-1-lx0[i],SCR_HT-1-ly0[i],SCR_WD-1-lx1[i],SCR_HT-1-ly1[i],0); 94 | lx0[curLine]=x0; 95 | lx1[curLine]=x1; 96 | ly0[curLine]=y0; 97 | ly1[curLine]=y1; 98 | if(++curLine>=numLines) curLine=0; 99 | for(int i=0;i>4)*10+((x)&0xf); } 2 | int DEC2BCD(int x) { return (((x)/10)<<4)+((x)%10); } 3 | 4 | #if USEHW==1 5 | #define I2CStart(x) Wire.beginTransmission(x) 6 | #define I2CStop() Wire.endTransmission() 7 | #define I2CWrite(x) Wire.write(x) 8 | #define I2CRead() Wire.read() 9 | #define I2CReadLast() Wire.read() 10 | #define I2CReq(x,y) Wire.requestFrom(x,y) 11 | #define I2CReady while(!Wire.available()) {}; 12 | #else 13 | #define I2CStart(x) i2c_start((x<<1) | I2C_WRITE) 14 | #define I2CStop() i2c_stop() 15 | #define I2CWrite(x) i2c_write(x) 16 | #define I2CRead() i2c_read(false) 17 | #define I2CReadLast() i2c_read(true) 18 | #define I2CReq(x,y) i2c_rep_start((x<<1) | I2C_READ) 19 | #define I2CReady 20 | #endif 21 | 22 | #define DS1307_I2C_ADDRESS 0x68 // same for DS3231 23 | #define DS1307_TIME 0x00 24 | #define DS1307_DOW 0x03 25 | #define DS1307_DATE 0x04 26 | #define DS1307_MEM 0x08 27 | 28 | #define DS3231_I2C_ADDRESS 0x68 29 | #define DS3231_CONTROL 0x0e 30 | #define DS3231_STATUS 0x0f 31 | #define DS3231_TEMP 0x11 32 | 33 | /* 34 | void setRTCDateTime(struct RTCData *data) 35 | { 36 | I2CStart(DS1307_I2C_ADDRESS); 37 | I2CWrite(DS1307_TIME); 38 | I2CWrite(DEC2BCD(data->second)); 39 | I2CWrite(DEC2BCD(data->minute)); 40 | I2CWrite(DEC2BCD(data->hour)); 41 | I2CWrite(DEC2BCD(data->dayOfWeek)); 42 | I2CWrite(DEC2BCD(data->day)); 43 | I2CWrite(DEC2BCD(data->month)); 44 | I2CWrite(DEC2BCD(data->year)); // year 00..99 45 | I2CStop(); 46 | } 47 | */ 48 | 49 | void setRTCTime(struct RTCData *data) 50 | { 51 | I2CStart(DS1307_I2C_ADDRESS); 52 | I2CWrite(DS1307_TIME); 53 | I2CWrite(DEC2BCD(data->second)); 54 | I2CWrite(DEC2BCD(data->minute)); 55 | I2CWrite(DEC2BCD(data->hour)); 56 | I2CStop(); 57 | } 58 | 59 | void getRTCDateTime(struct RTCData *data) 60 | { 61 | I2CStart(DS1307_I2C_ADDRESS); 62 | I2CWrite(DS1307_TIME); 63 | I2CStop(); 64 | 65 | I2CReq(DS1307_I2C_ADDRESS, 7); 66 | I2CReady; 67 | 68 | data->second = BCD2DEC(I2CRead() & 0x7f); 69 | data->minute = BCD2DEC(I2CRead() & 0x7f); 70 | data->hour = BCD2DEC(I2CRead() & 0x3f); 71 | data->dayOfWeek = I2CRead() & 0x07; 72 | data->day = BCD2DEC(I2CRead() & 0x3f); 73 | data->month = BCD2DEC(I2CRead() & 0x3f); 74 | data->year = BCD2DEC(I2CReadLast() & 0xff); 75 | 76 | I2CStop(); 77 | #if DEBUG_RTC==1 78 | //Serial.print(hour); Serial.print(":"); Serial.print(minute); Serial.print(":"); Serial.println(second); 79 | //Serial.print(day); Serial.print("-"); Serial.print(month); Serial.print("-"); Serial.println(year); 80 | //Serial.println(dayOfWeek); 81 | #endif 82 | } 83 | 84 | float getDS3231Temp() 85 | { 86 | I2CStart(DS3231_I2C_ADDRESS); 87 | I2CWrite(DS3231_TEMP); 88 | I2CStop(); 89 | I2CReq(DS1307_I2C_ADDRESS, 2); 90 | I2CReady; 91 | int msb = I2CRead()<<2; 92 | int lsb = I2CRead()>>6; 93 | I2CStop(); 94 | return (msb | lsb)/4.0; 95 | } 96 | 97 | void writeRTCReg(byte addr, byte val) 98 | { 99 | I2CStart(DS3231_I2C_ADDRESS); 100 | I2CWrite(addr); 101 | I2CWrite(val); 102 | I2CStop(); 103 | } 104 | 105 | // for DS1307 only 106 | void writeRTCMem(byte addr, byte val) 107 | { 108 | if(addr>56) return; 109 | I2CStart(DS1307_I2C_ADDRESS); 110 | I2CWrite(DS1307_MEM + addr); 111 | I2CWrite(val); 112 | I2CStop(); 113 | } 114 | 115 | byte readRTCMem(byte addr) 116 | { 117 | if(addr>56) return 0; 118 | I2CStart(DS1307_I2C_ADDRESS); 119 | I2CWrite(DS1307_MEM + addr); 120 | I2CStop(); 121 | I2CReq(DS1307_I2C_ADDRESS, 1); 122 | I2CReady; 123 | byte v = I2CReadLast(); 124 | I2CStop(); 125 | return v; 126 | } 127 | 128 | -------------------------------------------------------------------------------- /ILI9341_Fast.h: -------------------------------------------------------------------------------- 1 | // Fast ILI9341 240x320 2.2" display library 2 | // (c) 2019-20 by Pawel A. Hernik 3 | 4 | /* 5 | ILI9341 240x320 2.2" LCD pinout (header at the top, from left): 6 | #1 MISO -> NC 7 | #2 LED -> 3.3V 8 | #3 SCK -> SCL/D13/PA5 9 | #4 SDI -> MOSI/D11/PA7 10 | #5 DC -> D8/PA1 or any digital 11 | #6 RESET -> D9/PA0 or any digital 12 | #7 CS -> D10/PA2 or any digital 13 | #8 GND -> GND 14 | #9 VCC -> 3.3V 15 | */ 16 | 17 | #ifndef _ILI9341_FAST_H_ 18 | #define _ILI9341_FAST_H_ 19 | 20 | // ------------------------------ 21 | // remove "define COMPATIBILITY_MODE" for best performance on 16MHz AVR Arduinos 22 | // if defined - the library should work on all Arduino compatible boards 23 | //#define COMPATIBILITY_MODE 24 | 25 | // define when CS pin is always connected to the ground 26 | //#define CS_ALWAYS_LOW 27 | // ------------------------------ 28 | 29 | #include "Arduino.h" 30 | #include "Print.h" 31 | #include 32 | #include 33 | 34 | #define ILI9341_TFTWIDTH 240 35 | #define ILI9341_TFTHEIGHT 320 36 | 37 | // Color definitions 38 | 39 | #define RGBto565(r,g,b) ((((r) & 0xF8) << 8) | (((g) & 0xFC) << 3) | ((b) >> 3)) 40 | #define RGBIto565(r,g,b,i) ((((((r)*(i))/255) & 0xF8) << 8) | ((((g)*(i)/255) & 0xFC) << 3) | ((((b)*(i)/255) & 0xFC) >> 3)) 41 | 42 | #define BLACK 0x0000 43 | #define BLUE 0x001F 44 | #define RED 0xF800 45 | #define GREEN 0x07E0 46 | #define CYAN 0x07FF 47 | #define MAGENTA 0xF81F 48 | #define YELLOW 0xFFE0 49 | #define WHITE 0xFFFF 50 | 51 | #define GREY RGBto565(128,128,128) 52 | #define LGREY RGBto565(160,160,160) 53 | #define DGREY RGBto565( 80, 80, 80) 54 | 55 | #define LBLUE RGBto565(100,100,255) 56 | #define DBLUE RGBto565( 0, 0,128) 57 | 58 | class ILI9341 : public Adafruit_GFX { 59 | 60 | public: 61 | ILI9341(int8_t DC, int8_t RST, int8_t CS = -1); 62 | 63 | void init(); 64 | void begin() { init(); } 65 | void setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1); 66 | void pushColor(uint16_t color); 67 | void fillScreen(uint16_t color=BLACK); 68 | void clearScreen() { fillScreen(BLACK); } 69 | void drawPixel(int16_t x, int16_t y, uint16_t color); 70 | void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color); 71 | void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color); 72 | void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); 73 | void drawImage(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t *img); 74 | void drawImageF(int16_t x, int16_t y, int16_t w, int16_t h, const uint16_t *img16); 75 | void drawImageF(int16_t x, int16_t y, const uint16_t *img16) { drawImageF(x,y,pgm_read_word(img16),pgm_read_word(img16+1),img16+3); } 76 | void setRotation(uint8_t r); 77 | void invertDisplay(boolean mode); 78 | void partialDisplay(boolean mode); 79 | void sleepDisplay(boolean mode); 80 | void enableDisplay(boolean mode); 81 | void idleDisplay(boolean mode); 82 | void resetDisplay(); 83 | void setScrollArea(uint16_t tfa, uint16_t bfa); 84 | void setScroll(uint16_t vsp); 85 | void setPartArea(uint16_t sr, uint16_t er); 86 | 87 | uint16_t Color565(uint8_t r, uint8_t g, uint8_t b); 88 | uint16_t color565(uint8_t r, uint8_t g, uint8_t b) { return Color565(r, g, b); } 89 | void rgbWheel(int idx, uint8_t *_r, uint8_t *_g, uint8_t *_b); 90 | uint16_t rgbWheel(int idx); 91 | 92 | protected: 93 | void displayInit(const uint8_t *addr); 94 | void writeSPI(uint8_t); 95 | void writeMulti(uint16_t color, uint16_t num); 96 | void writeCmd(uint8_t c); 97 | void writeData(uint8_t d8); 98 | void writeData16(uint16_t d16); 99 | void copyMulti(uint8_t *img, uint16_t num); 100 | 101 | private: 102 | int8_t csPin, dcPin, rstPin; 103 | uint8_t csMask, dcMask; 104 | volatile uint8_t *csPort, *dcPort; 105 | 106 | }; 107 | 108 | #endif 109 | -------------------------------------------------------------------------------- /examples/ILI9341_lib_ControllerModes/ILI9341_lib_ControllerModes.ino: -------------------------------------------------------------------------------- 1 | // ILI9341 library example 2 | // (c) 2020 Pawel A. Hernik 3 | 4 | // requires RRE Font library: 5 | // https://github.com/cbm80amiga/RREFont 6 | 7 | /* 8 | ILI9341 240x320 2.2" LCD pinout (header at the top, from left): 9 | #1 MISO -> NC 10 | #2 LED -> 3.3V 11 | #3 SCK -> SCL/D13/PA5 12 | #4 SDI -> MOSI/D11/PA7 13 | #5 DC -> D8/PA1 or any digital 14 | #6 RESET -> D9/PA0 or any digital 15 | #7 CS -> D10/PA2 or any digital 16 | #8 GND -> GND 17 | #9 VCC -> 3.3V 18 | */ 19 | 20 | #define SCR_WD 240 21 | #define SCR_HT 320 22 | #include 23 | #include 24 | 25 | #if (__STM32F1__) // bluepill 26 | #define TFT_CS PA2 27 | #define TFT_DC PA1 28 | #define TFT_RST PA0 29 | //#include 30 | #else 31 | #define TFT_CS 10 32 | #define TFT_DC 8 33 | #define TFT_RST 9 34 | #include 35 | #endif 36 | 37 | ILI9341 lcd = ILI9341(TFT_DC, TFT_RST, TFT_CS); 38 | 39 | #include "RREFont.h" 40 | #include "rre_chicago_20x24.h" 41 | 42 | RREFont font; 43 | 44 | // needed for RREFont library initialization, define your fillRect 45 | void customRect(int x, int y, int w, int h, int c) { return lcd.fillRect(x, y, w, h, c); } 46 | 47 | void setup() 48 | { 49 | Serial.begin(9600); 50 | lcd.init(); 51 | font.init(customRect, SCR_WD, SCR_HT); // custom fillRect function and screen width and height values 52 | font.setFont(&rre_chicago_20x24); 53 | font.setScale(1,2); font.setSpacing(3); 54 | font.setColor(WHITE); 55 | } 56 | 57 | const int fht = 48; 58 | 59 | void rainbow() 60 | { 61 | for(int i=0;i NC 10 | #2 LED -> 3.3V 11 | #3 SCK -> SCL/D13/PA5 12 | #4 SDI -> MOSI/D11/PA7 13 | #5 DC -> D8/PA1 or any digital 14 | #6 RESET -> D9/PA0 or any digital 15 | #7 CS -> D10/PA2 or any digital 16 | #8 GND -> GND 17 | #9 VCC -> 3.3V 18 | */ 19 | 20 | #define SCR_WD 240 21 | #define SCR_HT 320 22 | #include 23 | #include 24 | 25 | #if (__STM32F1__) // bluepill 26 | #define TFT_CS PA2 27 | #define TFT_DC PA1 28 | #define TFT_RST PA0 29 | //#include 30 | #else 31 | #define TFT_CS 10 32 | #define TFT_DC 8 33 | #define TFT_RST 9 34 | #include 35 | #endif 36 | 37 | ILI9341 lcd = ILI9341(TFT_DC, TFT_RST, TFT_CS); 38 | 39 | #include "RREFont.h" 40 | #include "rre_times_98v.h" 41 | #include "rre_tahoma_65v.h" 42 | 43 | RRE_Font *rFont = &rre_Times98v; 44 | //RRE_Font *rFont = &rre_tahoma_65v; 45 | 46 | uint16_t bg = 0x0000, fg = 0xffff; 47 | int maxy = SCR_HT; 48 | int screenWd = SCR_WD, screenHt = SCR_HT; 49 | int spacing = 1; 50 | int sx = 1, sy = 1; 51 | int scrollStep = 2; 52 | int scrollDelay = 10; 53 | int cnt = 0; 54 | int ycnt = 0, yscr = 0; 55 | int offsY = 30; 56 | unsigned long ms; 57 | 58 | 59 | int scrollCharRRE(unsigned char c) 60 | { 61 | if(cfirstCh || c>rFont->lastCh) return 0; 62 | uint16_t recIdx = pgm_read_word(&(rFont->offs[c-rFont->firstCh])); 63 | uint16_t recNum = pgm_read_word(&(rFont->offs[c-rFont->firstCh+1]))-recIdx; 64 | int chWd = recNum>0 ? pgm_read_byte(rFont->rects + (recNum-1+recIdx)*3)+1 : 0; 65 | //Serial.println(String(char(c))+": "+chWd); 66 | spacing = (c==' ') ? rFont->wd/3 : 4; 67 | int idx = recIdx*3; 68 | for(int col = 0; col=maxy) yscr-=maxy; 72 | lcd.setScroll(yscr); 73 | ycnt=yscr+SCR_HT-1; 74 | if(ycnt>=maxy) ycnt-=maxy; 75 | //Serial.println(String("ycnt=")+ycnt); 76 | int scrHOffs = screenHt-1; 77 | int scrWOffs = screenWd-1; 78 | int lineY = scrHOffs-(screenHt-sx-ycnt); 79 | int wd; 80 | if(col>=chWd) { // draw empty column (spacing) 81 | wd = sy*rFont->ht; 82 | lcd.fillRect(scrWOffs-offsY-wd, lineY, wd, sx, bg); 83 | while(millis()-msrects+idx+0); 87 | int ybg = 0; 88 | while(xf==col) { // draw all lines for current column 89 | yf = pgm_read_byte(rFont->rects+idx+1); 90 | hf = pgm_read_byte(rFont->rects+idx+2); 91 | if(yf>0) { // bg line top 92 | wd = (yf-ybg)*sy; 93 | lcd.fillRect(scrWOffs-(offsY+ybg*sy)-wd, lineY, wd, sx, bg); 94 | } 95 | ybg = yf+hf; 96 | wd = hf*sy; 97 | lcd.fillRect(scrWOffs-(offsY+yf*sy)-wd, lineY, wd, sx, fg); 98 | idx+=3; 99 | xf = pgm_read_byte(rFont->rects+idx+0); 100 | } 101 | //Serial.println("ys = "+String(ys)+" "+String(charHt)); 102 | 103 | if(ybght-1) { // last bg line 104 | wd = (rFont->ht-ybg)*sy; 105 | lcd.fillRect(scrWOffs-(offsY+ybg*sy)-wd, lineY, wd, sx, bg); 106 | } 107 | while(millis()-msht*sy)/2; 135 | //scrollString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-!?.: "); 136 | scrollString("This is an example of super-smooth scrolling with ordinary Arduino, ILI9341 240x320 LCD library and large RRE font ... "); 137 | } 138 | 139 | -------------------------------------------------------------------------------- /examples/ILI9341_lib_AmigaBall/ILI9341_lib_AmigaBall.ino: -------------------------------------------------------------------------------- 1 | // ILI9341 library example 2 | // Amiga Boing Ball Demo 3 | // (c) 2019-20 Pawel A. Hernik 4 | // YT video: https://youtu.be/KwtkfmglT-c 5 | 6 | /* 7 | ILI9341 240x320 2.2" LCD pinout (header at the top, from left): 8 | #1 MISO -> NC 9 | #2 LED -> 3.3V 10 | #3 SCK -> SCL/D13/PA5 11 | #4 SDI -> MOSI/D11/PA7 12 | #5 DC -> D8/PA1 or any digital 13 | #6 RESET -> D9/PA0 or any digital 14 | #7 CS -> D10/PA2 or any digital 15 | #8 GND -> GND 16 | #9 VCC -> 3.3V 17 | */ 18 | 19 | #define SCR_WD 240 20 | #define SCR_HT 320 21 | #include 22 | #include 23 | 24 | #if (__STM32F1__) // bluepill 25 | #define TFT_CS PA2 26 | #define TFT_DC PA1 27 | #define TFT_RST PA0 28 | //#include 29 | #else 30 | #define TFT_CS 10 31 | #define TFT_DC 8 32 | #define TFT_RST 9 33 | #include 34 | #endif 35 | 36 | ILI9341 lcd = ILI9341(TFT_DC, TFT_RST, TFT_CS); 37 | 38 | #include "ball.h" 39 | 40 | uint16_t palette[16]; 41 | uint16_t line[SCR_WD]; 42 | uint16_t bgCol = RGBto565(160,160,160); 43 | uint16_t bgColS = RGBto565(90,90,90); 44 | uint16_t lineCol = RGBto565(150,40,150); 45 | uint16_t lineColS = RGBto565(80,10,80); 46 | 47 | #define LINE_YS 20 48 | #define LINE_XS1 30 49 | #define LINE_XS2 6 50 | 51 | #define BALL_WD 64 52 | #define BALL_HT 64 53 | #define BALL_SWD 240 54 | #define BALL_SHT 260 55 | 56 | #define SP 20 57 | 58 | #define SHADOW 20 59 | //#define SHADOW 0 60 | 61 | // AVR stats: 62 | // with shadow - 60-61ms/17fps 63 | // without shadow - 55-56ms/18fps 64 | 65 | void drawBall(int x, int y) 66 | { 67 | int i,j,ii; 68 | for(j=0;jLINE_YS) for(i=0;i<10;i++) line[LINE_XS1+i*SP]=lineCol; 79 | } 80 | for(i=BALL_WD-2;i>=0;i-=2) { 81 | v = pgm_read_byte(--img); 82 | if(v>>4) { 83 | line[x+i+0] = palette[v>>4]; 84 | #if SHADOW>0 85 | ii=x+i+0+SHADOW; 86 | if(ii0 92 | ii=x+i+1+SHADOW; 93 | if(ii=BALL_SWD-BALL_WD) { x=BALL_SWD-BALL_WD; xd=-xd; animd=-animd; } 144 | if(y<0) { y=0; yd=-yd; } 145 | if(y>=BALL_SHT-BALL_HT) { y=BALL_SHT-BALL_HT; yd=-yd; } 146 | //ms=millis()-ms; Serial.println(ms); 147 | } 148 | 149 | -------------------------------------------------------------------------------- /examples/ILI9341_lib_Numeric_display/ILI9341_lib_Numeric_display.ino: -------------------------------------------------------------------------------- 1 | // ILI9341 library example 2 | // Numeric display - RREFont vs PropFont 3 | // (c) 2020 Pawel A. Hernik 4 | // YouTube videos: 5 | // https://youtu.be/OOvzmHcou4E 6 | // https://youtu.be/-F7EWPt0yIo 7 | 8 | /* 9 | ILI9341 240x320 2.2" LCD pinout (header at the top, from left): 10 | #1 MISO -> NC 11 | #2 LED -> 3.3V 12 | #3 SCK -> SCL/D13/PA5 13 | #4 SDI -> MOSI/D11/PA7 14 | #5 DC -> D8/PA1 or any digital 15 | #6 RESET -> D9/PA0 or any digital 16 | #7 CS -> D10/PA2 or any digital 17 | #8 GND -> GND 18 | #9 VCC -> 3.3V 19 | */ 20 | 21 | #define SCR_WD 240 22 | #define SCR_HT 320 23 | #include 24 | #include 25 | 26 | #if (__STM32F1__) // bluepill 27 | #define TFT_CS PA2 28 | #define TFT_DC PA1 29 | #define TFT_RST PA0 30 | //#include 31 | #else 32 | #define TFT_CS 10 33 | #define TFT_DC 8 34 | #define TFT_RST 9 35 | #include 36 | #endif 37 | 38 | ILI9341 lcd = ILI9341(TFT_DC, TFT_RST, TFT_CS); 39 | 40 | // define what kind of fonts will be used 41 | #define USE_RRE_FONTS 1 42 | 43 | #if USE_RRE_FONTS==1 44 | 45 | #include "RREFont.h" 46 | #include "rre_term_10x16.h" 47 | #include "rre_bold13x20.h" 48 | #include "rre_bold13x20v.h" 49 | #include "rre_bold13x20no.h" 50 | 51 | RREFont font; 52 | // needed for RREFont library initialization, define your fillRect 53 | void customRect(int x, int y, int w, int h, int c) { return lcd.fillRect(x, y, w, h, c); } 54 | 55 | #else 56 | 57 | #include "PropFont.h" 58 | #include "bold13x20digtop_font.h" 59 | #include "term9x14_font.h" 60 | 61 | PropFont font; 62 | // needed for PropFont library initialization, define your drawPixel and fillRect 63 | void customPixel(int x, int y, int c) { lcd.drawPixel(x, y, c); } 64 | void customRect(int x, int y, int w, int h, int c) { lcd.fillRect(x, y, w, h, c); } 65 | #endif 66 | 67 | //----------------------------------------------------------------------------- 68 | 69 | unsigned long ms = 0; 70 | 71 | void setup() 72 | { 73 | Serial.begin(9600); 74 | lcd.init(); 75 | #if USE_RRE_FONTS==1 76 | font.init(customRect, SCR_WD, SCR_HT); // custom fillRect function and screen width and height values 77 | #else 78 | font.init(customPixel, customRect, SCR_WD, SCR_HT); // custom drawPixel and fillRect function and screen width and height values 79 | #endif 80 | } 81 | 82 | const uint16_t lnCol = RGBto565(255,80,255); 83 | const uint16_t ln2Col = RGBto565(180,180,180); 84 | const uint16_t labCol = RGBto565(250,250,250); 85 | const uint16_t v1Col = RGBto565(50,250,50); 86 | const uint16_t v2Col = RGBto565(255,250,50); 87 | const uint16_t v3Col = RGBto565(120,255,255); 88 | const uint16_t v4Col = RGBto565(255,70,70); 89 | const uint16_t v5Col = RGBto565(70,70,255); 90 | int mode=0,lastMode=-1; 91 | 92 | void setBigNumFont() 93 | { 94 | #if USE_RRE_FONTS==1 95 | font.setFont(&rre_Bold13x20v); 96 | //font.setFont(&rre_Bold13x20); // regular RRE rendered with rectangles 97 | //font.setFont(&rre_Bold13x20no); // like above but no overlapping 98 | #else 99 | font.setFont(Bold13x20); 100 | #endif 101 | font.setSpacing(1); 102 | font.setScale(1,2); 103 | font.setDigitMinWd(16); 104 | } 105 | 106 | void setInfoFont() 107 | { 108 | #if USE_RRE_FONTS==1 109 | font.setFont(&rre_term_10x16); 110 | #else 111 | font.setFont(Term9x14); 112 | #endif 113 | } 114 | 115 | void drawField(int x, int y, int w, int h, char *label, uint16_t col=lnCol) 116 | { 117 | lcd.drawRect(x,y+7,w,h-7,col); 118 | setInfoFont(); 119 | font.setScale(1); 120 | font.setColor(labCol,BLACK); 121 | int wl = font.strWidth(label); 122 | font.printStr(x+(w-wl)/2,y,label); 123 | } 124 | 125 | void showVal(float v, int x, int y, int w, int p, uint16_t col) 126 | { 127 | setBigNumFont(); 128 | font.setColor(col,BLACK); 129 | char txt[10]; 130 | dtostrf(v,w,p,txt); 131 | font.printStr(x,y,txt); 132 | } 133 | 134 | void constData() 135 | { 136 | drawField( 0, 0,120-5,80-2," Temp "); 137 | drawField(120+5, 0,120-5,80-2," Time "); 138 | drawField( 0, 81,120-5,80-2," Pressure "); 139 | drawField(120+5, 81,120-5,80-2," Altitude "); 140 | drawField( 0,162,240,80-2," Big Number ",ln2Col); 141 | setBigNumFont(); 142 | int wv=font.strWidth("88.8"); 143 | font.setColor(v1Col); font.printStr(18+wv,0+24,"'$"); 144 | wv=font.strWidth("999999999.99"); 145 | font.setColor(v5Col); font.printStr(22+wv,162+25,"'"); 146 | wv=font.strWidth("888.8"); 147 | int wv2=font.strWidth("888"); 148 | setInfoFont(); 149 | font.setScale(1,2); 150 | font.setColor(v4Col); font.printStr(21+120+wv+2,82+22+14,"m"); 151 | font.setColor(v2Col); font.printStr(32+120+wv2+3,24+12,"ms"); 152 | } 153 | 154 | float v1,v3,v4,v5; 155 | int tm = 0; 156 | 157 | void varData() 158 | { 159 | //v1=88.8; v3=8888.8; v4=888.8; v5=8888888.88; 160 | // PropFont optimizing: noopt=350ms, ff=317ms, 0+ff=298ms, +f0=290ms +0f=277ms 161 | showVal(v1, 18,0+24, 4,1, v1Col); 162 | showVal(tm, 32+120,0+24, 3,0, v2Col); 163 | showVal(v3, 14,82+24, 6,1, v3Col); 164 | showVal(v4, 21+120,82+24, 5,1, v4Col); 165 | showVal(v5, 22,162+25, 12,2, v5Col); 166 | v1+=1.1; if(v1>99.0) v1=0; 167 | v3+=10.1; if(v3>9999.0) v3=0; 168 | v4+=3.3; if(v4>999.0) v4=0; 169 | v5+=941340.32; if(v5>=999999999.99) v5=0; 170 | } 171 | 172 | void loop() 173 | { 174 | if(mode!=lastMode) { 175 | lastMode=mode; 176 | lcd.fillScreen(BLACK); 177 | constData(); 178 | } 179 | ms = millis(); 180 | varData(); 181 | tm = millis()-ms; 182 | Serial.println(tm); 183 | } 184 | 185 | -------------------------------------------------------------------------------- /examples/ILI9341_lib_Bitmap/bitmap.h: -------------------------------------------------------------------------------- 1 | // Generated by bmp2src by Pawel A. Hernik 2 | // Generated from: mario24b.bmp 3 | // Dimensions : 32x32x16 (65536 colors) 4 | // Size : 2048 [0x0800] bytes 5 | 6 | const uint16_t mario[] PROGMEM = { 7 | 0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0x8430,0x4208,0x18a2, 8 | 0x1861,0x18e3,0x6b4d,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514, 9 | 0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0x9cf3,0x528a,0x2080,0xa1e1,0xf2c1, 10 | 0xd261,0xb221,0x38a0,0x6b4d,0xa514,0x9cf3,0x738e,0x7bcf,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514, 11 | 0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0x9cf3,0x39e7,0x5100,0xf2c1,0xfae2,0xa349, 12 | 0xe69a,0xdd33,0x92a7,0x18a2,0x8c71,0x2965,0x39e7,0x3186,0x3186,0x632c,0x9cf3,0xa514,0xa514,0xa514,0xa514,0xa514, 13 | 0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0x52aa,0x40c0,0xf2c2,0xfac2,0xd241,0xde9a, 14 | 0xf246,0xf225,0xc513,0x3060,0x1082,0x6b6d,0x8430,0x8430,0xbdd7,0x4a49,0x39e7,0xa514,0xa514,0xa514,0xa514,0xa514, 15 | 0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0x8c51,0x1840,0xe281,0xfaa2,0xfa82,0xda21,0xd618, 16 | 0xec0e,0xac2f,0x8a06,0x80e1,0x88e1,0x80c1,0x60c2,0x3985,0xffdf,0xffdf,0x2124,0x8c71,0xa514,0xa514,0xa514,0xa514, 17 | 0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0x39c7,0x8941,0xfa41,0xfa41,0xf221,0xe1e1,0x69a5, 18 | 0x9163,0xd981,0xf181,0xe161,0x88c1,0x4860,0x2020,0x0800,0xad55,0xdefb,0x4a49,0x7bef,0xa514,0xa514,0xa514,0xa514, 19 | 0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0x94b2,0x1040,0xe9e1,0xf1e1,0xf1e1,0xb141,0x78a1,0xd921, 20 | 0xe941,0xd941,0x8983,0x62a7,0x0000,0x0000,0x4228,0xd6ba,0xc638,0xef5d,0x10a2,0x9492,0xa514,0xa514,0xa514,0xa514, 21 | 0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0x6b6d,0x68a0,0xf1a1,0xf1a1,0x9901,0xa0a1,0xd901,0xd901, 22 | 0x9963,0xa42b,0xfeb1,0x5a86,0x39a4,0xe71c,0xffff,0xf7be,0xffdf,0x632c,0x4208,0xa514,0xa514,0xa514,0xa514,0xa514, 23 | 0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0x52aa,0x1061,0xb101,0xf161,0xa901,0x7081,0xa0c1,0x91c4,0xac2a, 24 | 0x5a66,0xfed1,0xfed2,0x2943,0x3163,0x5aa8,0x5aeb,0xad75,0x94b2,0x1082,0x9cd3,0xa514,0xa514,0xa514,0xa514,0xa514, 25 | 0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0x6b6d,0x4860,0xc901,0xe941,0xe141,0x40a0,0x7307,0xddef,0xfed2,0xfed2, 26 | 0x1081,0xcd8e,0xf691,0xbd0d,0xfed1,0xfe90,0xedee,0x39a5,0x18c3,0x4a69,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514, 27 | 0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0x4208,0xa8a1,0xd0e1,0xb0e1,0x6880,0x6101,0x4962,0xddef,0xfed2,0xfed2, 28 | 0x8ba9,0xddcf,0xfeb1,0xfed2,0xfed2,0xfeb1,0xfe4f,0x8368,0x52aa,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514, 29 | 0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0x4a69,0x7080,0x6225,0xcd4d,0xc52d,0x4942,0x48c0,0x30a1,0xf670,0x8369, 30 | 0xd58e,0xfed2,0xfed2,0xfed2,0xfeb1,0xfe90,0xfe4f,0x7b28,0x738e,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514, 31 | 0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0x9492,0x1082,0xf62f,0xedce,0xa46b,0xbd0d,0x38e1,0x6266,0xfe90,0x28a1, 32 | 0x1840,0x3963,0x6286,0xd58e,0xfe90,0xfe4f,0xac6b,0x18c2,0x94b2,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514, 33 | 0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0x3165,0xfe4f,0xfe4f,0xac8b,0xddcf,0xee30,0xf691,0xfe91,0x7285, 34 | 0x2040,0x3880,0x4080,0x2860,0x30e1,0x1881,0x0000,0x7bcf,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514, 35 | 0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0x528a,0x9c0a,0xf62f,0xc52d,0xfeb1,0xfed2,0xfed2,0xfed2,0xfe70, 36 | 0x51e4,0x2860,0x2860,0x3880,0x2860,0x1020,0x3186,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514, 37 | 0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0x9cf3,0x31a6,0x41c4,0x7328,0x6aa6,0x7b28,0xfed2,0xfed2,0xfed1, 38 | 0x82a6,0x5060,0x3061,0x49c4,0x5080,0x1061,0x8c71,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514, 39 | 0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0x9cf3,0x4228,0x0000,0x2020,0x1820,0x4a05,0xe5ef,0xfe4f, 40 | 0x9b68,0x78c1,0x93e9,0x79c4,0x3040,0x6b6d,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514, 41 | 0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0x9cf3,0x7bef,0x20e3,0x7881,0xd0e1,0xe921,0xf141,0x5880,0x40a2,0x5aca, 42 | 0x7b28,0x7245,0x28c4,0x0841,0x4a69,0xa514,0x8430,0x39e7,0x31a6,0x5aeb,0x9cf3,0xa514,0xa514,0xa514,0xa514,0xa514, 43 | 0xa514,0xa514,0xa514,0xa514,0xa514,0x9492,0x2104,0x4228,0x59c6,0x8881,0xe101,0xb0e1,0x7080,0xc101,0xa8e1,0x0a33, 44 | 0x09d0,0xa102,0x88c1,0x014b,0x0862,0x4208,0x1061,0x5961,0x6181,0x28a0,0x3186,0x9492,0xa514,0xa514,0xa514,0xa514, 45 | 0xa514,0xa514,0xa514,0xa514,0x9cf3,0x4208,0x630c,0xe73c,0xffff,0xd6ba,0x5124,0x5060,0xd0c1,0xe101,0xa8e1,0x0a12, 46 | 0x1a2f,0x3a4a,0x09f1,0x0a55,0x4aca,0x2920,0x4100,0x8201,0x8a02,0x8202,0x10a2,0x2945,0xa514,0xa514,0xa514,0xa514, 47 | 0xa514,0xa514,0xa514,0xa514,0x52aa,0x8430,0xe73c,0xffff,0xffff,0xf7be,0x5acb,0xa8c1,0xd0a1,0xe101,0x60e4,0x09af, 48 | 0xd62a,0xfec5,0x42a9,0x0a55,0x324a,0x8382,0x5121,0x81c1,0x81e1,0x79c1,0x73ae,0x1082,0xa514,0xa514,0xa514,0xa514, 49 | 0xa514,0xa514,0xa514,0xa514,0x2124,0xdedb,0x7bcf,0xa534,0xffff,0xffdf,0xa534,0x30a5,0x68a3,0x48c5,0x09f1,0x09af, 50 | 0xcd84,0xf644,0x3a69,0x0a55,0x09f1,0x2962,0x5120,0x79c1,0x81c1,0x5961,0x7bcf,0x31a6,0xa514,0xa514,0xa514,0xa514, 51 | 0xa514,0xa514,0xa514,0xa514,0x2945,0xef7d,0xef5d,0x73ae,0xffff,0xef5d,0xd69a,0x012b,0x0a34,0x0a55,0x0a55,0x0a55, 52 | 0x11cc,0x2a09,0x0a33,0x0a55,0x0a55,0x0041,0x6961,0x7181,0x79c1,0x7b4b,0x18e3,0x738e,0xa514,0xa514,0xa514,0xa514, 53 | 0xa514,0xa514,0xa514,0xa514,0x39e7,0xc618,0xffdf,0xf7be,0xe71c,0x528a,0x630c,0x00c9,0x01f3,0x0a34,0x0a54,0x0a55, 54 | 0x0a55,0x0a55,0x0a55,0x0a55,0x09ae,0x1840,0x6140,0x6940,0x5121,0x5acb,0x3186,0xa514,0xa514,0xa514,0xa514,0xa514, 55 | 0xa514,0xa514,0xa514,0xa514,0x8c71,0x2104,0x94b2,0xdefb,0xd69a,0x4a49,0x4900,0x48e0,0x0085,0x0190,0x01f3,0x01f3, 56 | 0x0214,0x0214,0x0214,0x0a12,0x0042,0x2060,0x6141,0x6140,0x730b,0x10a2,0x8c51,0xa514,0xa514,0xa514,0xa514,0xa514, 57 | 0xa514,0xa514,0xa514,0xa514,0xa514,0x94b2,0x528a,0x0861,0x3144,0x5120,0x6140,0x40c0,0x5100,0x012b,0x01f3,0x01f3, 58 | 0x01f3,0x01f2,0x014c,0x0062,0x630c,0x4a49,0x0020,0x0020,0x10a2,0x2965,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514, 59 | 0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0x8c71,0x39c7,0x6a46,0x79a1,0x7181,0x5100,0x4900,0x0841,0x0042,0x0063, 60 | 0x0042,0x10a2,0x4228,0x8c71,0xa514,0xa514,0x9cf3,0x9cf3,0x7bef,0x9cd3,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514, 61 | 0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0x5aeb,0x8430,0x5941,0x79a1,0x79a1,0x6981,0x4900,0x4228,0x9cf3,0x94b2, 62 | 0x9cd3,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514, 63 | 0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0x4a49,0x94b2,0x6981,0x81c1,0x81c1,0x79a1,0x1860,0x6b6d,0xa514,0xa514, 64 | 0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514, 65 | 0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0x4a49,0x8410,0x71c1,0x8a02,0x8201,0x71a1,0x2124,0xa514,0xa514,0xa514, 66 | 0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514, 67 | 0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0x8410,0x18e3,0x4101,0x8a22,0x8a22,0x30c0,0x4a69,0xa514,0xa514,0xa514, 68 | 0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514, 69 | 0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0x94b2,0x4208,0x1061,0x1082,0x4a49,0x9cf3,0xa514,0xa514,0xa514, 70 | 0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514,0xa514, 71 | }; 72 | 73 | -------------------------------------------------------------------------------- /examples/ILI9341_lib_AmigaBall/ball.h: -------------------------------------------------------------------------------- 1 | // Generated by bmp2src by Pawel A. Hernik 2 | // Generated from: ball.bmp 3 | // Dimensions : 64x64x4 (16 colors) 4 | // Size : 2048 [0x0800] bytes 5 | 6 | 7 | const unsigned char ball[2048+16*2+6] PROGMEM = { 8 | 64,0,64,0,4,0, // width,height,bits 9 | 0x10,0x84, // c000->130,130,130 10 | 0x00,0xf8, // c001->255, 0, 0 11 | 0x00,0xf8, // c002->255, 0, 0 12 | 0x00,0xf8, // c003->255, 0, 0 13 | 0x00,0xf8, // c004->255, 0, 0 14 | 0x00,0xf8, // c005->255, 0, 0 15 | 0x00,0xf8, // c006->255, 0, 0 16 | 0x00,0xf8, // c007->255, 0, 0 17 | 0xff,0xff, // c008->255,255,255 18 | 0xff,0xff, // c009->255,255,255 19 | 0xff,0xff, // c010->255,255,255 20 | 0xff,0xff, // c011->255,255,255 21 | 0xff,0xff, // c012->255,255,255 22 | 0xff,0xff, // c013->255,255,255 23 | 0xff,0xff, // c014->255,255,255 24 | 0xff,0xff, // c015->255,255,255 25 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 26 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 27 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 28 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 29 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x32,0x1e,0xed,0xdc, 30 | 0xcc,0xbb,0xbc,0x57,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 31 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x87,0x76,0xcc,0xbb,0xaa, 32 | 0x99,0x88,0x87,0x7e,0xe1,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 33 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x87,0x65,0x54,0x43,0xa9,0x88, 34 | 0x87,0x76,0x65,0x55,0x4b,0xaa,0xa2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 35 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x87,0x65,0x54,0x43,0x32,0x11,0x77, 36 | 0x66,0x55,0x54,0x43,0x21,0x87,0x65,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 37 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x87,0x66,0x54,0x43,0x32,0x11,0xee,0xd6, 38 | 0x55,0x54,0x43,0x32,0x1e,0xed,0x55,0x42,0xb0,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 39 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x98,0x76,0x55,0x43,0x32,0x11,0x1e,0xed,0xdc, 40 | 0xc4,0x43,0x32,0x11,0xee,0xdc,0xcc,0x32,0xda,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 41 | 0x00,0x00,0x00,0x00,0x00,0x00,0x42,0xed,0x65,0x44,0x33,0x21,0x1e,0xed,0xdc,0xcc, 42 | 0xbb,0xa3,0x21,0x1e,0xed,0xcc,0xcb,0xa2,0xec,0x93,0x00,0x00,0x00,0x00,0x00,0x00, 43 | 0x00,0x00,0x00,0x00,0x00,0x03,0x1e,0xdd,0xc4,0x43,0x22,0x11,0xee,0xdd,0xcc,0xbb, 44 | 0xaa,0xa9,0x11,0xee,0xdd,0xcc,0xba,0x98,0x75,0x48,0x30,0x00,0x00,0x00,0x00,0x00, 45 | 0x00,0x00,0x00,0x00,0x00,0x31,0xed,0xcc,0xbb,0xa2,0x21,0x1e,0xed,0xdc,0xcb,0xba, 46 | 0xaa,0x98,0x87,0x7d,0xdc,0xcc,0xba,0x98,0x76,0x43,0xe2,0x00,0x00,0x00,0x00,0x00, 47 | 0x00,0x00,0x00,0x00,0x04,0x1e,0xdc,0xcb,0xaa,0x98,0x1e,0xee,0xdd,0xcc,0xbb,0xaa, 48 | 0xa9,0x88,0x77,0x66,0xcc,0xcb,0xaa,0x98,0x76,0x53,0x1d,0x80,0x00,0x00,0x00,0x00, 49 | 0x00,0x00,0x00,0x00,0x42,0xed,0xcc,0xba,0xa9,0x88,0x77,0xed,0xdc,0xcb,0xba,0xaa, 50 | 0x98,0x87,0x76,0x66,0x5c,0xbb,0xa9,0x98,0x76,0x54,0x2e,0xb6,0x00,0x00,0x00,0x00, 51 | 0x00,0x00,0x00,0x00,0x21,0xdd,0xcb,0xba,0x99,0x88,0x77,0x66,0xcc,0xbb,0xaa,0xa9, 52 | 0x88,0x87,0x76,0x65,0x55,0x4a,0xa9,0x98,0x76,0x54,0x31,0xda,0x00,0x00,0x00,0x00, 53 | 0x00,0x00,0x00,0x03,0x1e,0xdc,0xbb,0xa9,0x98,0x87,0x76,0x65,0x54,0xbb,0xaa,0x98, 54 | 0x88,0x77,0x66,0x55,0x54,0x43,0x32,0x88,0x76,0x54,0x32,0xec,0x90,0x00,0x00,0x00, 55 | 0x00,0x00,0x00,0x31,0xed,0xcb,0xba,0xa9,0x88,0x77,0x66,0x55,0x44,0x4a,0xa9,0x98, 56 | 0x87,0x76,0x66,0x55,0x54,0x33,0x22,0x17,0x66,0x54,0x32,0x1d,0xa7,0x00,0x00,0x00, 57 | 0x00,0x00,0x00,0x2e,0xdc,0xcb,0xaa,0x98,0x87,0x76,0x65,0x55,0x44,0x33,0x29,0x88, 58 | 0x77,0x76,0x65,0x55,0x44,0x33,0x21,0x1e,0xd6,0x54,0x32,0x1d,0xb9,0x00,0x00,0x00, 59 | 0x00,0x00,0x0a,0x87,0xdc,0xbb,0xa9,0x88,0x77,0x66,0x65,0x54,0x43,0x33,0x21,0x18, 60 | 0x77,0x66,0x55,0x54,0x43,0x32,0x21,0x1e,0xdc,0xc4,0x32,0x1d,0xca,0x70,0x00,0x00, 61 | 0x00,0x00,0xc9,0x76,0x54,0xba,0xa9,0x88,0x77,0x66,0x55,0x44,0x33,0x32,0x11,0x1e, 62 | 0x76,0x66,0x55,0x54,0x43,0x32,0x21,0x1e,0xdc,0xcb,0xa2,0x1e,0xcb,0x94,0x00,0x00, 63 | 0x00,0x00,0xa8,0x76,0x54,0x3a,0x98,0x87,0x76,0x65,0x54,0x44,0x33,0x22,0x11,0xee, 64 | 0xed,0xd5,0x55,0x44,0x33,0x22,0x11,0xed,0xdc,0xcb,0xa9,0x87,0xdb,0xa6,0x00,0x00, 65 | 0x00,0x00,0x97,0x65,0x44,0x32,0x98,0x77,0x66,0x55,0x54,0x43,0x32,0x21,0x11,0xee, 66 | 0xdd,0xcc,0x55,0x44,0x33,0x22,0x11,0xed,0xdc,0xbb,0xa9,0x87,0x6c,0xa8,0x00,0x00, 67 | 0x00,0x0a,0x87,0x65,0x43,0x32,0x11,0xe7,0x66,0x55,0x44,0x33,0x32,0x11,0x1e,0xed, 68 | 0xdd,0xcc,0xcb,0x43,0x32,0x22,0x11,0xed,0xdc,0xbb,0xa9,0x87,0x65,0x42,0x50,0x00, 69 | 0x00,0x0a,0x86,0x55,0x43,0x21,0x1e,0xed,0x65,0x55,0x44,0x33,0x22,0x11,0xee,0xed, 70 | 0xdc,0xcc,0xbb,0xba,0x32,0x21,0x1e,0xdd,0xcc,0xbb,0xa9,0x87,0x65,0x42,0xe0,0x00, 71 | 0x00,0x09,0x76,0x54,0x33,0x21,0x1e,0xed,0xdc,0x54,0x43,0x33,0x21,0x11,0xee,0xdd, 72 | 0xdc,0xcc,0xbb,0xaa,0x99,0x21,0x1e,0xdd,0xcc,0xba,0xa9,0x87,0x65,0x43,0x10,0x00, 73 | 0x00,0xb8,0x76,0x54,0x32,0x21,0xee,0xdd,0xcc,0xb4,0x43,0x32,0x21,0x1e,0xee,0xdd, 74 | 0xcc,0xcb,0xbb,0xaa,0x99,0x88,0xee,0xdd,0xcc,0xba,0xa9,0x87,0x65,0x43,0x1c,0x00, 75 | 0x00,0xa8,0x65,0x44,0x32,0x11,0xee,0xdd,0xcc,0xbb,0xa3,0x22,0x11,0x1e,0xed,0xdd, 76 | 0xcc,0xcb,0xba,0xa9,0x99,0x88,0x7d,0xdc,0xcb,0xba,0xa9,0x87,0x65,0x43,0x1d,0x00, 77 | 0x00,0x97,0x65,0x43,0x32,0x1e,0xed,0xdc,0xcb,0xbb,0xaa,0x98,0x11,0xee,0xdd,0xdc, 78 | 0xcc,0xbb,0xaa,0xa9,0x98,0x88,0x76,0x65,0xcb,0xba,0x99,0x87,0x65,0x43,0x2d,0x00, 79 | 0x00,0x97,0x65,0x43,0x21,0x1e,0xed,0xdc,0xcb,0xba,0xa9,0x98,0x87,0xee,0xdd,0xcc, 80 | 0xcc,0xbb,0xaa,0x99,0x98,0x87,0x76,0x65,0x5b,0xba,0x99,0x87,0x65,0x43,0x2d,0x00, 81 | 0x00,0x17,0x65,0x43,0x21,0x1e,0xdd,0xcc,0xbb,0xba,0xa9,0x88,0x87,0x76,0xdd,0xcc, 82 | 0xcb,0xba,0xaa,0x99,0x88,0x87,0x66,0x55,0x44,0x3a,0x99,0x87,0x65,0x43,0x2e,0x00, 83 | 0x00,0x1e,0x54,0x43,0x21,0xee,0xdd,0xcc,0xbb,0xaa,0x99,0x88,0x77,0x76,0xdc,0xcc, 84 | 0xcb,0xba,0xa9,0x99,0x88,0x77,0x66,0x55,0x44,0x33,0x28,0x87,0x65,0x43,0x2e,0x00, 85 | 0x00,0x1d,0xcb,0x33,0x21,0xee,0xdd,0xcc,0xbb,0xaa,0x98,0x88,0x77,0x66,0x65,0x5c, 86 | 0xbb,0xaa,0xa9,0x98,0x88,0x76,0x66,0x55,0x44,0x32,0x21,0x17,0x65,0x43,0x2e,0x00, 87 | 0x00,0x1d,0xcb,0xa9,0x11,0xed,0xdc,0xcb,0xba,0xa9,0x98,0x87,0x77,0x66,0x55,0x54, 88 | 0xbb,0xaa,0x99,0x98,0x87,0x76,0x65,0x54,0x43,0x32,0x21,0xed,0xd5,0x43,0x2e,0x00, 89 | 0x00,0x1d,0xcb,0xa9,0x81,0xed,0xdc,0xcb,0xba,0xa9,0x88,0x87,0x76,0x66,0x55,0x54, 90 | 0x43,0xaa,0x99,0x88,0x87,0x66,0x65,0x54,0x43,0x32,0x21,0xed,0xdc,0xb3,0x2e,0x00, 91 | 0x00,0x1d,0xcb,0xa9,0x87,0x76,0xdc,0xbb,0xaa,0xa9,0x88,0x77,0x76,0x65,0x55,0x44, 92 | 0x43,0x32,0x99,0x88,0x77,0x66,0x55,0x44,0x33,0x22,0x11,0xed,0xcc,0xba,0x9e,0x00, 93 | 0x00,0x1d,0xcb,0xa9,0x87,0x76,0x55,0xbb,0xaa,0x99,0x88,0x77,0x66,0x65,0x55,0x44, 94 | 0x33,0x32,0x21,0x88,0x76,0x66,0x55,0x44,0x33,0x22,0x11,0xed,0xcb,0xba,0x86,0x00, 95 | 0x00,0x1d,0xcb,0xa9,0x87,0x66,0x55,0x4b,0xaa,0x98,0x87,0x77,0x66,0x55,0x54,0x44, 96 | 0x33,0x22,0x21,0x1e,0x76,0x65,0x54,0x44,0x33,0x22,0x1e,0xdd,0xcb,0xa9,0x86,0x00, 97 | 0x00,0x1d,0xcb,0xa9,0x87,0x66,0x54,0x43,0x39,0x98,0x87,0x76,0x66,0x55,0x54,0x43, 98 | 0x33,0x22,0x11,0x1e,0xdd,0x65,0x54,0x43,0x32,0x21,0x1e,0xdd,0xcb,0xa9,0x86,0x00, 99 | 0x00,0x2d,0xcb,0xa8,0x87,0x66,0x54,0x43,0x32,0x18,0x77,0x76,0x65,0x55,0x44,0x33, 100 | 0x32,0x22,0x11,0xee,0xdd,0xcc,0x44,0x43,0x32,0x21,0x1e,0xdc,0xcb,0xa9,0x86,0x00, 101 | 0x00,0x2e,0xcb,0xa8,0x87,0x65,0x54,0x43,0x32,0x11,0x77,0x66,0x65,0x55,0x44,0x33, 102 | 0x22,0x21,0x11,0xed,0xdd,0xcc,0xb4,0x33,0x22,0x11,0xed,0xdc,0xbb,0xa9,0x75,0x00, 103 | 0x00,0x3e,0xcb,0xa8,0x87,0x65,0x54,0x33,0x22,0x11,0xee,0x66,0x55,0x54,0x43,0x33, 104 | 0x22,0x11,0x1e,0xed,0xdc,0xcb,0xbb,0xa3,0x22,0x11,0xed,0xcc,0xba,0x98,0x74,0x00, 105 | 0x00,0x0e,0xcb,0xa8,0x87,0x65,0x54,0x33,0x21,0x1e,0xed,0xdd,0xc5,0x54,0x43,0x32, 106 | 0x22,0x11,0xee,0xdd,0xcc,0xcb,0xba,0xa9,0x91,0x1e,0xdd,0xcc,0xba,0x98,0x60,0x00, 107 | 0x00,0x08,0x6b,0xa9,0x87,0x65,0x44,0x33,0x21,0x1e,0xed,0xdc,0xcc,0x44,0x33,0x32, 108 | 0x21,0x11,0xed,0xdd,0xcc,0xbb,0xba,0xa9,0x98,0x8e,0xdd,0xcb,0xaa,0x98,0x60,0x00, 109 | 0x00,0x0a,0x64,0x39,0x87,0x65,0x44,0x32,0x21,0xee,0xdd,0xdc,0xcc,0xbb,0x33,0x22, 110 | 0x21,0x1e,0xed,0xdc,0xcc,0xbb,0xaa,0x99,0x88,0x76,0x6c,0xcb,0xa9,0x87,0x50,0x00, 111 | 0x00,0x00,0x75,0x32,0x87,0x65,0x44,0x32,0x11,0xee,0xdd,0xcc,0xcb,0xba,0xa2,0x22, 112 | 0x11,0xee,0xdd,0xcc,0xcb,0xba,0xaa,0x99,0x88,0x76,0x65,0x4b,0xa9,0x86,0x00,0x00, 113 | 0x00,0x00,0x85,0x42,0x1e,0x65,0x43,0x32,0x11,0xee,0xdd,0xcc,0xcb,0xba,0xa9,0x91, 114 | 0x11,0xed,0xdd,0xcc,0xbb,0xba,0xa9,0x98,0x87,0x66,0x55,0x43,0x98,0x75,0x00,0x00, 115 | 0x00,0x00,0xc6,0x43,0x1e,0xdc,0xb3,0x32,0x1e,0xed,0xdc,0xcc,0xbb,0xaa,0x99,0x98, 116 | 0x8e,0xed,0xdc,0xcc,0xbb,0xaa,0x99,0x88,0x77,0x65,0x54,0x33,0x21,0x63,0x00,0x00, 117 | 0x00,0x00,0x08,0x53,0x1e,0xdc,0xba,0x32,0x1e,0xed,0xdc,0xcc,0xba,0xaa,0x99,0x88, 118 | 0x77,0x66,0xcc,0xcb,0xba,0xa9,0x99,0x88,0x76,0x65,0x44,0x32,0x1e,0xc0,0x00,0x00, 119 | 0x00,0x00,0x00,0x64,0x2e,0xdc,0xba,0x98,0x1e,0xdd,0xcc,0xcb,0xba,0xa9,0x98,0x88, 120 | 0x76,0x66,0x5c,0xbb,0xaa,0xa9,0x98,0x87,0x66,0x55,0x43,0x32,0x1d,0x00,0x00,0x00, 121 | 0x00,0x00,0x00,0x85,0x21,0xdc,0xba,0x98,0x87,0xdd,0xcc,0xcb,0xaa,0x99,0x98,0x87, 122 | 0x76,0x65,0x54,0x4b,0xaa,0x99,0x88,0x77,0x65,0x54,0x43,0x21,0xec,0x00,0x00,0x00, 123 | 0x00,0x00,0x00,0x06,0x31,0xdc,0xba,0x98,0x77,0x65,0xcc,0xbb,0xaa,0x99,0x88,0x77, 124 | 0x66,0x55,0x44,0x43,0x39,0x98,0x87,0x76,0x65,0x44,0x32,0x1e,0xc0,0x00,0x00,0x00, 125 | 0x00,0x00,0x00,0x00,0x52,0xec,0xba,0x98,0x77,0x65,0x55,0xba,0xa9,0x98,0x87,0x76, 126 | 0x65,0x55,0x44,0x33,0x22,0x88,0x77,0x66,0x54,0x43,0x21,0x1d,0x00,0x00,0x00,0x00, 127 | 0x00,0x00,0x00,0x00,0x14,0x1d,0xba,0x98,0x76,0x65,0x54,0x43,0x99,0x98,0x87,0x66, 128 | 0x55,0x54,0x43,0x32,0x21,0x11,0x76,0x65,0x54,0x33,0x21,0xdb,0x00,0x00,0x00,0x00, 129 | 0x00,0x00,0x00,0x00,0x0e,0x9e,0xca,0x98,0x76,0x55,0x54,0x33,0x29,0x88,0x76,0x65, 130 | 0x55,0x44,0x33,0x22,0x11,0x1e,0xdd,0x55,0x43,0x32,0x1d,0xc0,0x00,0x00,0x00,0x00, 131 | 0x00,0x00,0x00,0x00,0x00,0xd8,0xcb,0x98,0x76,0x55,0x43,0x32,0x21,0x17,0x66,0x55, 132 | 0x54,0x43,0x32,0x21,0x1e,0xed,0xdc,0xcb,0x33,0x21,0xdc,0x00,0x00,0x00,0x00,0x00, 133 | 0x00,0x00,0x00,0x00,0x00,0x0c,0x74,0xa8,0x75,0x55,0x43,0x22,0x11,0xed,0xd5,0x55, 134 | 0x44,0x33,0x22,0x11,0xee,0xdd,0xcb,0xba,0x99,0x1d,0xc0,0x00,0x00,0x00,0x00,0x00, 135 | 0x00,0x00,0x00,0x00,0x00,0x00,0xd6,0x31,0xdc,0x54,0x33,0x21,0x1e,0xdd,0xcc,0xb4, 136 | 0x33,0x32,0x21,0x1e,0xdd,0xcc,0xbb,0xa9,0x98,0x64,0x00,0x00,0x00,0x00,0x00,0x00, 137 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x51,0xdc,0xc4,0x32,0x11,0xed,0xdc,0xcb,0xba, 138 | 0x32,0x21,0x11,0xed,0xdc,0xcb,0xaa,0x98,0x76,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 139 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xdc,0xba,0x21,0x1e,0xdc,0xcb,0xba,0xaa, 140 | 0x99,0x11,0xed,0xdc,0xcb,0xba,0x99,0x86,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 141 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xa9,0x87,0xdd,0xcb,0xba,0xaa,0x99, 142 | 0x88,0x76,0xdc,0xcb,0xba,0xa9,0x87,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 143 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc5,0x55,0x44,0xaa,0xa9,0x98,0x87, 144 | 0x76,0x65,0x54,0xba,0x99,0x87,0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 145 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xe1,0x18,0x87,0x76,0x66, 146 | 0x55,0x44,0x33,0x21,0x86,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 147 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x8a,0xa4,0x44,0x33, 148 | 0x32,0x22,0x1e,0xdc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 149 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a, 150 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 151 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 152 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 153 | }; 154 | -------------------------------------------------------------------------------- /examples/ILI9341_lib_Gauges/ILI9341_lib_Gauges.ino: -------------------------------------------------------------------------------- 1 | // ILI9341 library example 2 | // (c) 2019-20 Pawel A. Hernik 3 | // Color gauges and progress bars 4 | // YouTube videos: 5 | // https://youtu.be/rdL3qHEnd4Q 6 | // https://youtu.be/x94y-qH2RBs 7 | 8 | /* 9 | ILI9341 240x320 2.2" LCD pinout (header at the top, from left): 10 | #1 MISO -> NC 11 | #2 LED -> 3.3V 12 | #3 SCK -> SCL/D13/PA5 13 | #4 SDI -> MOSI/D11/PA7 14 | #5 DC -> D8/PA1 or any digital 15 | #6 RESET -> D9/PA0 or any digital 16 | #7 CS -> D10/PA2 or any digital 17 | #8 GND -> GND 18 | #9 VCC -> 3.3V 19 | */ 20 | 21 | #define SCR_WD 240 22 | #define SCR_HT 320 23 | #include 24 | #include 25 | 26 | #if (__STM32F1__) // bluepill 27 | #define TFT_CS PA2 28 | #define TFT_DC PA1 29 | #define TFT_RST PA0 30 | //#include 31 | #else 32 | #define TFT_CS 10 33 | #define TFT_DC 8 34 | #define TFT_RST 9 35 | #include 36 | #endif 37 | 38 | ILI9341 lcd = ILI9341(TFT_DC, TFT_RST, TFT_CS); 39 | 40 | #include "RREFont.h" 41 | #include "rre_bold13x20.h" 42 | #include "rre_5x8.h" 43 | 44 | RREFont font; 45 | 46 | // needed for RREFont library initialization, define your fillRect 47 | void customRect(int x, int y, int w, int h, int c) { return lcd.fillRect(x, y, w, h, c); } 48 | 49 | //#include "bold13x20digtop_font.h" 50 | //#include "small4x6_font.h" 51 | 52 | int cx,cy; 53 | int sx,sy; 54 | int xs0,ys0,xe0,ye0; 55 | int xs1,ys1,xe1,ye1; 56 | uint16_t bgCol; 57 | int i; 58 | char buf[20]; 59 | 60 | // ------------------------------------------------ 61 | #define MAXSIN 255 62 | const uint8_t sinTab[91] PROGMEM = { 63 | 0,4,8,13,17,22,26,31,35,39,44,48,53,57,61,65,70,74,78,83,87,91,95,99,103,107,111,115,119,123, 64 | 127,131,135,138,142,146,149,153,156,160,163,167,170,173,177,180,183,186,189,192,195,198,200,203,206,208,211,213,216,218, 65 | 220,223,225,227,229,231,232,234,236,238,239,241,242,243,245,246,247,248,249,250,251,251,252,253,253,254,254,254,254,254, 66 | 255 67 | }; 68 | 69 | int fastSin(int i) 70 | { 71 | while(i<0) i+=360; 72 | while(i>=360) i-=360; 73 | if(i<90) return(pgm_read_byte(&sinTab[i])); else 74 | if(i<180) return(pgm_read_byte(&sinTab[180-i])); else 75 | if(i<270) return(-pgm_read_byte(&sinTab[i-180])); else 76 | return(-pgm_read_byte(&sinTab[360-i])); 77 | } 78 | 79 | int fastCos(int i) 80 | { 81 | return fastSin(i+90); 82 | } 83 | 84 | // ------------------------------------------------ 85 | 86 | void drawGauge1(int level) 87 | { 88 | cx=SCR_WD/2; 89 | cy=SCR_HT/2; 90 | int rx0=90, ry0=90; 91 | int rx1=120, ry1=120; 92 | int mina=-75; 93 | int maxa=180+75; 94 | for(int i=mina; imina) lcd.drawLine(xs0,ys0,lastx,lasty,BLACK); 143 | lastx=xs0; 144 | lasty=ys0; 145 | xs0 = cx+sx*rx2/MAXSIN; 146 | ys0 = cy+sy*rx2/MAXSIN; 147 | snprintf(buf,4,"%d",(i-mina)/10); 148 | font.setFont(&rre_5x8); 149 | font.setColor(RGBto565(150,150,150)); 150 | font.printStr(i==maxa?xs0-4:xs0-2,ys0-2,buf); 151 | } 152 | 153 | int a = map(level,0,100,mina,maxa); 154 | rx1 = rx0-12; 155 | sx = fastCos(a-180); 156 | sy = fastSin(a-180); 157 | xs0 = cx+(sx*rx1+MAXSIN/2)/MAXSIN; 158 | ys0 = cy+(sy*rx1+MAXSIN/2)/MAXSIN; 159 | rx1 = rx0-42; 160 | sx = fastCos(a-180); 161 | sy = fastSin(a-180); 162 | xs1 = cx+(sx*rx1+MAXSIN/2)/MAXSIN; 163 | ys1 = cy+(sy*rx1+MAXSIN/2)/MAXSIN; 164 | rx1 = rx0-42; 165 | sx = fastCos(a-180-8); 166 | sy = fastSin(a-180-8); 167 | xe0 = cx+(sx*rx1+MAXSIN/2)/MAXSIN; 168 | ye0 = cy+(sy*rx1+MAXSIN/2)/MAXSIN; 169 | sx = fastCos(a-180+8); 170 | sy = fastSin(a-180+8); 171 | xe1 = cx+(sx*rx1+MAXSIN/2)/MAXSIN; 172 | ye1 = cy+(sy*rx1+MAXSIN/2)/MAXSIN; 173 | 174 | lcd.drawLine(xs1Old,ys1Old,cx,cy,bgCol); 175 | lcd.fillTriangle(xs0Old,ys0Old,xe0Old,ye0Old,xe1Old,ye1Old,bgCol); 176 | lcd.drawLine(xs1,ys1,cx,cy,BLACK); 177 | lcd.fillTriangle(xs0,ys0,xe0,ye0,xe1,ye1,RED); 178 | lcd.fillCircle(cx,cy,2,BLACK); 179 | xs0Old=xs0; ys0Old=ys0; xs1Old=xs1; ys1Old=ys1; 180 | xe0Old=xe0; ye0Old=ye0; xe1Old=xe1; ye1Old=ye1; 181 | } 182 | 183 | void drawGauge3(int level) 184 | { 185 | cx=SCR_WD/2; 186 | cy=SCR_HT/2; 187 | int rx0=120; 188 | int rx1; 189 | int mina=0; 190 | int maxa=270; 191 | int lastx,lasty; 192 | static int xs0Old=0,ys0Old=0; 193 | for(int i=mina; i<=maxa; i+=3) { 194 | sx = fastCos(i-270); 195 | sy = fastSin(i-270); 196 | xs0 = cx+sx*rx0/MAXSIN; 197 | ys0 = cy+sy*rx0/MAXSIN; 198 | if(i>mina) lcd.drawLine(xs0,ys0,lastx,lasty,WHITE); 199 | lastx=xs0; 200 | lasty=ys0; 201 | } 202 | for(int i=mina; i<=maxa; i+=9) { 203 | sx = fastCos(i-270); 204 | sy = fastSin(i-270); 205 | xs0 = cx+sx*rx0/MAXSIN; 206 | ys0 = cy+sy*rx0/MAXSIN; 207 | if(i%27==0) rx1=rx0-14; else rx1=rx0-7; 208 | xe0 = cx+sx*rx1/MAXSIN; 209 | ye0 = cy+sy*rx1/MAXSIN; 210 | lcd.drawLine(xs0,ys0,xe0,ye0,WHITE); 211 | } 212 | 213 | int a = map(level,0,100,mina,maxa); 214 | rx1=rx0-18; 215 | sx = fastCos(a-270); 216 | sy = fastSin(a-270); 217 | xs0 = cx+sx*rx1/MAXSIN; 218 | ys0 = cy+sy*rx1/MAXSIN; 219 | lcd.drawLine(xs0Old,ys0Old,cx,cy,BLACK); 220 | lcd.drawLine(xs0,ys0,cx,cy,RED); 221 | lcd.fillCircle(cx,cy,2,RED); 222 | xs0Old=xs0; ys0Old=ys0; 223 | 224 | lcd.fillRect(SCR_WD-13*3-2,SCR_HT-20,13*3+2,20,BLACK); 225 | snprintf(buf,10,"%d",level); 226 | font.setFont(&rre_Bold13x20); 227 | font.setCharMinWd(13); 228 | font.setColor(WHITE); 229 | font.printStr(ALIGN_RIGHT,SCR_HT-20,buf); 230 | } 231 | 232 | void drawGauge4(int level) 233 | { 234 | cx=SCR_WD-1; 235 | cy=SCR_HT-1; 236 | long rx0=240-4, ry0=240-4; 237 | long rx1=rx0-40, ry1=ry0-40; 238 | long rx2=rx0+4, ry2=ry0+4; 239 | int mina=0; 240 | int maxa=90; 241 | for(int i=mina; i<=maxa; i+=5) { 242 | sx = fastCos(i-180); 243 | sy = fastSin(i-180); 244 | xs0 = cx+sx*rx0/MAXSIN; 245 | ys0 = cy+sy*ry0/MAXSIN; 246 | xe0 = cx+sx*rx1/MAXSIN; 247 | ye0 = cy+sy*ry1/MAXSIN; 248 | if(i>mina) { 249 | if(i<=level) { 250 | lcd.fillTriangle(xs0,ys0,xe0,ye0,xe1,ye1, lcd.rgbWheel(85*2*(90-i)/90)); 251 | lcd.fillTriangle(xs1,ys1,xe1,ye1,xs0,ys0, lcd.rgbWheel(85*2*(90-i)/90)); 252 | } else { 253 | lcd.fillTriangle(xs0,ys0,xe0,ye0,xe1,ye1, RGBto565(60,60,60)); 254 | lcd.fillTriangle(xs1,ys1,xe1,ye1,xs0,ys0, RGBto565(60,60,60)); 255 | } 256 | } 257 | xs1 = xs0; ys1 = ys0; 258 | xe1 = xe0; ye1 = ye0; 259 | xe0 = cx+sx*rx2/MAXSIN; 260 | ye0 = cy+sy*ry2/MAXSIN; 261 | lcd.drawLine(xs0,ys0,xe0,ye0, YELLOW); 262 | } 263 | lcd.fillRect(SCR_WD-(13*3+2)*1,SCR_HT-20,(13*3+2)*1,20,BLACK); 264 | snprintf(buf,10,"%d",level); 265 | font.setFont(&rre_Bold13x20); 266 | font.setCharMinWd(13); 267 | font.setColor(WHITE); 268 | font.printStr(ALIGN_RIGHT,SCR_HT-20,buf); 269 | } 270 | 271 | void drawBar(int level) 272 | { 273 | int i=level*SCR_WD/100; 274 | int ht=31; 275 | lcd.fillRect(0,20,i,ht,lcd.rgbWheel(85*2*level/100)); 276 | lcd.fillRect(i,20,SCR_WD-i,ht,RGBto565(60,60,60)); 277 | 278 | for(i=0;i100) br=127; else br=30+(127-30)*(br-30)/(100-30); 306 | lcd.fillRect(i*w,SCR_HT-1-barLev[i],w-1,barLev[i],RGBto565(r*br/127,g*br/127,b*br/127)); 307 | barLevOld[i]=barLev[i]; 308 | } 309 | 310 | for(int i=0;i<16;i++) { 311 | if(!barDec[i]) { 312 | if(barLev[i]>barLevSet[i]) { 313 | barLev[i]-=4; 314 | if(barLev[i]barLevSet[i]) { barLev[i]=barLevSet[i]; barDec[i]=1; } 318 | } 319 | } else { 320 | barLev[i]--; 321 | if(barLev[i]<0) barLev[i]=0; 322 | } 323 | } 324 | int r=random(16); 325 | barLevSet[r]=random(10,SCR_HT); barDec[r]=0; 326 | if(r>0) { barLevSet[r-1]=7*barLevSet[r]/10; barDec[r-1]=0; } 327 | if(r<15) { barLevSet[r+1]=7*barLevSet[r]/10; barDec[r+1]=0; } 328 | } 329 | 330 | unsigned long ms,tm=15000; 331 | 332 | void setup(void) 333 | { 334 | Serial.begin(9600); 335 | lcd.init(); 336 | lcd.fillScreen(BLACK); 337 | font.init(customRect, SCR_WD, SCR_HT); // custom fillRect function and screen width and height values 338 | font.setFont(&rre_5x8); 339 | font.setColor(GREEN); 340 | font.printStr(ALIGN_CENTER,SCR_HT/2-3,"GAUGES DEMO"); 341 | //delay(2000); 342 | } 343 | 344 | void loop() 345 | { 346 | lcd.fillScreen(BLACK); 347 | ms=millis(); 348 | while(millis()-ms=0;i-=5) { drawGauge1(i); delay(10); } 352 | delay(250); 353 | } 354 | 355 | lcd.fillScreen(BLACK); 356 | ms=millis(); 357 | while(millis()-ms=0;i-=5) { drawBar(i); delay(30); } 361 | delay(250); 362 | } 363 | 364 | bgCol=RGBto565(220,220,220); 365 | lcd.fillScreen(bgCol); 366 | ms=millis(); 367 | while(millis()-ms=0;i-=2) { drawGauge2(i); delay(10); } 371 | delay(450); 372 | } 373 | 374 | lcd.fillScreen(BLACK); 375 | ms=millis(); 376 | while(millis()-ms=0;i-=2) { drawGauge3(i); delay(20); } 386 | delay(450); 387 | } 388 | 389 | lcd.fillScreen(BLACK); 390 | ms=millis(); 391 | while(millis()-ms=0;i-=5) { drawGauge4(i); delay(5); } 395 | delay(450); 396 | } 397 | } 398 | 399 | 400 | -------------------------------------------------------------------------------- /examples/ILI9341_lib_Watch_2bit/ILI9341_lib_Watch_2bit.ino: -------------------------------------------------------------------------------- 1 | // ILI9341 library example 2 | // (c) 2020 Pawel A. Hernik 3 | // Analog watch/clock, AVR + DS1307/DS3231 RTC module 4 | // YT videos: 5 | // https://youtu.be/jFGDFuLhdMc 6 | // https://youtu.be/35Z0enhEYqM 7 | // https://youtu.be/Xr-dxPhePhY 8 | 9 | /* 10 | ILI9341 240x320 2.2" LCD pinout (header at the top, from left): 11 | #1 MISO -> NC 12 | #2 LED -> 3.3V 13 | #3 SCK -> SCL/D13/PA5 14 | #4 SDI -> MOSI/D11/PA7 15 | #5 DC -> D8/PA1 or any digital 16 | #6 RESET -> D9/PA0 or any digital 17 | #7 CS -> D10/PA2 or any digital 18 | #8 GND -> GND 19 | #9 VCC -> 3.3V 20 | */ 21 | 22 | #define SCR_WD 240 23 | #define SCR_HT 320 24 | #include 25 | #include 26 | 27 | #if (__STM32F1__) // bluepill 28 | #define TFT_CS PA2 29 | #define TFT_DC PA1 30 | #define TFT_RST PA0 31 | //#include 32 | #else 33 | #define TFT_CS 10 34 | #define TFT_DC 8 35 | #define TFT_RST 9 36 | #define BUTTON 3 37 | #include 38 | #endif 39 | 40 | ILI9341 lcd = ILI9341(TFT_DC, TFT_RST, TFT_CS); 41 | 42 | //#include "sansmains.h" 43 | //#include "smartq02.h" 44 | //#include "smartq04.h" 45 | //#include "smartq09.h" 46 | //#include "smartq07.h" 47 | #include "smartq08.h" 48 | const unsigned char *clockface = dial2bit; 49 | 50 | //#include "small4x6_font.h" 51 | 52 | struct RTCData { 53 | int hour,minute,second; 54 | int year,month,day,dayOfWeek; 55 | }; 56 | 57 | RTCData cur; 58 | 59 | #define USEHW 1 60 | #include 61 | //#include "rtc.h" 62 | 63 | uint8_t txt2num(const char* p) 64 | { 65 | return 10*(*p-'0') + *(p+1)-'0'; 66 | } 67 | 68 | // configuration 69 | 70 | //const uint16_t cx = SCR_WD/2, cy = SCR_HT/2; // clock center 71 | const uint16_t cx = SCR_WD/2, cy = 240/2; // clock center 72 | const uint16_t selHandCol1 = RGBto565(250,250,0); 73 | const uint16_t selHandCol2 = RGBto565(180,180,0); 74 | const uint16_t mHandCol1 = RGBto565(220,220,220); 75 | const uint16_t mHandCol2 = RGBto565(100,100,100); 76 | const uint16_t hHandCol1 = RGBto565(220,220,220); 77 | const uint16_t hHandCol2 = RGBto565(100,100,100); 78 | const uint16_t sHandCol1 = RGBto565(250,20,20); 79 | const uint16_t sHandCol2 = RGBto565(200,0,0); 80 | int hHandL = 25*2, hHandW = 3*2; 81 | int mHandL = 36*2, mHandW = 3*2; 82 | int sHandL = 44*2, sHandW = 2*2; 83 | 84 | 85 | int sDeg,mDeg,hDeg; 86 | int sDegOld,mDegOld,hDegOld; 87 | unsigned long styleTime, ms; 88 | uint8_t hh = txt2num(__TIME__+0); 89 | uint8_t mm = txt2num(__TIME__+3); 90 | uint8_t ss = txt2num(__TIME__+6); 91 | uint8_t start = 1; 92 | int setMode = 0; 93 | 94 | // ---------------------------------------------------------------- 95 | 96 | uint16_t palette[4]; 97 | uint16_t line[SCR_WD+4]; 98 | 99 | void imgLineH(int x, int y, int w) 100 | { 101 | if(w<=0) return; 102 | uint8_t v,*img = (uint8_t*)clockface+4*2+6+y*SCR_WD/4+x/4; 103 | int ww = (x&3)?w+4:w; 104 | for(int i=0;i>6)&3]; 107 | line[i+1] = palette[(v>>4)&3]; 108 | line[i+2] = palette[(v>>2)&3]; 109 | line[i+3] = palette[v&3]; 110 | } 111 | lcd.drawImage(x,y,w,1,line+(x&3)); 112 | } 113 | 114 | void imgRect(int x, int y, int w, int h) 115 | { 116 | for(int i=y;iy2) { swap(y1,y2); swap(x1,x2); } 129 | if (y1>y3) { swap(y1,y3); swap(x1,x3); } 130 | if (y2>y3) { swap(y2,y3); swap(x2,x3); } 131 | 132 | t1x=t2x=x1; y=y1; // Starting points 133 | 134 | dx1 = x2 - x1; if(dx1<0) { dx1=-dx1; signx1=-1; } else signx1=1; 135 | dy1 = y2 - y1; 136 | 137 | dx2 = x3 - x1; if(dx2<0) { dx2=-dx2; signx2=-1; } else signx2=1; 138 | dy2 = y3 - y1; 139 | 140 | if (dy1 > dx1) { swap(dx1,dy1); changed1 = true; } 141 | if (dy2 > dx2) { swap(dy2,dx2); changed2 = true; } 142 | 143 | e2 = dx2>>1; 144 | if(y1==y2) goto next; // Flat top, just process the second half 145 | e1 = dx1>>1; 146 | 147 | for (uint16_t i = 0; i < dx1;) { 148 | t1xp=0; t2xp=0; 149 | if(t1x= dx1) { 156 | e1 -= dx1; 157 | if (changed1) t1xp=signx1;//t1x += signx1; 158 | else goto next1; 159 | } 160 | if (changed1) break; 161 | else t1x += signx1; 162 | } 163 | // Move line 164 | next1: 165 | // process second line until y value is about to change 166 | while (1) { 167 | e2 += dy2; 168 | while (e2 >= dx2) { 169 | e2 -= dx2; 170 | if (changed2) t2xp=signx2;//t2x += signx2; 171 | else goto next2; 172 | } 173 | if (changed2) break; 174 | else t2x += signx2; 175 | } 176 | next2: 177 | if(minx>t1x) minx=t1x; if(minx>t2x) minx=t2x; 178 | if(maxx dx1) { swap(dy1,dx1); changed1 = true; } else changed1=false; 199 | 200 | e1 = dx1>>1; 201 | 202 | for (uint16_t i = 0; i<=dx1; i++) { 203 | t1xp=0; t2xp=0; 204 | if(t1x= dx1) { 210 | e1 -= dx1; 211 | if (changed1) { t1xp=signx1; break; }//t1x += signx1; 212 | else goto next3; 213 | } 214 | if (changed1) break; 215 | else t1x += signx1; 216 | if(i= dx2) { 223 | e2 -= dx2; 224 | if(changed2) t2xp=signx2; 225 | else goto next4; 226 | } 227 | if (changed2) break; 228 | else t2x += signx2; 229 | } 230 | next4: 231 | if(minx>t1x) minx=t1x; if(minx>t2x) minx=t2x; 232 | if(maxxy3) return; 242 | } 243 | } 244 | 245 | // ------------------------------------------------ 246 | #define MAXSIN 255 247 | const uint8_t sinTab[91] PROGMEM = { 248 | 0,4,8,13,17,22,26,31,35,39,44,48,53,57,61,65,70,74,78,83,87,91,95,99,103,107,111,115,119,123, 249 | 127,131,135,138,142,146,149,153,156,160,163,167,170,173,177,180,183,186,189,192,195,198,200,203,206,208,211,213,216,218, 250 | 220,223,225,227,229,231,232,234,236,238,239,241,242,243,245,246,247,248,249,250,251,251,252,253,253,254,254,254,254,254, 251 | 255 252 | }; 253 | 254 | int fastSin(int i) 255 | { 256 | while(i<0) i+=360; 257 | while(i>=360) i-=360; 258 | if(i<90) return(pgm_read_byte(&sinTab[i])); else 259 | if(i<180) return(pgm_read_byte(&sinTab[180-i])); else 260 | if(i<270) return(-pgm_read_byte(&sinTab[i-180])); else 261 | return(-pgm_read_byte(&sinTab[360-i])); 262 | } 263 | 264 | int fastCos(int i) 265 | { 266 | return fastSin(i+90); 267 | } 268 | 269 | // ------------------------------------------------ 270 | 271 | int px[8],py[8]; 272 | 273 | void drawHand(int deg, int w, int l, int col1=0, int col2=0) 274 | { 275 | int i,num = 4; 276 | px[0]= 0, py[0]= l; 277 | px[1]=-w-1, py[1]= 0; 278 | px[2]= w+1, py[2]= 0; 279 | px[3]= 0, py[3]=-15; 280 | int x[5],y[5]; 281 | int cc = fastCos(deg+180); 282 | int ss = fastSin(deg+180); 283 | for(i=0;i0?MAXSIN/2:-MAXSIN/2))/MAXSIN; 287 | y[i] = cy + (y[i]+(y[i]>0?MAXSIN/2:-MAXSIN/2))/MAXSIN; 288 | } 289 | imgTriangle(x[0],y[0], x[1],y[1], x[3],y[3], col2); 290 | imgTriangle(x[2],y[2], x[3],y[3], x[0],y[0], col1); 291 | } 292 | 293 | void drawHandS(int deg, int w, int l, int col1=0, int col2=0) 294 | { 295 | int i,num = 8; 296 | px[0]=-w+3, py[0]= l; 297 | px[1]=-w+3, py[1]=-20; 298 | px[2]= w-3, py[2]= l; 299 | px[3]= w-3, py[3]=-20; 300 | px[4]=-w+1, py[4]=-40; 301 | px[5]=-w+1, py[5]=-15; 302 | px[6]= w-1, py[6]=-40; 303 | px[7]= w-1, py[7]=-15; 304 | int x[8],y[8]; 305 | int cc = fastCos(deg+180); 306 | int ss = fastSin(deg+180); 307 | for(i=0;i0?MAXSIN/2:-MAXSIN/2))/MAXSIN; 311 | y[i] = cy + (y[i]+(y[i]>0?MAXSIN/2:-MAXSIN/2))/MAXSIN; 312 | } 313 | imgTriangle(x[0],y[0], x[1],y[1], x[3],y[3], col1); 314 | imgTriangle(x[2],y[2], x[3],y[3], x[0],y[0], col1); 315 | imgTriangle(x[4],y[4], x[5],y[5], x[7],y[7], col1); 316 | imgTriangle(x[6],y[6], x[7],y[7], x[4],y[4], col1); 317 | } 318 | 319 | void clockUpdate() 320 | { 321 | if(millis()-ms<1000 && !start) return; 322 | ms = millis(); 323 | if(setMode==0) { 324 | //getRTCDateTime(&cur); 325 | if(++cur.second>59) { 326 | cur.second = 0; 327 | if(++cur.minute>59) { 328 | cur.minute = 0; 329 | if(++cur.hour>11) { 330 | cur.hour = 0; 331 | } 332 | } 333 | } 334 | ss = cur.second; 335 | mm = cur.minute; 336 | hh = cur.hour; 337 | } 338 | 339 | sDeg = ss*6; 340 | 341 | if(ss==0 || start) { 342 | start = 0; 343 | mDeg = mm*6+sDeg/60; 344 | hDeg = hh*30+mDeg/12; 345 | drawHand(hDegOld,hHandW,hHandL); 346 | drawHand(mDegOld,mHandW,mHandL); 347 | mDegOld = mDeg; 348 | hDegOld = hDeg; 349 | } 350 | 351 | drawHandS(sDegOld,sHandW,sHandL); 352 | if(setMode==1) 353 | drawHand(hDeg,hHandW,hHandL,selHandCol1,selHandCol2); 354 | else 355 | drawHand(hDeg,hHandW,hHandL,hHandCol1,hHandCol2); 356 | if(setMode==2) 357 | drawHand(mDeg,mHandW,mHandL,selHandCol1,selHandCol2); 358 | else 359 | drawHand(mDeg,mHandW,mHandL,mHandCol1,mHandCol2); 360 | if(setMode==0) 361 | drawHandS(sDeg,sHandW,sHandL,sHandCol1,sHandCol2); 362 | sDegOld = sDeg; 363 | 364 | lcd.fillCircle(cx,cy, 4, RGBto565(40,40,40)); 365 | /* 366 | lcd.setTextSize(3); lcd.setTextColor(WHITE,BLACK); 367 | lcd.setCursor(0,0); 368 | lcd.print(hh); lcd.print(":"); lcd.print(mm); lcd.print(":"); lcd.print(ss); 369 | lcd.setCursor(0,30); 370 | lcd.print(cur.day); lcd.print("."); lcd.print(cur.month); lcd.print("."); lcd.print(cur.year+2000); 371 | */ 372 | } 373 | 374 | // -------------------------------------------------------------------------- 375 | int stateOld = HIGH; 376 | long btDebounce = 30; 377 | long btDoubleClick = 600; 378 | long btLongClick = 700; 379 | long btLongerClick = 2000; 380 | long btTime = 0, btTime2 = 0; 381 | int clickCnt = 1; 382 | 383 | // 0=idle, 1,2,3=click, -1,-2=longclick 384 | int checkButton() 385 | { 386 | int state = digitalRead(BUTTON); 387 | if( state == LOW && stateOld == HIGH ) { btTime = millis(); stateOld = state; return 0; } // button just pressed 388 | if( state == HIGH && stateOld == LOW ) { // button just released 389 | stateOld = state; 390 | if( millis()-btTime >= btDebounce && millis()-btTime < btLongClick ) { 391 | if( millis()-btTime2= btLongerClick ) { stateOld = state; return -2; } 397 | if( state == LOW && millis()-btTime >= btLongClick ) { stateOld = state; return -1; } 398 | return 0; 399 | } 400 | // -------------------------------------------------------------------------- 401 | const char *months[] = {"???", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; 402 | const char *delim = " :"; 403 | char bld[40]; 404 | 405 | uint8_t str2month(const char * d) 406 | { 407 | uint8_t i = 13; 408 | while((--i) && strcmp(months[i], d)); 409 | return i; 410 | } 411 | 412 | void setBuildTime() 413 | { 414 | // Timestamp format: "Mar 3 2019 12:34:56" 415 | snprintf(bld,40,"%s %s\n", __DATE__, __TIME__); 416 | char *token = strtok(bld, delim); 417 | while(token) { 418 | int m = str2month((const char*)token); 419 | if(m>0) { 420 | cur.month = m; 421 | token = strtok(NULL, delim); cur.day = atoi(token); 422 | token = strtok(NULL, delim); cur.year = atoi(token) - 1970; 423 | token = strtok(NULL, delim); cur.hour = atoi(token); 424 | token = strtok(NULL, delim); cur.minute = atoi(token); 425 | token = strtok(NULL, delim); cur.second = atoi(token); 426 | } 427 | token = strtok(NULL, delim); 428 | } 429 | //snprintf(bld,40,"Build: %02d-%02d-%02d %02d:%02d:%02d\n",mt.year+1970,mt.month,mt.day,mt.hour,mt.minute,mt.second); Serial.println(bld); 430 | //setRTCTime(&cur); 431 | } 432 | 433 | //----------------------------------------------------------------------------- 434 | 435 | void setup() 436 | { 437 | Serial.begin(9600); 438 | pinMode(BUTTON, INPUT_PULLUP); 439 | //Wire.begin(); 440 | //Wire.setClock(400000); // faster 441 | lcd.init(); 442 | lcd.fillScreen(); 443 | //getRTCDateTime(&cur); 444 | if(cur.year+2000<2020) setBuildTime(); // <2020 - invalid year 445 | uint16_t *pal = (uint16_t*)clockface+3; 446 | for(int i=0;i<4;i++) palette[i]=pgm_read_word(pal++); 447 | imgRect(0,0,SCR_WD,240); 448 | ms = millis(); 449 | } 450 | 451 | void loop() 452 | { 453 | /* 454 | int st = checkButton(); 455 | if(st<0 && setMode==0) setMode=1; 456 | if(setMode>0) { 457 | if(st>0) { start=1; if(++setMode>2) setMode=0; } 458 | if(setMode==1 && st<0) { if(++hh>23) hh=0; start=1; delay(600); } 459 | if(setMode==2 && st<0) { if(++mm>59) mm=0; start=1; delay(200); } 460 | cur.hour = hh; 461 | cur.minute = mm; 462 | //setRTCTime(&cur); 463 | }*/ 464 | clockUpdate(); 465 | } 466 | 467 | -------------------------------------------------------------------------------- /ILI9341_Fast.cpp: -------------------------------------------------------------------------------- 1 | // Fast ILI9341 240x320 2.2" display library 2 | // (c) 2019-20 by Pawel A. Hernik 3 | 4 | #include "ILI9341_Fast.h" 5 | #include 6 | #include "pins_arduino.h" 7 | #include "wiring_private.h" 8 | #include 9 | 10 | // ----------------------------------------- 11 | // ILI9341 commands 12 | #define ILI9341_NOP 0x00 13 | #define ILI9341_SWRESET 0x01 14 | #define ILI9341_RDDID 0x04 15 | #define ILI9341_RDDST 0x09 16 | #define ILI9341_RDMODE 0x0A 17 | #define ILI9341_RDMADCTL 0x0B 18 | #define ILI9341_RDPIXFMT 0x0C 19 | #define ILI9341_RDIMGFMT 0x0A 20 | #define ILI9341_RDSELFDIAG 0x0F 21 | 22 | #define ILI9341_SLPIN 0x10 23 | #define ILI9341_SLPOUT 0x11 24 | #define ILI9341_PTLON 0x12 25 | #define ILI9341_NORON 0x13 26 | 27 | #define ILI9341_INVOFF 0x20 28 | #define ILI9341_INVON 0x21 29 | #define ILI9341_GAMMASET 0x26 30 | #define ILI9341_DISPOFF 0x28 31 | #define ILI9341_DISPON 0x29 32 | #define ILI9341_CASET 0x2A 33 | #define ILI9341_PASET 0x2B 34 | #define ILI9341_RAMWR 0x2C 35 | #define ILI9341_RAMRD 0x2E 36 | 37 | #define ILI9341_PTLAR 0x30 38 | #define ILI9341_VSCRDEF 0x33 39 | #define ILI9341_MADCTL 0x36 40 | #define ILI9341_VSCRSADD 0x37 41 | #define ILI9341_PIXFMT 0x3A 42 | 43 | #define ILI9341_FRMCTR1 0xB1 44 | #define ILI9341_FRMCTR2 0xB2 45 | #define ILI9341_FRMCTR3 0xB3 46 | #define ILI9341_INVCTR 0xB4 47 | #define ILI9341_DFUNCTR 0xB6 48 | 49 | #define ILI9341_PWCTR1 0xC0 50 | #define ILI9341_PWCTR2 0xC1 51 | #define ILI9341_PWCTR3 0xC2 52 | #define ILI9341_PWCTR4 0xC3 53 | #define ILI9341_PWCTR5 0xC4 54 | #define ILI9341_VMCTR1 0xC5 55 | #define ILI9341_VMCTR2 0xC7 56 | #define ILI9341_PWCTRA 0xCB 57 | #define ILI9341_CMD_CF 0xCF 58 | 59 | #define ILI9341_RDID1 0xDA 60 | #define ILI9341_RDID2 0xDB 61 | #define ILI9341_RDID3 0xDC 62 | #define ILI9341_RDID4 0xDD 63 | 64 | #define ILI9341_GMCTRP1 0xE0 65 | #define ILI9341_GMCTRN1 0xE1 66 | #define ILI9341_TIMCTRA 0xE8 67 | #define ILI9341_TIMCTRB 0xE9 68 | #define ILI9341_TIMCTRC 0xEA 69 | #define ILI9341_POWSEQ 0xED 70 | #define ILI9341_CMD_EF 0xEF 71 | 72 | #define ILI9341_EN3GAM 0xF2 73 | #define ILI9341_PUMPRAT 0xF7 74 | 75 | #define CMD_DELAY 0x80 76 | 77 | #define ILI9341_MADCTL_MY 0x80 78 | #define ILI9341_MADCTL_MX 0x40 79 | #define ILI9341_MADCTL_MV 0x20 80 | #define ILI9341_MADCTL_ML 0x10 81 | #define ILI9341_MADCTL_RGB 0x00 82 | #define ILI9341_MADCTL_BGR 0x08 83 | #define ILI9341_MADCTL_MH 0x04 84 | 85 | static const uint8_t ILI9341_commands[] PROGMEM = { 86 | 22, // number of commands 87 | ILI9341_SWRESET, CMD_DELAY, 5, // 1 88 | ILI9341_CMD_EF, 3, // 2 89 | 0x03, 0x80, 0x02, 90 | ILI9341_CMD_CF, 3, // 3 91 | 0x00, 0xC1, 0x30, 92 | ILI9341_POWSEQ, 4, // 4 93 | 0x64, 0x03, 0x12, 0x81, 94 | ILI9341_TIMCTRA, 3, // 5 95 | 0x85, 0x00, 0x78, 96 | ILI9341_PWCTRA, 5, // 6 97 | 0x39, 0x2C, 0x00, 0x34, 0x02, 98 | ILI9341_PUMPRAT, 1, // 7 99 | 0x20, 100 | ILI9341_TIMCTRC, 2, // 8 101 | 0x00, 0x00, 102 | ILI9341_PWCTR1, 1, // 9 power control 103 | 0x23, // VRH[5:0] 104 | ILI9341_PWCTR2, 1, // 10 power control 105 | 0x10, // SAP[2:0];BT[3:0] 106 | ILI9341_VMCTR1, 2, // 11 VCM control 107 | 0x3e, 0x28, 108 | ILI9341_VMCTR2, 1, // 12 VCM control2 109 | 0x86, // -- 110 | ILI9341_MADCTL, 1, // 13 111 | (ILI9341_MADCTL_MX | ILI9341_MADCTL_BGR), 112 | ILI9341_PIXFMT, 1, // 14 113 | 0x55, 114 | ILI9341_FRMCTR1, 2, // 15 115 | 0x00, 0x18, 116 | ILI9341_DFUNCTR, 3, // 16 117 | 0x08, 0x82, 0x27, 118 | ILI9341_EN3GAM, 1, // 17 3Gamma Function Disable 119 | 0x00, 120 | ILI9341_GAMMASET, 1, // 18 Gamma curve selected 121 | 0x01, 122 | ILI9341_GMCTRP1, 15, // 19 Set Gamma 123 | 0x0F, 0x31, 0x2B, 0x0C, 0x0E, 0x08, 0x4E, 0xF1, 0x37, 0x07, 0x10, 0x03, 0x0E, 0x09, 0x00, 124 | ILI9341_GMCTRN1, 15, // 20 125 | 0x00, 0x0E, 0x14, 0x03, 0x11, 0x07, 0x31, 0xC1, 0x48, 0x08, 0x0F, 0x0C, 0x31, 0x36, 0x0F, 126 | ILI9341_SLPOUT, CMD_DELAY, 120, // 21 127 | ILI9341_DISPON, 0, // 22 128 | }; 129 | // ----------------------------------------- 130 | 131 | #ifdef COMPATIBILITY_MODE 132 | static SPISettings spiSettings; 133 | #define SPI_START SPI.beginTransaction(spiSettings) 134 | #define SPI_END SPI.endTransaction() 135 | #else 136 | #define SPI_START 137 | #define SPI_END 138 | #endif 139 | 140 | // macros for fast DC and CS state changes 141 | #ifdef COMPATIBILITY_MODE 142 | #define DC_DATA digitalWrite(dcPin, HIGH) 143 | #define DC_COMMAND digitalWrite(dcPin, LOW) 144 | #define CS_IDLE digitalWrite(csPin, HIGH) 145 | #define CS_ACTIVE digitalWrite(csPin, LOW) 146 | #else 147 | #define DC_DATA *dcPort |= dcMask 148 | #define DC_COMMAND *dcPort &= ~dcMask 149 | #define CS_IDLE *csPort |= csMask 150 | #define CS_ACTIVE *csPort &= ~csMask 151 | #endif 152 | 153 | // if CS always connected to the ground then don't do anything for better performance 154 | #ifdef CS_ALWAYS_LOW 155 | #define CS_IDLE 156 | #define CS_ACTIVE 157 | #endif 158 | 159 | // ---------------------------------------------------------- 160 | // speed test results: 161 | // in AVR best performance mode -> about 7.1 Mbps 162 | // in compatibility mode (SPI.transfer(c)) -> about 4 Mbps 163 | 164 | inline void ILI9341::writeSPI(uint8_t c) 165 | { 166 | #ifdef COMPATIBILITY_MODE 167 | SPI.transfer(c); 168 | #else 169 | SPDR = c; 170 | /* 171 | asm volatile("nop;"); // 8 NOPs seem to be enough for 16MHz AVR @ DIV2 to avoid using while loop 172 | asm volatile("nop"); 173 | asm volatile("nop"); 174 | asm volatile("nop"); 175 | asm volatile("nop"); 176 | asm volatile("nop"); 177 | asm volatile("nop"); 178 | asm volatile("nop"); 179 | */ 180 | asm volatile("rjmp .+0\n"); // same cycles but uses half the memory 181 | asm volatile("rjmp .+0\n"); 182 | asm volatile("rjmp .+0\n"); 183 | asm volatile("rjmp .+0\n"); 184 | //while(!(SPSR & _BV(SPIF))) ; 185 | #endif 186 | } 187 | 188 | // ---------------------------------------------------------- 189 | // fast method to send multiple 16-bit values via SPI 190 | inline void ILI9341::writeMulti(uint16_t color, uint16_t num) 191 | { 192 | #ifdef COMPATIBILITY_MODE 193 | while(num--) { SPI.transfer(color>>8); SPI.transfer(color); } 194 | #else 195 | asm volatile 196 | ( 197 | "next:\n" 198 | "out %[spdr],%[hi]\n" 199 | "rjmp .+0\n" // wait 8*2+1 = 17 cycles 200 | "rjmp .+0\n" 201 | "rjmp .+0\n" 202 | "rjmp .+0\n" 203 | "rjmp .+0\n" 204 | "rjmp .+0\n" 205 | "rjmp .+0\n" 206 | "rjmp .+0\n" 207 | "nop\n" 208 | "out %[spdr],%[lo]\n" 209 | "rjmp .+0\n" // wait 6*2+1 = 13 cycles + sbiw + brne 210 | "rjmp .+0\n" 211 | "rjmp .+0\n" 212 | "rjmp .+0\n" 213 | "rjmp .+0\n" 214 | "rjmp .+0\n" 215 | "nop\n" 216 | "sbiw %[num],1\n" 217 | "brne next\n" 218 | : [num] "+w" (num) 219 | : [spdr] "I" (_SFR_IO_ADDR(SPDR)), [lo] "r" ((uint8_t)color), [hi] "r" ((uint8_t)(color>>8)) 220 | ); 221 | #endif 222 | } 223 | // ---------------------------------------------------------- 224 | // fast method to send multiple 16-bit values from RAM via SPI 225 | inline void ILI9341::copyMulti(uint8_t *img, uint16_t num) 226 | { 227 | #ifdef COMPATIBILITY_MODE 228 | while(num--) { SPI.transfer(*(img+1)); SPI.transfer(*(img+0)); img+=2; } 229 | #else 230 | uint8_t lo,hi; 231 | asm volatile 232 | ( 233 | "nextCopy:\n" 234 | "ld %[hi],%a[img]+\n" 235 | "ld %[lo],%a[img]+\n" 236 | "out %[spdr],%[lo]\n" 237 | "rjmp .+0\n" // wait 8*2+1 = 17 cycles 238 | "rjmp .+0\n" 239 | "rjmp .+0\n" 240 | "rjmp .+0\n" 241 | "rjmp .+0\n" 242 | "rjmp .+0\n" 243 | "rjmp .+0\n" 244 | "rjmp .+0\n" 245 | "nop\n" 246 | "out %[spdr],%[hi]\n" 247 | "rjmp .+0\n" // wait 4*2+1 = 9 cycles + sbiw + brne + ld*2 248 | "rjmp .+0\n" 249 | "rjmp .+0\n" 250 | "rjmp .+0\n" 251 | "nop\n" 252 | "sbiw %[num],1\n" 253 | "brne nextCopy\n" 254 | : [num] "+w" (num) 255 | : [spdr] "I" (_SFR_IO_ADDR(SPDR)), [img] "e" (img), [lo] "r" (lo), [hi] "r" (hi) 256 | ); 257 | #endif 258 | } 259 | // ---------------------------------------------------------- 260 | ILI9341::ILI9341(int8_t dc, int8_t rst, int8_t cs) : Adafruit_GFX(ILI9341_TFTWIDTH, ILI9341_TFTHEIGHT) 261 | { 262 | csPin = cs; 263 | dcPin = dc; 264 | rstPin = rst; 265 | } 266 | 267 | // ---------------------------------------------------------- 268 | void ILI9341::init() 269 | { 270 | pinMode(dcPin, OUTPUT); 271 | #ifndef CS_ALWAYS_LOW 272 | pinMode(csPin, OUTPUT); 273 | #endif 274 | 275 | #ifndef COMPATIBILITY_MODE 276 | dcPort = portOutputRegister(digitalPinToPort(dcPin)); 277 | dcMask = digitalPinToBitMask(dcPin); 278 | #ifndef CS_ALWAYS_LOW 279 | csPort = portOutputRegister(digitalPinToPort(csPin)); 280 | csMask = digitalPinToBitMask(csPin); 281 | #endif 282 | #endif 283 | 284 | SPI.begin(); 285 | #ifdef COMPATIBILITY_MODE 286 | spiSettings = SPISettings(16000000, MSBFIRST, SPI_MODE0); // 8000000 gives max speed on AVR 16MHz 287 | #else 288 | SPI.setClockDivider(SPI_CLOCK_DIV2); 289 | SPI.setDataMode(SPI_MODE0); 290 | #endif 291 | 292 | CS_ACTIVE; 293 | if(rstPin != -1) { 294 | pinMode(rstPin, OUTPUT); 295 | digitalWrite(rstPin, HIGH); 296 | delay(5); 297 | digitalWrite(rstPin, LOW); 298 | delay(20); 299 | digitalWrite(rstPin, HIGH); 300 | delay(150); 301 | } 302 | 303 | _width = ILI9341_TFTWIDTH; 304 | _height = ILI9341_TFTHEIGHT; 305 | displayInit(ILI9341_commands); 306 | setRotation(2); 307 | } 308 | 309 | // ---------------------------------------------------------- 310 | void ILI9341::writeCmd(uint8_t c) 311 | { 312 | DC_COMMAND; 313 | CS_ACTIVE; 314 | SPI_START; 315 | 316 | writeSPI(c); 317 | 318 | CS_IDLE; 319 | SPI_END; 320 | } 321 | 322 | // ---------------------------------------------------------- 323 | void ILI9341::writeData(uint8_t d8) 324 | { 325 | DC_DATA; 326 | CS_ACTIVE; 327 | SPI_START; 328 | 329 | writeSPI(d8); 330 | 331 | CS_IDLE; 332 | SPI_END; 333 | } 334 | 335 | // ---------------------------------------------------------- 336 | void ILI9341::writeData16(uint16_t d16) 337 | { 338 | DC_DATA; 339 | CS_ACTIVE; 340 | SPI_START; 341 | 342 | writeMulti(d16,1); 343 | 344 | CS_IDLE; 345 | SPI_END; 346 | } 347 | 348 | // ---------------------------------------------------------- 349 | void ILI9341::displayInit(const uint8_t *addr) 350 | { 351 | uint8_t numCommands, numArgs; 352 | uint16_t ms; 353 | numCommands = pgm_read_byte(addr++); 354 | while(numCommands--) { 355 | writeCmd(pgm_read_byte(addr++)); 356 | numArgs = pgm_read_byte(addr++); 357 | ms = numArgs & CMD_DELAY; 358 | numArgs &= ~CMD_DELAY; 359 | while(numArgs--) writeData(pgm_read_byte(addr++)); 360 | 361 | if(ms) { 362 | ms = pgm_read_byte(addr++); 363 | if(ms==255) ms=500; 364 | delay(ms); 365 | } 366 | } 367 | } 368 | 369 | // ---------------------------------------------------------- 370 | void ILI9341::setRotation(uint8_t m) 371 | { 372 | writeCmd(ILI9341_MADCTL); 373 | rotation = m & 3; 374 | switch (rotation) { 375 | case 0: 376 | writeData(ILI9341_MADCTL_MX | ILI9341_MADCTL_BGR); 377 | _width = ILI9341_TFTWIDTH; 378 | _height = ILI9341_TFTHEIGHT; 379 | break; 380 | case 1: 381 | writeData(ILI9341_MADCTL_MV | ILI9341_MADCTL_BGR); 382 | _width = ILI9341_TFTHEIGHT; 383 | _height = ILI9341_TFTWIDTH; 384 | break; 385 | case 2: 386 | writeData(ILI9341_MADCTL_MY | ILI9341_MADCTL_BGR); 387 | _width = ILI9341_TFTWIDTH; 388 | _height = ILI9341_TFTHEIGHT; 389 | break; 390 | case 3: 391 | writeData(ILI9341_MADCTL_MX | ILI9341_MADCTL_MY | ILI9341_MADCTL_MV | ILI9341_MADCTL_BGR); 392 | _width = ILI9341_TFTHEIGHT; 393 | _height = ILI9341_TFTWIDTH; 394 | break; 395 | } 396 | } 397 | 398 | // ---------------------------------------------------------- 399 | void ILI9341::setAddrWindow(uint16_t xs, uint16_t ys, uint16_t xe, uint16_t ye) 400 | { 401 | // optimized version 402 | CS_ACTIVE; 403 | SPI_START; 404 | 405 | DC_COMMAND; writeSPI(ILI9341_CASET); 406 | DC_DATA; writeMulti(xs,1); writeMulti(xe,1); 407 | 408 | DC_COMMAND; writeSPI(ILI9341_PASET); 409 | DC_DATA; writeMulti(ys,1); writeMulti(ye,1); 410 | 411 | DC_COMMAND; writeSPI(ILI9341_RAMWR); 412 | 413 | DC_DATA; 414 | // no CS_IDLE + SPI_END, DC_DATA to save memory 415 | } 416 | 417 | // ---------------------------------------------------------- 418 | void ILI9341::pushColor(uint16_t color) 419 | { 420 | SPI_START; 421 | //DC_DATA; 422 | CS_ACTIVE; 423 | 424 | writeSPI(color>>8); writeSPI(color); 425 | 426 | CS_IDLE; 427 | SPI_END; 428 | } 429 | 430 | // ---------------------------------------------------------- 431 | void ILI9341::drawPixel(int16_t x, int16_t y, uint16_t color) 432 | { 433 | if(x<0 ||x>=_width || y<0 || y>=_height) return; 434 | setAddrWindow(x,y,x+1,y+1); 435 | 436 | //writeMulti(color,1); 437 | writeSPI(color>>8); writeSPI(color); 438 | 439 | CS_IDLE; 440 | SPI_END; 441 | } 442 | 443 | // ---------------------------------------------------------- 444 | void ILI9341::drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color) 445 | { 446 | if(x>=_width || y>=_height || h<=0) return; 447 | if(y+h-1>=_height) h=_height-y; 448 | setAddrWindow(x, y, x, y+h-1); 449 | 450 | writeMulti(color,h); 451 | 452 | CS_IDLE; 453 | SPI_END; 454 | } 455 | 456 | // ---------------------------------------------------------- 457 | void ILI9341::drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color) 458 | { 459 | if(x>=_width || y>=_height || w<=0) return; 460 | if(x+w-1>=_width) w=_width-x; 461 | setAddrWindow(x, y, x+w-1, y); 462 | 463 | writeMulti(color,w); 464 | 465 | CS_IDLE; 466 | SPI_END; 467 | } 468 | 469 | // ---------------------------------------------------------- 470 | void ILI9341::fillScreen(uint16_t color) 471 | { 472 | fillRect(0, 0, _width, _height, color); 473 | } 474 | 475 | // ---------------------------------------------------------- 476 | void ILI9341::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) 477 | { 478 | if(x>=_width || y>=_height || w<=0 || h<=0) return; 479 | if(x+w-1>=_width) w=_width -x; 480 | if(y+h-1>=_height) h=_height-y; 481 | setAddrWindow(x, y, x+w-1, y+h-1); 482 | 483 | uint32_t num = (uint32_t)w*h; 484 | if(num>0xffff) { 485 | writeMulti(color,0xffff); 486 | writeMulti(color,num-0xffff); 487 | } else writeMulti(color,num); 488 | 489 | CS_IDLE; 490 | SPI_END; 491 | } 492 | 493 | // ---------------------------------------------------------- 494 | // draws image from RAM 495 | void ILI9341::drawImage(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t *img16) 496 | { 497 | // all protections should be on the application side 498 | //if(x>=_width || y>=_height || w<=0 || h<=0) return; 499 | //if(x+w-1>=_width) w=_width -x; 500 | //if(y+h-1>=_height) h=_height-y; 501 | setAddrWindow(x, y, x+w-1, y+h-1); 502 | 503 | copyMulti((uint8_t *)img16, w*h); 504 | 505 | CS_IDLE; 506 | SPI_END; 507 | } 508 | 509 | // ---------------------------------------------------------- 510 | // draws image from flash (PROGMEM) 511 | void ILI9341::drawImageF(int16_t x, int16_t y, int16_t w, int16_t h, const uint16_t *img16) 512 | { 513 | if(x>=_width || y>=_height || w<=0 || h<=0) return; 514 | setAddrWindow(x, y, x+w-1, y+h-1); 515 | 516 | uint32_t num = (uint32_t)w*h; 517 | uint16_t num16 = num>>3; 518 | uint8_t *img = (uint8_t *)img16; 519 | while(num16--) { 520 | writeSPI(pgm_read_byte(img+1)); writeSPI(pgm_read_byte(img+0)); img+=2; 521 | writeSPI(pgm_read_byte(img+1)); writeSPI(pgm_read_byte(img+0)); img+=2; 522 | writeSPI(pgm_read_byte(img+1)); writeSPI(pgm_read_byte(img+0)); img+=2; 523 | writeSPI(pgm_read_byte(img+1)); writeSPI(pgm_read_byte(img+0)); img+=2; 524 | writeSPI(pgm_read_byte(img+1)); writeSPI(pgm_read_byte(img+0)); img+=2; 525 | writeSPI(pgm_read_byte(img+1)); writeSPI(pgm_read_byte(img+0)); img+=2; 526 | writeSPI(pgm_read_byte(img+1)); writeSPI(pgm_read_byte(img+0)); img+=2; 527 | writeSPI(pgm_read_byte(img+1)); writeSPI(pgm_read_byte(img+0)); img+=2; 528 | } 529 | uint8_t num8 = num & 0x7; 530 | while(num8--) { writeSPI(pgm_read_byte(img+1)); writeSPI(pgm_read_byte(img+0)); img+=2; } 531 | 532 | CS_IDLE; 533 | SPI_END; 534 | } 535 | 536 | // ---------------------------------------------------------- 537 | // Pass 8-bit (each) R,G,B, get back 16-bit packed color 538 | uint16_t ILI9341::Color565(uint8_t r, uint8_t g, uint8_t b) 539 | { 540 | return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3); 541 | } 542 | 543 | // ---------------------------------------------------------- 544 | void ILI9341::invertDisplay(boolean mode) 545 | { 546 | writeCmd(mode ? ILI9341_INVON : ILI9341_INVOFF); 547 | } 548 | 549 | // ---------------------------------------------------------- 550 | void ILI9341::partialDisplay(boolean mode) 551 | { 552 | writeCmd(mode ? ILI9341_PTLON : ILI9341_NORON); 553 | } 554 | 555 | // ---------------------------------------------------------- 556 | void ILI9341::sleepDisplay(boolean mode) 557 | { 558 | writeCmd(mode ? ILI9341_SLPIN : ILI9341_SLPOUT); 559 | delay(5); 560 | } 561 | 562 | // ---------------------------------------------------------- 563 | void ILI9341::enableDisplay(boolean mode) 564 | { 565 | writeCmd(mode ? ILI9341_DISPON : ILI9341_DISPOFF); 566 | } 567 | 568 | // ---------------------------------------------------------- 569 | void ILI9341::resetDisplay() 570 | { 571 | writeCmd(ILI9341_SWRESET); 572 | delay(5); 573 | } 574 | 575 | // ---------------------------------------------------------- 576 | void ILI9341::setScrollArea(uint16_t tfa, uint16_t bfa) 577 | { 578 | uint16_t vsa = 320-tfa-bfa; 579 | writeCmd(ILI9341_VSCRDEF); 580 | writeData16(tfa); 581 | writeData16(vsa); 582 | writeData16(bfa); 583 | } 584 | 585 | // ---------------------------------------------------------- 586 | void ILI9341::setScroll(uint16_t vsp) 587 | { 588 | writeCmd(ILI9341_VSCRSADD); 589 | writeData16(vsp); 590 | } 591 | 592 | // ---------------------------------------------------------- 593 | void ILI9341::setPartArea(uint16_t sr, uint16_t er) 594 | { 595 | writeCmd(ILI9341_PTLAR); 596 | writeData16(sr); 597 | writeData16(er); 598 | } 599 | 600 | // ------------------------------------------------ 601 | // Input a value 0 to 511 (85*6) to get a color value. 602 | // The colours are a transition R - Y - G - C - B - M - R. 603 | void ILI9341::rgbWheel(int idx, uint8_t *_r, uint8_t *_g, uint8_t *_b) 604 | { 605 | idx &= 0x1ff; 606 | if(idx < 85) { // R->Y 607 | *_r = 255; *_g = idx * 3; *_b = 0; 608 | return; 609 | } else if(idx < 85*2) { // Y->G 610 | idx -= 85*1; 611 | *_r = 255 - idx * 3; *_g = 255; *_b = 0; 612 | return; 613 | } else if(idx < 85*3) { // G->C 614 | idx -= 85*2; 615 | *_r = 0; *_g = 255; *_b = idx * 3; 616 | return; 617 | } else if(idx < 85*4) { // C->B 618 | idx -= 85*3; 619 | *_r = 0; *_g = 255 - idx * 3; *_b = 255; 620 | return; 621 | } else if(idx < 85*5) { // B->M 622 | idx -= 85*4; 623 | *_r = idx * 3; *_g = 0; *_b = 255; 624 | return; 625 | } else { // M->R 626 | idx -= 85*5; 627 | *_r = 255; *_g = 0; *_b = 255 - idx * 3; 628 | return; 629 | } 630 | } 631 | 632 | uint16_t ILI9341::rgbWheel(int idx) 633 | { 634 | uint8_t r,g,b; 635 | rgbWheel(idx, &r,&g,&b); 636 | return RGBto565(r,g,b); 637 | } 638 | 639 | // ------------------------------------------------ -------------------------------------------------------------------------------- /examples/ILI9341_lib_AdafruitBenchmark/ILI9341_lib_AdafruitBenchmark.ino: -------------------------------------------------------------------------------- 1 | // ILI9341 library example 2 | // (c) 2020 Pawel A. Hernik 3 | 4 | /* 5 | ILI9341 240x320 2.2" LCD pinout (header at the top, from left): 6 | #1 MISO -> NC 7 | #2 LED -> 3.3V 8 | #3 SCK -> SCL/D13/PA5 9 | #4 SDI -> MOSI/D11/PA7 10 | #5 DC -> D8/PA1 or any digital 11 | #6 RESET -> D9/PA0 or any digital 12 | #7 CS -> D10/PA2 or any digital 13 | #8 GND -> GND 14 | #9 VCC -> 3.3V 15 | */ 16 | 17 | #define SCR_WD 240 18 | #define SCR_HT 320 19 | #include 20 | #include 21 | 22 | #if (__STM32F1__) // bluepill 23 | #define TFT_CS PA2 24 | #define TFT_DC PA1 25 | #define TFT_RST PA0 26 | //#include 27 | #else 28 | #define TFT_CS 10 29 | #define TFT_DC 8 30 | #define TFT_RST 9 31 | #include 32 | //#include 33 | #endif 34 | 35 | ILI9341 tft = ILI9341(TFT_DC, TFT_RST, TFT_CS); 36 | //Adafruit_ILI9341 tft = Adafruit_ILI9341( TFT_CS, TFT_DC, TFT_RST); 37 | 38 | // Color definitions 39 | #define BLACK 0x0000 40 | #define BLUE 0x001F 41 | #define RED 0xF800 42 | #define GREEN 0x07E0 43 | #define CYAN 0x07FF 44 | #define MAGENTA 0xF81F 45 | #define YELLOW 0xFFE0 46 | #define WHITE 0xFFFF 47 | #define RGBto565(r,g,b) ((((r) & 0xF8) << 8) | (((g) & 0xFC) << 3) | ((b) >> 3)) 48 | 49 | 50 | // ------------------------------------------------ 51 | unsigned long FillScreenTest() 52 | { 53 | unsigned long start = millis(); 54 | for(int i=0;i<5;i++) { 55 | tft.fillScreen(RED); 56 | tft.fillScreen(GREEN); 57 | tft.fillScreen(BLUE); 58 | tft.fillScreen(YELLOW); 59 | } 60 | return millis()-start; 61 | } 62 | 63 | // ------------------------------------------------ 64 | unsigned long ClearScreenTest() 65 | { 66 | unsigned long start = millis(); 67 | for(int i=0;i<5*4;i++) 68 | tft.fillScreen(BLACK); 69 | return millis()-start; 70 | } 71 | // ------------------------------------------------ 72 | const uint16_t imgF[] PROGMEM = {0xF800,0xF840,0xF8A0,0xF900,0xF960,0xF9C0,0xFA20,0xFA80,0xFAE0,0xFB40,0xFBA0,0xFC00,0xFC60,0xFCC0,0xFD20,0xFD80,0xFDE0,0xFE40,0xFEA0,0xFF00,0xFF60,0xFFC0,0xFFE0,0xEFE0,0xE7E0,0xD7E0,0xCFE0,0xBFE0,0xB7E0,0xA7E0,0x9FE0,0x8FE0,0x87E0,0x77E0,0x6FE0,0x5FE0,0x57E0,0x47E0,0x3FE0,0x2FE0,0x27E0,0x17E0,0xFE0,0x7E0,0x7E1,0x7E3,0x7E4,0x7E6,0x7E7,0x7E9,0x7EA,0x7EC,0x7ED,0x7EF,0x7F0,0x7F2,0x7F3,0x7F5,0x7F6,0x7F8,0x7F9,0x7FB,0x7FC,0x7FE,0x7FF,0x79F,0x73F,0x6DF,0x67F,0x61F,0x5BF,0x55F,0x4FF,0x49F,0x43F,0x3DF,0x37F,0x31F,0x2BF,0x25F,0x1FF,0x19F,0x13F,0xDF,0x7F,0x1F,0x81F,0x101F,0x201F,0x281F,0x381F,0x401F,0x501F,0x581F,0x681F,0x701F,0x801F,0x881F,0x981F,0xA01F,0xB01F,0xB81F,0xC81F,0xD01F,0xE01F,0xE81F,0xF81F,0xF81F,0xF81D,0xF81C,0xF81A,0xF819,0xF817,0xF816,0xF814,0xF813,0xF811,0xF810,0xF80E,0xF80D,0xF80B,0xF80A,0xF808,0xF807,0xF805,0xF804,0xF802,0xF801, 73 | 0xF800,0xF840,0xF8A0,0xF900,0xF960,0xF9C0,0xFA20,0xFA80,0xFAE0,0xFB40,0xFBA0,0xFC00,0xFC60,0xFCC0,0xFD20,0xFD80,0xFDE0,0xFE40,0xFEA0,0xFF00,0xFF60,0xFFC0,0xFFE0,0xEFE0,0xE7E0,0xD7E0,0xCFE0,0xBFE0,0xB7E0,0xA7E0,0x9FE0,0x8FE0,0x87E0,0x77E0,0x6FE0,0x5FE0,0x57E0,0x47E0,0x3FE0,0x2FE0,0x27E0,0x17E0,0xFE0,0x7E0,0x7E1,0x7E3,0x7E4,0x7E6,0x7E7,0x7E9,0x7EA,0x7EC,0x7ED,0x7EF,0x7F0,0x7F2,0x7F3,0x7F5,0x7F6,0x7F8,0x7F9,0x7FB,0x7FC,0x7FE,0x7FF,0x79F,0x73F,0x6DF,0x67F,0x61F,0x5BF,0x55F,0x4FF,0x49F,0x43F,0x3DF,0x37F,0x31F,0x2BF,0x25F,0x1FF,0x19F,0x13F,0xDF,0x7F,0x1F,0x81F,0x101F,0x201F,0x281F,0x381F,0x401F,0x501F,0x581F,0x681F,0x701F,0x801F,0x881F,0x981F,0xA01F,0xB01F,0xB81F,0xC81F,0xD01F,0xE01F,0xE81F,0xF81F,0xF81F,0xF81D,0xF81C,0xF81A,0xF819,0xF817,0xF816,0xF814,0xF813,0xF811,0xF810,0xF80E,0xF80D,0xF80B,0xF80A,0xF808,0xF807,0xF805,0xF804,0xF802,0xF801}; 74 | uint16_t img[SCR_WD+16]; 75 | unsigned long DrawImageTest() 76 | { 77 | for(int i=0;i>2)+i)&0xf)); 80 | return millis()-start; 81 | } 82 | // ------------------------------------------------ 83 | unsigned long DrawImageFTest() 84 | { 85 | unsigned long start = millis(); 86 | for(int i=0;i<5*4;i++) for(int y=0;y>2)+i)&0xf)); 87 | return millis()-start; 88 | } 89 | // ------------------------------------------------ 90 | unsigned long orig[14]={ 8504,8505,2126420,256356,2364088,179228,119136,4416428,723324,1034904,517836,1835884,388904,4460568 }; 91 | 92 | unsigned long res[14]; 93 | void result(int i) 94 | { 95 | Serial.print(res[i]); 96 | if(res[i]<1000000) Serial.print("\t"); 97 | Serial.print("\t\t\t"); 98 | Serial.print(100*orig[i]/res[i]); 99 | Serial.println("%"); 100 | } 101 | 102 | void setup(void) 103 | { 104 | Serial.begin(9600); 105 | Serial.println(F("ILI9341 240x320")); 106 | tft.begin(); 107 | tft.setRotation(2); 108 | tft.fillScreen(BLACK); 109 | tft.setCursor(0, 0); 110 | tft.setTextColor(WHITE); tft.setTextSize(1); 111 | tft.println("ILI9341 240x320"); 112 | tft.println("Library Benchmark"); 113 | tft.println("starts in 3s ..."); 114 | delay(3000); 115 | 116 | Serial.println(F("Benchmark Time (microseconds)")); 117 | 118 | res[0]=FillScreenTest(); 119 | Serial.print(F("FillScreen Mbps ")); 120 | Serial.println(String(res[0])+"ms "+String(1000*20.0/res[0])+"fps "+String(20.0*SCR_WD*SCR_HT*16/res[0]/1000.0)+" Mbps\t"+100*orig[0]/res[0]+"%"); 121 | 122 | //for(int i=0;i<100;i++) tft.fillRect(i,i,SCR_WD-i*2,SCR_HT-i*2,tft.rgbWheel(i*10)); delay(1000); 123 | 124 | res[1]=ClearScreenTest(); 125 | Serial.print(F("ClearScreen Mbps ")); 126 | Serial.println(String(res[1])+"ms "+String(1000*20.0/res[1])+"fps "+String(20.0*SCR_WD*SCR_HT*16/res[1]/1000.0)+" Mbps\t"+100*orig[1]/res[1]+"%"); 127 | 128 | res[1]=DrawImageTest(); 129 | Serial.print(F("DrawImage Mbps ")); 130 | Serial.println(String(res[1])+"ms "+String(1000*20.0/res[1])+"fps "+String(20.0*SCR_WD*SCR_HT*16/res[1]/1000.0)+" Mbps\t"+100*orig[1]/res[1]+"%"); 131 | 132 | res[1]=DrawImageFTest(); 133 | Serial.print(F("DrawImageF Mbps ")); 134 | Serial.println(String(res[1])+"ms "+String(1000*20.0/res[1])+"fps "+String(20.0*SCR_WD*SCR_HT*16/res[1]/1000.0)+" Mbps\t"+100*orig[1]/res[1]+"%"); 135 | 136 | res[2]=testFillScreen(); 137 | Serial.print(F("Screen fill ")); 138 | result(2); 139 | delay(500); 140 | 141 | res[3]=testText(); 142 | Serial.print(F("Text ")); 143 | result(3); 144 | delay(3000); 145 | 146 | res[4]=testLines(CYAN); 147 | Serial.print(F("Lines ")); 148 | result(4); 149 | delay(500); 150 | 151 | res[5]=testFastLines(RED, BLUE); 152 | Serial.print(F("Horiz/Vert Lines ")); 153 | result(5); 154 | delay(500); 155 | 156 | res[6]=testRects(GREEN); 157 | Serial.print(F("Rectangles (outline) ")); 158 | result(6); 159 | delay(500); 160 | 161 | res[7]=testFilledRects(YELLOW, MAGENTA); 162 | Serial.print(F("Rectangles (filled) ")); 163 | result(7); 164 | delay(500); 165 | 166 | res[8]=testFilledCircles(10, MAGENTA); 167 | Serial.print(F("Circles (filled) ")); 168 | result(8); 169 | 170 | res[9]=testCircles(10, WHITE); 171 | Serial.print(F("Circles (outline) ")); 172 | result(9); 173 | delay(500); 174 | 175 | res[10]=testTriangles(); 176 | Serial.print(F("Triangles (outline) ")); 177 | result(10); 178 | delay(500); 179 | 180 | res[11]=testFilledTriangles(); 181 | Serial.print(F("Triangles (filled) ")); 182 | result(11); 183 | delay(500); 184 | 185 | res[12]=testRoundRects(); 186 | Serial.print(F("Rounded rects (outline) ")); 187 | result(12); 188 | delay(500); 189 | 190 | res[13]=testFilledRoundRects(); 191 | Serial.print(F("Rounded rects (filled) ")); 192 | result(13); 193 | delay(500); 194 | 195 | Serial.println(F("Done!")); 196 | Serial.println(F("Results:")); 197 | for(int i=0;i<14;i++) { Serial.print(res[i]); Serial.print(","); } 198 | Serial.println(); 199 | 200 | int c1=YELLOW, c2=WHITE; 201 | tft.fillScreen(BLACK); 202 | tft.setCursor(0, 0); 203 | tft.setTextSize(2); 204 | tft.setTextColor(CYAN); 205 | tft.println("RESULTS:"); 206 | 207 | tft.setTextSize(1); 208 | tft.println(); 209 | tft.setTextColor(GREEN); 210 | tft.println(F("Benchmark Time/us")); 211 | tft.setTextColor(c1); tft.print(F("FillScr Mbps ")); 212 | tft.setTextColor(c2); tft.println(String(res[0])+"ms "+String(20.0*SCR_WD*SCR_HT*16/res[0]/1000.0)+" Mbps"); 213 | //tft.setTextColor(c2); tft.println(String(20.0*SCR_WD*SCR_HT*16/res[0]/1000.0)); 214 | //tft.setTextColor(c1); tft.print(F("ClrScr ")); 215 | //tft.setTextColor(c2); tft.println(String(res[1])+"ms "+String(20.0*SCR_WD*SCR_HT*16/res[1]/1000.0)+" Mbps"); 216 | //tft.setTextColor(c2); tft.println(String(20.0*SCR_WD*SCR_HT*16/res[1]/1000.0)); 217 | tft.setTextColor(c1); tft.print(F("DrwImgF Mbps ")); 218 | tft.setTextColor(c2); tft.println(String(res[1])+"ms "+String(20.0*SCR_WD*SCR_HT*16/res[1]/1000.0)+" Mbps"); 219 | //tft.setTextColor(c2); tft.println(String(20.0*SCR_WD*SCR_HT*16/res[1]/1000.0)); 220 | 221 | tft.setTextColor(c1); tft.print(F("Screen fill ")); 222 | tft.setTextColor(c2); tft.println(res[2]); 223 | tft.setTextColor(c1); tft.print(F("Text ")); 224 | tft.setTextColor(c2); tft.println(res[3]); 225 | tft.setTextColor(c1); tft.print(F("Lines ")); 226 | tft.setTextColor(c2); tft.println(res[4]); 227 | tft.setTextColor(c1); tft.print(F("H/V Lines ")); 228 | tft.setTextColor(c2); tft.println(res[5]); 229 | tft.setTextColor(c1); tft.print(F("Rects O ")); 230 | tft.setTextColor(c2); tft.println(res[6]); 231 | tft.setTextColor(c1); tft.print(F("Rects F ")); 232 | tft.setTextColor(c2); tft.println(res[7]); 233 | tft.setTextColor(c1); tft.print(F("Circles F ")); 234 | tft.setTextColor(c2); tft.println(res[8]); 235 | tft.setTextColor(c1); tft.print(F("Circles O ")); 236 | tft.setTextColor(c2); tft.println(res[9]); 237 | tft.setTextColor(c1); tft.print(F("Tris O ")); 238 | tft.setTextColor(c2); tft.println(res[10]); 239 | tft.setTextColor(c1); tft.print(F("Tris F ")); 240 | tft.setTextColor(c2); tft.println(res[11]); 241 | tft.setTextColor(c1); tft.print(F("Round rects O ")); 242 | tft.setTextColor(c2); tft.println(res[12]); 243 | tft.setTextColor(c1); tft.print(F("Round rects F ")); 244 | tft.setTextColor(c2); tft.println(res[13]); 245 | tft.setTextColor(RED); tft.println(F("Done!")); 246 | } 247 | 248 | /* 249 | 250 | --- below + back to old drawPixel 251 | ILI9341 240x320 252 | Benchmark Time (microseconds) 253 | FillScreen Mbps 3477ms 5.75fps 7.07 Mbps 244% 254 | ClearScreen Mbps 3478ms 5.75fps 7.07 Mbps 244% 255 | DrawImage Mbps 3675ms 5.44fps 6.69 Mbps 231% 256 | DrawImageF Mbps 4804ms 4.16fps 5.12 Mbps 177% 257 | Screen fill 869880 244% 258 | Text 120580 212% ++ 259 | Lines 895560 263% ++ 260 | Horiz/Vert Lines 72956 245% 261 | Rectangles (outline) 48552 245% 262 | Rectangles (filled) 1805836 244% 263 | Circles (filled) 294596 245% 264 | Circles (outline) 389072 265% + 265 | Triangles (outline) 196984 262% + 266 | Triangles (filled) 891104 206% 267 | Rounded rects (outline) 150336 258% + 268 | Rounded rects (filled) 1824904 244% 269 | Done! 270 | Results: 271 | 3477,4804,869880,120580,895560,72956,48552,1805836,294596,389072,196984,891104,150336,1824904, 272 | 273 | --- below + opt setAddrWindow + writeMulti 274 | ILI9341 240x320 275 | Benchmark Time (microseconds) 276 | FillScreen Mbps 3478ms 5.75fps 7.07 Mbps 244% 277 | ClearScreen Mbps 3479ms 5.75fps 7.06 Mbps 244% 278 | DrawImage Mbps 3675ms 5.44fps 6.69 Mbps 231% 279 | DrawImageF Mbps 4804ms 4.16fps 5.12 Mbps 177% 280 | Screen fill 869884 244% 281 | Text 121828 210% 282 | Lines 913776 258% 283 | Horiz/Vert Lines 72960 245% 284 | Rectangles (outline) 48552 245% 285 | Rectangles (filled) 1805840 244% 286 | Circles (filled) 294596 245% 287 | Circles (outline) 396932 260% 288 | Triangles (outline) 200828 257% 289 | Triangles (filled) 891092 206% 290 | Rounded rects (outline) 152616 254% 291 | Rounded rects (filled) 1824908 244% 292 | Done! 293 | 294 | 295 | --- Fast AVR + writeMulti + copyMulti: 296 | 297 | ILI9341 240x320 298 | Benchmark Time (microseconds) 299 | FillScreen Mbps 3477ms 5.75fps 7.07 Mbps 244% 300 | ClearScreen Mbps 3478ms 5.75fps 7.07 Mbps 244% 301 | DrawImage Mbps 3695ms 5.41fps 6.65 Mbps 230% 302 | DrawImageF Mbps 4826ms 4.14fps 5.09 Mbps 176% 303 | Screen fill 869904 244% 304 | Text 128088 200% 305 | Lines 983324 240% 306 | Horiz/Vert Lines 73324 244% 307 | Rectangles (outline) 49064 242% 308 | Rectangles (filled) 1805948 244% 309 | Circles (filled) 307728 235% 310 | Circles (outline) 427460 242% 311 | Triangles (outline) 215620 240% 312 | Triangles (filled) 900716 203% 313 | Rounded rects (outline) 161828 240% 314 | Rounded rects (filled) 1828932 243% 315 | Done! 316 | 317 | 318 | --- Fast AVR + writeMulti: 319 | 320 | ILI9341 240x320 321 | Benchmark Time (microseconds) 322 | FillScreen Mbps 3477ms 5.75fps 7.07 Mbps 244% 323 | ClearScreen Mbps 3478ms 5.75fps 7.07 Mbps 244% 324 | DrawImage Mbps 4090ms 4.89fps 6.01 Mbps 207% 325 | DrawImageF Mbps 4827ms 4.14fps 5.09 Mbps 176% 326 | Screen fill 869904 244% 327 | Text 128088 200% 328 | Lines 983324 240% 329 | Horiz/Vert Lines 73316 244% 330 | Rectangles (outline) 49072 242% 331 | Rectangles (filled) 1805992 244% 332 | Circles (filled) 307724 235% 333 | Circles (outline) 427468 242% 334 | Triangles (outline) 215612 240% 335 | Triangles (filled) 900708 203% 336 | Rounded rects (outline) 161828 240% 337 | Rounded rects (filled) 1828932 243% 338 | Done! 339 | 340 | 341 | --- Fast AVR old: 342 | 343 | ILI9341 240x320 344 | Benchmark Time (microseconds) 345 | FillScreen Mbps 3532ms 5.66fps 6.96 Mbps 240% 346 | ClearScreen Mbps 3533ms 5.66fps 6.96 Mbps 240% 347 | DrawImage Mbps 4090ms 4.89fps 6.01 Mbps 207% 348 | DrawImageF Mbps 4826ms 4.14fps 5.09 Mbps 176% 349 | Screen fill 883488 240% 350 | Text 129780 197% 351 | Lines 983324 240% 352 | Horiz/Vert Lines 75212 238% 353 | Rectangles (outline) 50532 235% 354 | Rectangles (filled) 1834220 240% 355 | Circles (filled) 323312 223% 356 | Circles (outline) 427460 242% 357 | Triangles (outline) 215844 239% 358 | Triangles (filled) 922416 199% 359 | Rounded rects (outline) 163016 238% 360 | Rounded rects (filled) 1863564 239% 361 | Done! 362 | 363 | --- Fast in COMPATIBILITY mode - new: 364 | 365 | ILI9341 240x320 366 | Benchmark Time (microseconds) 367 | FillScreen Mbps 7149ms 2.80fps 3.44 Mbps 118% 368 | ClearScreen Mbps 7148ms 2.80fps 3.44 Mbps 118% 369 | DrawImage Mbps 6982ms 2.86fps 3.52 Mbps 121% 370 | DrawImageF Mbps 7716ms 2.59fps 3.19 Mbps 110% 371 | Screen fill 1787472 118% 372 | Text 279244 91% 373 | Lines 2637368 89% 374 | Horiz/Vert Lines 153764 116% 375 | Rectangles (outline) 104672 113% 376 | Rectangles (filled) 3712456 118% 377 | Circles (filled) 721304 100% 378 | Circles (outline) 1151040 89% 379 | Triangles (outline) 573508 90% 380 | Triangles (filled) 1664728 110% 381 | Rounded rects (outline) 412532 94% 382 | Rounded rects (filled) 3783184 117% 383 | Done! 384 | 385 | --- Fast in COMPATIBILITY mode - old: 386 | 387 | ILI9341 240x320 388 | Benchmark Time (microseconds) 389 | FillScreen Mbps 6044ms 3.31fps 4.07 Mbps 140% 390 | ClearScreen Mbps 6044ms 3.31fps 4.07 Mbps 140% 391 | DrawImage Mbps 6980ms 2.87fps 3.52 Mbps 121% 392 | DrawImageF Mbps 7714ms 2.59fps 3.19 Mbps 110% 393 | Screen fill 1511196 140% 394 | Text 276932 92% 395 | Lines 2637380 89% 396 | Horiz/Vert Lines 132280 135% 397 | Rectangles (outline) 91440 130% 398 | Rectangles (filled) 3138956 140% 399 | Circles (filled) 678416 106% 400 | Circles (outline) 1151036 89% 401 | Triangles (outline) 571576 90% 402 | Triangles (filled) 1498052 122% 403 | Rounded rects (outline) 402724 96% 404 | Rounded rects (filled) 3222412 138% 405 | Done! 406 | 407 | --- Original Adafruit: 408 | 409 | ILI9341 240x320 410 | Benchmark Time (microseconds) 411 | FillScreen Mbps 8504ms 2.35fps 2.89 Mbps 100% 412 | ClearScreen Mbps 8505ms 2.35fps 2.89 Mbps 0% 413 | DrawImage Mbps 8505ms 2.35fps 2.89 Mbps 0% 414 | DrawImageF Mbps 8505ms 2.35fps 2.89 Mbps 0% 415 | Screen fill 2126432 99% 416 | Text 256364 99% 417 | Lines 2364076 100% 418 | Horiz/Vert Lines 179228 100% 419 | Rectangles (outline) 119144 99% 420 | Rectangles (filled) 4416444 99% 421 | Circles (filled) 723332 99% 422 | Circles (outline) 1034928 99% 423 | Triangles (outline) 517836 100% 424 | Triangles (filled) 1835860 100% 425 | Rounded rects (outline) 388900 100% 426 | Rounded rects (filled) 4460552 100% 427 | Done! 428 | 429 | */ 430 | 431 | 432 | // ------------------------------------------------ 433 | 434 | void loop(void) 435 | { 436 | } 437 | 438 | // ------------------------------------------------ 439 | 440 | unsigned long testFillScreen() { 441 | unsigned long start = micros(); 442 | //for (uint8_t i = 0; i < 12; i++) { 443 | tft.fillScreen(BLACK); 444 | tft.fillScreen(RED); 445 | tft.fillScreen(GREEN); 446 | tft.fillScreen(BLUE); 447 | tft.fillScreen(BLACK); 448 | //} 449 | return micros() - start; 450 | } 451 | 452 | // ------------------------------------------------ 453 | unsigned long testText() { 454 | tft.fillScreen(BLACK); 455 | unsigned long start = micros(); 456 | tft.setCursor(0, 0); 457 | tft.setTextColor(WHITE); tft.setTextSize(1); 458 | tft.println("Hello World!"); 459 | tft.setTextColor(YELLOW); tft.setTextSize(2); 460 | tft.println(1234.56); 461 | tft.setTextColor(RED); tft.setTextSize(3); 462 | tft.println(0xDEADBEEF, HEX); 463 | tft.println(); 464 | tft.setTextColor(GREEN); 465 | tft.setTextSize(5); 466 | tft.println("Groop"); 467 | tft.setTextSize(2); 468 | tft.println("I implore thee,"); 469 | tft.setTextSize(1); 470 | tft.println("my foonting turlingdromes."); 471 | tft.println("And hooptiously drangle me"); 472 | tft.println("with crinkly bindlewurdles,"); 473 | tft.println("Or I will rend thee"); 474 | tft.println("in the gobberwarts"); 475 | tft.println("with my blurglecruncheon,"); 476 | tft.println("see if I don't!"); 477 | return micros() - start; 478 | } 479 | 480 | // ------------------------------------------------ 481 | unsigned long testLines(uint16_t color) { 482 | unsigned long start, t; 483 | int x1, y1, x2, y2, 484 | w = tft.width(), 485 | h = tft.height(); 486 | 487 | tft.fillScreen(BLACK); 488 | 489 | x1 = y1 = 0; 490 | y2 = h - 1; 491 | start = micros(); 492 | for(x2=0; x20; i-=6) { 573 | i2 = i / 2; 574 | start = micros(); 575 | tft.fillRect(cx-i2, cy-i2, i, i, color1); 576 | t += micros() - start; 577 | // Outlines are not included in timing results 578 | tft.drawRect(cx-i2, cy-i2, i, i, color2); 579 | } 580 | 581 | return t; 582 | } 583 | 584 | // ------------------------------------------------ 585 | unsigned long testFilledCircles(uint8_t radius, uint16_t color) { 586 | unsigned long start; 587 | int x, y, w = tft.width(), h = tft.height(), r2 = radius * 2; 588 | 589 | tft.fillScreen(BLACK); 590 | start = micros(); 591 | for(x=radius; x10; i-=5) { 648 | start = micros(); 649 | tft.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i, 650 | RGBto565(0, i, i)); 651 | t += micros() - start; 652 | tft.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i, 653 | RGBto565(i, i, 0)); 654 | } 655 | 656 | return t; 657 | } 658 | 659 | // ------------------------------------------------ 660 | unsigned long testRoundRects() { 661 | unsigned long start; 662 | int w, i, i2, 663 | cx = tft.width() / 2 - 1, 664 | cy = tft.height() / 2 - 1; 665 | 666 | tft.fillScreen(BLACK); 667 | w = min(tft.width(), tft.height()); 668 | start = micros(); 669 | for(i=0; i20; i-=6) { 687 | i2 = i / 2; 688 | tft.fillRoundRect(cx-i2, cy-i2, i, i, i/8, RGBto565(0, i, 0)); 689 | } 690 | 691 | return micros() - start; 692 | } 693 | // ------------------------------------------------ 694 | 695 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------