STAR Firmware by JonnyC - Source Code and Explanation

It seems it works as I modify:
#define ADC_LOW 130 (130=56C)
#define ADC_CRIT 140 (140=60C)
Change
if (ADCH < voltage_val) {
if (++lowbatt_cnt > 8)
to
if (ADCH > voltage_val) {
if (—lowbatt_cnt > 8)

In fact, the 140 shut off the light will not happen because the power to LED already has been ramped down when the temperature reach 130.

Better now but still getting this

If you're using MODE_HIGH as your single mode, and not turbo, you also need to comment out #define TURBO_TIMEOUT.

Are you also disabling low voltage monitoring? (if so, why?) When you comment out settings at the top, you have to go hunt for other stuff farther down that refers to the things you disabled. If you re-enable #define VOLTAGE_MON those two errors will go away and it builds correctly.

You saved me once again!
If I have only one mode (turbo), voltage step down will work, since I re-enabled the vol mon?

Cool. Good point, I guess a sudden jump from 55c to 60c would be a huge thermal shock: never going to happen unless you drop it in a volcano. I hadn’t thought of that.

I think for step-down to work some extra stuff has to be done. STAR steps down by lowering the mode index (it changes the mode to a lower one). If you only have one mode defined then the stock STAR ontime or offtime firmware can’t step down. Momentary might be different, I don’t remember.

I think RMM has a post about that subject around here somewhere. I don’t recall how he was working around it.

zeremefico, “MODE_TURBO” (255) mode includes a timed step-down to “MODE_HIGH_W_TURBO” (110). This is independent from the low-voltage-protection step-down. “MODE_HIGH” (255) uses the same brightness but does not include a timed step-down. You do want Turbo?

I had problems with high (set at 255), as only mode, so i chose turbo only.

Johnny - that did it. Thank you very much for your help. It’s certainly appreciated.

I took star off-time memory 1.3 and modified it to add the feature that the longer press (of reverse clicky switch) cycles back the mode. (It’s less than 10 lines of additional code).

Finally I have the perfect driver for me.

Let me start by saying thanks to RMM and to everyone who has contributed to this code.

Let me say next you can put what I know about doing this between these 2 brackets ( ). Not much. With that in mind...

Tom that is awesome.

Am I understanding correctly that this code can be used with a 7135 based driver and ONLY a momentary switch (no dual switch)?

If so how do you wire the switch? Got a picture maybe?

Finally would it be possible to get this code in an elf or hex? I really know nothing a bout writing code, but I do have an avr programmer running AVR studio 4 if that will work.

Thanks again all.

So are you saying you can now use the forward/reverse function with just a reverse clicky? No secondary momentary switch?

JonnyC is the mastermind, I just got the benefit of creating the OP since he was out of town. I've been a beta tester, at best.

  • This FW can be used with 7135 and FET drivers, or as a piggyback to another driver
  • One side of the switch is wired to the switch pin (Pin 3 by default) with the other side to ground
  • There is a "dual switch" version also available, but I'm not sure if Tom E. has added his custom tweaks to this one

In a dual-switch light (momentary side, tail clicky) the tail switch just acts as a lockout, it won't change modes. The driver will behave the same as if you disassemble to swap batteries, meaning the FW will reset back to whatever the default starting mode is after using the tail clicky.

edit: Is the dual-switch specific version able to avoid that, so the tail switch lets it work for signaling/whatever? I haven't looked at that one yet.

Yes. It is basically like the normal momentary version, but with memory.

I guess I need to read through these 500+ replies. So it’s possible to get some of the features of this firmware with just a reverse clicky?

I might have to get myself a programmer… Is there a thread about how to get started programming your own drivers?

http://flashlightwiki.com/AVR_Drivers

There are different firmware versions for different switches. There's clicky-specific (both forward & reverse, which physically break power) versions, and momentary-specific (electronic, which just ground a pin on the controller) versions.

I’ve done clicky-only firmwares and momentary-only firmwares but haven’t done a dual-switch one yet. It shouldn’t be hard though, since it’s just momentary plus memory, and JonnyC has already done most of the work.

In general, there are enough people familiar with STAR that we can probably help with most questions, or make the modifications necessary for anything reasonably small.

One of the mods I made has 14 modes (clicky switch only), including a variety of strobes and signal flashers which don’t have to be cycled through in order to use the main solid modes. Another is a smooth ramping firmware for momentary switches, with click for on/off and shortcuts to min/max. I need to make a ramping strobe UI too, among some other things. But I just do it for fun, and release all the code for anyone to use.

Ok, I understand the switch part of this now. Thanks


I could certainly still use some help getting the file from TomE converted to a hex or elf though.

I did attempt multiple times to downlaod the version of AVR studio that comfy did the tutorial on, but for some reason the download fails each time.

That said I am having a bit of trouble converting the file in studio 4.

After opening new project I took the option that said
AVR GCC and it then asks for a project name to which I wrote MomStar and it let me move forward.
I am then asked to select a debugging platform and the micro. I just took AVR ONE! and Atiny13A

Next ( and this may be where I blew it??) I copied all of the data from tomEs page from the place where it starts like this

//-------------------------------------------------------------------------------------
// Used for 7135 based Phase Corrected PWM:
//-------------------------------------------------------------------------------------
//#define MODES 0,5,15,92,255       // 5=moonlight, 15=6%, 92=36%, 255=100%

All the way to the bottom of the page and pasted it in the blank box in avr.
Next I clicked build an nothing happened.

All I got in the box below was

"Build started 28.10.2014 at 20:43:19"

Anyone wanna take a guess at where I went wrong :slight_smile:
I know there are many places to choose from.

For starters make sure you grab the whole thing. You definitely left out a define:
#define F_CPU 4800000UL

Also if you need to you could try a newer version than the one in comfychair’s tutorial. Download it directly from Atmel.

If it helps, I added that code from Tom E to my collection, compiled it, tried it on my test torch, and uploaded it. You can get a copy (including the .hex file) here:

http://bazaar.launchpad.net/~toykeeper/flashlight-firmware/trunk/files/head:/Tom_E/

I don’t know how to build it on Windows on OSX though. I used avr-gcc in Linux.

Toykeeprer, thats a big help.

I have done this once before using a hex, but I'm still not doing something right.

I took the hex from your link and copied it to notepad. Then saved it as MomStar.hex

I opened the programmer as usual. Went to the program tab, but rather than going to the bottom where my elf files are I used the top box where it says "flash" and input hex. When I tired using the file it just said "Getting isp parameter.. SD=0x06 .. OKUnable to open the specified file"


Any idea what I have done now?