### Touchscreen Calibration Values for LVGL Source: https://github.com/witnessmenow/esp32-cheap-yellow-display/blob/main/Examples/LVGL9/README.md These C++ variables define the mapping between raw touchscreen readings and screen coordinates. Users must adjust these values to ensure accurate touchscreen input for their specific display. This is essential for interactive LVGL applications. ```c++ uint16_t touchScreenMinimumX = 200, touchScreenMaximumX = 3700, touchScreenMinimumY = 240,touchScreenMaximumY = 3800; ``` -------------------------------- ### ESP32 Button Input Configuration Source: https://github.com/witnessmenow/esp32-cheap-yellow-display/blob/main/PINS.md This code example demonstrates how to use the IO0 pin as a GPIO input for the BOOT button. This pin can be utilized within user sketches to detect button presses. ```c++ // BOOT button connected to IO0 // Can be used as an input in sketches ``` -------------------------------- ### ESP32 Touchscreen Calibration with LVGL Source: https://github.com/witnessmenow/esp32-cheap-yellow-display/blob/main/Examples/LVGL8/README.md This code snippet demonstrates how to calibrate the touchscreen input for LVGL on an ESP32. It uses the `map()` function to convert raw touchscreen readings to screen coordinates, which are essential for accurate touch interaction. Users will need to adjust the calibration values based on their specific display. ```c++ touchX = map(p.x,200,3700,1,screenWidth); /* Touchscreen X calibration */ touchY = map(p.y,240,3800,1,screenHeight); /* Touchscreen Y calibration */ ``` -------------------------------- ### Configure ESPHome Display Component (ILI9XXX) Source: https://github.com/witnessmenow/esp32-cheap-yellow-display/blob/main/Examples/ESPHome/README.md This snippet configures the display component for ESPHome, specifically for models using the ILI9XXX driver. It sets the display model, SPI connection, and pin assignments for chip select (CS) and data/command (DC). It also includes the option to invert display colors, which may vary based on the ESPHome version. ```yaml display: - platform: ili9xxx id: esp_display model: ili9342 spi_id: tft cs_pin: GPIO15 dc_pin: GPIO2 invert_colors: true ``` -------------------------------- ### SD Card Operations with Arduino SD Source: https://context7.com/witnessmenow/esp32-cheap-yellow-display/llms.txt Demonstrates file system operations on an SD card using the Arduino SD library and VSPI bus. It includes mounting the card, displaying its type and size, writing to a file, reading from a file, and showing total and used space. Dependencies include FS, SD, and SPI. ```cpp #include "FS.h" #include "SD.h" #include "SPI.h" // SD uses default VSPI pins: SCK=18, MISO=19, MOSI=23, CS=5 void setup() { Serial.begin(115200); SPIClass spi = SPIClass(VSPI); if (!SD.begin(SS, spi, 80000000)) { Serial.println("Card Mount Failed"); return; } uint8_t cardType = SD.cardType(); if (cardType == CARD_NONE) { Serial.println("No SD card attached"); return; } // Display card info Serial.print("SD Card Type: "); if (cardType == CARD_MMC) Serial.println("MMC"); else if (cardType == CARD_SD) Serial.println("SDSC"); else if (cardType == CARD_SDHC) Serial.println("SDHC"); uint64_t cardSize = SD.cardSize() / (1024 * 1024); Serial.printf("SD Card Size: %lluMB\n", cardSize); // File operations writeFile(SD, "/test.txt", "Hello CYD!"); readFile(SD, "/test.txt"); Serial.printf("Total space: %lluMB\n", SD.totalBytes() / (1024 * 1024)); Serial.printf("Used space: %lluMB\n", SD.usedBytes() / (1024 * 1024)); } void writeFile(fs::FS &fs, const char *path, const char *message) { File file = fs.open(path, FILE_WRITE); if (!file) { Serial.println("Failed to open file for writing"); return; } if (file.print(message)) { Serial.println("File written"); } else { Serial.println("Write failed"); } file.close(); } void readFile(fs::FS &fs, const char *path) { File file = fs.open(path); if (!file) { Serial.println("Failed to open file for reading"); return; } Serial.print("Read from file: "); while (file.available()) { Serial.write(file.read()); } Serial.println(); file.close(); } void loop() {} ``` -------------------------------- ### Home Assistant Configuration for External Directories Source: https://github.com/witnessmenow/esp32-cheap-yellow-display/blob/main/Examples/openHASP/README.md This YAML snippet configures Home Assistant to allow external directories, which is necessary for loading openHASP pages from a network location. Ensure the path specified matches where your 'pages.jsonl' file is stored. ```yaml homeassistant: allowlist_external_dirs: - "/config/openhasp" ``` -------------------------------- ### Initialize ESP32 CYD Display and Render Text with TFT_eSPI Source: https://context7.com/witnessmenow/esp32-cheap-yellow-display/llms.txt This Arduino sketch demonstrates the basic initialization of the ESP32 Cheap Yellow Display using the TFT_eSPI library. It sets the display to landscape mode, fills the screen with black, and renders text with different alignments and colors. This code is suitable for initial display testing and text output. ```cpp #include TFT_eSPI tft = TFT_eSPI(); void setup() { // Initialize display tft.init(); tft.setRotation(1); // Landscape mode (320x240) tft.fillScreen(TFT_BLACK); // Text rendering with different alignments tft.setTextColor(TFT_WHITE, TFT_BLACK); int fontNum = 2; // 16 pixel high font // Left aligned tft.drawString("Hello", 5, 10, fontNum); // Center aligned tft.setTextColor(TFT_BLUE, TFT_BLACK); tft.drawCentreString("World", 160, 26, fontNum); } void loop() { // Display updates here } ``` -------------------------------- ### ESPHome Configuration for ESP32 Yellow Display Source: https://context7.com/witnessmenow/esp32-cheap-yellow-display/llms.txt This YAML configuration sets up an ESP32 device with a cheap yellow display using ESPHome. It defines device name, WiFi credentials, API settings, OTA updates, fonts, colors, images, backlight control, time synchronization, dual SPI buses for display and touch, and the display parameters including model and screen transformations. The lambda function is used to draw elements on the display. ```yaml substitutions: device_name: yellowtft1 friendly_name: Yellow TFT 1 esphome: name: $device_name friendly_name: $friendly_name esp32: board: esp32dev framework: type: arduino logger: api: encryption: key: !secret api_key ota: platform: esphome password: !secret ota_password wifi: ssid: !secret wifi_ssid password: !secret wifi_password ap: ssid: $device_name Fallback Hotspot password: !secret ap_password captive_portal: # Font definitions font: - file: 'fonts/Arimo-Regular.ttf' id: arimo24 size: 24 glyphs: "!\"%()+=,-_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" - file: 'fonts/Arimo-Regular.ttf' id: arimo96 size: 96 glyphs: ":0123456789" color: - id: ha_blue hex: 51c0f2 image: - file: "images/esphome.png" id: esphome_image type: RGB # Backlight control light: - platform: monochromatic output: backlight_pwm name: Display Backlight id: backlight restore_mode: ALWAYS_ON # Time from Home Assistant time: - platform: homeassistant id: esptime timezone: Europe/Dublin # Dual SPI buses spi: - id: tft clk_pin: GPIO14 mosi_pin: GPIO13 miso_pin: GPIO12 - id: touch clk_pin: GPIO25 mosi_pin: GPIO32 miso_pin: GPIO39 output: - platform: ledc pin: GPIO21 id: backlight_pwm # Display configuration display: - platform: ili9xxx model: ili9341 spi_id: tft cs_pin: GPIO15 dc_pin: GPIO2 color_palette: 8BIT transform: swap_xy: true invert_colors: false lambda: |- it.fill(id(ha_blue)); it.image(120, 10, id(esphome_image)); it.strftime(100, 100, id(arimo24), "%Y-%m-%d", id(esptime).now()); it.strftime(40, 120, id(arimo96), "%H:%M", id(esptime).now()); ``` -------------------------------- ### ESP32 Serial Debug Log Output Source: https://github.com/witnessmenow/esp32-cheap-yellow-display/blob/main/Examples/openHASP/README.md This snippet displays typical serial output from an ESP32 device during startup and configuration loading. It includes boot information, environment details, and confirmation of configuration file loading. Useful for diagnosing boot issues or configuration problems. ```text ELF file SHA256: 0000000000000000 Rebooting... ets Jul 29 2019 12:21:46 rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:2 load:0x3fff0030,len:184 load:0x40078000,len:12732 ho 0 tail 12 room 4 load:0x40080400,len:2908 entry 0x400805c4 open____ _____ _____ _____ | | | _ | __| _ | | | |__ | __| |__|__|__|__|_____|__| Home Automation Switch Plate Open Hardware edition v0.7.0-rc6 [06:21:16.693][110580/160512 31][ 0/ 0 0] DBUG: Started @ 115200 bps #[06:21:16.702][110580/160512 31][ 0/ 0 0] DBUG: Environment: esp32-2432s028r_4MB #[06:21:16.712][110580/160512 31][ 0/ 0 0] UART: Started #[06:21:16.720][110580/160512 31][ 0/ 0 0] UART: Client login from serial #[06:21:16.729][110580/160512 31][ 0/ 0 0] CONF: SPI flash FS mounted Prompt > [06:21:16.767][110580/160512 31][ 0/ 0 0] CONF: Loading /config.json Prompt > [06:21:16.778][110580/159712 30][ 0/ 0 0] CONF: Loaded /config.json Prompt > [06:21:16.788][110580/160576 31][ 0/ 0 0] DBUG: Loading debug settings ``` -------------------------------- ### Configure ESP32 CYD Touchscreen with XPT2046 and TFT_eSPI Source: https://context7.com/witnessmenow/esp32-cheap-yellow-display/llms.txt This Arduino sketch sets up the XPT2046 resistive touchscreen controller on the ESP32 Cheap Yellow Display using a separate VSPI bus. It includes pin definitions for the touch controller and demonstrates initializing both the touch screen and the display. The loop function continuously checks for touch events and prints raw touch coordinates to the serial monitor. ```cpp #include #include #include // Touch pins (VSPI bus) #define XPT2046_IRQ 36 #define XPT2046_MOSI 32 #define XPT2046_MISO 39 #define XPT2046_CLK 25 #define XPT2046_CS 33 SPIClass mySpi = SPIClass(VSPI); XPT2046_Touchscreen ts(XPT2046_CS, XPT2046_IRQ); TFT_eSPI tft = TFT_eSPI(); void setup() { Serial.begin(115200); // Initialize touch on separate SPI bus mySpi.begin(XPT2046_CLK, XPT2046_MISO, XPT2046_MOSI, XPT2046_CS); ts.begin(mySpi); ts.setRotation(1); tft.init(); tft.setRotation(1); tft.fillScreen(TFT_BLACK); } void loop() { if (ts.tirqTouched() && ts.touched()) { TS_Point p = ts.getPoint(); // Raw touch coordinates Serial.print("Pressure = "); Serial.print(p.z); Serial.print(", x = "); Serial.print(p.x); Serial.print(", y = "); Serial.println(p.y); delay(100); } } ``` -------------------------------- ### Touch Button UI with TFT_eSPI Source: https://context7.com/witnessmenow/esp32-cheap-yellow-display/llms.txt Implements an interactive 2x3 button grid on a TFT display using the TFT_eSPI library and an XPT2046 touch controller. It handles button presses and releases, printing events to the serial monitor. Dependencies include SPI, XPT2046_Bitbang, and TFT_eSPI. ```cpp #include #include #include #define XPT2046_IRQ 36 #define XPT2046_MOSI 32 #define XPT2046_MISO 39 #define XPT2046_CLK 25 #define XPT2046_CS 33 XPT2046_Bitbang ts(XPT2046_MOSI, XPT2046_MISO, XPT2046_CLK, XPT2046_CS); TFT_eSPI tft = TFT_eSPI(); TFT_eSPI_Button key[6]; void setup() { Serial.begin(115200); ts.begin(); tft.init(); tft.setRotation(1); tft.fillScreen(TFT_BLACK); tft.setFreeFont(&FreeMono18pt7b); // Create 2x3 button grid uint16_t bWidth = TFT_HEIGHT / 3; // 240 / 3 = 80 uint16_t bHeight = TFT_WIDTH / 2; // 320 / 2 = 160 for (int i = 0; i < 6; i++) { key[i].initButton(&tft, bWidth * (i % 3) + bWidth / 2, bHeight * (i / 3) + bHeight / 2, bWidth, bHeight, TFT_BLACK, // Outline TFT_BLUE, // Fill TFT_BLACK, // Text ", 1); key[i].drawButton(false, String(i + 1)); } } void loop() { TouchPoint p = ts.getTouch(); // Update button press states for (uint8_t b = 0; b < 6; b++) { if ((p.zRaw > 0) && key[b].contains(p.x, p.y)) { key[b].press(true); } else { key[b].press(false); } } // Handle button events for (uint8_t b = 0; b < 6; b++) { if (key[b].justPressed()) { Serial.printf("Button %d pressed\n", b); key[b].drawButton(true, String(b + 1)); } if (key[b].justReleased()) { Serial.printf("Button %d released\n", b); key[b].drawButton(false, String(b + 1)); } } delay(50); } ``` -------------------------------- ### Arduino IDE Board Manager Configuration Source: https://context7.com/witnessmenow/esp32-cheap-yellow-display/llms.txt Settings for configuring the ESP32 Dev Module in the Arduino IDE. These include selecting the correct board, upload speed, flash frequency, and partition scheme for optimal performance and compatibility. ```text Board: "ESP32 Dev Module" Upload Speed: 115200 (if errors occur) Flash Frequency: 80MHz Partition Scheme: Default 4MB with spiffs ``` -------------------------------- ### OpenHASP GPIO Configuration for Physical Button Source: https://github.com/witnessmenow/esp32-cheap-yellow-display/blob/main/Examples/openHASP/README.md This configuration is used within the openHASP web interface to add a physical button to the device. Pin 0 is configured as a 'Push Button' with 'Normal' action, and unlike touchscreen buttons, these are automatically added to Home Assistant. ```text Pin Type Group Default Action 0 Push Button 0 Normal ``` -------------------------------- ### WiFi Audio Streaming with ESP32-audioI2S Source: https://context7.com/witnessmenow/esp32-cheap-yellow-display/llms.txt Enables internet radio playback on an ESP32 using the ESP32-audioI2S library. It connects to WiFi, configures audio output to an I2S DAC, and streams audio from a specified URL. The code includes callbacks for audio information, stream title, and bitrate, and displays the current stream title on a TFT display. Dependencies include Arduino, WiFi, TFT_eSPI, and Audio. ```cpp #include #include #include #include "Audio.h" // https://github.com/schreibfaul1/ESP32-audioI2S const char* ssid = "YOUR-SSID"; const char* password = "YOUR-PASSWORD"; TFT_eSPI tft = TFT_eSPI(); Audio audio(true, I2S_DAC_CHANNEL_LEFT_EN); // Pin 26 to speaker void setup() { Serial.begin(115200); tft.init(); tft.setRotation(1); tft.fillScreen(TFT_BLACK); tft.setTextColor(TFT_WHITE, TFT_BLACK); tft.drawString("Connecting...", 0, 10, 1); // Connect to WiFi WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println("\nWiFi connected: " + WiFi.localIP().toString()); // Configure audio audio.forceMono(true); audio.setVolume(10); // Connect to stream bool succeeded; do { succeeded = audio.connecttohost("http://sc8.1.fm:8100/"); if (!succeeded) delay(500); } while (!succeeded); } void loop() { audio.loop(); // Process audio buffer } // Audio event callbacks void audio_info(const char *info) { Serial.println(String("Info: ") + info); } void audio_showstreamtitle(const char *info) { Serial.println(String("Now playing: ") + info); tft.fillRect(0, 20, 320, 200, TFT_BLACK); tft.setCursor(0, 20, 4); tft.setTextColor(TFT_SKYBLUE); tft.println(info); } void audio_bitrate(const char *info) { Serial.println(String("Bitrate: ") + info); } ``` -------------------------------- ### PlatformIO Config for ESP32-1732S019 Source: https://github.com/witnessmenow/esp32-cheap-yellow-display/blob/main/Variants/README.md PlatformIO configuration for the ESP32-1732S019 display. This includes settings for the platform, board, framework, and specific build flags for the ST7789 driver, including display dimensions and GPIO pin assignments for SPI communication and backlight control. ```ini [env:cyd1732] platform = espressif32 board = esp32-s3-devkitm-1 framework = arduino lib_ldf_mode = deep+ monitor_filters = esp32_exception_decoder monitor_speed = 115200 upload_speed = 460800 board_build.partitions = min_spiffs.csv build_flags = -DST7789_DRIVER -DTFT_WIDTH=170 -DTFT_HEIGHT=320 -DTFT_MISO=-1 -DTFT_MOSI=13 -DTFT_SCLK=12 -DTFT_CS=10 -DTFT_DC=11 -DTFT_RST=1 -DTFT_BL=14 -DTFT_BACKLIGHT_ON=HIGH -DTFT_BACKLIGHT_OFF=LOW -DTOUCH_CS=-1 -DLOAD_GLCD -DSPI_FREQUENCY=65000000 -DSPI_READ_FREQUENCY=20000000 -DSPI_TOUCH_FREQUENCY=2500000 -DTFT_INVERSION_ON ``` -------------------------------- ### Configure ESP32 CYD Display Pins for TFT_eSPI Source: https://context7.com/witnessmenow/esp32-cheap-yellow-display/llms.txt This configuration file defines the pin assignments and display parameters for the ESP32 Cheap Yellow Display (CYD) when using the TFT_eSPI library. It specifies the display driver, dimensions, and pins for the HSPI bus, as well as performance-related SPI frequencies. Ensure this file is placed in the Arduino libraries/TFT_eSPI folder. ```c // DisplayConfig/User_Setup.h - Copy to Arduino libraries/TFT_eSPI folder #define ILI9341_2_DRIVER // Display dimensions #define TFT_WIDTH 240 #define TFT_HEIGHT 320 // Display pins (HSPI) #define TFT_MISO 12 #define TFT_MOSI 13 #define TFT_SCLK 14 #define TFT_CS 15 #define TFT_DC 2 #define TFT_RST -1 // Connected to ESP32 RST #define TFT_BL 21 // Backlight control // Performance settings #define USE_HSPI_PORT #define SPI_FREQUENCY 55000000 #define SPI_READ_FREQUENCY 20000000 #define SPI_TOUCH_FREQUENCY 2500000 ``` -------------------------------- ### OpenHASP GPIO Configuration for RGB LED Source: https://github.com/witnessmenow/esp32-cheap-yellow-display/blob/main/Examples/openHASP/README.md This configuration is used within the openHASP web interface to set up pins for controlling an RGB LED. It defines the 'Mood Red', 'Mood Green', and 'Mood Blue' outputs on specific pins, with the 'Inverted' setting typically used for common anode LEDs. ```text Pin Type Group Default Action 4 Mood Red 0 Inverted 16 Mood Green 0 Inverted 17 Mood Blue 0 Inverted ``` -------------------------------- ### PlatformIO Config for ESP32-2432S024 Source: https://github.com/witnessmenow/esp32-cheap-yellow-display/blob/main/Variants/README.md Partial PlatformIO configuration for the ESP32-2432S024 display. This snippet focuses on the build flags required for the ILI9341 driver, specifying display dimensions and GPIO pin assignments for SPI communication and backlight control. ```ini -DILI9341_2_DRIVER -DTFT_WIDTH=240 -DTFT_HEIGHT=320 -DTFT_MISO=12 -DTFT_MOSI=13 -DTFT_SCLK=14 -DTFT_CS=15 -DTFT_DC=2 -DTFT_RST=-1 -DTFT_BL=27 -DTFT_BACKLIGHT_ON=HIGH -DTFT_BACKLIGHT_OFF=LOW -DTOUCH_CS=-1 -DLOAD_GLCD -DSPI_FREQUENCY=55000000 -DSPI_READ_FREQUENCY=20000000 -DSPI_TOUCH_FREQUENCY=2500000 -DTFT_INVERSION_OFF ``` -------------------------------- ### Define Touchscreen Trait in Rust Source: https://github.com/witnessmenow/esp32-cheap-yellow-display/blob/main/Variants/3248S035C/Examples/1-Draw/touchscreen/README.md Defines the core `Touchscreen` trait for handling touch input. It requires implementations to also be `DrawTarget` and `OriginDimensions` from the `embedded-graphics-core` crate. It specifies a method `get_touch_event` to retrieve touch events and an associated error type `TouchError`. ```rust pub trait Touchscreen: embedded_graphics_core::prelude::DrawTarget + embedded_graphics_core::prelude::OriginDimensions { type TouchError; fn get_touch_event(&mut self) -> Result, Self::TouchError>; } ``` -------------------------------- ### ESP32 Touch Screen Pin Definitions Source: https://github.com/witnessmenow/esp32-cheap-yellow-display/blob/main/PINS.md This snippet details the GPIO pin assignments for the touch screen controller (XPT2046). It includes pins for clock, MOSI, Chip Select (CS), Interrupt Request (IRQ), and MISO. ```c++ const int TOUCH_CLK = 25; const int TOUCH_MOSI = 32; const int TOUCH_CS = 33; const int TOUCH_IRQ = 36; const int TOUCH_MISO = 39; ``` -------------------------------- ### Invert Display with CYD2USB Source: https://github.com/witnessmenow/esp32-cheap-yellow-display/blob/main/cyd.md This code snippet demonstrates how to invert the display colors for the CYD2USB variant. It utilizes the `tft.invertDisplay(1)` method to achieve the color inversion. This is a common solution when dealing with displays that have inverted colors. ```arduino tft.invertDisplay(1); ``` -------------------------------- ### ESP32 SPI Pin Definitions for Display Source: https://github.com/witnessmenow/esp32-cheap-yellow-display/blob/main/PINS.md This code snippet outlines the pin assignments for the HSPI (Host SPI) interface used for the TFT display. It covers pins for Chip Select (CS), Serial Data Input (SDI/MOSI), Serial Data Output (SDO/MISO), Serial Clock (SCK), and Register Select (RS/DC). ```c++ // Display uses HSPI const int TFT_RS = 2; const int TFT_SDO = 12; // AKA: TFT_MISO const int TFT_SDI = 13; // AKA: TFT_MOSI const int TFT_SCK = 14; const int TFT_CS = 15; const int TFT_BL = 21; ``` -------------------------------- ### ESP32 SPI Pin Definitions for SD Card Source: https://github.com/witnessmenow/esp32-cheap-yellow-display/blob/main/PINS.md This code snippet illustrates the predefined pin assignments for the VSPI (Versal SPI) interface used for SD card communication on the ESP32. It assumes the use of the Arduino SPI.h library or similar. ```c++ // Pin names are predefined in SPI.h const int SD_SS = 5; const int SD_SCK = 18; const int SD_MISO = 19; const int SD_MOSI = 23; ``` -------------------------------- ### Control RGB LED on ESP32 CYD Board Source: https://context7.com/witnessmenow/esp32-cheap-yellow-display/llms.txt This Arduino sketch demonstrates how to control the active-low RGB LED connected to dedicated GPIO pins on the ESP32 Cheap Yellow Display (CYD). It defines the pins for red, green, and blue LEDs and includes a loop that cycles through turning each LED on individually, with all LEDs off between changes. Setting a pin HIGH turns the LED off, and LOW turns it on. ```cpp #define CYD_LED_RED 4 #define CYD_LED_GREEN 16 #define CYD_LED_BLUE 17 void setup() { pinMode(CYD_LED_RED, OUTPUT); pinMode(CYD_LED_GREEN, OUTPUT); pinMode(CYD_LED_BLUE, OUTPUT); } void loop() { // LEDs are active-low: HIGH = off, LOW = on // All off digitalWrite(CYD_LED_RED, HIGH); digitalWrite(CYD_LED_GREEN, HIGH); digitalWrite(CYD_LED_BLUE, HIGH); delay(1000); // Red only digitalWrite(CYD_LED_RED, LOW); digitalWrite(CYD_LED_GREEN, HIGH); digitalWrite(CYD_LED_BLUE, HIGH); delay(1000); // Green only digitalWrite(CYD_LED_RED, HIGH); digitalWrite(CYD_LED_GREEN, LOW); digitalWrite(CYD_LED_BLUE, HIGH); delay(1000); // Blue only digitalWrite(CYD_LED_RED, HIGH); digitalWrite(CYD_LED_GREEN, HIGH); digitalWrite(CYD_LED_BLUE, LOW); delay(1000); } ``` -------------------------------- ### Adjust Gamma for CYD2USB Display Source: https://github.com/witnessmenow/esp32-cheap-yellow-display/blob/main/cyd.md This code snippet provides a workaround for gamma issues on the CYD2USB display. It sends specific commands to the display controller to adjust the gamma curve, aiming to improve display quality. This involves writing commands and data to the TFT controller. ```arduino tft.writecommand(ILI9341_GAMMASET); //Gamma curve selected tft.writedata(2); delay(120); tft.writecommand(ILI9341_GAMMASET); //Gamma curve selected tft.writedata(1); ``` -------------------------------- ### Configure I2S DAC for Speaker Output Source: https://github.com/witnessmenow/esp32-cheap-yellow-display/blob/main/PINS.md This snippet shows how to configure the I2S (Inter-IC Sound) peripheral in DAC (Digital-to-Analog Converter) mode for audio output to the speaker. It utilizes the ESP-IDF framework. ```c i2s_set_dac_mode(I2S_DAC_CHANNEL_LEFT_EN); ``` -------------------------------- ### ESP32 LED Control (Active Low) Source: https://github.com/witnessmenow/esp32-cheap-yellow-display/blob/main/PINS.md This snippet shows the GPIO pins assigned to the RGB LEDs on the CYD. It highlights that these LEDs are active low, meaning a LOW signal turns them ON and a HIGH signal turns them OFF. ```c++ // RGB LED pins const int RED_LED = 4; const int GREEN_LED = 16; const int BLUE_LED = 17; // Note: LEDs are "active low", meaning HIGH == off, LOW == on ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.