STAR Firmware by JonnyC - Source Code and Explanation

This firmware was written by our fellow forum member, JonnyC. Jon did a great job with this firmware, pulling together many popular elements into one great firmware.

He worked hard to make the code easy to understand, as shown by the great comments placed throughout.

What Features Does it Have?

Clicky Version:

  • User configurable modes
  • Moonlight, mode order, and mode memory selectable via 105c stars
  • Fast or Phase Correct PWM, switchable by mode level
  • Optional turbo timer up to 120 seconds in 0.5 second increments
  • Dual PWM output option
  • Low voltage ramp down and shutoff
Momentary Version:
  • User configurable modes
  • Quick access to highest or lowest mode order, depending on long or short press (adjustable long press duration)
  • Fast or Phase Correct PWM, switchable by mode level
  • Optional turbo timer in 0.016 second increments
  • Dual PWM output option
  • Low voltage ramp down and shutoff
  • Temperature monitoring (with external sensor)
What Doesn't It Have?
  • No blinky modes, i.e. strobe, beacon, sos, etc. (by default, but others have added this functionality in custom builds, just search the threads)
  • When you build this code, you need to set your compiler settings to -Os (optimize for size)
  • Everything else you need to know should be explained in the code comments. Please read them first before asking a question here!

Where Can I Get A Driver With This Pre-Flashed?

How Do I Flash This Myself?
  • First, generate and create a HEX file from the code. Comfychair has an excellent tutorial on how to do this here.
  • Second, flash the file onto your device! For more information about this process, please see this wiki.
Current JohnnyC Firmware:
  • STAR On-time memory v1.1
  • STAR Off-time memory v1.4 (requires 1uF capacitor added between star 4/PB3/pin 2 and ground)
  • STAR Momentary Driver v1.4
  • STAR Dual-Switch (momentary + clicky)

Link to Jon's Github Page (download FW source here!)


Member Modified Versions: (PM me with link if you would like your work posted here!)


STAR Momentary mode switching order


Ah... some lines look familiar from luxdrv, and the stars config idea from NLITE.

Nice!!!! Downloaded, will compile a .hex when I get home...

Awesome!

Nice levels [8, 14, 39, 110(w/ turbo), 120, 255]

And a 2 min high dropout from wide open 255 back down to either 110 or 120

All I need now is my daggum AVRUSB and a daggum SOIC 8 pin clip...ARRRGH

Thanks JonnyC, DrJones and Richard.

Absolute brilliant coders!

And Tido too

... and sixty545, who came up with the low-battery step-down mechanism.

This is awesome guys! Thank you very much for all your time and effort!

I can only think of 2 small additions which could make this (and all other Nanjg 105C drivers) even better:

1) Like we have a Zener mod kit, maybe there can be a slider switch kit of 3 very small slide/press/flip switches which we can then solder on each star. Then whenever you want to change any of the stars, you can just slide/press/flip the correct switch :)

2) Off-time memory. Again, either this can be presented as a kit, or can be done by RMM for an additional fee. I know JonnyC was experimenting with this, but what was the final verdict?

Thanks guys, superb job :wink:

great job to all, but I’d caution everyone to be really really careful about commercially benefiting from code that may have been written by others on here without first obtaining their permission. All the great coding projects depend heavily on the time and goodwill of several people on here, some of whom sell drivers flashed with their own code, and it wouldn’t take much for those people to conclude that releasing their code for free for it to be used by a commercial competitor makes absolutely no sense.

Not pointing fingers or accusing anyone here, but this is a very sensitive issue that I’ve thought about alot as I get closer to putting together my own firmware for some drivers I need to flash. I wouldn’t want to see this awesome community hurt by anything, especially something that could be avoided by good communication.

Or it could be "open source" and the money people charge is for their efforts installing the software on pre-built modules

The firmware is "free", but the labor of loading it, building it and all that is what the customer is paying for...the convenience of not having to buy a programmer, a PCB, the components, and then soldering them down, flashing the firmware

But yeah...making sure you ensure intellectual patents are honored is always the right thing to do

that’s kinda splitting hairs. At the end of the day a community like this is built on trust and trust is an exceptionally fragile thing. Once it’s gone, it doesn’t come back. So my big worry is that some of the contributors may think they’ve been made a fool of and don’t want to be fooled twice, which would be a great shame for everyone. I don’t have a horse in this race, other than hoping people keep offering software so I don’t have to figure out how to write it as I’m a coding idiot, it’s just something that worries me and it’s a conversation we should all be having.

Fair enough, and I agree

The reason I started offering the STAR as well as the NLITE was because I was getting requests every day from customers wanting more customization than what NLITE gives them. I did not have the source code, nor did DrJones want to provide it, so there was no way I could do this with NLITE.

