--By Nigelsheffield, script for averaging the altitdude readings intended for ds type lift. --The idea is to get the highest and lowest points of each thermal/d.s circuit and then average the 2 together to give a stable readout of the altitude rather then lots of different readings taken at varying points in the circuit. the output will be spocken and switch on /off by a switch or logical switch local alt_id = getFieldInfo("altitude").id local alt = 0 local lastalt = 0 local topalt = 0 local lowalt = 0 local topmark = 0 local lowmark = 0 local avalt = 0 local function run() alt = getValue(alt_id) * 3.28 -- get height in feet, delete the * 3.28 if you want it in meters if lastalt > alt and topmark == 0 then --we have reached the top of circuit detected by looking for a drop topmark = 1--mark as top reached no more drops will be noticed topalt = alt if topalt > (lowalt+0.5) then --filter small amount of turbulence change the 0.3 to suit avalt = (topalt + lowalt) / 2 playNumber(avalt, 0, 1) end end if lastalt < alt and topmark == 1 then --we have reached bottom by detecting climb topmark = 0 lowalt = alt end lastalt = alt end return { run=run }