; TX-Controller - ab firmware 1.30 !!
; TX.dll ftMscLib (vom 13.11.2012)
to txinitgps :radius
output (.WINDOWS [|TX.dll| |txInitGPS|] :radius)
end

to txi2cread :dev :off :prot
output (.WINDOWS [|TX.dll| |txi2cread|] :dev :off :prot )
end
to txi2cwrite :dev :off :dat :prot
output (.WINDOWS [|TX.dll| |txi2cwrite|] :dev :off :dat :prot)
end
to txgpsbreite
output (.WINDOWS [|TX.dll| |txGetGPSBreite|])
end
to txgpslaenge
output (.WINDOWS [|TX.dll| |txGetGPSLaenge|])
end
to txgpszeit
output (.WINDOWS [|TX.dll| |txGetGPSZeit|])
end
to txgpsgesch
output (.WINDOWS [|TX.dll| |txGetGPSGesch|])
end
to txgpsgesch
output (.WINDOWS [|TX.dll| |txGetGPSGesch|])
end
to txgpsHoehe
output (.WINDOWS [|TX.dll| |txGetGPSHoehe|])
end
to txgpssat
output (.WINDOWS [|TX.dll| |txGetGPSSat|])
end
to txClose
if :@open [IGNORE (.WINDOWS [|TX.dll| |txCloseController|] )]
 make "@open "false
end
 make "@open "false
to txAnalog :AnalogNr
	output (.WINDOWS [|TX.dll| |txGetAnalog|] :ftiMain :AnalogNr - 1)
end
to txTrack :AnalogNr
	output (.WINDOWS [|TX.dll| |txGetTrack|] :ftiMain :AnalogNr - 1)
end
to txVoltage :VoltNr
	output (.WINDOWS [|TX.dll| |txGetVoltage|] :ftiMain :VoltNr - 1)
end

to txInput :InputNr
	output (.WINDOWS [|TX.dll| |txGetInput|] :ftiMain :InputNr - 1)<>0
end

to txdistance :nr
output (.WINDOWS [|TX.dll| |txGetDistance|] :ftiMain :nr - 1)
end

to txLamp :Nr :Speed
	IGNORE (.WINDOWS [|TX.dll| |txSetLamp|] :ftiMain :NR - 1 :Speed)
END
to txMOTOR :MotorNr :Direction :Speed
	IGNORE (.WINDOWS [|TX.dll| |txSetMotor|] :ftiMain :MOTORNR :DIRECTION :Speed)
END

to txStartMOTOR :MotorNr :Direction :Speed :icount :robmode
	IGNORE (.WINDOWS [|TX.dll| |txStartMotor|] :ftiMain :MOTORNR :DIRECTION :Speed :icount :robmode)
END
to txStartMotorSync :m1 :m2 :dir1 :dir2 :Speed :icount :mode	  ; mode = 0: Aktion als Threat
	IGNORE (.WINDOWS [|TX.dll| |txStartMotorSync|] :ftiMain :m1 :m2 :dir1 :dir2 :Speed :icount :mode)
END

to txMOTORReady :MotorNr 
		op (.WINDOWS [|TX.dll| |txIsMotorReady|] :ftiMain :MOTORNR)
END
to txAreMotorsReady :m1 :m2 
	  op (.WINDOWS [|TX.dll| |txAreMotorsReady|] :ftiMain :m1 :m2)
END
to txOpen :com
(local "TX)
	IF :@OPEN [STOP]
make "ftiMain 0
make "tx (.WINDOWS [|TX.dll| |txOpenController|] :com) ; output com 10
if :tx <> 0 [pr "Treiberfehler stop]
	MAKE "@OPEN "TRUE
END

to txGetCounter :Nr
	output (.WINDOWS [|TX.dll| |txGetCounter|] :ftiMain :Nr - 1)
end

to txClearCounter :nr
	IGNORE (.WINDOWS [|TX.dll| |txClearCounter|] :ftiMain :Nr - 1)
END

to TXSLEEP :ms
	IGNORE (.WINDOWS [|TX.dll| |txSleep|] :ms )
END
to TXESC
 output 0 <> (.WINDOWS [|TX.dll| |txEsc|] )
end
to TXGETTICKCOUNT
 output (.WINDOWS [|TX.dll| |txGetTickCount|])
end
to TXPIXY 
    IGNORE (.WINDOWS [|TX.dll| |txpixy|] )
END
to TXGETPIXYCHECK
 output (.WINDOWS [|TX.dll| |txGetPixyCheck|])
end
to TXGETPIXYOBJEKT
 output (.WINDOWS [|TX.dll| |txGetPixyObjekt|])
end
to TXGETPIXYX_CENT
 output (.WINDOWS [|TX.dll| |txGetPixyx_cent|])
end
to TXGETPIXYY_CENT
 output (.WINDOWS [|TX.dll| |txGetPixyy_cent|])
end
to TXGETPIXYBREITE
 output (.WINDOWS [|TX.dll| |txGetPixybreite|])
end
to TXGETPIXYHOEHE
 output (.WINDOWS [|TX.dll| |txGetPixyhoehe|])
end
to TXPIXYBEFEHLE
pr [TXPIXY TXGETPIXYCHECK TXGETPIXYOBJEKT TXGETPIXYX_CENT TXGETPIXYY_CENT TXGETPIXYBREITE TXGETPIXYHOEHE]
end
to TXGPSBEFEHLE
pr [txinitgps txgpsbreite txgpslaenge txgpsHoehe txgpsgesch txgpszeit txgpssat]
end
TO PIXYTEST 
	WHILE [TRUE] [TXPIXY (PR TXGETPIXYCHECK TXGETPIXYOBJEKT TXGETPIXYX_CENT TXGETPIXYY_CENT TXGETPIXYBREITE TXGETPIXYHOEHE)]
END
to txbefehle
pr [txopen txClose txmotor txlamp txinput txtrack txdistance txanalog txvoltage]
pr [txgetCounter txClearCounter txstartmotor txmotorready txStartMotorSync txAreMotorsReady]
pr [txi2cread txi2cwrite txsleep txesc txgettickcount]
pr "|Motor -> C-Eingang : m1 -> 1 m2 -> 2 usw.|
pr "|StartMotor: mode = 0: Vorgang läuft als Threat;  mode = 1: Abbruch mit Space|
end

To Touches :@list; [:@list []]
 Local "tlist Make "tlist []
 If Empty? :@list [Output .Touch allturtles] [Output .Touch :@list]
End

To .Touch :@list
 If Empty? :@list [output :tlist]
 If Word? Who [Make "@who (list who)] [make "@who who]
 If And Touching? First :@list Not.Equal? First :@list First :@who [make "tlist lput First :@list :tlist]
 Output .Touch Butfirst :@list
End 
BuryProc [Touches .Touch]
BuryProc [TXGPSBEFEHLE txinitgps txgpsbreite txgpsHoehe txgpslaenge txgpsgesch txgpszeit txgpssat]
BuryProc [txopen txClose txANALOG txtrack txopen txinput txdistance txlamp txmotor txstartmotor]
Buryproc [txVoltage txmotorready txgetCounter txClearCounter txbefehle txi2cread txi2cwrite]
BuryProc [TXGETTICKCOUNT txStartMotorSync txAreMotorsReady TXESC TXSLEEP PIXYTEST]
BuryProc [TXPIXYBEFEHLE TXPIXY TXGETPIXYCHECK TXGETPIXYOBJEKT TXGETPIXYX_CENT TXGETPIXYY_CENT TXGETPIXYBREITE TXGETPIXYHOEHE]
