STAR Firmware by JonnyC - Source Code and Explanation

star momentary can only be used with a forward clicky on a qlite driver correct?

It can only be used by a light with an e-switch, or momentary switch (not a clicky), such as the SRK. STAR or STAR_off_time is what can be used with forward clicky or reverse clicky light.

ok thanks jonny! i love star off-time, but was just looking for a way to quickly access strobe mode. i guess you cant have everything. :frowning:

It's doable to do something like "tap on and off very quickly two times and it will put you into a hidden mode". But that would require extra logic within the watchdog timer, and the program is already full due to my inefficient coding :)

Of course now I have to look at the program quick just to make sure it would be too tough to tackle...

Well it's doable, it would just require eliminating some features, because I've already racked my brain trying to come up with a better design to make the code more efficient. Some people here have come up with more efficient delay routines, maybe I'll have to look at those.

i tried to eliminate the stars in the code to make more room like mikec did, but it always comes up with errors so i am doing something wrong or not eliminating enough code. i am not a hacker so i dont no what i am doing, but i understand what some things do in the code but am lost in other parts.

if i tried to learn C programming i would probably get a brain hemorrhage or lots of headaches. it seems in code you have to tell the cpu or mcpu the same things several times in different ways to make it understand or so not to make a mistake. maybe one day their will be a high enough language for idiots like me to understand… :smiley:

Jonny; is the low voltage warning (low output slow flash) something built into the chip based on the two divider resistors or is this coded as well?

To me, this is a critical feature as I use these for bike lights where I cannot see them to confirm the batteries are still up.
I rarely run out of power, but I would hate for my unprotected cells to get sucked down below the 2.75V minimum.

That's in the code. I was thinking I could remove the flashing part and just have it step down with a single short blink to the next-lower mode (instead of cutting it in half). Not sure how much space that would save though.

Really, at this point, especially with the new dual-PWM output / PWM type definable per mode feature, each implementation for someone needs to be customized. I guess I could put it all in there, but at the top of the file you have to pick and choose what features you want, but you can't have them all.

I really need to learn C :~

Hi, I’ve managed to get srk_no_ramp_1.0.c installed on my srk. Is it normal that when i switch from mode 1 to 2 (0 to 16), it temporarily lights up at a very low level (just glowing) before moving on to mode 2 (16)? Then if I do a long hold, it drops to the just glowing again until I release the button (and then it goes to 0 )? Thanks!

Yes, that's an issue with fast-PWM and the MCU being awake (while the button is held down) but not outputting a PWM signal.

If you're not using it to control a 7135-based driver, you should really adjust those levels from the defaults in the original source file. Different driver hardware will work with different minimum levels, 7135s need a minimum of around 5-6, other stuff can go much lower. Some hardware may be too bright in the lowest mode with even a PWM of 1.

That brings up an interesting question… is the PWM signal a square wave with an equal on/off cycle or is it a triggered pulse where the off-time can be significantly longer?

These are taken from MCU pin 6.

PWM=2

PWM=6

PWM=18

PWM=54

PWM=130

PWM=255

It does not have an equal on/off cycle.

Duh! :slight_smile: Right… “PULSE =WIDTH= MODULATION”
On-time =during= the cycle.

Thanks for the excellent images!

Thanks.

Its contolling a fet.

So if I’m understanding correctly (which isn’t likely as I don’t understand the program at all) setting the lowest mode (as in #define MODES line) to 1 is an approach to solve this? I did this, but the issue is still occurring.

Is the other solution to set tccroba=0x21?

It is not a problem, doesn't cause anything other than the behavior you described. Phase-correct is noisy and not a good solution for something that isn't wrong.

OK. It doesn’t seem ideal, but doesn’t really bother me. I thought I would get rid of it if I could,but doesn’t sound like its possible. Thanks.

Well, it is possible, by changing to phase-correct instead of fast-PWM, but the issue isn't anything to worry about. It doesn't do anything at all except keep the LEDs dimly on if you hold the button down after backing up from the 1st mode to off. The MCU goes to sleep as soon as you release the button, that's why the LEDs fully turn off then. Some earlier firmwares used a different sleep strategy, and if they used fast-PWM the LEDs would never fully turn off... but this FW is not like that, as you yourself pointed out - the LEDs do turn fully off.

If you would rather change it to phase-correct and end up with a light that squeals like a stuck pig in the upper-middle modes, all to get rid of something that only happens when you keep holding the switch button after you've told the light to turn off, well....

I decided to try what you have called the phase correct ( 0*21 thing) to see what would happen. The low level light when the button is pressed is no longer there, and yes I do get a slight buzz, but only audible if I’m in a really quiet room and ear right near the torch. That’s not a problem for me, unless it is some way damaging the driver.

Is it genuinely loud for you went you use the phase correct? Maybe im lucky mine is very quiet. Or you just don’t like the very slight buzz?