This issue has gone on far to long.
Using the python drivers ili9XXX.py and xpt2046.py with either machine.SDCard or sdcard.py drivers
I could not find any combination where these three divices would work together.
I have also tryed using the lv_spi.py with no success.
Also sdcard.py has issues with 2GB cards and other problems, so I’d rather use machine.SDCard!
Let fix this once and for all !!!
I am using an ESP32 Wrover module with spiram
lv_micropython v9 using micropython v1.20
built with ESP-IDF v4.4.5
With the following code I am able to mount my SDCard.
List Directories… listdir(‘/sd’) and os.listdir(‘/sd/data’) ouput correctly.
Then initialize the display and touch drivers.
Load display elements…
Then TRY to List Directories AGAIN…
/sd shows… /sd: [‘test.txt’] should be… /sd: [‘System Volume Information’, ‘data’]
/sd/data gets…
Traceback (most recent call last):
File “”, line 45, in
OSError: [Errno 2] ENOENT
Display and Touch functions work fine but the SD driver… not sooo much.
import lvgl as lv
from ili9XXX import ili9341
from xpt2046 import xpt2046
from machine import SDCard
import os
print('Mount SD Card')
try:
sd = SDCard(slot=2, cs=14, freq=20_000_000)
os.mount(sd, '/sd')
print("\nList Dir's")
print(f"/sd: {os.listdir('/sd')}")
print(f"/sd/data: {os.listdir('/sd/data')}")
except Exception as e:
print(f'SD Error\n{e}')
print('Load TFT Driver')
disp = ili9341(hybrid=True, spihost=2, miso=-1, mosi=-1, clk=-1, cs=15, mhz=20, dc=13, rst=-1, power=-1, factor=48, half_duplex=False, backlight=27, backlight_on=1)
print('Load Touch Driver')
touch = xpt2046(spihost=2, cs=5) # half_duplex=False causes button to lock up !!!
def button_cb(e):
if e.get_code() == lv.EVENT.CLICKED:
print("Clicked")
scr = lv.scr_act()
u_name = lv.label(scr)
u_name.align(lv.ALIGN.TOP_MID, 0, 40)
u_name.set_style_text_font(lv.font_montserrat_20, 0)
u_name.set_text('SPI Issue')
btn = lv.btn(scr)
btn.align(lv.ALIGN.TOP_MID, 0, 250)
btn.add_event(button_cb, lv.EVENT.CLICKED, None)
btn_lbl = lv.label(btn)
btn_lbl.set_text("CLICK Me")
lv.scr_load(scr)
print("\nList Dir's AGAIN")
print(f"/sd: {os.listdir('/sd')}")
print(f"/sd/data: {os.listdir('/sd/data')}")
Output…
>>>
>>>
Mount SD Card
List Dir's
/sd: ['System Volume Information', 'data']
/sd/data: ['test.txt']
Load TFT Driver
Double buffer
ILI9341 initialization completed
Enable backlight
Load Touch Driver
List Dir's AGAIN
/sd: ['test.txt']
♦Traceback (most recent call last):
File "<stdin>", line 45, in <module>
OSError: [Errno 2] ENOENT
♦>
MicroPython v1.20.0-700-g841ece132-dirty on 2023-09-15; ESP32 module (spiram) with ESP32
Type "help()" for more information.
>>>
>>>
I’m hoping the new maintainers of LV_Micropython could tackle this insidious problem
that this and the micropython forum are plagued with help wanted re. this issue.