size = { 670, 895 }

defineProperty("airspeed_acceleration_kts_sec_pilot", globalPropertyf("sim/cockpit2/gauges/indicators/airspeed_acceleration_kts_sec_pilot"))

defineProperty("autopilot_mode", globalPropertyi("sim/cockpit/autopilot/autopilot_mode"))

defineProperty("baro_pref", globalPropertyi("cl300/baro_pref"))
defineProperty("efis_map_range", globalPropertyi("sim/cockpit2/EFIS/map_range"))

defineProperty("nosewheelspd", globalPropertyf("sim/flightmodel/misc/nosewheel_speed"))

defineProperty("EFIS_shows_airports", globalPropertyi("sim/cockpit/switches/EFIS_shows_airports"))
defineProperty("EFIS_shows_waypoints", globalPropertyi("sim/cockpit/switches/EFIS_shows_waypoints"))
defineProperty("EFIS_shows_VORs", globalPropertyi("sim/cockpit/switches/EFIS_shows_VORs"))
defineProperty("EFIS_shows_NDBs", globalPropertyi("sim/cockpit/switches/EFIS_shows_NDBs"))

defineProperty("frame_rate_period", globalPropertyf("sim/operation/misc/frame_rate_period"))

defineProperty("flaprqst", globalPropertyf("sim/flightmodel/controls/flaprqst"))
defineProperty("flaprat", globalPropertyf("sim/flightmodel/controls/flaprat"))
defineProperty("flaps_warn", globalPropertyi("cl300/flaps_warn"))
defineProperty("gear_warn_w", globalPropertyi("cl300/gear_warn_w"))


defineProperty("wind_speed_kt", globalPropertyi("sim/cockpit2/gauges/indicators/wind_speed_kts"))

defineProperty("refspds", globalPropertyi("cl300/refspds"))
defineProperty("refspds_v1", globalPropertyi("cl300/refspds_v1"))
defineProperty("refspds_vr", globalPropertyi("cl300/refspds_vr"))
defineProperty("refspds_v2", globalPropertyi("cl300/refspds_v2"))
defineProperty("refspds_vt", globalPropertyi("cl300/refspds_vt"))
defineProperty("refspds_vga", globalPropertyi("cl300/refspds_vga"))
defineProperty("refspds_vref", globalPropertyi("cl300/refspds_vref"))

defineProperty("radio_altimeter_bug_ft_pilot", globalPropertyf("sim/cockpit2/gauges/actuators/radio_altimeter_bug_ft_pilot"))
defineProperty("radio_altimeter_height_ft_pilot", globalPropertyf("sim/cockpit2/gauges/indicators/radio_altimeter_height_ft_pilot"))

defineProperty("dcp_refs", globalPropertyi("cl300/dcp_refs"))
defineProperty("dcp_refs_menu", globalPropertyi("cl300/dcp_refs_menu"))
defineProperty("autop_brgsrc", globalPropertyi("cl300/autop_brgsrc"))
defineProperty("dcp_navsrc", globalPropertyi("cl300/dcp_navsrc"))
defineProperty("HSI_source_select_pilot", globalPropertyi("sim/cockpit2/radios/actuators/HSI_source_select_pilot"))



defineProperty("nav1_obs_degm", globalPropertyi("sim/cockpit/radios/nav1_obs_degm"))
defineProperty("nav2_obs_degm", globalPropertyi("sim/cockpit/radios/nav2_obs_degm"))
defineProperty("EFIS_1_selection_pilot", globalPropertyi("sim/cockpit2/EFIS/EFIS_1_selection_pilot"))
defineProperty("EFIS_2_selection_pilot", globalPropertyi("sim/cockpit2/EFIS/EFIS_2_selection_pilot"))
defineProperty("EFIS_tcas_on", globalPropertyi("sim/cockpit2/EFIS/EFIS_tcas_on"))
defineProperty("EFIS_weather_on", globalPropertyi("sim/cockpit2/EFIS/EFIS_weather_on"))


defineProperty("rev_air_dat", globalPropertyi("cl300/rev_air_dat"))
defineProperty("rev_att_hd", globalPropertyi("cl300/rev_att_hd"))

defineProperty("onground_all", globalPropertyi("sim/flightmodel/failures/onground_all"))


defineProperty("clock_gps", globalPropertyi("cl300/clock_gps"))
defineProperty("clock_flt", globalPropertyi("cl300/clock_flt"))
defineProperty("timer_elapsed_time_sec", globalPropertyf("sim/time/timer_elapsed_time_sec"))
defineProperty("totaltime", globalPropertyf("sim/time/total_running_time_sec"))
defineProperty("clock_mode", globalPropertyi("cl300/clock_mode"))
defineProperty("current_day", globalPropertyi("sim/cockpit2/clock_timer/current_day"))
defineProperty("current_month", globalPropertyi("sim/cockpit2/clock_timer/current_month"))
defineProperty("zulu_time_hours", globalPropertyi("sim/cockpit2/clock_timer/zulu_time_hours"))
defineProperty("zulu_time_minutes", globalPropertyi("sim/cockpit2/clock_timer/zulu_time_minutes"))
defineProperty("zulu_time_seconds", globalPropertyi("sim/cockpit2/clock_timer/zulu_time_seconds"))
defineProperty("local_time_hours", globalPropertyi("sim/cockpit2/clock_timer/local_time_hours"))
defineProperty("local_time_minutes", globalPropertyi("sim/cockpit2/clock_timer/local_time_minutes"))
defineProperty("local_time_seconds", globalPropertyi("sim/cockpit2/clock_timer/local_time_seconds"))


defineProperty("elapsed_time_minutes", globalPropertyi("sim/cockpit2/clock_timer/elapsed_time_minutes"))
defineProperty("elapsed_time_seconds", globalPropertyi("sim/cockpit2/clock_timer/elapsed_time_seconds"))

defineProperty("barometer_current_inhg", globalPropertyf("sim/weather/barometer_current_inhg"))

defineProperty("autopilot_disconnect", globalPropertyi("sim/cockpit/warnings/annunciators/autopilot_disconnect"))
defineProperty("autop_xfr_h", globalPropertyi("cl300/autop_xfr_h"))
defineProperty("bank_angle_mode", globalPropertyi("sim/cockpit2/autopilot/bank_angle_mode"))
defineProperty("half_bank_h", globalPropertyi("cl300/half_bank_h"))


defineProperty("approach_status", globalPropertyi("sim/cockpit2/autopilot/approach_status"))
defineProperty("TOGA_lateral_status", globalPropertyi("sim/cockpit2/autopilot/TOGA_lateral_status"))
defineProperty("TOGA_status", globalPropertyi("sim/cockpit2/autopilot/TOGA_status"))
defineProperty("heading_status", globalPropertyi("sim/cockpit2/autopilot/heading_status"))
defineProperty("backcourse_status", globalPropertyi("sim/cockpit2/autopilot/backcourse_status"))
defineProperty("vvi_status", globalPropertyi("sim/cockpit2/autopilot/vvi_status"))
defineProperty("altitude_hold_status", globalPropertyi("sim/cockpit2/autopilot/altitude_hold_status"))
defineProperty("speed_status", globalPropertyi("sim/cockpit2/autopilot/speed_status"))
defineProperty("altitude_hold_armed", globalPropertyi("sim/cockpit2/autopilot/altitude_hold_armed"))
defineProperty("pitch_status", globalPropertyi("sim/cockpit2/autopilot/pitch_status"))
defineProperty("roll_status", globalPropertyi("sim/cockpit2/autopilot/roll_status"))
defineProperty("nav_status", globalPropertyi("sim/cockpit2/autopilot/nav_status"))
defineProperty("autopilot_on", globalPropertyi("sim/cockpit2/autopilot/autopilot_on"))
defineProperty("yaw_damper_on", globalPropertyi("sim/cockpit2/switches/yaw_damper_on"))
defineProperty("servos_on", globalPropertyi("sim/cockpit2/autopilot/servos_on"))
defineProperty("glideslope_status", globalPropertyi("sim/cockpit2/autopilot/glideslope_status"))

