# XPUIPCOffsets.cfg - XPUIPC offset configuration file
#
# This file configures the mapping between X-Plane datarefs and FSUIPC offsets.
# It consists of a series of Command, Dataref and Offset commands, which can
# appear in any order. Commands are separated by line breaks by default (i.e.
# each one has to appear on its own line), but can be continued on the next line
# with the underscore (_) as the last non-blank character. Each command has a
# number of parameters, which are separated by any amount of white space (blank,
# tab). If not specifically stated otherwise, case is significant. Everything
# beyond a # sign is considered a comment and is ignored, as are blank lines. 
#
#
# Dataref <identifier> <dataref name> <type>
#
# Dataref commands assign a dataref to a unique identifier, and specify the type
# of the dataref. The dataref name is the unique string that identifies the
# dataref within X-Plane. Valid types are: int, float, and double for scalars,
# and intarray, floatarray, and data for arrays. If the dataref is an array,
# the array index in square brackets is appended to the dataref name, like this:
#
# Dataref	eng1_mixt	sim/flightmodel/engine/ENGN_mixt[0]		floatarray
#
#
# Offset <number> <type> <priority> <access> <conversion expression>
# 
# Offset commands specify how the value that can be read from an offset is to be
# calculated from any number of datarefs, and/or how to calculate values for
# any number of datarefs from the value written to an offset. The offset's
# number should be given in the usual hexadecimal notation, with leading 0x.
# For digits beyond 9, lower-case and upper-case letters are supported. Valid
# types are: UINT8, UINT16, UINT32, UINT64 for unsigned integers of various
# widths, SINT8, SINT16, SINT32, SINT64 for signed integers, and FLOAT32,
# FLOAT64 for floating point values. The priority determines how often the
# offset is updated from its corresponding dataref(s). Valid values are:
# 1		every flight model frame
# 2		every 7th frame		
# 3		every 13th frame
# 4		every 31st frame
# 5		every 31st frame, but phase-shifted by 500 ms
# 6		every 59th frame
# 7		every 157th frame
# 8		every 313th frame
# Access mode is one of r, w, or rw, to enable read, write, or read and write
# access, respectively. All remaining parameters, up to a maximum of 256, make
# up the conversion expression, which is explained below. Example:
#
# Offset	0x0890	UINT16	4	rw	$eng1_mixt 16384 * >eng1_mixt @ 16384 /
#
# Note that this is one of the vast number of offsets hard-coded into XPUIPC.
# As offset configured here take precedence over built-in ones, you can override
# the latter with your own implementation if you don't like the default. You can
# even completely disable built-in offsets by giving an Offset command with no
# conversion expression at all (not sure why you'd want to do that, though).
#
#
# Command <offset number> <offset type> [<toggle> <value> <command name>] [...]
#
# Command commands let you trigger actions within X-Plane - anything that can be
# assigned to joystick or keyboard buttons - from offset writes. The offset's
# number and type are specified just like in an Offset command. The remaining
# parameter triple, which can appear more than once, specifies which command
# to trigger when a specific value is written to the offset. Commands come in
# two varieties: toggle commands, meant to be fired momentarily, and continuous
# commands, meant to be 'held down'. If the toggle parameter is 1, the command
# is 'clicked' whenever the offset changes to the given value, i.e fired once.
# If the toggle parameter is 0, the command is 'held down' as long as the
# offset has the given value, i.e. fired continuously until the offset changes
# to a different value. For example, the magneto/ignition switch for the no. 1
# engine can be implemented like this:
#
# Command	0x0892	UINT16	1	0	sim/magnetos/magnetos_off_1 _
#							1	1	sim/magnetos/magnetos_right_1 _
#							1	2	sim/magnetos/magnetos_left_1 _
#							1	3	sim/magnetos/magnetos_both_1 _
#							0	4	sim/starters/engage_starter_1
#
# Note that you can use the same offset in a Command and an Offset line. A
# similar effect as above could have been achieved like this:
#
# Offset	0x0892	UINT16	6	rw	$Mags1 >Mags1 @
# Command	0x0892	UINT16	0	4	sim/starters/engage_starter_1
# Dataref	Mags1	sim/cockpit/engine/ignition_on[0]	intarray
#
#
# Expression evaluation
#
# Conversion expressions are written in postfix notation, aka Reverse Polish
# Notation, or RPN, which means operators follow their operands. For example,
# the expression (1 + 2) / 3, in the usual infix notation with operators
# between their operands, is written as 1 2 + 3 / in RPN. If you think of this
# as "remember 1; remember 2; pop the the last two numbers from your memory, add
# them, and remember the result; remember 3; pop the last two numbers from your
# memory, divide the second to last one by the last one, and remember the
# result; when done, the final result is what remains in your memory", it might
# make sense. If not, more information can be found on Wikipedia, as well as
# with your favorite search engine. Numbers, operators and datarefs are
# separated by white space, as in the example above. The following operators
# are supported:
#
# Binary operators:
# + - * /	The usual arithmetic operators
# \			Integer division
# ^			Exponentiation (raise the first operand to the power of the second)
# %			Modulo (the remainder of an integer division)
# & |		Bitwise AND, OR
# == !=		Equal, not equal
# < > <= >=	The usual comparison operators.
#
# The comparison and equality operators return 1 for 'true' and 0 for 'false'.
#
# Unary operators:
# abs		Return the absolute value
# round		Round the operand to the nearest integer
#
# Constants:
# PI		
#
# Ternary operator:
# ?			This operator uses three operands. If the first operand is non-zero,
#			it returns the second operand. If the first operand is zero, it
#			returns the third operand. It can be used to implement simple
#			if-then-else logic, like this: '$data 128 <= 0 255 ?' means 'if
#			$data <= 128 then return 0 else return 255'.
#			
#
# Note there's no unary '-'. Negative numbers are supported, but there must
# be no whitespace between the sign and the digits. If you need unary '-' for
# anything else, write '-1 *' instead.
#
# Datarefs are referred to by their identifier. To read a value from dataref
# and use it in the expression, prefix it's identifier with a dollar sign ($).
# To write the result of the sub-expression that follows to a dataref, prefix
# it's identifier with a greater-than sign (>).
#
# Conversion expressions consist of several sub-expressions, according to the
# offset's access mode: Everything up to the first dataref identifier with
# a > prefix, if any, is considered the read expression, which is evaluated when
# a value is read from this offset. The remainder, if any, is interpreted as one
# or more write expressions, each of which starts with the identifier of the
# dataref to write to, with a > prefix. When an offset is written to, each write
# expression is evaluated in turn, and the results are written to the datarefs
# they follow. That is, the syntax is:
#
# read_expression >dataref1 write_expression_1 >dataref2 write_expression_2 [...]
#
# Note that this backwards from the postfix notation: The result of
# write_expression_1 is stored in dataref1, not in dataref2 as one might
# expect. In write expressions, the special token @, which can appear any number
# of times, is replaced by the value that has been written to the offset.
#
# If anything goes wrong during expression evaluation, one of the following
# values are returned:
#
# 77	Access violation (write access to a read-only dataref, or vice versa)
# 88	Unbalanced formula (After evaluation, exactly one value has to remain
#		on the stack - the final result. If you have too many or too few
#		operators for the number of operands, you get this error.)
# 99	Stack overflow (more than 256 values on the stack)
# 111	Dataref not found
# 222	Stack underflow (not enough values on the stack for this operator)

