ToyKeeper / anduril

Anduril 2 Flashlight Firmware and FSM UI Toolkit
GNU General Public License v3.0
199 stars 48 forks source link

Add default handlers for thermal regulation #66

Open dpse opened 3 months ago

dpse commented 3 months ago

Adds default handlers for EV_temperature_high and EV_temperature_low to provide thermal regulation in modes that do not handle it themselves (e.g. strobe/mood modes). Thermal regulation is done is done by adjusting a ceiling level that caps the requested output level. If the ceiling is raised, the output level will also be raised if possible: The logic is basically the same as in ramp mode except a ceiling is adjusted rather than the current level. In ramp mode, the thermal regulation is unchanged.

Only enabled when DONT_USE_DEFAULT_STATE is undefined, USE_THERMAL_REGULATION and USE_DEFAULT_THERMAL_REGULATION as I know some users do not want any thermal stepdown in strobe modes.

Candle mode brightness is also automatically adjusted when thermally capped to not cut off mid-amplitude as that may look ugly.

dpse commented 3 months ago

It would be nice to gradually adjust the ceiling as done in ramp mode as well but I'm unsure of the best way to achieve that since the tick event cannot really be used...

dpse commented 3 months ago

Added gradual ceiling adjustment as well by forcing EV_tick down to the default state even if handled (which unfortunately is a bit ugly...). Also added automatic adjustment of brightness to bike flasher to prevent bursts to be capped. Ceiling is now also restored whenever changing state/mode.