PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test.ino 2.5KB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #include <SPI.h>
  2. #include <Adafruit_GFX.h>
  3. #include <TFT_ILI9163C.h>
  4. // Color definitions
  5. #define BLACK 0x0000
  6. #define BLUE 0x001F
  7. #define RED 0xF800
  8. #define GREEN 0x07E0
  9. #define CYAN 0x07FF
  10. #define MAGENTA 0xF81F
  11. #define YELLOW 0xFFE0
  12. #define WHITE 0xFFFF
  13. /*
  14. Teensy3.x and Arduino's
  15. You are using 4 wire SPI here, so:
  16. MOSI: 11//Teensy3.x/Arduino UNO (for MEGA/DUE refere to arduino site)
  17. MISO: 12//Teensy3.x/Arduino UNO (for MEGA/DUE refere to arduino site)
  18. SCK: 13//Teensy3.x/Arduino UNO (for MEGA/DUE refere to arduino site)
  19. the rest of pin below:
  20. */
  21. #define __CS 10
  22. #define __DC 9
  23. /*
  24. Teensy 3.x can use: 2,6,9,10,15,20,21,22,23
  25. Arduino's 8 bit: any
  26. DUE: check arduino site
  27. If you do not use reset, tie it to +3V3
  28. */
  29. TFT_ILI9163C tft = TFT_ILI9163C(__CS, __DC);
  30. void setup() {
  31. tft.begin();
  32. }
  33. void loop(){
  34. testLines(random(0x00ff,0xffff));
  35. delay(100);
  36. testText();
  37. delay(500);
  38. }
  39. unsigned long testText() {
  40. tft.fillScreen();
  41. unsigned long start = micros();
  42. tft.setCursor(0, 0);
  43. tft.setTextColor(WHITE);
  44. tft.setTextSize(1);
  45. tft.println("Hello World!");
  46. tft.setTextColor(YELLOW);
  47. tft.setTextSize(2);
  48. tft.println(1234.56);
  49. tft.setTextColor(RED);
  50. tft.setTextSize(3);
  51. tft.println(0xDEAD, HEX);
  52. tft.println();
  53. tft.setTextColor(GREEN);
  54. tft.setTextSize(4);
  55. tft.println("Hello");
  56. return micros() - start;
  57. }
  58. unsigned long testLines(uint16_t color) {
  59. tft.fillScreen();
  60. unsigned long start, t;
  61. int x1, y1, x2, y2,
  62. w = tft.width(),
  63. h = tft.height();
  64. tft.fillScreen();
  65. x1 = y1 = 0;
  66. y2 = h - 1;
  67. start = micros();
  68. for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
  69. x2 = w - 1;
  70. for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
  71. t = micros() - start; // fillScreen doesn't count against timing
  72. tft.fillScreen();
  73. x1 = w - 1;
  74. y1 = 0;
  75. y2 = h - 1;
  76. start = micros();
  77. for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
  78. x2 = 0;
  79. for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
  80. t += micros() - start;
  81. tft.fillScreen();
  82. x1 = 0;
  83. y1 = h - 1;
  84. y2 = 0;
  85. start = micros();
  86. for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
  87. x2 = w - 1;
  88. for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
  89. t += micros() - start;
  90. tft.fillScreen();
  91. x1 = w - 1;
  92. y1 = h - 1;
  93. y2 = 0;
  94. start = micros();
  95. for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
  96. x2 = 0;
  97. for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
  98. return micros() - start;
  99. }