14#ifndef M5_UNIT_LIGHT_UNIT_LIGHT_DATA_HPP
15#define M5_UNIT_LIGHT_UNIT_LIGHT_DATA_HPP
50 return std::numeric_limits<float>::quiet_NaN();
52 const float span{
static_cast<float>(
bright) -
static_cast<float>(
dark)};
53 float v{(
static_cast<float>(
analog_raw) -
static_cast<float>(
dark)) * 100.0f / span};
54 if (v < 0.0f) v = 0.0f;
55 if (v > 100.0f) v = 100.0f;
Top level namespace of M5Stack.
Measurement data group.
Definition unit_Light_data.hpp:33
bool digital
Comparator threshold output (active level is board-specific; verify with calibration)
Definition unit_Light_data.hpp:35
float normalized() const
Normalized brightness in 0..100 (%), where 0% = dark reference and 100% = bright reference.
Definition unit_Light_data.hpp:47
uint16_t bright
ADC reading captured when the sensor was lit (bright reference)
Definition unit_Light_data.hpp:37
uint16_t dark
ADC reading captured when the sensor was covered (dark reference)
Definition unit_Light_data.hpp:36
uint16_t analog_raw
Raw ADC value from the photoresistor path.
Definition unit_Light_data.hpp:34