LEDgadget 1.0 alpha

Developed or developing a new product in PureBasic? Tell the world about it.
localmotion34
Enthusiast
Enthusiast
Posts: 665
Joined: Fri Sep 12, 2003 10:40 pm
Location: Tallahassee, Florida

LEDgadget 1.0 alpha

Post 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

Code: Select all

!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
Brice Manuel

Post 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]
Last edited by Brice Manuel on Fri Aug 19, 2005 12:54 am, edited 1 time in total.
dagcrack
Addict
Addict
Posts: 1868
Joined: Sun Mar 07, 2004 8:47 am
Location: Argentina
Contact:

Post 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!
! Black holes are where God divided by zero !
My little blog!
(Not for the faint hearted!)
localmotion34
Enthusiast
Enthusiast
Posts: 665
Joined: Fri Sep 12, 2003 10:40 pm
Location: Tallahassee, Florida

Post 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.

Code: Select all

!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
Brice Manuel

Post 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.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post 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.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

@Localmotion
8)
BluesInA
User
User
Posts: 11
Joined: Mon Mar 07, 2005 3:20 pm

Post 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
Brice Manuel

Post 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.
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2137
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Post 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:
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
sharkpeter
User
User
Posts: 11
Joined: Sat Oct 02, 2004 5:02 pm
Location: Chemnitz

Post 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 
PB3.94 bis 5.xx / Win98/98SE/ME/XPProSP3/WINVista-X32/WIN7HP-X64/WIN8PRO-X32

Forum Falko und Jens

Portal / Projekt / Mallorca
User avatar
Falko
Enthusiast
Enthusiast
Posts: 271
Joined: Sat Oct 04, 2003 12:57 pm
Location: Germany
Contact:

Post 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)
Last edited by Falko on Sun Jan 01, 2006 3:29 pm, edited 1 time in total.
sharkpeter
User
User
Posts: 11
Joined: Sat Oct 02, 2004 5:02 pm
Location: Chemnitz

Post by sharkpeter »

@Falko,

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
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Post by kinglestat »

I didnt manage to get this to work with PB4 I am using 4.02 any ideas ?

regards

KingLestat
localmotion34
Enthusiast
Enthusiast
Posts: 665
Joined: Fri Sep 12, 2003 10:40 pm
Location: Tallahassee, Florida

Post 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.

Code: Select all

!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
Post Reply