STAR Firmware by JonnyC - Source Code and Explanation

You need to add a pull-down resistor to keep the line normally low, then pressing the switch will pull the line high. Any value from 1k to 100k can be used if you disable the pull-up resistor on that input. But using a 1k ohm pull-down will overcome the internal pull-up even if not disabled (at the expense of a fraction of a Milli-amp of extra current draw, this could be an issue with e-switch lights). It is important that the positive side of the switch is the same voltage as the controller IC. If the voltage is higher, the IC may be damaged.

I'm not sure about the code, firmware wigs me out, I'm always off by one...

First try adding the pull-down resistor, then revisit the code, it just may work!

Edit: Put a meter on that line and verify it goes from a zero to a one when the switch is pressed.

Keep us posted.

Where I can find the “optimize for size”-option in Atmel Studio? At the moment my hex file is to large for the Attiny13A :frowning:

On the File menu at the top of your screen click “Project”, click the bottom selection “(project name) Properties”, click “Toolchain” on the left, and look for “Optimization”. Optimization level set to -Os Optimize for size.

Hi all,

Is the clickie version of this firmware default to use on time or off time memory?

The basic clicky STAR uses on-time. STAR_noinit uses fixed offtime via a memory decay trick. Or STAR_offtime uses configurable offtime via an offtime capacitor. Take your pick.

Ok, for the STAR_noinit. You say this uses a "decay trick". Does that mean that I can use that with a nanjg 105C and it will give the board off time memory?

I have a version of wights single sided 17mm FET DD board I would like to use it on. It has an OTC with a value of 1uf. I am guessing the STAR_offtime would be the way to go with that?

Yes & yes. You got it right. :)

Thank you! Flash Size is 0.94 KB (972 Bytes) now. That should work?

yeah should be fine. when you flash you should see exactly the size being written to the attiny. I think it’s 1024 bytes max.

Ok, I seem to be having some trouble with the Star offtime. I assume this is the one I am suppose to be using for the FET driver?

~toykeeper/flashlight-firmware/trunk : contents of JonnyC/STAR/STAR_off_time/STAR_off_time.c at revision 249



Even using the code as is, I am not able to get it to build correctly. At least I dont think I am. It says 0 errors but 5 warnings

Warning 1 unused variable 'prev_mode_idx' [-Wunused-variable] line 366

Then for lines 192,186,183, and 177 I get this warning over and over.

Warning 2 'modes' is static but used in inline function 'check_stars' which is not static [enabled by default]

What should I do about this?

someone who knows more can chime in but I’m pretty sure I had those warnings and it worked fine. flash it and test it :beer:

Yes, that's the correct one.

0 errors means that it compiled "correctly".

Those warnings are not severe, so you can just ignore them.

Or fix them by:
- removing the line 366 (the variable is not used, so it can - and should be - removed safely)
- removing the 'inline'-definition on line 168 (no point of inlining that function, especially as it uses a static variable which kind of works, but violates the C-standard)

Ok, Thanks.


I have a couple more questions. I would like to know how to add more modes to this.

I saw that the high mode was disabled, so I enabled that and added a value, but I would also like to be able to add more.

For example can I have the moonlight mode enabled by default rather than when using star 2?

Also if I wanted to get even more modes than that, like say 6,7,8 in the string, how to do that?

Other frimwares I have seen just had them in a single line like "define modes, 0,2,7,14,39,100" etc, but this one has a define and the name of each one.

Comment lines 175 & 179 away. (or reverse the star logic on line 175 to be able to disable moon with star 2)

First add more mode defines (after line 76) and then add the defined modes to the mode array (after line 187).

I like this idea the best, but I'm not exactly sure what to do there. I don't understand exactly how to express the change.

The way it is now
if
((PINB & (1 << STAR2_PIN)) == 0) {

Can you show me what it should look like?




Also what do I need to do to enable the turbo timer?

if ((PINB & (1 << STAR2_PIN)) > 0) {


Turbo timer is enabled by default in STAR_offtime. Check lines 78, 79 & 80.

BTW: Looks like STAR_offtime (revision shown by your link) doesn't have the ability to re-enable turbo after step down by a half click. Is it really so?

This is part of why I made a modified version of STAR_off_time called starry_offtime. It allows you to set the mode array directly like you described, for both channels (if you have a FET+1), and set the PWM speed for each mode. Also has some extras which can be disabled, such as blinky modes and “medium” presses to go backward instead of just short/long.

It’s sort of halfway between STAR_off_time.c and blf-a6.c. It’s not heavily tested though, so LVP might behave a little weird. It also doesn’t have a way to completely turn off support for the second power channel, so the best you can do is set it to all zeroes.

Anyway, just an idea in case it helps.

_the_,

Thanks, that code edit did give me the use of moonlight without the start locked.


I have been playing with the turbo timer a bit. It looks like it is in fact working. You are correct about not being able to go back to the turbo setting by a half click. When the timer kicks in the light ramps down to "turbo low" so since the light is technically still in turbo mode the next half click takes you to low.


ToyKeeper,

I appreciate that. It is much easier for us noobs to edit that single line with all the modes in it. I will keep the starry in mind.


Here is today's question if you guys can bear with me a bit longer.

Is there something else in the code that effects the level of light output besides the values of each mode?

The reason I ask is because I can set value of moonlight all the way down to 1, and it does give a reasonable low mode with one cell. On a zener modded board with 2 cells its a bit bright still though. I have other firmware I can flash that puts moonlight lower than this.

On a FET board, it’s difficult to get a true moon mode. In general, a value of PWM=1 will produce anything from 1 to 15 lumens depending on the cell and emitter(s) used. You can go lower by using fast PWM=0, but it’s incredibly voltage-sensitive and I’ve seen it put out as much as 4 lumens on a full cell (and down to 0.001 on a low cell, same light). You’ll get somewhat more stable output with phase-correct PWM, but the lowest level on that is 1 and it’ll probably be too bright for moon.

I tried using fast PWM=0 plus dynamic voltage-determined PFM (pulse frequency modulation) to get a better FET-only moon mode, but even that merely reduced the problem rather than really fixing it. You’re welcome to try it if you like though; the code is in ToyKeeper/cypreus/cypreus.c .

This is one of the reasons people use FET+1 drivers instead. The +1 gives you a single 7135 chip which can drive all the modes under about 140 lumens. It should produce a nice moon mode, plus stable current-regulated “low” and “medium” modes. It can also help reduce output sag on modes above that, and make the PWM even less visible.

What Phase Modes are the best for the Nanjq AK47A Fet Mod?

I used the Star_momentary firmware (link )

git says:
18 kHz PWM (“fast”) or 9.4 kHz PWM (“phase-correct”, usually used for custom FET driver versions) definable per output mode

So I have to choose “Phase” for every mode?

#define MODE_PWM 0,PHASE,PHASE,PHASE,PHASE,PHASE

I ask because the default values works well, too.

Thanks!