defineProperty("bank_line", loadImage("menu1.png", 322, 314, 62, 8))
defineProperty("ap_vs_tr", loadImage("menu1.png", 358, 234, 12, 17))
defineProperty("ap_arrow_down", loadImage("menu1.png", 340, 226, 5, 32))
defineProperty("ap_arrow_up", loadImage("menu1.png", 347, 226, 5, 32))
defineProperty("ap_arrow_l", loadImage("menu1.png", 340, 260, 26, 11))
defineProperty("ap_arrow_r", loadImage("menu1.png", 340, 271, 26, 11))
defineProperty("ap_arrow_l_w", loadImage("menu1.png", 340, 282, 26, 11))
defineProperty("ap_arrow_r_w", loadImage("menu1.png", 340, 293, 26, 11))
defineProperty("ap_arrow_l_r", loadImage("menu1.png", 340, 326, 26, 11))
defineProperty("ap_arrow_r_r", loadImage("menu1.png", 340, 337, 26, 11))
defineProperty("menu1", loadImage("menu1.png", 265, 94, 69, 26))
defineProperty("minimums", loadImage("menu1.png", 404, 303, 42, 23))
defineProperty("stall", loadImage("menu1.png", 418, 407, 67, 23))
defineProperty("aoa_yellow", loadImage("menu1.png", 489, 407, 50, 23))
defineProperty("aoa_red", loadImage("menu1.png", 541, 407, 50, 23))
defineProperty("green_line", loadImage("menu1.png", 342, 183, 1, 1))
defineProperty("red_line", loadImage("menu1.png", 467, 341, 1, 1))
defineProperty("blue_line", loadImage("menu1.png", 482, 341, 1, 1))
defineProperty("banana", loadImage("menu1.png", 933, 1002, 91, 15))

defineProperty("stall_warning", globalPropertyi("sim/cockpit2/annunciators/stall_warning"))
defineProperty("stall_warn_test", globalPropertyi("cl300/stall_warn_test"))
defineProperty("rudlim_test", globalPropertyi("cl300/rudlim_test"))

defineProperty("altitude_ft_pilot", globalPropertyf("sim/cockpit2/gauges/indicators/altitude_ft_pilot"))
defineProperty("ISA_t", globalPropertyf("cl300/ISA_t"))
defineProperty("utc_h", globalPropertyi("sim/cockpit2/clock_timer/zulu_time_hours"))
defineProperty("utc_min", globalPropertyi("sim/cockpit2/clock_timer/zulu_time_minutes"))
defineProperty("outside_air_temp_degc", globalPropertyi("sim/cockpit2/temperature/outside_air_temp_degc"))
defineProperty("true_airspeed", globalPropertyf("sim/flightmodel/position/true_airspeed"))
defineProperty("machno", globalPropertyf("sim/flightmodel/misc/machno"))
defineProperty("groundspeed", globalPropertyf("sim/flightmodel/position/groundspeed"))
defineProperty("elevation", globalPropertyf("sim/flightmodel/position/elevation"))
defineProperty("temperature_ambient_c", globalPropertyf("sim/weather/temperature_ambient_c"))
defineProperty("autop_altitude", globalPropertyi("sim/cockpit/autopilot/altitude"))
defineProperty("autop_airspeed", globalPropertyf("sim/cockpit/autopilot/airspeed"))
defineProperty("airspeed_is_mach", globalPropertyf("sim/cockpit/autopilot/airspeed_is_mach"))
defineProperty("barometer_setting_in_hg_pilot", globalPropertyf("sim/cockpit2/gauges/actuators/barometer_setting_in_hg_pilot"))
defineProperty("heading_dial_deg_mag_pilot", globalPropertyf("sim/cockpit2/autopilot/heading_dial_deg_mag_pilot"))
defineProperty("heading_AHARS_deg_mag_pilot", globalPropertyf("sim/cockpit2/gauges/indicators/heading_AHARS_deg_mag_pilot"))
defineProperty("vvi_fpm_pilot", globalPropertyf("sim/cockpit2/gauges/indicators/vvi_fpm_pilot"))
defineProperty("vvi_dial_fpm", globalPropertyf("sim/cockpit2/autopilot/vvi_dial_fpm"))
defineProperty("indicated_airspeed", globalPropertyf("sim/flightmodel/position/indicated_airspeed"))

--[=[

--]=]
defineProperty("disp", globalPropertyf("cl300/disp"))

local font1 = loadFont('font_7.fnt')
local font2 = loadFont('font_8.fnt')
local font3 = loadFont('font_9.fnt')
local font4 = loadFont('font_10.fnt')
local font5 = loadFont('font_11.fnt')
local font6 = loadFont('font_12.fnt')
local font7 = loadFont('font_13.fnt')
local font8 = loadFont('font_14.fnt')
local font9 = loadFont('font_15.fnt')
local font10 = loadFont('font_17.fnt')
local isa = 0
local gn = 0
local autop_sp = 0
local machno_p = 0
local baro_p = 0
local heading_dial_h = 0
local heading_a_h = 0
local stby_alt_t = 0
local chrono_hide = 1

local bank_tr = 0
 pos_temp = 0

map_range = 10

set(half_bank_h, 1)

set(clock_mode, 0)

vvi_i = {0,0,0,0}
autop_sp2 = {0,0,0,0}
autop_sp3 = {0,0,0,0}
machno_p2 = {0,0,0,0}
machno_p3 = {0,0,0,0}
baro_p1 = {0,0,0,0}
baro_p2 = {0,0,0,0}
baro_p3 = {0,0,0,0}
baro_p4 = {0,0,0,0}
baro_misc = {"."," IN"}
heading_dial = {0,0,0,0}
heading_a = {0,0,0,0}
heading_a2 = {0,0,0,0}

baro_current = {0,0,0,0}
baro_current2 = {0,0,0,0}

ias = {0,0,0,0,0,0}
stby_alt = {0,0,0,0,0,0,0}
elaps_time_sec = {0,0,0,0,0,0}
elaps_time_min = {0,0,0,0,0,0}

fly_time_hour = {0,0,0,0,0}
fly_time_min = {0,0,0,0,0}

pos_1 = {2, 173, 49, 19}
pos_2 = {2, 373, 49, 19}



bank_alt_last = {bank_tr, get(half_bank_h)}
alt_h={0,0,0,0,0}
flp_10_pos = {0}

color1 = {0.6,0.6,0.6}
color2 = {0,0.8,0}--green
color3 = {0,0.8,0.8}
color4 = {0.8,0.8,0.8}
color5 = {0.9,0.3,0.2}
color6 = {0.9,0.9,0.0}--yellow
color7 = {0.8,0,0}--red

color_efis_w = {0.8,0.8,0.8,0.8,0.8,0.8}

