Le Timer fonctionne de façon linéaire avec l'aiguille de déplacement douce, mais pas de façon non linéaire il suffit d'enlever les if then ça fonctionne avec l'aiguille de déplacement douce mais avec des valeur erronée.



Je crois que je vais enlever la fonction batterie et arrêter de ma casser la tête.

Jacques

- Code: Tout sélectionner
local gbl_max_fuel = 35
local gallons_L = 0
local gbl_cur_fuel = 0
local gbl_factor = 0.09
--Fuel_reservoir_L
function Fuel_reservoir_L(gallons_left,batterie,ffleft,ffright)
-- Convert weight in KG to gallons with 2.73KG / gallon
gallons = gallons_left
if batterie == true or (ffleft > 0) or ( ffright > 0) then
gallons_L = var_cap(gallons_left, 0, gbl_max_fuel)
else
gallons_L = 0
end
end
function timer_callback()
--gbl_max_fuel * gbl_cur_fuel
--if gallons_L > 35 then si plus de 35 Gallons
--img_rotate(img_Aiguille_Fuel_L, 262) --Alors galons = rotation Max 262°
img_rotate(img_Aiguille_Fuel_L, (262 / gbl_max_fuel * gbl_cur_fuel))
if gallons_L >= 24 then
img_rotate(img_Aiguille_Fuel_L, (38 / 11*(gallons_L-24)) + 224)
elseif gallons_L >= 20 then
img_rotate(img_Aiguille_Fuel_L, (39 / 4*(gallons_L-20)) + 185)
elseif gallons_L >= 16 then
img_rotate(img_Aiguille_Fuel_L, (36 / 4*(gallons_L-16)) + 149)
elseif gallons_L >= 12 then
img_rotate(img_Aiguille_Fuel_L, (54 / 4*(gallons_L-12)) + 95)
elseif gallons_L >= 8 then
img_rotate(img_Aiguille_Fuel_L, (47 / 4*(gallons_L-8)) + 48)
elseif gallons_L >= 4 then
img_rotate(img_Aiguille_Fuel_L, (34 / 4*(gallons_L-4)) + 14)
else
img_rotate(img_Aiguille_Fuel_L, (14 / 4* gallons_L))
-- Calculate the current fuel position
gbl_cur_fuel = gbl_cur_fuel + ((gallons_L - gbl_cur_fuel) * gbl_factor)
end
-- Calculate the current fuel position
--cur_fuel_l = cur_fuel_l + ((target_fuel_l - cur_fuel_l) * factor_l)
fsx_variable_subscribe("FUEL TANK CENTER QUANTITY", "Gallons",
"ELECTRICAL MASTER BATTERY", "Bool",
"RECIP ENG FUEL FLOW:1", "Pounds per hour",
"RECIP ENG FUEL FLOW:2", "Pounds per hour", Fuel_reservoir_L)
end
tmr_update = timer_start(0, 50, timer_callback)
PS: Sur le forum Siminnovation il y a un exemple mais je ne comprend pas comment il fait pour faire var_cap(cur_fuel_l , 0, 116) avec la function timer_callback()

function timer_callback()
cur_fuel_l = var_cap(cur_fuel_l , 0, 116)
https://siminnovations.com/forums/viewt ... back#p3922