drivers.reflectance module¶
- class drivers.reflectance.Reflectance_Sensor(analogPins)[source]¶
Bases:
objectDriver for a reflectance sensor array read through ADC channels.
- The class provides:
one-shot raw + normalized sensor reads (get_values)
calibration file loading (load_calibration_from_file)
cooperative calibration sampling (calibrate) via yield
- calibrate(mode)[source]¶
Cooperative calibration generator.
mode should be “light” or “dark”. The routine collects _SAMPLE_COUNT raw samples and stores the per-sensor average to file. It yields frequently so other cotasks can continue running.
After calibration completes, the in-memory cache is updated.
- get_values()[source]¶
Return (raw, calibrated, C, line_detected) where: - raw: list of averaged raw ADC values - calibrated: list of normalized sensor values (0=white, 1=black) - C: weighted line position (centroid) - line_detected: True if line is detected, False if lost (noise/uniform)
Raw values are averaged over _READ_SAMPLES reads to reduce noise. When line is lost, C returns the last valid centroid.