ELCROW CrowPanel –ESP32 Terminal with 3.5 inch parallel 480x320 TFT capacitive touch RGB display (DLC35010R) #104
Replies: 4 comments
-
Here is a small test program, which demonstrates how to use the module:
|
Beta Was this translation helpful? Give feedback.
-
There is a possible issue.... The init functions don't return the objects they created. While technically speaking you can get away with doing this because of the callback functions being registered in LVGL are what hold reference to the objects is what prevents them from being garbage collected it is technically not a great idea to do. Use case example is if you redirect the indev to use a different callback for the purposes of displaying a screen saver. Once the callback gets changed to something that is not a method in the instance for the driver the driver is going to get GC'd resulting in a crash. The display driver and indev drivers really should be initialized at the module level. For code organization purposes you put the display driver code into it's own module name "display_driver_init" and the indev into one called "indev_init" and then you would simply import the module the initialize the driver. This has the added benefit of being able to easily access the display driver or the indev driver from anywhere in your code by simply importing the init module and the driver will be available. When an import is done the code that is at the module level only runs a single time which is the first time it is imported any imports that are done doesn't run the code again, it imports the module in it's current state. |
Beta Was this translation helpful? Give feedback.
-
I also suggest not blocking the REPL like you are doing. Having the main thread/task set to loop endlessly will block access to the REPL. If you want to have a Watchdog that will work without blocking the main thread/task and will work correctly this is what you should do. from machine import WDT
import lvgl as lv
import task_handler
# initilize the task handler that updates lvgl
th = task_handler.TaskHander()
# initilize the watchdog with a timeout of 1 second. This is an ample
# amount of time to know if the main thread has frozen for some reason.
wdt = WDT(timeout=1000)
def wdt_callback(*_):
wdt.feed()
# we are able to use a timer in LVGL to make this callback because of how the
# task_handler.TaskHandler class works. What it does is it creates a hardware
# timer that calls a callback every 33 milliseconds. The callback is made in
# an ISR context and no memory is able to be allocated in that context so it
# tells MicroPython to run the code located in a callback from the main
# thread/task at it's earliest convience. The main thread then calls that
# function and that function is what calls lv.task_handler which then in turn
# will call the watchdog callback is 200 milliseconds has passed since it was
# last called.
#
# by handling the watchdog in this manner it doesmn't tie up the main
# thread/task in looping code where it is sleeping the majority of the time.
# this allows the REPL to function as usual so when you connect over a serial
# connection you will get a prompt and you will be able to interact with the ESP
# without it causing any issues with the currently running code.
lv_wdt = lv.timer_create(200, wdt_callback)
# repeat without end
lv_wdt.set_repeat_count(-1)
lv_wdt.enable(True)
def deinit():
# There is quite a bit involved to deinit and I am not going to go over
# that here. Because the REPL is no longer being blocked there is no
# reason to deinit anything and there is nmo need to have the exception
# catching for the keyboard interrupt.
pass You will find that this is a much better way to handle using the watchdog timer. |
Beta Was this translation helpful? Give feedback.
-
I do also want to mention one other thing for your knowledge.
the use_locks parameter is for use with MCU's that have threading support. This something that you would use if you have another device attached to the I2C bus that you want to poll to collect data from. You are able to set the use_locks to |
Beta Was this translation helpful? Give feedback.
-
Board is based on ILI9488 plus FT6236. Display uses 16-bit parallel bus, which makes it really fast.
There is a variant available with an additional camera, which needs a totally different setup!
Link to supplier product page:
https://www.elecrow.com/esp-terminal-with-esp32-3-5-inch-parallel-480x320-tft-capacitive-touch-display-rgb-by-chip-ili9488.html
My setup code is in a separate module (tft_lvgl_dlc35010R.py):
Beta Was this translation helpful? Give feedback.
All reactions