Advertisement
pleasedontcode

**Display Testing** rev_01

Feb 11th, 2025
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: **Display Testing**
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2025-02-12 03:37:44
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* make sure ST7789V display not white screen */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /* START CODE */
  24.  
  25. /****** DEFINITION OF LIBRARIES *****/
  26. #include <Adafruit_GFX.h>   //https://github.com/adafruit/Adafruit-GFX-Library
  27. #include <Adafruit_ST7789.h> // Added for ST7789 display support
  28. #include <SPI.h> // Added for SPI communication
  29.  
  30. /****** FUNCTION PROTOTYPES *****/
  31. void setup(void);
  32. void loop(void);
  33.  
  34. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  35. #define TFT_CS    6  
  36. #define TFT_DC    8
  37. #define TFT_RST   7  
  38.  
  39. Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST); // Instance of the display class
  40.  
  41. void setup(void)
  42. {
  43.     // put your setup code here, to run once:
  44.     Serial.begin(9600);
  45.     Serial.println("Initializing TFT display...");
  46.  
  47.     tft.init(240, 320, SPI_MODE0);
  48.     tft.setRotation(1); // Try different values (0-3)
  49.  
  50.     Serial.println("Display initialized!");
  51.  
  52.     // Fill the screen with a color to avoid white screen issue
  53.     tft.fillScreen(ST77XX_BLACK); // Set initial screen color to black
  54.     delay(500);
  55. }
  56.  
  57. void loop(void)
  58. {
  59.     // put your main code here, to run repeatedly:
  60.     tft.fillScreen(ST77XX_BLACK); // Clear screen each loop
  61.     tft.setTextColor(ST77XX_WHITE);
  62.     tft.setTextSize(2);
  63.     tft.setCursor(50, 50);
  64.     tft.println("ST7789 TEST");
  65.  
  66.     delay(1000);
  67. }
  68.  
  69. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement