
' ------------------------------------------------- Toolbar commands
Button 1 Label Title1
Button Title1 Label "Toolbar commands"
Button Title1 Color Green2
Button 2 Label Recognize
Button 3 Label Validate
Button 4 Label ErrorBeepON
Button 5 Label ErrorBeepOFF
Button 7 Label LockON
Button 8 Label LockOFF
Button 9 Label Disconnect
Button 10 Label NoEditsON
Button 11 Label NoEditsOFF
Button 12 Label Calibrate
Button 13 Label Calibration33
' ------------------------------------------------- Master properties
Button 17 Label Title2
Button Title2 Label "Master properties"
Button Title2 Color Green2
Button 18 Label SelectMaster1
Button 19 Label SelectMaster2

Button 21 Label LoadConfig1
Button 22 Label LoadConfig2
Button 23 Label LoadConfig3

Button 25 Label SpeedRandom
Button 26 Label FastExchangeON
Button 27 Label FastExchangeOFF

' ------------------------------------------------- Select Pin
Button 29 Label SelectPinRandom
Button SelectPinRandom Text "Select Pin by Number" + CRLF + "Random"

Button 30 Label SelectPinByName
Button SelectPinByName Text "Select Pin by Name" + CRLF + "for IotHAL and NetHAL"

Button 32 Label ResetCounters

' ------------------------------------------------- Pin properties
Button 33 Label Title3
Button Title3 Label "Pin properties"
Button Title3 Color Green2

Button 34 Label SetPinTypeRandom
Button SetPinTypeRandom Text "SetPinType" + CRLF + "Random"

Button 35 Label SetSlotRandom
Button SetSlotRandom Text "SetSlot" + CRLF + "Random"

Button 36 Label SetMaxValueRandom
Button SetMaxValueRandom Text "SetMaxValue" + CRLF + "Random"
Button 37 Label SetMinValueRandom
Button SetMinValueRandom Text "SetMinValue" + CRLF + "Random"

Button 38 Label SetResponseSpeedButtonON
Button SetResponseSpeedButtonON Text "ResponseSpeedButton" + CRLF + "ON"
Button 39 Label SetResponseSpeedButtonOFF
Button SetResponseSpeedButtonOFF Text "ResponseSpeedButton" + CRLF + "OFF"
Button 40 Label SetResponseSpeedRandom
Button SetResponseSpeedRandom Text "SetResponseSpeed" + CRLF + "Random"

' ------------------------------------------------- PWM and Servo properties
Button 42 Label Title4
Button Title4 Label "PWM and SERVO"
Button Title4 Color Green2
Button 43 Label MaxTimeRandom
Button 44 Label MinTimeRandom
Button 45 Label LogResponseON
Button 46 Label LogResponseOFF

' ------------------------------------------------- Stepper properties
Button 49 Label Title5
Button Title5 Label "STEPPERS"
Button Title5 Color Green2
Button 50 Label MaxSpeedRandom
Button MaxSpeedRandom Text "MaxSpeed" + CRLF + "Random"
Button 51 Label MaxAccRandom
Button MaxAccRandom Text "MaxAcc" + CRLF + "Random"
Button 52 Label StepsPerMmRandom
Button StepsPerMmRandom Text "StepsPerMm" + CRLF + "Random"
Button 53 Label LinkedtoPreviousON
Button LinkedtoPreviousON Text "LinkedtoPrevious" + CRLF + "ON"
Button 54 Label LinkedtoPreviousOFF
Button LinkedtoPreviousOFF Text "LinkedtoPrevious" + CRLF + "OFF"

' ------------------------------------------------- Pwm_Fast properties
Button 56 Label Title6
Button Title6 Label "PWM FAST"
Button Title6 Color Green2
Button 57 Label PwmFastFrequencyRandom
Button PwmFastFrequencyRandom Text "PwmFastFrequency" + CRLF + "Random"
Button 58 Label PwmFastDutyCycleRandom
Button PwmFastDutyCycleRandom Text "PwmFastDutyCycle" + CRLF + "Random"
Button 59 Label FrequencyFromSlotON
Button FrequencyFromSlotON Text "FrequencyFromSlot" + CRLF + "ON"
Button 60 Label FrequencyFromSlotOFF
Button FrequencyFromSlotOFF Text "FrequencyFromSlot" + CRLF + "OFF"
Button 61 Label DutyCycleFromSlotON
Button DutyCycleFromSlotON Text "DutyCycleFromSlot" + CRLF + "ON"
Button 62 Label DutyCycleFromSlotOFF
Button DutyCycleFromSlotOFF Text "DutyCycleFromSlot" + CRLF + "OFF"

