# NEOCA LEON / Code Posted



## PEU (Feb 13, 2005)

*NEOCA LEON / Code Posted!!*

After I finish with the NEOCA BL and the NEOCA WOOD projects I'll start this new one.


*Why NEOCA LEON? *

León Untroib was my grandfather, he was a great artist. This is my humble tribute to him 

Also, Leon is somewhat pronounced like Li-Ion, so you start getting the idea.


*NEOCA LEON is an open source PIC microcontrolled flashlight. *


What does this mean?

it means:

1 - user can use the flashlight with the included firmware

2 - user can remove the PIC microcontroller and load new firmware into it.

3 - since the circuit will be known, and the source code will be available, users with knowledge can modify the way it works.

4 - advanced users may create software and give/sell the pre-programmed chips (example: *NEOCA LEON* emulating an ARC4, LH, HDS, etc) 

5 - I will provide a low cost PIC programmer for all the interested people.


*NEOCA LEON* will use rechargeable batteries, my first intention is to use Pila batteries, but different bodies may also be available in the future.


And the best part, I'll try my best to keep the price as close to $100 as possible, including HA3 process, T-bin lux3 and S020XA reflector.


Comments are welcome.


Thanks for looking


Pablo


----------



## PEU (Feb 13, 2005)

*Re: NEOCA LEON (my next project)*

reserved for future use /ubbthreads/images/graemlins/grin.gif

but in the meantime enjoy this painting





The greatest tango singer: Carlos Gardel


Pablo


----------



## GADGETOMETRY (Feb 13, 2005)

*Re: NEOCA LEON (my next project)*

OK im in.


----------



## mut (Feb 13, 2005)

*Re: NEOCA LEON (my next project)*

I'm in too.

mut


----------



## jeffb (Feb 13, 2005)

*Re: NEOCA LEON (my next project)*

Always wanted to be #3!!


----------



## jaids (Feb 13, 2005)

*Re: NEOCA LEON (my next project)*

At that price range there is a good possibility for me to be in on this.


----------



## skr (Feb 13, 2005)

*Re: NEOCA LEON (my next project)*

Hmm... I don't exactly _need_ another flashlight, but open source firmware is definitely a neat idea. I doubt it'll be written in Java, C#, or C /ubbthreads/images/graemlins/smile.gif (the three languages I'm most familiar with)... still, I'm interested. If you start a pre-order list soon, please consider me to be on it...


----------



## cue003 (Feb 13, 2005)

*Re: NEOCA LEON (my next project)*

I am in also.

Curtis


----------



## Dandrop (Feb 14, 2005)

*Re: NEOCA LEON (my next project)*

i'll be #007 i'm in.


----------



## modamag (Feb 14, 2005)

*Re: NEOCA LEON (my next project)*

Pablo, at the rate of new light release I need to get a third job to support this addiction.

I'll take #32 as usual.


----------



## christrose (Feb 14, 2005)

*Re: NEOCA LEON (my next project)*

Interesting. I'm in too.


----------



## Frenchyled (Feb 14, 2005)

*Re: NEOCA LEON (my next project)*

Pablo, for sure I am in for one or two Leon Neoca /ubbthreads/images/graemlins/smile.gif
And please reserved me #13......I like this number /ubbthreads/images/graemlins/wink.gif


----------



## PeterB (Feb 14, 2005)

*Re: NEOCA LEON (my next project)*

I'm in!


----------



## MrMom (Feb 14, 2005)

*Re: NEOCA LEON (my next project)*

I'll take #45 and #98


----------



## PEU (Feb 14, 2005)

*Re: NEOCA LEON (my next project)*

/ubbthreads/images/graemlins/wow.gif /ubbthreads/images/graemlins/thanks.gif

Now again I need a list maintainer volunteer /ubbthreads/images/graemlins/smile.gif

as I done with my previous projects, you will see in this thread the complete development of this flashlight.

Thanks for the interest.


Pablo


----------



## flashlight (Feb 14, 2005)

*Re: NEOCA LEON (my next project)*

I'll volunteer to keep the list best I can /ubbthreads/images/graemlins/grin.gif

*Edit* So long as it doesn't go over 300! /ubbthreads/images/graemlins/ooo.gif


----------



## flashlight (Feb 14, 2005)

*Re: NEOCA LEON (my next project)*

OK guys *please do not *copy & add your name to the list to save bandwidth. Just post your interest & your name will be added to the list below later. Thanks. /ubbthreads/images/graemlins/smile.gif

1. GADGETOMETRY
2. mut
3. jeffb
4. Bogus1
5. skr
6. cue003
7. Dandrop
8. christrose
9. PeterB
10.kj
11.Catman10
12.Frenchyled
13.Frenchyled
14.Trev1960
[email protected]
16.Vifam
17.dbrad
18.flashlight
19.Dr_Joe 
20.4sevens
21.coby1man
22.pokkuhlag
23.bajaiman
24.GJW
25.luff
26.Wong
27.jaids
28.Amorphous
29.MY
30.Neg2LED
31.gregw
32.modamag
33.LazerBurnz
34.MY
35.gl22man 
36.vontech
37.Doc
38.Christoph
39.anch
40.Cones
41.diggdug13
42.DSpeck
43.yaesumofo
44.TCG
45.MrMom
50.moses
51.cdalyt (+ 4 extenders)
52.cdalyt
53.karlthev
54.rdf
55.Wasabi
56.javafool
57.cy
.
62.simbad
63.
64.
65.
66.LazerBurnz
67.
68.Fusion
69.jcciv
70.dbrad 
.
.
.
77.Wasabi
.
.
88.oldtimer
.
93.ArsMachina
98.MrMom
99.
100.moses


----------



## kj (Feb 14, 2005)

*Re: NEOCA LEON (my next project)*

That's very interesting! I'm in.


----------



## pokkuhlag (Feb 14, 2005)

*Re: NEOCA LEON (my next project)*

Depending on the final details (looks, convertor specs and dimensions) Reserve me a number 22 please. 100$ looks to good of a deal to pass.


----------



## PEU (Feb 14, 2005)

*Re: NEOCA LEON (my next project)*

NEW CPF RULE regarding interest lists

Cyril THANKS /ubbthreads/images/graemlins/happy14.gif, can you keep the list in the same post?


Pablo


----------



## Catman10 (Feb 14, 2005)

*Re: NEOCA LEON (my next project)*

Catman is in for #11!


----------



## coby1man (Feb 14, 2005)

*Re: NEOCA LEON (my next project)*

i'm interested if the price holds for number 21


----------



## Trev1960 (Feb 14, 2005)

*Re: NEOCA LEON (my next project)*

Pending more info I am in /ubbthreads/images/graemlins/smile.gif #69


----------



## Bogus1 (Feb 14, 2005)

*Re: NEOCA LEON (my next project)*

I'll take #15


----------



## GJW (Feb 14, 2005)

*Re: NEOCA LEON (my next project)*

I'll take #24


----------



## 4sevens (Feb 14, 2005)

*Re: NEOCA LEON (my next project)*

I'm in for #20


----------



## greenLED (Feb 14, 2005)

*Re: NEOCA LEON (my next project)*

What a great tribute to your grandfather, Pablo. Can I say #29, depending on details, final pricing, and timeline (gotta save for this puppy)?


----------



## Vifam (Feb 14, 2005)

*Re: NEOCA LEON (my next project)*

I'll take #16. /ubbthreads/images/graemlins/smile.gif


----------



## [email protected] (Feb 14, 2005)

*Re: NEOCA LEON (my next project)*





/ubbthreads/images/graemlins/wink.gif /ubbthreads/images/graemlins/cool.gif


----------



## dbrad (Feb 14, 2005)

*Re: NEOCA LEON (my next project)*

I'm in. #17


----------



## oldtimer (Feb 14, 2005)

*Re: NEOCA LEON (my next project)*

#88 please


----------



## PEU (Feb 14, 2005)

*Re: NEOCA LEON (my next project)*

OMG more work /ubbthreads/images/graemlins/grin.gif

I'm thinking on adding a Hall switch to the board so programming can be done more easily.


Example: instead of pressing and holding and its combinations, you should be able to put a magnet near the body and after rapid button sequence the light puts itself into programming mode.


This allows to do much more stuff without the need of more buttons in the flashlight.


If you have simple ideas, post them, thats the beauty of an open source & programmable flashlight, the sky is the limit (or should I say the internal memory is the limit /ubbthreads/images/graemlins/smile.gif )


PIC candidates are: 12F675 (ADC and 1k memory) and the more advanced 12F683 (ADC, hardware PWM and 2k mem)

Both are pin compatible. My actual problem is finding 12F683 here in Buenos Aires for prototyping /ubbthreads/images/graemlins/jpshakehead.gif (CPFers willing to help may ask microchip for 12f683 samples)

12F675 I already purchased 10 /ubbthreads/images/graemlins/smile.gif

So prototypes will use the available 12f675 and production units will use the more advanced 12f683


Pablo


----------



## Luff (Feb 14, 2005)

*Re: NEOCA LEON (my next project)*

Reserve #25 for me please


----------



## jaids (Feb 14, 2005)

*Re: NEOCA LEON (my next project)*

#27 Please


----------



## jaids (Feb 14, 2005)

*Re: NEOCA LEON (my next project)*

Also will this have a tailcap switch and act like an arc4 maybe or will it have a sde witch like the Lion Heart?


----------



## PEU (Feb 14, 2005)

*Re: NEOCA LEON (my next project)*

Side switch, mainly because is difficult to run a switch from the pic board to the bottom.


Pablo


----------



## jaids (Feb 14, 2005)

*Re: NEOCA LEON (my next project)*

Okay.


----------



## Amorphous (Feb 14, 2005)

*Re: NEOCA LEON (my next project)*

Yeah... I am interested. Please put me down for 28.

Thanks


----------



## Bogus1 (Feb 15, 2005)

*Re: NEOCA LEON (my next project)*

Silly request, but if #4 is open I'd rather be there than #15. Front of the line thing you know /ubbthreads/images/graemlins/rolleye11.gif


----------



## flashlight (Feb 15, 2005)

*Re: NEOCA LEON (my next project)*

[ QUOTE ]
*Bogus1 said:*
Silly request, but if #4 is open I'd rather be there than #15. Front of the line thing you know /ubbthreads/images/graemlins/rolleye11.gif 

[/ QUOTE ]

Done. jaids was the 4th person to express interest so I put him down as #4 but he prefers #27. Of course now #15 is open /ubbthreads/images/graemlins/grin.gif


----------



## DSpeck (Feb 15, 2005)

*Re: NEOCA LEON (my next project)*

I'm in. I'd like #42, please.


----------



## [email protected] (Feb 15, 2005)

*Re: NEOCA LEON (my next project)*

#15 Por Favor. /ubbthreads/images/graemlins/grin.gif


Edited to #15, since it became available, and 13 is taken. /ubbthreads/images/graemlins/frown.gif /ubbthreads/images/graemlins/wink.gif


----------



## cue003 (Feb 15, 2005)

*Re: NEOCA LEON (my next project)*

I REALLY would like to have position #3.

PLEASE, PLEASE, PLEASE!!!

Thanks.

Curtis


----------



## TCG (Feb 15, 2005)

*Re: NEOCA LEON (my next project)*

Put me down for #44 

Thanks


----------



## bajaiman (Feb 15, 2005)

*Re: NEOCA LEON (my next project)*

