WasatchPhotonics / ENLIGHTEN

Open-source spectroscopy application for controlling and taking measurements from Wasatch Photonics spectrometers.
https://wasatchphotonics.com/product-category/software/
MIT License
3 stars 6 forks source link

Disable laser with user feedback if has_battery yet battery disconnected #345

Open mzieg opened 9 months ago

mzieg commented 9 months ago

Currently the closest means we have to tell whether the battery is connected or not is if we read a battery charge percentage of 50.0. We need to leverage that to infer whether the battery appears to be disconnected, and prevent the laser from firing if that is the case (with explanatory message for the user).

In my mind, we can "average over" the case in which the battery charge "legitimately" passes through 50.0 by tracking whether the charge was in the range [48, 50) or (50, 52] in the last minute. If the laser initially comes up at 50.0 I would treat that as disconnected, noting that as soon as we get a Reading with a battery_perc != 50.0 we can re-enable the battery at that point anyway.