' ------------------------------------------------- Touch properties (cap)
Button 65 Label Title7
Button Title7 Label "TOUCH (cap)"
Button Title7 Color Green2
Button 66 Label MinVariationRandom
Button MinVariationRandom Text "MinVariation" + CRLF + "Random"
Button 67 Label ProportionalAreaRandom
Button ProportionalAreaRandom Text "ProportionalArea" + CRLF + "Random"

' ------------------------------------------------- Freq. properties (counter/fastcounter/period/slowperiod)
Button 69 Label Title8
Button Title8 Label "FREQUENCY FOR" + CR + "COUNTERS and PERIOD"
Button Title8 Color Green2
Button 70 Label ConvertToFrequencyON
Button ConvertToFrequencyON Text "ConvertToFrequency" + CRLF + "ON"
Button 71 Label ConvertToFrequencyOFF
Button ConvertToFrequencyOFF Text "ConvertToFrequency" + CRLF + "OFF"
Button 72 Label MaxFreqRandom
Button 73 Label MinFreqRandom

' ------------------------------------------------- CapSensor and Ultrasound properties (usound sensor)
Button 75 Label Title9
Button Title9 Label "CAPSENSOR and USOUND"
Button Title9 Color Green2
Button 76 Label MaxDistRandom
Button 77 Label MinDistRandom
Button 78 Label AreaRandom
Button 79 Label RemoveErrorsON
Button 80 Label RemoveErrorsOFF

' ------------------------------------------------- Adc24 properties
Button 81 Label Title10
Button Title10 Label "ADC24 MAIN PIN"
Button Title10 Color Green2
Button 82 Label NumberOfPinsRandom
Button NumberOfPinsRandom Text "NumberOfPins" + CRLF + "Random"
Button 83 Label SamplesSecRandom
Button SamplesSecRandom Text "SamplesSec" + CRLF + "Random"
Button 84 Label FilterRandom
Button FilterRandom Text "Filter" + CRLF + "Random"

' ------------------------------------------------- Adc24 channel properties
Button 86 Label Title11
Button Title11 Label "ADC24 PIN PROPS"
Button Title11 Color Green2
Button 87 Label TypeRandom
Button 88 Label GainRandom
Button 89 Label BiasedON
Button 90 Label BiasedOFF

' ------------------------------------------------- GET PROPS
Button 92 Label Title12
Button Title12 Label "GET PROPS"
Button Title12 Color Green2
Button 93 Label GetMasterName
Button 94 Label GetFPS
Button 95 Label GetPinType


' =============================================================
'  START AND STOP PROGRAM
' =============================================================
Variable Numeric Slot_Commands = 0
Variable Numeric Slot_Responses = 1

Load Theremino_SlotViewer.exe
'Window MinSize
Stop

Label EventStop
	'For v1 = 0 To 128
	'	Button v1 Text ""
	'Next
	'Window Sizable
End


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


' =============================================================
'  COMMANDS
' =============================================================

' ----------------------------------------------------- Toolbar commands
Label Recognize
	SendCommand("Recognize")
Return
Label Validate
	SendCommand("Validate")
Return
Label ErrorBeepON
	SendCommand("ErrorBeep 1")
Return
Label ErrorBeepOFF
	SendCommand("ErrorBeep 0")
Return
Label LockON
	SendCommand("LockMasters 1")
Return
Label LockOFF
	SendCommand("LockMasters 0")
Return
Label Disconnect
	SendCommand("Disconnect")
Return
Label NoEditsON
	SendCommand("NoEdits 1")
Return
Label NoEditsOFF
	SendCommand("NoEdits 0")
Return
Label Calibrate
	SendCommand("Calibrate")
Return
Label Calibration33
	SendCommand("CalibrationValue 33")
Return

  ' ------------------------------------------------- Master properties
Label SelectMaster1
	SendCommand("SelectMaster 1")
Return
Label SelectMaster2
	SendCommand("SelectMaster 2")
Return

Label LoadConfig1
	SendCommand("LoadConfig Test1")
Return
Label LoadConfig2
	SendCommand("LoadConfig Test2")
Return
Label LoadConfig3
	SendCommand("LoadConfig Test3")
Return
Label SpeedRandom
	SendCommand("Speed " + Int(1 + Rnd * 12))
Return

