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

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

Detailed Description

Header for photoresistor-based hit detection task logic.

Author
Andrew Carr

Created on: Jun 3, 2025

Function Documentation

◆ photoresistor_task_run()

void photoresistor_task_run ( PhotoresistorTask * photoresistor_task)

Executes the current task state function.

Parameters
photoresistor_taskPointer 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.

Parameters
photoresistor_taskPointer to PhotoresistorTask structure.

◆ photoresistor_task_state_0_init()

void photoresistor_task_state_0_init ( PhotoresistorTask * photoresistor_task)

Initializes the photoresistor task (state 0).

Parameters
photoresistor_taskPointer to the task structure.

Sets the next state to 1. Used to initialize any required sensor/button components.

Parameters
photoresistor_taskPointer to PhotoresistorTask structure.

◆ photoresistor_task_state_1_look()

void photoresistor_task_state_1_look ( PhotoresistorTask * photoresistor_task)

Checks for a light-based hit (state 1).

Parameters
photoresistor_taskPointer 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.

Parameters
photoresistor_taskPointer to PhotoresistorTask structure.

◆ photoresistor_task_state_2_hit()

void photoresistor_task_state_2_hit ( PhotoresistorTask * photoresistor_task)

Waits for hit flag to clear (state 2).

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

Parameters
photoresistor_taskPointer to PhotoresistorTask structure.