color_fms = {0.6,0.6,0.6}
color_nav1 = {0.6,0.6,0.6}
color_nav2 = {0.6,0.6,0.6}

hours = {0,0,0,0}
mins = {0,0,0,0}

cur_day = {0,0,0,0}
cur_month = {0,0,0,0}
zulu_hours = {0,0,0,0}
zulu_minutes = {0,0,0,0}
zulu_seconds = {0,0,0,0}
loc_hours = {0,0,0,0}
loc_minutes = {0,0,0,0}
loc_seconds = {0,0,0,0}

pos_spd_trend1 = { 200, 699, 3, 25 }
pos_spd_trend2 = { 193, 724, 10, 3 }

pos_alttrend = { 296, 350, 91, 15 }




time_now = {0,0}
last_states = {get(timer_elapsed_time_sec),get(onground_all), get(clock_flt)}


line1 = {"0"}
line2 = {"0"}
line3 = {"0"}
line4 = {"0"}
line5 = {"0"}
line6 = {"0"}
line7 = {"0"}
line8 = {"0"}
line9 = {"0"}
line10 = {"0"}
line11 = {"0"}
line12 = {"0"}
line13 = {"0"}
line14 = {"0"}
line15 = {"0"}
line16 = {"0"}
line17 = {"0"}

line18 = {0,{0,0,0}}
line19 = {"0"}
line20 = {"0"}
line21 = {"0"}
line22 = {"0"}
line23 = {"0"}
line24 = {"0"}
line25 = {"0"}

line26 = {"0"}
line27 = {"0"}
line28 = {"0"}
line29 = {"0"}
line30 = {"0"}
line31 = {"0"}

line32 = {"0"}
line33 = {"0"}
line34 = {"0"}
line35 = {"0"}
line36 = {"0"}
line37 = {"0"}
line38 = {"0"}
line39 = {"0"}
line40 = {"0"}
line41 = {"0"}
line42 = {"0"}

line43 = {"0"}
line44 = {"0"}
line45 = {"0"}
line46 = {"0"}

line47 = {"0"}
line48 = {"0"}
line49 = {"0"}
line50 = {"0"}

line51 = {"0"}
line52 = {"0"}
line53 = {"0"}

line54 = {"0"}

line55 = {"0","0","0"}
line56 = {"0","0","0"}
line57 = {"0","0","0"}


line58 = {"0"}
line59 = {"0"}
line60 = {"0"}
line61 = {"0"}
line62 = {"0"}
line63 = {"0"}

line64 = {"0"}

line65 = {"0"}

line66 = {"0"}
line67 = {"0"}

line68 = {"0"}


line69 = {"0","0"}
line70 = {"0","0"}
line71 = {"0","0"}
line72 = {"0","0"}

refspd_pos = {0,0,0,0,0,0,0}
alt_trend_range_coeff = 64*0.5^((get(efis_map_range) + 1) - 1)
alt_trend_vert_pos = alt_trend_range_coeff * 0.000164578834 * (get(autop_altitude) - get(altitude_ft_pilot)) * (get(groundspeed)*196.850394) / get(vvi_fpm_pilot)

--[=[components = {

    rectangle {
        position = { 0, 0, size[1], size[2] };
        color = { 0.05, 0.05, 0.05, 1.0 };
    },
autop_brgsrc

}--]=]

efis_mods = {"NO","NO","NO","NO"}

function update ()

-- Alt trend
alt_trend_range_coeff = 64*0.5^((get(efis_map_range) + 1) - 1)
alt_trend_vert_pos = alt_trend_range_coeff * 0.000164578834 * (get(autop_altitude) - get(altitude_ft_pilot)) * (get(groundspeed)*196.850394) / get(vvi_fpm_pilot)
pos_alttrend = { 296, 295 + alt_trend_vert_pos, 91, 15 }


--[=[
altitude_ft_pilot -- ft
groundspeed -- m/s * 196.850394 - ft/m
vvi_fpm_pilot -- ft/m
autop_altitude -- ft

--ft to nm = ft * 0.000164578834
--]=]


-- ASI trend
if math.abs(get(airspeed_acceleration_kts_sec_pilot)) < 12.5 then
	if get(airspeed_acceleration_kts_sec_pilot) >= 0 then
	pos_spd_trend1 = { 200, 699, 3, get(airspeed_acceleration_kts_sec_pilot)*10 }
	else
	pos_spd_trend1 = { 200, 699 + get(airspeed_acceleration_kts_sec_pilot)*10, 3, math.abs(get(airspeed_acceleration_kts_sec_pilot)*10) }
	end
pos_spd_trend2 = { 193, 699 + get(airspeed_acceleration_kts_sec_pilot)*10, 10, 3 }
end
--airspeed_acceleration_kts_sec_pilot

---

if get(EFIS_shows_airports) > 0 then efis_mods[1] = "YES" else efis_mods[1] = "NO" end
if get(EFIS_shows_waypoints) > 0 then efis_mods[2] = "YES" else efis_mods[2] = "NO" end
if get(EFIS_shows_VORs) > 0 then efis_mods[3] = "YES" else efis_mods[3] = "NO" end
if get(EFIS_shows_NDBs) > 0 then efis_mods[4] = "YES" else efis_mods[4] = "NO" end


-- AP

-- half bank mode

if bank_alt_last[2] - get(half_bank_h) ~= 0 and  get(autopilot_on) > 0 and get(roll_status) == 0 and get(TOGA_lateral_status) == 0 and get(bank_angle_mode) == 0 then
set(bank_angle_mode,3)
elseif bank_alt_last[2] - get(half_bank_h) ~= 0 then set(bank_angle_mode,0)

end

if get(altitude_ft_pilot) > 31600 then
bank_tr = 1
else
bank_tr = 0
end

if bank_alt_last[1] - bank_tr ~= 0 and bank_tr == 1 then
set(bank_angle_mode,3)
else
if bank_alt_last[1] - bank_tr ~= 0 and bank_tr == 0 then
set(bank_angle_mode,0)
end
end


if get(servos_on) == 1 then
line18 = {string.format("%s", "  AP"),color2}
else
	if get(autopilot_disconnect) < 1 then
	line18 = {string.format("%s", ""),color2}
	else
	line18 = {string.format("%s", "  AP"),color7}
	end
end

if get(yaw_damper_on) == 1 then
line19 = {string.format("%s", "  YD")}
else
line19 = {string.format("%s", "")}
end

if get(autopilot_on) > 0 and get(roll_status) > 0 then
line20 = {string.format("%s", "           ROLL")}
else
	if get(autopilot_on) > 0 and get(backcourse_status) == 2 then
	line20 = {string.format("%s", "             B/C")}
	else
			if get(autopilot_on) > 0 and get(TOGA_lateral_status) > 0 then
			line20 = {string.format("%s", "             TO")}
			else

			line20 = {string.format("%s", "")}
			end
	end
end


if get(autopilot_on) > 0 and get(heading_status) == 2 and get(TOGA_lateral_status) == 0 and get(backcourse_status) ~= 2 then
line24 = {string.format("%s", "           HDG")}
else
	if get(nav_status) == 2 and get(backcourse_status) ~= 2 then
		if get(HSI_source_select_pilot) == 1 then
		line24 = {string.format("%s", "          LOC2")}
		else
			if get(HSI_source_select_pilot) == 2 and get(backcourse_status) ~= 2 then
			line24 = {string.format("%s", "          FMS1")}
			else
			line24 = {string.format("%s", "          LOC1")}
			end
		end
	else
	line24 = {string.format("%s", "")}
	end
