E-switch UI Development / FSM

Hey y'all i'm late to the party and i'm trying to figure this out. I want to run anduril on a TA board that i'm pretty sure is a tripledown layout. Do I just add in a line "#define TRIPLEDOWN_LAYOUT " ?

And what about the FET+1+20 part? Its just a FET+1+6. Any help will be much appreciated

I’d suggest copying the FW3A config, or even just using it directly, depending on the details of that driver. It’s a FET+7+1, so it should be pretty close.

I recently (in the fsm branch) reorganized how hardware definitions work… there’s a physical layout file, like hwdef-FW3A.h, showing which pins do what and a couple other things. There’s also a UI config file, like cfg-fw3a.h, which configures options specific to Anduril or FSM.

Then there’s a magic #define to tell it which hardware config files to use.

There is a Tripledown definition, but I think it’s designed for a clicky-switch type with OTC and a voltage divider. So I suspect the FW3A definition might be closer, if you’re using it with e-switch instead of OTC, and if you take the voltage divider off. (it’s not recommended to have or use a voltage divider for e-switch lights, since it increases parasitic drain)

If you’re doing multiple cells in series though, it’ll need the voltage divider, and some bits copied/tweaked from the BLF GT configuration. And the 7135 chips are likely to burn out.

Anyway, you can probably just remove a voltage divider resistor and flash the FW3A build directly. If my guesses are right, it should “just work”.

Thanks TK. It's going into a sofirn C8F triple e switch only 1S light.

So, I'll just leave the voltage divider out and use the FW3A config.

What in the world is the optic nerve? Programming? More importantly for me at the moment is can I power the side switch LEDs with the FW3A config?

This is completely awesome.

It means my clicky and e-switch lights that I use daily can have the same user interface.

Just need to change the AtTinys on the Bistro lights to 85’s.

Oh, the FW3A doesn’t have a pin for an aux LED. The four main pins are used for 1x7135, Nx7135, FET, and e-switch. But you could probably attach the aux LED to pin 7 (PB2), and define something to make it use that. It should work, but will involve compiling your own version.

I’m also not entirely sure it’ll fit into ROM all at once. The third PWM channel uses extra space, and the aux LED uses extra space, and there may not be quite enough room for both unless you turn off something else.

Not really. E-switch and clicky switch aren’t capable of doing the same things. For example, it’s impossible to do “hold to change brightness” on a clicky switch, because holding (reverse clicky) physically disconnects power.

Anduril does not work on lights which have only a clicky switch. It requires an e-switch.

Comparing it to a computer, an e-switch works like a mouse button. It can be up or down, and the computer keeps processing in both states. But a clicky switch is more like pulling the power cord out of the wall. The computer won’t do anything at all until it’s plugged in again.

I don’t have any lights with ramping, never thought of the hold to change brightness thing. I was hoping FSM could do modes just like Bistro.

Out of all the flashlights and bike lights I have only three have the same user interface. I really want to do something about that.

It can do modes, like Bistro. There are several interfaces available, though the most popular one is Anduril. And instead of doing smooth ramping, it can do a mode group. Like Bistro, the user sets the number of modes. Unlike Bistro, the user can also set the brightness of the lowest and highest mode, and it’ll automatically space the in-between levels evenly. The actions from there are a little different than Bistro too — hold for a brighter mode, release and hold to go to a dimmer mode.

Or if you want e-switch lights to work almost exactly like Bistro, Flintrock added e-switch support to Bistro-HD. It pretends the e-switch is a clicky switch, even making sure to turn the light off momentarily while the button is pressed. It uses short and medium presses to go up and down. However, since an e-switch can’t actually cut power, turning the light off requires an extra-long press.

Bistro works fine on the clicky lights.

What I would like to do is unify my bike lights somehow. Getting to low mode fast when rounding a bend at speed on a bumpy trail and meeting another trail user needs to be easier. Too often I wind up in programming or strobe mode.

Now that Narsil and Anduril are available for buck drivers it has me thinking about replacing the Pic’s with AtTinys on a board glued to the LED shelf. How the light reacts to overheating is a big concern. The lights with a remote battery pack are quite small for the power they produce. The light needs to be able to protect itself when going slow or stopped but can’t step down abruptly when going fast in tricky sections.

The way you have Anduril responding to heat looks really good. It can’t match the Pic based lights with an actual temperature sensor but having the MCU to the shelf should be good enough. Ideally I’d like to remove some functions so they can’t be accidentally accessed or heavily debounce the e-switch. One button press can turn into many depending what the front tire runs into on the trail. I’m OK with basic Arduino stuff, a quick look at Anduril code tells me I am in for a steep learning curve.

Hello, maybe this question is already asked, but i dont want to get through 300 posts here :frowning:

i have BLF A6 driver, now i want to flash new FW which supports e-switch, which FW should i flash, thank you
I can reflow the attiny 13 to attiny 85 if needed

The BLF A6 driver has an issue with large voltage spikes on each FET pulse. The attiny13 handles this like a champ, but other attiny models reboot when the voltage goes out of spec. So they don’t work well above 4 or 5 Amps.

So you could stick with attiny13-based firmware, which will only have very simple interfaces, or you could mod the driver even further to fix the voltage spikes, or you could get/make drivers which don’t have that problem.

It sounds like a pretty detailed project, doing fairly deep modifications of both hardware and firmware. Have you considered making a thread for it here on BLF? It’d be exactly the sort of thing people love to see and talk about.

The hardware should be fairly easy if it’s possible at all. Del and (mostly) you have already solved the biggest problems.

The most daunting part is trying to understand FSM and Anduril. All the modes I don’t want to accidentally enter need to be removed or made inaccessible to the e-switch. If I get to the point where I’m able to do this its going to make other small projects I’d like to do possible.

Typing speed and writing skills are not my strong points, any thread I create will be pretty bland.

If, for example, you wanted to disable the ability to go from “off” to the strobe modes… go to the off_state() function, look for the part where it changes state to strobe, and comment that out. Basically, remove this:

    // click, click, long-click: strobe mode
    else if (event == EV_click3_hold) {
        set_state(strobe_state, 0);
        return MISCHIEF_MANAGED;
    }

This basically removes one arrow in the UI diagram, and thus gets rid of an entire set of blinkies.

Or there are other FSM-based UIs which don’t have all that extra stuff to begin with. You might do better making something new instead of removing most of the fancy parts you don’t want. The DarkHorse UI might work for the purpose you described, though it could probably use better thermal regulation.

Using the pyramid method fixed the issue completely when building triples with high current using a A6 or X6 board transplanting the attiny85 running NarsilM. I used Djozz’s pic’s as a guide. :wink:

I’ll have to look at Dark Horse, if it doesn’t have smooth ramping it could be a good place to start. Or taking a functioning program, understanding and removing one piece at a time and seeing what breaks. Ideally it gets so stripped down that e-switch programming is removed. If I end up writing my own program I’ll probably use a different MCU with more pins and do it in Arduino, it comes with training wheels. And it will be very, very basic.

Good temperature regulation is important, there won’t any hands monitoring temperature for long periods of time. And stepping down to 400 lumens after cresting a hill on the trail and heading down at 20+ km/hr will probably end badly for me.

Step one is to wait for a new buck driver to arrive for a flashlight and then use the old driver as a proof of concept.

If you’re familiar with Arduino, FSM should be pretty comfortable. It uses a very similar code interface, except it has a bunch of flashlight-related and e-switch-related stuff already taken care of in a library. You mostly just have to design the interface flowchart-style, then convert the flowchart bubbles into _state() functions and convert the flowchart lines into state changes.

The Baton UI might be a simpler place to start. ZebraLight (DarkHorse) is kind of a funky interface.

So i have do some research on BLF A6 driver and attiny 13, the driver already uses the Interupt pin, so E-switch is hard to add, i guess

I’d like to try Anduril on the BLF Q8.

I don’t have any knowledge on flashlight programming, so maybe just a precompiled hex file that will work on the stock BLF Q8, and also what exact command-line to use (Windows command line).

(I have a USBASP programmer device and have downloaded AVRDude software; but have yet to try a successful flashing with it)

I can’t seem to find the correct Anduril repository from TK’s firmware repository here:
https://code.launchpad.net/~toykeeper/flashlight-firmware/

~

another question:

I’d also like to flash an old Convoy C8 XM-L2 (the one with the 5/3-group modes L-M-H-Strobe-SOS) into Biscotti, I’ve found the biscotti.hex file from here (hope it’s the correct one):
https://bazaar.launchpad.net/~toykeeper/flashlight-firmware/convoy/files/head:/ToyKeeper/bistro/biscotti/

what specific command line should I use with avrdude?

Pardon my newbie questions…