-
MicroPython version: v1.19.1, downloaded from here Hello everyone, In my project, I use a 4 bit 7 segmentdisplay (without a driver like TM1637). Therefore, my code has to run continuously to show something on the segmentdisplay. This code works fine, and the segmentdisplay shows its data with no visible flickering. The ESP32 makes a webrequest every hour. To make the segment display continuously show its data, I use the _thread module. I watched this video, which told me that the _thread module allows me to use both cores of my ESP32. The problem is, that when I start one thread for the segmentdisplay and one to make a webrequest, the segmentdisplay starts to flicker, which means that the code that controls it is interrupted. I think that means both thread are running on the same core and the ESP32 switches between the threads, resulting in a flickering of the segmentdisplay. Is it possible to use both cores on the ESP32 and how? import _thread
import network_connection
from segment_display import SegmentDisplay
segment = SegmentDisplay(digits=(16, 18, 19, 4), segments=(5, 21, 26, 25, 33, 17, 27), show=False, wait_time=0.001) # intitializes the segment display
_thread.start_new_thread(segment.show, ())
data = network_connection.web_request() # establishes a wificonnection and does a webrequest Any help would be appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
I am pretty sure this is caused the global interpreter lock (GIL) used in most python/micropython implementations. |
Beta Was this translation helpful? Give feedback.
-
@PWSJA MicroPython does not support dual-core on the ESP32, it will always run all its threads on the same core. @karfas This isn't specifically related to the GIL -- the threads are on the same core the OP's problem would happen regardless. You're right though, if we did add support for multi-core on ESP32 then we would have to disable the GIL in order to get any real benefit -- exactly like on rp2040. |
Beta Was this translation helpful? Give feedback.
@PWSJA MicroPython does not support dual-core on the ESP32, it will always run all its threads on the same core.
@karfas This isn't specifically related to the GIL -- the threads are on the same core the OP's problem would happen regardless.
You're right though, if we did add support for multi-core on ESP32 then we would have to disable the GIL in order to get any real benefit -- exactly like on rp2040.