E-switch UI Development / FSM

Is Anduril able to use both AUX and Indicator LED's at the same time as long as the driver has the required hardware capabilities / pins ?

Not sure what you mean by AUX and Indicator LED's? I always thought of them as two words describing the same thing. I "think" Anduril has control over one pin for AUX/Indicator controls, so you can run multiple LED's off the same pin, for example, the switch LED's and the Lexel AUX board LED's on a MF01 Mini.

Pin Summary

1 - Reset (can be used for I/O but would break the popular dongles for re-programming)

2 - switch

3 - AUX LED, or main LED channel

4 - GRND

5 - main LED channel

6 - main LED channel

7 - for 6V/12V designs used for voltage divider for voltage reading, spare for 3V designs, or AUX LED for 3 channel drivers

8 - VCC

Example flashlight/driver pin layouts:

MF01-Mini driver layout
-----------------------
Reset -|1 8|- VCC
eswitch -|2 7|- aux LEDs
FET PWM -|3 6|- PWM (7x7135)
GND -|4 5|- PWM (1x7135)

Emisar D4 driver layout
-----------------------
Reset -|1 8|- VCC
eswitch -|2 7|-
AUX LED -|3 6|- PWM (FET)
GND -|4 5|- PWM (1x7135)

These two layouts above represent the classic 3 channel (FET+1+bank) and 2 channel (FET+1) layout of BLF drivers.

Hi Tom,

In Anduril the AUX LED's are the RGB front facing LED's, each one with its PWM PIN and the Indicator LED is the side switch LED, which is only 1 color, usually green. Thus far I have only seen lights using either one or the other, but never both. MF01 Mini only uses the Indicator LED PWM Channel for both the side switch LED and the front facing LED's. There is independent code in anduril.c to use any of them, but as per most lights hardware, the code is reflected as such, thus using either the Indicator or RGB AUX LED's code, but not both at once.

Regards.

Ahhh. Haven't noticed independent support in Anduril yet, but it certainly could be there. Since the Attiny85 has limited I/O pins, a 2 channel or 1 channel driver could use pin 7 as a secondary AUX/Indicator control, but I don't know what Anduril would do with the two separate functionalities.

Custom BLF drivers I typically use in a lot of mods are 2 channel 3V setups, so pin 7 is always available. I'll research Anduril now and look for the possible support there. I've even used 3 channel drivers as 2 channels, and not even populate the 7135 bank. This requires some switching around of the I/O pin assignments but NarsilM has support for that, so probably could be done easily in Anduril, but there's probably no existing hwdef file for it yet.

I have a problem with aux LED voltage indication on my D4Sv2.
When I connect power it sometimes blinks green but aside from that split second it’s never green, goes from blue directly to red.
I thought that was my bug (I still introduce many :frowning: ) but now checked with the TK’s latest revision and it’s not - I just put a ~3.7V cell, voltage blinkout shows 3.7 but aux LEDs are red…
I look at the code and fail to see the culprit…

I don't own one and there's no info about LVP indications on the product page: https://intl-outdoor.com/led-flashlights/emisar-d4sv2.html.

What is it supposed to do? Does the MCU think it's voltage is low, indicated by dropping amps?

It’s about voltage indication rather than low voltage indication. It’s a special aux LED mode which turns them blue above 3.8V, green above 3.3, red above 2.9. Below that they turn off. At least that’s what I see in the source, not in operation.
I don’t have a proper PSU, just a set of cells charged to different levels and I don’t see the exact thresholds but at 4V I see blue, at 3.7V and 3.5V I see red. In actual use I’ve never seen green.

Wow - this is strange. There's no manual on this light that documents how the AUX LED's work? From the UI diagram, I can only guess there is no auto setting of the color based on voltage, but you manually set the colors - it clearly shows that. Are you sure that code is relevant to this D4SV2 build?

Yes, it is relevant to this build. It has manual colour setting but also 2 other settings, rainbow/demo and voltage. You can set it independently for off and for lockout.
Mine is definitely in voltage readout both for locked out and for off, though I use different brightness to differentiate between them.