I'm in #23 please


----------



## flashlight (Feb 15, 2005)

*Re: NEOCA LEON (my next project)*

[ QUOTE ]
*cue003 said:*
I REALLY would like to have position #3.

PLEASE, PLEASE, PLEASE!!!

Thanks.

Curtis 

[/ QUOTE ]

Sorry Curtis but I think jeffb beat you to it unless he doesn't mind switching with you.


----------



## Dr_Joe (Feb 15, 2005)

*Re: NEOCA LEON (my next project)*

Pablo, do you ever sleep ?

Flashlight,(Official keeper of the "new" official CPF bandwith friendly "interest" posting policy)

Count me in (for the next lowest available #) /ubbthreads/images/graemlins/thinking.gif


----------



## gl22man (Feb 15, 2005)

*Re: NEOCA LEON (my next project)*

if it's near $100 i'll take #35


----------



## flashlight (Feb 15, 2005)

*Re: NEOCA LEON (my next project)*

[ QUOTE ]
*Dr_Joe said:*
Pablo, do you ever sleep ?

Flashlight,(Official keeper of the "new" official CPF bandwith friendly "interest" posting policy)

Count me in (for the next lowest available #) /ubbthreads/images/graemlins/thinking.gif 

[/ QUOTE ]

I'm the list/policy-keeper only for this thread /ubbthreads/images/graemlins/tongue.gif 
OK, that'll be #19 right after me /ubbthreads/images/graemlins/grin.gif


----------



## PEU (Feb 16, 2005)

*Re: NEOCA LEON (my next project)*

I know I'm about to open a can of worms /ubbthreads/images/graemlins/smile.gif but since this is an open source project, why not ask about its design?

I'll regret this /ubbthreads/images/graemlins/smile.gif 

What shape are you looking for?

Limitations to keep price at bay are:

parts should be cilindrical so they can be made in a CNC Lathe, without the need for a milling after process. Cilindrical grooves and Knurlings are OK

Yes: Alephs, ARC heads, LH, ORB

NO: Q3, Surefires, VIP KC, etc.

I'll draw my idea as soon as time allows.


Pablo


----------



## simbad (Feb 16, 2005)

*Re: NEOCA LEON (my next project)*

Im in for the #62 /ubbthreads/images/graemlins/tongue.gif , Pablo I really like your grandad´s painting.

Impresionante Carlitos!, cada dia canta mejor.


----------



## Bogus1 (Feb 16, 2005)

*Re: NEOCA LEON (my next project)*

It might be cool to have a "spiral" knurling if that's feasible.

In keeping with your open programming architecture, perhaps you could have an open architecture for parts as well, such as build SF E body compatibility. 

Build the switch into the head so that different size battery tubes can be changed for runtime advantages etc.

Build tubes wide enough to accomodate higher rated Li-ions such as the Pila "A" and unprotected Li-ions as well. Definitely set it up so there is warning before regulated Pila abrupt cut off.

It seems you intend complete utility with this light. Not to mean you won't still make it beautiful, however there are few lights that really have all the practical issues resolved, such ceiling bounce and a scalloped head so light isn't left on sitting head down. Instead of going with a scalloped head, perhaps a ring of pinholes on the end of the head would work.

You might even keep in line with your skinnable idea and built in a recess between the head and body for this as an accessory.

Of course a lanyard attachment and a pocket clip option would be nice.

Thanks, it's probably time for a newbie to shut up.


----------



## Wong (Feb 16, 2005)

*Re: NEOCA LEON (my next project)*

Please add me in the list /ubbthreads/images/graemlins/smile.gif 

/ubbthreads/images/graemlins/thanks.gif


----------



## Wasabi (Feb 16, 2005)

*Re: NEOCA LEON (my next project)*

Hi, I'm in for the #55 and #77.
Thanks, Cyril


----------



## PEU (Feb 17, 2005)

*Re: NEOCA LEON (my next project)*

I was playing almost this whole afternoon with latching Hall Switches. 

Very promising results


Pablo


----------



## jaids (Feb 17, 2005)

*Re: NEOCA LEON (my next project)*

One idea I have is to have the body "webbed" two thirds of the way up the battery tube to lessen weight and provide grip by drilling holes in the body. An o-ring would seal against the battery to provide water resistance.


----------



## PEU (Feb 18, 2005)

*Re: NEOCA LEON (my next project)*

/ubbthreads/images/graemlins/confused.gif

Pablo


----------



## jaids (Feb 18, 2005)

*Re: NEOCA LEON (my next project)*

Instead of knurling drill 4mm holes around the battery tube. This reduces weight and provides grip. Water resistance is lost this way unless an o-ring seals against the battery above the holes(inside the battery tube).


----------



## pokkuhlag (Feb 18, 2005)

*Re: NEOCA LEON (my next project)*

wow, how many holes do you want? The basic idea here is to minimize the amount of labor to the light to cut the labor cost. If you need to drill a certain area full with 4MM holes, it's quite labor expensive. After you've drilled the holes you also need to smoothen the edge of the holes to prevent cutting yourself. I've never hold a tube with 4mm holes before, so I don't know about the grip. If you have, is the grip better on the tube with holes?


----------



## PEU (Feb 18, 2005)

*Re: NEOCA LEON (my next project)*

As pokkuhlag said, the body you're proposing is way to complicate.

keep them coming /ubbthreads/images/graemlins/smile.gif

Pablo


----------



## Leeoniya (Feb 19, 2005)

*Re: NEOCA LEON (my next project)*

I can host the firmware program files and useful programs for these flashlights for all to download. with descriptions of what each one does.

what are the chances of publicly posting (or selling) the final electronic schematics and part numbers or diy electronics kits for those who want to route, solder, and assemble their own bodies and lights?

there have been numerous times when i wished a body design/reflector choice, and heatsinking were different with the same driver guts.

i'd still be in for one once all the beta testing is done, given MrAl/Newbie/dat2zip approve schematics and parts. 

neat idea.
looking forward to seeing those efficiency curves /ubbthreads/images/graemlins/smile.gif
Leon


----------



## Neg2LED (Feb 19, 2005)

*Re: NEOCA LEON (my next project)*

just gimme any random number. i may be in or not. depends.

neg


----------



## InFlux (Feb 19, 2005)

*Re: NEOCA LEON (my next project)*

Me Too- Me Too! # 66 Please!


----------



## flashlight (Feb 21, 2005)

*Re: NEOCA LEON (my next project)*

/ubbthreads/images/graemlins/bumpit.gif


----------



## Luff (Feb 24, 2005)

*Re: NEOCA LEON (my next project)*

Perhaps it's just me, but isn't the NEOCA LEON an exceptionally sensible alternative to the frenzy going on in another thread?

While Pablo's planning on using Pila's right now, what if this project offered R123 and CR123 power choices instead of Pila's ... all of a sudden, this light takes on most of the attributes of the competition at 1/3 the cost.

Either way, I'll vote with my pocketbook and buy this light! Having open source programming on this baby is a huge benefit. (No offense to those paying for another custom light ... this just makes lots more sense to me!)

Don't let this one fade away Pablo!




Keep up the great work.


----------



## PEU (Feb 24, 2005)

*Re: NEOCA LEON (my next project)*

Hey Mark,

is not fading away, quite the opposite my friend /ubbthreads/images/graemlins/smile.gif

While the CNC shop finishes machining the NEOCA BL parts, I'm learning PIC programming like crazy /ubbthreads/images/graemlins/smile.gif 

A fellow CPF'er (thanks 4sevens) sent me some PIC12F683 needed for the project and while I receive them I'm using a 16F628A a bigger one but with almost all the same specs

At the moment I have a working simulation of multi brightness activated by a single button:

click ON
click OFF

after click ON
3 clicks in less than 1 sec
from low to high in steps, when high pause and restart from low
brightness settled on the next click

next click off


and as I said in the first post, with PIC inside the NEOCA LEON the sky is the limit /ubbthreads/images/graemlins/smile.gif

Thanks for letting me update on this project


Pablo


----------



## jaids (Feb 24, 2005)

*Re: NEOCA LEON (my next project)*

What language are you writing this in?


----------



## flashlight (Feb 24, 2005)

*Re: NEOCA LEON (my next project)*

[ QUOTE ]
*jaids said:*
What language are you writing this in? 

[/ QUOTE ]

Argentinian? /ubbthreads/images/graemlins/icon3.gif Spanish? /ubbthreads/images/graemlins/thinking.gif Kidding /ubbthreads/images/graemlins/grin.gif


----------



## jaids (Feb 24, 2005)

*Re: NEOCA LEON (my next project)*

/ubbthreads/images/graemlins/crackup.gif


----------



## PEU (Feb 24, 2005)

*Re: NEOCA LEON (my next project)*

pic basic, I have no patience to learn pure assembler.

but hey, after I release the beast Im sure someone will jump into the bandwagon and post better firmwares /ubbthreads/images/graemlins/smile.gif


And regarding batteries, I have a full set of Pila batteries here and some protected r123 coming also from JSB.

I may add 2 extra tubes to add value to the kit (at a little extra of course /ubbthreads/images/graemlins/grin.gif )

Bodies: pila150, pila168 & ProtR123 

not sure on the default config yet

Pablo


----------



## pokkuhlag (Feb 25, 2005)

*Re: NEOCA LEON (my next project)*

PEU, great to hear about your progress and the battery options that will be available. But what do you think of making one battery tube (in this case the R123) and making battery extenders for the tube instead(for Pila150 and 168). It might save you some material, but not sure which one is more labor intensive. /ubbthreads/images/graemlins/smile.gif Just a suggestion to save me some weight on the mail.


----------



## PEU (Feb 25, 2005)

*Re: NEOCA LEON (my next project)*

actually pok... that is a great idea /ubbthreads/images/graemlins/smile.gif

And also it may be solved in a very elegant way:

Example

heights:
123a is 34.5mm 
Pila 150 is 50mm (diff w/previous 15.5mm)
Pila 168 is 68mm (diff w/previous 18mm)

so If I do a single cell extender of about 18mm you will be able to use 1 or 2 depending on your battery option. A spring can compensate for the differences.

This will go into SolidWorks for sure /ubbthreads/images/graemlins/grin.gif


Pablo


----------



## NetMage (Feb 25, 2005)

*Re: NEOCA LEON (my next project)*

Put me in with PIC programmer.

Are you doing brightness with PWM or do you have circuitry to regulate current?


----------



## PEU (Feb 25, 2005)

*Re: NEOCA LEON (my next project)*

circuit is still undecided, but Im shooting at controlling brightness by injecting the pwm signal into the shutdown pin of a TPS61030 chip, other possibility is to interact directly on the feedback node as a fellow CPFer told me is best (thanks NewBie)


Pablo


----------



## PEU (Feb 28, 2005)

*1st renders*

UPDATE:

1st early renders /ubbthreads/images/graemlins/grin.gif 













Shown with R123, total lenght is 80mm, diameter 26mm

Not drawn, orings, button cover, tail cap spring.

Pila 150 & 168 bodies will be 15 and 30mm longer using one or two extenders /ubbthreads/images/graemlins/smile.gif

enjoy


Pablo


----------



## Cones (Feb 28, 2005)

*Re: 1st renders*

Looks really good. /ubbthreads/images/graemlins/happy14.gif /ubbthreads/images/graemlins/happy14.gif

Compact. No awkward bulges.
Will the button be rubber?
Knurling?

I like to see someone do a sliding ring magnetic switch as in a dive light. That would be different.

Please say you will do brass as well /ubbthreads/images/graemlins/smile.gif

Oh. please put me down for #40 thanks. /ubbthreads/images/graemlins/grin.gif

Are you sure about that price! It's good value at double that.
But I didn't tell you that /ubbthreads/images/graemlins/smile.gif

Mark


----------



## Geheim (Feb 28, 2005)

*Re: 1st renders*

Add me to the list of a possible buyer at the next available number.

Thanks,
Chad


----------



## Dandrop (Mar 1, 2005)

*Re: 1st renders*

Lanyard hole please!


----------



## greenLED (Mar 1, 2005)

*Re: 1st renders*

flashlight, I just checked the list and it seems like you assigned 29 to Neg2LED after I had expressed my interest in it. Would it be possible to correct that? thank you.


----------



## Trev1960 (Mar 1, 2005)

*Re: 1st renders*

will it have protection for unprotected r123's?


----------



## flashlight (Mar 1, 2005)

*Re: 1st renders*

[ QUOTE ]
*greenLED said:*
flashlight, I just checked the list and it seems like you assigned 29 to Neg2LED after I had expressed my interest in it. Would it be possible to correct that? thank you. 

[/ QUOTE ]

My bad. Done. /ubbthreads/images/graemlins/blush.gif


----------



## PEU (Mar 1, 2005)

*Re: 1st renders*

cones: yes, button will be covered with a rubber pad, much like other lights. Brass as with NEOCA BL may be an option if enough interest. And yes, I'll try to keep the number as close to $100 as posible for the basic config. Why? because at this moment I think I can if the run is high enough.

dandrop: some kind of attachment will be available, still undecided.

trev1960: if I find a simple way to do it with a PIC and a Regulator yes, suggestions are accepted /ubbthreads/images/graemlins/smile.gif

ALL: no need to fight for numbers, I dont have in mind serializing

Regarding knurlings, I'm trying to be original, so instead of them I'll probably use beadblasted strips or fully beadblasted body... to early to tell /ubbthreads/images/graemlins/smile.gif


Thanks


Pablo


----------



## [email protected] (Mar 1, 2005)

*Re: 1st renders*

YUM! beadblasted HA-III.... /ubbthreads/images/graemlins/drool.gif /ubbthreads/images/graemlins/grin.gif


----------



## InFlux (Mar 1, 2005)

*Re: 1st renders*

Please put me down for a second unit #33. /ubbthreads/images/graemlins/smile.gif


----------



## MY (Mar 1, 2005)

*Re: 1st renders*

Please put me on the list.

PEU, I probably will be down your way in May so could pick it up in person from you!

Regards.


----------



## PEU (Mar 1, 2005)

*Re: 1st renders*

MAY may be too soon, but hey It took me only 2 months from paper to metal in the NEOCA BL, so maybe its a reality by may.

You're coming to Buenos Aires? 

GREAT you're invited to my office to see the NEOCA DEVELOPMENT CENTER /ubbthreads/images/graemlins/grin.gif and may be we can have lunch or something like that


Pablo


----------



## PEU (Mar 1, 2005)

*Re: 1st renders*

MAY may be too soon, but hey It took me only 2 months from paper to metal in the NEOCA BL, so maybe its a reality by may.

You're coming to Buenos Aires? 

GREAT you're invited to my office to see the NEOCA DEVELOPMENT CENTER /ubbthreads/images/graemlins/grin.gif and may be we can have lunch or something like that


Pablo


----------



## MY (Mar 1, 2005)

*Re: 1st renders*

Peu.

I am headed to Patagonia but always lay over in BA for a few days. Don't know what my schedule is until shortly before I leave. It would be great to see how a classy upscale, cost be damned, state of the art, flashlight development center looks like! I assume that you have an indoor testing center to measure actual light throw! How large is your R&D staff?

I know a great place for BBQ in downtown BA. The mate will be on me.

Regards.


----------



## PEU (Mar 1, 2005)

*Re: 1st renders*

I have this team for the whole NEOCA Flashlights family:

CAD Design: One Person
PIC Programming: One Person
Prototyping: One Person
Beta Testing: One Person
Quality Assurance: One Person
Assembly Line: One Person
Management: One Person
Marketing: One Person
Contractor Control: One Person
Sales: One Person
PR: One person

Total in team: One person...

/ubbthreads/images/graemlins/grin.gif

Pablo


----------



## MY (Mar 1, 2005)

*Re: 1st renders*

PEU, Ok enough of this flashlight stuff - you have already impressed me with your extensive team. On to something more serious, are you a Boca Junior or River Plate person?

Regards.


----------



## PEU (Mar 1, 2005)

*Re: 1st renders*

let me answer you with another painting from my grandfather:







Im "Hincha de Independiente" (the red ones)


Pablo


----------



## jaids (Mar 1, 2005)

*Re: 1st renders*

If near $100 I need to be put down for another one.
The renderings look great.

Are you saying that they will not be serialized?
Will the extender tubes be included?
Thanks,
Jay


----------



## dbrad (Mar 4, 2005)

*Re: 1st renders*

Pablo-
Put me down for a second one; number 70, please.
Thanks!
Are you considering anodizing colors and bead blasting?
-David


----------



## pokkuhlag (Mar 4, 2005)

*Re: 1st renders*

dbrad, why do you want to be at the underside of the line? The number represents the amount of interest people, there is not going to be any serializing(see Peu's post a few pages back). Might as wel pick the nearest number to get Leon faster. /ubbthreads/images/graemlins/wink.gif Just a tip.


----------



## Christoph (Mar 4, 2005)

*Re: 1st renders*

#38 for me
/ubbthreads/images/graemlins/smile.gif


----------



## flashlight (Mar 4, 2005)

*Re: 1st renders*

[ QUOTE ]
*pokkuhlag said:*
dbrad, why do you want to be at the underside of the line? The number represents the amount of interest people, there is not going to be any serializing(see Peu's post a few pages back). Might as wel pick the nearest number to get Leon faster. /ubbthreads/images/graemlins/wink.gif Just a tip. 

[/ QUOTE ]

Hmm, in that case, since I'm the keeper of the list, maybe I should bump myself up to the top then /ubbthreads/images/graemlins/naughty.gif


----------



## pokkuhlag (Mar 4, 2005)

*Re: 1st renders*

[ QUOTE ]
*flashlight said:*

Hmm, in that case, since I'm the keeper of the list, maybe I should bump myself up to the top then /ubbthreads/images/graemlins/naughty.gif 

[/ QUOTE ]

I don't mind you bumping yourself up, you are already above me. So my spot on the list won't get any lower by your bumping. /ubbthreads/images/graemlins/wink.gif


----------



## PEU (Mar 4, 2005)

*More renders*

UPDATE:

More renders, this time more detailed and they include the extenders:

NEOCA LEON with R123





NEOCA LEON with Pila 150 & one extender





NEOCA LEON with Pila 168 & two extenders





Total lenght of the 168 version is around 115mm /ubbthreads/images/graemlins/smile.gif

Hope you all like them.

Pablo


----------



## PEU (Mar 4, 2005)

*Re: More renders*

pokkuhlag: I corrected the inner diameter of the extenders. Thanks for pointing me the error.












Pablo


----------



## bwaites (Mar 4, 2005)

*Re: 1st renders*

MY, 

How about picking up some alfajores and Mirinda Manzana while you're there?

/ubbthreads/images/graemlins/smile.gif

Bill


----------



## [email protected] (Mar 4, 2005)

*Re: 1st renders*





/ubbthreads/images/graemlins/cool.gif /ubbthreads/images/graemlins/thumbsup.gif


----------



## PEU (Mar 6, 2005)

*1st operating firmware video*

This is the first video of the firmware in action: 

Quicktime Video (1.2mb) 
Windows Media Video (2mb) 

what you see:

Normal operation
click on 
click off

again
click on 
click off

click on
long click enters brightness adjust (test red led goes off)


led starts to go from high to low and then back to high with pauses at the top and the bottom

next click sets the level

next click turns off

click on
led turns on on the previous level

and I repeat the level adjust sequence.

Hope you all like it


Pablo


----------



## flashlight (Mar 6, 2005)

*Re: 1st operating firmware video*

Cool!


----------



## PEU (Mar 7, 2005)

*Re: 1st operating firmware video*

Video version 2:

NEOCA LEON firmware in action video 2 


Pablo


----------



## flashlight (Mar 7, 2005)

*Re: 1st operating firmware video*

[ QUOTE ]
*PEU said:*
Video version 2:

NEOCA LEON firmware in action video 2 


Pablo 

[/ QUOTE ]

hehe, OK, or is that a 'Nil' sign /ubbthreads/images/graemlins/grin.gif Btw, what's the red LED for? Is it like a 'stop' light? /ubbthreads/images/graemlins/grin.gif Will there be a red LED on the switch?


----------



## PEU (Mar 7, 2005)

*Re: 1st operating firmware video*

OK!!!

I use that led for debugging, to know if the pic is in the main loop or in the brightness adjustment loop.

The PIC at this moment have 2 of 5 outputs used (3 if you count the red led) so many things can be added to the software to use them.

One of the unused legs will probably be used as a feedback from the regulator chip for low battery warning, so unprotected li-ion cells can also be used.


Pablo


----------



## flashlight (Mar 7, 2005)

*Re: 1st operating firmware video*

Thanks Pablo. /ubbthreads/images/graemlins/grin.gif Keep up the good work! /ubbthreads/images/graemlins/thumbsup.gif


----------



## Frenchyled (Mar 7, 2005)

*Re: 1st operating firmware video*

Hi Pablo !!

The software seems in good way /ubbthreads/images/graemlins/wink.gif Thanks to letting us know about your progress /ubbthreads/images/graemlins/smile.gif..But, what about the light itself ? /ubbthreads/images/graemlins/grin.gif /ubbthreads/images/graemlins/cool.gif


----------



## PEU (Mar 7, 2005)

*Re: 1st operating firmware video*

Dont forget this previous post Pascal:

I have this team for the whole NEOCA Flashlights family: 

CAD Design: One Person 
PIC Programming: One Person 
Prototyping: One Person 
Beta Testing: One Person 
Quality Assurance: One Person 
Assembly Line: One Person 
Management: One Person 
Marketing: One Person 
Contractor Control: One Person 
Sales: One Person 
PR: One person 

Total in team: One person...

Sometimes it seems that I multiplex myself into many, but these days its more complicated /ubbthreads/images/graemlins/grin.gif

And remember I still have to work with the neoca Wood /ubbthreads/images/graemlins/smile.gif

So, after all these excuses, I will try to turn a body one of these weeks /ubbthreads/images/graemlins/grin.gif


Pablo


----------



## Frenchyled (Mar 7, 2005)

*Re: 1st operating firmware video*

I was not serious Pablo /ubbthreads/images/graemlins/smile.gif
I know you have lot of works, and for only one person, it's very nice /ubbthreads/images/graemlins/smile.gif

If you want a beta tester, you could count on me /ubbthreads/images/graemlins/wink.gif I am a lot "beta" and maybe tester /ubbthreads/images/graemlins/grin.gif
Take your time and finish your current flashlights before answering to my no serious questions /ubbthreads/images/graemlins/wink.gif


----------



## Bogus1 (Mar 7, 2005)

*Re: 1st operating firmware video*

Will you include flashing/strobing as a feature?

Thanks


----------



## PEU (Mar 7, 2005)

*Re: 1st operating firmware video*

Im trying to find a simple way to do it. I still didn't found it /ubbthreads/images/graemlins/smile.gif


Pablo


----------



## Doc (Mar 7, 2005)

*Re: 1st operating firmware video*

Pablo can you add me to the list for one. Doc


----------



## PEU (Mar 14, 2005)

*Re: little update*

Short Update: I'm fine tuning the different levels, and making some adjustments in the orings.

Also I drawed a second version of the LEON but without the switch, it uses a clever way to select the desired function (strobo-SOS) or light level. It's twist action and shorter in size /ubbthreads/images/graemlins/grin.gif

More later /ubbthreads/images/graemlins/evilgrin07.gif


Pablo


----------



## tinkerfy (Mar 15, 2005)

*Re: little update*

Hi Pablo..
very impressive mod. I like the multiple brightness adjusting mode. I have a similar mod to my Vortex KC1 Lookalike by djpark where he also included a PIC, and what he calls a POP circuit. While his mod is quite similar with yours, his was without a button but only a twistie.. 

my light the "First-A" named as our local CPFers in Malaysia, has the following modes:

1.Twist On (last used mode) High
Twist Off in under 1 sec
2.Twist On Low (leave on for more than 1 sec to set the last used mode)
Twist Off
3.Twist On Low
Twist Off
4.Twist On High
Twist Off
5.Twist on Ultra-low mode "survival mode"?
Twist Off
6.Twist On - Strobe mode
Twist Off
7.Twist On - SOS mode
Twist Off

My "first-A" was his prototype mod so these were all the features available. Based on your multi brightness level adjusting mode, I think its absolutely "necessary" for my mod as well.

djpark has also made a video of the "First-A" in action.
First-A Mod 

really wish I've got a pair of steady hands and modding skills like you guys.. /ubbthreads/images/graemlins/icon23.gif


----------



## PEU (Mar 15, 2005)

*TWIST ACTION*

Well... I finished the Twist Action LEON firmware /ubbthreads/images/graemlins/grin.gif

Here is how it works:

intead of the multi on/off designed by DJpark and suggested by tinkerfy, I had a different approach to the settings without an external button

Since I have a very powerful PIC with Hardware PWM and Analog to Digital converters, I used the later to transform a simple potentiometer into a selector key:







This preset will be accesible via a hole in the PCB so is easily accesible by simply opening the flashlight.


The prototype I have working uses the pic for control and a texas tps72501 LDO regulator for the led. This regulator is capable of handling 1A so its ideal for lux3 apps.

Here are some renders of the twist action LEON (maybe its renamed later)















And good thing about this board, you can replace the one in a Q3 for example, put a R123 and in a second you have a multilevel flashlight /ubbthreads/images/graemlins/smile.gif


Video later /ubbthreads/images/graemlins/evilgrin07.gif 


Pablo


----------



## Cones (Mar 15, 2005)

*Re: TWIST ACTION*

Would be very cool if you could change the setting by twisting a part of the light externally!

Be a headache to engineer though.

It keeps looking better and better.

Thanks

Mark


----------



## Bogus1 (Mar 15, 2005)

*Re: TWIST ACTION*

awesome, strobe! Important safety feature, imho


----------



## tinkerfy (Mar 15, 2005)

*Re: TWIST ACTION*

so any idea when the NEOCA LEON will be available?
I need to arrange for some major savings if i wanna get one of these little beauties..
has the price been confirmed to be under $100 yet?


----------



## greenLED (Mar 15, 2005)

*Re: TWIST ACTION*

flashlight, please remove me from the list; I have some bills to catch up with. Thank you and buena suerte, Pablo!


----------



## moses (Mar 16, 2005)

*Re: TWIST ACTION*

If you hit your price point and design spec (T ranked , May delivery etc), put me down for numbers 50 and 100. 

THANKS for doing something relatively 'affordable' given the context of current custom mods. Been wanting/needing some with variable power. 

I'm not up on the current 'state of the art' reflectors/collimators, but if this can possibly adapt somehow to collimators, that would be great. I'd like to use NX-01s. 

Anyway, I'm good for two. 

Blessings,
Moses


----------



## PEU (Mar 16, 2005)

*FIRST PCB*

Update:

Here is a picture of the 1st PCB of the neoca LEON in its twist flavor: 







on the flip side is a TPS72501 LDO regulator.

Nice thing about this 1st PCB is that if I replace the pot (blue thingy) with a button and change the firmware, it becomes the pushbutton LEON.

And thats not angry blue, is a Royal Blue Lux3 at the lowest setting /ubbthreads/images/graemlins/smile.gif

you see: *one PCB = dual function = twice the value = half the price /ubbthreads/images/graemlins/grin.gif*

more to come... /ubbthreads/images/graemlins/evilgrin07.gif


Pablo


----------



## PEU (Mar 17, 2005)

*Re: FIRST PCB*

Twist Action PCB in action video: Leon Twisty Quicktime Video 2.5Mb (Just in case: Quicktime viewer 12mb)

I tried compressing it to Windows Media but it lost the details of the blink/SOS morse code

What you see:

This firmware has only 4 levels+strobo+SOS, every time I short the bateries is like turning the light off and on again.

The circuit is running off a 14500 Li-Ion (thanks 4sevens /ubbthreads/images/graemlins/smile.gif )

enjoy


Pablo


----------



## PEU (Mar 17, 2005)

*Re: FIRST PCB*

To avoid confusions:

Leon and Leon twist share the same board design.

if I want the button activated version I use a button
if I want the twist activated version I use a potentiometer

Then I reload the corresponding firmware and Voila!!!

is it clear? I can explain more detailed if needed.


Pablo


----------



## Bogus1 (Mar 19, 2005)

*Re: FIRST PCB*

How about low battery indication or step down to alert to dropping voltage? For rechargeables, protected or not, this would be very nice. In one case you ruin your battery and in the other you're in the dark.

Thanks


----------



## Geheim (Mar 19, 2005)

*Re: NEOCA LEON (my next project)*

I have to bow out. Please remove me from the 31st position. I look forward to Peu's NEOCA BL light.

Chad


----------



## jaids (Mar 20, 2005)

*Re: NEOCA LEON (my next project)*

Please remove me from 36(I still want #27 though)


----------



## Luff (Mar 23, 2005)

*Re: NEOCA LEON (my next project)*

Unless the light has external control for dimming, etc., I'm not much interested as that's a level of flexibility I'll require.

If the design is going to retain the exterior button, I'm in. If you're going to use the internal pot, I'm out.

If you're going to make both ... I'm in awe.


----------



## JonSidneyB (Mar 23, 2005)

*Re: NEOCA LEON (my next project)*

/ubbthreads/images/graemlins/happy14.gif


----------



## jcciv (Mar 25, 2005)

*Re: NEOCA LEON (my next project)*

I'm in for 69


----------



## PEU (Mar 25, 2005)

*Re: NEOCA LEON (my next project)*

I'll take more care of this project as soon I finish with the neoca BL deliveries /ubbthreads/images/graemlins/smile.gif promise

sorry and Thanks!!!

I'm a one man operation /ubbthreads/images/graemlins/smile.gif

Pablo


----------



## PEU (Mar 25, 2005)

*Re: NEOCA LEON (my next project)*

double post sorry


----------



## pokkuhlag (Mar 28, 2005)

*Re: NEOCA LEON (my next project)*

/ubbthreads/images/graemlins/smile.gifI'm liking the open source idea more and more. What's a better firmware than your own personalized firmware. I think I will try to program my own firmware with personalized lock out mode, depending on the price the low cost programmer. Any cost estimation on that?


----------



## cdalyt (Mar 28, 2005)

*Re: NEOCA LEON (my next project)*

Pablo, your design and engineering is fantastic along with keeping us posted! 
Cyril thanks for keeping the list edited.

I would like to get two Neoca Leons and four extenders. 
If they get numbered, please make them 11 if not already requested and 29, otherwise 29 and 92.
Do not know if both button and twist switches will be avaliable, probably one of each if so.
As for finish, like your Nat ano w/lt BB, Black ano and Bare AL.

Thanks,
Mark /ubbthreads/images/graemlins/thumbsup.gif


----------



## vontech (Apr 7, 2005)

*Re: NEOCA LEON (my next project)*

I'll take #36!


----------



## dbrad (Apr 7, 2005)

*Re: NEOCA LEON (my next project)*

Pablo, the twist action rocks. I love that it takes up less room than the button, and is easier to operate. I had dreamed that someday we'd see this in a custom light, and I'm willing to learn whatever is necessary to do the programming myself.


----------



## ArsMachina (Apr 20, 2005)

*Re: NEOCA LEON (my next project)*

Hi,

I'll take #93! 

Thanks Jochen


----------



## MY (Apr 20, 2005)

*Re: NEOCA LEON (my next project)*

If there is a list somewhere, please add me to it with the lowest number that is available.

Regards


----------



## gregw (Apr 20, 2005)

*Re: NEOCA LEON (my next project)*

Put my name on the list for lowest available number.. /ubbthreads/images/graemlins/smile.gif I hope this will end up to be adjustable externally instead of having to open it up to make the brightness selection.


----------



## PEU (Apr 20, 2005)

*Re: NEOCA LEON (my next project)*

it will have a button Greg, I'll make it as close to the prototype posted as possible. As soon I finish with NEOCA BL shipments and taking a 2 week vacation, NEOCA LEON and WOOD SKINNABLE will be in my top priorities. Promise!

I'm doing some advances in the background, but I dont like vaporware, so as with NEOCA BL I will show progresses as they happen...!


Pablo


----------



## Fusion (Apr 23, 2005)

*Re: NEOCA LEON (my next project)*

Please add me to the list for #68.

Thanks,
Kham


----------



## anch (Apr 24, 2005)

*Re: NEOCA LEON (my next project)*

Please add me to the list for one.
Thanks

Anch


----------



## diggdug13 (May 18, 2005)

*Re: NEOCA LEON (my next project)*

Please add me to the list, I don't care about the number.

doug


----------



## karlthev (May 19, 2005)

*Re: NEOCA LEON (my next project)*

How I could have missed this one for so long I don't know but, put me on the list, number 53 if possible, if not number 54 and, if not that, whatever number is fine.


----------



## PEU (May 19, 2005)

*Re: NEOCA LEON (my next project)*

UPDATE:

I retought the idea of releasing the source code and schematic when the unit are ready, I will polish some details and try to release them in less than 15 days, so if someone is willing to help in the project and improve the design this can be put in the shipping units and everyone wins.

Thanks


Pablo


----------



## yaesumofo (Jun 12, 2005)

*Re: NEOCA LEON (my next project)*

I want one and don't care about the number. The idea of programming this with my computer to operate the way I want it too is exactly what I am looking for in a EDC light.
Yaesumofo


----------



## javafool (Jun 12, 2005)

*Re: NEOCA LEON (my next project)*

Please add me to the list for one unit. I wasn't following this thread but these are looking better and better.
Terry

I really like the price too. Sounds like a whole lot for the $$.


----------



## rdf (Jun 12, 2005)

*Re: NEOCA LEON (my next project)*

Please put me down for #54 if still available, otherwise next lowest number. Looks mahvelous. Waiting to see how the twist dimming feature is implemented ...


----------



## cy (Jun 12, 2005)

*Re: NEOCA LEON (my next project)*

don't know how I missed this thread. I'm in for one /ubbthreads/images/graemlins/grin.gif


----------



## wquiles (Jun 12, 2005)

*Re: NEOCA LEON (my next project)*

Pablo,

Te envie un PM.

Gracias,

Will


----------



## Trev1960 (Jun 12, 2005)

*Re: NEOCA LEON (my next project)*

Any updates?


----------



## PEU (Jun 12, 2005)

*Code Posted*

I will polish this post in the following days, the code is licenced under the Creative Commons Licence , the link is in the code header.

There is one catch, that won't appear in the final production unit, and I did this on purpose, just to test the whole open source idea, the catch is: this source code does not put the flashlight to sleep when powered off, what does it mean? instead of consuming microAmperes during its off state, it runs at full speed even when powered off.

as promised here is the source code:


```
'****************************************************************
'*  Name    : Linterna Multinivel                               *
'*  Author  : Pablo Untroib                                     *
'*  Notice  : Copyright (c) 2005 Pablo Untroib                  *
'*          : All Rights Reserved                               *
'*          : [url]http://creativecommons.org/licenses/by-nc-sa/2.5/[/url] *
'*  Date    : 26/02/2005                                        *
'*  Version : 2.0                                               *
'*  Notes   : Compiler PicBasicPro                              *
'*          :                                                   *
'****************************************************************


@ device INTRC_OSC_NOCLKOUT     
DEFINE OSC 4                    'Microcontroller is a PIC12F683
DEFINE PULSIN_MAX 65535

ansel=0                         ' no usar el comparador/do not use comparator
trisio=%00100000		        ' setear el gpio a salidas menos el 5/
                                ' set all to output but 5
vrcon=0


pulso       VAR WORD            ' ancho del pulso maximo 65535/
                                ' maximum pulse width 65535

TDP         VAR BYTE            ' tipo de pulso / pulse type

Conta       VAR BYTE            ' contador reusable para loops/
                                ' reusable loop counter
Frecu       VAR BYTE            ' frecuencia del PWM / PWM frequency
pwmstat     VAR BYTE            ' nivel actual de PWM / actual PWM level


prendido    VAR BIT             ' flag prendido/apagado / on-off flag
loopfl      VAR BIT             ' flag para el loop de seteo de PWM/
                                ' flag for the PWM loop
tipopulso	VAR BIT	        ' tipo de deteccion de pulso/
                                ' pulse detection type

boton       VAR GPIO.5          ' boton linterna / flashlight button
LED         VAR GPIO.2          ' salida led PWM / LED output
testigo     VAR GPIO.1	' led para ver por donde anda el programa/ 
                        'testing purpose, to know where the program is

tope	   CON 7		' setea cuantos niveles PWM hay/ 
                        'sets the amount of brightness levels

pwmduty     VAR BYTE[8]         ' tabla de niveles PWM / PMW levels table

pwmduty[0]= 1 '8
pwmduty[1]= 8 '16
pwmduty[2]= 16 '32
pwmduty[3]= 32 '64
pwmduty[4]= 64 '127
pwmduty[5]= 127 '150
pwmduty[6]= 192
pwmduty[7]= 255			' 255 es 100% del ciclo/ 255 is 100% duty cicle
							
prendido=0			' arranca apagado / starts off
frecu=250           ' frecuencia en Hertz / Frequency in hertz
testigo=0			' para debugging sacar en final /
                    'for debugging remove for production

tipopulso=1			' determina el flanco de deteccion del pulso/ 
                    ' sets pulse detection type

pwmstat=tope        ' arranca al maximo brillo/starts at maximum brightness

Pause 200			' inicio loops de inicializacion / 
                    ' remove for production, start checking sequence
For conta=0 TO 255
HPwm 1,conta,frecu
Next conta
Pause 500
For conta=255 TO 0 STEP -1
HPwm 1,conta,frecu
Next conta
For conta=0 TO 255
HPwm 1,conta,frecu
Next conta
Pause 500
For conta=255 TO 0 STEP -1
HPwm 1,conta,frecu
Next conta			' fin loops inicializacion / end testing loop



LOOP:

    tdp=2
    PulsIn boton, tipopulso, pulso
    Pause 10
 	
    IF pulso >0 Then
    
    
        IF pulso > 20000 Then 
            TDP=3
        Else
            tdp=1
        EndIF
            
    EndIF
    
    
    Select Case  tdp
    
        Case 1
                IF prendido =1 Then
                    prendido =0
                    HPwm 1,0,frecu
                    testigo=0
                Else 
                    prendido=1
                    HPwm 1,pwmduty[pwmstat],frecu
                    testigo=1
                EndIF   
                
        Case 3  

                GoSub spwm

    End Select
    
'    tdp=2
        

GoTo loop

SPWM:

pulso=0
boton=0
conta=pwmstat
pulso=0   
loopfl=0
While pulso=0

        
For conta=pwmstat TO tope
        HPwm 1,pwmduty[conta],frecu

        PulsIn boton, tipopulso, pulso
		
        IF pulso>0 Then 
            pwmstat=conta 
             conta=7
            loopfl=1
        EndIF
Next conta



IF loopfl=0  Then
        pwmstat=0
        For conta=tope TO 0 STEP -1
            HPwm 1,pwmduty[conta],frecu

	        PulsIn boton, tipopulso, pulso
	
            IF pulso>0 Then 
                pwmstat=conta 
                conta=0
            EndIF
	    Next conta
    
EndIF

        

Wend

testigo=1

Return
```

comments on the code itself will be added in the following days.

Thanks


Pablo


----------



## wquiles (Jun 12, 2005)

*Re: Code Posted*

Outstanding /ubbthreads/images/graemlins/happy14.gif

Thanks for sharing this /ubbthreads/images/graemlins/bowdown.gif

Will


----------



## pokkuhlag (Jun 15, 2005)

*First User develloped firmware for Leon: POSv1*

After seeing this thread with a open source firmware, I was finally able to do something I always wanted. Making my own firmware. Even though Leon is not yet available, I was able to simulate the circuit thanks to PEU's help and guidance. It took about 2 hours to make it work and understand the source. Then it took another 12 or more for my own firmware to work. I tested PEU's source and found out it's using scrolling to change brightness. I know there are plenty of other lights using click sequence to change brightness, so I wanted to see if it's possible for this source to make such a User Interface. And after 3 different version, I finally made POSv1. POS stands for a few possible things like Peu's Open Source or Pokkuhlag Open Source or even Piece Of S.... /ubbthreads/images/graemlins/wink.gif First lets start off with the manual:

So how does this POSv1 UI works? 

First of all we define clicks and presses and usual /ubbthreads/images/graemlins/tongue.gif
clicks are not time limited, BUT the time between each click is exactly 0.2 seconds, go to fast, your second click won't get recognize, go to slow, then the click is not recognized either. If you want to end a click, don't click for 0.3 second, same goes for press.
presses on the other hand is nicer. it's usually the last action after a series of clicks. this has to be longer than 0.3 seconds.
There is also a momentary press, this is longer than 0.7 secs, and there is no click sequence in front of it /ubbthreads/images/graemlins/wink.gif 


There are four brightness lvl's:
Low mode
Medium mode
High mode
Burst mode

These can only be setted, when the flashlight is on. The following commands:

Low mode: click, click, click
Medium mode: click, press
High mode: click, click
Burst mode: click, click, press

After that is done, the light will use this setting no matter if it's on or momentary on or momentary off.

So lets talk about the momentary:

There are two kind of people in CPF, one that likes momentary off, the other likes momentary on.

Since I don't like to discriminate minority there is BOTH momentary. All momentary will again use the saved light setting.

Momentary off: Light must be on, press longer than 0.7 secs, it then goes into momentary off, release to regain light

Momentary on: light must be off, press longer than 0.7 secs, it then goes into momentary on with setted brightness, release to regain darkness(of the light).

Almost forgot, for the flashlight noobs:

If flashlight is on, click once, to turn it off
If flashlight is off, click once, to turn it on

Now Lets see this thing working in real life, here is PEU with the real life circuit and with Coldplay as background music. The following sequence has been shown:

1) show on off for a couple of times
2) show momentary on
3) show mom off
4) show low level, show it remains in it after a on off
5) show med (same)
6) show high (same)
7) show burst (same)


