After a couple of hours playing with code i have yet to learn. Through trial and error i managed to get the EGT working and displaying the same as the sim cockpit. Thought id share in case someone else having the same issues, Although It works on my panel im totally new to this, so if there is a mistake please let me know where i have gone wrong so i can improve. If it works enjoy.
regards Alex
fs2020_variable_subscribe("GENERAL ENG EXHAUST GAS TEMPERATURE:1", "Fahrenheit",
"GENERAL ENG EXHAUST GAS TEMPERATURE:2", "Fahrenheit", function(egt1, egt2)
local egt_left = var_cap(egt1 - (user_prop_get(max_egt_prop) - 500), 0, 500)
local egt_right = var_cap(egt2 - (user_prop_get(max_egt_prop) - 500), 0, 500)
rotate(img_needle_right, 116 / 380.5 * egt_left - 58.5)
rotate(img_needle_left, 58.5 - (116 / 380.5 * egt_right) )
msfs2020 EGT carenado PA44 seminole
-
- Posts: 236
- Joined: Sun Feb 14, 2021 6:55 pm
Re: msfs2020 EGT carenado PA44 seminole
Seen your post when browsing through the unanswered topics.
Why don't you use built in features from the AM API, that would make your code so much easier. I suggest the following:
all the calculations are done in the interpolate_linear() function from the AM API helper functions (see the WIKI). No need to do it yourself again.
I think this is not just cleaner code, it is also more understandable for the reader of that code.
Paul
Why don't you use built in features from the AM API, that would make your code so much easier. I suggest the following:
Code: Select all
-- Define scale properties
local RANGE = 500 -- °F
local ALPHA = 35.5 -- the max deflection angle +/-
local MAX = user_prop_get(max_egt_prop)
local MIN = MAX - RANGE
local LEFT = { { MIN, ALPHA }, { MAX, -ALPHA } }
local RIGHT = { { MIN, -ALPHA }, { MAX, ALPHA } }
indicate_egt = function(egt1, egt2)
rotate( img_needle_right, interpolate_linear(RIGHT, egt1, true) )
rotate( img_needle_left, interpolate_linear(LEFT, egt2, true) )
end
fs2020_variable_subscribe(
"GENERAL ENG EXHAUST GAS TEMPERATURE:1", "Fahrenheit",
"GENERAL ENG EXHAUST GAS TEMPERATURE:2", "Fahrenheit",
indicate_egt
)
I think this is not just cleaner code, it is also more understandable for the reader of that code.
Paul
Re: msfs2020 EGT carenado PA44 seminole
Hi
The code I posted is the code that came with the original EGT I'm AM.
I didn't really have an idea what I was doing at that stage, still only just getting to grips with it and understanding the code.
I left that there incase someone else was struggling like I was at the start.
Alex
The code I posted is the code that came with the original EGT I'm AM.
I didn't really have an idea what I was doing at that stage, still only just getting to grips with it and understanding the code.
I left that there incase someone else was struggling like I was at the start.
Alex
Re: msfs2020 EGT carenado PA44 seminole
In most cases it is always code that is easier to read (AND well documented !) that is the 'best' code. Not necessarily the most elegant. The main thing is that YOU understand it. If so, then it is great code.
Joe. CISSP, MSc.