diff options
Diffstat (limited to 'lib/support/drivers/hotplug/tilt.lua')
-rw-r--r-- | lib/support/drivers/hotplug/tilt.lua | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/support/drivers/hotplug/tilt.lua b/lib/support/drivers/hotplug/tilt.lua new file mode 100644 index 0000000..1076479 --- /dev/null +++ b/lib/support/drivers/hotplug/tilt.lua @@ -0,0 +1,19 @@ +local device = _G + +api={} +api.getTilt = {} +api.getTilt.parameters = {} -- -- no input parameters +api.getTilt.returns = {[1]={rname="par1", rtype="int"}} +api.getTilt.call = function () + device:send(string.char(0x00)) -- codigo de operacion 0 + local sen_dig_response = device:read(3) + local raw_val + if not sen_dig_response or string.byte(sen_dig_response or "00000000", 2) == nil or string.byte(sen_dig_response or "00000000", 3) == nil + then + raw_val = "nil value" + else + raw_val = string.byte(sen_dig_response, 3) % 2 + end + return raw_val + +end |