*THE MOVIE!!* 

Link to POSv1 movie 

Well I hope you enjoyed it and now for the interested ones, here is the source with comments that start with a ':

'****************************************************************
'* Name : UNTITLED.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2005 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 6/14/2005 *
'* Version : 1.0 *
'* Notes : *
'* : *
'****************************************************************
@ device INTRC_OSC_NOCLKOUT 
DEFINE OSC 4
DEFINE PULSIN_MAX 65535
'ansel=0 
' no usar el comparador/do not use comparator

trisb=%00100000  
' setear el gpio a salidas menos el 5/set all to output but 5

vrcon=0
pulso VAR WORD 
' ancho del pulso maximo 65535/maximum pulse width 65535

time var bit
time2 Var Bit
geweest var bit
A Var Byte
An Var Byte
At Var Byte
B Var Byte
Bn Var Byte
Bt Var Byte
C Var Byte
Cn Var Byte
Ct Var Byte
Constant Var Byte
TDP VAR BYTE 
' tipo de pulso / pulse type

Conta VAR BYTE 
' contador reusable para loops/reusable loop counter

Frecu VAR BYTE 
' frecuencia del PWM / PWM frequency

pwmstat VAR BYTE 
' nivel actual de PWM / actual PWM level

prendido VAR BIT 
' flag prendido/apagado / on-off flag

