![]() |
Zap'Em Blast'Em Robots
robots that play laser tag!
|
Task logic for laser and servo control during shooting state. More...
Functions | |
void | shoot_task_run (ShootTask *shoot_task) |
Executes the current shoot task state function. | |
void | shoot_task_state_0_init (ShootTask *shoot_task) |
Initializes the shoot task (state 0). | |
void | shoot_task_state_1_wait (ShootTask *shoot_task) |
Waits for button press to initiate action (state 1). | |
void | shoot_task_state_2_unshield (ShootTask *shoot_task) |
Lowers the servo shield before firing (state 2). | |
void | shoot_task_state_3_shoot (ShootTask *shoot_task) |
Fires the laser and resets state if button is released (state 3). |
Task logic for laser and servo control during shooting state.
Created on: Jun 3, 2025
void shoot_task_run | ( | ShootTask * | shoot_task | ) |
Executes the current shoot task state function.
Executes the current shoot task state.
Checks that the current state index is valid and calls the corresponding state handler. Falls into an infinite loop if the state index is invalid.
shoot_task | Pointer to ShootTask structure. |
void shoot_task_state_0_init | ( | ShootTask * | shoot_task | ) |
Initializes the shoot task (state 0).
Initializes laser and servo to unshielded state and moves to state 1.
shoot_task | Pointer to ShootTask structure. |
void shoot_task_state_1_wait | ( | ShootTask * | shoot_task | ) |
Waits for button press to initiate action (state 1).
Waits for user input to activate shoot sequence (state 1).
Keeps laser on and servo unshielded. Advances to state 2 when button is pressed.
shoot_task | Pointer to ShootTask structure. |
void shoot_task_state_2_unshield | ( | ShootTask * | shoot_task | ) |
Lowers the servo shield before firing (state 2).
Lowers servo shield prior to firing laser (state 2).
After lowering shield, transitions to state 3. Also checks for early button release to return to state 1.
shoot_task | Pointer to ShootTask structure. |
void shoot_task_state_3_shoot | ( | ShootTask * | shoot_task | ) |
Fires the laser and resets state if button is released (state 3).
Fires the laser and returns to wait state after release (state 3).
Turns off laser and returns to wait state once the button is released.
shoot_task | Pointer to ShootTask structure. |