LEDgadget 1.0 alpha
-
- Enthusiast
- Posts: 665
- Joined: Fri Sep 12, 2003 10:40 pm
- Location: Tallahassee, Florida
LEDgadget 1.0 alpha
here it is, the next installment of the "advanced gadgets" libraries i am working on.
LEDgadget, and LEDswitch are two types of gadgets that i am releasing. one is like a meter, and the other is like a fancy radio button or checkbox.
download the source, the LIB and RES, as well as a small compiled program to see what it does.
TO BE ADDED: getLEDstate, and SetLEDswitch, which are simple in themselves, but the main function and look is what i am interested in.
again, this was done with subclassing as well as including the icons in the LIB.
NOTE: if you dont like the icons i used, please create, or point me in the direction of cool "lamplike" icons to use in the final release.
http://www.penguinbyte.com/apps/pbwebst ... Gadget.zip
LEDgadget, and LEDswitch are two types of gadgets that i am releasing. one is like a meter, and the other is like a fancy radio button or checkbox.
download the source, the LIB and RES, as well as a small compiled program to see what it does.
TO BE ADDED: getLEDstate, and SetLEDswitch, which are simple in themselves, but the main function and look is what i am interested in.
again, this was done with subclassing as well as including the icons in the LIB.
NOTE: if you dont like the icons i used, please create, or point me in the direction of cool "lamplike" icons to use in the final release.
http://www.penguinbyte.com/apps/pbwebst ... Gadget.zip
Code: Select all
!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
I really like this, and it is just what I need for one of the game I am working on. Here are a couple of suggestions, though:
1. For the LEDs. For the "off" state, they should be a very dark red, yellow and green. For the "on" state, they should be light and bright red, yellow and green. This would make it identical to real LEDs.
2. When using icons as images, it is important to remember that old versions of Windows (Like 95 (not sure if NT4 has this issue)) cannot display icons with more than 16 colors. Using higher bitdepth icons on Windows 95 will usually result in an ugly icon. Perhaps you could use BMPs?
As much as I like it, #2 would prevent me from using it in my game, just because my game needs to run on all OSes.
[images removes due to lack of server space]
1. For the LEDs. For the "off" state, they should be a very dark red, yellow and green. For the "on" state, they should be light and bright red, yellow and green. This would make it identical to real LEDs.
2. When using icons as images, it is important to remember that old versions of Windows (Like 95 (not sure if NT4 has this issue)) cannot display icons with more than 16 colors. Using higher bitdepth icons on Windows 95 will usually result in an ugly icon. Perhaps you could use BMPs?
As much as I like it, #2 would prevent me from using it in my game, just because my game needs to run on all OSes.
[images removes due to lack of server space]
Last edited by Brice Manuel on Fri Aug 19, 2005 12:54 am, edited 1 time in total.
Not very nice but quite accurate. May I talk about real LEDs too? 
"normal" (light visible LEDs) are made with silicon arsenide phosphide (not with silicon carbide like the ones at the begining of 20 century! hehe). while infrared ones are made with gallium arsenide... The light visible LEDs, the RED ones for example, for direct polarization you'll need arround 1,6 to 2V... If I remember well the Green ones with 2.4V, same for the yellow ones, blue requires arround 3-4V and for the infrared LEDs, those requires 1,35V for polarization...
Now, why using light visible leds (ye old 'normal' LEDs)?!? when now adays we use infrared ones even for lightbulbs (I think philips made one of this.. but for trailers and cars there was already 9V lightbulbs made out of infrared LEDs)
They are just nicer, need less voltage and uses about 15mA (bah with 20 they'll be over-bright but they wont burn out)... in watts consumes less than 0,02w..
(sorry if some terms are bad, I studied this crap in spanish long ago).
@localmotion34, you know I like the lib!

"normal" (light visible LEDs) are made with silicon arsenide phosphide (not with silicon carbide like the ones at the begining of 20 century! hehe). while infrared ones are made with gallium arsenide... The light visible LEDs, the RED ones for example, for direct polarization you'll need arround 1,6 to 2V... If I remember well the Green ones with 2.4V, same for the yellow ones, blue requires arround 3-4V and for the infrared LEDs, those requires 1,35V for polarization...
Now, why using light visible leds (ye old 'normal' LEDs)?!? when now adays we use infrared ones even for lightbulbs (I think philips made one of this.. but for trailers and cars there was already 9V lightbulbs made out of infrared LEDs)
They are just nicer, need less voltage and uses about 15mA (bah with 20 they'll be over-bright but they wont burn out)... in watts consumes less than 0,02w..
(sorry if some terms are bad, I studied this crap in spanish long ago).
@localmotion34, you know I like the lib!
-
- Enthusiast
- Posts: 665
- Joined: Fri Sep 12, 2003 10:40 pm
- Location: Tallahassee, Florida
OK, here is one with a different set of icons. id rather use icons because they are smaller than a BMP, and i dont know of anyone here that is still using windows 95. id rather keep it to 98 and later.
http://www.penguinbyte.com/apps/pbwebst ... gadget.zip
try it out, and if you find any better icons, send the links my way.
http://www.penguinbyte.com/apps/pbwebst ... gadget.zip
try it out, and if you find any better icons, send the links my way.
Code: Select all
!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
Wowzers! First, thanks for adding Blue. Second, The new graphics look awesome. I plan to put this to good use.
I hear you on the non '95 support. I am thinking of dropping support for it myself, just because out of my systems, the only one I can even get 95 to install on are the two old 486's I keep set up for DOS/3.1 games. Too hard to even test for 95 anymore.
I hear you on the non '95 support. I am thinking of dropping support for it myself, just because out of my systems, the only one I can even get 95 to install on are the two old 486's I keep set up for DOS/3.1 games. Too hard to even test for 95 anymore.
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
With WinNT4 is works great.Brice Manuel wrote:2. When using icons as images, it is important to remember that old versions of Windows (Like 95 (not sure if NT4 has this issue)) cannot display icons with more than 16 colors. Using higher bitdepth icons on Windows 95 will usually result in an ugly icon. Perhaps you could use BMPs?
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
localmotion34,
i pm'd you about these icons for your LED gadget but using the forum might be easier. i cranked these out in photoshop after i found an "easy led" lesson on the web. they're a little different than the ones you're using.
http://home.comcast.net/~tosca/LEDs.zip
mike
i pm'd you about these icons for your LED gadget but using the forum might be easier. i cranked these out in photoshop after i found an "easy led" lesson on the web. they're a little different than the ones you're using.
http://home.comcast.net/~tosca/LEDs.zip
mike
Yours are nice, but I like localmotion34's better. I think his look better. Your colors for "on and off" for the blue and yellow are a tad off.BluesInA wrote:localmotion34,
i pm'd you about these icons for your LED gadget but using the forum might be easier. i cranked these out in photoshop after i found an "easy led" lesson on the web. they're a little different than the ones you're using.
http://home.comcast.net/~tosca/LEDs.zip
mike
- Andre
- PureBasic Team
- Posts: 2137
- Joined: Fri Apr 25, 2003 6:14 pm
- Location: Germany (Saxony, Deutscheinsiedel)
- Contact:
@localmotion34: a german user reported a small bug for the lib (beside a lot of praise):
"As soon as the LED switches are programmed with a constant as gadget ID and when you put the code inside a procedure, there will be problems with driving of the several LED using setLEDstate().
As a small bug-fix he noted, that decreasing the used constant with 8 will give you access to the right LED."
I've asked him also to post an example to show the problem.
"As soon as the LED switches are programmed with a constant as gadget ID and when you put the code inside a procedure, there will be problems with driving of the several LED using setLEDstate().
As a small bug-fix he noted, that decreasing the used constant with 8 will give you access to the right LED."
I've asked him also to post an example to show the problem.

-
- User
- Posts: 11
- Joined: Sat Oct 02, 2004 5:02 pm
- Location: Chemnitz
hi localmotion34,
i´m the german user with bug localisation. here is a code for you.
i´m the german user with bug localisation. here is a code for you.
Code: Select all
; testprogram for the MoreButton.lib from localmotion34
; written with PB3.94
; create: 31.12.2005
; written from: Jens (sharkpeter) Haipeter from german forum
initLED()
; change the enumeration, and all ist ok, but in my opinion is this not correctly
Enumeration
#window
#cont_0
#butt_0
#le1 : #le2: #le3: #le4: #le5: #le6: #le7: #le8
EndEnumeration
; Enumeration
; #le1 : #le2: #le3: #le4: #le5: #le6: #le7: #le8
; #window
; #cont_0
; #butt_0
; EndEnumeration
Procedure testled()
a=GetSwitchState(#le2)
If a>0: a=0:Else: a=1: EndIf
SetSwitchState(#le2,a)
EndProcedure
; Window and Gadget
If OpenWindow(#window,100,320,300,300,#PB_Window_MinimizeGadget,"")
If CreateGadgetList(WindowID(#window))
ContainerGadget(#cont_0,0,0,140,170)
LEDswitch(#le1 , 10, 10,120, 20,"num :"+Str(#le1 ),#OnOff_Red)
LEDswitch(#le2 , 10, 30,120, 20,"num :"+Str(#le2 ),#OnOff_Red)
LEDswitch(#le3 , 10, 50,120, 20,"num :"+Str(#le3 ),#OnOff_Red)
LEDswitch(#le4 , 10, 70,120, 20,"num :"+Str(#le4 ),#OnOff_Red)
LEDswitch(#le5 , 10, 90,120, 20,"num :"+Str(#le5 ),#OnOff_Red)
LEDswitch(#le6 , 10,110,120, 20,"num :"+Str(#le6 ),#OnOff_Red)
LEDswitch(#le7 , 10,130,120, 20,"num :"+Str(#le7 ),#OnOff_Red)
LEDswitch(#le8 , 10,150,120, 20,"num :"+Str(#le8 ),#OnOff_Red)
CloseGadgetList()
TextGadget (#PB_Any, 10,190,300, 40,"The number of led is automatical generated with enumeration. When you push the button, in want to switch the second led, but it´s switch the 5th led.")
DisableGadget(#cont_0,1); for only switch with procedure, not click switch!
ButtonGadget(#butt_0, 10,240,120, 24,"Switch LED num: "+Str(#le2))
EndIf
Else
End
EndIf
; Loop
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_EventGadget
Select EventGadgetID()
Case #butt_0
testled()
EndSelect
EndIf
Until EventID = #PB_EventCloseWindow
; Ende
End
PB3.94 bis 5.xx / Win98/98SE/ME/XPProSP3/WINVista-X32/WIN7HP-X64/WIN8PRO-X32
Forum Falko und Jens
Portal / Projekt / Mallorca
Forum Falko und Jens
Portal / Projekt / Mallorca
Hi Jens,
and this?
Sorry
Edit this source to a new rang enumeration (01.01.2006)
and this?
Code: Select all
; testprogram for the MoreButton.lib from localmotion34
; written with PB3.94
; create: 31.12.2005
; written from: Jens (sharkpeter) Haipeter from german forum
initLED()
; change the enumeration, and all ist ok, but in my opinion is this not correctly
Enumeration
#window
EndEnumeration
Enumeration
#le1
#le2
#le3
#le4
#le5
#le6
#le7
#le8
#cont_0
#butt_0
EndEnumeration
Procedure testled()
a=GetSwitchState(#le2)
If a>0: a=0:Else: a=1: EndIf
SetSwitchState(#le2,a)
EndProcedure
; Window and Gadget
If OpenWindow(#window,100,320,300,300,#PB_Window_MinimizeGadget,"")
If CreateGadgetList(WindowID(#window))
ContainerGadget(#cont_0,0,0,140,170)
LEDswitch(#le1 , 10, 10,120, 20,"num :"+Str(#le1 ),#OnOff_Red)
LEDswitch(#le2 , 10, 30,120, 20,"num :"+Str(#le2 ),#OnOff_Red)
LEDswitch(#le3 , 10, 50,120, 20,"num :"+Str(#le3 ),#OnOff_Red)
LEDswitch(#le4 , 10, 70,120, 20,"num :"+Str(#le4 ),#OnOff_Red)
LEDswitch(#le5 , 10, 90,120, 20,"num :"+Str(#le5 ),#OnOff_Red)
LEDswitch(#le6 , 10,110,120, 20,"num :"+Str(#le6 ),#OnOff_Red)
LEDswitch(#le7 , 10,130,120, 20,"num :"+Str(#le7 ),#OnOff_Red)
LEDswitch(#le8 , 10,150,120, 20,"num :"+Str(#le8 ),#OnOff_Red)
CloseGadgetList()
TextGadget (#PB_Any, 10,190,300, 40,"The number of led is automatical generated with enumeration. When you push the button, in want to switch the second led, but it´s switch the 5th led.")
DisableGadget(#cont_0,1); for only switch with procedure, not click switch!
ButtonGadget(#butt_0, 10,240,120, 24,"Switch LED num: "+Str(#le2))
EndIf
Else
End
EndIf
; Loop
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_EventGadget
Select EventGadgetID()
Case #butt_0
testled()
EndSelect
EndIf
Until EventID = #PB_EventCloseWindow
; Ende
End
Edit this source to a new rang enumeration (01.01.2006)
Last edited by Falko on Sun Jan 01, 2006 3:29 pm, edited 1 time in total.
-
- User
- Posts: 11
- Joined: Sat Oct 02, 2004 5:02 pm
- Location: Chemnitz
@Falko,
yes, this is a chance for this problem.
Jens
yes, this is a chance for this problem.
Jens
PB3.94 bis 5.xx / Win98/98SE/ME/XPProSP3/WINVista-X32/WIN7HP-X64/WIN8PRO-X32
Forum Falko und Jens
Portal / Projekt / Mallorca
Forum Falko und Jens
Portal / Projekt / Mallorca
-
- Enthusiast
- Posts: 746
- Joined: Fri Jul 14, 2006 8:53 pm
- Location: Malta
- Contact:
-
- Enthusiast
- Posts: 665
- Joined: Fri Sep 12, 2003 10:40 pm
- Location: Tallahassee, Florida
i just got back from my christmas vacation. i am settling in and trying to catch up with my PHD emails ect. i will take a look at this, install the latest PB, and rework the code.
actually, i had already rewrote the code so NO linked lists are used. as soon as i can, i will post the new lib.
actually, i had already rewrote the code so NO linked lists are used. as soon as i can, i will post the new lib.
Code: Select all
!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw