mirror of
https://github.com/kepler155c/opus
synced 2025-10-18 17:27:39 +00:00
peripheral overhaul
This commit is contained in:
@@ -92,8 +92,8 @@ function Peripheral.get(args)
|
||||
args = { type = args }
|
||||
end
|
||||
|
||||
if args.device then
|
||||
return _G.device[args.device]
|
||||
if args.name then
|
||||
return _G.device[args.name]
|
||||
end
|
||||
|
||||
if args.type then
|
||||
@@ -157,7 +157,9 @@ local function getProxy(pi)
|
||||
if not queue then
|
||||
queue = { }
|
||||
Event.onTimeout(0, function()
|
||||
socket:write({ fn = 'fastBlit', args = { queue } })
|
||||
if not socket:write({ fn = 'fastBlit', args = { queue } }) then
|
||||
error("Timed out communicating with peripheral: " .. pi.uri)
|
||||
end
|
||||
queue = nil
|
||||
socket:read()
|
||||
end)
|
||||
@@ -192,26 +194,26 @@ end
|
||||
Parse a uri into it's components
|
||||
|
||||
Examples:
|
||||
monitor = { device = 'monitor' }
|
||||
side/top = { side = 'top' }
|
||||
method/list = { method = 'list' }
|
||||
12://device/monitor = { host = 12, device = 'monitor' }
|
||||
monitor = { name = 'monitor' }
|
||||
side/top = { side = 'top' }
|
||||
method/list = { method = 'list' }
|
||||
12://name/monitor = { host = 12, name = 'monitor' }
|
||||
]]--
|
||||
local function parse(uri)
|
||||
local pi = Util.split(uri:gsub('^%d*://', ''), '(.-)/')
|
||||
|
||||
if #pi == 1 then
|
||||
pi = {
|
||||
'device',
|
||||
'name',
|
||||
pi[1],
|
||||
}
|
||||
end
|
||||
|
||||
return {
|
||||
host = uri:match('^(%d*)%:'), -- 12
|
||||
uri = uri, -- 12://device/monitor
|
||||
path = uri:gsub('^%d*://', ''), -- device/monitor
|
||||
[ pi[1] ] = pi[2], -- device = 'monitor'
|
||||
uri = uri, -- 12://name/monitor
|
||||
path = uri:gsub('^%d*://', ''), -- name/monitor
|
||||
[ pi[1] ] = pi[2], -- name = 'monitor'
|
||||
}
|
||||
end
|
||||
|
||||
|
@@ -37,6 +37,7 @@ function socketClass:read(timeout)
|
||||
break
|
||||
end
|
||||
timerId = os.startTimer(5)
|
||||
self:ping()
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -54,10 +55,7 @@ end
|
||||
|
||||
function socketClass:ping()
|
||||
if self.connected then
|
||||
_G.transport.write(self, {
|
||||
type = 'PING',
|
||||
seq = self.wseq,
|
||||
})
|
||||
_G.transport.ping(self)
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
@@ -149,8 +149,8 @@ function Terminal.mirror(ct, dt)
|
||||
ct[k] = function(...)
|
||||
local ret = { f(...) }
|
||||
if dt[k] then
|
||||
dt[k](...)
|
||||
end
|
||||
dt[k](...)
|
||||
end
|
||||
return unpack(ret)
|
||||
end
|
||||
end
|
||||
|
@@ -1600,7 +1600,9 @@ function UI.Grid:setPage(pageNo)
|
||||
end
|
||||
|
||||
function UI.Grid:eventHandler(event)
|
||||
if event.type == 'mouse_click' or event.type == 'mouse_doubleclick' then
|
||||
if event.type == 'mouse_click' or
|
||||
event.type == 'mouse_rightclick' or
|
||||
event.type == 'mouse_doubleclick' then
|
||||
if not self.disableHeader then
|
||||
if event.y == 1 then
|
||||
local col = 2
|
||||
@@ -1628,6 +1630,8 @@ function UI.Grid:eventHandler(event)
|
||||
self:setIndex(row)
|
||||
if event.type == 'mouse_doubleclick' then
|
||||
self:emit({ type = 'key_enter' })
|
||||
elseif event.type == 'mouse_rightclick' then
|
||||
self:emit({ type = 'grid_select_right', selected = self.selected, element = self })
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
Reference in New Issue
Block a user