loopfl VAR BIT 
' flag para el loop de seteo de PWM / flag for the PWM loop

tipopulso VAR BIT 
' decide si detecta en flanco creciente o decreciente / pulse detection type

boton VAR portb.5 
' boton linterna / flashlight button

LED VAR portb.3 
' salida led PWM / LED output

testigo VAR portb.1 
' led para ver por donde anda el programa / testing purpose, to know where the program is at any moment

tope CON 7 
' setea cuantos niveles PWM hay para el seteo de brillo/ sets the amount of brightness levels

click CON 200 
' maximum click time in hundredste s 0.2

press COn 12000 
' equals 10000=0.1 second ;20000 = 0.2 second

pwmduty VAR BYTE[8] 
' tabla de niveles PWM / PMW levels table

pwmduty[0]= 1 
pwmduty[1]= 8 
' Low

pwmduty[2]= 16
pwmduty[3]= 32 
' Medium

pwmduty[4]= 64 
pwmduty[5]= 127 
' High

pwmduty[6]= 192
pwmduty[7]= 255
' 255 es 100% del ciclo/ 255 is 100% duty cicle Burst to burn your EYES!!!

prendido=0 
' arranca apagado / starts off

frecu=250 
' frecuencia en Hertz / Frequency in hertz

testigo=0 
' para debugging sacar en final / for debugging remove for production

