![]() |
Zap'Em Blast'Em Robots
robots that play laser tag!
|
Header for photoresistor-based hit detection task logic. More...
#include <stdint.h>#include "stm32f4xx_hal.h"Go to the source code of this file.
Data Structures | |
| struct | PhotoresistorTask |
| Structure for tracking photoresistor task state and config. More... | |
Typedefs | |
| typedef void(* | photoresistor_fcn_t) (PhotoresistorTask *photoresistor_task) |
| Function pointer type for photoresistor state functions. | |
Functions | |
| void | photoresistor_task_state_0_init (PhotoresistorTask *photoresistor_task) |
| Initializes the photoresistor task (state 0). | |
| void | photoresistor_task_run (PhotoresistorTask *photoresistor_task) |
| Executes the current task state function. | |
| void | photoresistor_task_state_1_look (PhotoresistorTask *photoresistor_task) |
| Checks for a light-based hit (state 1). | |
| void | photoresistor_task_state_2_hit (PhotoresistorTask *photoresistor_task) |
| Waits for hit flag to clear (state 2). | |
Header for photoresistor-based hit detection task logic.
Created on: Jun 3, 2025
| void photoresistor_task_run | ( | PhotoresistorTask * | photoresistor_task | ) |
Executes the current task state function.
| photoresistor_task | Pointer to the task structure. |
Executes the current task state function.
Checks that the current state index is valid and invokes the corresponding state function. Traps in an infinite loop if state index is invalid.
| photoresistor_task | Pointer to PhotoresistorTask structure. |
| void photoresistor_task_state_0_init | ( | PhotoresistorTask * | photoresistor_task | ) |
Initializes the photoresistor task (state 0).
| photoresistor_task | Pointer to the task structure. |
Sets the next state to 1. Used to initialize any required sensor/button components.
| photoresistor_task | Pointer to PhotoresistorTask structure. |
| void photoresistor_task_state_1_look | ( | PhotoresistorTask * | photoresistor_task | ) |
Checks for a light-based hit (state 1).
| photoresistor_task | Pointer to the task structure. |
Checks for a light-based hit (state 1).
Transitions to the hit state if the difference between the current ADC value and zero calibration exceeds the threshold.
| photoresistor_task | Pointer to PhotoresistorTask structure. |
| void photoresistor_task_state_2_hit | ( | PhotoresistorTask * | photoresistor_task | ) |
Waits for hit flag to clear (state 2).
| photoresistor_task | Pointer to the task structure. |
Waits for hit flag to clear (state 2).
Transitions back to look state once the hit flag has been cleared externally (e.g., by the game task after scoring).
| photoresistor_task | Pointer to PhotoresistorTask structure. |