fix(peripheral): 完善tm_gpu外设检测逻辑并升级版本号

新增scanForTmGpu函数用于遍历所有外设查找tm_gpu设备,在原有按类型匹配的查找失败时启用该后备逻辑,同时更新两个脚本文件的版本号。
This commit is contained in:
2026-07-31 11:18:38 +08:00
parent 879445b9f6
commit 9c7e99633b
2 changed files with 41 additions and 2 deletions
+22 -1
View File
@@ -1,7 +1,7 @@
local DEFAULT_SERVER_BASE = "https://ticket.fse-media.group"
local DEFAULT_SERVER_PATH = "/api/tickets/check"
local GATE_OPEN_SECONDS = 2
local VERSION = "v1.5.28"
local VERSION = "v1.5.29"
local VERSION_CHECK_INTERVAL = 5
local serverURL = nil
@@ -206,6 +206,20 @@ local function isTmGpu(dev)
and type(dev.sync) == "function"
end
local function scanForTmGpu()
if not peripheral or type(peripheral.getNames) ~= "function" or type(peripheral.wrap) ~= "function" then
return nil, nil
end
local names = peripheral.getNames() or {}
for _, name in ipairs(names) do
local okWrap, dev = pcall(peripheral.wrap, name)
if okWrap and isTmGpu(dev) then
return dev, name
end
end
return nil, nil
end
local function buildTmGpuTerm(dev)
local gpuTerm = {
kind = "tm_gpu",
@@ -364,6 +378,13 @@ local function refreshDisplayTarget()
nextGpuSide = nil
end
end
if not nextGpu then
local dev, name = scanForTmGpu()
if dev then
nextGpu = dev
nextGpuSide = name
end
end
if nextMonitorSide and type(peripheral.isPresent) == "function" and peripheral.isPresent(nextMonitorSide) and type(peripheral.wrap) == "function" then
local okWrap, wrapped = pcall(peripheral.wrap, nextMonitorSide)
if okWrap and wrapped then