tipopulso=1 
' determina el flanco de deteccion del pulso / sets pulse detection type

pwmstat=5 
' arranca al primera brillo / starts at primary brightness


'the beginning of possible Leon UI baby? Depends on PEU's approval 
LOOP:

TDP=22
time=0
time2=0
geweest=0
A=0
AN=0
B=0
Bn=0
C=0
Cn=0
Constant=50
' the requirement of a press is a count of 50 that translates into 0.005*50= 0.25 second maybe?

conta = 0




wHILE BOTON = 1 
'so the stupid button is finally pushed in?

An=1+A 
A=An
' we loop so we know how long the button push is, click or press? 

If a > 70 and prendido = 1 then 
HPwm 1,0,frecu 
time = 1
endif
' are you holding it way longer than a click or press? while it's the first one? Then we got momentary BABY!!!
' momentary off if the light is on

If a > 70 and prendido = 0 then 
HPwm 1,pwmduty[pwmstat],frecu
time2 = 1
endif
' momentary on, if light is on

pause 5 
wend
' the loops gets sampled each 5 microsecond till button is released.

If time = 1 then 
HPwm 1,pwmduty[pwmstat],frecu
endif
IF time2 = 1 then
HPwm 1,0,frecu
Endif
' after those momentary's it needs to be put back in original position

