Files
pitts-touchscreen/2B+Software/app/touch.lua

46 lines
1.1 KiB
Lua

local evdev = require "evdev"
local dev = evdev.Device("/dev/input/event0")
local x = 0
local y = 0
local cnt = 0
while true do
--local timestamp, eventType, eventCode, value = dev:read()
--print(dev:avail())
if dev:avail() > 0 then
local timestamp, eventType, eventCode, value = dev:read()
if eventType == evdev.EV_ABS then
if eventCode == 57 then
if value < 0 then
if y > 0 and y < 79 then
print("Ctrl1: ",math.floor(x/80)+1)
end
if y > 400 and y < 479 then
print("Ctrl2: ",math.floor(x/80)+1)
end
if y > 320 and y < 399 then
print("Numbs: ",math.floor(x/80)+1)
end
if y > 80 and y < 319 then
-- print("Lines: ",math.floor(y/((320-80)/6))-1,math.floor(x/20)+1,x,y,math.floor((y-80)/240*10+6),math.floor(x/465*23+5))
print("Lines: ",math.floor((y-80)/240*10+6),math.floor(x/720*36+7))
end
end
elseif eventCode == 0 then
x = value
elseif eventCode == 1 then
y = value
end
end
else
cnt = cnt + 1
end
end