CDS55 Photoresistor
|
Functions | |
void | photoCell_init (photoCell_t *sensor, bool scaled, uint16_t min_value, uint16_t max_value) |
Initializes a photoCell_t instance with the specified configuration. | |
uint8_t | readSensor (photoCell_t *sensor) |
Reads the photocell value from ADC and updates the sensor state. |
Variables | |
ADC_HandleTypeDef | hadc1 |
void photoCell_init | ( | photoCell_t * | sensor, |
bool | scaled, | ||
uint16_t | min_value, | ||
uint16_t | max_value ) |
Initializes a photoCell_t instance with the specified configuration.
This function sets the scaling behavior and raw ADC min/max calibration points. It also clears the current light level and last raw ADC value.
sensor | Pointer to a photoCell_t instance to initialize. |
scaled | If true, the output will be scaled to a range of 0–100. |
min_value | Minimum expected raw ADC value for scaling. |
max_value | Maximum expected raw ADC value for scaling. |
uint8_t readSensor | ( | photoCell_t * | sensor | ) |
Reads the photocell value from ADC and updates the sensor state.
This function performs a blocking ADC read using STM32 HAL and stores both the raw and optionally scaled light level into the provided sensor instance.
sensor | Pointer to a photoCell_t instance to update. |
|
extern |