if A > 0 then
'well there has been a first click, how about a possible second click?

pause click
wHILE BOTON = 1 
Bn=1+B
B=Bn
pause 5
' again the length of button hold will be measured like first on, but without the momentary BS. 

WEND
endif

if B > 0 then
' wth? Is a third click possible? Yeah baby, it is possible, this is the main essence of showing the omni clicks UI.

pause click 
wHILE BOTON = 1 
Cn=1+C
C=Cn
pause 5
WEND
endif
' end if button sensing, add more of these loops if you go beyond 3 clicks/presses /ubbthreads/images/graemlins/wink.gif not advisable according to mrB. Thumb goes numb.

IF a < Constant and B = 0 and prendido = 0 THEN 
TDP=99 
Endif
' first case, first and only click, the light is also off, well then it goes ON!!! And man was given light /ubbthreads/images/graemlins/smile.gif. On mode. 

' time for some brightness settings, these can be done with scrolling like PEU's source, but that's so damn slow /ubbthreads/images/graemlins/tongue.gif. 

IF a < Constant and B < Constant and B > 0 and C = 0 and prendido = 1 THEN 
TDP=2 
Endif
' first click, second click, light goes into high mode

IF a < Constant and B > Constant and C = 0 and prendido = 1 THEN 
TDP=4 
Endif
' first click, second press, light goes into medium mode

If A < Constant and b < Constant and C > Constant and prendido = 1 then 
TDP=6
Endif
' first click, second click, third press, light goes into burst mode. time to ignore all other stuff like heat and runtime, it's time to P I M P with your light, impress them .

If A < Constant and b < Constant and C < Constant and C > 0 and prendido = 1 then 
TDP=3
Endif
' first click, second click, third click, light goes into low mode. /ubbthreads/images/graemlins/wink.gif think of our earth, use minimum brightness, use less energy. Oh there is a bonus too, runtime /ubbthreads/images/graemlins/smile.gif.

If A < Constant and B = 0 and prendido = 1 then 
TDP=1
Endif
' last but not least, first and only click while the light is on. Well we could always use an off /ubbthreads/images/graemlins/wink.gif.

If A = 0 then
goto loop
endif
' If there is nothing counted at all, go back.

Select Case tdp
Case 1 
HPwm 1,0,frecu 
Prendido = 0
'turn off light

Case 2 
pwmstat = 5 
HPwm 1,pwmduty[pwmstat],frecu
'high mode

cASE 3 
pwmstat = 1 
HPwm 1,pwmduty[pwmstat],frecu
'low mode

cASE 4 
pwmstat = 3 
HPwm 1,pwmduty[pwmstat],frecu
'medium mode

cASE 6
pwmstat = 7 
HPwm 1,pwmduty[pwmstat],frecu
'burst mode /ubbthreads/images/graemlins/wink.gif sounds familiar? It's just a name!!! you won't hear or read it on the light anyway. Heck this is just a comment.

cASE 99 
HPwm 1,pwmduty[pwmstat],frecu 
PRENDIDO = 1
'turns light on in setted brightness

End Select


GoTo loop

Return

This is the end of the source firmware. The most important thing of this firmware is:
1) possibility of initiating action by sequence of clicks or presses.
2) Momentary off and on to please both parties
3) I got my OWN UI!!! /ubbthreads/images/graemlins/tongue.gif Now I need a light that can use that UI.

/ubbthreads/images/graemlins/smile.gif I'm very satisfied for the time being. I will continue building this firmware. I would also like to thank PEU for making this possible for me. I hope I inspired some of the lurking programmers to support this project. Making your own UI isn't impossible, it just takes a bit of time /ubbthreads/images/graemlins/grin.gif.


----------



## wquiles (Jun 15, 2005)

*Re: First User develloped firmware for Leon: POSv1*

pokkuhlag,

/ubbthreads/images/graemlins/bowdown.gif

Sharing your hard work with all of us is definitely MUCH appretiated - /ubbthreads/images/graemlins/happy14.gif

Will


----------



## Amorphous (Jun 15, 2005)

*Re: First User develloped firmware for Leon: POSv1*

PEU / Pokkuhlag

Awesome!! /ubbthreads/images/graemlins/happy14.gif


----------



## jbev (Jun 15, 2005)

*Re: First User develloped firmware for Leon: POSv1*

Congratulations PEU on your open source hacking friendly light. Keep up the good work. /ubbthreads/images/graemlins/buttrock.gif

P.S. Nice video pokkuhlag


----------



## pokkuhlag (Jun 16, 2005)

*Re: First User develloped firmware for Leon: POSv1*

Thanks guys /ubbthreads/images/graemlins/smile.gif, any request on improvements or features you would like next? I was thinking a lock-out mode with a message and strobe. At what kind of frequency would you like that strobe to be? I have no experience with strobe and I have no lights with strobe, so any feedback will be appreciated here.


----------



## PEU (Jun 16, 2005)

*Re: First User developed firmware for Leon: POSv1*

/ubbthreads/images/graemlins/happy14.gif Pokkuhlag!!!

Lets see if some one else is willing to participate in this project, I see a bright future in trully CPF collaborative spirit.


Pablo


----------



## wquiles (Jun 16, 2005)

*Re: First User develloped firmware for Leon: POSv1*

I have two suggestions. Most of the UI's that I have seen are simply too hard to figure out or will not work unless you read the instructions and/or practice a lot with the light. There is no way anyone but the owner can pick up the light and use it well with the current UI's that I have seen described here. I can see myself telling my wife - no dear, you need to wait a little bit longer befre pressing ON again /ubbthreads/images/graemlins/crazy.gif

Idea 1) Keep it really really simple:
First ON - Low mode
Second ON - Medium mode
Third ON - Full mode
Next ON - turns OFF light
Once it is ON, next time you press (or twist) it simply turns OFF. Next time it starts again on LOW mode and repeats.

For menu mode - something special sequence should put you in programing mode, where the options would be few and simple. I would propose only to be able to change the default sequence and (see below) something to monitor battery life.

2) Idea 2: Use strobe mode for something practical
It is maybe just me, but from my point of view, when using any light, the strobe would likely not be something you would use often, so why not use strobe mode to help with battery status?

I have not yet investigated what pins are left from the PIC, but I feel it would be cool/practical to have the PIC measure/monitor battery voltage and then go into strobe mode (slowly at first, like one half second OFF period for every 5 seconds ON) to let the user know that the batteries are starting to run low. 

Even if one uses protected cells, it is always nice to know that your light is about to run out of batteries. The strobing frequency could increase as the batteries got even lower (like one half second for every second ON), before quiting all together. Different versions of the software could be made to match 1 or 2 cells or between primary (3.0) and LiIon (4.2) cells - this could also be menu selectable for complete flexibility.

Just a suggestion /ubbthreads/images/graemlins/smile.gif

Will


----------



## pokkuhlag (Jun 16, 2005)

*Re: First User develloped firmware for Leon: POSv1*

1) That simple UI could be made for you and posted (if you really want it, reply my PM. I can make it in my vacation starts on 4th of july), but I won't use it in my POS version. Why? Not my style /ubbthreads/images/graemlins/grin.gif. 

2) I'm sorry to say, but the source code does not allow me to get readings out of batteries. The only input now is the single button.

Thanks for your suggestions


----------



## legtu (Jun 23, 2005)

*Re: First User develloped firmware for Leon: POSv1*

My PIC seems to be 'broken'. Once I power it up, it'll go thru the different modes even if the 'button' pin is disconnected or left untouched. The only way I can make it stable is by tying the 'button' pin to the ground with a high value resistor. /ubbthreads/images/graemlins/mecry.gif I might have 'broken' it when I was testing some code with a power fet attached directly to the 'pwm' pin. I was cycling through the pwm routine when the PIC got hot and that's when I disconnected the power. /ubbthreads/images/graemlins/banghead.gif

Can anybody post a simple code that puts the PIC into sleep and wakes it up when a button is pressed? I can't get my PIC to wake up after issuing a sleep command. 

Anyway, here's a simple code for toggling on/off. /ubbthreads/images/graemlins/grin.gif
<font class="small">Code:</font><hr /><pre>'****************************************************************
'* Name : legtu on-off *
'* Author : legtu *
'* Notice : Copyright (c) 2005 legtu *
'* : *
'* : *
'* Date : 06/22/2005 *
'* Version : 1.2 *
'* Notes : Compiler PicBasicPro *
'* : *
'****************************************************************

ansel = 0 ' do not use comparator
vrcon = 0 ' do not use voltage reference control register

on_off_flag VAR BIT ' on-off flag

pin2_inout VAR GPIO.5 ' switch button
pin3_in VAR GPIO.4 '
pin4_inout VAR GPIO.3 ' 
pin7_inout VAR GPIO.0 ' debug led
pin6_inout VAR GPIO.1 ' debug led
pin5_inout VAR GPIO.2 ' output led

input pin2_inout
output pin6_inout
output pin4_inout
output pin5_inout
output pin7_inout

'************* sequence check start *************
pin7_inout = 1
pause 200
pin7_inout = 0
pause 200
pin7_inout = 1
pause 200
pin7_inout = 0
pause 200
pin6_inout = 1
pause 200
pin6_inout = 0
pause 200
pin6_inout = 1
pause 200
pin6_inout = 0
'************* sequence check end ************* 

'************* main loop start *************
loop:
if pin2_inout = 1 then
pause 180
if on_off_flag = 1 then
on_off_flag = 0
else
on_off_flag = 1
endif
endif
if on_off_flag = 1 then 'full on
pin5_inout = 1
else 'full off
pin5_inout = 0
endif
goto loop

Return </pre><hr />


----------



## pokkuhlag (Jul 11, 2005)

*POS.Advance and Basic update*

Well folks, after 4 weeks it's time for an update. I've had some struggling with this firmware, but with help of PEU I was able to kill some real life bugs in my firmware. This was necessary since I couldn't spot them with my simulator. So what have I done in these four weeks besides having exams? 

- I didn't like the exactly at .2 sec click timing, so I updated that with better timings. As long as you click or touch within 0.25 sec the second time.
- Due to space limits in PIC, I had to use different counters and sensing loop to save space. The original basic version went from 800 lines to 500 words. And the advance went from 2000 to 1300 words of code. Now it's truely omni click, cause of the limitation of previous version, only a certain amount of clicks is possible due to space limit. Now it can count till eternity. 60000 clicks for easter egg? /ubbthreads/images/graemlins/tongue.gif
- Finally the most important update, an option menu for extra stuff for some of us.