BTW I noticed something that may be (or may not be) a bug (unrelated):
{

2302-void indicator_blink(uint8_t arg) {
2303- // turn off aux LEDs when battery is empty
2304: if (voltage < VOLTAGE_LOW) { indicator_led(0); return; }
2305-
2306- #ifdef USE_FANCIER_BLINKING_INDICATOR
2307-
2308- // fancy blink, set off/low/high levels here:
2309- uint8_t seq[] = {0, 1, 2, 1, 0, 0, 0, 0,

2330-void rgb_led_update(uint8_t mode, uint8_t arg) {
2331- static uint8_t rainbow = 0; // track state of rainbow mode
2332- static uint8_t frame = 0; // track state of animation mode
2333-
2334- // turn off aux LEDs when battery is empty
2335: // (but if voltage==0, that means we just booted and don’t know yet)
2336: uint8_t volts = voltage; // save a few bytes by caching volatile value
2337- if ((volts) && (volts < VOLTAGE_LOW)) {

rgb_led_update() treats voltage of 0 specially.
indicator_blink() doesn’t.

Dunno, depends on the state each of those is called. Maybe the state of "voltage = 0" is only relevant when rbg_led_update() is called?

For you AUX LED issue, dunno, maybe there is a bug in the voltage setting. For the hardware, I assume you can verify if the green LED's are working, if so, then I'd suspect a bug in the firmware. With that 1634 processor, there's plenty of I/O pins, so I assume she's got one dedicate to the green aux LED's, so if the full green setting is working, then it should work the some for voltage reading.

Ohh - it helps to use a fixed space font like Courier new for quoting code. I do this all the time.

I worked on adding voltage Cal to Anduril. All coded, compiled, ready to test. I made it work to enter the fudge factor via clicks. 5 clicks is 0.25, 7 clicks is 0.35, etc. Max of 10 clicks.

Installed this just now on a SP36, previously had NarsilM v1.3 on it, and been testing it - the voltage fudge factor configuration seems to be working fine!

If I set it to 3 clicks, it reads 3.8V. If set to 10 clicks, it reads 4.1V. A difference of 7 clicks is about 1.75V, so this makes a lot of sense. Now if we (or I) could get this rolled in the official Anduril? Seems like a great feature. I was gonna spend the time doing it with NarsilM but it would be a lot more effort, because I also would have had to roll thermal config in.

Wooo Hooo!!

Well, crap. The Astrolux EC01 is one of my favorite torches right now. My son has one, and I have 3. Now that I’ve sent all that money their way, I find out they’re violating the GPL. I figured since they say right in the titles of their product pages that they’re using Andúril, that they would have done it right.

Another observation:
When I’m in voltage blinkout mode with the cell I have in the light now, the first result is either 2.6V or 3.6V (not sure, the light turns on and off as I do the clicking), probably 3.6V. But later it shows consistently 3.7V.
Is it that turning it on for the split second drops cell voltage by 0.1V and the first blinkout starts before the cell recovers?

Tom E,
Great feature, but it will be used once after flashing firmware and forgotten

True, hopefully, but that's the point - just like thermal config settings. I'm tired of re-flashing simply to tweak these settings, like I've been doing for years with Narsil. Also, there's been a lot of complaints in production lights on the inaccuracy of the voltage readings, so we will have a fix for that.

I've noticed this in my Anduril lights as well - usually a 0.1V variance, but not sure if it happens in Narsil as much. Well, the D4SV2 is a 1634 light, so the low pass filter is enabled in the cfg-emisar-d4sv2 file. Just reviewed it, and it's the same low pass filter I implemented in Narsil, actually first written by DEL. DEL's/Narsil's implementation is interrupt driven for the A-D conversions, and best as I can tell, so is Anduril, but the interrupt processing is deferred. Her interrupt handler is 1 line of code in fsm-wdt.

The only difference I can see between Narsil and Anduril is that Narsil throws away the first, or every other ADC voltage reading, and Narsil doesn't defer the processing.

So the cell will lag under load - I've certainly seen this, though I thought it was with more weak type cells, like 16340's, etc., but maybe even on a good cell, the lag could be seen as a small dip.

Awesome Tom E, sounds like a very worthwhile addition!

I guess that battery sag could be fixed by blinking number of volts , reading voltage again and blinking 0-1 numbers for full volts and then the decimals. Careful not to blink 4.9.
Or better: blindly do 2 blinks and then the rest.

Might be easily fixable by a delay. I recall from DEL, there was a reason to skip the first reading... This was back in the day of the Q8 development.

The low pass filter we use is still subject to 1 off glitchy readings - it's not doing averaging of any kind.