# Whiskey compass heading
Dataref	CompassHdg	sim/cockpit2/gauges/indicators/compass_heading_deg_mag	float
Offset	0x02CC	FLOAT64	1	r	$CompassHdg						# 1:1 mapping

# Turn rate (for turn coordinator)
# Standard rate (3 deg/s) is +/- 20 deg in X-Plane (which is the instrument's
# deflection), and +/- 512 in MSFS (which is just a weird value)
#Dataref	TurnRate	sim/cockpit2/gauges/indicators/turn_rate_roll_deg_pilot	float
#Offset	0x037C	SINT16	1	r	$TurnRate 20.0 / 512 *

# Light switches
# This is a good example for a more complex offset. All the light switches
# are combined into one offset in MSFS. The first bit represents the nav lights,
# the second bit is the beacons, etc. For read access, all the datarefs are
# multiplied by the corresponding bit's value, and added up. For write access,
# for each dataref the value written to the offset (@) is taken modulo 64
# (because the higher bits have no representation is X-Plane), the corresponding
# bit is separated out by a bitwise AND, and the result is divided by that bit's
# value to make sure the result is not greater than 1. Bit no 7 (value 64),
# which collectively represents all instrument lights, is used to switch a
# couple of different datarefs all at once. Notice how each line but the last
# ends with an underscore, the line continuation character. Also notice that
# the order of Offset and Dataref commands doesn't matter.

#Dataref	NavLights			sim/cockpit2/switches/navigation_lights_on				int
#Dataref	Beacons				sim/cockpit2/switches/beacon_on							int
#Dataref	LandingLights		sim/cockpit2/switches/landing_lights_on					int
#Dataref	TaxiLights			sim/cockpit2/switches/taxi_light_on						int
#Dataref	Strobes				sim/cockpit2/switches/strobe_lights_on					int
#Dataref	FloodLight			sim/cockpit2/switches/panel_brightness_ratio[0]			floatarray
#Dataref	SpotLight1			sim/cockpit2/switches/panel_brightness_ratio[1]			floatarray
#Dataref	SpotLight2			sim/cockpit2/switches/panel_brightness_ratio[2]			floatarray
#Dataref	SpotLight3			sim/cockpit2/switches/panel_brightness_ratio[3]			floatarray
#Dataref	PilotLights			sim/cockpit2/switches/instrument_brightness_ratio[0]	floatarray
#Dataref	CopilotLights		sim/cockpit2/switches/instrument_brightness_ratio[1]	floatarray
#Offset 0x0D0C	UINT16	4	rw	$NavLights _
#								$Beacons 2 * + _
#								$LandingLights 4 * + _
#								$TaxiLights 8 * + _
#								$Strobes 16 * + _
#								$FloodLight round 32 * + _
#								>NavLights @ 64 % 1 & _
#								>Beacons @ 64 % 2 & 2 / _
#								>LandingLights @ 64 % 4 & 4 / _
#								>TaxiLights @ 64 % 8 & 8 / _
#								>Strobes @ 64 % 16 & 16 / _
#								>FloodLight @ 64 % 32 & 32 / _
#								>SpotLight1 @ 64 % 32 & 32 / _
#								>SpotLight2 @ 64 % 32 & 32 / _
#								>SpotLight3 @ 64 % 32 & 32 / _
#								>PilotLights @ 64 % 32 & 32 / _
#								>CopilotLights @ 64 % 32 & 32 /


# Manifold pressure
#Dataref ManifoldPressure1	sim/cockpit2/engine/indicators/MPR_in_hg[0]	floatarray
#Dataref ManifoldPressure2	sim/cockpit2/engine/indicators/MPR_in_hg[1]	floatarray
#Dataref ManifoldPressure3	sim/cockpit2/engine/indicators/MPR_in_hg[2]	floatarray
#Dataref ManifoldPressure4	sim/cockpit2/engine/indicators/MPR_in_hg[3]	floatarray
#Offset	0x08C0	UINT16	2	r	$ManifoldPressure1 1024 *
#Offset	0x0958	UINT16	2	r	$ManifoldPressure2 1024 *
#Offset	0x09F0	UINT16	2	r	$ManifoldPressure3 1024 *
#Offset	0x0A88	UINT16	2	r	$ManifoldPressure4 1024 *

