
' ----------------------------------------- BUTTONS
Button 1 Text "RUN TEST"
Button 2 Text "ZERO"
Button 3 Text "IN POWER"
Button 4 Text "IN MEMORY"
Button 5 Text "IN USB3"
Button 6 Text "IN USBC"
Button 7 Text "IN HDMI"
Button 8 Text "IN USBPWR"
Button 9 Text "IN HEARSET"
Button 10 Text "PEN DOWN"
Button 11 Text "ALL OUT"
Button 12 Text "ROTATE HORZ"
Button 13 Text "ROTATE MIDL"

Button 15 Text "POWER CYCLE"
Button 16 Text "CLOSE ALL"


Stop



' =====================================================================
'  SEQUENCE LOADING AND EXECUTION
' =====================================================================
Variable String SequenceFileName
Variable String Sequence
Variable String SequenceCmd
Variable Numeric SequenceIndex
Variable Numeric SequenceLength

Label ExecSequence
	Load Sequence SequenceFileName
	If Len(Sequence) = 0
		Controls OpenTextBox
		Print CRLF + " Sequence file not found: " + SequenceFileName
		Beep
		Stop
	EndIf
	SequenceLength = GetSeparatedStringCount(Sequence, CRLF)
	For SequenceIndex = 0 To SequenceLength-1
		SequenceCmd = GetSeparatedString(Sequence, SequenceIndex, CRLF)
		SequenceCmd = Replace(SequenceCmd, Chr(9), " ") 'TABS to SPACES
		SequenceCmd = RemoveComments(SequenceCmd)
		SequenceCmd = Trim(SequenceCmd)
		SequenceCmd = UCase(SequenceCmd)
		'
		Print " Executing command: " + SequenceCmd
		'
		Select SequenceCmd
			' ----------------------------------
			Case "ZERO"
				Gosub ZERO
			Case "ALL OUT"
				Gosub ALL OUT
			Case "POWER IN"
				Gosub POWER IN
			Case "ENABLE MOTORS"
				Gosub ENABLE MOTORS
			Case "DISABLE MOTORS"
				Gosub DISABLE MOTORS
			Case "PEN UP"
				Gosub PEN UP
			Case "PEN DOWN"
				Gosub PEN DOWN
			Case "PEN ACTION"
				Gosub PEN ACTION
			Case "POWER CYCLE"
				Gosub POWER CYCLE
			' ----------------------------------
			Case "HDMI IN"
				Gosub HDMI IN
			Case "HDMI OUT"
				Gosub HDMI OUT
			Case "USB3 IN"
				Gosub USB3 IN
			Case "USB3 OUT"
				Gosub USB3 OUT
			Case "USBC IN"
				Gosub USBC IN
			Case "USBC OUT"
				Gosub USBC OUT
			Case "USBPWR IN"
				Gosub USBPWR IN
			Case "USBPWR OUT"
				Gosub USBPWR OUT
			Case "POWER IN"
				Gosub POWER IN
			Case "POWER OUT"
				Gosub POWER OUT
			Case "MEMORY IN"
				Gosub MEMORY IN
			Case "MEMORY OUT"
				Gosub MEMORY OUT
			Case "HEARSET IN"
				Gosub HEARSET IN
			Case "HEARSET OUT"
				Gosub HEARSET OUT
			Case "ROTATE VERT"
				Gosub ROTATE VERT
			Case "ROTATE MIDL"
				Gosub ROTATE MIDL
			Case "ROTATE HORZ"
				Gosub ROTATE HORZ
			' ----------------------------------
			CaseElse
				s1 = GetSeparatedString(SequenceCmd, 0)
				Select s1
					Case "MOVE"
						DestX = GetSeparatedString(SequenceCmd, 1)
						DestY = GetSeparatedString(SequenceCmd, 2)
						Gosub CoreXY_MoveToDestXY_AndWait
					Case "PAUSE"
						Wait Seconds GetSeparatedString(SequenceCmd, 1)
					CaseElse
						If s1 <> ""
							Controls OpenTextBox
							Print CRLF + " Unrecognized command: " + SequenceCmd
							Beep
							Stop
						EndIf
				EndSelect
		EndSelect
	Next
Return



Variable Numeric DestX
Variable Numeric DestY
Variable Numeric SlotRotHV_Drive
Variable Numeric SlotRotHV_Current
Variable Numeric SlotRotHV_MaxCurrent

Label ROTATE HORZ
	Slot 998 = 1000			'start Signal Scope
	Slot SlotRotHV_Drive = 0
	Wait Seconds 0.3
	For v1 = 1 To 1300        ' <<< 1000 = 10 sec timeout (approx)
		Wait Seconds 0.009
		If Slot(SlotRotHV_Current) > SlotRotHV_MaxCurrent
			Slot SlotRotHV_Drive = 500
			Slot 998 = 0	'stop Signal Scope
			Button 12 Text ROTATE VERT
			Goto exit
		EndIf
	Next
	Slot SlotRotHV_Drive = 500
	Slot 998 = 0			'stop Signal Scope
	Button 12 Text ROTATE VERT
	'
Label exit
Return