Label FastExchangeON
	SendCommand("FastDataExchange 1")
Return
Label FastExchangeOFF
	SendCommand("FastDataExchange 0")
Return

 ' ------------------------------------------------- Select Pins
Label SelectPinRandom
	SendCommand("SelectPin " + Int(1 + Rnd * 20))
Return

Label SelectPinByName
	s1 = Input "Pin name ?"
	SendCommand("SelectPin " + s1)
Return

'
Label ResetCounters
	SendCommand("ResetCounters")
Return


' ------------------------------------------------- Pin properties
Label SetPinTypeRandom
	Select Int(Rnd * 16)
		Case 0
			SendCommand("SetPinType unUsed")
		Case 1
			SendCommand("SetPinType dig-out")
		Case 2
			SendCommand("SetPinType pwm 16")
		Case 3
			SendCommand("SetPinType servo 16")
		Case 4
			SendCommand("SetPinType pwm fast")
		Case 5
			SendCommand("SetPinType DIGIN pu")
		Case 6
			SendCommand("SetPinType cap16")
		Case 7
			SendCommand("SetPinType res16")
		Case 8
			SendCommand("SetPinType adc16")
		Case 9
			SendCommand("SetPinType COUNTER pu")
		Case 10
			SendCommand("SetPinType fast counterPU")
		Case 11
			SendCommand("SetPinType PeRiOD---pu")
		Case 12
			SendCommand("SetPinType usound---sensor")
		Case 13
			SendCommand("SetPinType encoder_a pu")
		Case 14
			SendCommand("SetPinType SlowPeriodPu")
		Case 15
			SendCommand("SetPinType Adc24")
	EndSelect
Return

Label SetSlotRandom
	SendCommand("SetSlot " + Int(1 + Rnd * 99))
Return

Label SetMaxValueRandom
	SendCommand("SetMaxValue " + Int(Rnd * 10000) / 10)
Return
Label SetMinValueRandom
	SendCommand("SetMinValue " + Int(Rnd * 10000) / 10)
Return

Label SetResponseSpeedButtonON
	SendCommand("SetResponseSpeedButton 1")
Return
Label SetResponseSpeedButtonOFF
	SendCommand("SetResponseSpeedButton 0")
Return
Label SetResponseSpeedRandom
	SendCommand("SetResponseSpeed " + Int(1 + Rnd * 100))
Return

' ------------------------------------------------- PWM and Servo properties
Label MaxTimeRandom
	SendCommand("MaxTime " + Int(Rnd * 100))
Return
Label MinTimeRandom
	SendCommand("MinTime " + Int(Rnd * 100))
Return
Label LogResponseON
	SendCommand("LogarithmicResponse 1")
Return
Label LogResponseOFF
	SendCommand("LogarithmicResponse 0")
Return

' ------------------------------------------------- Stepper properties
Label MaxSpeedRandom
	SendCommand("MaxSpeed " + Int(Rnd * 10000) / 10)
Return
Label MaxAccRandom
	SendCommand("MaxAcc " + Int(Rnd * 1000) / 10)
Return
Label StepsPerMmRandom
	SendCommand("StepsPerMm " + Int(Rnd * 100) / 10)
Return
Label LinkedtoPreviousON
	SendCommand("LinkedtoPrevious 1")
Return
Label LinkedtoPreviousOFF
	SendCommand("LinkedtoPrevious 0")
Return

' ------------------------------------------------- Pwm_Fast properties
Label PwmFastFrequencyRandom
	SendCommand("PwmFastFrequency " + Int(Rnd * 100000))
Return
Label PwmFastDutyCycleRandom
	SendCommand("PwmFastDutyCycle " + Int(Rnd * 1000))
Return
Label FrequencyFromSlotON
	SendCommand("FrequencyFromSlot 1")
Return
Label FrequencyFromSlotOFF
	SendCommand("FrequencyFromSlot 0")
Return
Label DutyCycleFromSlotON
	SendCommand("DutyCycleFromSlot 1")
Return
Label DutyCycleFromSlotOFF
	SendCommand("DutyCycleFromSlot 0")
Return

' ------------------------------------------------- Touch properties (cap)
Label MinVariationRandom
	SendCommand("MinVariation " + Int(Rnd * 1000 - 500))
Return
Label ProportionalAreaRandom
	SendCommand("ProportionalArea " + Int(Rnd * 1000 - 500))
Return