# Prop lever
Dataref	PropMaxRPM	sim/aircraft/controls/acf_RSC_redline_prp	float		# Max rpm in rad/sec, for all props(?)
Dataref	Prop1		sim/flightmodel/engine/ENGN_prop[0]		floatarray	# Commanded prop rpm in rad/sec, between 0 and PropMaxRPM
Dataref	Prop1		sim/flightmodel/engine/ENGN_prop[0]		floatarray	# Commanded prop rpm in rad/sec, between 0 and PropMaxRPM
Dataref	Prop2		sim/flightmodel/engine/ENGN_prop[1]		floatarray
Dataref	Prop3		sim/flightmodel/engine/ENGN_prop[2]		floatarray
Dataref	Prop4		sim/flightmodel/engine/ENGN_prop[3]		floatarray
# The prop levers go from Ð4096 to +16384 in MSFS
Offset	0x088E	SINT16	5	rw	$Prop1 $PropMaxRPM / 20480 * 4096 - _
								>Prop1 @ 4096 + 20480 / $PropMaxRPM *
Offset	0x0926	SINT16	5	rw	$Prop2 $PropMaxRPM / 20480 * 4096 - _
								>Prop2 @ 4096 + 20480 / $PropMaxRPM *
Offset	0x09BE	SINT16	5	rw	$Prop3 $PropMaxRPM / 20480 * 4096 - _
								>Prop3 @ 4096 + 20480 / $PropMaxRPM *
Offset	0x0A56	SINT16	5	rw	$Prop4 $PropMaxRPM / 20480 * 4096 - _
								>Prop4 @ 4096 + 20480 / $PropMaxRPM *

# N1: 0.0 - 100.0
Dataref N1_1		sim/flightmodel/engine/ENGN_N1_[0]		floatarray
Dataref N1_2		sim/flightmodel/engine/ENGN_N1_[1]		floatarray
Dataref N1_3		sim/flightmodel/engine/ENGN_N1_[2]		floatarray
Dataref N1_4		sim/flightmodel/engine/ENGN_N1_[3]		floatarray
# Prop speed in rad/sec
Dataref PropSpeed1	sim/flightmodel/engine/POINT_tacrad[0]	floatarray
Dataref PropSpeed2	sim/flightmodel/engine/POINT_tacrad[1]	floatarray
Dataref PropSpeed3	sim/flightmodel/engine/POINT_tacrad[2]	floatarray
Dataref PropSpeed4	sim/flightmodel/engine/POINT_tacrad[3]	floatarray
# Prop direction: 1.0 = CW, -1.0 = CCW
Dataref PropDir1	sim/aircraft/prop/acf_prop_dir[0]		floatarray
Dataref PropDir2	sim/aircraft/prop/acf_prop_dir[1]		floatarray
Dataref PropDir3	sim/aircraft/prop/acf_prop_dir[2]		floatarray
Dataref PropDir4	sim/aircraft/prop/acf_prop_dir[3]		floatarray
# N1: 0 - 16384
#Offset	0x0898	SINT16	1	r	$N1_1 100 / 16384 * $PropDir1 *
#Offset	0x0930	SINT16	2	r	$N1_2 100 / 16384 * $PropDir2 *
#Offset	0x09C8	SINT16	2	r	$N1_3 100 / 16384 * $PropDir3 *
#Offset	0x0A60	SINT16	2	r	$N1_4 100 / 16384 * $PropDir4 *

# RPM Scaler: Prop RPM = N1 * RPM Scaler / 65536
Offset	0x08C8	UINT16	2	r	$PropSpeed1 12000 * $N1_1 / PI /
Offset	0x0960	UINT16	2	r	$PropSpeed2 12000 * $N1_2 / PI /
Offset	0x09F8	UINT16	2	r	$PropSpeed3 12000 * $N1_3 / PI /
Offset	0x0A90	UINT16	2	r	$PropSpeed4 12000 * $N1_4 / PI /

