Page 1 of 2

LEDgadget 1.0 alpha

Posted: Wed Aug 17, 2005 9:09 pm
by localmotion34
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

Posted: Thu Aug 18, 2005 3:58 am
by Brice Manuel
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]

Posted: Thu Aug 18, 2005 5:39 am
by dagcrack
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!

Posted: Thu Aug 18, 2005 8:27 pm
by localmotion34
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.

Posted: Fri Aug 19, 2005 1:33 am
by Brice Manuel
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.

Posted: Fri Aug 19, 2005 7:46 am
by gnozal
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?
With WinNT4 is works great.

Posted: Fri Aug 19, 2005 5:19 pm
by fsw
@Localmotion
8)

Posted: Sat Aug 20, 2005 6:59 pm
by BluesInA
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

Posted: Sun Aug 21, 2005 2:53 am
by Brice Manuel
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
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.

Posted: Sat Dec 31, 2005 12:44 pm
by Andre
@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. :wink:

Posted: Sat Dec 31, 2005 2:03 pm
by sharkpeter
hi localmotion34,
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 

Posted: Sat Dec 31, 2005 8:36 pm
by Falko
Hi Jens,
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 
Sorry
Edit this source to a new rang enumeration (01.01.2006)

Posted: Sun Jan 01, 2006 12:12 pm
by sharkpeter
@Falko,

yes, this is a chance for this problem.

Jens

Posted: Mon Jan 01, 2007 3:34 pm
by kinglestat
I didnt manage to get this to work with PB4 I am using 4.02 any ideas ?

regards

KingLestat

Posted: Mon Jan 01, 2007 7:25 pm
by localmotion34
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.