-- copy this script to /SCRIPT/MIXES BattCapacity = 0 BattFuel = 0 timeOld1 = 0 timeOld2 = 0 timeNow = 0 local announcements = { 90, 75, 50, 40, 30, 25, 20, 18, 16, 14, 12, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0} local annIndex = 1 -- index into the announcements table (1 based) local mAhUnit = 13 -- used by playNumber() for unit announcement (here: percent) local input = { { "control", SOURCE} -- control used to set battery capacity, preferred is "S1" } local function init() timeNow = getTime() timeOld1 = timeNow timeOld2 = timeNow end local function run(control) local BattUse timeNow = getTime() if timeNow > (timeOld1 + 30) then timeOld1 = timeNow BattCapacity = (control + 1025) * 3 BattUse = getValue("KAPA") BattFuel = math.floor((1 - BattUse / BattCapacity) *100) end while (annIndex < 22) and (BattFuel < announcements[annIndex + 1]) do annIndex = annIndex + 1 -- catch up if lost one announcement end while (annIndex > 1) and (BattFuel > announcements[annIndex - 1]) do annIndex = annIndex - 1 -- catch up if battery reset end if (timeNow > (timeOld2 + 300)) and (BattFuel <= announcements[annIndex]) then timeOld2 = timeNow playNumber(BattFuel, mAhUnit) annIndex = annIndex + 1 end return end return { input=input, init=init, run=run }