As for the similar code: why would you reinvent the wheel when others have OPENLY SHARED their code and you are planning on OPENLY SHARING your own code? After you've seen others code that works you would have to try exceptionally hard to write something functionally similar but coded substantially different, especially with the space limitations of this MCU. It is easy to see that there is original work here, along with better, more understandable comments than I've seen in any other project so far. The reason he wrote such descriptive comments was so that when he shared it, lay people (such as I) would be able to understand what he did and build on it.

JonnyC didn't build this firmware to make money, which is why he released the source code after many of the bugs had been worked out. He wants to help everyone with their projects, and hoped that others would take and continue to build their own code with any part of it (or the whole thing!) that they liked. I pay him a percentage out of gratitude for all of the time he spent with me getting this working, not because he asked for it. The reason I charge for it is because (1) it takes me time to configure, flash, and test every driver and (2) because it is my small way of saying "thank you" for the countless hours he has spent with me troubleshooting and making this work. He will never earn enough off of this to be worth even close the amount of time he spent with me alone.

As for me? I spend WAY more time than it's worth configuring, flashing, and testing these drivers. I offer it so that those who can't yet or don't want to do it on their own have a way to get the flashlight they want. With my limited amount of time I would rather sell parts and have people build their own stuff than build it myself, but I know that there are many who have big dreams and not enough time or skills yet to do it themselves.

As for all of the accusations, let's put them to rest right here and now. Answer this question: if I or JonnyC wanted to profit from this firmware, WHY IN THE WORLD would we release the source code??? This was a labor of love, not a profiteering exercise by JonnyC. Let me reiterate: JonnyC wrote this with the INTENTION of sharing it and helping others with their projects. He wanted to make sure that we had most of the bugs ironed out before releasing the code.

So I hope that this settles some of the bad mojo that's flying around here. The reason I love BLF is that spirit of sharing which benefits us all, and if sharing this source code isn't in accordance with that spirit I don't know what is. I know that it's easy to get caught up in a bunch of assumptions when you don't have the whole story, but let's just let this one go.

OK, now that said...deep breath and back to happy BLF! :)

Thanx All!! Not sure bout this software rights issue. Even though I'm a 35 year career software developer, I make my living on consulting, and I've found the best policy is to be 100% open with my clients, don't hide or disguise anything, and be committed to openness, and teaching to all those that want to learn. This of course is all within the client's organization, or partners we work with.

As far as a community like BLF is concerned, I feel strongly it should be an open community. All of us seem to publish everything we know, teach those that want to learn, put it all out on the table when asked, etc. So making software/firmware/drivers somehow an exception to that rule, just doesn't fit or feel right here.

There is absolutely no one now making any money off the custom driver software floating around. The small mark-ups that are charged don't even cover classic shipping and handling costs, and certainly don't cover the costs/time to even program the boards with normal labor rates. Basically it's a service of matching a hardware board to a customized configured program. Many of us don't have the time, patience, or knowledge to do this our selves.

Edit - Ooops, posted before reading your post RMM - I'm in total agreement here... Stating from my point of view.

http://www.ebay.com/itm/321057008586

They must be the smaller 'half pitch' pieces, the more common 2.54mm pitch (the spacing between leads) is too bulky to fit.

Bend the upper legs so they point straight down, bend the lower set all the way under. Scrape off the green solder mask covering the traces going to the stars where the legs will sit. The spring has to be temporarily removed for clearance.

Fold the switch down flat, then solder the lower legs to the ground ring on the driver.

They're a bit fragile if you leave them like that, so add a little dab of epoxy (JB Weld) on the left & right sides to hold the switch onto the driver. I had some of them break free during assembly before I started using epoxy.

Thanks Dr.Jones!

I also came up with the battery indicator and the short cycle memory that you found the good name for.

Theese functions are governed by the GNU license rules from my publification.

Honestly I don't know exactly what that implies.

The dip switch's kind of kill the e-switch ability. Best if in the UI, but it's never easy with having power ON/OFF being your only UI input.

Momentary FW link added to OP.

This FW has a UI similar to Werner's beta momentary firmware, with a few extra functions such as definable modes, turbo timer, etc.

please don’t take any of what I wrote as an accusation, it really wasn’t meant as such and I apologise if I offended you or JonnyC. I appreciate that no one’s going to get rich off of this and the list of people who’ve contributed to each feature in the code is long and somewhat complicated. I also think that it’s great that you’ve both provided the source code and that’s part of what makes BLF great. I just wanted to make the point that the list of people who’ve contributed to the firmware and the fact that some of them also have a business selling drivers with custom firmware makes it a bit of a minefield to make sure the contributors are all okay with their code being made commercially available (and that it won’t affect their providing free code in the future). As far as I can remember most of the code is out under a Open Commons/ GNU licence for personal or non-commercial use, but it wouldn’t hurt to get the okay from the authors first.

I’m hoping (have been hoping for the last 6mths!) to get a full featured e-switch firmware for Attiny13/25 put together from different bits’n’pieces people have published on here, but I won’t release it publicly until I’ve got the OK from everyone who’s code I’ve used.