' ------------------------------------------------- Freq. properties (counter/fastcounter/period/slowperiod)
Label ConvertToFrequencyON
	SendCommand("ConvertToFrequency 1")
Return
Label ConvertToFrequencyOFF
	SendCommand("ConvertToFrequency 0")
Return
Label MaxFreqRandom
	SendCommand("MaxFreq " + Int(Rnd * 10000))
Return
Label MinFreqRandom
	SendCommand("MinFreq " + Int(Rnd * 10000))
Return

' ------------------------------------------------- CapSensor and Ultrasound properties (usound sensor)
Label MaxDistRandom
	SendCommand("MaxDist " + Int(50 + Rnd * 9000))
Return
Label MinDistRandom
	SendCommand("MinDist " + Int(Rnd * 5000))
Return
Label AreaRandom
	SendCommand("Area " + Int(Rnd * 1000))
Return
Label RemoveErrorsON
	SendCommand("RemoveErrors 1")
Return
Label RemoveErrorsOFF
	SendCommand("RemoveErrors 0")
Return

' ------------------------------------------------- Adc24 properties
Label NumberOfPinsRandom
	SendCommand("NumberOfPins " + Int(Rnd * 16))
Return
Label SamplesSecRandom
	Select Int(Rnd * 21)
		Case 0
			SendCommand("SamplesSec 19200")
		Case 1
			SendCommand("SamplesSec 9600")
		Case 2
			SendCommand("SamplesSec 4800")
		Case 3
			SendCommand("SamplesSec 3840")
		Case 4
			SendCommand("SamplesSec 3200")
		Case 5
			SendCommand("SamplesSec 2400")
		Case 6
			SendCommand("SamplesSec 1600")
		Case 7
			SendCommand("SamplesSec 1200")
		Case 8
			SendCommand("SamplesSec 1000")
		Case 9
			SendCommand("SamplesSec 600")
		Case 10
			SendCommand("SamplesSec 500")
		Case 11
			SendCommand("SamplesSec 300")
		Case 12
			SendCommand("SamplesSec 200")
		Case 13
			SendCommand("SamplesSec 120")
		Case 14
			SendCommand("SamplesSec 100")
		Case 15
			SendCommand("SamplesSec 60")
		Case 16
			SendCommand("SamplesSec 50")
		Case 17
			SendCommand("SamplesSec 30")
		Case 18
			SendCommand("SamplesSec 20")
		Case 19
			SendCommand("SamplesSec 12")
		Case 20
			SendCommand("SamplesSec 10")
	EndSelect
Return
Label FilterRandom
	Select Int(Rnd * 8)
		Case 0
			SendCommand("Filter Max Speed")
		Case 1
			SendCommand("Filter Fast")
		Case 2
			SendCommand("Filter Medium")
		Case 3
			SendCommand("Filter Slow")
		Case 4
			SendCommand("Filter Post Max")
		Case 5
			SendCommand("Filter Post Fast")
		Case 6
			SendCommand("Filter Post Medium")
		Case 7
			SendCommand("Filter Post Slow")
	EndSelect
Return

' ------------------------------------------------- Adc24 channel properties
Label TypeRandom
	Select Int(Rnd * 3)
		Case 0
			SendCommand("Type Differential")
		Case 1
			SendCommand("Type Pseudo Diff")
		Case 2
			SendCommand("Type Single Ended")
	EndSelect
Return
Label GainRandom
	Select Int(Rnd * 8)
		Case 0
			SendCommand("Gain 1")
		Case 1
			SendCommand("Gain 2")
		Case 2
			SendCommand("Gain 4")
		Case 3
			SendCommand("Gain 8")
		Case 4
			SendCommand("Gain 16")
		Case 5
			SendCommand("Gain 32")
		Case 6
			SendCommand("Gain 64")
		Case 7
			SendCommand("Gain 128")
	EndSelect
Return
Label BiasedON
	SendCommand("Biased 1")
Return
Label BiasedOFF
	SendCommand("Biased 0")
Return

' ------------------------------------------------- GET
Label GetMasterName
	SendCommand("GetMasterName")
	Print SlotText(Slot_Responses)
Return
Label GetFPS
	SendCommand("GetFPS")
	Print SlotText(Slot_Responses)
Return
Label GetPinType
	SendCommand("GetPinType")
	Print SlotText(Slot_Responses)
Return


'BOOKMARKS 

'EDITEDLINES 170 4 177 5 174 6 38 7 277 8 274 9 276 10 

'WATCH SewTo_Speed
'EXEC Button 5 Text Button5
