-- GPS Satellite Display for RadioMaster GX12 -- Displays satellite count on mode selector RGB LEDs -- Red: < 8 sats, Yellow: 8-10 sats, Green: 11+ sats -- Place in /SCRIPTS/RGBLED/ folder -- Activate via Special Functions -> RGB Led local LED_COUNT = 6 -- 6 mode selector buttons (indices 0-5) -- SA/SD are indices 6-7 if you want to use them local function init() -- Clear all LEDs on init for i = 0, LED_COUNT - 1 do setRGBLedColor(i, 0, 0, 0) end applyRGBLedColors() end local function getColor(satCount) if satCount < 8 then return 255, 0, 0 -- Red elseif satCount <= 10 then return 255, 150, 0 -- Yellow/Amber else return 0, 255, 0 -- Green end end local function run() -- Get GPS satellite count from ELRS telemetry -- Common sensor names: "Sats", "Tmp2" (for some setups) local satCount = 0 -- Try "Sats" first (standard ELRS GPS satellite sensor) local satsField = getFieldInfo("Sats") if satsField then local val = getValue(satsField.id) if type(val) == "number" then satCount = val end else -- Fallback: try "Tmp2" (some FC configurations use this) local tmp2Field = getFieldInfo("Tmp2") if tmp2Field then local val = getValue(tmp2Field.id) if type(val) == "number" then satCount = val end end end -- Clamp to valid range if satCount < 0 then satCount = 0 end -- Get color based on satellite count local r, g, b = getColor(satCount) -- Number of LEDs to light (max 6 for mode buttons) local ledsToLight = math.min(satCount, LED_COUNT) -- Set LED colors - light up sequentially for i = 0, LED_COUNT - 1 do if i < ledsToLight then setRGBLedColor(i, r, g, b) else setRGBLedColor(i, 0, 0, 0) -- Off end end -- Apply the changes applyRGBLedColors() end local function background() -- Called when Special Function switch is off -- Turn off all LEDs for i = 0, LED_COUNT - 1 do setRGBLedColor(i, 0, 0, 0) end applyRGBLedColors() end return { init = init, run = run, background = background }