What MCU/Processor/Board and compiler are you using?
- WT32-SC01 Plus
- Arduino 1.8 using Visual Micro
- LVGL v9.2.2
The WT32-SC01 Plus uses a 320x480px RGB LCD using a ST7796U controller 8080 interface(I am not exactly sure what 8080 means)
Datasheet for the dev board: Here
Touch screen uses FT6336U I2C interface.
What do you want to achieve?
Right now I am just trying to get the basic demo_widgets demo to display, then get the touch working
Code to reproduce
I have been working towards something functional and this is my best attempt so far:
Since the lv_conf contains a section for ST7796U shouldn’t there be a way to define the parallel interface rather than writing a driver? I am a bit unclear on if the below flush function will work, found it online but can’t seem to find the source now. Should I be using something like LGFX to handle the actual writing to the display? Even so, the error I am getting about theming would be an issue.
lv_conf.h too long to post, if it is necessary I can post it cut up into parts
#include <lvgl.h>
#include <demos/lv_demos.h>
#include <examples/lv_examples.h>
#include <SPI.h>
// Define parallel pins (adjust based on your wiring)
#define screenWidth 480
#define screenHeight 320
#define BL_PWM 45
#define TFT_D0 9
#define TFT_D1 46
#define TFT_D2 3
#define TFT_D3 8
#define TFT_D4 18
#define TFT_D5 17
#define TFT_D6 16
#define TFT_D7 15
// Write Clock
#define TFT_WR 47
// Frame Sync
#define TFT_FSYNC 48
// Reset
#define TFT_RST 4
// Data/Command
#define TFT_DC 0
const unsigned int lvBufferSize = screenWidth * screenHeight / 10 * (LV_COLOR_DEPTH / 8);
uint8_t lvBuffer[lvBufferSize];
void setup() {
Serial.begin(115200);
pinMode(BL_PWM, OUTPUT);
analogWrite(BL_PWM, 200);
lv_init(); // Initialize LVGL
static lv_display_t* display = lv_display_create(screenWidth, screenHeight);
lv_display_set_color_format(display, LV_COLOR_FORMAT_RGB565);
lv_display_set_flush_cb(display, flush);
lv_display_set_buffers(display, lvBuffer, nullptr, lvBufferSize, LV_DISPLAY_RENDER_MODE_PARTIAL);
//static auto* lvInput = lv_indev_create();
//lv_indev_set_type(lvInput, LV_INDEV_TYPE_POINTER);
//lv_indev_set_read_cb(lvInput, my_touch_read);
pinMode(TFT_D0, OUTPUT);
pinMode(TFT_D1, OUTPUT);
pinMode(TFT_D2, OUTPUT);
pinMode(TFT_D3, OUTPUT);
pinMode(TFT_D4, OUTPUT);
pinMode(TFT_D5, OUTPUT);
pinMode(TFT_D6, OUTPUT);
pinMode(TFT_D7, OUTPUT);
pinMode(TFT_WR, OUTPUT);
pinMode(TFT_FSYNC, OUTPUT);
pinMode(TFT_RST, OUTPUT);
pinMode(TFT_DC, OUTPUT);
digitalWrite(TFT_RST, LOW); // Reset the display (important!)
delay(100);
digitalWrite(TFT_RST, HIGH);
delay(100);
lv_display_set_rotation(display, 90); // Rotate the display 90 degrees
lv_demo_widgets();
}
void loop() {
lv_timer_handler(); // Process LVGL events and drawing
delay(10);
}
//Flush and send8Bits are functions i found and tried to adapt for my use.
void flush(lv_display_t* disp, const lv_area_t* area, unsigned char* data) {
// Implementation for ST7796U 8-bit parallel interface.
uint32_t x = area->x1;
uint32_t y = area->y1;
uint32_t w = area->x2 - area->x1;
uint32_t h = area->y2 - area->y1;
// Iterate through the buffer and send data to the display.
for (uint32_t i = 0; i < lvBufferSize / (screenWidth * screenHeight); ++i) {
digitalWrite(TFT_DC, LOW); // Data/Command: Command
digitalWrite(TFT_WR, LOW); // Write
send8Bits(data + i * 2); // Assuming RGB565 (16 bits per pixel = 2 bytes)
digitalWrite(TFT_WR, HIGH);
}
}
void send8Bits(uint8_t* data) {
// Send 8 bits in parallel.
digitalWrite(TFT_FSYNC, LOW); // Start of frame sync
digitalWrite(TFT_FSYNC, HIGH);
digitalWrite(TFT_D0, (data[0] >> 7) & 0x01);
digitalWrite(TFT_D1, (data[0] >> 6) & 0x01);
digitalWrite(TFT_D2, (data[0] >> 5) & 0x01);
digitalWrite(TFT_D3, (data[0] >> 4) & 0x01);
digitalWrite(TFT_D4, (data[0] >> 3) & 0x01);
digitalWrite(TFT_D5, (data[0] >> 2) & 0x01);
digitalWrite(TFT_D6, (data[1] >> 7) & 0x01);
digitalWrite(TFT_D7, (data[1] >> 6) & 0x01);
}
This gets a compiler error: 1:10: fatal error: ../../src/themes/lv_theme_private.h: No such file or directory
even though the file is in the themes directory.
Tomorrow
It is late and I just wanted to post this and hope someone has ideas. I will be switching to the LGFX implementation from: here tomorrow but I do not expect it to fix my theme error.