This is our GFX example for the Adafruit ILI9341 Breakout and Shield ----> http://www.adafruit.com/products/1651 Check out the links above for our tutorials and wiring diagrams These displays use SPI to communicate, 4 or 5 pins are required to interface (RST is optional) Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit! Written by Limor Fried/Ladyada for Adafruit Industries. MIT license, all text above must be included in any redistribution
Dependencies: Adafruit_GFX_MBED Adafruit_ILI9341 BurstSPI mbed
main.cpp@0:0697cb7bb5a1, 2014-12-05 (annotated)
- Committer:
- infotech1
- Date:
- Fri Dec 05 06:47:40 2014 +0000
- Revision:
- 0:0697cb7bb5a1
- Child:
- 1:ad0604ca8377
Initial commit, displays benchmark stats over Serial.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
infotech1 | 0:0697cb7bb5a1 | 1 | #include "mbed.h" |
infotech1 | 0:0697cb7bb5a1 | 2 | #include "Adafruit_ILI9341.h" |
infotech1 | 0:0697cb7bb5a1 | 3 | // Change to your dc/cs/rst pins |
infotech1 | 0:0697cb7bb5a1 | 4 | Adafruit_ILI9341 tft = Adafruit_ILI9341(D10,D9,D8); |
infotech1 | 0:0697cb7bb5a1 | 5 | |
infotech1 | 0:0697cb7bb5a1 | 6 | Serial pc(SERIAL_TX,SERIAL_RX); |
infotech1 | 0:0697cb7bb5a1 | 7 | |
infotech1 | 0:0697cb7bb5a1 | 8 | Timer t; |
infotech1 | 0:0697cb7bb5a1 | 9 | |
infotech1 | 0:0697cb7bb5a1 | 10 | int min(int x, int y) { |
infotech1 | 0:0697cb7bb5a1 | 11 | if(x > y) |
infotech1 | 0:0697cb7bb5a1 | 12 | return y; |
infotech1 | 0:0697cb7bb5a1 | 13 | return x; |
infotech1 | 0:0697cb7bb5a1 | 14 | } |
infotech1 | 0:0697cb7bb5a1 | 15 | |
infotech1 | 0:0697cb7bb5a1 | 16 | int testFillScreen() { |
infotech1 | 0:0697cb7bb5a1 | 17 | tft.fillScreen(ILI9341_BLACK); |
infotech1 | 0:0697cb7bb5a1 | 18 | tft.fillScreen(ILI9341_RED); |
infotech1 | 0:0697cb7bb5a1 | 19 | tft.fillScreen(ILI9341_GREEN); |
infotech1 | 0:0697cb7bb5a1 | 20 | tft.fillScreen(ILI9341_BLUE); |
infotech1 | 0:0697cb7bb5a1 | 21 | tft.fillScreen(ILI9341_BLACK); |
infotech1 | 0:0697cb7bb5a1 | 22 | return 1; |
infotech1 | 0:0697cb7bb5a1 | 23 | } |
infotech1 | 0:0697cb7bb5a1 | 24 | |
infotech1 | 0:0697cb7bb5a1 | 25 | int testText() { |
infotech1 | 0:0697cb7bb5a1 | 26 | tft.fillScreen(ILI9341_BLACK); |
infotech1 | 0:0697cb7bb5a1 | 27 | unsigned long start = t.read_ms(); |
infotech1 | 0:0697cb7bb5a1 | 28 | tft.setCursor(0, 0); |
infotech1 | 0:0697cb7bb5a1 | 29 | tft.setTextColor(ILI9341_WHITE); tft.setTextSize(1); |
infotech1 | 0:0697cb7bb5a1 | 30 | tft.print("Hello World!"); |
infotech1 | 0:0697cb7bb5a1 | 31 | tft.setTextColor(ILI9341_YELLOW); tft.setTextSize(2); |
infotech1 | 0:0697cb7bb5a1 | 32 | tft.print(1234.56); |
infotech1 | 0:0697cb7bb5a1 | 33 | tft.setTextColor(ILI9341_RED); tft.setTextSize(3); |
infotech1 | 0:0697cb7bb5a1 | 34 | tft.print(0xDEADBEEF, 16); |
infotech1 | 0:0697cb7bb5a1 | 35 | tft.println(); |
infotech1 | 0:0697cb7bb5a1 | 36 | tft.setTextColor(ILI9341_GREEN); |
infotech1 | 0:0697cb7bb5a1 | 37 | tft.setTextSize(5); |
infotech1 | 0:0697cb7bb5a1 | 38 | tft.print("Groop"); |
infotech1 | 0:0697cb7bb5a1 | 39 | tft.setTextSize(2); |
infotech1 | 0:0697cb7bb5a1 | 40 | tft.print("I implore thee,"); |
infotech1 | 0:0697cb7bb5a1 | 41 | tft.setTextSize(1); |
infotech1 | 0:0697cb7bb5a1 | 42 | tft.print("my foonting turlingdromes."); |
infotech1 | 0:0697cb7bb5a1 | 43 | tft.print("And hooptiously drangle me"); |
infotech1 | 0:0697cb7bb5a1 | 44 | tft.print("with crinkly bindlewurdles,"); |
infotech1 | 0:0697cb7bb5a1 | 45 | tft.print("Or I will rend thee"); |
infotech1 | 0:0697cb7bb5a1 | 46 | tft.print("in the gobberwarts"); |
infotech1 | 0:0697cb7bb5a1 | 47 | tft.print("with my blurglecruncheon,"); |
infotech1 | 0:0697cb7bb5a1 | 48 | tft.print("see if I don't!"); |
infotech1 | 0:0697cb7bb5a1 | 49 | return t.read_ms() - start; |
infotech1 | 0:0697cb7bb5a1 | 50 | } |
infotech1 | 0:0697cb7bb5a1 | 51 | |
infotech1 | 0:0697cb7bb5a1 | 52 | int testLines(uint16_t color) { |
infotech1 | 0:0697cb7bb5a1 | 53 | unsigned long start, tt; |
infotech1 | 0:0697cb7bb5a1 | 54 | int x1, y1, x2, y2, |
infotech1 | 0:0697cb7bb5a1 | 55 | w = tft.width(), |
infotech1 | 0:0697cb7bb5a1 | 56 | h = tft.height(); |
infotech1 | 0:0697cb7bb5a1 | 57 | |
infotech1 | 0:0697cb7bb5a1 | 58 | tft.fillScreen(ILI9341_BLACK); |
infotech1 | 0:0697cb7bb5a1 | 59 | |
infotech1 | 0:0697cb7bb5a1 | 60 | x1 = y1 = 0; |
infotech1 | 0:0697cb7bb5a1 | 61 | y2 = h - 1; |
infotech1 | 0:0697cb7bb5a1 | 62 | start = t.read_ms(); |
infotech1 | 0:0697cb7bb5a1 | 63 | for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color); |
infotech1 | 0:0697cb7bb5a1 | 64 | x2 = w - 1; |
infotech1 | 0:0697cb7bb5a1 | 65 | for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color); |
infotech1 | 0:0697cb7bb5a1 | 66 | tt = 1; // fillScreen doesn't count against timing |
infotech1 | 0:0697cb7bb5a1 | 67 | |
infotech1 | 0:0697cb7bb5a1 | 68 | tft.fillScreen(ILI9341_BLACK); |
infotech1 | 0:0697cb7bb5a1 | 69 | |
infotech1 | 0:0697cb7bb5a1 | 70 | x1 = w - 1; |
infotech1 | 0:0697cb7bb5a1 | 71 | y1 = 0; |
infotech1 | 0:0697cb7bb5a1 | 72 | y2 = h - 1; |
infotech1 | 0:0697cb7bb5a1 | 73 | start = 1; |
infotech1 | 0:0697cb7bb5a1 | 74 | for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color); |
infotech1 | 0:0697cb7bb5a1 | 75 | x2 = 0; |
infotech1 | 0:0697cb7bb5a1 | 76 | for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color); |
infotech1 | 0:0697cb7bb5a1 | 77 | tt += 1; |
infotech1 | 0:0697cb7bb5a1 | 78 | |
infotech1 | 0:0697cb7bb5a1 | 79 | tft.fillScreen(ILI9341_BLACK); |
infotech1 | 0:0697cb7bb5a1 | 80 | |
infotech1 | 0:0697cb7bb5a1 | 81 | x1 = 0; |
infotech1 | 0:0697cb7bb5a1 | 82 | y1 = h - 1; |
infotech1 | 0:0697cb7bb5a1 | 83 | y2 = 0; |
infotech1 | 0:0697cb7bb5a1 | 84 | start = 1; |
infotech1 | 0:0697cb7bb5a1 | 85 | for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color); |
infotech1 | 0:0697cb7bb5a1 | 86 | x2 = w - 1; |
infotech1 | 0:0697cb7bb5a1 | 87 | for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color); |
infotech1 | 0:0697cb7bb5a1 | 88 | tt += 1; |
infotech1 | 0:0697cb7bb5a1 | 89 | |
infotech1 | 0:0697cb7bb5a1 | 90 | tft.fillScreen(ILI9341_BLACK); |
infotech1 | 0:0697cb7bb5a1 | 91 | |
infotech1 | 0:0697cb7bb5a1 | 92 | x1 = w - 1; |
infotech1 | 0:0697cb7bb5a1 | 93 | y1 = h - 1; |
infotech1 | 0:0697cb7bb5a1 | 94 | y2 = 0; |
infotech1 | 0:0697cb7bb5a1 | 95 | start = 1; |
infotech1 | 0:0697cb7bb5a1 | 96 | for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color); |
infotech1 | 0:0697cb7bb5a1 | 97 | x2 = 0; |
infotech1 | 0:0697cb7bb5a1 | 98 | for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color); |
infotech1 | 0:0697cb7bb5a1 | 99 | |
infotech1 | 0:0697cb7bb5a1 | 100 | return t.read_ms() - start; |
infotech1 | 0:0697cb7bb5a1 | 101 | } |
infotech1 | 0:0697cb7bb5a1 | 102 | |
infotech1 | 0:0697cb7bb5a1 | 103 | int testFastLines(uint16_t color1, uint16_t color2) { |
infotech1 | 0:0697cb7bb5a1 | 104 | unsigned long start; |
infotech1 | 0:0697cb7bb5a1 | 105 | int x, y, w = tft.width(), h = tft.height(); |
infotech1 | 0:0697cb7bb5a1 | 106 | |
infotech1 | 0:0697cb7bb5a1 | 107 | tft.fillScreen(ILI9341_BLACK); |
infotech1 | 0:0697cb7bb5a1 | 108 | start = t.read_ms(); |
infotech1 | 0:0697cb7bb5a1 | 109 | for(y=0; y<h; y+=5) tft.drawFastHLine(0, y, w, color1); |
infotech1 | 0:0697cb7bb5a1 | 110 | for(x=0; x<w; x+=5) tft.drawFastVLine(x, 0, h, color2); |
infotech1 | 0:0697cb7bb5a1 | 111 | |
infotech1 | 0:0697cb7bb5a1 | 112 | return t.read_ms() - start; |
infotech1 | 0:0697cb7bb5a1 | 113 | } |
infotech1 | 0:0697cb7bb5a1 | 114 | |
infotech1 | 0:0697cb7bb5a1 | 115 | int testRects(uint16_t color) { |
infotech1 | 0:0697cb7bb5a1 | 116 | unsigned long start; |
infotech1 | 0:0697cb7bb5a1 | 117 | int n, i, i2, |
infotech1 | 0:0697cb7bb5a1 | 118 | cx = tft.width() / 2, |
infotech1 | 0:0697cb7bb5a1 | 119 | cy = tft.height() / 2; |
infotech1 | 0:0697cb7bb5a1 | 120 | |
infotech1 | 0:0697cb7bb5a1 | 121 | tft.fillScreen(ILI9341_BLACK); |
infotech1 | 0:0697cb7bb5a1 | 122 | n = min(tft.width(), tft.height()); |
infotech1 | 0:0697cb7bb5a1 | 123 | start = t.read_ms(); |
infotech1 | 0:0697cb7bb5a1 | 124 | for(i=2; i<n; i+=6) { |
infotech1 | 0:0697cb7bb5a1 | 125 | i2 = i / 2; |
infotech1 | 0:0697cb7bb5a1 | 126 | tft.drawRect(cx-i2, cy-i2, i, i, color); |
infotech1 | 0:0697cb7bb5a1 | 127 | } |
infotech1 | 0:0697cb7bb5a1 | 128 | |
infotech1 | 0:0697cb7bb5a1 | 129 | return t.read_ms() - start; |
infotech1 | 0:0697cb7bb5a1 | 130 | } |
infotech1 | 0:0697cb7bb5a1 | 131 | |
infotech1 | 0:0697cb7bb5a1 | 132 | int testFilledRects(uint16_t color1, uint16_t color2) { |
infotech1 | 0:0697cb7bb5a1 | 133 | unsigned long start, tt = 0; |
infotech1 | 0:0697cb7bb5a1 | 134 | int n, i, i2, |
infotech1 | 0:0697cb7bb5a1 | 135 | cx = tft.width() / 2 - 1, |
infotech1 | 0:0697cb7bb5a1 | 136 | cy = tft.height() / 2 - 1; |
infotech1 | 0:0697cb7bb5a1 | 137 | |
infotech1 | 0:0697cb7bb5a1 | 138 | tft.fillScreen(ILI9341_BLACK); |
infotech1 | 0:0697cb7bb5a1 | 139 | n = min(tft.width(), tft.height()); |
infotech1 | 0:0697cb7bb5a1 | 140 | start = t.read_ms(); |
infotech1 | 0:0697cb7bb5a1 | 141 | for(i=n; i>0; i-=6) { |
infotech1 | 0:0697cb7bb5a1 | 142 | i2 = i / 2; |
infotech1 | 0:0697cb7bb5a1 | 143 | start = 1; |
infotech1 | 0:0697cb7bb5a1 | 144 | tft.fillRect(cx-i2, cy-i2, i, i, color1); |
infotech1 | 0:0697cb7bb5a1 | 145 | tt += 1; |
infotech1 | 0:0697cb7bb5a1 | 146 | // Outlines are not included in timing results |
infotech1 | 0:0697cb7bb5a1 | 147 | tft.drawRect(cx-i2, cy-i2, i, i, color2); |
infotech1 | 0:0697cb7bb5a1 | 148 | } |
infotech1 | 0:0697cb7bb5a1 | 149 | |
infotech1 | 0:0697cb7bb5a1 | 150 | return t.read_ms() - start; |
infotech1 | 0:0697cb7bb5a1 | 151 | } |
infotech1 | 0:0697cb7bb5a1 | 152 | |
infotech1 | 0:0697cb7bb5a1 | 153 | int testFilledCircles(uint8_t radius, uint16_t color) { |
infotech1 | 0:0697cb7bb5a1 | 154 | unsigned long start; |
infotech1 | 0:0697cb7bb5a1 | 155 | int x, y, w = tft.width(), h = tft.height(), r2 = radius * 2; |
infotech1 | 0:0697cb7bb5a1 | 156 | |
infotech1 | 0:0697cb7bb5a1 | 157 | tft.fillScreen(ILI9341_BLACK); |
infotech1 | 0:0697cb7bb5a1 | 158 | start = t.read_ms(); |
infotech1 | 0:0697cb7bb5a1 | 159 | for(x=radius; x<w; x+=r2) { |
infotech1 | 0:0697cb7bb5a1 | 160 | for(y=radius; y<h; y+=r2) { |
infotech1 | 0:0697cb7bb5a1 | 161 | tft.fillCircle(x, y, radius, color); |
infotech1 | 0:0697cb7bb5a1 | 162 | } |
infotech1 | 0:0697cb7bb5a1 | 163 | } |
infotech1 | 0:0697cb7bb5a1 | 164 | |
infotech1 | 0:0697cb7bb5a1 | 165 | return t.read_ms() - start; |
infotech1 | 0:0697cb7bb5a1 | 166 | } |
infotech1 | 0:0697cb7bb5a1 | 167 | |
infotech1 | 0:0697cb7bb5a1 | 168 | int testCircles(uint8_t radius, uint16_t color) { |
infotech1 | 0:0697cb7bb5a1 | 169 | unsigned long start; |
infotech1 | 0:0697cb7bb5a1 | 170 | int x, y, r2 = radius * 2, |
infotech1 | 0:0697cb7bb5a1 | 171 | w = tft.width() + radius, |
infotech1 | 0:0697cb7bb5a1 | 172 | h = tft.height() + radius; |
infotech1 | 0:0697cb7bb5a1 | 173 | |
infotech1 | 0:0697cb7bb5a1 | 174 | // Screen is not cleared for this one -- this is |
infotech1 | 0:0697cb7bb5a1 | 175 | // intentional and does not affect the reported time. |
infotech1 | 0:0697cb7bb5a1 | 176 | start = t.read_ms(); |
infotech1 | 0:0697cb7bb5a1 | 177 | for(x=0; x<w; x+=r2) { |
infotech1 | 0:0697cb7bb5a1 | 178 | for(y=0; y<h; y+=r2) { |
infotech1 | 0:0697cb7bb5a1 | 179 | tft.drawCircle(x, y, radius, color); |
infotech1 | 0:0697cb7bb5a1 | 180 | } |
infotech1 | 0:0697cb7bb5a1 | 181 | } |
infotech1 | 0:0697cb7bb5a1 | 182 | |
infotech1 | 0:0697cb7bb5a1 | 183 | return t.read_ms() - start; |
infotech1 | 0:0697cb7bb5a1 | 184 | } |
infotech1 | 0:0697cb7bb5a1 | 185 | |
infotech1 | 0:0697cb7bb5a1 | 186 | int testTriangles() { |
infotech1 | 0:0697cb7bb5a1 | 187 | unsigned long start; |
infotech1 | 0:0697cb7bb5a1 | 188 | int n, i, cx = tft.width() / 2 - 1, |
infotech1 | 0:0697cb7bb5a1 | 189 | cy = tft.height() / 2 - 1; |
infotech1 | 0:0697cb7bb5a1 | 190 | |
infotech1 | 0:0697cb7bb5a1 | 191 | tft.fillScreen(ILI9341_BLACK); |
infotech1 | 0:0697cb7bb5a1 | 192 | n = min(cx, cy); |
infotech1 | 0:0697cb7bb5a1 | 193 | start = t.read_ms(); |
infotech1 | 0:0697cb7bb5a1 | 194 | for(i=0; i<n; i+=5) { |
infotech1 | 0:0697cb7bb5a1 | 195 | tft.drawTriangle( |
infotech1 | 0:0697cb7bb5a1 | 196 | cx , cy - i, // peak |
infotech1 | 0:0697cb7bb5a1 | 197 | cx - i, cy + i, // bottom left |
infotech1 | 0:0697cb7bb5a1 | 198 | cx + i, cy + i, // bottom right |
infotech1 | 0:0697cb7bb5a1 | 199 | tft.color565(0, 0, i)); |
infotech1 | 0:0697cb7bb5a1 | 200 | } |
infotech1 | 0:0697cb7bb5a1 | 201 | |
infotech1 | 0:0697cb7bb5a1 | 202 | return t.read_ms() - start; |
infotech1 | 0:0697cb7bb5a1 | 203 | } |
infotech1 | 0:0697cb7bb5a1 | 204 | |
infotech1 | 0:0697cb7bb5a1 | 205 | int testFilledTriangles() { |
infotech1 | 0:0697cb7bb5a1 | 206 | unsigned long start, tt = 0; |
infotech1 | 0:0697cb7bb5a1 | 207 | int i, cx = tft.width() / 2 - 1, |
infotech1 | 0:0697cb7bb5a1 | 208 | cy = tft.height() / 2 - 1; |
infotech1 | 0:0697cb7bb5a1 | 209 | |
infotech1 | 0:0697cb7bb5a1 | 210 | tft.fillScreen(ILI9341_BLACK); |
infotech1 | 0:0697cb7bb5a1 | 211 | start = t.read_ms(); |
infotech1 | 0:0697cb7bb5a1 | 212 | for(i=min(cx,cy); i>10; i-=5) { |
infotech1 | 0:0697cb7bb5a1 | 213 | start = 1; |
infotech1 | 0:0697cb7bb5a1 | 214 | tft.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i, |
infotech1 | 0:0697cb7bb5a1 | 215 | tft.color565(0, i, i)); |
infotech1 | 0:0697cb7bb5a1 | 216 | tt += 1; |
infotech1 | 0:0697cb7bb5a1 | 217 | tft.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i, |
infotech1 | 0:0697cb7bb5a1 | 218 | tft.color565(i, i, 0)); |
infotech1 | 0:0697cb7bb5a1 | 219 | } |
infotech1 | 0:0697cb7bb5a1 | 220 | |
infotech1 | 0:0697cb7bb5a1 | 221 | return t.read_ms() - start; |
infotech1 | 0:0697cb7bb5a1 | 222 | } |
infotech1 | 0:0697cb7bb5a1 | 223 | |
infotech1 | 0:0697cb7bb5a1 | 224 | int testRoundRects() { |
infotech1 | 0:0697cb7bb5a1 | 225 | unsigned long start; |
infotech1 | 0:0697cb7bb5a1 | 226 | int w, i, i2, |
infotech1 | 0:0697cb7bb5a1 | 227 | cx = tft.width() / 2 - 1, |
infotech1 | 0:0697cb7bb5a1 | 228 | cy = tft.height() / 2 - 1; |
infotech1 | 0:0697cb7bb5a1 | 229 | |
infotech1 | 0:0697cb7bb5a1 | 230 | tft.fillScreen(ILI9341_BLACK); |
infotech1 | 0:0697cb7bb5a1 | 231 | w = min(tft.width(), tft.height()); |
infotech1 | 0:0697cb7bb5a1 | 232 | start = t.read_ms(); |
infotech1 | 0:0697cb7bb5a1 | 233 | for(i=0; i<w; i+=6) { |
infotech1 | 0:0697cb7bb5a1 | 234 | i2 = i / 2; |
infotech1 | 0:0697cb7bb5a1 | 235 | tft.drawRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(i, 0, 0)); |
infotech1 | 0:0697cb7bb5a1 | 236 | } |
infotech1 | 0:0697cb7bb5a1 | 237 | |
infotech1 | 0:0697cb7bb5a1 | 238 | return t.read_ms() - start; |
infotech1 | 0:0697cb7bb5a1 | 239 | } |
infotech1 | 0:0697cb7bb5a1 | 240 | |
infotech1 | 0:0697cb7bb5a1 | 241 | |
infotech1 | 0:0697cb7bb5a1 | 242 | |
infotech1 | 0:0697cb7bb5a1 | 243 | int testFilledRoundRects() { |
infotech1 | 0:0697cb7bb5a1 | 244 | unsigned long start; |
infotech1 | 0:0697cb7bb5a1 | 245 | int i, i2, |
infotech1 | 0:0697cb7bb5a1 | 246 | cx = tft.width() / 2 - 1, |
infotech1 | 0:0697cb7bb5a1 | 247 | cy = tft.height() / 2 - 1; |
infotech1 | 0:0697cb7bb5a1 | 248 | |
infotech1 | 0:0697cb7bb5a1 | 249 | tft.fillScreen(ILI9341_BLACK); |
infotech1 | 0:0697cb7bb5a1 | 250 | start = t.read_ms(); |
infotech1 | 0:0697cb7bb5a1 | 251 | |
infotech1 | 0:0697cb7bb5a1 | 252 | for(i=min(tft.width(), tft.height()); i>20; i-=6) { |
infotech1 | 0:0697cb7bb5a1 | 253 | i2 = i / 2; |
infotech1 | 0:0697cb7bb5a1 | 254 | tft.fillRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(0, i, 0)); |
infotech1 | 0:0697cb7bb5a1 | 255 | } |
infotech1 | 0:0697cb7bb5a1 | 256 | |
infotech1 | 0:0697cb7bb5a1 | 257 | return t.read_ms() - start; |
infotech1 | 0:0697cb7bb5a1 | 258 | } |
infotech1 | 0:0697cb7bb5a1 | 259 | |
infotech1 | 0:0697cb7bb5a1 | 260 | |
infotech1 | 0:0697cb7bb5a1 | 261 | int main() { |
infotech1 | 0:0697cb7bb5a1 | 262 | tft.begin(); |
infotech1 | 0:0697cb7bb5a1 | 263 | t.start(); |
infotech1 | 0:0697cb7bb5a1 | 264 | |
infotech1 | 0:0697cb7bb5a1 | 265 | while(1) { |
infotech1 | 0:0697cb7bb5a1 | 266 | pc.printf("Ili9341 test\n"); |
infotech1 | 0:0697cb7bb5a1 | 267 | uint8_t x = tft.readcommand8(ILI9341_RDMODE); |
infotech1 | 0:0697cb7bb5a1 | 268 | pc.printf("Display Power Mode: 0x"); pc.printf("%d\n",x); |
infotech1 | 0:0697cb7bb5a1 | 269 | x = tft.readcommand8(ILI9341_RDMADCTL); |
infotech1 | 0:0697cb7bb5a1 | 270 | pc.printf("MADCTL Mode: 0x"); pc.printf("%d\n",x); |
infotech1 | 0:0697cb7bb5a1 | 271 | x = tft.readcommand8(ILI9341_RDPIXFMT); |
infotech1 | 0:0697cb7bb5a1 | 272 | pc.printf("Pixel Format: 0x"); pc.printf("%d\n",x); |
infotech1 | 0:0697cb7bb5a1 | 273 | x = tft.readcommand8(ILI9341_RDIMGFMT); |
infotech1 | 0:0697cb7bb5a1 | 274 | pc.printf("Image Format: 0x"); pc.printf("%d\n",x); |
infotech1 | 0:0697cb7bb5a1 | 275 | x = tft.readcommand8(ILI9341_RDSELFDIAG); |
infotech1 | 0:0697cb7bb5a1 | 276 | pc.printf("Self Diagnostic: 0x"); pc.printf("%d\n",x); |
infotech1 | 0:0697cb7bb5a1 | 277 | |
infotech1 | 0:0697cb7bb5a1 | 278 | pc.printf(("Benchmark Time (microseconds)\n")); |
infotech1 | 0:0697cb7bb5a1 | 279 | |
infotech1 | 0:0697cb7bb5a1 | 280 | pc.printf(("Screen fill ")); |
infotech1 | 0:0697cb7bb5a1 | 281 | pc.printf("%d",testFillScreen()); |
infotech1 | 0:0697cb7bb5a1 | 282 | wait_ms(500); |
infotech1 | 0:0697cb7bb5a1 | 283 | |
infotech1 | 0:0697cb7bb5a1 | 284 | pc.printf(("Text ")); |
infotech1 | 0:0697cb7bb5a1 | 285 | pc.printf("%d\n",testText()); |
infotech1 | 0:0697cb7bb5a1 | 286 | wait_ms(3000); |
infotech1 | 0:0697cb7bb5a1 | 287 | |
infotech1 | 0:0697cb7bb5a1 | 288 | pc.printf(("Lines ")); |
infotech1 | 0:0697cb7bb5a1 | 289 | pc.printf("%d\n",testLines(ILI9341_CYAN)); |
infotech1 | 0:0697cb7bb5a1 | 290 | wait_ms(500); |
infotech1 | 0:0697cb7bb5a1 | 291 | |
infotech1 | 0:0697cb7bb5a1 | 292 | pc.printf(("Horiz/Vert Lines ")); |
infotech1 | 0:0697cb7bb5a1 | 293 | pc.printf("%d\n",testFastLines(ILI9341_RED, ILI9341_BLUE)); |
infotech1 | 0:0697cb7bb5a1 | 294 | wait_ms(500); |
infotech1 | 0:0697cb7bb5a1 | 295 | |
infotech1 | 0:0697cb7bb5a1 | 296 | pc.printf(("Rectangles (outline) ")); |
infotech1 | 0:0697cb7bb5a1 | 297 | pc.printf("%d\n",testRects(ILI9341_GREEN)); |
infotech1 | 0:0697cb7bb5a1 | 298 | wait_ms(500); |
infotech1 | 0:0697cb7bb5a1 | 299 | |
infotech1 | 0:0697cb7bb5a1 | 300 | pc.printf(("Rectangles (filled) ")); |
infotech1 | 0:0697cb7bb5a1 | 301 | pc.printf("%d\n",testFilledRects(ILI9341_YELLOW, ILI9341_MAGENTA)); |
infotech1 | 0:0697cb7bb5a1 | 302 | wait_ms(500); |
infotech1 | 0:0697cb7bb5a1 | 303 | |
infotech1 | 0:0697cb7bb5a1 | 304 | pc.printf(("Circles (filled) ")); |
infotech1 | 0:0697cb7bb5a1 | 305 | pc.printf("%d\n",testFilledCircles(10, ILI9341_MAGENTA)); |
infotech1 | 0:0697cb7bb5a1 | 306 | |
infotech1 | 0:0697cb7bb5a1 | 307 | pc.printf(("Circles (outline) ")); |
infotech1 | 0:0697cb7bb5a1 | 308 | pc.printf("%d\n",testCircles(10, ILI9341_WHITE)); |
infotech1 | 0:0697cb7bb5a1 | 309 | wait_ms(500); |
infotech1 | 0:0697cb7bb5a1 | 310 | |
infotech1 | 0:0697cb7bb5a1 | 311 | pc.printf(("Triangles (outline) ")); |
infotech1 | 0:0697cb7bb5a1 | 312 | pc.printf("%d\n",testTriangles()); |
infotech1 | 0:0697cb7bb5a1 | 313 | wait_ms(500); |
infotech1 | 0:0697cb7bb5a1 | 314 | |
infotech1 | 0:0697cb7bb5a1 | 315 | pc.printf(("Triangles (filled) ")); |
infotech1 | 0:0697cb7bb5a1 | 316 | pc.printf("%d\n",testFilledTriangles()); |
infotech1 | 0:0697cb7bb5a1 | 317 | wait_ms(500); |
infotech1 | 0:0697cb7bb5a1 | 318 | tft.fillScreen(ILI9341_WHITE); |
infotech1 | 0:0697cb7bb5a1 | 319 | pc.printf(("Rounded rects (outline) ")); |
infotech1 | 0:0697cb7bb5a1 | 320 | pc.printf("%d\n",testRoundRects()); |
infotech1 | 0:0697cb7bb5a1 | 321 | wait_ms(500); |
infotech1 | 0:0697cb7bb5a1 | 322 | |
infotech1 | 0:0697cb7bb5a1 | 323 | pc.printf(("Rounded rects (filled) ")); |
infotech1 | 0:0697cb7bb5a1 | 324 | pc.printf("%d\n",testFilledRoundRects()); |
infotech1 | 0:0697cb7bb5a1 | 325 | wait_ms(500); |
infotech1 | 0:0697cb7bb5a1 | 326 | |
infotech1 | 0:0697cb7bb5a1 | 327 | pc.printf(("Done!")); |
infotech1 | 0:0697cb7bb5a1 | 328 | } |
infotech1 | 0:0697cb7bb5a1 | 329 | } |