' ====================================================================
'     Name:	WXM_DigiClamp_1.txt                   Date: 22 August 2020
'    Autor: Leonardo DE PALO Ph.D.
'    Scope: Digital gripper
'
' Hardware: Standard Theremino Master and Theremino Current Sensor
'
' ====================================================================

Load images\DigiClamp.jpg
'Load sound\gong.wav
Option Speed 9

' -------------------------------------- Slots
Slot_ClampPushButton = 6
Slot_RoboClampCommand = 13

' -------------------------------------- BUTTONS
Button  1 Text  CLAMP
Button  1 Color Yellow
Button  1 Slot  Slot_ClampPushButton

Button  2 Text  "PRESSURE "
Button  2 Color PaleGoldenrod

Button  5 Text  CLOSE ALL
Button  5 Color Red

Gosub DisableAllButtons

' -------------------------------------- LOAD EXTERNAL PROGRAMS
Load "Theremino_HAL\Theremino_HAL.exe"
'Load "Microvideo\Theremino_MicroVideo.exe"
Load "Theremino_HAL\Theremino_SlotViewer.exe"
Load "RoboClamp\RoboClamp.exe"
'Load "Theremino_GamePad\Theremino_GamePad\Theremino_GamePad.exe"

' -------------------------------------- TEST MASTER PRESENT
For v1 = 1 To 9e99
	For v2 = 1 To 20 ' <<< testing for 2 seconds
		If (Slot(0) >= 1 And Slot(0) <= 2) Or Key("CTRL")
			Exit 2
		EndIf
		Wait Seconds 0.1
	Next
	Print " Invalid master number: " + Slot(0)
	Slot 0 = Recognize
	Beep
Next
Print ""

Gosub EnableAllButtons
Load Hide

'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Stop				 '<<<<<<<<<<<<<< STOP >>>>>>>>>>>>>>
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

' ====================================================================
'  VARIABLES
' ====================================================================
Variable Numeric Slot_ClampPushButton
Variable Numeric Slot_RoboClampCommand

' ====================================================================
' ENABLE/DISABLE BUTTONS
' ====================================================================
Label EnableAllButtons
	For v1 = 1 To 32
		Button v1 Enabled
	Next
Return

Label DisableAllButtons
	For v1 = 1 To 32
		Button v1 Disabled
	Next
Return

' =====================================================================
'  CLOSING EVENTS
' =====================================================================
Label CLOSE ALL
	Load CloseApps
Return

Label EventStop
	Gosub EnableAllButtons
End

' ====================================================================
'  FUNCTIONS
' ====================================================================
Label CLAMP
	Slot Slot_RoboClampCommand = 1000
	Button 1 Text RELEASE
	Button 1 Color Flashing7 Orange Yellow
Return

Label RELEASE
	Slot Slot_RoboClampCommand = 0
	Button 1 Color Yellow
	Button 1 Text CLAMP
Return

Label EventTimer
	v1 = Slot(2)
	v1 = Int(v1)
	Button 2 Text "Pressure=" + v1
Return


'WATCH SlotMotor
'WATCH Abs(Slot(SlotMotor))
'WATCH v1
'WATCH Load
'EXEC Sin2 = Sin(33)
