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.

46 lines
1.3KB

  1. #include <Arduino.h>
  2. #include <SPI.h>
  3. #include <ssd1351.h>
  4. // use this to do Color c = RGB(...) instead of `RGB c = RGB(...)` or ssd1351::LowColor c = RGB(...)
  5. // because it's slightly faster and guarantees you won't be sending wrong colours to the display.
  6. // Choose color depth - IndexedColor, LowColor and HighColor currently supported
  7. // typedef ssd1351::IndexedColor Color;
  8. // typedef ssd1351::LowColor Color;
  9. typedef ssd1351::HighColor Color;
  10. // Choose display buffering - NoBuffer or SingleBuffer currently supported
  11. // auto display = ssd1351::SSD1351<Color, ssd1351::NoBuffer, 128, 96>();
  12. auto display = ssd1351::SSD1351<Color, ssd1351::SingleBuffer, 128, 96>();
  13. void setup() {
  14. Serial.begin(9600);
  15. Serial.println("Booting...");
  16. display.begin();
  17. display.setTextSize(1);
  18. Serial.println("Display set up.");
  19. }
  20. void loop() {
  21. unsigned long before = millis();
  22. display.fillScreen(ssd1351::RGB());
  23. if (millis() > 5000) {
  24. display.setFont(FreeMonoBold24pt7b);
  25. display.setTextSize(1);
  26. }
  27. char test_string[] = "Test";
  28. uint16_t w = display.getTextWidth(test_string);
  29. display.setCursor(64 - w/2, 40);
  30. display.setTextColor(ssd1351::RGB(255, 255, 255));
  31. display.print(test_string);
  32. display.drawLine(63, 0, 63, 96, ssd1351::RGB(255, 0, 0));
  33. display.updateScreen();
  34. Serial.println(millis() - before);
  35. }