Closed dizcza closed 1 year ago
@dizcza The sample uses shared SPI so helper_storage.hpp needs only CS pin. LovyanGFX initialize SPI already so again initialising is not required.
By weekend will update the sample with more clarity in comments on this.
@dizcza Also make sure to add this in your config file for enabling SD support
SD card requires a defined MISO pin, not -1.
@dizcza For using shared SPI bus you need to enable bus_shared = true in LovyanGFX. Once that's done you don't need to initialize the bus again.
After that if you add the following, SD card related code will be taken care of in helper_storage.hpp
.
You only need CS pin since SPI bus is initialized by LovyanGFX by default.
#define SD_ENABLED
Check conf_FeatherS3_ILI9341.h
for example configuration.
For using shared SPI bus you need to enable bus_shared = true in LovyanGFX. Once that's done you don't need to initialize the bus again.
The bus is shared by default in LGFX. I'm not initializing the bus again.
Have you tried connecting an external SD card slot to one of these boards? In particular, to WT32-SC01? I guess not, because
The only way I got your example running was after I
That means SD card is not on the same (shared) bus as the display.
Sample is using shared bus for both display and SD Card.
This is the working sample config using shared bus
https://github.com/sukesh-ak/ESP32-LVGL8x-SDSPI/blob/master/main/conf_FeatherS3_ILI9341.h
The only way I got your example running was after I
- changed SPI2_HOST to SPI3_HOST
- connected SD card MISO pin to one of the board pins, say 32
- Set LGFX MISO pin to 32 https://github.com/lovyan03/LovyanGFX/blob/9de99d25496413f133ce3c057fa3edb60148f523/src/lgfx/v1_autodetect/LGFX_AutoDetect_ESP32.hpp#L1717
Didn't realize you were connecting external SD card to WT32-SC01. Will take a look for that scenario.
conf_FeatherS3_ILI9341.h would work had I had the board. Because there you initialize everything manually rather than relying on LGFX autodetect functionality. In particular, you set a valid pin number for MISO, not -1
. In other words, the connection is full-duplex.
In WT-SC01, however, the default SPI bus (in LGFX implementation) is half-duplex unless you forget about autodetect and write a custom script as you do with FeatherS3.
I don't know if an SD card can run in half-duplex. If I just set MISO pin to -1
in spi_bus_config_t
, it fails to initialize.
I'm using HW-125 adapter
conf_FeatherS3_ILI9341.h would work had I had the board. Because there you initialize everything manually rather than relying on LGFX autodetect functionality. In particular, you set a valid pin number for MISO, not
-1
. In other words, the connection is full-duplex.In WT-SC01, however, the default SPI bus (in LGFX implementation) is half-duplex unless you forget about autodetect and write a custom script as you do with FeatherS3.
I don't know if an SD card can run in half-duplex. If I just set MISO pin to
-1
inspi_bus_config_t
, it fails to initialize.I'm using HW-125 adapter
Understood.
A new sample for WT32-SC01 & WT32-SC01 Plus is being cooked. Will take care of this issue in that sample by not using autodetect, so we can provide MISO there.
@dizcza Here is the new sample specially for WT32-SC01 and the new Plus version which has ESP32-S3 + SD Card.
It works. But I'd like to see these changes in the template repository it has been generated from, as I suppose I'll be supporting the main repository, not the offspring. In particular, I see you've switched to lvgl v9 there. I don't need helper storage code since I'll be using my sdcard component anyway.
Once you backport lvgl v9 config to the template repository, I may come up with a PR to address some compilation warnings and other things I encounter.
@dizcza https://github.com/sukesh-ak/WT32-SC01-PLUS-LVGL-IDF
I have marked that repo also as a template. Other repo is a mix of different screens which also needs a lot of conditional compiler options.
Also the UI is not configured for Portrait/Landscape auto scaling.
I am planning to add several features to this one, since this has TFT and CTP. So this repo will support devices with different resolution with CTP only.
Few things I am going to add are
Like I mentioned earlier, I have moved on so not sure. It was working then.
ESP32-TUX is the latest version and now it uses ESP-IDF 5.0 This supports 4 different devices now and more to come.
The SD card support https://github.com/sukesh-ak/ESP32-LVGL8x-SDSPI/blob/master/main/helper_storage.hpp seems not finished: it lacks SPI initialization (
spi_bus_initialize
) prior mounting an SD card with SPI interface.But I also don't know how to wire an external SD card slot to WT32-SC01 with SPI. Since it should be shared with the TFT LCD, I first used
but then I noticed
#define PIN_NUM_CS GPIO_NUM_33
inhelper_storage.hpp
. So I need to know the correct MISO and CS pins to finish SD card wiring. And get SPI initialization fixed, of course.I'm using an HW-125 SD card slot, not an expansion board.