# Magneto switches
#Command	0x6892	UINT16	1	0	sim/magnetos/magnetos_off_1 _
#						1	1	sim/magnetos/magnetos_right_1 _
#						1	2	sim/magnetos/magnetos_left_1 _
#						1	3	sim/magnetos/magnetos_both_1 _
#						0	4	sim/starters/engage_starter_1

#Command	0x092A	UINT16	1	0	sim/magnetos/magnetos_off_2 _
#						1	1	sim/magnetos/magnetos_right_2 _
#						1	2	sim/magnetos/magnetos_left_2 _
#						1	3	sim/magnetos/magnetos_both_2 _
#						0	4	sim/starters/engage_starter_2

#Command	0x09C2	UINT16	1	0	sim/magnetos/magnetos_off_3 _
#						1	1	sim/magnetos/magnetos_right_3 _
#						1	2	sim/magnetos/magnetos_left_3 _
#						1	3	sim/magnetos/magnetos_both_3 _
#						0	4	sim/starters/engage_starter_3

#Command	0x0A5A	UINT16	1	0	sim/magnetos/magnetos_off_4 _
#						1	1	sim/magnetos/magnetos_right_4 _
#						1	2	sim/magnetos/magnetos_left_4 _
#						1	3	sim/magnetos/magnetos_both_4 _
#						0	4	sim/starters/engage_starter_4
#Dataref Magnetos1	sim/cockpit/engine/ignition_on[0]	intarray
#Dataref Magnetos2	sim/cockpit/engine/ignition_on[1]	intarray
#Dataref Magnetos3	sim/cockpit/engine/ignition_on[2]	intarray
#Dataref Magnetos4	sim/cockpit/engine/ignition_on[3]	intarray
#Offset	0x0892	UINT16	8	rw	$Magnetos1
#Offset	0x092A	UINT16	8	rw	$Magnetos2
#Offset	0x09C2	UINT16	8	rw	$Magnetos3
#Offset	0x0A5A	UINT16	8	rw	$Magnetos4

# DME speed strings
# This is a four-character string in FS. Since strings are not supported,
# we have to revert to a little hack and fill in each digit individually,
# pretending the offset is made up of 4 individual UINT8 (i.e. one byte) numbers.
# 48 is the ASCII code for the character '0', with the other numbers following
# in their numerical order. So adding 48 to a digit value effectively converts
# it to ASCII, which is what we need here. The same idea can be used to copy
# X-Plane strings, which are usually data arrays, to string offsets, character
# after character, but of course that quickly becomes tedious for all but the
# shortest strings.
Offset	0C2E	UINT8	4	r	$Nav1DmeSpeed 100 \ 48 +
Offset	0C2F	UINT8	4	r	$Nav1DmeSpeed 100 % 10 \ 48 +
Offset	0C30	UINT8	4	r	$Nav1DmeSpeed 10 % 48 +
Offset	0C31	UINT8	4	r	0
Offset	0C38	UINT8	4	r	$Nav2DmeSpeed 100 \ 48 +
Offset	0C39	UINT8	4	r	$Nav2DmeSpeed 100 % 10 \ 48 +
Offset	0C3A	UINT8	4	r	$Nav2DmeSpeed 10 % 48 +
Offset	0C3B	UINT8	4	r	0
Dataref	Nav1DmeSpeed	sim/cockpit2/radios/indicators/nav1_dme_speed_kts	float
Dataref	Nav2DmeSpeed	sim/cockpit2/radios/indicators/nav2_dme_speed_kts	float

