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
+19 -1
View File
@@ -1,6 +1,6 @@
local CURRENT_STATION_CODE = 'Ticket-Machine'
local API_BASE = 'https://ticket.fse-media.group/api'
local VERSION = 'v1.5.26'
local VERSION = 'v1.5.27'
local UPDATE_CHECK_INTERVAL = 5
local pack = table.pack or function(...)
@@ -566,6 +566,21 @@ local function findPeripheralByType(typeName)
return nil, nil
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 {}
table.sort(names, comparePeripheralName)
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 termDev = nativeTerm or term
local w, h = termDev.getSize()
@@ -578,6 +593,9 @@ local function refreshDevices()
}, '|')
monitor, monitorName = findPeripheralByType('monitor')
tmGpu, tmGpuName = findPeripheralByType('tm_gpu')
if not isTmGpu(tmGpu) then
tmGpu, tmGpuName = scanForTmGpu()
end
ticketVendingMachine, ticketVendingMachineName = findPeripheralByType('ticket_vending_machine')
speaker, speakerName = findPeripheralByType('speaker')
if tmGpu and isTmGpu(tmGpu) then