end

if get(autopilot_on) > 0 and get(bank_angle_mode) > 0 and get(roll_status) == 0 then
line25 = {string.format("%s", "1/2 BNK")}
else
line25 = {string.format("%s", "")}
end


if get(autopilot_on) > 0 and get(pitch_status) > 0 then
line21 = {string.format("%s", "PTCH")}
else

	if get(autopilot_on) > 0 and get(speed_status) > 0 then
	line21 = {string.format("%s", "FLC")}
	else
		if get(autopilot_on) > 0 and get(altitude_hold_status) > 1 then
		line21 = {string.format("%s", "ALT")}
		else
			if get(autopilot_on) > 0 and get(TOGA_status) > 0 then
			line21 = {string.format("%s", "TO")}
			else
				if get(autopilot_on) > 0 and get(vvi_status) > 0  then
					if get(vvi_dial_fpm) == 0 then
					line21 = {string.format("%s", "VS")}
					else
					line21 = {string.format("%s%s", "VS     ", math.abs(math.floor(get(vvi_dial_fpm))))}
					end
				else
					if get(glideslope_status) == 2 then
					line21 = {string.format("%s", "GS     ")}
					else
					line21 = {string.format("%s", "")}
					end
				end
			end
		end
	end


end






if get(altitude_hold_armed) == 1 and get(glideslope_status) == 0 then
line22 = {string.format("%s", "ALTS")}
else
	if get(glideslope_status) == 1 then
	line22 = {string.format("%s", "GS")}
	else
	line22 = {string.format("%s", "")}
	end
end

if get(backcourse_status) == 1 then
line23 = {string.format("%s", "              B/C")}
else
	if get(approach_status) == 1 then
	line23 = {string.format("%s", "           APPR")}
	else
		if get(nav_status) == 1 then
			if get(HSI_source_select_pilot) > 0 then
			line23 = {string.format("%s", "           LNV2")}
			else
			line23 = {string.format("%s", "           LNV1")}
			end
		else
		line23 = {string.format("%s", "")}
		end
	end
end


if get(elevation)*3.2808399 < 36000 then
isa = 15-2*(get(elevation)*3.2808399)/1000
else
isa = -56.5
end

hours = {math.modf(get(utc_h)/10)}
mins = {math.modf(get(utc_min)/10)}

gn = get(autop_altitude)

autop_sp2 = {math.modf(get(autop_airspeed)*100)}
if get(airspeed_is_mach) > 0.5 then
		if autop_sp2[2] > 0.5 then
		autop_sp = math.ceil(get(autop_airspeed)*100)
		else
		autop_sp = math.floor(get(autop_airspeed)*100)
		end
		autop_sp3 = {math.modf(autop_sp/10)}





	line8 = {string.format("%s%s%s","   ", autop_sp3[1],autop_sp3[2]*10)}
	line9 = {string.format("%s", "     M.")}
else
	line8 = {string.format("%i",get(autop_airspeed))}
	line9 = {string.format("%s", "")}
end

--0.3189
--


machno_p2 = {math.modf(get(machno)*1000)}--318&0.9
if machno_p2[2] > 0.5 then
	machno_p = math.ceil(get(machno)*1000)--319
else
	machno_p = math.floor(get(machno)*1000)--318
end

machno_p3[1] = math.floor(machno_p / 100)--3
machno_p = machno_p - machno_p3[1]*100--18
machno_p3[2] = math.floor(machno_p / 10)--1
machno_p3[3] = machno_p - machno_p3[2]*10--8



if get(baro_pref) == 0 then
baro_misc = {"."," IN"}
baro_p1 = {math.modf(get(barometer_setting_in_hg_pilot)*100)}--2999&0.8199
	if baro_p1[2] > 0.5 then
	baro_p = math.ceil(get(barometer_setting_in_hg_pilot)*100)--3000
	else
	baro_p = math.floor(get(barometer_setting_in_hg_pilot)*100)--2999
	end

baro_p2[1] = math.floor(baro_p / 1000)--2
baro_p = baro_p - baro_p2[1]*1000--999
baro_p2[2] = math.floor(baro_p / 100)--9
baro_p = baro_p - baro_p2[2]*100--99
baro_p2[3] = math.floor(baro_p / 10)--9
baro_p2[4] = baro_p - baro_p2[3]*10

else
baro_misc = {""," hPa"}

baro_p = math.floor(get(barometer_setting_in_hg_pilot)*33.86)

baro_p2[1] = math.floor(baro_p / 1000)--2
baro_p = baro_p - baro_p2[1]*1000--999
baro_p2[2] = math.floor(baro_p / 100)--9
baro_p = baro_p - baro_p2[2]*100--99
baro_p2[3] = math.floor(baro_p / 10)--9
baro_p2[4] = baro_p - baro_p2[3]*10


end



-- heading dial
heading_dial = {math.modf(get(heading_dial_deg_mag_pilot))}
if heading_dial[2] > 0.5 then
heading_dial_h = math.ceil(get(heading_dial_deg_mag_pilot))
else
heading_dial_h = math.floor(get(heading_dial_deg_mag_pilot))
end

--heading
--[=[
heading_a = {math.modf(get(heading_AHARS_deg_mag_pilot))}
if heading_a[2] > 0.5 then
heading_a_h = math.ceil(get(heading_AHARS_deg_mag_pilot))
else
heading_a_h = math.floor(get(heading_AHARS_deg_mag_pilot))
end --]=]
heading_a_h = math.floor(get(heading_AHARS_deg_mag_pilot))
--156
heading_a2[1] = math.floor(heading_a_h / 100)--1
heading_a_h = heading_a_h - heading_a2[1]*100--56
heading_a2[2] = math.floor(heading_a_h / 10)--5
heading_a2[3] = heading_a_h - heading_a2[2]*10--6



alt_h[1] = math.floor(gn / 10000)
gn = gn - alt_h[1]*10000
alt_h[2] = math.floor(gn / 1000)
gn = gn - alt_h[2]*1000
alt_h[3] = math.floor(gn / 100)
gn = gn - alt_h[3]*100
alt_h[4] = math.floor(gn / 10)
alt_h[5] = gn - alt_h[4]*10



vvi_i = {math.modf(get(vvi_fpm_pilot))}

if vvi_i[1] > 10 then
line16 = {string.format("%s", vvi_i[1])}
else
line16 = {string.format("%s", "")}
end
if vvi_i[1] < -10 then
line17 = {string.format("%s", -vvi_i[1])}
else
line17 = {string.format("%s", "")}
end


line1 = {string.format("%s%s%s%s%s",hours[1],hours[2]*10," : ",mins[1],mins[2]*10)}
line2 = {get(outside_air_temp_degc)}
line3 = {math.floor(get(true_airspeed)*1.94385)}
line4 = {math.floor(get(groundspeed)*1.94385)}
line5 = {math.floor(get(temperature_ambient_c)-isa)}
line6 = {string.format("%s%s%s", alt_h[1], alt_h[2], alt_h[3])}
line7 = {string.format("%s%s", alt_h[4],alt_h[5])}

line10 = {string.format("%s%s%s%s", ".", machno_p3[1], machno_p3[2],machno_p3[3])}
line12 = {string.format("%s", "M")}
line13 = {string.format("%s%s%s%s%s%s", baro_p2[1], baro_p2[2],baro_misc[1], baro_p2[3],baro_p2[4],baro_misc[2])}
line14 = {string.format("%s%s", "HDG ", heading_dial_h)}
line15 = {string.format("%s%s%s", heading_a2[1],heading_a2[2],heading_a2[3])}


