STAR Firmware by JonnyC - Source Code and Explanation

Oops, I just realized/remembered that STAR doesn’t know at compile time how many modes there will be. That certainly makes it harder to use the mode index to decide what kind of behavior to use.

Hi, I really like a feature, rmm’s tk61 super driver has, the momentary turbo from off mode. It works until you leave the long press. Richard gave me some tips on how I can add this to star firmware but my skills dont let me to accomplise that.
Can anyone assist me on that?

Adding momentary turbo from off shouldn’t be terribly difficult, but it has a cost that you lose the ability to map long-press-from-off to something else.

I added it to my todo list, but I’m not sure when it’ll happen.

For now, there are a couple of similar options:

  • Long press from off goes to turbo, release and short-press to turn it off. (in one variant, holding the initial press longer will ramp down) Short press from off goes to the lowest mode (repeat to increase brightness). Turn off by raising or lowering brightness past the maximum level. One version also has a battery check mode on short-then-long-from-off.
  • Long press from off goes to moon, short press goes to last-used level, double click from off goes to turbo. While on, short press turns the light off, long press and hold ramps brightness (smoothly or in steps). Extra-long press from off toggles soft lockout on one version of this UI.

Would either of those work? There’s basically STAR momentary, my version of STAR momentary, a smooth ramping UI, or a stepped ramping UI (like an Olight Baton).

Thanks TK, will I find these in your repository?

Yes. STAR itself is in the JonnyC directory, and the others are all under ToyKeeper/Ferrero_Rocher/ .

I still need to make the red/green battery indicator bits easy to turn off at compile time; these were designed for a very specific driver. They work on other attiny13-based e-switch drivers though. The most likely thing to need changing is the PWM levels, since that’s very hardware-dependent. It’s calibrated for a FET by default.

Edit: Actually, looking at the code today, I have lots of misc cleanup to do… and need to apply upgrades from some of the files to the other files. I mostly stopped after getting things working, and didn’t finish the “polish” to make it really clean for others to use.

Edit 2: I just did some significant cleanup, mostly merging code between the three Ferrero Rocher firmwares to make them more consistent. It should be significantly easier to turn off the red/green indicators now, at least. Also freed up more space on two of the three.

Hello all!
I really like the Star (On-Time Memory) program. It is simple and functional. However, I would like to see one additional feature: the ability to reduce the mods in the normal and reverse cycle. I mean the following:
Short press (from off) (ML), Low, Med, Off
Long press (from off) Turbo, High, (Med), Off
In this way I do not need to go through unnecessary mods.
Is this addition difficult to accomplish?

I think this is impossible. Long/short press functionality while on has been implemented by a member here in STAR off-time, but I believe it is impossible from an off state.

I meant, of course “Star momentary driver” program.
I apologize for the error

No worries! Unless I am misunderstanding what you want to do, the momentary program already does have that functionality.

Function may be already in the program, but I do not find it there. So, I just may have to study more about the program.

It is already there by default. You can change the amount of time that constitutes a long press by changing the LONG_PRESS_DUR value. 32 ticks (0.016 seconds each tick) is the default, but I prefer 22 to 24 ticks.

That should be do-able with only small changes.

First, you’d want to put a 0 in the middle of the mode sequence. Second, you’d need to add a line in the main loop which sets the mode index to zero when the PWM level is zero. This way, it would reset to the default “off” state whenever you reach that level.

Using the stock STAR_momentary, you may also need to redefine the number and value of output levels, disable alt PWM, and possibly disable the hidden momentary mode.

Does this make sense?

Yes, it does make sense!
Now I just need to focus on programming.
Thank you for your help.

A couple of members have recently sought a “1 mode” driver/firmware for various reasons.

Using STAR as a base, it’s easy enough for people with limited code skills such as myself to comment out all modes bar 255, but I found that this method doesn’t play nice with the low voltage warning/step down, as there is no lower mode to step down to.

If I keep a 2nd lower mode in there, the code works as it should, but there will be instances where the lower mode can be inadvertently changed to, even when set to come on in High mode every time.

I want to keep the low voltage step down routine, so “Mr. Muggles” sees the light has dimmed noticeably, & figures that it’s time to change the battery.

I’m thinking that the best solution would be to disable the part of the code that looks for the ‘quick-click’ for the mode change, or just shorten that time so as it’s not possible to click into the lower mode.

Could one of the code Guru’s help me out with what needs to be changed - I’ve tried to follow it through, but can’t put my finger on it.

Cheers :slight_smile:

I guess easiest would be to simply comment out the “next_mode()” call from the mode_idx&0x10 check (or comment out the entire mode_idx&0x10 check routine), disable mode memory and have mode direction high to low.

I assume we are talking about the clicky firmwares.

For the clicky firmwares I think the most straightforward way to handle it is to set the minimum stepdown brightness manually. This line determines the lowest PWM level the driver will stepdown to:

if ((PWM_LVL >> 1) < modes[0]) {

Note that it’s based on modes [0], the first mode, but in a single mode driver that’s the only mode we have! Instead we just set it like this:

if ((PWM_LVL >> 1) < 30) {

where “30” is the lowest level we want it to step down to in this case. Assuming the single-mode was set to 255, stepdown pattern would look like this:
255, 128, 64, 32, 30, 30, 30, etc, …, critical shutdown

If you’re building a lot of single mode drivers and plan to change the minimum stepdown level a lot you may use a define for that value, just add one at the top like:

#define STEPDOWN_MINIMUM 30

if ((PWM_LVL >> 1) < STEPDOWN_MINIMUM) {


EDIT: My kingdom for a [code] tag. The forum software is messing up the first code quote, the mistake is fairly visible though (modes with a superscript zero).

That's what I usually do: define a lower mode, but don't put it in the normal mode orders, then tell the program to step down to that level as the minimum. I also do the same thing when I want the turbo timer to step down to a "hidden" level.

Hi all,

I have a somewhat related question. Is there any way to use a pot to control a 7135 based driver?

See my posts a few pages ago where I started working on the code to do that with LVP integrated.

Alternatively you can use a VaraPower driver and hook up the PWM input on the 7135’s to the gate pin on the FET of the VaraPower (but do not route LED power through the VaraPower of course!).

Thanks for the help everyone, I’ll try defining the step-down level & adding it in there.

I’ll be flashing a couple this weekend if all goes well.