Anduril ... 2?

Don’t know if it was already talked about in this thread, but I might have a new suggestion: Multi-Chemistry Cell Support

Of course the voltage-ranges of the different chemistries have to have a gap in between them, but then it could be possible with multiple ADC*… tables, and then different PWM_LEVELS linked to the specific ADC*… tables.
MCU pin definitions have to be linked to the ADC_… tables as well (at least the LED_ENABLE_PIN should be changeable), a 14500 might have a different circuit that needs to be controlled compared to a AA.

The MCU could measure the voltage when inserting a cell, and then choose the correct table according to the measured voltage, then next cell insertion overwrites the old.
To save bytes, there could be a #define to enable or disable the whole “Multi-Chemistry Cell Support” (I hope it’s possible on tiny1634, it’s not needed on 85 since it has too few pins anyway).

Thank you ToyKeeper for your hard work. I am a embedded SW developer myself and I know how hard it can be to develop SW for platforms with limited resources and try to add all functions and options the users request.

I followed your steps for building and it works fine in Ubuntu on Windows, within 10 minutes I was able to build Anduril and Anduril 2. I didn’t change anything (yet) but just looked at the code and tried to understand how it works.

I tried one thing however and it reduced the file sizes a few bytes of multiple targets. I added “static const” in front of the variables seq, levels and animation in aux-leds.c. By adding this the variables can be accessed in ROM directly and are not copied from ROM to stack (RAM) every time a function is called.

A tip for others: if you cd to /mnt/c in the Linux prompt you can access your local Windows C: drive from within the Linux prompt. If you clone the anduril source code here you can still use your favorite Windows editor to read and/or modify the code (no need to use vi). The hex files will also be generated on the Windows drive so Windows tools can be used to flash.

Did you include config-default.h in your project? Again (many times), AS 7.0 works for me perfectly.

Got a chance to review the settings and found this setting was missing from my VS 7.0 build:

-fwhole-program

Added it under Project Properties->AVR GNU C Compiler->Optimization->Other optimization flags, and it reduced the size:

7772 -> 7604

It’s an interesting idea. Sounds tricky though, if it needs to use different control pins and different PWM tables for different cell types. Not impossible, of course… just perhaps a bit messy because it would add a bunch of nested conditional logic in parts of the code which are already not very clean.

Also sounds difficult on the hardware side of things, trying to fit all the driver components into an AA-sized light.

Also notice VS 7.0 has these settings for optimization that the build scripts are not using:

-ffunction-sections -fdata-sections -fpack-struct

It adds 162 bytes if I turn them off.

Thanks! It’s a little embarrassing I didn’t think to do that earlier. It saves a significant amount of space, and I’ve used the same trick elsewhere in the code… just forgot to do it there.

Anyway, it’s included in the latest anduril2 rev.

Now anduril2 is at a point where, despite all the new things added, most of the build targets are about the same size as they were in anduril1. Some are bigger, some are smaller, but overall not much different. The size optimizations have been enough to almost completely compensate for the added features.

Yeah, that’s an important one. :slight_smile:

The entire weird layout of the program is done specifically to make that one compiler option possible. It reduces the size enough to make room for at least one or two extra features. On a normal program, it’d be crazy to do that… but for something so size-sensitive, it’s worth using bizarre tricks like #including the .c files inline instead of linking them.

That’s odd. I tried those in the build script, and it made no difference. Same size, same md5sum. Perhaps they’re enabled by default without having to specify anything.

Yep, double-checked when I got that message too.

The files should be put in the top level of the specific project folder correct?

Someone mentioned on reddit about Halloween and making a flicker effect and I thought it would be neat to like triple click while in lightning mode and invert it so it dims every once in a while, don’t know if that would fill up too much space though.

Top level? I have all the files in one level, no sub levels, i.e. no sub folders.

When I first make the project it creates sub-folders within it, one of which contains main.o and a few other files that I’m actually not sure the purpose of. I put the Anduril files at the top level folder though.

Oh, I did that long ago. I delete main, merge all the Anduril files into one folder, and then add all the Anduril files. It's simple - no need to organize down to sub folders.

Here is a ZIP file of my current Anduril2 AS 7.0 build project: https://drive.google.com/file/d/1o74vZ7FaxO-jPsYxk1lFZR7KnbEwhzP3/view?usp=sharing

Download it into clean folder, unzip, load into AS7 and build.

Add this step between steps #2 and #3:

sudo apt update

