Setting up LVGL+Micropython on ESP32-S3-Touch-LCD-4.3 from WaveShare #142
Replies: 21 comments 81 replies
-
I just recently made some changes that I am going to revert. I have to mess around with testing them locally to find out why they are not working properly. |
Beta Was this translation helpful? Give feedback.
-
Status update: i uncommented these lines: # data8=_DATA8,
# data9=_DATA9,
# data10=_DATA10,
# data11=_DATA11,
# data12=_DATA12,
# data13=_DATA13,
# data14=_DATA14,
# data15=_DATA15, Still can't access the REPL after flashing the code as well. |
Beta Was this translation helpful? Give feedback.
-
Plug your USB cable into the other USB port. That is the reason why you are not able to access the REPL. |
Beta Was this translation helpful? Give feedback.
-
This is the build command I use for that display...
and this is the code that I use to initialize the display... from micropython import const # NOQA
from i2c import I2C
import gt911
import lcd_bus
import task_handler
import lvgl as lv # NOQA
import rgb_display
_WIDTH = const(800)
_HEIGHT = const(480)
_BUFFER_SIZE = const(76800)
_CTP_SCL = const(9)
_CTP_SDA = const(8)
_CTP_IRQ = const(4)
_SD_MOSI = const(11)
_SD_SCK = const(12)
_SD_MISO = const(13)
_LCD_FREQ = const(13000000)
_PCLK_ACTIVE_NEG = const(0)
_HSYNC_PULSE_WIDTH = const(10)
_HSYNC_BACK_PORCH = const(10)
_HSYNC_FRONT_PORCH = const(10)
_VSYNC_PULSE_WIDTH = const(10)
_VSYNC_BACK_PORCH = const(10)
_VSYNC_FRONT_PORCH = const(20)
_PCLK = const(7)
_HSYNC = const(46)
_VSYNC = const(3)
_DE = const(5)
_DISP = None
_BCKL = None
_DRST = None
I2C_BUS = I2C.Bus(
host=1,
scl=_CTP_SCL,
sda=_CTP_SDA,
freq=400000,
use_locks=False
)
TOUCH_DEVICE = I2C.Device(
I2C_BUS,
dev_id=gt911.I2C_ADDR,
reg_bits=gt911.BITS
)
_DATA15 = const(10) # B7
_DATA14 = const(17) # B6
_DATA13 = const(18) # B5
_DATA12 = const(38) # B4
_DATA11 = const(14) # B3
_DATA10 = const(21) # G7
_DATA9 = const(47) # G6
_DATA8 = const(48) # G5
_DATA7 = const(45) # G4
_DATA6 = const(0) # G3
_DATA5 = const(39) # G2
_DATA4 = const(40) # R7
_DATA3 = const(41) # R6
_DATA2 = const(42) # R5
_DATA1 = const(2) # R4
_DATA0 = const(1) # R3
bus = lcd_bus.RGBBus(
hsync=_HSYNC,
vsync=_VSYNC,
de=_DE,
pclk=_PCLK,
data0=_DATA0,
data1=_DATA1,
data2=_DATA2,
data3=_DATA3,
data4=_DATA4,
data5=_DATA5,
data6=_DATA6,
data7=_DATA7,
data8= _DATA8,
data9=_DATA9,
data10= _DATA10,
data11= _DATA11,
data12=_DATA12,
data13=_DATA13,
data14=_DATA14,
data15=_DATA15,
freq=_LCD_FREQ,
hsync_front_porch=_HSYNC_FRONT_PORCH,
hsync_back_porch=_HSYNC_BACK_PORCH,
hsync_pulse_width=_HSYNC_PULSE_WIDTH,
hsync_idle_low=False,
vsync_front_porch=_VSYNC_FRONT_PORCH,
vsync_back_porch=_VSYNC_BACK_PORCH,
vsync_pulse_width=_VSYNC_PULSE_WIDTH,
vsync_idle_low=False,
de_idle_high=False,
pclk_idle_high=False,
pclk_active_low=_PCLK_ACTIVE_NEG,
)
buf1 = bus.allocate_framebuffer(_BUFFER_SIZE, lcd_bus.MEMORY_SPIRAM)
buf2 = bus.allocate_framebuffer(_BUFFER_SIZE, lcd_bus.MEMORY_SPIRAM)
display = rgb_display.RGBDisplay(
data_bus=bus,
display_width=_WIDTH,
display_height=_HEIGHT,
frame_buffer1=buf1,
frame_buffer2=buf2,
color_space=lv.COLOR_FORMAT.RGB565,
rgb565_byte_swap=True
)
display.set_power(True)
display.init()
display.set_backlight(100)
indev = gt911.GT911(TOUCH_DEVICE)
if indev.hw_size != (_WIDTH, _HEIGHT):
fw_config = indev.firmware_config
fw_config.width = _WIDTH
fw_config.height = _HEIGHT
fw_config.save()
del fw_config
# display.set_rotation(lv.DISPLAY_ROTATION._90) # NOQA
scrn = lv.screen_active()
scrn.set_style_bg_color(lv.color_hex(0x000000), 0)
slider = lv.slider(scrn)
slider.center()
task_handler.TaskHandler() |
Beta Was this translation helpful? Give feedback.
-
The display is running successfully. I can now see a slider. Is there extra documentation for LVGL+MicroPython for V9.x? |
Beta Was this translation helpful? Give feedback.
-
I found a better way of generating the code that is used in the binding and at some point I will write the generator code over again. The way it has been done is not the most efficient... |
Beta Was this translation helpful? Give feedback.
-
How do I rotate the UI display from a horizontal display to a vertical display? |
Beta Was this translation helpful? Give feedback.
-
At least this is my workflow for now, which I know is not the best (but it's the only way I currently know) and am sure will change in the future. |
Beta Was this translation helpful? Give feedback.
-
Another annoying issue that has an annoying workaround:
Keep getting this when trying to flash my own program. Erasing the flash and reflashing the firmware does the job but I have to reflash the programs in again but only to be greeted with this after the first or second time of flashing my program on to the hardware. |
Beta Was this translation helpful? Give feedback.
-
One question: in what way is the main.py ran on the device (like runs when booting or loops after booting)? Is it running as a loop or something, or is it only just running one time? I've been trying to setup a realtime local time display but haven't succeeded yet. |
Beta Was this translation helpful? Give feedback.
-
I noticed something funny: with the
|
Beta Was this translation helpful? Give feedback.
-
OK so when dealing with the RGBBus and using RGB565 with a 16 lane connection if your colors are off it is going to be because the pins are not defined correctly. I have seen this more than once where for some crazy reason the pin order is goofed up. so what you are going to need to do is double check the pins to see if they align with what the data sheet says. You will have to compare that with what is in the examples for the display as well. I have found that the datasheet is not always correct but the examples are and the examples also will give you a hint as to what pin actually does what. |
Beta Was this translation helpful? Give feedback.
-
An update on the SD Card Slot thingy: i recently bought an MMC Micro card to see whether it'll work on the board and it does not fit lol. I now bought another micro SD card and am waiting for it to arrive. |
Beta Was this translation helpful? Give feedback.
-
Update on the SD Card thingy: I rechecked the wiki again and it says that:
...whatever the hell that means. |
Beta Was this translation helpful? Give feedback.
-
I successfully built a .bin for the ESP32-S3-Touch-LCD-4.3 from WaveShare on both MacOS and Linux. There's lots of helpful info from kdschlosser in the Closed Issues for this repo regarding getting a build to actually work on MacOS and Linux - there are lots of things that might not work at first. I built a native binary for MacOS then Linux , then for the WaveShare board. Here's the build command for the WaveShare board: At the end of the build, it displays the command to flash the .bin onto the WaveShare board. You have to figure out the name of the USB serial port that appears on your computer when you plug the Waveshare board in using a USB cable. Replace "(PORT)" with that devicename. On my Linux box the device is /dev/ttyACM0 I installed mpremote on my Linux box so I could manipulate (copy from PC to board, etc.) Python files on the WaveShare board. I got some demo LVGL python demo code running on the board. The touchscreen works too. Copy the demo.py file to the board using Type |
Beta Was this translation helpful? Give feedback.
-
Colors are still not correct. (even with Type-32's swapping pins fix from comment #142) Another color demo program is: cdemo.py - draws a lot of buttons with the hex code for the background color as the label - with no font specified. cdemo.py.txt |
Beta Was this translation helpful? Give feedback.
-
Here is the palette test code. I believe I have the correct pin config, from your post #142. And the pin numbers match what's in the board datasheet on the WaveShare website. The button labels show the name of the LVGL Palette and the hex code for that color. in the following code I swapped the blue and green pins so that it is RGB instead of RBG, but that did not fix the color issue. It only made it make more sense. There is something incorrect about the pins, as some of another R, G or B gets involved when it is set to zero. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Here's those 3 buttons and more. This is with rgb565_byte_swap=FALSE
|
Beta Was this translation helpful? Give feedback.
-
SUCCESS! Replaced the code in pal.py.txt with your new pin definitions and Voila! |
Beta Was this translation helpful? Give feedback.
-
When I try to connect to a WiFi network using the commands that are displayed when I run help() in the REPL, Micropython crashes on an illegal instruction and does a crash dump. The specific Python statement that crashes it is sta_if.connect() |
Beta Was this translation helpful? Give feedback.
-
This here is the board I have and are referencing: ESP32-S3-Touch-LCD-4.3 from WaveShare
I modified the python code that @kdschlosser provided in #138 and flashed it into my board.
After flashing it, the board screen glows white (which is better than showing nothing since the last five days I've been trying to get it to show something other than nothing). But after flashing the python program on to it, I can't connect the REPL anymore, including flashing any other python code on to the board.
Am I doing something wrong here, or is there something weird with the code I modified...? I honestly am a complete amateur to this type of development and I would appreciate any help (scolding also works). I'd also appreciate if there's other resources I can reference off of.
Beta Was this translation helpful? Give feedback.
All reactions