Lesson 11 Warning Light Function
In this lesson, we will learn how to use PiCarPro's warning light function.
11.1 Function introduction
This section of the course introduces the use of multi-threading to achieve some
effects related to WS2812 LED lights. Multi-threading is a very common operation
we use in robot projects, because robots have high requirements for real-time
response. When performing a certain task, try not to block the main thread
communication.
Multi-threading is similar to executing multiple different programs or tasks at the
same time. Multi-threaded operation has the following advantages:
1. Using threads to put time-consuming tasks in the background for processing.
2. Improving the operating efficiency of the program. The subsequent real-time
video and OpenCV processing video frames use multi-threading to greatly increase
the frame rate.
3. The encapsulated multi-threaded task is more convenient to call, similar to the
non-blocking control method, that is, the control method of the servo is encapsulated
by multi-threading.
We use python's threading library to provide thread-related work, and thread is
the smallest unit of work in an application. The current version of Python does not yet
provide multi-threaded priority, thread groups, and threads cannot be stopped,
suspended, resumed, or interrupted.
11.2 Realizing the WS2812 LED lighting effect with
multithreading
159
Need help?
Do you have a question about the PiCar-Pro and is the answer not in the manual?