And this step to access the files in windows explorer (mind the space and dot ” .” at the end);

  1. explorer.exe .

(I have avrdude.exe and the USBasp-win-driver-x86-x64-v3.0.7 driver installed on windows)

Hybrid memory is an excellent idea, but shouldn’t it be available for both automatic and manual memory modes? I personally prefer the convenience of automatic-memory, and I don’t go to manual memory anymore because I feel stuck since it is not my personal default mode.

Here is my UI suggestion for “temporarily switching the memory mode” (hybrid mode):
[Removed by myself, I have revised my suggestion in a later post]

Also, could the timer be in increments of 5 to 15 minutes? My particular use case would be to manually set moon-mode at night for a couple of hours. 255 times clicks is a lot!

Also, this is my first post but I have been lurking Anduril threads since I found out about BLF and TK’s Emisar D4V2 review… and I bought one the same day, my first quality flashlight, D4v2 in sst20-4000k :slight_smile:

2 Thanks

It could be modified to do that, but there’s kind of a problem… heat. Lightning mode barely generates any heat, so it’s pretty safe to leave on. An inverted lightning mode, however, would overheat in under a minute on a lot of lights. So you’d have to make sure the top level is thermally sustainable, and then flicker downward from there.

That’s basically what hybrid mode is… it’s both.

I get the impression there has been a misunderstanding… possibly just me not understanding the idea. So perhaps I can clear things up by explaining the memory options a different way.

There are three different styles for brightness memory in Anduril 2. So after shutting off the light, there are three things it can do with the last-ramped brightness level:

  • Always remember.
  • Remember for N minutes.
  • Never remember.

These are called “automatic”, “hybrid”, and “manual” memory modes.

But it sounds like you might be suggesting a fourth option?

  • Only remember after light has been off for N minutes.

Is that correct? And if so, can you provide an example where it would make sense to do this?

Or perhaps the idea was to have a timer which starts when the user activates it in the config menu, and it temporarily changes the memory mode, and then after the timer expires, it goes back to the previous setting? So, like, it’s 9pm and you start a timer for 3 hours. You have 3 hours to use the light with a different memory setting. Then at midnight, it goes back to the original setting?

But that’s not how it works. The “N minutes” memory timer starts each time the light is turned off. So if you set the timer to an hour, but you turn it on every 45 minutes, it will always remember. It doesn’t forget until the light has been off for at least an hour with no button clicks.

Phrased a different way, a 1-hour memory timer means: If the light has been off for more than an hour, I probably don’t remember what brightness level it was at… so go back to the default level. However, if it has been off for less than an hour, keep using the same level it was at before.

It remembers brightness during each session, but resets to a default brightness afterward so it won’t do anything unexpected. No more accidental moon mode during the day, or accidental turbo during a late-night bathroom trip. If it has been on a shelf for a week, there’s no need to wonder what brightness it’ll turn on at… it’ll use a predictable default. Set the memory timer to match the attention span of the user, and it’ll mostly “just work” in an intuitive way without unpleasant surprises.

I’ve been trying to get the UI as close as possible to just “one click on / one click off” with no need to do anything else. That’s impossible, of course, without telepathy… but this seems to get it one step closer.

Yes, manual memory (the “never remember” mode) is when the timer is zero. If it helps, here’s a table from the documentation, explaining how to configure each of the three styles:

  mem type  manual mem  manual mem timer
  --------  ----------  ----------------
  automatic off     any
  manual    on      zero
  hybrid    on      non-zero

Thank you! The misunderstanding was on my part, my apologies… this is actually excellent! :slight_smile: .

What I was suggesting the inverse of hybrid memory, temporary manual : whatever mode you are on, you can set a timer (10H—menu #3 o #4 ). Now your light is in temporary-manual and will always turn back on (from off) to same brightness level.
When the timer expires, the previous mode comes back.

But you might as well just go to manual memory … no real need for a new menu item.

[edited 2021-04 to make this shorter and to say… hybrid memory is the best!]

Just flashed my D4V2 with anduril 2. Very impressed with the improvements especially the momentary turbo with 2H.Very Good job toykeeper! Now i’d like to know if it’s safe to flash my KR1 (W2 green) with kr4-nofet firmware? Is my D4v2 adapter compatible? Thanks

Would be awesome if someone could provide a complete hex for flashing…

>hint, hint<

You may find the complete built here http://toykeeper.net/torches/fsm/anduril2/

Wow…those are fresh!

Thanks!

Yes, it should work… and that’s the correct build for that light.