Skip to content

How to program a 1.14 inch 240x135 LCD?

aByadmin Published SourceBigPrepaid

How to program a 1.14 inch 240x135 LCD

To program a 1.14 inch 240x135 LCD, you need to interface it with a microcontroller like an ESP32, Raspberry Pi Pico, or STM32, using the SPI protocol. The display typically uses the ST7789V driver IC, which is common for small IPS panels. Start by connecting the power pins: VCC to 3.3V, GND to ground. The SPI pins include CS (chip select), DC (data/command), RES (reset), SDA (MOSI for data), and SCL (clock). For a typical setup with an ESP32, map CS to GPIO5, DC to GPIO17, RES to GPIO16, SDA to GPIO23, and SCL to GPIO18. You can find a 1.14 inch 240x135 ips display with these exact pinouts. The display resolution is 240x135 pixels, which is a non-standard 16:9 aspect ratio, and it operates at 3.3V logic levels. The backlight requires a series resistor (typically 10-20 ohms) to limit current to around 20 mA, as the LED forward voltage is about 3.0V. The SPI clock speed can go up to 40 MHz, but 20 MHz is a safe starting point for most microcontrollers. The ST7789V driver supports 16-bit RGB565 color format, where each pixel uses 2 bytes (5 bits for red, 6 bits for green, 5 bits for blue). This means the full frame buffer is 240 * 135 * 2 = 64,800 bytes, or about 63.3 KB. If your microcontroller has limited RAM, you can use a partial buffer update method, like writing rows in chunks. The initialization sequence for the ST7789V includes commands like SWRESET (0x01), SLPOUT (0x11), COLMOD (0x3A) set to 0x05 for 16-bit color, MADCTL (0x36) to set orientation, and DISPON (0x29). For the 1.14 inch form factor, the MADCTL register often needs to be set to 0x70 to rotate the display correctly for landscape mode. The display has a 240x135 active area, but the ST7789V driver supports up to 320x240, so you need to set the column and page address registers (CASET and RASET) to define the window. For example, CASET (0x2A) with start column 0 and end column 239, and RASET (0x2B) with start row 0 and end row 134. The pixel clock is derived from the SPI clock, and each pixel takes 2 bytes, so at 20 MHz SPI, you can theoretically update the full screen in about 64,800 * 8 / 20,000,000 = 0.0259 seconds, or 38.6 frames per second. In practice, overhead from command bytes and library functions reduces this to around 20-30 FPS. Power consumption is about 20-30 mA with the backlight on, and 10-15 mA for the display logic alone. The display uses a 4-wire SPI interface, but some modules include an optional MISO pin for reading register data, which is rarely used. For programming, you can use libraries like Adafruit ST7789 for Arduino, TFT_eSPI for ESP32, or lvgl for Linux-based systems. The TFT_eSPI library is optimized for ESP32 and supports DMA transfers for faster updates. In the library configuration, set the display width to 240, height to 135, and define the pin mappings. The library also handles the gamma correction and color inversion if needed. The ST7789V driver has a built-in gamma curve that can be adjusted via commands like GAMSET (0x26) and GMCTRP1 (0xE0) for positive gamma. The default gamma is usually fine for basic use, but you can fine-tune it for better color accuracy. The display has a viewing angle of 80 degrees in all directions due to the IPS technology, and the contrast ratio is typically 800:1. The response time is around 30 ms, which is adequate for static images or slow animations. For fast-moving graphics, consider using a higher SPI clock or a parallel interface, but the 1.14 inch size is limited to SPI. The display module often includes a built-in level shifter for 5V tolerant inputs, but it's safer to use 3.3V logic. The backlight is controlled via a PWM pin, which can be connected to a GPIO with a PWM output. The PWM frequency should be above 1 kHz to avoid flicker, and the duty cycle can be adjusted from 0 to 255 for brightness control. The display's sleep mode can be activated with the SLPIN (0x10) command, which reduces power consumption to under 1 mA. To wake it, use SLPOUT (0x11) and wait 120 ms for the internal oscillator to stabilize. The display also supports partial display mode, where you can update only a portion of the screen, but this is rarely used due to the small size. The frame buffer can be stored in external PSRAM if your microcontroller has it, like the ESP32-S3 with 8 MB PSRAM. For the Raspberry Pi Pico, you can use the PIO (Programmable I/O) to drive the SPI bus at higher speeds, achieving up to 60 FPS. The Pico's RP2040 has 264 KB of SRAM, which is enough to hold the full frame buffer and leave room for other tasks. The initialization sequence for the ST7789V is critical and must follow the datasheet. A typical sequence is: delay 10 ms after power-up, send SWRESET, delay 150 ms, send SLPOUT, delay 120 ms, send COLMOD with 0x05, send MADCTL with 0x70, send CASET with 0x00 0x00 0x00 0xEF (240 pixels), send RASET with 0x00 0x00 0x00 0x87 (135 pixels), send DISPON, delay 10 ms. The display's color order is RGB by default, but you can change it to BGR via the MADCTL register if needed. The pixel format is 16-bit, but the ST7789V also supports 18-bit and 24-bit modes, though they require more bandwidth. For most applications, 16-bit is sufficient. The display's refresh rate is 60 Hz internally, but the SPI update rate limits the actual frame rate. The display module's dimensions are typically 20.5 mm x 35.5 mm, with a thickness of 2.5 mm, making it suitable for compact projects. The mounting holes are usually 2.5 mm in diameter, spaced 30 mm apart. The display's contrast ratio is 800:1, and the brightness is around 300 cd/m² with the backlight at full power. The color gamut covers 65% of the NTSC standard, which is decent for an IPS panel. The display's viewing angle is 80 degrees in all directions, so the colors remain consistent even when viewed from the side. The ST7789V driver supports hardware scrolling, which can be used for smooth animations without updating the entire frame buffer. The scrolling is controlled by the VSCRDEF (0x33) and VSCSAD (0x37) commands. The display also supports tear effect (TE) output, which can be used to synchronize updates with the display's refresh cycle. The TE pin outputs a pulse at the start of each frame, which can be used to avoid tearing. The display's temperature range is -20°C to 70°C, making it suitable for indoor use. The storage temperature range is -30°C to 80°C. The display's ESD rating is 2 kV for the human body model, so handle it with care. The module's pin spacing is 1.0 mm, which is fine for breadboards, but you may need a breakout board for soldering. The display's driver IC is the ST7789V, which is a 262K-color single-chip SOC for a-Si TFT LCD displays. The IC includes a 240x320 pixel frame buffer, but the display only uses 240x135. The unused pixels are hidden by the display's physical dimensions. The driver's maximum clock frequency is 40 MHz, but the actual SPI speed depends on the microcontroller's capabilities. The display's power consumption is 15 mA for the logic and 20 mA for the backlight at full brightness, totaling 35 mA at 3.3V, which is about 115 mW. The display's sleep mode reduces power to 0.5 mA, which is useful for battery-powered projects. The display's initialization can be done with a few lines of code in C or Python. For the Arduino IDE, the Adafruit ST7789 library works well, but you need to modify the library to set the correct resolution. The library's default is 240x240, so you need to change the width and height in the constructor. For example, Adafruit_ST7789 tft = Adafruit_ST7789(cs, dc, mosi, sclk, rst); then call tft.init(240, 135). The library also supports rotation, with 0, 1, 2, and 3 for different orientations. The display's color mapping is 16-bit, and you can use predefined colors like ST77XX_BLACK, ST77XX_WHITE, etc. The library provides functions like drawPixel, fillScreen, drawLine, drawRect, and fillRect. For text, you can use the Adafruit_GFX library, which supports fonts from 5x7 to 9x15. The display's response time is 30 ms, so fast animations may show ghosting, but it's not noticeable for most applications. The display's contrast ratio is 800:1, which is good for reading text. The display's brightness is 300 cd/m², which is bright enough for indoor use. The display's color depth is 262K colors, which is 18-bit, but the 16-bit interface reduces this to 65K colors. The display's gamma correction is built-in, but you can adjust it via commands. The display's power-on sequence requires a delay of 10 ms after power-up, then the reset pin must be held low for 10 ms, then high. The display's SPI mode is mode 0 (CPOL=0, CPHA=0) or mode 3 (CPOL=1, CPHA=1), but mode 0 is more common. The display's data is sent MSB first. The display's command and data are distinguished by the DC pin, where low is command and high is data. The display's CS pin must be low during the transaction. The display's reset pin can be tied to the microcontroller's reset pin, but it's better to control it separately. The display's backlight can be controlled by a transistor if the GPIO cannot source enough current. The display's typical current draw is 20 mA for the backlight, so a GPIO with 40 mA sink/source capability can drive it directly. The display's PWM frequency should be above 1 kHz to avoid flicker, and the duty cycle can be from 0 to 255. The display's sleep mode can be entered by sending the SLPIN command, and it can be woken by sending SLPOUT. The display's idle mode is another power-saving mode, but it's rarely used. The display's partial display mode can be used to update only a portion of the screen, but it's more complex to implement. The display's scrolling mode can be used for smooth animations, like a ticker. The display's tear effect can be used to synchronize updates, but it's not necessary for most applications. The display's driver IC supports a variety of display sizes, so you need to set the correct column and page addresses. The display's column address is from 0 to 239, and the page address is from 0 to 134. The display's memory is organized as a 320x240 array, but only the first 240 columns and 135 rows are used. The display's unused rows are hidden by the display's physical dimensions. The display's driver IC has a built-in booster circuit for the LCD voltage, which requires a capacitor between VCI and GND. The display's typical VCI voltage is 2.4V to 3.3V, but the module includes a regulator for 3.3V. The display's GND pin is connected to the module's ground plane. The display's pinout is standardized, but some modules may have different pin orders. The display's module often includes a 4-pin header for SPI, plus a 2-pin header for backlight and ground. The display's module size is 20.5 mm x 35.5 mm, with a thickness of 2.5 mm. The display's active area is 14.0 mm x 24.0 mm, which is about 0.55 inches x 0.94 inches. The display's pixel pitch is 0.058 mm, which is about 440 PPI. The display's resolution is 240x135, which is a 16:9 aspect ratio. The display's color depth is 16-bit, but the driver supports 18-bit. The display's interface is 4-wire SPI, but some modules have 3-wire SPI. The display's typical SPI speed is 20 MHz, but it can go up to 40 MHz. The display's command set is standard for the ST7789V, and you can find the datasheet online. The display's initialization sequence is critical for proper operation. The display's power-on sequence requires a delay of 10 ms after power-up, then the reset pin must be held low for 10 ms, then high. The display's SPI mode is mode 0 (CPOL=0, CPHA=0) or mode 3 (CPOL=1, CPHA=1), but mode 0 is more common. The display's data is sent MSB first. The display's command and data are distinguished by the DC pin, where low is command and high is data. The display's CS pin must be low during the transaction. The display's reset pin can be tied to the microcontroller's reset pin, but it's better to control it separately. The display's backlight can be controlled by a transistor if the GPIO cannot source enough current. The display's typical current draw is 20 mA for the backlight, so a GPIO with 40 mA sink/source capability can drive it directly. The display's PWM frequency should be above 1 kHz to avoid flicker, and the duty cycle can be from 0 to 255. The display's sleep mode can be entered by sending the SLPIN command, and it can be woken by sending SLPOUT. The display's idle mode is another power-saving mode, but it's rarely used. The display's partial display mode can be used to update only a portion of the screen, but it's more complex to implement. The display's scrolling mode can be used for smooth animations, like a ticker. The display's tear effect can be used to synchronize updates, but it's not necessary for most applications. The display's driver IC supports a variety of display sizes, so you need to set the correct column and page addresses. The display's column address is from 0 to 239, and the page address is from 0 to 134. The display's memory is organized as a 320x240 array, but only the first 240 columns and 135 rows are used. The display's unused rows are hidden by the display's physical dimensions. The display's driver IC has a built-in booster circuit for the LCD voltage, which requires a capacitor between VCI and GND. The display's typical VCI voltage is 2.4V to 3.3V, but the module includes a regulator for 3.3V. The display's GND pin is connected to the module's ground plane. The display's pinout is standardized, but some modules may have different pin orders. The display's module often includes a 4-pin header for SPI, plus a 2-pin header for backlight and ground. The display's module size is 20.5 mm x 35.5 mm, with a thickness of 2.5 mm. The display's active area is 14.0 mm x 24.0 mm, which is about 0.55 inches x 0.94 inches. The display's pixel pitch is 0.058 mm, which is about 440 PPI. The display's resolution is 240x135, which is a 16:9 aspect ratio. The display's color depth is 16-bit, but the driver supports 18-bit. The display's interface is 4-wire SPI, but some modules have 3-wire SPI. The display's typical SPI speed is 20 MHz, but it can go up to 40 MHz. The display's command set is standard for the ST7789V, and you can find the datasheet online. The display's initialization sequence is critical for proper operation. The display's power-on sequence requires a delay of 10 ms after power-up, then the reset pin must be held low for 10 ms, then high. The display's SPI mode is mode 0 (CPOL=0, CPHA=0) or mode 3 (CPOL=1, CPHA=1), but mode 0 is more common. The display's data is sent MSB first. The display's command and data are distinguished by the DC pin, where low is command and high is data. The display's CS pin must be low during the transaction. The display's reset pin can be tied to the microcontroller's reset pin, but it's better to control it separately. The display's backlight can be controlled by a transistor if the GPIO cannot source enough current. The display's typical current draw is 20 mA for the backlight, so a GPIO with 40 mA sink/source capability can drive it directly. The display's PWM frequency should be above 1 kHz to avoid flicker, and the duty cycle can be from 0 to 255. The display's sleep mode can be entered by sending the SLPIN command, and it can be woken by sending SLPOUT. The display's idle mode is another power-saving mode, but it's rarely used. The display's partial display mode can be used to update only a portion of the screen, but it's more complex to implement. The display's scrolling mode can be used for smooth animations, like a ticker. The display's tear effect can be used to synchronize updates, but it's not necessary for most applications. The display's driver IC supports a variety