ToyKeeper / anduril

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

bikeflash: Cap default brightness to MAX_BIKING_LEVEL, add optional default define #23

Closed digitalcircuit closed 9 months ago

digitalcircuit commented 9 months ago

Migrated from original Launchpad merge request

This fixes the issue where builds with a single voltage/current regulator (e.g. the Noctigon KR4 linear driver with noFET/FET disabled in firmware) put the default bike flasher brightness beyond MAX_BIKING_LEVEL (120) due to MAX_1x7135 = 150 (MAX_LEVEL).

With this change, the default bike flasher brightness is the minimum of MAX_1x7135 and MAX_BIKING_LEVEL, ensuring it never exceeds the maximum.

As a side effect, this provides a way to specify the default bike flasher brightness via #define DEFAULT_BIKING_LEVEL. This is not checked against MAX_BIKING_LEVEL, for simplicity.

Alternatively, strobe-modes.c could be updated to check if the value exceeds MAX_BIKING_LEVEL at runtime. However, that might take up more flash space.

ToyKeeper commented 9 months ago

Thanks! Looks good. I modified it a bit to put the definitions into a more specific file, and to remove dependence on old 7135 chip symbols. The default is level 50/150 now, unless overridden.