Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/lib/support/drivers/motorin.lua
blob: 042f3cc3204267f099e20646f22e918ed330b807 (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
local device = _G

api={}
api.speed = {}
api.speed.parameters = {[1]={rname="freq", rtype="int", min=0, max=65536}}
api.speed.returns = {}
api.speed.call = function (freq)
	local msg = string.char(0x02) .. string.char(math.floor(freq / 256)) .. string.char(freq % 256)
	device:send(msg)
	device:read(1)
end

api.steps = {}
api.steps.parameters = {[1]={rname="number", rtype="int", min=0, max=65536}}
api.steps.returns = {}
api.steps.call = function (number)
	local msg = string.char(0x03) .. string.char(math.floor(number / 256)) .. string.char(number % 256)
	device:send(msg)
	device:read(1)
end

api.on = {}
api.on.parameters = {[1]={rname="direction", rtype="int", min=-1, max=1}}
api.on.returns = {}
api.on.call = function (dir)
	local msg = string.char(0x01) .. string.char(dir+1)
	device:send(msg)
end