What I need to do is :
Start off with flashing red light during event.
If even A happens, Flashing red light illuminates solid for 5 seconds.
If event b happens, light flashes For 5 seconds (Interval is .5 seconds on then .5 seconds off)
I need to do this with various leds.
Just got a testbed app ready to play with timings but no idea where to go yet. Still playing of course but suggestions would be greatly appreciated.
Suggestions of "Steal srod's underpants and wash the sheep with them" will be vastly amusing but not helpful!
Code: Select all
;
Enumeration 1
#Window_flashbox
EndEnumeration
#WindowIndex = #PB_Compiler_EnumerationValue
Enumeration 1
#Gadget_flashbox_cFlashBox
#Gadget_flashbox_Area3
#Gadget_flashbox_cControl
#Gadget_flashbox_Area5
#Gadget_flashbox_BlueOff
#Gadget_flashbox_GreenOff
#Gadget_flashbox_RedOff
#Gadget_flashbox_YellowOff
#Gadget_flashbox_BlackOff
#Gadget_flashbox_Start
#Gadget_flashbox_Blink
#Gadget_flashbox_Stop
EndEnumeration
#GadgetIndex = #PB_Compiler_EnumerationValue
Enumeration 1
#Image_flashbox_BlueOff
#Image_flashbox_BlueOn
#Image_flashbox_GreenOff
#Image_flashbox_GreenOn
#Image_flashbox_RedOff
#Image_flashbox_RedOn
#Image_flashbox_YellowOff
#Image_flashbox_YellowOn
#Image_flashbox_BlackOff
#Image_flashbox_BlackOn
EndEnumeration
#ImageIndex = #PB_Compiler_EnumerationValue
;
CatchImage(#Image_flashbox_BlueOff, ?_MGB_flashbox_BlueOff)
CatchImage(#Image_flashbox_BlueOn, ?_MGB_flashbox_BlueOn)
CatchImage(#Image_flashbox_GreenOff, ?_MGB_flashbox_GreenOff)
CatchImage(#Image_flashbox_GreenOn, ?_MGB_flashbox_GreenOn)
CatchImage(#Image_flashbox_RedOff, ?_MGB_flashbox_RedOff)
CatchImage(#Image_flashbox_RedOn, ?_MGB_flashbox_RedOn)
CatchImage(#Image_flashbox_YellowOff, ?_MGB_flashbox_YellowOff)
CatchImage(#Image_flashbox_YellowOn, ?_MGB_flashbox_YellowOn)
CatchImage(#Image_flashbox_BlackOff, ?_MGB_flashbox_BlackOff)
;CatchImage(#Image_flashbox_BlackOn, ?_MGB_flashbox_BlackOn)
;
DataSection
_MGB_flashbox_BlueOff : IncludeBinary "Images\LedBlueOff 16x16.ico"
_MGB_flashbox_BlueOn : IncludeBinary "Images\LedBlueon 16x16.ico"
_MGB_flashbox_GreenOff : IncludeBinary "Images\LedGreenOff 16x16.ico"
_MGB_flashbox_GreenOn : IncludeBinary "Images\LedGreenOn 16x16.ico"
_MGB_flashbox_RedOff : IncludeBinary "Images\LedRedOff 16x16.ico"
_MGB_flashbox_RedOn : IncludeBinary "Images\LedRedOn 16x16.ico"
_MGB_flashbox_YellowOff : IncludeBinary "Images\LedYellowOff 16x16.ico"
_MGB_flashbox_YellowOn : IncludeBinary "Images\LedYellowOn 16x16.ico"
_MGB_flashbox_BlackOff : IncludeBinary "Images\LedBlack 16x16.ico"
; _MGB_flashbox_BlackOn : IncludeBinary "Images\LedBlackOn 16x16.ico"
EndDataSection
;
Procedure.l Window_flashbox()
If OpenWindow(#Window_flashbox,262,141,165,95,"Flashbox",#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_Invisible)
ContainerGadget(#Gadget_flashbox_cFlashBox,5,5,155,40,#PB_Container_Flat|#PB_Container_BorderLess)
ImageGadget(#Gadget_flashbox_BlueOff,10,10,16,16,ImageID(#Image_flashbox_BlueOff))
ImageGadget(#Gadget_flashbox_GreenOff,40,10,16,16,ImageID(#Image_flashbox_GreenOff))
ImageGadget(#Gadget_flashbox_RedOff,70,10,16,16,ImageID(#Image_flashbox_RedOff))
ImageGadget(#Gadget_flashbox_YellowOff,100,10,16,16,ImageID(#Image_flashbox_YellowOff))
ImageGadget(#Gadget_flashbox_BlackOff,130,10,16,16,ImageID(#Image_flashbox_BlackOff))
CloseGadgetList()
ContainerGadget(#Gadget_flashbox_cControl,5,50,155,40,#PB_Container_Flat|#PB_Container_BorderLess)
ButtonGadget(#Gadget_flashbox_Start,10,10,45,20,"Start")
SetGadgetFont(#Gadget_flashbox_Start,LoadFont(#Gadget_flashbox_Start,"Comic Sans MS",10,0))
ButtonGadget(#Gadget_flashbox_Blink,55,10,45,20,"Blink")
SetGadgetFont(#Gadget_flashbox_Blink,LoadFont(#Gadget_flashbox_Blink,"Comic Sans MS",10,0))
ButtonGadget(#Gadget_flashbox_Stop,100,10,45,20,"Stop")
SetGadgetFont(#Gadget_flashbox_Stop,LoadFont(#Gadget_flashbox_Stop,"Comic Sans MS",10,0))
CloseGadgetList()
HideWindow(#Window_flashbox,0)
ProcedureReturn WindowID(#Window_flashbox)
EndIf
EndProcedure
; My constants here
Structure ProgramData
FlashOn.i
EndStructure
Global Program.ProgramData
; My declarations here
Declare StartLeds()
Declare BlinkLeds()
Declare StopLeds()
Declare AsyncTimer(ObjectHandle, Message, EventNumber, TimePeriod)
;
Procedure StartLeds()
; Check if the program timer needs to turn on ; Windows, event number, resolution, procedure
SetTimer_(WindowID(#Window_flashbox), 111, 1000, @AsyncTimer())
EndProcedure
Procedure BlinkLeds()
EndProcedure
;
Procedure StopLeds()
KillTimer_(WindowID(#Window_flashbox), 111)
EndProcedure
; Run an asynchronous clock in the window title bar
Procedure AsyncTimer(ObjectHandle, Message, EventNumber, TimePeriod)
Select EventNumber
Case 111
If Program\FlashOn = 1
Program\FlashOn = 0
SetGadgetState(#Gadget_flashbox_BlueOff, ImageID(#Image_flashbox_BlueOff))
ElseIf Program\FlashOn = 0
Program\FlashOn = 1
SetGadgetState(#Gadget_flashbox_BlueOff, ImageID(#Image_flashbox_BlueOn))
EndIf
EndSelect
EndProcedure
;
If Window_flashbox()
quitflashbox = 0
Program\FlashOn = 0
Repeat
EventID = WaitWindowEvent()
MenuID = EventMenu()
GadgetID = EventGadget()
WindowID = EventWindow()
Select EventID
Case #PB_Event_CloseWindow
Select WindowID
Case #Window_flashbox : quitflashbox = 1
EndSelect
Case #PB_Event_Gadget
Select GadgetID
Case #Gadget_flashbox_Start : StartLeds()
Case #Gadget_flashbox_Blink : BlinkLeds()
Case #Gadget_flashbox_Stop : StopLeds()
EndSelect
EndSelect
Until quitflashbox
CloseWindow(#Window_flashbox)
EndIf
End