# Voltages and amperages
# 4 busses and bus amperage is supported in X-Plane 9.40 and later only
Dataref	Bat1Volt	sim/cockpit2/electrical/battery_voltage_actual_volts[0]	floatarray
Dataref Bat1Amps	sim/cockpit2/electrical/battery_amps[0]					floatarray
Dataref Bus1Volt	sim/cockpit2/electrical/bus_volts[0]					floatarray
Dataref Bus1Amps	sim/cockpit2/electrical/bus_load_amps[0]				floatarray
Dataref Bus2Volt	sim/cockpit2/electrical/bus_volts[1]					floatarray
Dataref Bus2Amps	sim/cockpit2/electrical/bus_load_amps[1]				floatarray
Dataref Bus3Volt	sim/cockpit2/electrical/bus_volts[2]					floatarray
Dataref Bus3Amps	sim/cockpit2/electrical/bus_load_amps[2]				floatarray
Dataref Bus4Volt	sim/cockpit2/electrical/bus_volts[3]					floatarray
Dataref Bus4Amps	sim/cockpit2/electrical/bus_load_amps[3]				floatarray
Dataref Gen1Amps	sim/cockpit2/electrical/generator_amps[0]				floatarray
Dataref Gen2Amps	sim/cockpit2/electrical/generator_amps[1]				floatarray
Dataref Gen3Amps	sim/cockpit2/electrical/generator_amps[2]				floatarray
Dataref Gen4Amps	sim/cockpit2/electrical/generator_amps[3]				floatarray
#Dataref Gen1Volt	???														floatarray
#Dataref Gen2Volt	???														floatarray
#Dataref Gen3Volt	???														floatarray
#Dataref Gen4Volt	???														floatarray
# Battery
Offset	0x282C	FLOAT64	2	r	$Bat1Amps
Offset	0x2834	FLOAT64	2	r	$Bat1Volt
# Main bus
Offset	0x2840	FLOAT64	2	r	$Bus1Volt
Offset	0x2848	FLOAT64	2	r	$Bus1Amps
# Avionics bus
Offset	0x2850	FLOAT64	2	r	$Bus2Volt
Offset	0x2858	FLOAT64	2	r	$Bus2Amps
# Hot battery bus
Offset	0x2860	FLOAT64	2	r	$Bus3Volt
Offset	0x2868	FLOAT64	2	r	$Bus3Amps
# Battery bus
Offset	0x2870	FLOAT64	2	r	$Bus4Volt
Offset	0x2878	FLOAT64	2	r	$Bus4Amps
# Engine 1 generator
Offset	0x2880	FLOAT64	2	r	$Bus1Volt
Offset	0x2888	FLOAT64	2	r	$Gen1Amps
# Engine 2 generator
Offset	0x2890	FLOAT64	2	r	$Bus2Volt
Offset	0x2898	FLOAT64	2	r	$Gen2Amps
# Engine 3 generator
Offset	0x28A0	FLOAT64	2	r	$Bus3Volt
Offset	0x28A8	FLOAT64	2	r	$Gen3Amps
# Engine 4 generator
Offset	0x28B0	FLOAT64	2	r	$Bus4Volt
Offset	0x28B8	FLOAT64	2	r	$Gen4Amps

# Gyro drift
Dataref GyroDrift	sim/cockpit/gyros/dg_drift_vac_deg		float
Offset	0x0C3E	SINT16	2	rw	$GyroDrift 360 / 65536 * >GyroDrift @ 360 * 65536 /

# NAV1/GPS selector
Dataref	HSISelect	sim/cockpit/switches/HSI_selector	int			# 0: NAV1, 1: NAV2, 2: GPS
Offset	0x132C	UINT32	5	rw	$HSISelect 2 == >HSISelect @ 2 *	# 0: NAV1, 1: GPS

# ADF1 relative bearing
Dataref Adf1Dir		sim/cockpit/radios/adf1_dir_degt		float
Offset	0x0C6A	SINT16	1	r	$Adf1Dir 360 / 65536 *

# ADF2 relative bearing
Dataref Adf2Dir		sim/cockpit/radios/adf2_dir_degt		float
Offset	0x02D8	SINT16	1	r	$Adf2Dir 360 / 65536 *

