style: update OTA version indicators to lime/yellow/red and output errors to CC terminal

This commit is contained in:
2026-07-11 13:03:44 +08:00
parent d5b7a51dae
commit 2eddb8b84c
2 changed files with 94 additions and 31 deletions
+14 -8
View File
@@ -661,17 +661,14 @@ local lastUpdateError = nil
local function drawVersionIndicator()
if w < 1 then return end
local markerColor = colors.yellow
local markerColor = colors.lime
local markerText = '* '
if isUpdating then
markerColor = colors.yellow
markerText = '^ing'
elseif versionMismatch == true then
elseif lastUpdateError then
markerColor = colors.red
markerText = '* '
elseif versionMismatch == false then
markerColor = colors.lime
markerText = ' '
end
termDev.setBackgroundColor(colors.black)
termDev.setTextColor(colors.gray)
@@ -720,18 +717,27 @@ local function checkAndApplyUpdate()
local ok, res = pcall(fn, "--silent")
if not ok then
lastUpdateError = string.sub(tostring(res), 1, 30)
if term and term.setTextColor then
term.setTextColor(colors.red)
print("OTA Update Error: " .. tostring(res))
term.setTextColor(colors.white)
end
end
else
lastUpdateError = "loadfile failed: " .. tostring(err)
if term and term.setTextColor then
term.setTextColor(colors.red)
print("OTA Update Error: " .. tostring(err))
term.setTextColor(colors.white)
end
end
isUpdating = false
pcall(drawVersionIndicator)
if lastUpdateError then
sleep(3)
if not lastUpdateError then
os.reboot()
end
os.reboot()
end
local function backgroundSyncTask()