-- baro settings stby instr
baro_current = {math.modf(get(barometer_setting_in_hg_pilot)*33.86)}
baro_current2[1] = math.floor(baro_current[2]*10)


line26 = {string.format("%s%s%s", baro_current[1], ".",  baro_current2[1])}

-- ias stby inst

ias = {math.modf(get(indicated_airspeed))}

line27 = {string.format("%s", math.abs(ias[1]))}

-- alt stby inst
stby_alt_t = math.abs(get(altitude_ft_pilot))


stby_alt[1] = math.floor(stby_alt_t/10000)
stby_alt_t = stby_alt_t - stby_alt[1]*10000
stby_alt[2] = math.floor(stby_alt_t/1000)
stby_alt_t = stby_alt_t - stby_alt[2]*1000
stby_alt[3] = math.floor(stby_alt_t/100)
stby_alt_t = stby_alt_t - stby_alt[3]*100
stby_alt[4] = math.floor(stby_alt_t/10)
--stby_alt[5] = stby_alt_t - stby_alt[4]*10


line28 = {string.format("%s%s",stby_alt[4],"0" )}



line29 = {string.format("%s%s%s", stby_alt[1], stby_alt[2], stby_alt[3] )}

-- clock



if last_states[2] - get(onground_all) ~= 0 and get(onground_all) == 0 then
time_now[2] = get(totaltime)
else
if last_states[2] - get(onground_all) ~= 0 and get(onground_all) == 1 then
time_now[2] = 0
end
end

if get(onground_all) == 0 then
fly_time_hour[1] = math.floor(math.floor((get(totaltime)-time_now[2])/3600)/10)
fly_time_hour[2] = math.floor((get(totaltime)-time_now[2])/3600) - fly_time_hour[1]*10

fly_time_min[1] = math.floor(math.floor(((get(totaltime)-time_now[2])/60)-(fly_time_hour[1]*10+fly_time_hour[2])*60)/10)
fly_time_min[2] = math.floor(((get(totaltime)-time_now[2])/60)-(fly_time_hour[1]*10+fly_time_hour[2])*60) - fly_time_min[1]*10
end



line37 = {string.format("%s%s%s%s%s",fly_time_hour[1],fly_time_hour[2], ":",fly_time_min[1],fly_time_min[2])}
line38 = {string.format("%s", "HR     MIN")}
line39 = {string.format("%s", "FLY")}

if get(clock_gps) == 1 then
line40 = {string.format("%s", "GPS")}
else
line40 = {string.format("%s", "")}
end

if last_states[3] - get(clock_flt) ~= 0 then

time_now[2] = get(totaltime)
fly_time_hour[1] = 0
fly_time_hour[2] = 0

fly_time_min[1] = 0
fly_time_min[2] = 0

end







elaps_time_sec[1] = math.floor(get(elapsed_time_seconds)/10)
elaps_time_sec[2] = get(elapsed_time_seconds) - elaps_time_sec[1]*10

elaps_time_min[1] = math.floor(get(elapsed_time_minutes)/10)
elaps_time_min[2] = get(elapsed_time_minutes) - elaps_time_min[1]*10


-- hiding chrono

if last_states[1] - math.floor(get(timer_elapsed_time_sec)) ~= 0 and math.floor(get(timer_elapsed_time_sec)) == 0 then
time_now[1] = get(totaltime)
else
chrono_hide = 0
end

if get(totaltime) - time_now[1] > 10 and math.floor(get(timer_elapsed_time_sec)) == 0 then chrono_hide = 1 else chrono_hide = 0 end

--]=]

if chrono_hide == 0 then
line30 = {string.format("%s%s%s%s%s",elaps_time_min[1],elaps_time_min[2], ":",elaps_time_sec[1],elaps_time_sec[2])}
line31 = {string.format("%s", "MIN   SEC")}
else
line30 = {string.format("%s", "")}
line31 = {string.format("%s", "")}
end


cur_day[1] = math.floor(get(current_day)/10)
cur_day[2] = get(current_day) - cur_day[1]*10
cur_month[1] = math.floor(get(current_month)/10)
cur_month[2] = get(current_month) - cur_month[1]*10

zulu_hours[1] = math.floor(get(zulu_time_hours)/10)
zulu_hours[2] = get(zulu_time_hours) - zulu_hours[1]*10
zulu_minutes[1] = math.floor(get(zulu_time_minutes)/10)
zulu_minutes[2] = get(zulu_time_minutes) - zulu_minutes[1]*10
zulu_seconds[1] = math.floor(get(zulu_time_seconds)/10)
zulu_seconds[2] = get(zulu_time_seconds) - zulu_seconds[1]*10

loc_hours[1] = math.floor(get(local_time_hours)/10)
loc_hours[2] = get(local_time_hours) - loc_hours[1]*10
loc_minutes[1] = math.floor(get(local_time_minutes)/10)
loc_minutes[2] = get(local_time_minutes) - loc_minutes[1]*10
loc_seconds[1] = math.floor(get(local_time_seconds)/10)
loc_seconds[2] = get(local_time_seconds) - loc_seconds[1]*10


if get(clock_mode) == 0 then
line32 = {string.format("%s%s%s%s%s",loc_hours[1],loc_hours[2], ":",loc_minutes[1],loc_minutes[2])}
line33 = {string.format("%s%s%s", ":",loc_seconds[1],loc_seconds[2])}
line34 = {string.format("%s", "")}

line35 = {string.format("%s", "LOC")}
line36 = {string.format("%s", "")}
else
if get(clock_mode) == 1 then
line32 = {string.format("%s%s%s%s%s",zulu_hours[1],zulu_hours[2], ":",zulu_minutes[1],zulu_minutes[2])}
line33 = {string.format("%s%s%s", ":",zulu_seconds[1],zulu_seconds[2])}
line34 = {string.format("%s", "")}

line35 = {string.format("%s", "")}
line36 = {string.format("%s", "UTC")}
end
if get(clock_mode) == 2 then
line32 = {string.format("%s%s%s%s%s",cur_day[1],cur_day[2], " ",cur_month[1],cur_month[2])}
line33 = {string.format("%s", "")}
line34 = {string.format("%s", "DAY   MONTH")}

line35 = {string.format("%s", "")}
line36 = {string.format("%s", "")}
end


end



if get(rev_att_hd) == 1 then
line41 = {string.format("%s", "")}
else
	if get(rev_att_hd) == 0 then
	line41 = {string.format("%s", "AHS1")}
	else
	line41 = {string.format("%s", "AHS2")}
	end
end


if get(rev_air_dat) == 1 then
line42 = {string.format("%s", "")}
else
	if get(rev_air_dat) == 0 then
	line42 = {string.format("%s", "ADC1")}
	else
	line42 = {string.format("%s", "ADC2")}
	end
end



line43 = {string.format("%s","TR")}
line44 = {string.format("%s","WX")}

if get(EFIS_tcas_on) < 1 then
line46 = {string.format("%s","TFC")}
line45 = {string.format("%s","TCAS OFF")}
else
line46 = {string.format("%s","")}
line45 = {string.format("%s","")}
end

if get(EFIS_weather_on) < 1 then
color_efis_w = {0,0.8,0.8,0.8,0.8,0.8}
else
color_efis_w = {0.8,0.8,0.8,0,0.8,0.8}
end

