My journey of flashlight firmware development (Anduril)

11 posts / 0 new
Last post
SammysHP
SammysHP's picture
Offline
Last seen: 7 hours 24 min ago
Joined: 06/25/2019 - 14:35
Posts: 1428
Location: Germany
My journey of flashlight firmware development (Anduril)

Introduction

In the beginning, there was nothing. But at first nobody said “let there be light”, everything started with software development. Back in 2018 I was looking for some small projects I could do in my free time. I only had a ZebraLight SC63w and a few other, simple flashlights and thougth: “Light is nice, it lets me see things. But can’t you do more than turning it on and off?”

And I bought a cheap Convoy S2+ and started developing my own firmware for the ATtiny13. I read through countless pages in various forums about flashlight firmware and what you can do with flashlights. With all inspirations I could find I created a firmware with the not so impressive name “rampinglight”. It uses every byte of the ATtiny13 and includes as many features as I could pack into it: Stepped and smooth ramping, turbo, strobe, beacon, mode memory, configuration options and more. You can find it here on GitHub.

Just half a year later I discovered the spectacular ##flashlight IRC channel and it opened a whole new world for me. Quickly I discovered that there are flashlights with exposed flashing pads for firmware update and an open-source firmware called Anduril! Then I ordered an Emisar D4S and the fun began. I started playing with Anduril, bought more lights, not only with Anduril – I was infected with the flashlight virus. You all know what I mean.



Contributions to Anduril

Over the years I made several changes to the Anduril firmware, some of them are already included upstream, some of them might be eventually. Who knows.

Autolock
The first implementation of the autolock feature. Lock the light automatically after a configurable time of inactivity. Made originally for Anduril 1, it found its way into the official version of Anduril 2.

2C turbo config
A global option to define what should happen on 2C (turbo vs. ceiling). It is now included in Anduril 2.

Don’t ramp up after moon
Another global option to define what happens after entering moon mode. By default Anduril automatically starts to ramp up after a short delay. Now you can disable this to stay at moon until you release the switch and press it again. I think the idea came from tribixbite. Also included in Anduril 2 now.

Ramp border delay
You have noticed the blip when ramping up and down on some lights, right? It marks the switchover from one to the other channel. But it’s almost impossible to stop right at the threshold. Well, this patch adds a little pause at the switchover so that you can stay at the maximum level of that channel.

Smooth sunset
Makes sunset mode much smoother (still not perfectly smooth, but it doesn’t skip ramp levels as before).

More aux patterns
Add more aux LED patterns like short low intensity blinks, short high intensity blinks or no aux LEDs at all (but keep the switch LED enabled). Works for classic and RGB aux LEDs. As a side effect this also adds LVP for simple aux LEDs.

Stepped tint ramping
Stepped tint ramping similar to stepped brightness levels with configurable number of steps (0: smooth ramping, 1: all channels same intensity, 2: toggle between CH1 and CH2, 3+: number of steps).

Anduril PocketUI
Anduril PocketUI – the pocket-friendly UI. If enabled, many button mappings are shifted and require one press more to activate, for example turn the light on with 2C from off. From off you get a momentary moon mode with 1H and lockout won’t have any momentary mode at all. PocketUI can be enabled during runtime.

aux-blink-fix
Fix issue with wrong aux LED intensity directly after releasing button in lockout.

High aux preview
Always use high brightness for aux LED configuration. Makes it easier to see the color.

Manual memory fixed for lockout
If manual/hybrid memory is enabled, use it consistently in lockout and reset hybrid memory when entering lockout.

Turbo in momentary mode
Allow to use turbo in momentary mode (5C).

Save tint optionally
By default the tint is automatically saved on every change so that it can be restored after swapping the battery. But this is not the case for the brightness level! Why this inconsistency? AFAIk it was by user requests. Anyway, this patch adds the possibility to disable saving the tint so that it will be reset to the default value after mechanical lockout.

Wurkkos TS10 fixes
Recently the Wurkkos TS10 was released. It suffered from bad ramping, high minimum output and – most importantly – no LVP for the aux LEDs. My patches already added proper LVP. I also developed a new ramping configuration that allows lower moonlight and smoother ramping. It will be included in the next batch of the TS10.

You can find my modifications in my GitHub mirror of the flashlight-firmware repository. There is also a wiki page with an overview over these changes.

I was also involved in many discussions about the development of Anduril, helping with debugging and helping users when something didn’t work as expected. Three years full of adventures, what a journey!



What’s next?

In the past year(s) ToyKeeper, the original author of Anduril, took a break and kept herself busy with other things. Well deserved! That also led to the uncomfortable situation of a rather messy Anduril landscape. New flashlight models required new configurations and changes to the code. People like me worked on modifications and maintain their individual “forks” with their own patches. Now you can live with “good old upstream Anduril” or compile your own version. That’s not an accusation! Just the result of changing priorities we all experience in our lifes.

But Anduril isn’t the end. Someone will create a new firmware for flashlights eventually. Who and when is unknown, but time will tell.

Haukkeli
Offline
Last seen: 9 hours 51 min ago
Joined: 06/24/2021 - 05:27
Posts: 455
Location: Suomi

Nice story. I have tinkered a lot with hardware side of things, but haven’t much dared to touch the software.

thefreeman
thefreeman's picture
Offline
Last seen: 20 min 57 sec ago
Joined: 01/06/2020 - 09:56
Posts: 1448
Location: France

Thanks for that, it’s great to have people like you and Gchart contributing to Anduril Thumbs Up

SammysHP
SammysHP's picture
Offline
Last seen: 7 hours 24 min ago
Joined: 06/25/2019 - 14:35
Posts: 1428
Location: Germany

Software is pretty much useless without the hardware! So thank you for your work on that part! Thumbs Up

RoboEgg
Offline
Last seen: 12 hours 13 min ago
Joined: 10/07/2013 - 07:26
Posts: 24
Location: UK

Great story.I’m a software developer C++ embedded. I have tinckered with arduino. Iwould like to make my own tweaks to anduril and maybe share if i have anything worthy, but I need help getting started. Getting tar to download without error 500 and some tips on loading in to windows ide.

SammysHP
SammysHP's picture
Offline
Last seen: 7 hours 24 min ago
Joined: 06/25/2019 - 14:35
Posts: 1428
Location: Germany

@RoboEgg
As answered in another thread, use breezy to download the source code. The archive download on launchpad is broken.

brz branch lp:~toykeeper/flashlight-firmware/anduril2

For compilation use avr-gcc – it’s the only officially supported compiler. There is a build script (build-all.sh) in the anduril subdirectory. Development is very Linux-centric, but should work with WSL. I don’t use Windows, so I cannot help you with it.

jon_slider
jon_slider's picture
Offline
Last seen: 13 hours 28 min ago
Joined: 09/08/2015 - 12:20
Posts: 6215
Location: Central North America

SammysHP wrote:
2C turbo config
… (turbo vs. ceiling).

Don’t ramp up after moon


added proper LVP.

lower moonlight

Thank You!
I use all of those features on reflashed TS10 and SC21 Pro

love the lower lows
glad anduril now has LVP for single color aux/button lights

SearchLight
Offline
Last seen: 10 hours 7 min ago
Joined: 04/02/2022 - 12:53
Posts: 22

Thank you for your contributions! Just to better understand, you do not have your forks as hex files, correct? I’ve been reading and looking around your links for the past 30 mins but having tough time finding where to download them.

Wurkkos Terry
Wurkkos Terry's picture
Offline
Last seen: 1 day 20 hours ago
Joined: 04/08/2021 - 04:25
Posts: 183

Tribute to you, the great pioneer SammysHP, you dispel the darkness of the unknown field.
I really appreciate it.

Unheard
Unheard's picture
Offline
Last seen: 7 hours 56 min ago
Joined: 01/16/2019 - 11:38
Posts: 2583
Location: Germany

Thank you, Sammy. If time permits, it would be nice if flashlight manufacturers would consult any of you developers to create custom solutions, not leaving their customers with poor implementations.

Smile, you cannot kill them all.

SammysHP
SammysHP's picture
Offline
Last seen: 7 hours 24 min ago
Joined: 06/25/2019 - 14:35
Posts: 1428
Location: Germany

SearchLight wrote:
Thank you for your contributions! Just to better understand, you do not have your forks as hex files, correct? I’ve been reading and looking around your links for the past 30 mins but having tough time finding where to download them.

Not yet. Some of the features must be enabled in the configuration files and even the smaller fixes overflow the memory of the ATtiny85 with the stock configuration. Either I have to remove features for these builds or find something to optimize.