So what is in the option menu?
- first of all, if an item flashes in option menu it will use the setted brightness.
- the option menu itself flashes every second, so you know that you are in options menu.
- there is morse mode, so you can now communicate with morse.
- strobe mode with changeable frequency. due to software limitation, only 1-26 hz can be change with one hz. anything above 26 hz will go exponential till 250 Hz I think. Oh yeah a disclaimer: the user is responsible for using strobe mode. Due to possible seizures on certain strobe frequency, use it at your own risk. Don't blame me for dying or having a seizure. The start frequency is 29 Hz. And the variable strobe = 17. The function used is 500/strobe variabel=frequency. For those interested in the exponential growth after 26 Hz
- lockout mode. if pressed anything but the exit sequence, it will simulate a dying led /ubbthreads/images/graemlins/smile.gif. max brightness to 0 in 0.5 sec.



In this revision, only the last hit of the button will be registered as click <0.25 sec or press >0.25sec or long hold press >3sec
The first one two or three hits will not be registered but they will be counted. 
for multi clicks/press you must reach the button within 0.25 second
for end of clicking just don't click for 0.25 second.
Long hold press has flashes every second hold going to a maximum of three. This is available in most modes except exiting morse mode.
if the counts are made when a pulse go off, then the other modes have counters. 

for example: Press third time = something, something, press

Something can be anything as long as the next button hit is within 0.25 sec.

Now lets go to actual handling.

From off:

Press longer than 0.25 second = momentary on till release of button

Click once = on

anything else = nothing



From on:

Press longer than 0.25 second = momentary off till release of button

click once = off

click second time = high

press second time = medium

click third time = low

press third time = maximum

click fourth time = options menu with pulsing flash



From option menu with pulsing flash:

If you select option, you will only exit that option by performing the same task as entering.
You can only enter an option if your last hit is a hold long press which is more than 3 second.

first long hold press = morse mode

second long hold press = strobe mode

third long hold press = lockout mode

fourth click = exit options menu and turn off light



From morse mode:

touch is light 

long hold press = exit to options menu



From strobe mode:

first click = rise the frequency by one or more hz

second click = drop the frequency by one or more hz

second long hold press = exit to options menu



From lockout mode:

third long hold press = exit to options menu

Any other stuff = failure to stay on /ubbthreads/images/graemlins/smile.gif it browses from high to no brightness in 0.25 or 0.5 secs?


now here is an example movie again made by PEU, since he has the hardware.
He will first show some of the basic features and then you can see him quadra click to go to options menu.
There you can see him entering and exiting strobe and lockout mode using three long press holds. /ubbthreads/images/graemlins/tongue.gif We had some miscommunications, but the first one or two long hold presses is not necessary. It does show it will still work as long as the next hit is in 0.25 sec.



Link to PEU's demonstration of POS.Advance



And here is the the source code of POS.Advance, the basic version(without options)can be stripped of the advance version.

'****************************************************************
'* Name : UNTITLED.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2005 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 6/13/2005 *
'* Version : 1.0 *
'* Notes : *
'* : *
'****************************************************************
@ device INTRC_OSC_NOCLKOUT 
DEFINE OSC 4
DEFINE PULSIN_MAX 65535
'ansel=0 ' no usar el comparador/do not use comparator
trisb=%00100000 ' setear el gpio a salidas menos el 5/set all to output but 5
vrcon=0

time var bit
time2 Var Bit

A Var WORD
An Var WORD
B Var Byte
Bn Var Byte
strobo Var WORD
strobon Var WORD
strobo2 Var word
freq Var word
freq2 Var word
n Var Byte
Constant Con 50 ' 0.25+ secs
Press Con 600 ' 3+ secs
TDP VAR BYTE ' tipo de pulso / pulse type case
brightness Var Byte
menu Var Byte
prendido VAR BIT ' flag prendido/apagado / on-off flag
boton VAR portb.5 ' boton linterna / flashlight button
LED VAR portb.3 ' salida led PWM / LED output
testigo VAR portb.1 ' led para ver por donde anda el programa / testing purpose, to know where the program is at any moment



'pwmduty[0]= 1 '8
'pwmduty[1]= 8 '16 Low
'pwmduty[2]= 16 '32
'pwmduty[3]= 32 '64 Medium
'pwmduty[4]= 64 '127
'pwmduty[5]= 127 '150 High
'pwmduty[6]= 192
'pwmduty[7]= 255' 255 es 100% del ciclo/ 255 is 100% duty cicle Burst to burn your EYES!!!


hpwm 1, 0 , 250
prendido=0 ' arranca apagado / starts off
'frecu=250 ' frecuencia en Hertz / Frequency in hertz
testigo=0 ' para debugging sacar en final / for debugging remove for production
brightness = 127
menu = 0



'the beginning of possible Leon UI baby? Depends on PEU's approval /ubbthreads/images/graemlins/tongue.gif
LOOP:
'serout portb.2,2,[#A]

TDP=22
time=0
time2=0


B=0
Bn=0

'the requirement of a press is a count of 50 that translates into 0.005*50= 0.25 second maybe?

If menu = 1 then
HPwm 1,0,250

For n=0 to 474
pause 2

if boton = 1 then
n = 474
goto Sense
endif

next n

HPwm 1,brightness,250

For n=0 to 24
pause 2

if boton = 1 then
n = 24
HPwm 1,0,250
goto sense
endif
'checks for a maximum of 0.05 second on clicks before going to go off.

next n

endif

If Menu = 3 then 'activate strobe mode

while boton = 0
HPwm 1,brightness,250
For n=0 to strobo
Pause 1

if boton = 1 then
n = strobo

goto Sense

endif
Next n
hpwm 1, 0 , 250
For n=0 to strobo
Pause 1

if boton = 1 then
n = strobo

goto Sense
ENdif
next n

wend

endif

Sense: 'Sense loop 

A=0 'reset press or click counter
AN=0 

wHILE BOTON = 1 'so the stupid button is finally pushed in?
An=1+A ' we loop so we know how long the button push is, click or press? 
A=An

If B = 0 and menu = 0 then
If a > Constant and prendido = 1 then 
HPwm 1,0,250 'momentary off if the light is on
time = 1
endif
If a > Constant and prendido = 0 then 'momentary on, on setted mode
HPwm 1,brightness,250
time2 = 1
endif
endif
If Menu > 0 and Menu <> 2 then

For n = 1 to 3
If A = n*200 then
HPwm 1,brightness,250
Endif
if A = n*210 then
HPwm 1,0,250
endif


Next n
endif





If menu = 2 then 'morse code shorter than 3 sec
HPwm 1,brightness,250




Endif

pause 5
'the loops gets sampled each 5 microsecond till button is released.
wend

If menu = 2 and A > 0 then 'Don't give a *beep* about length B counting, just shut off and loop again.
HPwm 1,0,250
If A > Press then 'longer than 3 sec will trigger exit mode

Menu = 1

endif
GOTO loop
endif


If time = 1 then 'after those momentary's it needs to be put back in original position
HPwm 1,brightness,250
goto loop
endif
IF time2 = 1 then
HPwm 1,0,250
goto loop
Endif

If A = 0 and B = 0 then
goto loop
Else
'well there has been a first click, how about a possible second click?
Bn=1+B
B=Bn 
For n=0 to 125
pause 2
'play around with the pause timings, 2 maybe 1

if boton = 1 then
n = 125
goto sense
endif

next n
endif
'If there will not be any following press or click it'll be done sensing.




If menu = 0 then 'basic

If prendido = 1 then 'if it's on do something 
IF a < Constant and B = 2 THEN 'first click, second click, light goes into high mode
brightness = 127 'high mode

Endif
IF a > Constant and B = 2 THEN 'first click, second press, light goes into medium mode
brightness = 64 'medium mode
'HPwm 1,brightness,250 
Endif
If A > Constant and b = 3 then 'max brightness
brightness = 255 
'HPwm 1,brightness,250
Endif
If A < Constant and b = 3 then '
brightness = 8 
'HPwm 1,brightness,250
Endif
If A < Constant and B = 1 then 
HPwm 1,0,250 
Prendido = 0
goto loop
endif 
If A < Constant and B = 4 then 'options menu on
menu = 1
strobo = 17 ' 30 Hz
goto loop
endif

HPwm 1,brightness,250

Else 'if it's not on there can only one thing be done for clicks
IF a < Constant and B = 1 THEN 
HPwm 1,brightness,250 'turns light on in setted mode
PRENDIDO = 1
goto loop
Endif

Endif

else  'menu 1 or higher

If menu = 1 then 'in option menu

If A < Constant and B = 4 then
menu = 0
HPwm 1,0,250 'turn off light
Prendido = 0
goto loop 'and get out of flashing option menu
endif

If A > Press and B = 1 then 'select morse mode
Menu = 2
endif

If A > Press and B = 2 then 'select strobe mode
menu = 3
goto loop
endif

If A > Press and B = 3 then 'select lockout mode
menu = 4
goto loop
endif



Endif 'end of menu list

If Menu = 3 then 'in strobe menu

If A > Press and B = 2 then 'get out of strobe
menu = 1
endif

If A < Constant and B = 1 then 'turn up the frequency

strobo2 = strobo -1
freq = 500/strobo
freq2=freq + 1
strobon=500/freq2

If strobon > strobo2 then
strobo = strobo2
Else

strobo = strobon
Endif


Endif

If A < Constant and B = 2 then 'drop frequency

strobo2 = strobo +1
freq = 500/strobo
freq2=freq - 1
strobon=500/freq2

If strobon < strobo2 then
strobo = strobo2
Else

strobo = strobon
Endif

Endif


endif 'end of menu 3 

If Menu = 4 then 'begin of menu 4

If A > Press and B = 3 then 'get out of strobe
menu = 1
endif

IF A < Press and B > 0 then
For n = 250 to 0 step -2
HPwm 1,n,250
pause 5
next n
HPwm 1,0,250
Endif

If A > Press and B <> 3 then
For n = 250 to 0 step -2
HPwm 1,n,250
pause 5
next n
HPwm 1,0,250
Endif

endif 'end of menu 4

endif

GoTo loop

Return


----------



## [email protected] (Jul 11, 2005)

*Re: POS.Advance and Basic update*

Nice work pokkie! /ubbthreads/images/graemlins/thumbsup.gif


----------



## PEU (Jul 11, 2005)

*Re: POS.Advance and Basic update*

Nice hand... /ubbthreads/images/graemlins/stupid.gif

Great Work POK!!! as I told you in private, I like this release a lot, its simpler and have more features!

One more proof that collective open source work is better than closed /ubbthreads/images/graemlins/happy14.gif


Pablo


----------



## wquiles (Jul 12, 2005)

*Re: POS.Advance and Basic update*

Most excellent - thanks for sharing with us /ubbthreads/images/graemlins/goodjob.gif

Will


----------



## pokkuhlag (Jul 13, 2005)

*Re: POS.Advance and Basic update*

Thanks guys, any suggestion on feature you would like to have? I've already added 256 step brightness changing and so you can select one of them as your brightness setting. I also added morse code message, so if you guys want SOS morsing mode could be done in 100 word codes or less.

Wquilles: I will try to do the battery status thing next, but I have to get this new simulation circuit working and it isn't very cooperative.


----------



## legtu (Jul 13, 2005)

*Alternate firmware: uCF v1.0 beta - osc*

