![]() |
Zap'Em Blast'Em Robots
robots that play laser tag!
|
Task logic for hit detection using photoresistors in game loop. More...
Functions | |
void | photoresistor_task_run (PhotoresistorTask *photoresistor_task) |
Executes the current state of the photoresistor task. | |
void | photoresistor_task_state_0_init (PhotoresistorTask *photoresistor_task) |
Initializes the photoresistor task (state 0). | |
void | photoresistor_task_state_1_look (PhotoresistorTask *photoresistor_task) |
Checks for light detection and sets hit flag (state 1). | |
void | photoresistor_task_state_2_hit (PhotoresistorTask *photoresistor_task) |
Waits for score handling and clears hit flag (state 2). |
Task logic for hit detection using photoresistors in game loop.
Created on: Jun 3, 2025
void photoresistor_task_run | ( | PhotoresistorTask * | photoresistor_task | ) |
Executes the current state of the photoresistor task.
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).
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 light detection and sets hit flag (state 1).
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 score handling and clears hit flag (state 2).
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. |