line47 = {string.format("%s", math.floor(get(nav1_obs_degm)))}
line48 = {string.format("%s", math.floor(get(nav2_obs_degm)))}



if get(EFIS_1_selection_pilot) == 1 then
line49 = {string.format("%s","")}
else
	if get(EFIS_1_selection_pilot) == 2 then
	line49 = {string.format("%s","VOR")}
	else
	line49 = {string.format("%s","ADF")}
	end
end

if get(EFIS_2_selection_pilot) == 1 then
line50 = {string.format("%s","")}
else
	if get(EFIS_2_selection_pilot) == 2 then
	line50 = {string.format("%s","VOR")}
	else
	line50 = {string.format("%s","ADF")}
	end
end


if get(autop_brgsrc) < 1 then
pos_1 = {74, 173, 44, 19}
else
pos_1 = {74, 153, 44, 19}
end




if get(HSI_source_select_pilot) == 0 then
pos_2 = {1, 362, 49, 19}
color_fms = {0,0.8,0.8}
color_nav1 = {0.6,0,0.6}
color_nav2 = {0,0.8,0.8}
line54 = {"NAV1"}
else
	if get(HSI_source_select_pilot) == 1 then
	pos_2 = {1, 342, 49, 19}
	color_fms = {0,0.8,0.8}
	color_nav1 = {0,0.8,0.8}
	color_nav2 = {0.6,0,0.6}
	line54 = {"NAV2"}
	end
	if get(HSI_source_select_pilot) == 2 then
	pos_2 = {1, 382, 49, 19}
	color_fms = {0.6,0,0.6}
	color_nav1 = {0,0.8,0.8}
	color_nav2 = {0,0.8,0.8}
	line54 = {"FMS1"}
	end
end



line51 = {"FMS1"}
line52 = {"NAV1"}
line53 = {"NAV2"}



if get(refspds) == 2 then
line57 = {string.format("%s",get(refspds_vt)),string.format("%s",get(refspds_vga)),string.format("%s",get(refspds_vref))}
else
	if get(refspds) == 1 then
	line57 = {string.format("%s",get(refspds_v1)),string.format("%s",get(refspds_vr)),string.format("%s",get(refspds_v2))}
	end
end

if get(dcp_refs) == 0 then
line56 = {string.format("%s","V1"),string.format("%s","VR"),string.format("%s","V2")}
	line55 = {string.format("%s",get(refspds_v1)),string.format("%s",get(refspds_vr)),string.format("%s",get(refspds_v2))}
else
	if get(dcp_refs) == 1 then

	line55 = {string.format("%s",get(refspds_vt)),string.format("%s",get(refspds_vga)),string.format("%s",get(refspds_vref))}
	line56 = {string.format("%s","VT"),string.format("%s","VGA"),string.format("%s","VREF")}
	else
	line56 = {string.format("%s",""),string.format("%s",""),string.format("%s","")}
	line55 = {string.format("%s",""),string.format("%s",""),string.format("%s","")}
	end
end



--vsp_pos = {0,0}
if get(dcp_refs) == 0 then set(refspds, 1) end
if get(dcp_refs) == 1 then set(refspds, 2) end

if get(radio_altimeter_height_ft_pilot) > 2500 then

line68 = {string.format("%s","")}
else


	line68 = {string.format("%s%s%s","MIN ", math.floor(get(radio_altimeter_bug_ft_pilot)+0.01)," RA")}
end



if get(dcp_refs) < 0 then
	if get(radio_altimeter_height_ft_pilot) > 2500 then
	set(refspds, 0)
	line57 = {string.format("%s",""),string.format("%s",""),string.format("%s","")}
	else
		if get(nosewheelspd) > 2.6 or get(onground_all) == 1 then
		set(refspds, 1)
		else
		set(refspds, 2)
		end
	end
end


if get(dcp_refs) > -1 then
	if get(dcp_refs_menu) == 0 then
	pos_1 = {50, 296, 38, 19}
	else
		if get(dcp_refs_menu) == 1 then
		pos_1 = {50, 281, 38, 19}
		else
			if get(dcp_refs_menu) == 2 then
			pos_1 = {50, 266, 38, 19}
			else
				if get(dcp_refs_menu) == 3 then
				pos_1 = {50, 250, 38, 19}
				end
			end
		end
	end
end

if get(refspds) == 0 then
refspd_pos[7] = 571
else
refspd_pos[7] = 661
end


if get(dcp_refs) == 2 then
line65 = {string.format("%s%s%s","MIN  ", math.floor(get(radio_altimeter_bug_ft_pilot)+0.01)," RA")}
pos_1 = {35, 296, 38, 19}
else
	if get(dcp_refs) == 3 then
	line65 = {string.format("%s","")}
	line69 = {string.format("%s%s","BARO  ", baro_misc[2])}
	line70 = {string.format("%s","")}
	line71 = {string.format("%s","")}
	line72 = {string.format("%s","")}
	pos_1 = {52, 296, 38, 19}
	else
		if get(dcp_refs) == 4 then
		line65 = {string.format("%s","")}
		line69 = {string.format("%s%s","APTs  ", efis_mods[1])}
		line70 = {string.format("%s%s","FIXes  ", efis_mods[2])}
		line71 = {string.format("%s%s","VORs  ", efis_mods[3])}
		line72 = {string.format("%s%s","NDBs  ", efis_mods[4])}
		--pos_1 = {46, 296, 38, 19}
		else
		line69 = {string.format("%s","")}
		line70 = {string.format("%s","")}
		line71 = {string.format("%s","")}
		line72 = {string.format("%s","")}
		line65 = {string.format("%s","")}
		end
	end

end


if get(dcp_refs) < 1 then pos_temp = 0 else pos_temp = 1 end



refspd_pos[1] = 695 + (get(refspds_v1) - get(indicated_airspeed))*3.1
refspd_pos[2] = 695 + (get(refspds_vr) - get(indicated_airspeed))*3.1
refspd_pos[3] = 695 + (get(refspds_v2) - get(indicated_airspeed))*3.1
refspd_pos[4] = 695 + (get(refspds_vt) - get(indicated_airspeed))*3.1
refspd_pos[5] = 695 + (get(refspds_vga) - get(indicated_airspeed))*3.1
refspd_pos[6] = 695 + (get(refspds_vref) - get(indicated_airspeed))*3.1

if refspd_pos[1] < 819 and refspd_pos[1] > refspd_pos[7] and get(refspds) == 1 then line58 = {string.format("%s","V1")} else line58 = {string.format("%s","")} end
if refspd_pos[2] < 819 and refspd_pos[2] > refspd_pos[7] and get(refspds) == 1 then line59 = {string.format("%s","Vr")} else line59 = {string.format("%s","")} end
if refspd_pos[3] < 819 and refspd_pos[3] > refspd_pos[7] and get(refspds) == 1 then line60 = {string.format("%s","V2")} else line60 = {string.format("%s","")} end
if refspd_pos[4] < 819 and refspd_pos[4] > refspd_pos[7] and get(refspds) == 2 then line61 = {string.format("%s","Vt")} else line61 = {string.format("%s","")} end
if refspd_pos[5] < 819 and refspd_pos[5] > refspd_pos[7] and get(refspds) == 2 then line62 = {string.format("%s","Vga")} else line62 = {string.format("%s","")} end
if refspd_pos[6] < 819 and refspd_pos[6] > refspd_pos[7] and get(refspds) == 2 then line63 = {string.format("%s","Vref")} else line63 = {string.format("%s","")} end


