TFT_ILI9163C test A fork of https://github.com/sumotoy/TFT_ILI9163C
Dependencies: Adafruit-GFX-Library TFT_ILI9163C mbed
Fork of IL9163C_test by
main.cpp@5:f6052f005aef, 2015-01-26 (annotated)
- Committer:
- peu605
- Date:
- Mon Jan 26 12:37:24 2015 +0000
- Revision:
- 5:f6052f005aef
- Parent:
- 3:8e74cab81b3c
- Child:
- 8:4fcf5494f425
update lib
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
peu605 | 0:26cf1056924c | 1 | #include "mbed.h" |
peu605 | 0:26cf1056924c | 2 | |
peu605 | 0:26cf1056924c | 3 | #include <Adafruit_GFX.h> |
peu605 | 0:26cf1056924c | 4 | #include <TFT_ILI9163C.h> |
peu605 | 0:26cf1056924c | 5 | |
peu605 | 0:26cf1056924c | 6 | #define __MOSI D11 |
peu605 | 0:26cf1056924c | 7 | #define __MISO NC |
peu605 | 0:26cf1056924c | 8 | #define __SCLK D13 |
peu605 | 0:26cf1056924c | 9 | #define __CS D10 |
peu605 | 0:26cf1056924c | 10 | #define __DC D9 |
peu605 | 0:26cf1056924c | 11 | #define __RST D8 |
peu605 | 0:26cf1056924c | 12 | |
peu605 | 0:26cf1056924c | 13 | // Color definitions |
peu605 | 0:26cf1056924c | 14 | #define BLACK 0x0000 |
peu605 | 0:26cf1056924c | 15 | #define BLUE 0x001F |
peu605 | 0:26cf1056924c | 16 | #define RED 0xF800 |
peu605 | 0:26cf1056924c | 17 | #define GREEN 0x07E0 |
peu605 | 0:26cf1056924c | 18 | #define CYAN 0x07FF |
peu605 | 0:26cf1056924c | 19 | #define MAGENTA 0xF81F |
peu605 | 0:26cf1056924c | 20 | #define YELLOW 0xFFE0 |
peu605 | 0:26cf1056924c | 21 | #define WHITE 0xFFFF |
peu605 | 0:26cf1056924c | 22 | #define TRANSPARENT -1 |
peu605 | 0:26cf1056924c | 23 | |
peu605 | 0:26cf1056924c | 24 | TFT_ILI9163C display(__MOSI, __MISO, __SCLK, __CS, __DC, __RST); |
peu605 | 0:26cf1056924c | 25 | //TFT_ILI9163C display(__MOSI, __MISO, __SCLK, __CS, __DC); |
peu605 | 0:26cf1056924c | 26 | |
peu605 | 0:26cf1056924c | 27 | Timer t; |
peu605 | 0:26cf1056924c | 28 | |
peu605 | 0:26cf1056924c | 29 | const float p = 3.1415926; |
peu605 | 0:26cf1056924c | 30 | |
peu605 | 0:26cf1056924c | 31 | uint32_t millis() { |
peu605 | 0:26cf1056924c | 32 | return t.read_ms(); |
peu605 | 0:26cf1056924c | 33 | } |
peu605 | 0:26cf1056924c | 34 | |
peu605 | 0:26cf1056924c | 35 | int32_t random(int32_t howbig) { |
peu605 | 0:26cf1056924c | 36 | if (howbig == 0) { |
peu605 | 0:26cf1056924c | 37 | return 0; |
peu605 | 0:26cf1056924c | 38 | } |
peu605 | 0:26cf1056924c | 39 | return rand() % howbig; |
peu605 | 0:26cf1056924c | 40 | } |
peu605 | 0:26cf1056924c | 41 | |
peu605 | 0:26cf1056924c | 42 | int32_t random(int32_t howsmall, int32_t howbig) { |
peu605 | 0:26cf1056924c | 43 | if (howsmall >= howbig) { |
peu605 | 0:26cf1056924c | 44 | return howsmall; |
peu605 | 0:26cf1056924c | 45 | } |
peu605 | 0:26cf1056924c | 46 | int32_t diff = howbig - howsmall +1; |
peu605 | 0:26cf1056924c | 47 | return random(diff) + howsmall; |
peu605 | 0:26cf1056924c | 48 | } |
peu605 | 0:26cf1056924c | 49 | |
peu605 | 0:26cf1056924c | 50 | void testlines(uint16_t color) { |
peu605 | 0:26cf1056924c | 51 | display.clearScreen(); |
peu605 | 0:26cf1056924c | 52 | for (int16_t x=0; x < display.width()-1; x+=6) { |
peu605 | 0:26cf1056924c | 53 | display.drawLine(0, 0, x, display.height()-1, color); |
peu605 | 0:26cf1056924c | 54 | } |
peu605 | 0:26cf1056924c | 55 | for (int16_t y=0; y < display.height()-1; y+=6) { |
peu605 | 0:26cf1056924c | 56 | display.drawLine(0, 0, display.width()-1, y, color); |
peu605 | 0:26cf1056924c | 57 | } |
peu605 | 0:26cf1056924c | 58 | display.clearScreen(); |
peu605 | 0:26cf1056924c | 59 | for (int16_t x=0; x < display.width()-1; x+=6) { |
peu605 | 0:26cf1056924c | 60 | display.drawLine(display.width()-1, 0, x, display.height()-1, color); |
peu605 | 0:26cf1056924c | 61 | } |
peu605 | 0:26cf1056924c | 62 | for (int16_t y=0; y < display.height()-1; y+=6) { |
peu605 | 0:26cf1056924c | 63 | display.drawLine(display.width()-1, 0, 0, y, color); |
peu605 | 0:26cf1056924c | 64 | } |
peu605 | 0:26cf1056924c | 65 | |
peu605 | 0:26cf1056924c | 66 | display.clearScreen(); |
peu605 | 0:26cf1056924c | 67 | for (int16_t x=0; x < display.width()-1; x+=6) { |
peu605 | 0:26cf1056924c | 68 | display.drawLine(0, display.height()-1, x, 0, color); |
peu605 | 0:26cf1056924c | 69 | } |
peu605 | 0:26cf1056924c | 70 | for (int16_t y=0; y < display.height()-1; y+=6) { |
peu605 | 0:26cf1056924c | 71 | display.drawLine(0, display.height()-1, display.width()-1, y, color); |
peu605 | 0:26cf1056924c | 72 | } |
peu605 | 0:26cf1056924c | 73 | display.clearScreen(); |
peu605 | 0:26cf1056924c | 74 | for (int16_t x=0; x < display.width()-1; x+=6) { |
peu605 | 0:26cf1056924c | 75 | display.drawLine(display.width()-1, display.height()-1, x, 0, color); |
peu605 | 0:26cf1056924c | 76 | } |
peu605 | 0:26cf1056924c | 77 | for (int16_t y=0; y < display.height()-1; y+=6) { |
peu605 | 0:26cf1056924c | 78 | display.drawLine(display.width()-1, display.height()-1, 0, y, color); |
peu605 | 0:26cf1056924c | 79 | } |
peu605 | 0:26cf1056924c | 80 | wait_ms(500); |
peu605 | 0:26cf1056924c | 81 | } |
peu605 | 0:26cf1056924c | 82 | |
peu605 | 0:26cf1056924c | 83 | |
peu605 | 0:26cf1056924c | 84 | void testdrawtext(char *text, uint16_t color) { |
peu605 | 0:26cf1056924c | 85 | display.setTextSize(1); |
peu605 | 0:26cf1056924c | 86 | display.setTextColor(WHITE); |
peu605 | 0:26cf1056924c | 87 | display.setCursor(0,0); |
peu605 | 0:26cf1056924c | 88 | |
peu605 | 0:26cf1056924c | 89 | for (uint8_t i=0; i < 168; i++) { |
peu605 | 0:26cf1056924c | 90 | if (i == '\n') continue; |
peu605 | 0:26cf1056924c | 91 | display.writeChar(i); |
peu605 | 0:26cf1056924c | 92 | if ((i > 0) && (i % 21 == 0)) |
peu605 | 0:26cf1056924c | 93 | display.printf("\n"); |
peu605 | 0:26cf1056924c | 94 | } |
peu605 | 0:26cf1056924c | 95 | } |
peu605 | 0:26cf1056924c | 96 | |
peu605 | 0:26cf1056924c | 97 | void testfastlines(uint16_t color1, uint16_t color2) { |
peu605 | 0:26cf1056924c | 98 | display.clearScreen(); |
peu605 | 0:26cf1056924c | 99 | for (int16_t y=0; y < display.height()-1; y+=5) { |
peu605 | 0:26cf1056924c | 100 | display.drawFastHLine(0, y, display.width()-1, color1); |
peu605 | 0:26cf1056924c | 101 | } |
peu605 | 0:26cf1056924c | 102 | for (int16_t x=0; x < display.width()-1; x+=5) { |
peu605 | 0:26cf1056924c | 103 | display.drawFastVLine(x, 0, display.height()-1, color2); |
peu605 | 0:26cf1056924c | 104 | } |
peu605 | 0:26cf1056924c | 105 | } |
peu605 | 0:26cf1056924c | 106 | |
peu605 | 0:26cf1056924c | 107 | void testdrawrects(uint16_t color) { |
peu605 | 0:26cf1056924c | 108 | display.clearScreen(); |
peu605 | 0:26cf1056924c | 109 | for (int16_t x=0; x < display.height()-1; x+=6) { |
peu605 | 0:26cf1056924c | 110 | display.drawRect((display.width()-1)/2 -x/2, (display.height()-1)/2 -x/2 , x, x, color); |
peu605 | 0:26cf1056924c | 111 | } |
peu605 | 0:26cf1056924c | 112 | } |
peu605 | 0:26cf1056924c | 113 | |
peu605 | 0:26cf1056924c | 114 | void testfillrects(uint16_t color1, uint16_t color2) { |
peu605 | 0:26cf1056924c | 115 | display.clearScreen(); |
peu605 | 0:26cf1056924c | 116 | for (int16_t x=display.height()-1; x > 6; x-=6) { |
peu605 | 0:26cf1056924c | 117 | display.fillRect((display.width()-1)/2 -x/2, (display.height()-1)/2 -x/2 , x, x, color1); |
peu605 | 0:26cf1056924c | 118 | display.drawRect((display.width()-1)/2 -x/2, (display.height()-1)/2 -x/2 , x, x, color2); |
peu605 | 0:26cf1056924c | 119 | } |
peu605 | 0:26cf1056924c | 120 | } |
peu605 | 0:26cf1056924c | 121 | |
peu605 | 0:26cf1056924c | 122 | void testfillcircles(uint8_t radius, uint16_t color) { |
peu605 | 0:26cf1056924c | 123 | for (uint8_t x=radius; x < display.width()-1; x+=radius*2) { |
peu605 | 0:26cf1056924c | 124 | for (uint8_t y=radius; y < display.height()-1; y+=radius*2) { |
peu605 | 0:26cf1056924c | 125 | display.fillCircle(x, y, radius, color); |
peu605 | 0:26cf1056924c | 126 | } |
peu605 | 0:26cf1056924c | 127 | } |
peu605 | 0:26cf1056924c | 128 | } |
peu605 | 0:26cf1056924c | 129 | |
peu605 | 0:26cf1056924c | 130 | void testdrawcircles(uint8_t radius, uint16_t color) { |
peu605 | 0:26cf1056924c | 131 | for (int16_t x=0; x < (display.width()-1)+radius; x+=radius*2) { |
peu605 | 0:26cf1056924c | 132 | for (int16_t y=0; y < (display.height())-1+radius; y+=radius*2) { |
peu605 | 0:26cf1056924c | 133 | display.drawCircle(x, y, radius, color); |
peu605 | 0:26cf1056924c | 134 | } |
peu605 | 0:26cf1056924c | 135 | } |
peu605 | 0:26cf1056924c | 136 | } |
peu605 | 0:26cf1056924c | 137 | |
peu605 | 0:26cf1056924c | 138 | void testtriangles() { |
peu605 | 0:26cf1056924c | 139 | display.clearScreen(); |
peu605 | 0:26cf1056924c | 140 | int color = 0xF800; |
peu605 | 0:26cf1056924c | 141 | int t; |
peu605 | 0:26cf1056924c | 142 | int w = display.width()/2; |
peu605 | 0:26cf1056924c | 143 | int x = display.height(); |
peu605 | 0:26cf1056924c | 144 | int y = 0; |
peu605 | 0:26cf1056924c | 145 | int z = display.width(); |
peu605 | 0:26cf1056924c | 146 | for(t = 0 ; t <= 15; t+=1) { |
peu605 | 0:26cf1056924c | 147 | display.drawTriangle(w, y, y, x, z, x, color); |
peu605 | 0:26cf1056924c | 148 | x-=4; |
peu605 | 0:26cf1056924c | 149 | y+=4; |
peu605 | 0:26cf1056924c | 150 | z-=4; |
peu605 | 0:26cf1056924c | 151 | color+=100; |
peu605 | 0:26cf1056924c | 152 | } |
peu605 | 0:26cf1056924c | 153 | } |
peu605 | 0:26cf1056924c | 154 | |
peu605 | 0:26cf1056924c | 155 | void testroundrects() { |
peu605 | 0:26cf1056924c | 156 | display.clearScreen(); |
peu605 | 0:26cf1056924c | 157 | int color = 100; |
peu605 | 0:26cf1056924c | 158 | int i; |
peu605 | 0:26cf1056924c | 159 | int t; |
peu605 | 0:26cf1056924c | 160 | for(t = 0 ; t <= 4; t+=1) { |
peu605 | 0:26cf1056924c | 161 | int x = 0; |
peu605 | 0:26cf1056924c | 162 | int y = 0; |
peu605 | 0:26cf1056924c | 163 | int w = display.width(); |
peu605 | 0:26cf1056924c | 164 | int h = display.height(); |
peu605 | 0:26cf1056924c | 165 | for(i = 0 ; i <= 24; i+=1) { |
peu605 | 0:26cf1056924c | 166 | display.drawRoundRect(x, y, w, h, 5, color); |
peu605 | 0:26cf1056924c | 167 | x+=2; |
peu605 | 0:26cf1056924c | 168 | y+=3; |
peu605 | 0:26cf1056924c | 169 | w-=4; |
peu605 | 0:26cf1056924c | 170 | h-=6; |
peu605 | 0:26cf1056924c | 171 | color+=1100; |
peu605 | 0:26cf1056924c | 172 | } |
peu605 | 0:26cf1056924c | 173 | color+=100; |
peu605 | 0:26cf1056924c | 174 | } |
peu605 | 0:26cf1056924c | 175 | } |
peu605 | 0:26cf1056924c | 176 | |
peu605 | 0:26cf1056924c | 177 | void tftPrintTest() { |
peu605 | 0:26cf1056924c | 178 | display.clearScreen(); |
peu605 | 0:26cf1056924c | 179 | display.setCursor(0, 5); |
peu605 | 0:26cf1056924c | 180 | display.setTextColor(RED); |
peu605 | 0:26cf1056924c | 181 | display.setTextSize(1); |
peu605 | 0:26cf1056924c | 182 | display.printf("Hello World!\n"); |
peu605 | 0:26cf1056924c | 183 | display.setTextColor(YELLOW, GREEN); |
peu605 | 0:26cf1056924c | 184 | display.setTextSize(2); |
peu605 | 0:26cf1056924c | 185 | display.printf("Hello Wo"); |
peu605 | 0:26cf1056924c | 186 | display.setTextColor(BLUE); |
peu605 | 0:26cf1056924c | 187 | display.setTextSize(3); |
peu605 | 0:26cf1056924c | 188 | display.printf("%.2f", 12.57); |
peu605 | 0:26cf1056924c | 189 | wait_ms(1500); |
peu605 | 0:26cf1056924c | 190 | display.setCursor(0, 5); |
peu605 | 0:26cf1056924c | 191 | display.clearScreen(); |
peu605 | 0:26cf1056924c | 192 | display.setTextColor(WHITE); |
peu605 | 0:26cf1056924c | 193 | display.setTextSize(0); |
peu605 | 0:26cf1056924c | 194 | display.printf("Hello World!\n"); |
peu605 | 0:26cf1056924c | 195 | display.setTextSize(1); |
peu605 | 0:26cf1056924c | 196 | display.setTextColor(GREEN); |
peu605 | 0:26cf1056924c | 197 | display.printf("%5f", p); |
peu605 | 0:26cf1056924c | 198 | display.printf(" Want pi?\n"); |
peu605 | 0:26cf1056924c | 199 | display.printf("%x", 8675309); |
peu605 | 0:26cf1056924c | 200 | display.printf(" Print HEX\n"); |
peu605 | 0:26cf1056924c | 201 | display.setTextColor(WHITE); |
peu605 | 0:26cf1056924c | 202 | display.printf("Sketch has been\n"); |
peu605 | 0:26cf1056924c | 203 | display.printf("running for: \n"); |
peu605 | 0:26cf1056924c | 204 | display.setTextColor(MAGENTA); |
peu605 | 0:26cf1056924c | 205 | display.printf("%d", millis() / 1000); |
peu605 | 0:26cf1056924c | 206 | display.setTextColor(WHITE); |
peu605 | 0:26cf1056924c | 207 | display.printf(" sec."); |
peu605 | 0:26cf1056924c | 208 | } |
peu605 | 0:26cf1056924c | 209 | |
peu605 | 0:26cf1056924c | 210 | |
peu605 | 0:26cf1056924c | 211 | void randomRect(bool fill){ |
peu605 | 0:26cf1056924c | 212 | display.clearScreen(); |
peu605 | 0:26cf1056924c | 213 | uint8_t k,c; |
peu605 | 0:26cf1056924c | 214 | for (k = 0; k < 16; k++) { |
peu605 | 0:26cf1056924c | 215 | for (c = 0; c < 32; c++) { |
peu605 | 0:26cf1056924c | 216 | uint8_t cx, cy, x, y, w, h; |
peu605 | 0:26cf1056924c | 217 | // center |
peu605 | 0:26cf1056924c | 218 | cx = random(0,display.width()); |
peu605 | 0:26cf1056924c | 219 | cy = random(0,display.height()); |
peu605 | 0:26cf1056924c | 220 | // size |
peu605 | 0:26cf1056924c | 221 | w = random(0,30 + 6); |
peu605 | 0:26cf1056924c | 222 | h = random(0,20 + 4); |
peu605 | 0:26cf1056924c | 223 | // upper-left |
peu605 | 0:26cf1056924c | 224 | x = cx - w / 2; |
peu605 | 0:26cf1056924c | 225 | y = cy - h / 2; |
peu605 | 0:26cf1056924c | 226 | // if (x < 0) x = 0; |
peu605 | 0:26cf1056924c | 227 | // if (y < 0) y = 0; |
peu605 | 0:26cf1056924c | 228 | // adjust size |
peu605 | 0:26cf1056924c | 229 | if (x + w > display.width()) w = display.width() - x; |
peu605 | 0:26cf1056924c | 230 | if (y + h > display.height()) h = display.height() - y; |
peu605 | 0:26cf1056924c | 231 | if (fill){ |
peu605 | 0:26cf1056924c | 232 | display.fillRect(x, y, w, h,random(0x0010,0xFFFF)); |
peu605 | 0:26cf1056924c | 233 | } |
peu605 | 0:26cf1056924c | 234 | else { |
peu605 | 0:26cf1056924c | 235 | display.drawRect(x, y, w, h,random(0x0010,0xFFFF)); |
peu605 | 0:26cf1056924c | 236 | } |
peu605 | 0:26cf1056924c | 237 | |
peu605 | 0:26cf1056924c | 238 | } |
peu605 | 0:26cf1056924c | 239 | display.clearScreen(); |
peu605 | 0:26cf1056924c | 240 | } |
peu605 | 0:26cf1056924c | 241 | } |
peu605 | 0:26cf1056924c | 242 | |
peu605 | 0:26cf1056924c | 243 | void randomCircles(bool fill){ |
peu605 | 0:26cf1056924c | 244 | display.clearScreen(); |
peu605 | 0:26cf1056924c | 245 | uint8_t k,c; |
peu605 | 0:26cf1056924c | 246 | for (k = 0; k < display.height(); k++) { |
peu605 | 0:26cf1056924c | 247 | for (c = 0; c < display.height()/2; c++) { |
peu605 | 0:26cf1056924c | 248 | // coordinates |
peu605 | 0:26cf1056924c | 249 | uint8_t x = random(0,120 + 3), y = random(0,90 + 2), r = random(0,40 + 1); |
peu605 | 0:26cf1056924c | 250 | if (x - r < 0) r = x; |
peu605 | 0:26cf1056924c | 251 | if (x + r > (display.width()-1)) r = (display.width() - 1) - x; |
peu605 | 0:26cf1056924c | 252 | if (y - r < 0) r = y; |
peu605 | 0:26cf1056924c | 253 | if (y + r > (display.height()-1)) r = (display.height() - 1) - y; |
peu605 | 0:26cf1056924c | 254 | if (fill){ |
peu605 | 0:26cf1056924c | 255 | display.fillCircle(x, y, r,random(0x0010,0xFFFF)); |
peu605 | 0:26cf1056924c | 256 | } |
peu605 | 0:26cf1056924c | 257 | else { |
peu605 | 0:26cf1056924c | 258 | display.drawCircle(x, y, r,random(0x0010,0xFFFF)); |
peu605 | 0:26cf1056924c | 259 | } |
peu605 | 0:26cf1056924c | 260 | } |
peu605 | 0:26cf1056924c | 261 | if (!fill)display.clearScreen(); |
peu605 | 0:26cf1056924c | 262 | } |
peu605 | 0:26cf1056924c | 263 | } |
peu605 | 0:26cf1056924c | 264 | |
peu605 | 0:26cf1056924c | 265 | |
peu605 | 0:26cf1056924c | 266 | void randomLines(){ |
peu605 | 0:26cf1056924c | 267 | display.clearScreen(); |
peu605 | 0:26cf1056924c | 268 | uint8_t k,c; |
peu605 | 0:26cf1056924c | 269 | for (k = 0; k < display.height(); k++) { |
peu605 | 0:26cf1056924c | 270 | for (c = 0; c < display.height()/2; c++) { |
peu605 | 0:26cf1056924c | 271 | uint8_t x1 = random(0,display.width()), y1 = random(0,display.height()), x2 = random(0,display.width()), y2 = random(0,display.height()); |
peu605 | 0:26cf1056924c | 272 | display.drawLine(x1, y1, x2, y2,random(0x0010,0xFFFF)); |
peu605 | 0:26cf1056924c | 273 | } |
peu605 | 0:26cf1056924c | 274 | display.clearScreen(); |
peu605 | 0:26cf1056924c | 275 | } |
peu605 | 0:26cf1056924c | 276 | } |
peu605 | 0:26cf1056924c | 277 | |
peu605 | 0:26cf1056924c | 278 | |
peu605 | 0:26cf1056924c | 279 | void randomPoints(){ |
peu605 | 0:26cf1056924c | 280 | display.clearScreen(); |
peu605 | 0:26cf1056924c | 281 | for (uint8_t k = 0; k < 128; k++) { |
peu605 | 0:26cf1056924c | 282 | for (uint16_t c = 0; c < 1000; c++) { |
peu605 | 0:26cf1056924c | 283 | uint8_t x = random(0,display.width()), y = random(0,display.height()); |
peu605 | 0:26cf1056924c | 284 | display.drawPixel(x, y, random(0x0010,0xFFFF)); |
peu605 | 0:26cf1056924c | 285 | } |
peu605 | 0:26cf1056924c | 286 | display.clearScreen(); |
peu605 | 0:26cf1056924c | 287 | } |
peu605 | 0:26cf1056924c | 288 | } |
peu605 | 0:26cf1056924c | 289 | |
peu605 | 0:26cf1056924c | 290 | void loop() { |
peu605 | 0:26cf1056924c | 291 | |
peu605 | 0:26cf1056924c | 292 | testlines(random(0x0010,0xFFFF)); |
peu605 | 0:26cf1056924c | 293 | randomLines(); |
peu605 | 0:26cf1056924c | 294 | //randomCircles(1); |
peu605 | 0:26cf1056924c | 295 | randomCircles(0); |
peu605 | 0:26cf1056924c | 296 | randomRect(1); |
peu605 | 0:26cf1056924c | 297 | randomRect(1); |
peu605 | 0:26cf1056924c | 298 | randomRect(1); |
peu605 | 0:26cf1056924c | 299 | randomRect(1); |
peu605 | 0:26cf1056924c | 300 | randomRect(1); |
peu605 | 0:26cf1056924c | 301 | randomRect(0); |
peu605 | 0:26cf1056924c | 302 | randomRect(0); |
peu605 | 0:26cf1056924c | 303 | randomRect(0); |
peu605 | 0:26cf1056924c | 304 | randomRect(0); |
peu605 | 0:26cf1056924c | 305 | randomRect(0); |
peu605 | 0:26cf1056924c | 306 | randomRect(0); |
peu605 | 0:26cf1056924c | 307 | randomPoints(); |
peu605 | 0:26cf1056924c | 308 | } |
peu605 | 0:26cf1056924c | 309 | |
peu605 | 0:26cf1056924c | 310 | void setup(void) { |
peu605 | 0:26cf1056924c | 311 | |
peu605 | 0:26cf1056924c | 312 | t.start(); |
peu605 | 0:26cf1056924c | 313 | |
peu605 | 0:26cf1056924c | 314 | display.begin(); |
peu605 | 5:f6052f005aef | 315 | // display.setBitrate(10000000L); |
peu605 | 3:8e74cab81b3c | 316 | // display.setBitrate(25000000L); |
peu605 | 3:8e74cab81b3c | 317 | display.setBitrate(50000000L); |
peu605 | 0:26cf1056924c | 318 | display.setRotation(2); |
peu605 | 0:26cf1056924c | 319 | |
peu605 | 0:26cf1056924c | 320 | // lcdTestPattern(); |
peu605 | 0:26cf1056924c | 321 | // delay(1000); |
peu605 | 0:26cf1056924c | 322 | |
peu605 | 0:26cf1056924c | 323 | display.clearScreen(); |
peu605 | 0:26cf1056924c | 324 | display.setCursor(0,0); |
peu605 | 0:26cf1056924c | 325 | display.printf("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur adipiscing ante sed nibh tincidunt feugiat. Maecenas enim massa"); |
peu605 | 0:26cf1056924c | 326 | wait_ms(1000); |
peu605 | 0:26cf1056924c | 327 | |
peu605 | 0:26cf1056924c | 328 | tftPrintTest(); |
peu605 | 0:26cf1056924c | 329 | wait_ms(2000); |
peu605 | 0:26cf1056924c | 330 | |
peu605 | 0:26cf1056924c | 331 | //a single pixel |
peu605 | 0:26cf1056924c | 332 | display.drawPixel(display.width()/2, display.height()/2, GREEN); |
peu605 | 0:26cf1056924c | 333 | wait_ms(500); |
peu605 | 0:26cf1056924c | 334 | |
peu605 | 0:26cf1056924c | 335 | // line draw test |
peu605 | 0:26cf1056924c | 336 | testlines(YELLOW); |
peu605 | 0:26cf1056924c | 337 | wait_ms(500); |
peu605 | 0:26cf1056924c | 338 | |
peu605 | 0:26cf1056924c | 339 | // optimized lines |
peu605 | 0:26cf1056924c | 340 | testfastlines(RED, BLUE); |
peu605 | 0:26cf1056924c | 341 | wait_ms(500); |
peu605 | 0:26cf1056924c | 342 | |
peu605 | 0:26cf1056924c | 343 | testdrawrects(GREEN); |
peu605 | 0:26cf1056924c | 344 | wait_ms(1000); |
peu605 | 0:26cf1056924c | 345 | |
peu605 | 0:26cf1056924c | 346 | testfillrects(BLUE, YELLOW); |
peu605 | 0:26cf1056924c | 347 | wait_ms(1000); |
peu605 | 0:26cf1056924c | 348 | |
peu605 | 0:26cf1056924c | 349 | randomRect(0); |
peu605 | 0:26cf1056924c | 350 | wait_ms(100); |
peu605 | 0:26cf1056924c | 351 | randomCircles(0); |
peu605 | 0:26cf1056924c | 352 | wait_ms(100); |
peu605 | 0:26cf1056924c | 353 | randomLines(); |
peu605 | 0:26cf1056924c | 354 | wait_ms(100); |
peu605 | 0:26cf1056924c | 355 | randomPoints(); |
peu605 | 0:26cf1056924c | 356 | wait_ms(500); |
peu605 | 0:26cf1056924c | 357 | |
peu605 | 0:26cf1056924c | 358 | display.clearScreen(); |
peu605 | 0:26cf1056924c | 359 | testfillcircles(10, BLUE); |
peu605 | 0:26cf1056924c | 360 | testdrawcircles(10, WHITE); |
peu605 | 0:26cf1056924c | 361 | wait_ms(1000); |
peu605 | 0:26cf1056924c | 362 | |
peu605 | 0:26cf1056924c | 363 | testroundrects(); |
peu605 | 0:26cf1056924c | 364 | wait_ms(500); |
peu605 | 0:26cf1056924c | 365 | |
peu605 | 0:26cf1056924c | 366 | testtriangles(); |
peu605 | 0:26cf1056924c | 367 | wait_ms(500); |
peu605 | 0:26cf1056924c | 368 | |
peu605 | 0:26cf1056924c | 369 | } |
peu605 | 0:26cf1056924c | 370 | |
peu605 | 0:26cf1056924c | 371 | int main() { |
peu605 | 0:26cf1056924c | 372 | |
peu605 | 0:26cf1056924c | 373 | setup(); |
peu605 | 0:26cf1056924c | 374 | |
peu605 | 0:26cf1056924c | 375 | while (true) { |
peu605 | 0:26cf1056924c | 376 | loop(); |
peu605 | 0:26cf1056924c | 377 | } |
peu605 | 0:26cf1056924c | 378 | } |