STAR Firmware by JonnyC - Source Code and Explanation

Well with the current design, as soon as a long press exceed 512 msecs, it acts on a long press action (mode decrement), so you have the same mode flash issue. Also, I would prefer one simple single click to turn it OFF.

I just want to say “Thanks” again to JonnyC (and anyone else who contributed to the Star1.1 code) for sharing this with the rest of us.

With a little more fiddling around today, I was easily able to customize it to provide exactly the functionality I’ve been looking for:

  • L, MH, Turbo (1-minute) output levels
  • No low battery step-down warning flash (step-down is warning enough for me)
  • “Soft Blink” critical low battery cut-off warning (20 blinks @ 750ms on / 750 ms/slightly dimmed)
  • 3.17V low battery step-down trigger voltage
  • 2.84V critical low-battery cut-off trigger voltage (might raise that a bit for unprotected cells)

This code accommodates my needs (and my limited programming skills) quite nicely.

Sincerely, Thanks - again,

JW

Me Too! Thanks double JonnyC and RMM!! Just programmed my customized version of STAR Momentary into a ZY-T11 clone (here), UltraFire. Here's what I did:

  • Modes: 0,5,15,92,255 (5=moonlight, 15=6%, 92=36%, 255=100%)
  • Running PWM's at 9.4 kHz (phase corrected)
  • Cut the long press down time from a 1/2 sec to 1/4 sec (much more responsive!)
  • Added a new compile switch option of "Idle Lock", and set the time to 1.2 secs. What this does is if the light is ON, check for a time the button is Idle for - if it exceeds the limit (ex: 1.2 secs), then the short click will turn the light OFF. The long click is still functional
  • Disable TURBO option, enable Voltage Monitoring keeping the low of 3.1v, and critical changed to 2.84v

So for me, I like the Idle Lock feature because with the quicker long press because:

  • From OFF - one click to moonlight
  • From OFF - 1/4 sec hold to High
  • When turning ON, you can change modes all you like as long as mode changes are within 1.2 secs of each other, just as you used to
  • While ON, if you pause from changing modes more than 1.2 secs (i.e. idling), a click will turn the light OFF, but longer clicks will still change modes from higher to lower

The behavior is more like Dr Jones' lumodrv, but not exactly the same. Also the one-click-OFF feature is really nice with a higher numbers of modes, like 5 or 6.

If anyone is interested, I can publish the modified source code - let me know.

Other details of the mod build:

  • QLite 3.04A with 2 7135 350's added (3.74A total), piggy backed on stock driver, stripped all components off the stock driver except the switch. Removed the stupid charger connector too.
  • copper penny added under the pill top for extra heat sinking (Arctic epoxied, surfaces sanded, solder added on edges of penny to fill small gap to the pill walls)
  • XM-L2 U2 1A on 20mm Noctigon -- thinner star from stock results in reflector rattle, so added an o-ring between the reflector and glass -- worked well!
  • copper braided driver spring, need to copper braid tail spring also
  • roughly doing 1,100 lumens or so on a Pana PD. May go up a bit with copper braiding on the tail, using a Pana PF or Sam 20R, and replacing the stock lens with a AR

Tom E

Got a STAR_Tom_E.c for us?


I can post it, somewhere, maybe on Google Driver like RMM did. But, I pm'ed JonnyC with a question/issue yesterday, waiting for a response. I'd like to get his response first to be sure the code is ok... Also I'd like to hear from RMM if this is ok to do?

Thanks JohnnyC and RMM sharing the code. Also, Tom E enrich the features of convenient option.

Please publish the code to let us the AVR dummies can learn and experience the new customized features.

Here is updated source code: https://drive.google.com/file/d/0B1IxYZuk4Djcc09STnlITjh5OW8/edit?usp=sharing

Few Notes:

  • I used Atmel Studio 6.2 to compile this (latest - marked as BETA)
  • I formatted for tabs being set to every 3 columns, not 4
  • I added a few comments and function headers, etc.
  • I'm a long time C programmer, so re-formatted the code to a style I'm used to. Please understand just because you have 3 lines of code in one line in the source code, doesn't mean it will take less memory up when compiled. Comments and blank lines are free - no penalty in the compiled code.
  • I'm not sure of the de-bouncing is working the way JohnnyC intended. I could be wrong -- waiting on JohnnyC to respond to my PM. The "fix" I suggested is not in this code. I'm thinking de-bouncing may not be necessary on this hardware - not sure...

