M5Unit-LIGHT 0.0.2 git rev:6d734f0
Loading...
Searching...
No Matches
m5::unit::light::Data Struct Reference

Measurement data group. More...

#include <unit_Light_data.hpp>

Public Member Functions

float normalized () const
 Normalized brightness in 0..100 (%), where 0% = dark reference and 100% = bright reference.
 

Public Attributes

uint16_t analog_raw {}
 Raw ADC value from the photoresistor path.
 
bool digital {}
 Comparator threshold output (active level is board-specific; verify with calibration)
 
uint16_t dark {0}
 ADC reading captured when the sensor was covered (dark reference)
 
uint16_t bright {4095}
 ADC reading captured when the sensor was lit (bright reference)
 

Detailed Description

Measurement data group.

Member Function Documentation

◆ normalized()

float m5::unit::light::Data::normalized ( ) const
inline

Normalized brightness in 0..100 (%), where 0% = dark reference and 100% = bright reference.

Returns
NaN only when dark == bright (cannot form a range)
Note
dark and bright are stored as the raw ADC values captured during calibration; their magnitudes do not imply polarity. On U021 the photoresistor circuit polarity is board-specific (some revisions yield higher ADC in the dark, others in the light) — normalized() handles either polarity and always maps dark to 0% and bright to 100%.