Zap'Em Blast'Em Robots
robots that play laser tag!
Loading...
Searching...
No Matches
shoot_task.c File Reference

Task logic for laser and servo control during shooting state. More...

#include "shoot_task.h"
#include <stdio.h>

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).

Detailed Description

Task logic for laser and servo control during shooting state.

Author
Andrew Carr

Created on: Jun 3, 2025

Function Documentation

◆ shoot_task_run()

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.

Parameters
shoot_taskPointer to ShootTask structure.

◆ shoot_task_state_0_init()

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.

Parameters
shoot_taskPointer to ShootTask structure.

◆ shoot_task_state_1_wait()

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.

Parameters
shoot_taskPointer to ShootTask structure.

◆ shoot_task_state_2_unshield()

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.

Parameters
shoot_taskPointer to ShootTask structure.

◆ shoot_task_state_3_shoot()

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.

Parameters
shoot_taskPointer to ShootTask structure.