Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/lib/support/drivers/stmtr.lua
blob: 9bd9b406eb307bf90848387cec8bf5ff7651d95a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
local device = _G

api={}
api.rawspeed = {}
api.rawspeed.parameters = {[1]={rname="speed1", rtype="int", min=-5, max=5}, [2]={rname="speed2", rtype="int", min=-5, max=5}}
api.rawspeed.returns = {}
api.rawspeed.call = function (speed1, speed2)
	local msg = string.char(0x02,speed1,speed2)
	device:send(msg)
	device:read()
end

api.t0cfg = {}
api.t0cfg.parameters = {[1]={rname="t0_low", rtype="int", min=0, max=255}, [2]={rname="t0_high", rtype="int", min=0, max=255}}
api.t0cfg.returns = {}
api.t0cfg.call = function (t0_low, t0_high)
	local msg = string.char(0x01,t0_low,t0_high)
	device:send(msg)
	device:read()
end

api={}
api.speed = {}
api.speed.parameters = {[1]={rname="vel1", rtype="float", min=-127, max=127}, 
			[2]={rname="vel2", rtype="float", min=-127, max=127}}
api.speed.returns = {}
api.speed.call = function (vel1, vel2)
	vel1=tonumber(vel1)
	vel2=tonumber(vel2)
	
	local speed1, speed2
	if vel1>=0 then
		speed1=vel1
	else
		speed1=0xFF + vel1 + 1
	end
	if vel2>=0 then
		speed2=vel2
	else
		speed2=0xFF + vel2 + 1
	end

	local msg = string.char(0x02,speed1,speed2)
	device:send(msg)
	device:read()
end