Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/lib/support/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'lib/support/drivers')
-rw-r--r--lib/support/drivers/admin.lua11
-rw-r--r--lib/support/drivers/ax.lua118
-rw-r--r--lib/support/drivers/boot.lua11
-rw-r--r--lib/support/drivers/boton.lua19
-rw-r--r--lib/support/drivers/butia.lua39
-rw-r--r--lib/support/drivers/buzzer.lua51
-rw-r--r--lib/support/drivers/debug.lua39
-rw-r--r--lib/support/drivers/display.lua99
-rw-r--r--lib/support/drivers/dist.lua25
-rw-r--r--lib/support/drivers/dynamix.lua34
-rw-r--r--lib/support/drivers/gas.lua20
-rw-r--r--lib/support/drivers/grises.lua19
-rw-r--r--lib/support/drivers/hotplug/button.lua32
-rw-r--r--lib/support/drivers/hotplug/distanc.lua32
-rw-r--r--lib/support/drivers/hotplug/gpio.lua19
-rw-r--r--lib/support/drivers/hotplug/grey.lua32
-rw-r--r--lib/support/drivers/hotplug/light.lua32
-rw-r--r--lib/support/drivers/hotplug/port.lua19
-rw-r--r--lib/support/drivers/hotplug/tilt.lua19
-rw-r--r--lib/support/drivers/hotplug/vibra.lua19
-rw-r--r--lib/support/drivers/lback.lua21
-rw-r--r--lib/support/drivers/led.lua17
-rw-r--r--lib/support/drivers/ledA.lua46
-rw-r--r--lib/support/drivers/ledR.lua31
-rw-r--r--lib/support/drivers/ledV.lua31
-rw-r--r--lib/support/drivers/leds.lua43
-rw-r--r--lib/support/drivers/luz.lua21
-rw-r--r--lib/support/drivers/magnet.lua21
-rw-r--r--lib/support/drivers/motor.lua42
-rw-r--r--lib/support/drivers/motorTm.lua47
-rw-r--r--lib/support/drivers/motores.lua48
-rw-r--r--lib/support/drivers/motorin.lua28
-rw-r--r--lib/support/drivers/motors.lua70
-rw-r--r--lib/support/drivers/move.lua16
-rw-r--r--lib/support/drivers/pnp.lua0
-rw-r--r--lib/support/drivers/pote.lua16
-rw-r--r--lib/support/drivers/puerta.lua31
-rw-r--r--lib/support/drivers/sec.lua87
-rw-r--r--lib/support/drivers/sensor.lua52
-rw-r--r--lib/support/drivers/stmtr.lua46
-rw-r--r--lib/support/drivers/temp.lua28
-rw-r--r--lib/support/drivers/temp_lubot.lua20
42 files changed, 0 insertions, 1451 deletions
diff --git a/lib/support/drivers/admin.lua b/lib/support/drivers/admin.lua
deleted file mode 100644
index c3e3da9..0000000
--- a/lib/support/drivers/admin.lua
+++ /dev/null
@@ -1,11 +0,0 @@
-local device = _G
-local RESET = string.char(0xFF)
-
-api={}
-api.reset = {}
-api.reset.parameters = {}
-api.reset.returns = {}
-api.reset.call = function (data)
- device:send(RESET)
-end
-
diff --git a/lib/support/drivers/ax.lua b/lib/support/drivers/ax.lua
deleted file mode 100644
index d505511..0000000
--- a/lib/support/drivers/ax.lua
+++ /dev/null
@@ -1,118 +0,0 @@
-local device = _G
-local WRITE_INFO = 0x01
-local READ_INFO = 0x02
-local GET_RAW_POS = 0x03
-local char000 = string.char(0,0,0)
-local mode='wheel'
-
---byte id,byte regstart, int value
-api={}
-api.write_info = {}
-api.write_info.parameters = {[1]={rname="id", rtype="number", min=0, max=255},[2]={rname="regstart", rtype="number", min=0, max=255},[3]={rname="value", rtype="number", min=0, max=65536}} ----byte id,byte regstart, int value
-api.write_info.returns = {[1]={rname="write_info_return", rtype="number"}} --one return
-api.write_info.call = function (id, regstart, value)
- id, regstart, value = tonumber(id), tonumber(regstart), tonumber(value)
- local write_info_payload = string.char(WRITE_INFO, id, regstart, math.floor(value / 256),value % 256)
- device:send(write_info_payload)
- local write_info_response = device:read(2) or char000
- local raw_val = (string.byte(write_info_response, 2) or 0)
- return raw_val
-end
-
---- Set wheel mode.
---Set the motor to continuous rotation mode.
-api.wheel_mode = {}
-api.wheel_mode.parameters = {[1]={rname="id", rtype="number", min=0, max=255}}
-api.wheel_mode.returns = {}
-api.wheel_mode.call = function (id )
- id = tonumber(id)
- local ret = device:send(string.char(WRITE_INFO,id,0x06,0x00,0x00))
- local write_info_response = device:read(1) or string.char(0,0)
- local ret = device:send(string.char(WRITE_INFO,id,0x08,0x00,0x00))
- local write_info_response = device:read(1) or string.char(0,0)
- mode='wheel'
- end
-
---- Set joint mode.
--- Set the motor to joint mode. Angles are provided in degrees,
--- in the full servo coverage (0 - 300 degrees arc)
--- @param min the minimum joint angle (defaults to 0)
--- @param max the maximum joint angle (defaults to 300)
-api.joint_mode = {}
-api.joint_mode.parameters = {[1]={rname="id", rtype="number", min=0, max=255},[2]={rname="minimo", rtype="number", min=0, max=1023},[3]={rname="maximo", rtype="number", min=0, max=1023}}
-api.joint_mode.returns = {}
-api.joint_mode.call = function (id ,minimo, maximo)
- id = tonumber(id)
- minimo=tonumber(minimo)
- maximo=tonumber(maximo)
- local ret = device:send(string.char(WRITE_INFO,id,0x06,math.floor(minimo / 256),minimo % 256))
- local write_info_response = device:read(1) or string.char(0,0)
- local ret = device:send(string.char(WRITE_INFO,id,0x08,math.floor(maximo / 256),maximo % 256))
- local write_info_response = device:read(1) or string.char(0,0)
- mode='joint'
- end
-
-
---- Set motor position.
--- Set the target position for the motor's axle. Only works in
--- joint mode.
--- @param value Angle in degrees, in the 0 .. 300deg range.
-api.set_position = {}
-api.set_position.parameters = {[1]={rname="id", rtype="number", min=0, max=255},[2]={rname="pos", rtype="number", min=0, max=1023}}
-api.set_position.returns = {}
-api.set_position.call = function (id, pos )
- id = tonumber(id)
- pos = tonumber(pos)
- local ret = device:send(string.char(WRITE_INFO,id,0x1E,math.floor(pos / 256),pos % 256))
- local write_info_response = device:read(1) or string.char(0,0)
- end
-
-
---- Get motor position.
--- Read the axle position from the motor.
--- @return The angle in deg. The reading is only valid in the
--- 0 .. 300deg range
-api.get_position = {}
-api.get_position.parameters = {[1]={rname="id", rtype="number", min=0, max=255},[2]={rname="pos", rtype="number", min=0, max=1023}}
-api.get_position.returns = {[1]={rname="motor_position", rtype="number"}} --one return
-api.get_position.call = function(id)
- local send_response = device:send(string.char(GET_RAW_POS,id))
- local value = device:read(3) or string.char(0,0,0)
- local h_value = string.byte(value, 2)
- local l_value = string.byte(value, 3)
- local raw_angle = 256 * h_value + l_value
- local ang=0.29*(raw_angle) -- deg ?
- return raw_angle
-
- end
-
-
---- Set motor speed.
--- @param value If motor in joint mode, speed in deg/sec in the 1 .. 684 range
--- (0 means max available speed).
--- If in wheel mode, as a fraction of max torque (in the -1 .. 1 range).
-api.set_speed = {}
-api.set_speed.parameters = {[1]={rname="id", rtype="number", min=0, max=255},[2]={rname="speed", rtype="number", min=-1, max=684}}
-api.set_speed.returns = {} --no return
-api.set_speed.call = function(id, speed)
- --if mode=='joint' then
- -- 0 .. 684 deg/sec
- local vel=math.floor(speed * 1.496)
- local lowb = math.floor(vel/ 256)
- local highb = vel % 256
-
-
- --local lowb, highb = get2bytes_unsigned(vel)
- local ret = device:send(id,0x20,string.char(lowb,highb))
- print ("ret= ",ret, " lowb= ", lowb, " highb= ", highb)
- if ret then return ret:byte() end
- --else --mode=='wheel'
- -- -1 .. +1 max torque
- --local vel=math.floor(speed * 1023)
- --local lowb, highb = get2bytes_signed(vel)
- --local ret = device:send(id,0x20,string.char(lowb,highb))
- --if ret then return ret:byte() end
- --end
-end
-
-
diff --git a/lib/support/drivers/boot.lua b/lib/support/drivers/boot.lua
deleted file mode 100644
index 2471ab9..0000000
--- a/lib/support/drivers/boot.lua
+++ /dev/null
@@ -1,11 +0,0 @@
-local device = _G
-local RESET = string.char(0xFF)
-
-api={}
-api.reset = {}
-api.reset.parameters = {} --no parameters
-api.reset.returns = {} --no returns
-api.reset.call = function ()
- device:send(RESET)
-end
-
diff --git a/lib/support/drivers/boton.lua b/lib/support/drivers/boton.lua
deleted file mode 100644
index 4f846c9..0000000
--- a/lib/support/drivers/boton.lua
+++ /dev/null
@@ -1,19 +0,0 @@
-local device = _G
-
-local GET_VALUE=string.char(0x00)
-local string_byte=string.byte
-
--- description: lets us know button's current status
--- input: empty
--- output: button's current status. Possible status: 1 pressed - 0 not pressed
-api={}
-api.getValue = {}
-api.getValue.parameters = {} -- no input parameters
-api.getValue.returns = {[1]={rname="state", rtype="int"}}
-api.getValue.call = function ()
- device:send(GET_VALUE) -- operation code 1 = get button's status
- local sen_dig_response = device:read(2) -- 2 bytes to read (opcode, data)
- if not sen_dig_response or #sen_dig_response~=2 then return -1 end
- local raw_val = string_byte(sen_dig_response, 2) or 0 -- keep data
- return raw_val
-end
diff --git a/lib/support/drivers/butia.lua b/lib/support/drivers/butia.lua
deleted file mode 100644
index b29c9f1..0000000
--- a/lib/support/drivers/butia.lua
+++ /dev/null
@@ -1,39 +0,0 @@
-local device = _G
-local RD_VERSION = string.char(0x02) -- lee la versión del firmware de la placa (Igual para 1.0 y 2.0)
-local GET_VOLT = string.char(0x03) -- obtiene el voltage de la batería (Igual para 1.0 y 2.0)
-
-api={}
-api.read_ver = {}
-api.read_ver.parameters = {}
-api.read_ver.returns = {[1]={rname="data", rtype="string"}}
-api.read_ver.call = function (data)
- device:send(RD_VERSION)
- local devolver = -1
- local ret = device:read(2)
- if ret then
- devolver = string.byte(ret , 2) --leo el segundo byte obtenido que tiene la versión (el primero tiene el opcode)
- end
- --local devolver = (string.byte(version_response,2) or 0) + (string.byte(version_response,3) or 0)* 256
- return devolver
-end
-
-api.get_volt = {}
-api.get_volt.parameters = {} -- no se envian parámetros
-api.get_volt.returns = {[1]={rname="volts", rtype="string"}} --nos devuelve el voltaje de las baterías
-api.get_volt.call = function ()
- device:send(GET_VOLT) --envío el código de operación
- local data_in = device:read(2) --leo 2 bytes, primero el código de operación y segundo el voltaje
- local voltaje = string.byte(data_in or "00000000" , 2) --leo el segundo byte obtenido que es el que tiene el voltaje
- --local resultado = string.char(math.floor(voltNum / 10),".",tonumber(volNum) % 256, " volts")
- return voltaje
-end
-
---[[
-function bytesToString(data)
- local data_hex = ""
- for i=1, string.len(data) do
- data_hex = data_hex .. string.format('%02X', (string.byte(data, i)))
- end
- return data_hex
-end
---]]
diff --git a/lib/support/drivers/buzzer.lua b/lib/support/drivers/buzzer.lua
deleted file mode 100644
index a2ede05..0000000
--- a/lib/support/drivers/buzzer.lua
+++ /dev/null
@@ -1,51 +0,0 @@
-local device = _G
-local RD_VERSION = string.char(0x00)
-local PRENDER = string.char(0x01)
-local APAGAR = string.char(0x02)
-local BUZZER_CORTO = string.char(0x03)
-local BUZZER_TRIPLE = string.char(0x04)
-
-api={}
-api.read_version = {}
-api.read_version.parameters = {} --no parameters
-api.read_version.returns = {[1]={rname="version", rtype="number"}} --one return
-api.read_version.call = function ()
- local get_read_version = RD_VERSION
- device:send(get_read_version)
- local version_response = device:read(2)
- local raw_val = string.byte(version_response, 2)
- --print("rawval, deg_temp: ", raw_val, deg_temp)
- return raw_val
-end
-
-api.prender = {}
-api.prender.parameters = {} --no parameters
-api.prender.returns = {} --no return
-api.prender.call = function ()
- local write_res, err = device:send(PRENDER)
- if write_res then return 1 else return 0 end
-end
-
-api.apagar = {}
-api.apagar.parameters = {} --no parameters
-api.apagar.returns = {} --no return
-api.apagar.call = function ()
- local write_res, err = device:send(APAGAR)
- if write_res then return 1 else return 0 end
-end
-
-api.buzzer_corto = {}
-api.buzzer_corto.parameters = {[1]={rname="num", rtype="number"}}
-api.buzzer_corto.returns = {} --no return
-api.buzzer_corto.call = function (num)
- local write_res, err = device:send(BUZZER_CORTO .. string.char(num))
- if write_res then return 1 else return 0 end
-end
-
-api.buzzer_triple = {}
-api.buzzer_triple.parameters = {[1]={rname="tiempo1", rtype="number"}, [2]={rname="tiempo2", rtype="number"}, [3]={rname="tiempo3", rtype="number"}}
-api.buzzer_triple.returns = {} --no return
-api.buzzer_triple.call = function (tiempo1, tiempo2, tiempo3)
- local write_res, err = device:send(BUZZER_TRIPLE .. string.char(tiempo1) .. string.char(tiempo2) .. string.char(tiempo3))
- if write_res then return 1 else return 0 end
-end
diff --git a/lib/support/drivers/debug.lua b/lib/support/drivers/debug.lua
deleted file mode 100644
index d8191ec..0000000
--- a/lib/support/drivers/debug.lua
+++ /dev/null
@@ -1,39 +0,0 @@
-local device = _G
-local RD_VERSION = string.char(0x00)
-local RD_DEBUG = string.char(0x01)
-local MESSAGE = string.char(0x02)
-
-
-api={}
-api.read_version = {}
-api.read_version.parameters = {} --no parameters
-api.read_version.returns = {[1]={rname="version", rtype="number"}} --one return
-api.read_version.call = function ()
- local get_read_version = RD_VERSION
- device:send(get_read_version)
- local version_response = device:read(2)
- local raw_val = string.byte(version_response, 2)
- --print("rawval, deg_temp: ", raw_val, deg_temp)
- --return raw_val
- return version_response
-end
-
-api.rd_debug = {}
-api.rd_debug.parameters = {} --no parameters
-api.rd_debug.returns = {[1]={rname="data", rtype="string"}} --debug message
-api.rd_debug.call = function ()
- local write_res, err = device:send(RD_DEBUG)
- local len = 4
- local ret = device:read(len) or ""
- print("====",ret, string.len(ret))
- return ret
-end
-
-api.message = {}
-api.message.parameters = {} --no parameters
-api.message.returns = {}
-api.message.call = function ()
- local write_res, err = device:send(MESSAGE)
- return write_res
-end
-
diff --git a/lib/support/drivers/display.lua b/lib/support/drivers/display.lua
deleted file mode 100644
index 3629cb9..0000000
--- a/lib/support/drivers/display.lua
+++ /dev/null
@@ -1,99 +0,0 @@
-local device = _G
-
-local string_char=string.char
-
-local RD_VERSION = string_char(0x00)
-local ESCRIBIR = string_char(0x01)
-local PRUEBA = string_char(0x02)
-local BORRAR = string_char(0x03)
-local INICIAR = string_char(0x04)
-local PRENDER_BKL = string_char(0x08)
-local APAGAR_BKL = string_char(0x09)
-local AGENDAR_MSG = string_char(0x0A)
-local SET_TICKS = string_char(0x0B)
-local ESPACIO = string_char(0x20)
-
-
-api={}
-api.read_version = {}
-api.read_version.parameters = {} --no parameters
-api.read_version.returns = {[1]={rname="version", rtype="number"}} --one return
-api.read_version.call = function ()
- device:send(RD_VERSION)
- local version_response = device:read(2)
- local raw_val = string.byte(temperature_response, 2)
- --print("rawval, deg_temp: ", raw_val, deg_temp)
- return raw_val
-end
-
-api.escribir = {}
-api.escribir.parameters = {[1]={rname="message", rtype="string"}}
-api.escribir.returns = {}
-api.escribir.call = function (str)
- local msg = ESCRIBIR .. str
- device:send(msg)
- --device:read()
-end
-
-api.prueba = {}
-api.prueba.parameters = {} --no parameters
-api.prueba.returns = {} --no return
-api.prueba.call = function ()
- device:send(PRUEBA)
-end
-
-api.borrar = {}
-api.borrar.parameters = {} --no parameters
-api.borrar.returns = {} --no return
-api.borrar.call = function ()
- device:send(BORRAR)
-end
-
-api.iniciar = {}
-api.iniciar.parameters = {} --no parameters
-api.iniciar.returns = {} --no return
-api.iniciar.call = function ()
- device:send(INICIAR)
-end
-
-api.prender_bkl = {}
-api.prender_bkl.parameters = {} --no parameters
-api.prender_bkl.returns = {} --no return
-api.prender_bkl.call = function ()
- device:send(PRENDER_BKL)
-end
-
-api.apagar_bkl = {}
-api.apagar_bkl.parameters = {} --no parameters
-api.apagar_bkl.returns = {} --no return
-api.apagar_bkl.call = function ()
- device:send(APAGAR_BKL)
-end
-
-api.set_ticks = {}
-api.set_ticks.parameters = {[1]={rname="cantTicks", rtype="numeric"}} --how many timmers ticks have to pass before display agendar_msg screen
-api.set_ticks.returns = {} --no return
-api.set_ticks.call = function (ticks)
- device:send(SET_TICKS .. string_char(ticks))
-end
-
-api.agendar_msg = {}
-api.agendar_msg.parameters = {
- [1]={rname="message", rtype="string"}, -- first parameter is the message
- [2]={rname="isCiclic", rtype="numeric"}, -- 1 in case of a ciclic message 0 elsewere
- [3]={rname="isEnd", rtype="numeric"}} -- 1 in case of end of message, so previously calls to agendar_msg could be concatenated
-api.agendar_msg.returns = {[1]={rname="isFull", rtype="boolean"}} --If it is no more space in the event buffer returns true, false elsewere
-api.agendar_msg.call = function (str, isCiclic, isEnd)
- device:send(AGENDAR_MSG .. string_char(32) .. string_char(isEnd) .. string_char(isCiclic) .. str)
- print("despues del send")
- local ret = device:read(3) or char0000 --el tercer byte recibido indica con un 1 si el buffer circuilar que se utiliza para mantener los mensajes esta lleno, 0 en caso controario
- print("despues del read")
- local error = (string.byte(ret,3) or 0)
- print("despues de capturar el 3er byte")
- if(error == 1) then
- print "error, buffer lleno"
- else
- print "ok"
- end
- return error
-end
diff --git a/lib/support/drivers/dist.lua b/lib/support/drivers/dist.lua
deleted file mode 100644
index 5b8a247..0000000
--- a/lib/support/drivers/dist.lua
+++ /dev/null
@@ -1,25 +0,0 @@
-local device = _G
-
-local GET_VALUE=string.char(0x00)
-local string_byte=string.byte
-
--- description: lets us know dist sensor's current value
--- input: empty
--- output: dist sensor's current value.
-api={}
-api.getValue = {}
-api.getValue.parameters = {} -- no input parameters
-api.getValue.returns = {[1]={rname="par1", rtype="int"}}
-api.getValue.call = function ()
- device:send(GET_VALUE) -- operation code 1 = get distance of object
- local sen_anl_response = device:read(3) -- operation code and data
- if not sen_anl_response or #sen_anl_response~=3 then return -1 end
- --local raw_val = (string_byte(sen_anl_response, 2) or 0) + (string_byte(sen_anl_response, 3) or 0)* 256
- raw_val = string.byte(sen_anl_response, 2)* 256 + string.byte(sen_anl_response, 3)
- raw_val = 1024 - raw_val
- return raw_val
-end
-
-
-
-
diff --git a/lib/support/drivers/dynamix.lua b/lib/support/drivers/dynamix.lua
deleted file mode 100644
index 52ea4ba..0000000
--- a/lib/support/drivers/dynamix.lua
+++ /dev/null
@@ -1,34 +0,0 @@
-local device = _G
-local WRITE_INFO = 0x01
-local SEND_BUS = 0x01
-local READ_INFO = 0x02
-local GET_RAW_POS = 0x03
-local char000 = string.char(0,0,0)
-
---byte id,byte regstart, int value
-api={}
-api.write_info = {}
-api.write_info.parameters = {[1]={rname="id", rtype="number", min=0, max=255},[2]={rname="regstart", rtype="number", min=0, max=255},[3]={rname="value", rtype="number", min=0, max=65536}} ----byte id,byte regstart, int value
-api.write_info.returns = {[1]={rname="write_info_return", rtype="number"}} --one return
-api.write_info.call = function (id, regstart, value)
- id, regstart, value = tonumber(id), tonumber(regstart), tonumber(value)
- local write_info_payload = string.char(WRITE_INFO, id, regstart, math.floor(value / 256),value % 256)
- device:send(write_info_payload)
- local write_info_response = device:read(2) or char000
- local raw_val = (string.byte(write_info_response, 2) or 0)
- return raw_val
-end
-
-api.pasarela = {}
-api.pasarela.parameters = {[1]={rname="packet", rtype="string", min=0, max=255}}
-api.pasarela.returns = {}
-api.pasarela.call = function (value)
- local valueN = tonumber(value)
- local checksum = 255 - ((0xfe + 0x04 + 0x03 + 0x19 +valueN)%256)
- print (checksum)
- local paquete = string.char(SEND_BUS, 0xff, 0xff,0xfe, 0x04, 0x03, 0x19, valueN, checksum)
- device:send(paquete)
-end
-
-
-
diff --git a/lib/support/drivers/gas.lua b/lib/support/drivers/gas.lua
deleted file mode 100644
index a056759..0000000
--- a/lib/support/drivers/gas.lua
+++ /dev/null
@@ -1,20 +0,0 @@
-local device = _G
-local RD_GAS = string.char(0x01)
-local char000 = string.char(0,0,0)
-
-api={}
-api.get_gas = {}
-api.get_gas.parameters = {} --no parameter
-api.get_gas.returns = {[1]={rname="gas level", rtype="number"}} --one return
-api.get_gas.call = function ()
- local get_payload = RD_GAS
- device:send(get_payload)
- local response = device:read(3)
- if not response then
- print ('WARN: api.get_gas.call failure on device:read(3)')
- response=char000
- end
- local raw_val = string.byte(response, 2) + 255*string.byte(response, 3)
- return raw_val
-end
-
diff --git a/lib/support/drivers/grises.lua b/lib/support/drivers/grises.lua
deleted file mode 100644
index a680266..0000000
--- a/lib/support/drivers/grises.lua
+++ /dev/null
@@ -1,19 +0,0 @@
-local device = _G
-
-local GET_VALUE=string.char(0x00)
-local string_byte=string.byte
-
--- description: lets us know grey sensor's current value
--- input: empty
--- output: grey sensor's current value.
-api={}
-api.getValue = {}
-api.getValue.parameters = {} -- no input parameters
-api.getValue.returns = {[1]={rname="par1", rtype="int"}}
-api.getValue.call = function ()
- device:send(GET_VALUE) -- operation code 1 = get grey level
- local sen_anl_response = device:read(3) -- operation code and data
- if not sen_anl_response or #sen_anl_response~=3 then return -1 end
- local raw_val = math.floor(((string_byte(sen_anl_response, 2) or 0) + (string_byte(sen_anl_response, 3) or 0)* 256)/ 100)
- return raw_val
-end
diff --git a/lib/support/drivers/hotplug/button.lua b/lib/support/drivers/hotplug/button.lua
deleted file mode 100644
index 9ddba48..0000000
--- a/lib/support/drivers/hotplug/button.lua
+++ /dev/null
@@ -1,32 +0,0 @@
-local device = _G
-
-local RD_VERSION=string.char(0x00)
-local GET_VALUE=string.char(0x01)
-local string_byte=string.byte
-
--- description: lets us know button module's version
-api={}
-api.getVersion = {}
-api.getVersion.parameters = {} -- no input parameters
-api.getVersion.returns = {[1]={rname="version", rtype="int"}}
-api.getVersion.call = function ()
- device:send(RD_VERSION) -- operation code 0 = get version
- local version_response = device:read(3) -- 3 bytes to read (opcode, data)
- if not version_response or #version_response~=3 then return -1 end
- local raw_val = (string_byte(version_response,2) or 0) + (string_byte(version_response,3) or 0)* 256
- return raw_val
-end
-
--- description: lets us know button's current status
--- input: empty
--- output: button's current status. Possible status: 1 pressed - 0 not pressed
-api.getValue = {}
-api.getValue.parameters = {} -- no input parameters
-api.getValue.returns = {[1]={rname="state", rtype="int"}}
-api.getValue.call = function ()
- device:send(GET_VALUE) -- operation code 1 = get button's status
- local sen_dig_response = device:read(2) -- 2 bytes to read (opcode, data)
- if not sen_dig_response or #sen_dig_response~=2 then return -1 end
- local raw_val = string_byte(sen_dig_response, 2) or 0 -- keep data
- return raw_val
-end
diff --git a/lib/support/drivers/hotplug/distanc.lua b/lib/support/drivers/hotplug/distanc.lua
deleted file mode 100644
index 2340796..0000000
--- a/lib/support/drivers/hotplug/distanc.lua
+++ /dev/null
@@ -1,32 +0,0 @@
-local device = _G
-
-local RD_VERSION=string.char(0x00)
-local GET_VALUE=string.char(0x01)
-local string_byte=string.byte
-
--- description: lets us know dist module's version
-api={}
-api.getVersion = {}
-api.getVersion.parameters = {} -- no input parameters
-api.getVersion.returns = {[1]={rname="version", rtype="int"}}
-api.getVersion.call = function ()
- device:send(RD_VERSION) -- operation code 0 = get version
- local version_response = device:read(3) -- 3 bytes to read (opcode, data)
- if not version_response or #version_response~=3 then return -1 end
- local raw_val = (string_byte(version_response,2) or 0) + (string_byte(version_response,3) or 0)* 256
- return raw_val
-end
-
--- description: lets us know dist sensor's current value
--- input: empty
--- output: dist sensor's current value.
-api.getValue = {}
-api.getValue.parameters = {} -- no input parameters
-api.getValue.returns = {[1]={rname="par1", rtype="int"}}
-api.getValue.call = function ()
- device:send(GET_VALUE) -- operation code 1 = get distance of object
- local sen_anl_response = device:read(3) -- operation code and data
- if not sen_anl_response or #sen_anl_response~=3 then return -1 end
- local raw_val = (string_byte(sen_anl_response, 2) or 0) + (string_byte(sen_anl_response, 3) or 0)* 256
- return raw_val
-end
diff --git a/lib/support/drivers/hotplug/gpio.lua b/lib/support/drivers/hotplug/gpio.lua
deleted file mode 100644
index 331efb3..0000000
--- a/lib/support/drivers/hotplug/gpio.lua
+++ /dev/null
@@ -1,19 +0,0 @@
-local device = _G
-
-local RD_VERSION=string.char(0x00)
-local string_byte=string.byte
-
--- description: lets us know button module's version
-api={}
-api.getVersion = {}
-api.getVersion.parameters = {} -- no input parameters
-api.getVersion.returns = {[1]={rname="version", rtype="int"}}
-api.getVersion.call = function ()
- device:send(RD_VERSION) -- operation code 0 = get version
- local version_response = device:read(3) -- 3 bytes to read (opcode, data)
- if not version_response or #version_response~=3 then return -1 end
- local raw_val = (string_byte(version_response,2) or 0) + (string_byte(version_response,3) or 0)* 256
- return raw_val
-end
-
-
diff --git a/lib/support/drivers/hotplug/grey.lua b/lib/support/drivers/hotplug/grey.lua
deleted file mode 100644
index eb24f36..0000000
--- a/lib/support/drivers/hotplug/grey.lua
+++ /dev/null
@@ -1,32 +0,0 @@
-local device = _G
-
-local RD_VERSION=string.char(0x00)
-local GET_VALUE=string.char(0x01)
-local string_byte=string.byte
-
--- description: lets us know grey module's version
-api={}
-api.getVersion = {}
-api.getVersion.parameters = {} -- no input parameters
-api.getVersion.returns = {[1]={rname="version", rtype="int"}}
-api.getVersion.call = function ()
- device:send(RD_VERSION) -- operation code 0 = get version
- local version_response = device:read(3) -- 3 bytes to read (opcode, data)
- if not version_response or #version_response~=3 then return -1 end
- local raw_val = (string_byte(version_response,2) or 0) + (string_byte(version_response,3) or 0)* 256
- return raw_val
-end
-
--- description: lets us know grey sensor's current value
--- input: empty
--- output: grey sensor's current value.
-api.getValue = {}
-api.getValue.parameters = {} -- no input parameters
-api.getValue.returns = {[1]={rname="par1", rtype="int"}}
-api.getValue.call = function ()
- device:send(GET_VALUE) -- operation code 1 = get grey level
- local sen_anl_response = device:read(3) -- operation code and data
- if not sen_anl_response or #sen_anl_response~=3 then return -1 end
- local raw_val = (string_byte(sen_anl_response, 2) or 0) + (string_byte(sen_anl_response, 3) or 0)* 256
- return raw_val
-end
diff --git a/lib/support/drivers/hotplug/light.lua b/lib/support/drivers/hotplug/light.lua
deleted file mode 100644
index ce953b2..0000000
--- a/lib/support/drivers/hotplug/light.lua
+++ /dev/null
@@ -1,32 +0,0 @@
-local device = _G
-
-local RD_VERSION=string.char(0x00)
-local GET_VALUE=string.char(0x01)
-local string_byte=string.byte
-
--- description: lets us know light module's version
-api={}
-api.getVersion = {}
-api.getVersion.parameters = {} -- no input parameters
-api.getVersion.returns = {[1]={rname="version", rtype="int"}}
-api.getVersion.call = function ()
- device:send(RD_VERSION) -- operation code 0 = get version
- local version_response = device:read(3) -- 3 bytes to read (opcode, data)
- if not version_response or #version_response~=3 then return -1 end
- local raw_val = (string_byte(version_response,2) or 0) + (string_byte(version_response,3) or 0)* 256
- return raw_val
-end
-
--- description: lets us know light sensor's current value
--- input: empty
--- output: light sensor's current value.
-api.getValue = {}
-api.getValue.parameters = {} -- no input parameters
-api.getValue.returns = {[1]={rname="par1", rtype="int"}}
-api.getValue.call = function ()
- device:send(GET_VALUE) -- operation code 1 = get light level
- local sen_anl_response = device:read(3) -- operation code and data
- if not sen_anl_response or #sen_anl_response~=3 then return -1 end
- local raw_val = (string_byte(sen_anl_response, 2) or 0) + (string_byte(sen_anl_response, 3) or 0)* 256
- return raw_val
-end
diff --git a/lib/support/drivers/hotplug/port.lua b/lib/support/drivers/hotplug/port.lua
deleted file mode 100644
index 331efb3..0000000
--- a/lib/support/drivers/hotplug/port.lua
+++ /dev/null
@@ -1,19 +0,0 @@
-local device = _G
-
-local RD_VERSION=string.char(0x00)
-local string_byte=string.byte
-
--- description: lets us know button module's version
-api={}
-api.getVersion = {}
-api.getVersion.parameters = {} -- no input parameters
-api.getVersion.returns = {[1]={rname="version", rtype="int"}}
-api.getVersion.call = function ()
- device:send(RD_VERSION) -- operation code 0 = get version
- local version_response = device:read(3) -- 3 bytes to read (opcode, data)
- if not version_response or #version_response~=3 then return -1 end
- local raw_val = (string_byte(version_response,2) or 0) + (string_byte(version_response,3) or 0)* 256
- return raw_val
-end
-
-
diff --git a/lib/support/drivers/hotplug/tilt.lua b/lib/support/drivers/hotplug/tilt.lua
deleted file mode 100644
index 1076479..0000000
--- a/lib/support/drivers/hotplug/tilt.lua
+++ /dev/null
@@ -1,19 +0,0 @@
-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
diff --git a/lib/support/drivers/hotplug/vibra.lua b/lib/support/drivers/hotplug/vibra.lua
deleted file mode 100644
index 0c3d985..0000000
--- a/lib/support/drivers/hotplug/vibra.lua
+++ /dev/null
@@ -1,19 +0,0 @@
-local device = _G
-
-api={}
-api.getVibra = {}
-api.getVibra.parameters = {} -- -- no input parameters
-api.getVibra.returns = {[1]={rname="par1", rtype="int"}}
-api.getVibra.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
diff --git a/lib/support/drivers/lback.lua b/lib/support/drivers/lback.lua
deleted file mode 100644
index 9f903b1..0000000
--- a/lib/support/drivers/lback.lua
+++ /dev/null
@@ -1,21 +0,0 @@
-local device = _G
-
-api={}
-api.send = {}
-api.send.parameters = {[1]={rname="data", rtype="string"}}
-api.send.returns = {}
-api.send.call = function (data)
- --print("####", data, string.len(data))
- device:send(data)
-end
-
-api.read = {}
-api.read.parameters = {[1]={rname="len", rtype="int", default=64, min=0, max=255}}
-api.read.returns = {[1]={rname="data", rtype="string"}}
-api.read.call = function (len)
- local len = len or 64
- local ret = device:read(len)
--- print("====",ret, string.len(ret))
- return ret
-end
-
diff --git a/lib/support/drivers/led.lua b/lib/support/drivers/led.lua
deleted file mode 100644
index 1095d93..0000000
--- a/lib/support/drivers/led.lua
+++ /dev/null
@@ -1,17 +0,0 @@
-local device = _G
-
-local string_char=string.char
-
-api={}
-api.setLight = {}
-api.setLight.parameters = {[1]={rname="message", rtype="string"}}
-api.setLight.returns = {}
-api.setLight.call = function (intensidad)
- intensidad=tonumber(intensidad)
- if (not intensidad) or intensidad<0 then intensidad=0
- elseif intensidad>255 then intensidad=255 end
-
- local msg = string_char(0x00) .. string_char(math.floor(intensidad)) -- entre 0 y 255
- device:send(msg)
- local version_response = device:read()
-end
diff --git a/lib/support/drivers/ledA.lua b/lib/support/drivers/ledA.lua
deleted file mode 100644
index f76b501..0000000
--- a/lib/support/drivers/ledA.lua
+++ /dev/null
@@ -1,46 +0,0 @@
-local device = _G
-local RD_VERSION = string.char(0x00)
-local PRENDER = string.char(0x01)
-local APAGAR = string.char(0x02)
-local BLINK = string.char(0x03)
-
-api={}
-api.read_version = {}
-api.read_version.parameters = {} --no parameters
-api.read_version.returns = {[1]={rname="version", rtype="number"}} --one return
-api.read_version.call = function ()
- local get_read_version = RD_VERSION
- device:send(get_read_version)
- local version_response = device:read(2)
- local raw_val = string.byte(version_response, 2)
- --print("rawval, deg_temp: ", raw_val, deg_temp)
- return raw_val
-end
-
-api.prender = {}
-api.prender.parameters = {} --no parameters
-api.prender.returns = {} --no return
-api.prender.call = function ()
- device:send(PRENDER)
--- local response = device:read(2)
--- print("[",string.byte(response, 1),",", string.byte(response, 2),"]")
--- print("-----------------------------------------------")
--- if (string.byte(response, 1) ~= nil or string.byte(response, 2) ~= nil) then
--- print("vino data")
--- end
-end
-
-api.apagar = {}
-api.apagar.parameters = {} --no parameters
-api.apagar.returns = {} --no return
-api.apagar.call = function ()
- device:send(APAGAR)
-end
-
-api.blink = {}
-api.blink.parameters = {[1]={rname="time", rtype="number"}, [2]={rname="blinks", rtype="number"}}
-api.blink.returns = {} --no return
-api.blink.call = function (time, blinks)
- local msg = BLINK .. string.char(time) .. string.char(blinks)
- device:send(msg)
-end
diff --git a/lib/support/drivers/ledR.lua b/lib/support/drivers/ledR.lua
deleted file mode 100644
index 1d3e726..0000000
--- a/lib/support/drivers/ledR.lua
+++ /dev/null
@@ -1,31 +0,0 @@
-local device = _G
-local RD_VERSION = string.char(0x00)
-local PRENDER = string.char(0x01)
-local APAGAR = string.char(0x02)
-
-api={}
-api.read_version = {}
-api.read_version.parameters = {} --no parameters
-api.read_version.returns = {[1]={rname="version", rtype="number"}} --one return
-api.read_version.call = function ()
- local get_read_version = RD_VERSION
- device:send(get_read_version)
- local version_response = device:read(2)
- local raw_val = string.byte(version_response, 2)
- --print("rawval, deg_temp: ", raw_val, deg_temp)
- return raw_val
-end
-
-api.prender = {}
-api.prender.parameters = {} --no parameters
-api.prender.returns = {} --no return
-api.prender.call = function ()
- device:send(PRENDER)
-end
-
-api.apagar = {}
-api.apagar.parameters = {} --no parameters
-api.apagar.returns = {} --no return
-api.apagar.call = function ()
- device:send(APAGAR)
-end
diff --git a/lib/support/drivers/ledV.lua b/lib/support/drivers/ledV.lua
deleted file mode 100644
index 1d3e726..0000000
--- a/lib/support/drivers/ledV.lua
+++ /dev/null
@@ -1,31 +0,0 @@
-local device = _G
-local RD_VERSION = string.char(0x00)
-local PRENDER = string.char(0x01)
-local APAGAR = string.char(0x02)
-
-api={}
-api.read_version = {}
-api.read_version.parameters = {} --no parameters
-api.read_version.returns = {[1]={rname="version", rtype="number"}} --one return
-api.read_version.call = function ()
- local get_read_version = RD_VERSION
- device:send(get_read_version)
- local version_response = device:read(2)
- local raw_val = string.byte(version_response, 2)
- --print("rawval, deg_temp: ", raw_val, deg_temp)
- return raw_val
-end
-
-api.prender = {}
-api.prender.parameters = {} --no parameters
-api.prender.returns = {} --no return
-api.prender.call = function ()
- device:send(PRENDER)
-end
-
-api.apagar = {}
-api.apagar.parameters = {} --no parameters
-api.apagar.returns = {} --no return
-api.apagar.call = function ()
- device:send(APAGAR)
-end
diff --git a/lib/support/drivers/leds.lua b/lib/support/drivers/leds.lua
deleted file mode 100644
index 7e55ce6..0000000
--- a/lib/support/drivers/leds.lua
+++ /dev/null
@@ -1,43 +0,0 @@
-local device = _G
-local RD_VERSION = string.char(0x00)
-local PRENDER = string.char(0x01)
-local APAGAR = string.char(0x02)
-local BLINK = string.char(0x03)
-
-api={}
-api.read_version = {}
-api.read_version.parameters = {} --no parameters
-api.read_version.returns = {[1]={rname="version", rtype="number"}} --one return
-api.read_version.call = function ()
- local get_read_version = RD_VERSION
- device:send(get_read_version)
- local version_response = device:read(2)
- local raw_val = string.byte(version_response, 2)
- --print("rawval, deg_temp: ", raw_val, deg_temp)
- return raw_val
-end
-
-api.prender = {}
-api.prender.parameters = {[1]={rname="numLed", rtype="number"}} --recibe the led number
-api.prender.returns = {} --no return
-api.prender.call = function (ledNumber)
- local write_res, err = device:send(PRENDER .. string.char(ledNumber))
- if write_res then return 1 else return 0 end
-end
-
-api.apagar = {}
-api.apagar.parameters = {[1]={rname="numLed", rtype="number"}} --recibe the led number
-api.apagar.returns = {} --no return
-api.apagar.call = function (ledNumber)
- local write_res, err = device:send(APAGAR .. string.char(ledNumber))
- if write_res then return 1 else return 0 end
-end
-
-api.blink = {}
-api.blink.parameters = {[1]={rname="time", rtype="number"}, [2]={rname="blinks", rtype="number"}, [3]={rname="numLed", rtype="number"}}
-api.blink.returns = {} --no return
-api.blink.call = function (time, blinks, ledNumber)
- local msg = BLINK .. string.char(time) .. string.char(blinks) .. string.char(ledNumber)
- local write_res, err = device:send(msg)
- if write_res then return 1 else return 0 end
-end
diff --git a/lib/support/drivers/luz.lua b/lib/support/drivers/luz.lua
deleted file mode 100644
index ed14e26..0000000
--- a/lib/support/drivers/luz.lua
+++ /dev/null
@@ -1,21 +0,0 @@
-local device = _G
-
-api={}
-api.getLuz = {}
-api.getLuz.parameters = {} -- -- no input parameters
-api.getLuz.returns = {[1]={rname="par1", rtype="int"}}
-api.getLuz.call = function ()
- device:send(string.char(0x00)) -- codigo de operacion 0
- local sen_anl_response = device:read(3)
- local raw_val
- if not sen_anl_response or string.byte(sen_anl_response or "00000000", 2) == nil or string.byte(sen_anl_response or "00000000", 3) == nil
- then
- raw_val = "nil value"
- else
- raw_val = string.byte(sen_anl_response, 2)* 256 + string.byte(sen_anl_response, 3)
- raw_val = 1024 - raw_val
-
- end
- return raw_val
-
-end
diff --git a/lib/support/drivers/magnet.lua b/lib/support/drivers/magnet.lua
deleted file mode 100644
index e70b69c..0000000
--- a/lib/support/drivers/magnet.lua
+++ /dev/null
@@ -1,21 +0,0 @@
-local device = _G
-
--- descripción: permite conocer el estado el botón en un momento dado.
--- entrada: no tiene.
--- salida: estado del botón. Posibles estados: 1 presionado, 0 libre.
-api={}
-api.getCampo = {}
-api.getCampo.parameters = {} -- no tiene parámetros de entrada
-api.getCampo.returns = {[1]={rname="par1", rtype="int"}} -- 1 = presionado, 0 = libre
-api.getCampo.call = function ()
- device:send(string.char(0x00)) -- codigo de operacion = 0
- local sen_dig_response = device:read(3) -- leo 2 bytes (opcode, data)
- 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 = 1 - (string.byte(sen_dig_response, 3) % 2)
- end
- return raw_val
-end
diff --git a/lib/support/drivers/motor.lua b/lib/support/drivers/motor.lua
deleted file mode 100644
index c1a86d6..0000000
--- a/lib/support/drivers/motor.lua
+++ /dev/null
@@ -1,42 +0,0 @@
-local device = _G
-local SET_VEL_ADL = 0x00 -- código de op para mover el motor hacia adelante
-local SET_VEL_ATR = 0x01 -- código de op para mover el motor hacia atrás
-
-
-api={}
-api.setveladl = {}
-api.setveladl.parameters = {[1]={rname="id", rtype="int"}, [2]={rname="vel", rtype="int"}} --primer parametro id motor, segundo velocidad
-api.setveladl.returns = {[1]={rname="dato", rtype="int"}} --codigo de operación
-api.setveladl.call = function (id, vel)
- local msg = string.char(SET_VEL_ADL,id, math.floor(vel / 256),vel % 256)
- device:send(msg)
- local ret = device:read(1)
- local raw_val = string.byte(ret or " ", 1)
- return raw_val
-end
-
-api.setvelatr = {}
-api.setvelatr.parameters = {[1]={rname="id", rtype="int"}, [2]={rname="vel", rtype="int"}} --primer parametro id motor, segundo velocidad
-api.setvelatr.returns = {[1]={rname="dato", rtype="int"}} --codigo de operación
-api.setvelatr.call = function (id, vel)
- local msg = string.char(SET_VEL_ATR,id, math.floor(vel / 256),vel % 256)
- device:send(msg)
- local ret = device:read(1)
- local raw_val = string.byte(ret or " ", 1)
- return raw_val
-end
-
-
-api.setvelatr2 = {}
-api.setvelatr2.parameters = {[1]={rname="id", rtype="int"}, [2]={rname="vel", rtype="int"}} --primer parametro id motor, segundo velocidad
-api.setvelatr2.returns = {[1]={rname="dato", rtype="int"}} --codigo de operación
-api.setvelatr2.call = function (vel)
- local msg = string.char(SET_VEL_ATR,0, math.floor(vel / 256),vel % 256)
- device:send(msg)
- local msg = string.char(SET_VEL_ATR,1, math.floor(vel / 256),vel % 256)
- device:send(msg)
- local ret = device:read(1)
- local ret = device:read(1)
- local raw_val = string.byte(ret or " ", 1)
- return raw_val
-end
diff --git a/lib/support/drivers/motorTm.lua b/lib/support/drivers/motorTm.lua
deleted file mode 100644
index 9343855..0000000
--- a/lib/support/drivers/motorTm.lua
+++ /dev/null
@@ -1,47 +0,0 @@
-local device = _G
-
-api={}
-api.step = {}
-api.step.parameters = {[1]={rname="step", rtype="int", min=0, max=65536}}
-api.step.returns = {}
-api.step.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.phasetype = {}
-api.phasetype.parameters = {[1]={rname="phasetype", rtype="int", min=0, max=2}}
-api.phasetype.returns = {}
-api.phasetype.call = function (phasetype)
- local msg = string.char(0x04) .. string.char(phasetype)
- device:send(msg)
-end
-
-api.power_on = {}
-api.power_on.parameters = {[1]={rname="power_on", rtype="int", min=0, max=1}}
-api.power_on.returns = {}
-api.power_on.call = function (on)
- local msg = string.char(0x06) .. string.char(on)
- device:send(msg)
-end
-
-api.direction = {}
-api.direction.parameters = {[1]={rname="direction", rtype="int", min=-1, max=1}}
-api.direction.returns = {}
-api.direction.call = function (dir)
- if dir==-1 then dir=2 end
- local msg = string.char(0x07) .. string.char(dir+1)
- device:send(msg)
-end
-
-
diff --git a/lib/support/drivers/motores.lua b/lib/support/drivers/motores.lua
deleted file mode 100644
index 45d2967..0000000
--- a/lib/support/drivers/motores.lua
+++ /dev/null
@@ -1,48 +0,0 @@
-local device = _G
-local SET_VEL_MTR = 0x00 -- código de op para mover un motor con vel y sentido
-local SET_VEL_2MTR = 0x01 -- código de op para mover dos motores con vel y sentido
-
-
-api={}
-api.setvelmtr = {}
-api.setvelmtr.parameters = {[1]={rname="id", rtype="int"},[2]={rname="sentido", rtype="int"},[3]={rname="vel", rtype="int"}} --parametros, id sentido vel
-api.setvelmtr.returns = {[1]={rname="dato", rtype="int"}} --codigo de operación
-api.setvelmtr.call = function (id, sentido, vel)
- vel=tonumber(vel)
- if vel>1023 then vel=1023 end
- local msg = string.char(SET_VEL_MTR,id, sentido, math.floor(vel / 256),vel % 256)
- device:send(msg)
- local ret = device:read(1)
- local raw_val = string.byte(ret or " ", 1)
- return raw_val
-end
-
-api.setvel2mtr = {}
-api.setvel2mtr.parameters = {[1]={rname="sentido", rtype="int"},[2]={rname="vel", rtype="int"},[3]={rname="sentido", rtype="int"},[4]={rname="vel", rtype="int"}}
-api.setvel2mtr.returns = {[1]={rname="dato", rtype="int"}} --codigo de operación
-api.setvel2mtr.call = function (sentido1, vel1, sentido2, vel2)
- vel1, vel2 = tonumber(vel1), tonumber(vel2)
- if vel1>1023 then vel1=1023 end
- if vel2>1023 then vel2=1023 end
- local msg = string.char(SET_VEL_2MTR,sentido1, math.floor(vel1 / 256),vel1 % 256, sentido2, math.floor(vel2 / 256),vel2 % 256)
- device:send(msg)
- local ret = device:read(1)
- local raw_val = string.byte(ret or " ", 1)
- return raw_val
-end
-
-
-api.setvelatr2 = {}
-api.setvelatr2.parameters = {[1]={rname="id", rtype="int"}, [2]={rname="vel", rtype="int"}} --primer parametro id motor, segundo velocidad
-api.setvelatr2.returns = {[1]={rname="dato", rtype="int"}} --codigo de operación
-api.setvelatr2.call = function (vel)
- local vdiv, vmod = math.floor(vel / 256),vel % 256
- local msg = string.char(SET_VEL_ATR, 0, vdiv, vmod)
- device:send(msg)
- msg = string.char(SET_VEL_ATR, 1, vdiv, vmod)
- device:send(msg)
- local ret = device:read(1)
- ret = device:read(1)
- local raw_val = string.byte(ret or " ", 1)
- return raw_val
-end
diff --git a/lib/support/drivers/motorin.lua b/lib/support/drivers/motorin.lua
deleted file mode 100644
index 042f3cc..0000000
--- a/lib/support/drivers/motorin.lua
+++ /dev/null
@@ -1,28 +0,0 @@
-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
diff --git a/lib/support/drivers/motors.lua b/lib/support/drivers/motors.lua
deleted file mode 100644
index a7c9a05..0000000
--- a/lib/support/drivers/motors.lua
+++ /dev/null
@@ -1,70 +0,0 @@
-local device = _G
-local RD_VERSION=string.char(0x00)
-local SET_VEL_2MTR=0x01 -- código de op para mover dos motores con vel y sentido
-local TEST_MOTORS=string.char(0x02)
-local SET_VEL_MTR = 0x01 -- código de op para mover un motor con vel y sentido
-
-api={}
-api.getVersion = {}
-api.getVersion.parameters = {} -- no input parameters
-api.getVersion.returns = {[1]={rname="version", rtype="int"}}
-api.getVersion.call = function ()
- device:send(RD_VERSION) -- operation code 0 = get version
- local version_response = device:read(3) -- 3 bytes to read (opcode, data)
- if not version_response or #version_response~=3 then return -1 end
- local raw_val = (string.byte(version_response,2) or 0) + (string.byte(version_response,3) or 0)* 256
- return raw_val
-end
-
-api.setvelmtr = {} -- no impl en firmware
-api.setvelmtr.parameters = {[1]={rname="id", rtype="int"},[2]={rname="sentido", rtype="int"},[3]={rname="vel", rtype="int"}} --parametros, id sentido vel
-api.setvelmtr.returns = {[1]={rname="dato", rtype="int"}} --codigo de operación
-api.setvelmtr.call = function (id, sentido, vel)
- vel=tonumber(vel)
- if vel>1023 then vel=1023 end
- local msg = string.char(SET_VEL_MTR,id, sentido, math.floor(vel / 256),vel % 256)
- device:send(msg)
- local ret = device:read(1)
- local raw_val = string.byte(ret or " ", 1)
- return raw_val
-end
-
-api.setvel2mtr = {}
-api.setvel2mtr.parameters = {[1]={rname="sentido", rtype="int"},[2]={rname="vel", rtype="int"},[3]={rname="sentido", rtype="int"},[4]={rname="vel", rtype="int"}}
-api.setvel2mtr.returns = {[1]={rname="dato", rtype="int"}} --codigo de operación
-api.setvel2mtr.call = function (sentido1, vel1, sentido2, vel2)
- vel1, vel2 = tonumber(vel1), tonumber(vel2)
- if vel1>1023 then vel1=1023 end
- if vel2>1023 then vel2=1023 end
- local msg = string.char(SET_VEL_2MTR,sentido1, math.floor(vel1 / 256),vel1 % 256, sentido2, math.floor(vel2 / 256),vel2 % 256)
- device:send(msg)
- local ret = device:read(1)
- local raw_val = string.byte(ret or " ", 1)
- return raw_val
-end
-
-api.setvelatr2 = {} -- no impl en firmware
-api.setvelatr2.parameters = {[1]={rname="id", rtype="int"}, [2]={rname="vel", rtype="int"}} --primer parametro id motor, segundo velocidad
-api.setvelatr2.returns = {[1]={rname="dato", rtype="int"}} --codigo de operación
-api.setvelatr2.call = function (vel)
- local vdiv, vmod = math.floor(vel / 256),vel % 256
- local msg = string.char(SET_VEL_ATR, 0, vdiv, vmod)
- device:send(msg)
- msg = string.char(SET_VEL_ATR, 1, vdiv, vmod)
- device:send(msg)
- local ret = device:read(1)
- ret = device:read(1)
- local raw_val = string.byte(ret or " ", 1)
- return raw_val
-end
-
-api.testMotors = {}
-api.testMotors.parameters = {} -- no input parameters
-api.testMotors.returns = {[1]={rname="dato", rtype="int"}}
-api.testMotors.call = function ()
- device:send(TEST_MOTORS) -- operation code 2 = test motors
- local ret = device:read(1) -- 1 byte to read (opcode)
- if not ret or #ret~=1 then return -1 end
- local ret = string.byte(ret, 1)
- return ret
-end
diff --git a/lib/support/drivers/move.lua b/lib/support/drivers/move.lua
deleted file mode 100644
index 7c361e3..0000000
--- a/lib/support/drivers/move.lua
+++ /dev/null
@@ -1,16 +0,0 @@
-local device = _G
-local GET_MOVE = string.char(0x01)
-local char000 = string.char(0,0,0)
-
-api={}
-api.get_move = {}
-api.get_move.parameters = {} --no parameter
-api.get_move.returns = {[1]={rname="digital_value", rtype="number"}} --one return
-api.get_move.call = function ()
- local get_move_payload = GET_MOVE
- device:send(get_move_payload)
- local move_response = device:read(2) or char000
- local raw_val = (string.byte(move_response, 2) or 0)
- return raw_val
-end
-
diff --git a/lib/support/drivers/pnp.lua b/lib/support/drivers/pnp.lua
deleted file mode 100644
index e69de29..0000000
--- a/lib/support/drivers/pnp.lua
+++ /dev/null
diff --git a/lib/support/drivers/pote.lua b/lib/support/drivers/pote.lua
deleted file mode 100644
index fac23cf..0000000
--- a/lib/support/drivers/pote.lua
+++ /dev/null
@@ -1,16 +0,0 @@
-local device = _G
-local RD_POTE = string.char(0x01)
-local char000 = string.char(0,0,0)
-
-api={}
-api.get_pote = {}
-api.get_pote.parameters = {} --no parameter
-api.get_pote.returns = {[1]={rname="analog_value", rtype="number"}} --one return
-api.get_pote.call = function ()
- local get_pote_payload = RD_POTE
- device:send(get_pote_payload)
- local pote_response = device:read(3) or char000
- local raw_val = (string.byte(pote_response, 2) or 0) + 255*(string.byte(pote_response, 3) or 0)
- return raw_val
-end
-
diff --git a/lib/support/drivers/puerta.lua b/lib/support/drivers/puerta.lua
deleted file mode 100644
index 1d3e726..0000000
--- a/lib/support/drivers/puerta.lua
+++ /dev/null
@@ -1,31 +0,0 @@
-local device = _G
-local RD_VERSION = string.char(0x00)
-local PRENDER = string.char(0x01)
-local APAGAR = string.char(0x02)
-
-api={}
-api.read_version = {}
-api.read_version.parameters = {} --no parameters
-api.read_version.returns = {[1]={rname="version", rtype="number"}} --one return
-api.read_version.call = function ()
- local get_read_version = RD_VERSION
- device:send(get_read_version)
- local version_response = device:read(2)
- local raw_val = string.byte(version_response, 2)
- --print("rawval, deg_temp: ", raw_val, deg_temp)
- return raw_val
-end
-
-api.prender = {}
-api.prender.parameters = {} --no parameters
-api.prender.returns = {} --no return
-api.prender.call = function ()
- device:send(PRENDER)
-end
-
-api.apagar = {}
-api.apagar.parameters = {} --no parameters
-api.apagar.returns = {} --no return
-api.apagar.call = function ()
- device:send(APAGAR)
-end
diff --git a/lib/support/drivers/sec.lua b/lib/support/drivers/sec.lua
deleted file mode 100644
index e89646b..0000000
--- a/lib/support/drivers/sec.lua
+++ /dev/null
@@ -1,87 +0,0 @@
-local device = _G
-local RD_VERSION = string.char(0x00)
-local GET_SEC = string.char(0X01)
-local INTRUSION = string.char(0x02)
-local RESET_FLAG = string.char(0x03)
-local CONT_INT = string.char(0x04)
-local MESS = string.char(0x05)
-local RESET = string.char(0xFF)
-
-api={}
-api.read_version = {}
-api.read_version.parameters = {} --no parameters
-api.read_version.returns = {[1]={rname="version", rtype="number"}} --one return
-api.read_version.call = function ()
- local get_read_version = RD_VERSION
- device:send(get_read_version)
- local version_response = device:read(4)
- local raw_val = string.byte(version_response, 3)
- --print("rawval, deg_temp: ", raw_val, deg_temp)
- return raw_val
-end
-
-api.get_sec = {}
-api.get_sec.parameters = {} --no parameters
---api.get_sec.returns = {[1]={rname="error", rtype="string"},[2]={rname="SecSensorValue_1", rtype="number"},[3]={rname="SecSensorValue_2", rtype="number"}}
-api.get_sec.returns = {[1]={rname="SecSensorValue_1", rtype="number"},[2]={rname="SecSensorValue_2", rtype="number"}}
-api.get_sec.call = function ()
- local send_res, err
- send_res, err = device:send(GET_SEC)
- local ret = device:read(3)
- local SecSensorValue_1 = (string.byte(ret,2) or 0)
- local SecSensorValue_2 = (string.byte(ret,3) or 0)
--- local SecSensorValue_1 = (string.byte(ret,2))
--- local SecSensorValue_2 = (string.byte(ret,3))
- if ((SecSensorValue_1 == 0) and (SecSensorValue_2 == 0)) then
- alarma = "00"
- elseif ((SecSensorValue_1 == 0) and (SecSensorValue_2 == 1)) then
- alarma = "01"
- elseif ((SecSensorValue_1 == 1) and (SecSensorValue_2 == 0)) then
- alarma = "10"
- else
- alarma = "11"
- end
- return alarma
- --if ret then return true, SecSensorValue_1, SecSensorValue_2 else return false end
-end
-
-api.intrusion = {}
-api.intrusion.parameters = {} --no parameters
-api.intrusion.returns = {[1]={rname="alarma", rtype="number"}} --one return
-api.intrusion.call = function ()
- local intrusion = INTRUSION
- device:send(intrusion)
- local alarma = device:read(1)
- if (alarma == string.char(0x00)) then
- alarma = 0
- else
- alarma = 1
- end
- return alarma
-end
-
-api.reset_flag = {}
-api.reset_flag.parameters = {} --no parameters
-api.reset_flag.returns = {[1]={rname="borrado", rtype="number"}} --one return
-api.reset_flag.call = function ()
- local reset_flag = RESET_FLAG
- device:send(reset_flag)
- local borrado = device:read(1)
- if (borrado == string.char(0x00)) then
- borrado = 0
- else
- borrado = 1
- end
-
- return borrado
-end
-
-api.cont_int = {}
-api.cont_int.parameters = {} --no parameters
-api.cont_int.returns = {[1]={rname="cantidad", rtype="number"}} --one return
-api.cont_int.call = function ()
- local cont_int = CONT_INT
- device:send(cont_int)
- local cantidad = device:read(1)
- return string.byte(cantidad)
-end
diff --git a/lib/support/drivers/sensor.lua b/lib/support/drivers/sensor.lua
deleted file mode 100644
index d4df8d4..0000000
--- a/lib/support/drivers/sensor.lua
+++ /dev/null
@@ -1,52 +0,0 @@
-local device = _G
-local SEN_DIG = string.char(0x03) -- consulta un sensor digital
-local SEN_ANL = string.char(0x00) -- consulta un sensor analogico
-local SEN_ I2C = string.char(0x02) -- consulta un sensor i2c
-
-api={}
-api.senanl = {}
-api.senanl.parameters = {[1]={rname="idPin", rtype="int"}} -- -- el parámetro indica el pin que queremos leer de la arduino
-api.senanl.returns = {[1]={rname="par1", rtype="int"}} --{[1]={rname="par1", rtype="int"}, [2]={rname="par2", rtype="int"}} --two return
-api.senanl.call = function (idPin)
- device:send(string.char(0x00, idPin)) -- codigo de operacion 0
- local sen_anl_response = device:read(3)
- local raw_val
- if not sen_anl_response or string.byte(sen_anl_response or "00000000", 2) == nil or string.byte(sen_anl_response or "00000000", 3) == nil
- then
- raw_val = "nil value"
- else
- raw_val = string.byte(sen_anl_response or "00000000", 2)* 256 + string.byte(sen_anl_response or "00000000", 3)
- end
- --local raw_val2 = string.byte(set_anl_response or " ", 3)
- return raw_val --string.char(raw_val ,raw_val2)
-end
-
-api.sendig = {}
-api.sendig.parameters = {[1]={rname="idPin", rtype="int"}} -- el parámetro indica el pin que queremos leer de la arduino
-api.sendig.returns = {[1]={rname="lecturaSensor", rtype="int"}}
-api.sendig.call = function (idPin)
- device:send(string.char(0x01, idPin)) -- codigo de operacion 1
- local sen_dig_response = device:read(3)
- local raw_val
- --if not sen_dig_response
- --then
- -- raw_val = "nil value"
- --else
- raw_val = string.byte(sen_dig_response or "0000", 2)* 256 + string.byte(sen_dig_response or "0000", 3) + 0
- --end
- return raw_val
-
-end
-
-
---api.seni2c = {}
---api.seni2c.parameters = {} -- no params
---api.seni2c.returns = {[1]={rname="par1", rtype="int"}, [2]={rname="par2", rtype="int"}} --two return
---api.seni2c.call = function ()
--- local get_sen_i2c = SET_I2C
--- device:send(get_sen_i2c)
--- local sen_i2c_response = device:read(2)
--- local raw_val = string.byte(set_i2c_response, 2)
--- return raw_val
---end
-
diff --git a/lib/support/drivers/stmtr.lua b/lib/support/drivers/stmtr.lua
deleted file mode 100644
index 9bd9b40..0000000
--- a/lib/support/drivers/stmtr.lua
+++ /dev/null
@@ -1,46 +0,0 @@
-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
diff --git a/lib/support/drivers/temp.lua b/lib/support/drivers/temp.lua
deleted file mode 100644
index 09ffe9f..0000000
--- a/lib/support/drivers/temp.lua
+++ /dev/null
@@ -1,28 +0,0 @@
-local device = _G
-
-api={}
-api.getTemp = {}
-api.getTemp.parameters = {} -- -- no input parameters
-api.getTemp.returns = {[1]={rname="par1", rtype="int"}}
-api.getTemp.call = function ()
- device:send(string.char(0x00)) -- codigo de operacion 0
- local sen_anl_response = device:read(3)
- local raw_val
- if not sen_anl_response or string.byte(sen_anl_response or "00000000", 2) == nil or string.byte(sen_anl_response or "00000000", 3) == nil
- then
- raw_val = "nil value"
- else
- raw_val = string.byte(sen_anl_response, 2)* 256 + string.byte(sen_anl_response, 3)
-
- local aux = (raw_val * 500) / 1024 --- obtengo la temperatura en grados
-
- if aux > 180 then
- raw_val = (raw_val * 45) / 1024
- else
- raw_val = aux
- end
-
- end
- return raw_val
-
-end
diff --git a/lib/support/drivers/temp_lubot.lua b/lib/support/drivers/temp_lubot.lua
deleted file mode 100644
index dd22fc4..0000000
--- a/lib/support/drivers/temp_lubot.lua
+++ /dev/null
@@ -1,20 +0,0 @@
-local device = _G
-local RD_TEMP = string.char(0x34, 0x02)
-local char000 = string.char(0,0,0)
-
-
-api={}
-api.get_temperature = {}
-api.get_temperature.parameters = {} --no parameters
-api.get_temperature.returns = {[1]={rname="temperature", rtype="number"}} --one return
-api.get_temperature.call = function ()
- local get_temp_payload = RD_TEMP
- device:send(get_temp_payload)
- local temperature_response = device:read(3) or char000
- local raw_val = string.byte(temperature_response, 2) + (string.byte(temperature_response, 3) * 256)
- local raw_temp = raw_val / 8
- local deg_temp = raw_temp * 0.0625
- --print("rawval, deg_temp: ", raw_val, deg_temp)
- return deg_temp
-end
-