STAR Firmware by JonnyC - Source Code and Explanation

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!

I would use PHASE only for the lowest moonlight and highest turbo mode. For all other modes in between use FAST.

As I understand correctly it gives a better, more stable moonlight mode.

As seen here ~toykeeper/flashlight-firmware/trunk : contents of ToyKeeper/blf-a6/blf-a6.c at revision 249

Thank you!

Now I try to flash a brand new attiny 13A SSU

The Attinys on Nanjg works without any problems…but on the new ones I got a verification error. What could be a reason for this?

wiggle/check your cables/wiring

I got errors like that when I had five wires connected on my clip instead of six wires. I could write data but couldn’t read it.

Another thing to check is whether you have any pins grounded (or any stars soldered). That can interfere with flashing.

What do I need to do in order to properly disable the Turbo timer on the Star off time.

I tried commenting out the turbo time out line, and it gave me an error. It said undeclared ( fist use in this function)

I want to keep the turbo mode, just not the timer.

I think you’re supposed to use MODE_HIGH instead of MODE_TURBO, if you want it to not step down.

Or you could use both (5 modes instead of 4) and comment out the parts which implement the step-down logic.

Quick question:

I’m trying use only ADC_CRIT and disable ADC_LOW.

When I comment out ADC_LOW I get the following compile error”

‘ADC_LOW’ undeclared (first use in this function)

Instead of commenting it out would I be better off setting it to 0?