Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* Pleasedontcode.com **********
- Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- - Terms and Conditions:
- You have a non-exclusive, revocable, worldwide, royalty-free license
- for personal and commercial use. Attribution is optional; modifications
- are allowed, but you're responsible for code maintenance. We're not
- liable for any loss or damage. For full terms,
- please visit pleasedontcode.com/termsandconditions.
- - Project: **Display Initialization**
- - Source Code NOT compiled for: ESP32 DevKit V1
- - Source Code created on: 2025-05-01 07:34:51
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Enable the Obsidian ESP32 board to control the */
- /* ILI9341 TFT display, utilizing SPI communication */
- /* for efficient data transfer. Ensure proper */
- /* initialization of the display and manage output */
- /* states for the reset and data command pins. */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <SPI.h>
- #include <Adafruit_ILI9341.h> //https://github.com/adafruit/Adafruit_ILI9341
- #include <U8g2_for_Adafruit_GFX.h> //https://github.com/olikraus/U8g2_for_Adafruit_GFX
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- void updateOutputs();
- void initializeDisplay();
- /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
- const uint8_t dis_ILI9341_TFT_RST_PIN_D4 = 4;
- const uint8_t dis_ILI9341_TFT_DC_PIN_D13 = 13;
- /***** DEFINITION OF SPI PINS *****/
- const uint8_t dis_ILI9341_TFT_SPI_PIN_MOSI_D23 = 23;
- const uint8_t dis_ILI9341_TFT_SPI_PIN_MISO_D19 = 19;
- const uint8_t dis_ILI9341_TFT_SPI_PIN_SCLK_D18 = 18;
- const uint8_t dis_ILI9341_TFT_SPI_PIN_CS_D5 = 5;
- /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
- /***** used to store raw data *****/
- bool dis_ILI9341_TFT_RST_PIN_D4_rawData = 0;
- bool dis_ILI9341_TFT_DC_PIN_D13_rawData = 0;
- /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
- /***** used to store data after characteristic curve transformation *****/
- float dis_ILI9341_TFT_RST_PIN_D4_phyData = 0.0;
- float dis_ILI9341_TFT_DC_PIN_D13_phyData = 0.0;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- // Instantiate the display object
- Adafruit_ILI9341 display(dis_ILI9341_TFT_SPI_PIN_CS_D5, dis_ILI9341_TFT_DC_PIN_D13, dis_ILI9341_TFT_SPI_PIN_MOSI_D23, dis_ILI9341_TFT_SPI_PIN_SCLK_D18, dis_ILI9341_TFT_RST_PIN_D4);
- void setup(void)
- {
- // put your setup code here, to run once:
- pinMode(dis_ILI9341_TFT_RST_PIN_D4, OUTPUT);
- pinMode(dis_ILI9341_TFT_DC_PIN_D13, OUTPUT);
- pinMode(dis_ILI9341_TFT_SPI_PIN_CS_D5, OUTPUT);
- // start the SPI library:
- SPI.begin();
- // Initialize the display
- initializeDisplay();
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- updateOutputs(); // Refresh output data
- }
- void updateOutputs()
- {
- digitalWrite(dis_ILI9341_TFT_RST_PIN_D4, dis_ILI9341_TFT_RST_PIN_D4_rawData);
- digitalWrite(dis_ILI9341_TFT_DC_PIN_D13, dis_ILI9341_TFT_DC_PIN_D13_rawData);
- }
- void initializeDisplay() {
- // Initialize the display
- display.begin();
- display.setRotation(3); // Set the rotation of the display
- display.fillScreen(ILI9341_BLACK); // Clear the screen with black color
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement