E-switch UI Development / FSM

I figured that what else it could be while laying in bed thinking about this. Too far into this hobby where this ends up happening…

I would definitely need to test this on the bench with the PWM to see how it behaves. I have seen a test of these where at 120mA they start to go blue… Are there lower power 7135s?

There should be lower-power chips of the same general type. I’m just not familiar with them.

Lots of code updates lately, though most of them aren’t UI changes. Most are to keep code cleaner and more manageable, splitting hardware-specific bits out into their own files and such. This way, new drivers can be added more easily with less clutter. Drop in a hardware layout definition and a UI config file, and it should be pretty much done.

Due to the way the C preprocessor works though, it does typically still require adding a couple lines to the main source files. But the changes there are a lot smaller than they used to be, and easier to read.

Anyway, I paid off some technical debt so I’m done for the evening.

:+1:
Thanks TK.

@TK
I couldn’t compile the latest anduril r344 for BLF Q8 in Atmel Studio 7.0
Got this error: #elif with no expression anduril.c Line 72

But it was an easy fix by changing:

#elif FSM_BLF_Q8_DRIVER
to
#elif defined(FSM_BLF_Q8_DRIVER)

Thanks TK for all your awesome work!

Oops, that’s definitely a typo. Fixed.

I wonder how it even compiled like that. I’ve been using a script lately to build every supported version every time instead of doing just one, and the Q8 version built and worked normally under gcc 4.9.2. But it looks like it really shouldn’t have worked…

Since it’s a thing people might want, and since I think Lexel may have been requesting it, I took a moment to make a Werner-style momentary UI, side e-switch plus tail clicky-switch.

https://code.launchpad.net/~toykeeper/flashlight-firmware/fsm

The short version is:

While completely off (power disconnected):

  • Click tail to turn on at memorized level.
  • Hold e-switch and click tail to enter utility mode.

While on (regular “on” mode):

  • Click tail switch to turn off.
  • Click side switch to go brighter.
  • Hold side switch to go dimmer.

In utility mode:

  • Click side switch to go to regular “on” mode.
  • Hold side switch to go turn on at lowest level.
  • Double click side switch to turn on at highest level.
  • 3 clicks: Battcheck.
  • 4 clicks: Ramp config.

Battcheck mode: Blinks out battery voltage.

  • Click to go back to utility mode.
  • 2 clicks for tempcheck mode.

Tempcheck mode: Blinks out current temperature in C.

  • Click to go back to utility mode.
  • 2 clicks for battcheck mode.
  • 4 clicks for thermal config mode.

Thermal config:

  • During first “buzz”, click N times to set floor level to N out of 150 total levels.
  • During second “buzz”, click N times to set ceiling level to 151 minus N.
  • During third “buzz”, click N times to set number of total brightness steps.
  • Each “buzz” can be skipped to leave the value as-is.

Ramp config:

  • During first “buzz”, click N times to calibrate current temperature to N degrees C.
  • During second “buzz”, click N times to set thermal ceiling to 30 C + N.
  • Each “buzz” can be skipped to leave the value as-is.

Includes LVP and smooth thermal regulation, copied directly from Anduril.

nice

Is it possible to change the brightness of the low level of the indicator LED in the code. I have found nothing. Thank you

Nope, that is set entirely in hardware. It depends on the indicator LED Vf, the battery voltage, and the resistor(s) between them. Note that, in low mode, the attiny’s internal resistor is active, which is why low mode exists at all.

The code can’t change this, because the MCU is asleep and not executing any code. The PWM facility isn’t active.

Thanks for the detailed answer. :+1:

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.