
' ----------------------------------------------
'  Commands to Theremino_Motors
' ----------------------------------------------
' EnableConnection
' DisableConnection

' ResetAllMultiturnValues
' ResetAllCalibrationValues

' Calibrate Motor x To nn.n


' ----------------------------------------------
'  SLOT TEXT for COMMANDS
' ----------------------------------------------
Variable Numeric Slot_Commands = 50
Variable Numeric Slot_Responses = 51

' ----------------------------------------------
'  BUTTONS
' ----------------------------------------------
Button 1 Label EnableConnection
Button 2 Label DisableConnection

Button 4 Label WriteFirmware
Button 5 Label SendReset

Button 7  Label WriteSerialNumberToMotor
Button WriteSerialNumberToMotor Text "Write Serial to Motor" + CRLF +"and Increase it"
Button 8 Label SetSerialNumber
Button 9 Label GetSerialNumber

Button 17 Label ShowWindow

Button 19 Label ResetAllMultiturnValues
Button 20 Label ResetAllCalibrationValues

Button 22 Label "Calibrate Motor 1 To 0"
Button 23 Label "Calibrate Motor 1 To 30"
Button 24 Label "Calibrate Motor 1 To 60"
Button 25 Label "Calibrate Motor 1 To 90"

Gosub Loop
Stop

' ----------------------------------------------
'  LOOP
' ----------------------------------------------
Label Loop
	'Variable String Response
	'Response = SlotText(Slot_Responses)
	'Print Response
	Wait Seconds 0.1
Goto Loop


' =============================================================
'  SEND COMMAND (default timeout = 0.5 Sec)
' =============================================================
Label SendCommand
	Variable Numeric SC1       '<-- Parameter Destinat.-Slot
	Variable String  SC2       '<-- Parameter Command-String
	Variable Numeric SC3 = 0.5 '<-- The timeout in seconds
	Variable Numeric SC4
	SlotText SC1 = SC2
	For SC4 = 0.1 To SC3 Step 0.1
		If SlotText(SC1) = ""
			Exit
		EndIf
		Wait Seconds 0.1
	Next
Return

' ----------------------------------------------
'  COMMANDS
' ----------------------------------------------
Label EnableConnection
	SendCommand(Slot_Commands)("EnableConnection")
Return
Label DisableConnection
	SendCommand(Slot_Commands)("DisableConnection")
Return

Label WriteFirmware
	SendCommand(Slot_Commands)("WriteFirmware")
Return
Label SendReset
	SendCommand(Slot_Commands)("SendReset")
Return

Label WriteSerialNumberToMotor
	SendCommand(Slot_Commands)("WriteSerialNumberToMotor")
Return
Label SetSerialNumber
	v1 = Input("Initial serial number ?")
	SendCommand(Slot_Commands)("SetSerialNumber " + v1)
Return
Label GetSerialNumber
	SendCommand(Slot_Commands)("GetSerialNumber")
	Print SlotText(Slot_Responses)
Return

Label ShowWindow
	SendCommand(Slot_Commands)("Minimize")
Return

Label ResetAllMultiturnValues
	SendCommand(Slot_Commands)("ResetAllMultiturnValues")
Return
Label ResetAllCalibrationValues
	SendCommand(Slot_Commands)("ResetAllCalibrationValues")
Return

Label Calibrate Motor 1 To 0
	SendCommand(Slot_Commands)("Calibrate Motor 1 To 0")
Return
Label Calibrate Motor 1 To 30
	SendCommand(Slot_Commands)("Calibrate Motor 1 To 30")
Return
Label Calibrate Motor 1 To 60
	SendCommand(Slot_Commands)("Calibrate Motor 1 To 60")
Return
Label Calibrate Motor 1 To 90
	SendCommand(Slot_Commands)("Calibrate Motor 1 To 90")
Return


'BOOKMARKS 

'EDITEDLINES 29 9 31 3 17 3 101 5 99 6 91 7 92 8 28 9 104 10 

'WATCH v1
'EXEC DestX = 12