if get(radio_altimeter_height_ft_pilot) < 2500 then line64 = {string.format("%s",math.floor(get(radio_altimeter_height_ft_pilot)))} else line64 = {string.format("%s","")} end

if get(onground_all) == 0 then
	if get(flaps_warn) > 0 or get(gear_warn_w) > 0 then
	line66 = {string.format("%s","GND PROX")}
	else
	line66 = {string.format("%s","")}
	end
else
line66 = {string.format("%s","")}
end



line67 = {string.format("%s",get(wind_speed_kt))}







if get(flaprqst) > 0.32 and get(flaprqst) < 0.67 then
flp_10_pos[1] = math.max(698 + (210 - get(indicated_airspeed))*3.1, refspd_pos[7])
else
	if get(flaprqst) > 0.67 then
		flp_10_pos[1] = math.max(698 + (175 - get(indicated_airspeed))*3.1, refspd_pos[7])
		else
			if get(flaprqst) < 0.1 then
			flp_10_pos[1] = math.min(math.max(698 + (320 - get(indicated_airspeed))*3.1, refspd_pos[7]),math.max(698 + (0.83 - get(machno))*1110, refspd_pos[7]))
			end

	end
end


--

map_range = 10 * 2 ^((get(efis_map_range) + 1) - 1)

--flp_blue_pos[1] = 695 + (210 - get(indicated_airspeed))*3.1


--set(disp, baro_p2[4])--
set(ISA_t, math.floor(get(temperature_ambient_c)-isa))

bank_alt_last = {bank_tr, get(half_bank_h)}

last_states = {get(timer_elapsed_time_sec),get(onground_all), get(clock_flt)}


end





components = {

-- flp_10 bug
	textureLit {
        position = function ()
		return { 184, flp_10_pos[1], 7, (833 - flp_10_pos[1]) } --flp_10_pos[1]
		end,
        image = get(red_line),
		visible = function ()
	--		if flp_10_pos[1] < 790 and flp_10_pos[1] > refspd_pos[7] then--and get(flaprqst) > 0.32 and get(flaprqst) < 0.34
			return true
	--		else
	--		return false
	--		end

		end,
	},

--[=[	textureLit {
        position = function ()
		return { 183, flp_10_pos[1] + 45, 10, -(flp_10_pos[1] - 790)} --flp_10_pos[1]
		end,
        image = get(blue_line),
		visible = function ()
			--if flp_10_pos[1] < 819 and refspd_pos[1] > refspd_pos[7] then
			return true --get(flaprqst) > 0.32 and get(flaprqst) < 0.34
			--else
			--return false
		end,
	},--]=]


	--



	textureLit {
        position = { 328, 851, 26, 11 },
        image = function ()
		if get(servos_on) > 0 then
		return get(ap_arrow_l)
		else
			if get(autopilot_disconnect) < 1 then
			return get(ap_arrow_l_w)
			else
			return get(ap_arrow_l_r)
			end
		end

		end,
		visible = function ()
		if get(autop_xfr_h) == 0 then
		return true
		else
		return false
		end
		end,
		},

		textureLit {
        position = { 328, 851, 26, 11 },
		image = function ()
		if get(servos_on) > 0 then
		return get(ap_arrow_r)
		else
		if get(autopilot_disconnect) < 1 then
			return get(ap_arrow_r_w)
			else
			return get(ap_arrow_r_r)
			end
		end

		end,
		visible = function ()
		if get(autop_xfr_h) == 1 then
		return true
		else
		return false
		end
		end,
		},

		textureLit {
        position = { 446, 868, 6, 20 },
		image = function()
		if get(vvi_dial_fpm) > 0 then
		return get(ap_arrow_up)
		else
		return get(ap_arrow_down)
		end
		end,
		visible = function ()
		if get(vvi_dial_fpm) ~= 0 and get(vvi_status) > 0 then
		return true
		else
		return false
		end
		end,
		},

		textureLit {
        position = { 394, 868, 12, 17 },
		image = get(ap_vs_tr),
		visible = function ()
		if get(vvi_dial_fpm) ~= 0 and get(vvi_status) > 0 then
		return true
		else
		return false
		end
		end,
		},

		textureLit {
        position = { 310, 827, 62, 8 },
		image = get(bank_line),
		visible = function ()
		if get(bank_angle_mode) > 0 and get(roll_status) == 0 then
		return true
		else
		return false
		end
		end,
		},


		textureLit {
        position = function() return pos_1 end,
        image = get(menu1),
		visible = function()
		return get(dcp_refs) < 5
		end,

    },

		textureLit {
        position = function() return pos_2 end,
        image = get(menu1),
		visible = function()
		return get(dcp_refs) < 2
		end,

    },
		rectangle {
        position = { 0, 150, 120, 98 };
        color = { 0.0, 0.0, 0.0, 1.0 };
		visible = function ()
		return get(autop_brgsrc) == -1
		end,

    },

		rectangle {
        position = { 0, 340, 120, 108 };
        color = { 0.0, 0.0, 0.0, 1.0 };
		visible = function ()
		return get(dcp_navsrc) == -1
		end,

    },

		rectangle {
        position = { 319, 580, 43, 25 };
        color = { 0.0, 0.0, 0.0, 1.0 };
		visible = function ()
		return get(get(radio_altimeter_height_ft_pilot)) < 2500
		end,
    },
		textureLit {
        position = { 405, 710, 42, 23 };
        image = get(minimums),
		visible = function()
		return get(radio_altimeter_height_ft_pilot) < get(radio_altimeter_bug_ft_pilot) + 30 and get(radio_altimeter_height_ft_pilot) > get(radio_altimeter_bug_ft_pilot) - 30 and get(vvi_fpm_pilot) < -100 and get(onground_all) == 0
		end,



    },

			textureLit {
        position = { 310, 737, 67, 23 };
        image = get(stall),
		visible = function()
		return get(stall_warning) == 1 or get(stall_warn_test) == 1
		end,



    },
		textureLit {
        position = { 318, 710, 50, 23 };
        image = get(aoa_yellow),
		visible = function()
		return get(rudlim_test) == 1
		end,
    },


		rectangle {
        position =  function() return pos_spd_trend1 end, --{ 200, 699, 3, 25 };
        color = { 0.8, 0.0, 0.7, 1.0 },
		visible = true,
    },

		rectangle {
        position = function() return pos_spd_trend2 end,
        color = { 0.8, 0.0, 0.7, 1.0 },
		visible = true,
    },


		textureLit {
        position = function () return pos_alttrend end,
        image = get(banana),
		visible = function () return get(autopilot_mode) > 0 and math.abs(get(vvi_fpm_pilot)) > 50 and get(groundspeed) > 10 and alt_trend_vert_pos > 0 and alt_trend_vert_pos < 130 end,



    },
--[=[		rectangle {
        position = { 320, 580, 800, 800 };
        color = { 0.0, 0.0, 0.0, 1.0 };
		visible = true,

    };--]=]

	--[=[		textureLit {
        position = { 355, 710, 50, 23 };
        image = get(aoa_red),
		visible = function()
		return get(stall_warn_test) == 1
		end,



    },--]=]


--[=[		textureLit {
        position = { 124, 570, 80, 88 };
        image = get(vspd_to),
		visible = true,









    },--]=]

};

function draw()