# Battery and avionics master switches
Dataref	BatteryMaster	sim/cockpit/electrical/battery_on	int
Dataref	AvionicsMaster	sim/cockpit/electrical/avionics_on	int
Offset	0x281C	UINT32	4	rw	$BatteryMaster >BatteryMaster @
Offset	0x2E80	UINT32	5	rw	$AvionicsMaster >AvionicsMaster @

# Generator switches
Dataref	Gen1On			sim/cockpit/electrical/generator_on[0]	intarray
Dataref	Gen2On			sim/cockpit/electrical/generator_on[1]	intarray
Dataref	Gen3On			sim/cockpit/electrical/generator_on[2]	intarray
Dataref	Gen4On			sim/cockpit/electrical/generator_on[3]	intarray
Offset	0x3B78	UINT32	4	rw	$Gen1On >Gen1On @
Offset	0x3AB8	UINT32	4	rw	$Gen2On >Gen2On @
Offset	0x39F8	UINT32	4	rw	$Gen3On >Gen3On @
Offset	0x3938	UINT32	4	rw	$Gen4On >Gen4On @

# Fuel pumps
Dataref FuelPump1		sim/cockpit/engine/fuel_pump_on[0]		intarray
Dataref FuelPump2		sim/cockpit/engine/fuel_pump_on[1]		intarray
Dataref FuelPump3		sim/cockpit/engine/fuel_pump_on[2]		intarray
Dataref FuelPump4		sim/cockpit/engine/fuel_pump_on[3]		intarray
Offset	0x3B98	UINT32	5	rw	$FuelPump1 >FuelPump1 @
Offset	0x3AD8	UINT32	5	rw	$FuelPump2 >FuelPump2 @
Offset	0x3A18	UINT32	5	rw	$FuelPump3 >FuelPump3 @
Offset	0x3958	UINT32	5	rw	$FuelPump4 >FuelPump4 @

# Prop sync
Dataref	PropSync		sim/cockpit/switches/prop_sync_on		int
Offset	0x2EC8	UINT32	4	rw	$PropSync >PropSync @

# CHT - FS values are in Fahrenheit
Dataref CHT1	sim/cockpit2/engine/indicators/CHT_deg_C[0]		floatarray
Dataref CHT2	sim/cockpit2/engine/indicators/CHT_deg_C[1]		floatarray
Dataref CHT3	sim/cockpit2/engine/indicators/CHT_deg_C[2]		floatarray
Dataref CHT4	sim/cockpit2/engine/indicators/CHT_deg_C[3]		floatarray
Offset	0x08E8	FLOAT64	2	r	$CHT1 1.8 * 32 +
Offset	0x0980	FLOAT64	2	r	$CHT2 1.8 * 32 +
Offset	0x0A18	FLOAT64	2	r	$CHT3 1.8 * 32 +
Offset	0x0AB0	FLOAT64	2	r	$CHT4 1.8 * 32 +
Offset	0x3858	FLOAT64	2	r	$CHT1 1.8 * 32 +

# EGT - FS values are in Rankine
Dataref EGT1	sim/cockpit2/engine/indicators/EGT_deg_C[0]		floatarray
Dataref EGT2	sim/cockpit2/engine/indicators/EGT_deg_C[1]		floatarray
Dataref EGT3	sim/cockpit2/engine/indicators/EGT_deg_C[2]		floatarray
Dataref EGT4	sim/cockpit2/engine/indicators/EGT_deg_C[3]		floatarray
Offset	0x3B70	FLOAT64	1	r	$EGT1 1.8 * 491.67 +
Offset	0x3AB0	FLOAT64	1	r	$EGT2 1.8 * 491.67 +
Offset	0x39F0	FLOAT64	1	r	$EGT3 1.8 * 491.67 +
Offset	0x3930	FLOAT64	1	r	$EGT4 1.8 * 491.67 +

# Cowl flaps
Dataref CowlFlaps1	sim/cockpit2/engine/actuators/cowl_flap_ratio[0]	floatarray
Dataref CowlFlaps2	sim/cockpit2/engine/actuators/cowl_flap_ratio[1]	floatarray
Dataref CowlFlaps3	sim/cockpit2/engine/actuators/cowl_flap_ratio[2]	floatarray
Dataref CowlFlaps4	sim/cockpit2/engine/actuators/cowl_flap_ratio[3]	floatarray
Offset	0x37F0	FLOAT64	3	rw	$CowlFlaps1 >CowlFlaps1 @
Offset	0x3730	FLOAT64	3	rw	$CowlFlaps2 >CowlFlaps2 @
Offset	0x3670	FLOAT64	3	rw	$CowlFlaps3 >CowlFlaps3 @
Offset	0x35B0	FLOAT64	3	rw	$CowlFlaps4 >CowlFlaps4 @

# Overspeed warning
Dataref Vne			sim/aircraft/view/acf_Vne						float
Dataref IAS			sim/flightmodel/position/indicated_airspeed		float
Offset	0x036D	UINT8	2	r	$IAS $Vne >

# Vertical speed
Dataref VVI			sim/flightmodel/position/vh_ind		float	# m/s
#Offset	0x0842	SINT16	1	r	$VVI -60 * 						# m/min

# DME NAV source
Dataref DmeSource	sim/cockpit2/radios/actuators/DME_slave_source	int
Offset	0x0378	UINT16	4	rw	$DmeSource 1 + >DmeSource @ 1 -

# Audio panel (X-Plane >= 9.40)
# Before 9.40, the audio panel buttons in X-Plane were mutually exclusive,
# while in FS they aren't. To map this correctly, you would need to split
# this offset into COM, NAV, DME and marker parts, and then detect state
# changes within the COM and NAV portions. In other words, if e.g. Nav1 is
# already selected, and the Adf1 button is pressed, you need to make sure
# that Nav1 deactivates and Adf1 activates, not the other way round. And vice
# versa. This is probably just a tiny bit too complex to compute here, and would
# be better implemented in a little plugin publishing a custom dataref that
# could then be used here without further ado:
#Dataref	AudioPanel		xpuipc/audio_panel_bitfield		int
#Offset		0x3122	UINT8	3	rw	$AudioPanel >AudioPanel @
# So this is for X-Plane 9.40 and above only:
#Dataref Com1Audio	sim/cockpit2/radios/actuators/audio_selection_com1	int
#Dataref Com2Audio	sim/cockpit2/radios/actuators/audio_selection_com2	int
#Dataref Nav1Audio	sim/cockpit2/radios/actuators/audio_selection_nav1	int
#Dataref Nav2Audio	sim/cockpit2/radios/actuators/audio_selection_nav2	int
#Dataref Adf1Audio	sim/cockpit2/radios/actuators/audio_selection_adf1	int
#Dataref Adf2Audio	sim/cockpit2/radios/actuators/audio_selection_adf2	int
#Dataref DmeAudio	sim/cockpit2/radios/actuators/audio_dme_enabled		int
#Dataref MkrAudio	sim/cockpit2/radios/actuators/audio_marker_enabled	int
#Offset	0x3122	UINT8	3	rw	$Com1Audio 128 * $Com2Audio 64 * + $Nav1Audio 16 * + $Nav2Audio 8 * + $MkrAudio 4 * + $DmeAudio 2 * + $Adf1Audio 1 * + _
#								>Com1Audio @ 128 & 128 / _
#								>Com2Audio @ 64 & 64 / _
#								>Nav1Audio @ 16 & 16 / _
#								>Nav2Audio @ 8 & 8 / _
#								>MkrAudio @ 4 & 4 / _
#								>DmeAudio @ 2 & 2 / _
#								>Adf1Audio @ 1 & 1 /
