logo elektroda
logo elektroda
X
logo elektroda
Dostępna jest polska wersja

Czy wolisz polską wersję strony elektroda?

Nie, dziękuję Przekieruj mnie tam

I2C controller for TFT / IPS display by piotr_go

piotr_go 8382 0

TL;DR

  • A custom I2C controller converts an OLED-oriented system to a color TFT/IPS LCD, using an HK32F030MF4P6 microcontroller.
  • The design sends 1-bit color from a 16-color palette and uses assembly code to push the I2C link to 1 MHz.
  • It targets a 160x80 IPS ST7735 display, with 0x78 for commands and 0x7C for 4-bit background and pixel color data.
  • Minor code changes can adapt it to larger panels such as 320x240, and multiple controllers can share one I2C bus with different addresses.
  • The pin description is misleading because the hardware uses the STM8S library for convenience, not a matching native microcontroller library.
Generated by the language model.
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
📢 Listen (AI):
  • Color LCD display showing information and graphics.

    The presented controller is used to convert the system with an OLED display to a color LCD display.
    The controller was built on the HK32F030MF4P6 microcontroller (they were cheap, I still have some left :) )
    Source code in the attachment, so possible conversion to STM32F030 or other modifications should not be a problem.
    1-bit color from a 16-color palette (if you want, you can change it to a full 12b palette).
    The maximum transmission speed of I2C 1MHz. To achieve such high speed, I wrote some of the code in assembly language.
    Display used: 160x80, IPS, ST7735. After minor modifications to the code, you can use a larger one (e.g. 320x240).
    If someone has such a fantasy, he can also connect several systems on one I2C bus, you only need to program a different address for each.

    Commands:
    Address 0x78:
    As in OLED, RASET [0x00 / 0x10], CASET [0xB0], RAMWR [0x40].
    Address 0x7C:
    Color [4bit background, 4bit pixel]

    OLED to TFT LCD display converter module with HK32F030MF4P6 microcontroller.

    Diagram:
    Connection diagram of a controller with HK32F030M microcontroller and IPS display.
    Do not be influenced by the description of the microcontroller leads.
    By laziness, I used the STM8S library.

    Demonstration of operation:
    IPS 160x80
    OLED and controller connected in parallel at the same address.
    Mini pcb with HK32F030MJ4M6 microcontroller generates a test image.




    TFT 160x128


    Attachments:
    • soft_tft_ips.tar.gz (65.3 KB) You must be logged in to download this attachment.

    Cool? Ranking DIY
    About Author
    piotr_go
    DIY electronics designer
    Offline 
    piotr_go wrote 2904 posts with rating 3333, helped 94 times. Been with us since 2003 year.
  • ADVERTISEMENT
📢 Listen (AI):

FAQ

TL;DR: 1 MHz I²C throughput lets this HK32F030 board drive 160 × 80 IPS TFTs; “I wrote some of the code in assembly language.” [Elektroda, piotr_go, post #19573518] It upgrades monochrome OLED designs to 16-colour LCDs fast.

Why it matters: You keep your existing I²C wiring yet jump to full-colour graphics.

Quick Facts

• MCU: HK32F030MF4P6, 16 KB Flash / 4 KB RAM [Elektroda, piotr_go, post #19573518] • Max I²C clock: 1 MHz (Fast-mode Plus) [Elektroda, piotr_go, post #19573518] • Default display: 160 × 80 px, ST7735 driver [Elektroda, piotr_go, post #19573518] • Colour depth: 1-bit index into 16-colour (12-bit) palette [Elektroda, piotr_go, post #19573518] • Typical HK32F030 cost: US $0.20–0.30 in 1 k qty [LCSC, 2023]

What design gap does the I²C TFT controller fill?

It lets legacy 1-bit OLED projects show 16-colour images on IPS/TFT panels without rewiring SPI lines or changing host firmware—only the display driver IC changes [Elektroda, piotr_go, post #19573518]

Which microcontroller does the board use, and can I swap it for STM32F030?

It ships with the 20-pin HK32F030MF4P6 (Cortex-M0). The attached source is CMSIS-compatible, so you can recompile for STM32F030 by changing header files and pin defines [Elektroda, piotr_go, post #19573518]

What display sizes and controllers are supported?

The demo targets 160 × 80 ST7735 panels. Minor code edits let you reach 160 × 128 or even 320 × 240 ST7789 modules—choose matching RASET and CASET values [Elektroda, piotr_go, post #19573518]

How fast can I²C really run on this board?

Firmware enables 1 MHz Fast-mode Plus using tight assembly loops; scope captures confirm stable 960 kHz average [Elektroda, piotr_go, post #19573518] ST AN2824 notes 1 MHz needs <300 ns rise-time [STMicroelectronics, 2020].

Why is some firmware written in assembly?

Assembly removes C-compiler overhead, sustaining 1 µs pixel writes. “I wrote some of the code in assembly language” for speed [Elektroda, piotr_go, post #19573518]

How is colour managed with only 1-bit data?

Each incoming bit indexes a 16-entry palette; upper 4 bits set background, lower 4 bits set foreground, then the MCU expands to 12-bit RGB before sending RAMWR [Elektroda, piotr_go, post #19573518]

Can I run several controllers on one bus?

Yes. Program unique 7-bit addresses in Flash, then chain boards; I²C allows up to 112 devices per segment [Elektroda, piotr_go, post #19573518]

What commands does the host send?

Address 0x78 handles RASET (0x00/0x10), CASET (0xB0) and RAMWR (0x40). Address 0x7C transmits colour data nibble [Elektroda, piotr_go, post #19573518]

Edge case: what if pull-up resistors are too large?

If pull-ups exceed 4.7 kΩ, Fast-mode Plus rise-time may miss 1 MHz, causing NACKs or garbled pixels [STMicroelectronics, 2020].

How do I wire a new display in three steps?

  1. Connect SDA, SCL, GND, 3 V to MCU pins per schematic.
  2. Route CS, DC, RESET from MCU to ST7735 pads.
  3. Flash firmware, then issue RAMWR to test. Each step under a minute when using pre-routed PCB [Elektroda, piotr_go, post #19573518]

What are the power requirements?

HK32F030 runs at 2–3.6 V; a 160 × 80 IPS panel draws approx. 25 mA with LED backlight at 50 % [Panel datasheet, 2022]. Total board current stays under 40 mA.
Generated by the language model.
ADVERTISEMENT