How To Build a Flashlight With Perfect Modes (picture heavy)

Could somebody explain the memory after off mod?
What to get, what is the schema and how it works, is it already built into some code or does it have to be coded?

#177 nice but not replicable without specs and info.

Welcome
I have a little problem with saving the selected programmable batch mode.
After uploading .hex and .eep everything works I have 3 modes low, medium and high after a few clique have flash and choose the level but I do not want to remember it.
My driver is a standard 105C with ATTINY13V and ATtiny13A and second in both cases there is the same problem.
My fuse settings is -Ulfuse:w:0x79:m -Uhfuse:w:0xed:m, I will add that other programs such as Fixed Modes, Simple, Default work well, but do not want to remember Programmable modes selected.

Regards

Hi Jack, I got your PM.
Making a drawing can take a little while. In the meantime you can read about the
background in post#249
The modes in post #254
The code link in post #264 (code ready compiled for 105C)
(also links in post #467)
Memory tip and link to spreadsheet in post #469

Memory_after_on:
Will save the mode after using it for appr. 2 sec. Then if you want the next mode one tap will not give you that but will start a new 2 sec window where you have to tap again to shift mode.
If you shift mode and shot down in less than 2 sec, then the next time you turn on, the mode will shift to the next again because the memory knows that you already have tapped once.

To overcome this we have Memory_after_off:
An external condenser is charged through a diode when the light is on. When you switch off, the charge on the condenser will bleed through a large resistor so the voltage will be low after appr. 0.5 sec. The condenser voltage is sensed via an input to the MCU just after turn on. If the voltage is sensed to be high (after a short tap), then the mode will shift else the old mode will be kept. After that, the condenser is charged again as long as the light is on.

I use MCU input pin 2 for the sensing. On the NANJG 105C pin 2 is connected to the rightmost star so I mount the condenser there. The 101AK is more difficult, there I must solder a wire to pin 2 and take it through a hole to the other side of the board where i mount the components.

Eventually I may try to make a drawing of the components which are:
1 condenser/capacitor 100 nF keramic (from pin 2 to resistor and diode(anode)
1 resistor SMD0805 10 MOhm (from condenser to ground ring)
1 diode eg. 1N4149 (from condenser to ground ring (kathode)

I’m trying to program a driver, but this stuff is over my head. :frowning:

You just need a taller ladder… :wink:

This might help a little.
http://flashlightwiki.com/AVR_Drivers

Doesn’t look like there is even one tall enough…

Yeah, reading that a few times is what got me thinking I could actually do this. I was hoping I could just code a few easy lines with the modes and memory I wanted, but there is so much more than that. Lol

Dunno I’m building my SOIC clip, the AVR wiki and other pages that take you through the software part needed help. Or just search how to develop for AVR and try the first one you find. I like to pick and see what works first.

Programming the drivers, well, it’s going to be a bit lower level since it’s an embedded system. But doesn’t seem insane to me, but I’m used to programming days and night. Just not embedded systems yet.

Well, I’ve been at this for hours. Maybe someone can code and compile me a driver for trade or something.
I am trying to make a driver for all my current and future Convoy S3s(current = 2.8A XM-L U2 and 1.4A XP-G2 R5 both from IOS)
This is what I am looking for:

Med 30%
High 75%

On the 4th quick click in a row start extended modes with moon

Moon (lowest possible)
Low 10%
Turbo 100%
Beacon
SOS

Preferably with short cycle memory. I really like the idea of it.
I’m not sure about the battery monitoring and what not(if my Convoys are capable stock)
High PWM:quest:
Not sure what else.

Is this even possible?
Thanks In Advance
-Jesse

You could use luxdrv 0.3 (uses short-cycle memory) with the modes Med/High/Med/High/Moon/Low/Turbo/Beacon/SOS. That should behave like you described.

You could use luxdrv 0.3 (uses short-cycle memory) with the modes Med/High/Med/High/Moon/Low/Turbo/Beacon/SOS. That should behave like you described.

Thanks for the reply. I’d like for the lights to stay in Med/High loop unless I do 4 quick clicks. If I can’t manage to get that, I will most definitely use luxdrv, you do great work.

It does, due to the Med / High / Med / High at the beginning, it takes 4 clicks to get to something else. This kind of setup doesn’t work with classic memory, but with no-memory or short-cycle memory.

But if I am using my light and I need High for a couple of seconds, I would like to be able to continue going between Med and High without shutting the light off if it’s possible.

EDIT
Unless I want to use the other modes, then just do 4 quick clicks.

I must be missing something…
I tried reflashing the backed up files
with this command

also this one

But neither work. Any help?
No problem flashing the BLF-VLD files.

Those stock NANJGs are read protected, i.e. if you try to read out the flash, you only get nonsense data.

"continue going between Med and High without shutting the light off": Such a NANJG dosn't measure how long it was off, it decides wether to go into next mode or use memory based on how long it was on the last time ("on-time memory"). That means you don't need to switch the light off for a while to reset it, instead you leave it on for a certain amout of time for memory to kick in. That also means, if the light is on, it needs 2 quick clicks to get into next mode. That is the same for the stock firmware or Tido's or mine (except with no-memory, or with the infamous next-mode-memory).

So what you can easily have is this: MMMM-M-HHHH-H-MMMM-M-HHHH

with -:tap/half-press, or actually being off for an arbitrary time
MMMM-M: running Med for a while, then tap, then memory kicks in
MMMM-M-HHHH: ...then a second quick tap to change the mode, use that for a while
...and so on.

With shortcycle memory and M/H/V/L/T/S/E (V:very low/moon, S:strobe, E:emergency/SOS) you'd get this behaviour, only a third/fourth/... quick tap would let you advance in the mode list.

For example: MMMM-M-HHHH-H-MMMM-M-H-V-LLLL-L-MMMM-MMMM-M-H-V-L-TTTT-T-MMMM-M-HHHH-H-M-H-VVVV-V-M-H-V-L-T-SSSS-S-MMMM



Oh, I didn’t know that. Guess the backup was pointless.

I’m a bit lost(granted it is 7am here and I haven’t slept)

What I’m envisioning is no matter how many times I change modes, 1 soft click will only take me between Med and High all day. But if I do 4 soft clicks(say within 2 seconds) it will give me access to the extended modes.

That would only work with either off-time memory, i.e. some hardware modding to the driver to distinguish short taps from long power-off periods,
or “next-mode-memory”, which means that if you run the light in some mode, switch it off and later on, it will come on in the next mode instead of the same mode, that’s not really how “memory” is supposed to work and most people dislike it: Explain to me please (the use of): next mode memory

Ok, thanks for all the info. Looks like I will go with luxdrv. I will start figuring out configuring/compiling after I get some sleep.

I’ll share my success today, made a connection to the Nanjg 105C, home made connector, DIY FTW :bigsmile:

I’ll share the source, pics, description and my custom PCB board later.

The guide.