Toujours pour mes tests pour une application de gestion DMX-512, j'avais besoin d'avoir un temps BPM qui servira pour les animations alors j'ai fait ce petit source que je fait partager. Toujours ce source n'a aucune prétention.
Code : Tout sélectionner
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
DisableASM
EnableExplicit
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
;- DECLARATION DES VARIABLES (SYSTEME).
;{ - CONSTANTES
#WinLenX = 200
#WinLenY = 160
;}
;{ - ENUMERATION
Enumeration
#Window_0
EndEnumeration
Enumeration
#Text_0
#Text_1
#Text_2
#Text_3
#String_0
EndEnumeration
;}
;{ - CONSTANTES GLOBALS
Global FontID1 = LoadFont(#PB_Any, "Century Gothic", 9, #PB_Font_HighQuality | #PB_Font_Bold)
Global FontID2 = LoadFont(#PB_Any, "Century Gothic", 12, #PB_Font_HighQuality | #PB_Font_Bold)
Global FontID3 = LoadFont(#PB_Any, "Century Gothic", 14, #PB_Font_HighQuality | #PB_Font_Bold)
;}
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
Procedure.f BPM_Time(value.l)
;
If value > 0
ProcedureReturn (60/value)
EndIf
EndProcedure
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
Define i.l
Define event.l
Define eveng.l
Define value.l = 120
Define Time.l = ElapsedMilliseconds()
Define TimeOut.l = BPM_Time(value) * 1000
Define hWnd.l = OpenWindow(#Window_0, 0, 0, #WinLenX, #WinLenY, "BPM", #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
If hWnd <> 0
TextGadget(#Text_0, 40, 80, 30, 30, "", #PB_Text_Border)
SetGadgetColor(#Text_0, #PB_Gadget_BackColor, $4A4A4A)
TextGadget(#Text_1, 70, 80, 30, 30, "", #PB_Text_Border)
SetGadgetColor(#Text_1, #PB_Gadget_BackColor, $4A4A4A)
TextGadget(#Text_2, 100, 80, 30, 30, "", #PB_Text_Border)
SetGadgetColor(#Text_2, #PB_Gadget_BackColor, $4A4A4A)
TextGadget(#Text_3, 130, 80, 30, 30, "", #PB_Text_Border)
SetGadgetColor(#Text_3, #PB_Gadget_BackColor, $4A4A4A)
StringGadget(#String_0, 40, 40, 120, 30, Str(value))
SetGadgetFont(#String_0, FontID(FontID3))
Repeat
event = WaitWindowEvent(50)
eveng = EventGadget()
If event = #PB_Event_Gadget And eveng = #String_0
TimeOut.l = BPM_Time(Val(GetGadgetText(#String_0))) * 1000
EndIf
If ElapsedMilliseconds() - Time > TimeOut
SetGadgetColor(#Text_0, #PB_Gadget_BackColor, $4A4A4A)
SetGadgetColor(#Text_1, #PB_Gadget_BackColor, $4A4A4A)
SetGadgetColor(#Text_2, #PB_Gadget_BackColor, $4A4A4A)
SetGadgetColor(#Text_3, #PB_Gadget_BackColor, $4A4A4A)
SetGadgetColor(i, #PB_Gadget_BackColor, $FF)
i + 1
If i>3
i = 0
EndIf
Time = ElapsedMilliseconds()
EndIf
Until event = #PB_Event_CloseWindow
EndIf
GallyHC