--FunctionScript to calculate LoverD (GlideRatio) to telemetry sensors to log it in the logfile --Copyright LShems --www.just.solutions --GPL -- --copy file to /SCRIPTS/FUNCTIONS -- --!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --!!!! create special function with switch ON to run the script 'logchx' !!!! --!!!! make sure all units are the same: kts or m/s !!!! --!!!! set new output sensors LD_A and LD_V to precision 0.00 !!!! --!!!! add sensor by creating calculated sensor and name it Gdst !!!! --!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -- --detect sensors. --after detection, delete current logfile --this to allow the new columns to be created correctly in the new logfile. local AltBaro = function() return getValue("Alt") or 0 end local VSpdBaro = function() return getValue("VSpd") or 0 end local GSpd = function() return getValue("GSpd") or 0 end local Gdst = function() return getValue("Gdst") or 0 end --uncomment and adjust if you prefer sensor positions --local AltBaro = function() return getValue("telem8") or 0 end --local VSpdBaro = function() return getValue("telem5") or 0 end --local GSpd = function() return getValue("telem3") or 0 end --local Gdst = function() return getValue("telem9") or 0 end --!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --don't edit below this if you don't know what you are doing --!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! local altOld local distOld local LD_Vspd = 0 local LD_Alt = 0 return { init=function() altOld = AltBaro() distOld = Gdst() end, run=function() local alt = AltBaro() local dist = Gdst() local vSpeed = VSpdBaro() local gSpeed = GSpd() if alt~=altOld then LD_Alt = (distOld-dist)/(altOld-alt)*100 end if vSpeed~=0 then LD_Vspd = gSpeed/vSpeed*100 end setTelemetryValue(0X0000,0,101,LD_Alt,0,2,"LD_A") setTelemetryValue(0X0000,0,102,LD_Vspd,0,2,"LD_V") altOld = alt distOld = dist end, }