drawText(font1, 50, 176, line47[1],  color3[1],color3[2],color3[3])
drawText(font1, 50, 156, line48[1],  color3[1],color3[2],color3[3])

drawText(font1, 80, 176, line49[1],  color3[1],color3[2],color3[3])
drawText(font1, 80, 156, line50[1],  color3[1],color3[2],color3[3])

drawText(font1, 4, 385, line51[1],  color_fms[1],color_fms[2],color_fms[3])
drawText(font1, 4, 365, line52[1],  color_nav1[1],color_nav1[2],color_nav1[3])
drawText(font1, 4, 345, line53[1],  color_nav2[1],color_nav2[2],color_nav2[3])

drawText(font2, 168, 620, line57[1],  color3[1],color3[2],color3[3])
drawText(font2, 168, 604, line57[2],  color3[1],color3[2],color3[3])
drawText(font2, 168, 588, line57[3],  color3[1],color3[2],color3[3])


drawText(font2, 8, 300, line56[1],  color3[1],color3[2],color3[3])
drawText(font2, 8, 284, line56[2],  color3[1],color3[2],color3[3])
drawText(font2, 8, 268, line56[3],  color3[1],color3[2],color3[3])
drawText(font2, 58, 300, line55[1],  color3[1],color3[2],color3[3])
drawText(font2, 58, 284, line55[2],  color3[1],color3[2],color3[3])
drawText(font2, 58, 268, line55[3],  color3[1],color3[2],color3[3])

drawText(font2, 8, 300, line65[1],  color3[1],color3[2],color3[3])
drawText(font10, 428, 440, line68[1],  color3[1],color3[2],color3[3]) -- minimums display

drawText(font1, 182, refspd_pos[1], line58[1],  color3[1],color3[2],color3[3])
drawText(font1, 182, refspd_pos[2], line59[1],  color3[1],color3[2],color3[3])
drawText(font1, 182, refspd_pos[3], line60[1],  color3[1],color3[2],color3[3])
drawText(font1, 182, refspd_pos[4], line61[1],  color3[1],color3[2],color3[3])
drawText(font1, 182, refspd_pos[5], line62[1],  color3[1],color3[2],color3[3])
drawText(font1, 182, refspd_pos[6], line63[1],  color3[1],color3[2],color3[3])

drawText(font9, 273, 640, line66[1],  color6[1],color6[2],color6[3])

drawAll(components)

drawText(font1, 12, 595, "UTC",  color1[1],color1[2],color1[3])
drawText(font1, 12, 565, "SAT           °C",  color1[1],color1[2],color1[3])
drawText(font1, 12, 548, "ISA            °C",  color1[1],color1[2],color1[3])
drawText(font1, 12, 531, "TAS",  color1[1],color1[2],color1[3])
drawText(font1, 12, 514, "GS",  color1[1],color1[2],color1[3])

drawText(font2, 47, 595, line1[1], color2[1],color2[2],color2[3])
drawText(font2, 53, 565, line2[1], color2[1],color2[2],color2[3])
drawText(font2, 52, 531, line3[1], color2[1],color2[2],color2[3])
drawText(font2, 52, 514, line4[1], color2[1],color2[2],color2[3])
drawText(font2, 52, 548, line5[1], color2[1],color2[2],color2[3])

drawText(font3, 492, 838, line6[1], color3[1],color3[2],color3[3])
drawText(font2, 528, 838, line7[1], color3[1],color3[2],color3[3])
drawText(font3, 165, 833, line8[1], color3[1],color3[2],color3[3])
drawText(font3, 135, 833, line9[1], color3[1],color3[2],color3[3])
drawText(font3, 160, 551, line10[1], color2[1],color2[2],color2[3])
drawText(font3, 143, 551, line12[1], color1[1],color1[2],color1[3])
drawText(font3, 484, 553, line13[1], color3[1],color3[2],color3[3])

drawText(font1, 245, 454, line14[1], color3[1],color3[2],color3[3])
drawText(font1, 330, 451, line15[1], color2[1],color2[2],color2[3])

drawText(font2, 579, 817, line16[1], color2[1],color2[2],color2[3])
drawText(font2, 579, 574, line17[1], color2[1],color2[2],color2[3])

drawText(font1, 313, 873, line18[1], line18[2][1],line18[2][2],line18[2][3])
drawText(font1, 333, 873, line19[1], color2[1],color2[2],color2[3])
drawText(font1, 230, 873, line20[1], color2[1],color2[2],color2[3])
drawText(font1, 373, 873, line21[1], color2[1],color2[2],color2[3])
drawText(font1, 373, 853, line22[1], color4[1],color4[2],color4[3])
drawText(font1, 230, 853, line23[1], color4[1],color4[2],color4[3])

drawText(font1, 230, 873, line24[1], color2[1],color2[2],color2[3])
drawText(font1, 210, 873, line25[1], color2[1],color2[2],color2[3])

drawText(font1, 36, -626, line10[1], color2[1],color2[2],color2[3])

drawText(font1, 143, -420, line26[1], color3[1],color3[2],color3[3])
drawText(font5, 3, -523, line27[1], color2[1],color2[2],color2[3])
drawText(font1, 219, -522, line28[1], color2[1],color2[2],color2[3])
drawText(font5, 191, -521, line29[1], color2[1],color2[2],color2[3])

drawText(font6, 308, -598, line30[1], color5[1],color5[2],color5[3])
drawText(font7, 316, -618, line31[1], color5[1],color5[2],color5[3])

drawText(font6, 308, -522, line32[1], color5[1],color5[2],color5[3])
drawText(font8, 410, -522, line33[1], color5[1],color5[2],color5[3])
drawText(font7, 310, -545, line34[1], color5[1],color5[2],color5[3])
drawText(font7, 251, -522, line35[1], color5[1],color5[2],color5[3])
drawText(font7, 251, -508, line36[1], color5[1],color5[2],color5[3])
drawText(font6, 310, -442, line37[1], color5[1],color5[2],color5[3])
drawText(font7, 316, -463, line38[1], color5[1],color5[2],color5[3])
drawText(font7, 251, -437, line39[1], color5[1],color5[2],color5[3])
drawText(font7, 427, -437, line40[1], color5[1],color5[2],color5[3])

drawText(font5, 594, 544, line41[1], color6[1],color6[2],color6[3])
drawText(font5, 594, 524, line42[1], color6[1],color6[2],color6[3])

drawText(font2, 584, 150, line43[1],  color_efis_w[1],color_efis_w[2],color_efis_w[3])
drawText(font2, 614, 150, line44[1],  color_efis_w[4],color_efis_w[5],color_efis_w[6])

drawText(font1, 590, 430, line45[1],  color3[1],color3[2],color3[3])
drawText(font2, 630, 450, line46[1],  color3[1],color3[2],color3[3])

drawText(font1, 7, 70, line54[1],  color1[1],color1[2],color1[3])
drawText(font1, 60, 70, map_range .. "N",  color1[1],color1[2],color1[3])


drawText(font5, 323, 587, line64[1],  color2[1],color2[2],color2[3])

drawText(font1, 33, 493, line67[1], color2[1],color2[2],color2[3])

drawText(font1, 8, 300, line69[1] ,  color3[1],color3[2],color3[3])
drawText(font1, 8, 284, line70[1] ,  color3[1],color3[2],color3[3])
drawText(font1, 8, 268, line71[1] ,  color3[1],color3[2],color3[3])
drawText(font1, 8, 252, line72[1] ,  color3[1],color3[2],color3[3])


end
