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.

57 lines
1.6KB

  1. /*
  2. this sketch demostrate the ability to rotate screen .
  3. since his introduction, setRotation created some problems in library
  4. because RA8875 does most of his stuff internally so from library version 0.69b21
  5. code has many changes to fix the rotation issues.
  6. */
  7. #include <SPI.h>
  8. #include <RA8875.h>
  9. #define RA8875_CS 10 //any digital pin
  10. #define RA8875_RESET 9//any pin or 255 to disable it!
  11. RA8875 tft = RA8875(RA8875_CS,RA8875_RESET);//arduino's
  12. void setup()
  13. {
  14. Serial.begin(38400);
  15. //long unsigned debug_start = millis ();
  16. //while (!Serial && ((millis () - debug_start) <= 5000)) ;
  17. //Serial.println("RA8875 start");
  18. // begin display: Choose from: RA8875_480x272, RA8875_800x480, RA8875_800x480ALT, Adafruit_480x272, Adafruit_800x480
  19. tft.begin(RA8875_800x480);
  20. }
  21. uint8_t rot = 0;
  22. void loop()
  23. {
  24. tft.fillWindow();
  25. tft.setRotation(rot);
  26. tft.setCursor(0,0);
  27. tft.print("[rotation ");
  28. tft.print(rot);
  29. tft.print("]");
  30. tft.setCursor(100,0);
  31. tft.print("txt shifted to X100");
  32. tft.setCursor(0,20);
  33. tft.print("txt shifted to Y20");
  34. tft.drawCircle(tft.width()/2,tft.height()/2,50,RA8875_GREEN);
  35. tft.drawRect((tft.width()/2)-50,(tft.height()/2)-25,100,50,RA8875_YELLOW);
  36. tft.drawEllipse(tft.width()/2,tft.height()/2,50,25,RA8875_CYAN);
  37. tft.drawTriangle((tft.width()/2)-50,(tft.height()/2)-25,tft.width()/2,(tft.height()/2)+25,(tft.width()/2)+50,(tft.height()/2)-25,RA8875_RED);
  38. tft.drawPixel(tft.width()/2,tft.height()/2,RA8875_WHITE);
  39. tft.drawFastVLine(tft.width()/2,(tft.height()/2)-60,60,RA8875_RED);
  40. tft.drawFastHLine((tft.width()/2)-60,tft.height()/2,60,RA8875_RED);
  41. delay(3000);
  42. if (rot > 3) rot = 0;
  43. rot++;
  44. }