Zap'Em Blast'Em Robots
robots that play laser tag!
Loading...
Searching...
No Matches
shoot_task.h
Go to the documentation of this file.
1
8
9#ifndef INC_SHOOT_TASK_H_
10#define INC_SHOOT_TASK_H_
11
12#include <stdint.h> // Allows use of standard integer types
13#include "stm32f4xx_hal.h" // or your STM32 family
14
18typedef struct ShootTask ShootTask; // forward declaration
19
23typedef void (*shoot_fcn_t)(ShootTask *shoot_task);
24
32{
33 int32_t state;
34 int32_t num_states;
35 int32_t button;
36 TIM_HandleTypeDef *servo_tim;
37 uint32_t channel;
38 int32_t shield_val;
39 int32_t unshield_val;
40 uint32_t laser_gpio;
42};
43
49void shoot_task_state_0_init(ShootTask *shoot_task);
50
56void shoot_task_run(ShootTask *shoot_task);
57
63void shoot_task_state_1_wait(ShootTask *shoot_task);
64
71
77void shoot_task_state_3_shoot(ShootTask *shoot_task);
78
79#endif /* INC_SHOOT_TASK_H_ */
void shoot_task_state_3_shoot(ShootTask *shoot_task)
Fires the laser and returns to wait state after release (state 3).
Definition shoot_task.c:101
void shoot_task_state_0_init(ShootTask *shoot_task)
Initializes the shoot task (state 0).
Definition shoot_task.c:45
void shoot_task_state_2_unshield(ShootTask *shoot_task)
Lowers servo shield prior to firing laser (state 2).
Definition shoot_task.c:81
void(* shoot_fcn_t)(ShootTask *shoot_task)
Function pointer type for shoot task state functions.
Definition shoot_task.h:23
void shoot_task_run(ShootTask *shoot_task)
Executes the current shoot task state.
Definition shoot_task.c:23
void shoot_task_state_1_wait(ShootTask *shoot_task)
Waits for user input to activate shoot sequence (state 1).
Definition shoot_task.c:62
Structure for shoot task configuration and state tracking.
Definition shoot_task.h:32
int32_t num_states
Definition shoot_task.h:34
uint32_t channel
Definition shoot_task.h:37
shoot_fcn_t state_list[]
Definition shoot_task.h:41
uint32_t laser_gpio
Definition shoot_task.h:40
int32_t unshield_val
Definition shoot_task.h:39
int32_t button
Definition shoot_task.h:35
TIM_HandleTypeDef * servo_tim
Definition shoot_task.h:36
int32_t shield_val
Definition shoot_task.h:38
int32_t state
Definition shoot_task.h:33