-- Lua Countdown caller -- -- Adapted from the example provided in the Lua Reference Guide for OpenTX 2.1: https://dsbeach.gitbooks.io/opentx-lua-reference-guide/content/function_scripts.html -- by Samu Mäntyniemi -- -- The default voice countdown caller of OpenTX 2.1 works quite well for FxJ thermal duration training -- and competition sessions. However, sometimes more frequent calling towards the end of the working time -- might be desired. This Lua scripts helps you to add calls wherever you want. -- SETUP -- 1) Save this code on the Taranis SD card as SCRIPTS\FUNCTIONS\caller.lua -- 2) Go to MODEL SETUP/SPECIAL FUNCTIONS -- 3) Make a new function to an empty slot by choosing a switch. ON means always active -- 4) Action: "Lua Script" ( or "Play Script" in Companion ) -- 5) Parameters: choose "caller.lua" -- 6) Next time you use your countdown timer, you should here the additional announcements! -- EDITING -- Calls the remaining time of Timer 1 at times specified in "announcements" vector. -- Edit the announcements (in seconds) to customize to your own needs. -- For example: -- local announcements = { 90 , 15} -- announces the remaining time at 1:30 and at 0:15 -- If timer 1 uses voice announcements at the same time points, time will be announced twice: -- either silence the default voice, or specify only additional announcements here. -- -- If you want to use this for Timer 2 instead just change "remaining = model.getTimer(0).value" to -- "remaining = model.getTimer(1).value". local lstannounce local running = false local announcements = { 210, 150, 90, 75, 55, 50, 45, 40, 35, 25, 19, 18, 17, 16, 15, 14, 13, 12, 11} local annIndex local minUnit local function init() local version = getVersion() if version < "2.1" then minUnit = 16 -- must be running OpenTX 2.0 else minUnit = 23 end end local function run() local remaining local minutes local seconds if not running then running = true annIndex = 1 end remaining = model.getTimer(0).value if remaining < 0 then running = false -- we were 'paused' and missed zero return end while remaining < announcements[annIndex] do annIndex = annIndex + 1 -- catch up in case we were paused end if remaining == announcements[annIndex] then minutes = math.floor(remaining / 60) seconds = remaining % 60 if minutes > 0 then playNumber(minutes, minUnit, 0) end if seconds > 0 then playNumber(seconds, 0, 0) end annIndex = annIndex + 1 end if remaining <= 0 then playNumber(0,0,0) running = false end end return { init=init, run=run }