-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Platform.io example with lvgl + touch + sd + lcd #2
Comments
Hello @AllanOricil! I can only tell you what I went through. This Cheap Yellow Display has more SPI devices than buses and none seem to share the same pins. The XPT2046 is on pins that don't seem to have hardware SPI, but SD and TFT are each on separate hardware SPI. I made this library to independently support software SPI on this device without forcing LVGL or TFT_eSPI to handle bitbanging the touchscreen (software SPI). Easier to isolate issues for me when I don't use a package-deal that includes touch and TFT. That's where my challenges took a different route from yours. I was on Arduino IDE and was trying both LVGL and TFT_eSPI, testing with each back and forth. At some point I decided this device was unusual enough that I had to separate out the touch capabilities from the TFT to isolate issues. I used TFT_eSPI for the display, this for the XPT2046 library, and the most common FAT32 SD library in Arduino IDE. I used all onboard devices simultaneously, I never recall an SD card issue on mine though. Check the basics like make sure your power supply is plenty. The next thing that comes to mind is that in LVGL, if the touch is set to hardware SPI, it may be trying the other hardware SPI bus, which is really your SD. Sounds like this library could help you isolate issues if you are able to remove touch as an LVGL component. Full integration with LVGL or your graphics lib is best, this was a rudimentary but effective workaround for me. These devices are weird but so cool. I hope you find your fix. Let me know if I can help any more, I'm not an expert, just an enthusiast. |
I have no idea where to start to fix my issue, really. I started this project with almost no knowledge of microcontrollers. Could you tell me if there is a solution? Thank you @ddxfish |
@AllanOricil that make a lot of sense, that's how I started too. Here are some rough ideas.
If there was a direct answer, I'd give it. I'm maybe medium skill level, so nothing special. The main challenge in this board was that normal libraries didn't often work due to the weird pinout. I had to swap them out with others and constantly rework my code to adapt. I think your key is going to be swapping libraries at first. Just in case it helps, this diagram helped me confirm my pinout a while back for the CYD. |
@AllanOricil I ran LVGL on my esp32 CYD on platform.io and my sd card and it works with this library. I have touch and SD functions in my loop and they both work with TFT enabled. Your code you posted to your issue is also good, or at least looks good. The issue you are having is in the code you didn't post, or less likely, your power supply. Check your flush function to make sure it works without SD and touch for debug, check your pin configs in all libraries you use, and if it fails, swap the smartdisplay driver for TFT_eSPI ILI9341 driver, which I also tested with this setup and it works. |
@ddxfish could you publish this platform.io project to github so that I can flash it into my esp32 and see if it works? |
@AllanOricil I'll post the relevant parts of the code. I used TFT_eSPI as the display driver, but earlier versions had smartdisplay driver working fine too without any touch (no, I didn't keep or continue that version after testing it). This uses TFT_eSPI as the driver instead of smartdisplay for the ILI9341, and LVGL as the graphics lib. This is very bad code, only use it for testing. I should be using LVGL's event handler instead of my own in loop() to bypass event handling. It draws sqaure-like-things on the screen and not circles. It cuts off part of the display. But it prints SD card while using touch and the display at the same time. platformio.ini
main.cpp
TFT_eSPI User_Setup_Config.hcomment out the first line, uncomment the second line later in the code.
TFT_eSPI Setup42_ILI9341_ESP32.h
SdFatConfig.h
lv_conf.hThis is just the top of the file.
|
@ddxfish my weekend will be fun! |
@AllanOricil good luck! I think you can pull this off. Tell me if you get it working in the end. |
@ddxfish I made a repo with the code you shared. https://github.com/AllanOricil/lvgl-lcd-touch-sd-card-test After building and deploying:
![]() Could you take a look and see what I missed? obs: My TFT seems to be obs: dependencies are tagged, and using a git repo because my platform.io could not find them the way you described. Are we using the same dependencies? could you check if UPDATE: I was able to calibrate the touch! But I still cant see anything rendering on the screen. |
I GOT IT! FUCK YEAH! hehe |
@AllanOricil It sounds like you are close. I had a white screen when I had the wrong pin numbers. ST7789- I didn't know CYD had this variant on displays. TFT_eSPI supports this. Edit your User_Setup.h to point to one of the other drivers in the User_Setups directory. In User_Setup.h you'll find a ton of setups, and that #42 is uncommented, try a different one. Try enabling one of the ST7789 config files, maybe #203. Then edit the file for #203 to match your pins and resolution. To narrow down issues with driver vs lvgl, add a snippet of code at the start of your setup that inits the TFT_eSPI and draws a circle. |
Just saw this. Awesome! I hope the rest goes without speedbumps hehe. |
@ddxfish Im using the same driver as you. I thought about using ST7789 because I was using this platform.io board in project. |
I'm still having a small problem. The rotation isn't working, and tft can't see part of the screen. Look. Do you have a guess of what I missed? 20240316_162921.mp4 |
@AllanOricil I'm glad it helped. I'll close this issue. I might use LVGL for my next project too. Good luck with your project! |
@ddxfish the touch works, but lvgl does not react to it. Look at my latest changes: https://github.com/AllanOricil/esp32-lvgl-lcd-touch-sd-card the touch callback isn't called :/ |
finally fixed it. In lvgl 7 we have to call WhatsApp.Video.2024-03-16.at.21.33.16.mp4 |
Nice work on that one! I've been working on a better demo on the way to my next LVGL project, but it might take me a bit longer. It'll have all of these, RBG LED, photo sensor, and maybe a speaker demo too. I'll reference your code to see how to fix that rotation. I was playing with lv_tick at one point and will probably use that so I can use the internal event handler. So much cleaner. |
@ddxfish I'm trying to make it work with lvgl 8.3.11 but it is behaving very weird.
|
Updated the example to use lvgl 8.3.11 https://github.com/AllanOricil/esp32-lvgl-lcd-touch-sd-card/tree/lvgl_8 |
I am making a local wikireader from my CYD using LVGL. I'll use v8 too, it has a better event handler. I'll post both the project base code and the final. I feel like we need a repo for CYD community for example code. |
@ddxfish after migrating to lvgl 8.3.11 in my project, I had to disable build_flags =
-Ofast
-Wall
-D WIFI_SSID=$WIFI_SSID
-D WIFI_PASSWORD=$WIFI_PASSWORD
-D USER_SETUP_LOADED=1
-D TFT_RGB_ORDER=TFT_RGB
-D LVGL_DISPLAY_WIDTH=320
-D LVGL_DISPLAY_HEIGHT=240
-D ILI9341_DRIVER=1
-D LCD_WIDTH=320
-D LCD_HEIGHT=240
-D TFT_WIDTH=320
-D TFT_HEIGHT=240
-D TFT_MISO=19
-D TFT_MOSI=13
-D TFT_SCLK=14
-D TFT_CS=15
-D TFT_DC=2
-D TFT_RST=12
-D TFT_BCKL=21
-D SPI_FREQUENCY=40000000
-D SPI_READ_FREQUENCY=16000000
-D SMOOTH_FONT=1
-D TOUCH_MOSI=32
-D TOUCH_MISO=39
-D TOUCH_CLK=25
-D TOUCH_CS=33
-D TF_CS=5
-D ENABLE_FAT12_SUPPORT=1
-D LV_CONF_PATH="${PROJECT_DIR}/lv_conf.h"
-I include ;
|
I'm looking for a way to fix my problem of not being able to use the SD card when LCD + Touch are working, each using a different SPI bus. Someone on the CYD discord channel told me that your library is the solution.
I'm currently using a library called
smartdisplay
to initialize the display and lcd. As soon as I init both I can no longer use the SD card. So, with your library I think I can overcome this issue.Could you help me? Thank you.
The text was updated successfully, but these errors were encountered: