Testers wanted! BLF A6 firmware revamp!

I have HEAVILY modified ToyKeeper’s BLF A6 firmware, stripping it down to bare essentials and adding some functionality in from bistro while reducing the overall compiled size.

I would really like it if some people wouldn’t mind getting hands-on, and finding bugs if possible. I use this in my EDC, and haven’t found any bugs in the most recent rev, but I’d really like to get someone to break it in a weird edge case I might not have thought up.

You can download the hex (built for the attiny13a) here: https://github.com/googlegot/blf/blob/master/blf-a6-rmm-tiny13a.hex

And the source here: https://github.com/googlegot/blf/blob/master/blf-a6-rmm.c

UI Changes:

  1. Two new configuration options have been added: Mode Order Reversal (option 3) and Medium Press Disable (option 4)

2. Config mode now emulates bistro firmware, flashing the config option number then “buzz” strobing for ~1s. Tap during the buzz to set that config option.

3. Low on mode group 2 is now ‘moon’ instead of just kinda low.

4. In reverse mode, medium press will drop to moon first, then enter hidden modes.

- This will visually be regular TURBO -> regular moon -> hidden TURBO -> hidden STROBE -> hidden BATTCHECK -> hidden BIKING_STROBE -> regular TURBO.

Backend Changes:
Full compiled size with avr-gcc 6 and all options enabled is 820 bytes!!

avr-size output:

text: 782
data: 38
bss: 4
dec: 824
hex: 338

1. Fast PWM is disabled completely. This is in line with bistro, and doesn’t make any audible noise on any of my A6 driver lights (S41S, S41, K01, A6, and a custom Convoy S2+). Please let me know if you hear a whine, it should be 9.5khz or so if you do. If you do notice a whine, please post the board rev if you can.
2. Bistro blink has replaced the old blink function.
3. Strobe and biking strobe are now in the same function. Strobe just skips the lower output and delay.
4. next() and med() replace next_mode() and prev_mode(). They are now uint8_t, and return an index based off input variables.
5. mode_idx is now a local variable in main()
6. Additional config modes states are stored in the unused two bits in the low nibble of eep.
7. mode_idx is stored in the high nibble of eep.
8. eep is now stored flipped, so even if all options are set and mode_idx is 15, there is no possibility of loss of config.
9. voltage checks now take place at the beginning of the main() loop, and voltage monitoring occurs at the end
10. Several unnecessary sleeps have been removed or converted from _sleep_ms() to _sleep_s() for space savings
11. next() and med() are inline now, which significantly reduces compiled size.
12. toggle() and count_modes() have been moved into main() and refactored
13. All mode configs are now stored in two arrays (modesNx1 and modes1x1), with modes_pwm1, modes_pwm2, modesNx2, and modes1x2 completely removed.
14. No more PROGMEM, there’s plenty of sram to use. This speeds up mode setting significantly, making the while(1) main operating loop able to run blinky modes without weird pauses due to values being read from flash.
15. Modes are stored in the arrays in order: 0-3 are hidden, 4-10 are mode group 1, 11-14 are mode group 2.

There’s WAY more than that, but those are the broad strokes. Please, break my firmware. Show me the stupid mistakes I made. Feel free to contribute as well.