local RIGHT_CHAIN = { 23, 24, 24, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9 } local LEFT_CHAIN = { 22, 21, 20, 18, 17, 16, 15, 14, 13, 12, 11, 10, 19 } local MAX_STEPS = #RIGHT_CHAIN local function init() end local function fillCenterOutCustom(ledValue) -- ledValue 范围 0 到 255 -- 计算当前油门应该扩散到第几层灯珠 (0 到 13) local spreadProgress = (ledValue / 255) * MAX_STEPS local activeSteps = math.floor(spreadProgress) local remainder = spreadProgress - activeSteps local edgeBrightness = math.floor(5 + (remainder * 250)) if ledValue == 255 then activeSteps = MAX_STEPS edgeBrightness = 255 end for step = 1, MAX_STEPS do local rLed = RIGHT_CHAIN[step] local lLed = LEFT_CHAIN[step] if step <= activeSteps then if rLed then setRGBLedColor(rLed, 255, 0, 0) end if lLed then setRGBLedColor(lLed, 255, 0, 0) end elseif step == activeSteps + 1 then if rLed then setRGBLedColor(rLed, edgeBrightness, 0, 0) end if lLed then setRGBLedColor(lLed, edgeBrightness, 0, 0) end else if rLed then setRGBLedColor(rLed, 0, 0, 0) end if lLed then setRGBLedColor(lLed, 0, 0, 0) end end end end local function run() local throttle = getOutputValue(2) local ledValue = math.floor((throttle + 1024) * 255 / 2048) ledValue = math.max(0, math.min(255, ledValue)) fillCenterOutCustom(ledValue) applyRGBLedColors() end local function background() end return { run=run, background=background, init=init }