Here's an alternate firmware. It's an offshoot from my other project, the uCF which stands for "micro-controlled flashlight". /ubbthreads/images/graemlins/grin.gif 

This is the open-source version. It currently supports 5 functions, which are:
- toggle on/off
- cyclic dimming
- start @ last/lowest level
- strobe
- electronic switch lockout

The firmware is easily extendible (I hope) and still has lots of room to spare. The code hasn't 'really' been optimized and _it's un-tested_. *I haven't done any simulation or actual tests on the code... yet.* /ubbthreads/images/graemlins/tongue.gif It has status blinks which will hopefully inform you what mode it's in. The status blink is meant to be directed to a low-intensity LED but is re-directed to the main LED in the code.

Now, for the firmware 'manual'.

* With the light off
- 1 click turns it on
- Pressing and holding the button will start the dimming cycle from lowest level to brightest and then back down to lowest. Release the button to select and store the brightness level
- 2 clicks turns it on @ the last remembered brightness level. It defaults to the lowest level if there's no last level stored
- 3 clicks activates strobe mode
- 4 clicks will engage electronic switch lockout. Press and hold the button to disable lockout

* With the light on
- 1 click turns it off
- Pressing and holding the button will activate the dimming cycle, start increasing brightness at the current brightness level

The source code:

<font class="small">Code:</font><hr /><pre>
'*******************************************************************
'* Name : uCF - 'micro-controlled flashlight' *
'* Author : c-o-s / legtu *
'* Notice : Copyright (c) 2005 c-o-s *
'* : All Rights Reserved *
'* : Released under the Creative Commons *
'* : Attribution-NonCommercial-ShareAlike License *
'* : http://creativecommons.org/licenses/by-nc-sa/2.5/ *
'* : *
'* Date : 07/12/2005 *
'* Version : 1.00 - beta - open source code *
'* Notes : Compiler - PicBasic Pro *
'* : *
'* : *** user interface *** *
'* : + short press - toggle on/off *
'* : + 2x short press - start @ last/lowest level *
'* : - short press - off *
'* : + 3x short press - strobe mode *
'* : - short press - off *
'* : + 4x short switch lockout *
'* : - long press disables lockout *
'* : + long press when on or off - toggle dimming *
'* : - short press - off *
'* : - last brightness level always remembered *
'* : *
'*******************************************************************

data @0, "uCF - 'micro-controlled flashlight'"
data @40, "v1.00b - osc"
data @56, "(c)c-o-s"
data @72, "* 07-12-2005 * [c-o-s(at)gamebox.net]"
' uPIC used : PIC12F683
' uPIC 'sleep'/'wake' ready
@ device INTRC_OSC_NOCLKOUT 
DEFINE OSC 4 ' set internal oscillator to 4mhz

ansel = 0 ' do not use comparator
vrcon = 0 ' do not use vref

'intcon = %10001000 ' enable gpio on-change interrupt
'ioc = %00100000 ' enable gpio on-change interrupt on pin2
trisio = %00100000 ' set all pins to output except pin2

dim_down VAR bit ' dimming up/down flag

ctr VAR word ' reusable loop counter
butt_ctr var word ' button ctr
hold_ctr var word ' hold button ctr
pause_ctr var word ' pause ctr
butt_clicks var byte ' button clicks counter
pwm_freq VAR BYTE ' PWM frequency
pwm_level VAR BYTE ' actual PWM level
last_level var byte ' last brightness level

on_off_flag VAR BIT ' on-off flag
pwmloop_flag VAR BIT ' flag for the PWM loop
fullon_flag var bit ' full-on flag
lastlevel_flag var bit ' resume to last brightness level flag
switchlock_flag var bit ' switch lock flag

brightness_level CON 15 ' sets the amount of brightness levels
lowest_level con 0 ' sets the lowest level

pwmtable VAR BYTE[brightness_level+1] ' PWM levels table

pwmtable[0] = 1
pwmtable[1] = 4
pwmtable[2] = 8
pwmtable[3] = 16
pwmtable[4] = 32
pwmtable[5] = 48
pwmtable[6] = 64
pwmtable[7] = 80
pwmtable[8] = 96
pwmtable[9] = 112
pwmtable[10] = 128
pwmtable[11] = 144
pwmtable[12] = 160
pwmtable[13] = 176
pwmtable[14] = 192
pwmtable[15] = 255 ' 100% duty cicle

pin2 VAR GPIO.5 ' switch button
'pin7 VAR GPIO.0 ' status led
pin5 VAR GPIO.2 ' pwm output

symbol pin7 = pin5 ' re-direct status led to main led 

pwm_freq = 250 ' pwm frequency in hertz
on_off_flag = 0 ' starts off
dim_down = 0
pwm_level = lowest_level ' sets current level to lowest level
last_level = lowest_level ' sets last level to lowest level
lastlevel_flag = 0
butt_ctr = 0
butt_clicks = 0
hold_ctr = 0
switchlock_flag = 0

'************* sequence check start *************
'************* sequence check end ************* 

'************* main loop start *************
goto all_off

loop:
butt_clicks = 0
butt_ctr = 0
hold_ctr = 0
while pin2 = 1 '1 click
pauseus 800
hold_ctr = hold_ctr + 1
if hold_ctr >= 400 then 'button held down, goto subpwm
if fullon_flag = 0 then
dim_down = 1
else 
pwm_level = brightness_level
dim_down = 0
endif
gosub status_blink40
goto subpwm
endif
wend 
pause 8
if hold_ctr > 0 then
butt_clicks = 1
butt_ctr = 0
while pin2 = 0
butt_ctr = butt_ctr + 1
if butt_ctr >= 4000 then
goto timeout
endif

check_button: 
while pin2 = 1
pause 8
butt_clicks = butt_clicks + 1
butt_ctr = 0
while pin2 = 0
butt_ctr = butt_ctr + 1
if butt_ctr >= 4000 then
goto timeout
endif
wend
 goto check_button
wend
wend
endif

timeout: 
select case butt_clicks 'determine mode based on number of clicks
case 1 '1 click
if on_off_flag = 0 then
on_off_flag = 1
else
on_off_flag = 0
endif
if on_off_flag = 1 then
if pwmloop_flag = 0 then
fullon_flag = 1
pwm_level = brightness_level
HPwm 1, pwmtable[brightness_level], pwm_freq ' full on 
endif
goto loop 
else ' full off
goto all_off 
endif
goto loop
case 2 '2 clicks, set last or lowest level, goto subpwm
pwm_level = last_level
lastlevel_flag = 1 'set last level flag before going to subpwm
goto subpwm
case 3 '3 clicks, goto strobe
gosub status_blink200
pause 200
goto strobe
case 4 '4 clicks, switch lockout 
goto switch_lock
case else
goto all_off 
end select
goto loop

all_off: 
output pin7
HPwm 1, 0, pwm_freq
pin5 = 0
pin7 = 0
on_off_flag = 0
fullon_flag = 0
pwmloop_flag = 0
'end 'endless sleep until button press
while switchlock_flag = 1
hold_ctr = 0
while pin2 = 1
pause 80
hold_ctr = hold_ctr + 1
if hold_ctr >= 4000 then 'button held down, disable switch lock
switchlock_flag = 0 
gosub status_blink200
pause 200
gosub status_blink200
goto all_off
endif
wend
wend
goto loop 


'************* pwm dimming loop start ************* 
subpwm:
last_level = pwm_level
if lastlevel_flag = 1 then
HPwm 1, pwmtable[pwm_level], pwm_freq
lastlevel_flag = 0
else
HPwm 1, pwmtable[pwm_level], pwm_freq
endif 
if pwm_level <= lowest_level then
pause 200
endif
if pwm_level >= brightness_level then
pause 200
endif
if pin2 = 0 then
on_off_flag = 1
pwmloop_flag = 1
goto loop
endif
if pin2 = 1 then
pause 80
fullon_flag = 0
if dim_down = 1 then
pwm_level = pwm_level + 1
if pwm_level > brightness_level then
dim_down = 0
pwm_level = brightness_level
endif
else
pwm_level = pwm_level - 1
if pwm_level < lowest_level then
dim_down = 1
pwm_level = lowest_level
endif
endif
goto subpwm
endif
goto loop


'************* strobe loop start ************* 
strobe:
pause 40
pin7 = 1
for pause_ctr = 1 to 100 'blink every 1 sec (10*100 = 1000ms)
pause 10
if pin2 = 1 then 'button pressed, turn off
pause 180
gosub status_blink200
pause 200
gosub status_blink200
goto all_off
endif
next pause_ctr 
pin7 = 0
goto strobe


'************* switch lock loop start ************* 
switch_lock:
switchlock_flag = 1
goto all_off


' **** status blink sub-routine start
status_blink40:
PWM pin7, 4, 8 ' low intensity 40ms blink
output pin7 ' reset pin7 to output
pin7 = 0 ' turn-off pin7
return
' **** status blink sub-routine end

' **** 200ms status blink sub-routine start
status_blink200:
PWM pin7, 4, 40 'low intensity 200ms status blink
output pin7 ' reset pin7 to output
pin7 = 0 ' turn-off pin7
return
' **** status blink sub-routine end

Return 'end main
</pre><hr />


----------



## wquiles (Jul 13, 2005)

*Re: Alternate firmware: uCF v1.0 beta - osc*

Thanks letgu !!!

Will


----------



## pokkuhlag (Jul 13, 2005)

*Re: Alternate firmware: uCF v1.0 beta - osc*

Nice letgu !!!

I hope you test it soon, cause when this baby is up and running. /ubbthreads/images/graemlins/grin.gif You'll be even more happier than you are now. If you are testing in real life, could you please make a video of it? Thanks in advance and good luck with your code.


----------



## legtu (Jul 13, 2005)

*Re: Alternate firmware: uCF v1.0 beta - osc*

[ QUOTE ]
*pokkuhlag said:*
I hope you test it soon, cause when this baby is up and running. /ubbthreads/images/graemlins/grin.gif You'll be even more happier than you are now. If you are testing in real life, could you please make a video of it? Thanks in advance and good luck with your code. 

[/ QUOTE ]

As much as I'd like to do some real life tests on it, I can't 'cause I don't have the hardware. /ubbthreads/images/graemlins/blush.gif My uCF light is undergoing 'beta' testing with my GF and eventually, some of my friends. /ubbthreads/images/graemlins/popcorn.gif All of its features came from the original uCF firmware so you can take a peek on how it works at the video(s) posted on the other thread. 

Do you have some ideas for monitoring the battery? I'm also working on it, plus some other battery-related features. Checking the battery voltage can be a hassle especially when loaded since the uPIC's Vin also changes. /ubbthreads/images/graemlins/thinking.gif


----------



## pokkuhlag (Jul 13, 2005)

*Re: Alternate firmware: uCF v1.0 beta - osc*

I've seen the other video's already, right after I posted.

About the battery monitoring... I really have no idea. I guess, I have to ask PEU about it. That's because I'm a total noob in terms of electrical engineering. For my POS firmware, I just used the ports available in the original source. So I need to find out if there are ports available that can read the voltage of the battery.


----------



## Trev1960 (Jul 20, 2005)

*Re: Alternate firmware: uCF v1.0 beta - osc*

How is this project going?


----------



## lukestephens777 (Jan 29, 2008)

Pablo,

Is this project still under consideration? Or has it merged with Neoca 18650? This sounded fantastic!


----------

