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

Header file for shoot task state machine and control logic. More...

#include <stdint.h>
#include "stm32f4xx_hal.h"

Go to the source code of this file.

Data Structures

struct  ShootTask
 Structure for shoot task configuration and state tracking. More...

Typedefs

typedef struct ShootTask ShootTask
 Forward declaration of ShootTask structure.
typedef void(* shoot_fcn_t) (ShootTask *shoot_task)
 Function pointer type for shoot task state functions.

Functions

void shoot_task_state_0_init (ShootTask *shoot_task)
 Initializes the shoot task (state 0).
void shoot_task_run (ShootTask *shoot_task)
 Executes the current shoot task state.
void shoot_task_state_1_wait (ShootTask *shoot_task)
 Waits for user input to activate shoot sequence (state 1).
void shoot_task_state_2_unshield (ShootTask *shoot_task)
 Lowers servo shield prior to firing laser (state 2).
void shoot_task_state_3_shoot (ShootTask *shoot_task)
 Fires the laser and returns to wait state after release (state 3).

Detailed Description

Header file for shoot task state machine and control logic.

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.

Parameters
shoot_taskPointer to ShootTask structure.

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

Parameters
shoot_taskPointer to ShootTask structure.

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 user input to activate shoot sequence (state 1).

Parameters
shoot_taskPointer to ShootTask structure.

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 servo shield prior to firing laser (state 2).

Parameters
shoot_taskPointer to ShootTask structure.

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 returns to wait state after release (state 3).

Parameters
shoot_taskPointer to ShootTask structure.

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.