Thanks Tom E,

I built and run the code in Studio 4.18 with no error. I shall flash the 13A to-night to play with.

In playing with it, the 1/4 sec long click/hold is maybe too aggressive. Probably wise to back off a little - I'm gonna try 0.3 secs or 0.35 secs next time. The way it is now, you can accidentally get a long click if you are not quick.

19 would be the value to use for "LONG_PRESS_DUR" to get 300 msecs, 22 for 0.35 secs.

Tom, I replied to your PM. I'll follow up to other questions/comments tonight when I get back in the US (took a trip to Cozumel for a week). Real quick though I'll say I'm glad you all can utilize this and customize it so easily! I will be adding a slightly modified program for off-time memory. Capacitors arrived at my house yesterday and I'll be building my first light to test it out soon.

I can’t seem to stop playing with this code – I’m having too much fun with it.

In addition to customizing the low battery warning blinks as mentioned previously, I’ve made one more tweak I think I’m going to like.

In essence, I’ve configured the driver for 3 basic mode levels, but with a fourth level that is only reached following turbo time-out.

Momentarily releasing the switch following time-out bumps it back into turbo for another time cycle.

Normal mode cycling is simply L-H-Turbo (skipping the turbo step-down level).

It goes something like this:

Low = PWM 15
High = PWM 75
Turbo = PWM 255 (1-minute)
Turbo Step-down = PWM 150

I’ll fine tune the levels and turbo timer once I put the driver into a host and use it for awhile.

The reason I chose to do this is because I found that having 4 or 5 levels resulted in too much “switch fiddling”. It wasn’t long before I found myself missing the simple 3-mode w/memory configuration. (K.I.S.S. comes to mind once again…)

I think the turbo step-down level combined with a short turbo timer will help to manage heat while not drastically hindering usefulness (at least for my needs).

Thanks for reading…

-JW

once the turbo step down happens can you bump it back up to turbo with a 1/2 button press, or do you have to recycle back thru?

most excellent...can we get a code posting of what you did here [in quotes or a link or whatever]?

If you make a change, post the .c code here so others to compile and mess with it too

Cycling through is not necessary.

Following turbo time-out, last mode memorized was “turbo”, so turning off (for any length of time) then back on will return to turbo mode. In other words - short off, then back on will return to turbo and restart turbo timer.

Are you saying I could copy the text from the .c code, put quotes around it, then post it here? I suppose I could try that…

-JW

comfy - Great info on the dip switches! I was actually browsing DigiKey the other day as I was thinking about doing the same, and I figured someone had already done it. And I agree, after going through about three 3M clips I just went with the Pomona and it's working great.

drdanke - Awesome work and excellent documentation!

BIG-P - Just let me know what you need and I'll get some drivers to you :)

JW980 - Excellent. I just guessed on the low-voltage warning signals and I figured the 250/500ms was a bit goofy, but figured what the heck. And I hear you on tearing down lights to reflash. I probably have 3 or 4 sitting around that have old programs that are just clunky to me now, have bad PWM, etc.

Tom E - I like your firmware. Someone else did/suggested the same thing, where you can switch through modes at the start but after a set number of seconds a short press will turn it off. There are so many options for momentary drivers it's hard to write a program that everyone will like, so I'm glad you were able to customize it.

I received a couple of different 1.0uF capacitors and one style of 2.2uF caps today that I'm going to try out for the off-time memory. I guess that's the next source that RMM can toss up there if it ends up working well, although it's really only 4 or 5 lines that need to change.

I tried that, it get’s all squiffy…

JohnnyC - There are so many thread that I forget which one I have read ” the capacitance change because of the temperature may affect the off-time memory” and there is a link to MLCC of Y5V. I hope you have purchased the 1uF and the 2.2uF are X5R or X7R which capacitance are more stable at high temperature.

Is there this kind of thread in CPF?

No idea..I don't go there

To be honest I had no clue what I was looking at when ordering the capacitors, but I did get X7R ones because they had the greatest operating temperature range. This is one of the ones I purchased - http://www.digikey.com/product-detail/en/CL21B105KBFNNNE/1276-1029-1-ND/3889115.

For anyone interested, my modified version of the Star1.1.c program (see “JBW-” comments) and corresponding hex file have been posted here:

https://www.dropbox.com/sh/yjq5ahllbuqf1zh/yoJRh8nJPT/STAR/JW980.build

Thanks to WarHawk-AVG for posting it for me so others can see what was done :slight_smile:

-JW