Skip to content

Instantly share code, notes, and snippets.

@j0hnm4r5
Created April 9, 2026 06:10
Show Gist options
  • Select an option

  • Save j0hnm4r5/a996e5fd879d79930599365902666086 to your computer and use it in GitHub Desktop.

Select an option

Save j0hnm4r5/a996e5fd879d79930599365902666086 to your computer and use it in GitHub Desktop.
Continuous throttle pitch for EdgeTX radios
-- thrvar.lua — Throttle → continuous pitch via PLAY_BACKGROUND
-- Place in /SCRIPTS/FUNCTIONS/thrvar.lua
-- Add to Special Functions: Switch=<your switch>, Function=Lua, File=thrvar
-- ── Config ────────────────────────────────────────────────────────────────
local MIN_FREQ = 250 -- Hz when throttle is just above the floor
local MAX_FREQ = 1000 -- Hz at full throttle
local THR_FLOOR = -950 -- throttle values at or below this = silence
-- (-1024 is absolute minimum; -950 leaves a small deadband)
-- ─────────────────────────────────────────────────────────────────────────
local thr_id
local function init()
local info = getFieldInfo("thr")
if info then thr_id = info.id end
end
local function silence()
playTone(150, 1, 0, PLAY_BACKGROUND)
end
local function run()
local thr = getValue(thr_id or "thr") -- −1024 … +1024
if thr <= THR_FLOOR then
silence()
return
end
local freq = MIN_FREQ + math.floor((thr - THR_FLOOR) * (MAX_FREQ - MIN_FREQ) / (1024 - THR_FLOOR))
playTone(freq, 30000, 0, PLAY_BACKGROUND)
end
local function background()
silence()
end
return { init = init, run = run, background = background }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment