4. Software structure - Zeren-Zhao/parcel_sorting_car GitHub Wiki

Main structure

The program is designed with two threads: Thread A and Thread B. Thread A is responsible for continuously scanning QR codes using the camera, and is implemented using a while(true) loop to ensure that it keeps scanning until a condition is met. When this condition is reached, it calls a callback function to assign a value to the location variable.

Meanwhile, Thread B is constantly making judgments based on the program's logic. When a certain condition is met, it triggers the state machine to perform an action. These two threads work together to ensure that the program functions smoothly and efficiently.

Image text

System Flowchart

Image text

State Machine structure

In this project, the finite state machine is responsible for determining the action to be performed after the user has scanned and decoded the QR code information obtained through Thread A. The state machine represents the program's overall flow of operation, which can be visualized through a diagram. The state machine ensures that the program follows a predetermined sequence of steps, ultimately leading to the desired outcome.

Image text

User Case

Image text