#set INI_VERSION_2 ; this is set by TunerStudio, but needs to be unset for Megatune to work

#set CAN_COMMANDS

[MegaTune]
   MTversion      = 2.25 ; MegaTune itself; needs to match exec version.

[TunerStudio]
   iniSpecVersion = 3.71

#if CAN_COMMANDS
   versionInfo    = "r\$tsCanId\x0e\x00\x00\x00\x3c"  ; Put this in the title bar.
   queryCommand   = "r\$tsCanId\x0f\x00\x00\x00\x14"  ; Verify against signature.
#else
   versionInfo    = "S"  ; Put this in the title bar.
   queryCommand   = "Q"  ; Verify against signature.
#endif
   signature      = "AMP DBW 1.0.1 Rel  " ; I/O Extender sends a null at 20th byte. Signature Must be of a specific attribute to be allowed by TS
                   ; 123456789.123456789.



[ReferenceTables] 	
    tableBlockingFactor = 512
;-------------------------------------------------------------------------------
[Constants] 

   pageActivationDelay = 50 ; Milliseconds delay after burn command.
   blockReadTimeout    = 1000 ; Milliseconds total timeout for reading page. 
   interWriteDelay     = 100   

	endianness          = big
	nPages              = 1        

	pageSize            = 567

	pageIdentifier      = "\$tsCanId\x04" 
	burnCommand		    = "b%2i"				
    pageReadCommand     = "r%2i%2o%2c"		
    pageValueWrite      = "w%2i%2o%2c%v"	
	
	
   messageEnvelopeFormat	= msEnvelope_1.0 ;  TS could use the 'F' command to determine this automatically.

   page = 1
; name 						= class	,	type, 	offset, shape, units, scale, 			tralate, min, max, 	digits
	conStrategy 			= bits, 	U08,	0,  [2:3], "Basic Target Follower","INVALID","INVALID","INVALID"
	conRPM_GearLimiter 	    = bits,  	U08,    0,  [4:5], "Disable","RPM","Gear","INVALID"	
	conBlipEnable			= bits,		U08,	0,	[6:7], "Disable","Enable","INVALID","INVALID"			;TODO: Disable, Simple, RPM Targeted, RPM vs Gear vs Speed


	conIdleInput			= bits,		U08,	1,	[0:1], "Fixed Minimum","PWM Input 1","PWM Input 2", "CANbus"
	conRPMInputDBW			= bits,		U08,	1,	[2:3], "Disable","PWM Input 1","PWM Input 2","CANbus"
	conRPMInputCAS 	   		= bits,		U08,	1,	[2:3], "INVALID","PWM Input 1","PWM Input 2","CANbus"
	conVSSInput				= bits,		U08,	1,	[4:5], "Disable","PWM Input 1","PWM Input 2","CANbus"
	
    conPWMTargetInput   	= bits,		U08,	2,	[0:1], "INVALID","PWM Input 1","PWM Input 2","INVALID"
	conGPOfunction   		= bits,		U08,	2,	[2:3], "None","Fault Code Flash","On with Fault","INVALID"
	conTPSOutRange  		= bits,		U08,	2, 	[4:4], "Full Range", "Exclude Idle Range"
	throttleType	    	= bits,		U08,	2,  [6:7], "Standard","Ford Half-scale","INVALID","INVALID"
	
	numGears		    	= scalar, 	U08, 	3,	"", , 		1, 		0,		1,	6,	0;
	idleDCposTarget 		= scalar,	U16,	4,	"", , 		0.03125, 	-400,	0,	15,	1;
	faultMaxDev 	    	= scalar,	U16,	6,	"", , 		0.03125,	-400,   0,	100,	0;
	faultSettleTime 		= scalar,	U08,	8,	"", ,		1, 		0.		0,	5,	0;
	faultMaxPos 	    	= scalar,	U16,	9,	"", , 		0.03125,	-400,   0,	100,	0;
	
	canMode11				= bits, 	U08, 	11, [0:0], "Disable", "Enable"
	canMode29				= bits, 	U08, 	11, [1:1], "Disable", "Enable"
	canBaud					= bits,		U08, 	11, [3:4], "250k", "500k", "1M", "INVALID"
	canTerm					= bits,		U08,	11, [5:5], "Off", "On"
	can11baseAddr			= scalar,	U16, 	12, "", ,	1,		0,			0,	65535,  0;
	canID			    	= scalar,	U08,	14,	"", , 	1, 		0,			2,	15,		0;
	cantxBroadcast			= scalar,	U08,	16,	"", , 	1, 	0,		    5,	255,	0;
	
	throttleControlRate 	= scalar, 	U08, 	17,	"", , 	1, 		0,			1,	15,	0;

	pidIlimitMax			= scalar,	U16,	18,	"", , 	1.0, 	0.0,		0,	16384,	0.0;	

;20-25 free
		
	KPCurve					= array , 	U16,    26,     [   16], "",   1,   		0,	0,   750,      0 ; * (  32 bytes)
	KICurve					= array , 	U16,    58,     [   16], "",   1,    	0,	0,   150,      0 ; * (  32 bytes)
	KDCurve					= array , 	U16,    90,     [   16], "",   1,   		0,	0,   200,      0 ; * (  32 bytes)
	PIDxAxis_Error			= array ,  	S16,    122,    [   16], "",   1,		 0,  -3000,	3000,   0 ; * (  32 bytes)
	
	follower_PedalIn		= array , 	U16,    158,    [   11], "",  0.03125,   		-400	,0,   100,      0 ; * (  22 bytes)
	follower_ThrottleOut	= array , 	U16,    180,    [   11], "",  0.03125,   		-400	,0,   100,      0 ; * (  22 bytes)
	
	idleFixedMin			= scalar,	U16,	202,	"", , 		0.03125, 			-400,		0,	15,	1;	
	idleCANmaxTarget		= scalar,	U16,	204,	"", , 		0.03125, 			-400,		0,	15,	1;	
	
devIpreload				= scalar,	U16,	206,	"", , 		1, 			0,		0, 1250,	0;	//TODO: STILL EXISTS?????????????????????????????????????????????????????

	gearLimiter1_RPMIn		= array , 	U16,    209,    [   11], "",  1,		0.0,		0,   20000,    0 ; * (  22 bytes)
	gearLimiter1_ThrottleOut= array ,  	U16,    231,    [   11], "",  0.03125,	-400,		0,   100,      0 ; * (  22 bytes)
	gearLimiter2_RPMIn		= array ,  	U16,    253,    [   11], "",  1,   		0.0	,		0,   20000,    0 ; * (  22 bytes)
	gearLimiter2_ThrottleOut= array ,  	U16,    275,    [   11], "",  0.03125,	-400,		0,   100,      0 ; * (  22 bytes)
	gearLimiter3_RPMIn		= array ,  	U16,    297,    [   11], "",  1,		0.0,		0,   20000,    0 ; * (  22 bytes)
	gearLimiter3_ThrottleOut= array ,  	U16,    319,    [   11], "",  0.03125,	-400,		0,   100,      0 ; * (  22 bytes)
	gearLimiter4_RPMIn		= array ,  	U16,    341,    [   11], "",  1,		0.0,		0,   20000,    0 ; * (  22 bytes)
	gearLimiter4_ThrottleOut= array ,  	U16,    363,    [   11], "",  0.03125,	-400,		0,   100,      0 ; * (  22 bytes)
	gearLimiter5_RPMIn		= array ,  	U16,    385,    [   11], "",  1,		0.0,		0,   20000,    0 ; * (  22 bytes)
	gearLimiter5_ThrottleOut= array ,  	U16,    407,    [   11], "",  0.03125,	-400,		0,   100,      0 ; * (  22 bytes)
	gearLimiter6_RPMIn		= array ,  	U16,    429,    [   11], "",  1,		0.0,		0,   20000,    0 ; * (  22 bytes)
	gearLimiter6_ThrottleOut= array ,  	U16,    451,    [   11], "",  0.03125,	-400,		0,   100,      0 ; * (  22 bytes)
	
		
	canIn_ID_Target			= scalar,	U16,	473,	"", , 		1 			0,		0,	65535,	0;
	canIn_Off_Target		= scalar,	U08,  	475,	"", , 		1 			0,		0,	   6,	0;
	
	canIn_Mult_Target		= scalar,	S16,	477,	"", , 		1 			0,		-32767,	32767,	0;
	canIn_Div_Target		= scalar,	S16,	479,	"", , 		1 			0,		     1,	32767,	0;
	canIn_Add_Target		= scalar,	S16,	481,	"", , 		1 			0,		-32767,	32767,	0;
	
	canIn_ID_RPM			= scalar,	U16,	483,	"", , 		1 			0,		0,	65535,	0;
	canIn_Off_RPM			= scalar,	U08,  	485,	"", , 		1 			0,		0,	   6,	0;
	
	canIn_Mult_RPM			= scalar,	S16,	487,	"", , 		1 			0,		-32767,	32767,	0;
	canIn_Div_RPM			= scalar,	S16,	489,	"", , 		1 			0,		     1,	32767,	0;
	canIn_Add_RPM			= scalar,	S16,	491,	"", , 		1 			0,		-32767,	32767,	0;
	
	canIn_ID_Gear			= scalar,	U16,  	493,	"", , 		1 			0,		0,	65535,	0;
	canIn_Off_Gear			= scalar,	U08, 	495,	"", , 		1 			0,		0,	   7,	0;
	
	canIn_Mult_Gear			= scalar,	S16,	497,	"", , 		1 			0,		-32767,	32767,	0;
	canIn_Div_Gear			= scalar,	S16,	499,	"", , 		1 			0,		     1,	32767,	0;
	canIn_Add_Gear			= scalar,	S16,	501,	"", , 		1 			0,		-32767,	32767,	0;
	
	canIn_ID_VSS			= scalar,	U16,  	503,	"", , 		1 			0,		0,	65535,	0;	
	canIn_Off_VSS			= scalar,	U08,  	505,	"", , 		1 			0,		0,	   6,	0;	
	
	canIn_Mult_VSS			= scalar,	S16,	507,	"", , 		1 			0,		-32767,	32767,	0;
	canIn_Div_VSS			= scalar,	S16,	509,	"", , 		1 			0,		     1,	32767,	0;
	canIn_Add_VSS			= scalar,	S16,	511,	"", , 		1 			0,		-32767,	32767,	0;
	
	canIn_ID_Idle			= scalar,	U16,  	513,	"", , 		1 			0,		0,	65535,	0;	
	canIn_Off_Idle			= scalar,	U08,  	515,	"", , 		1 			0,		0,	   6,	0;	
	
	canIn_Mult_Idle			= scalar,	S16,	517,	"", , 		1 			0,		-32767,	32767,	0;
	canIn_Div_Idle			= scalar,	S16,	519,	"", , 		1 			0,		     1,	32767,	0;
	canIn_Add_Idle			= scalar,	S16,	521,	"", , 		1 			0,		-32767,	32767,	0;
	
	
	canOut_Sensors1_ID		= scalar,	U16,	523,	"", , 		1 			0,		0,	65535,	0;
		
	canOut_Sensors2_ID		= scalar,	U16,	529,	"", , 		1 			0,		0,	65535,	0;
	
	canOut_Faults1_ID		= scalar,	U16,  	535,	"", , 		1 			0,		0,	65535,	0;
	
	canOut_Faults2_ID		= scalar,	U16,  	541,	"", , 		1 			0,		0,	65535,	0;
	
	pidIlimitMin 			= scalar,	U16,	547,	"", , 	1.0, 	0.0,		0,	16384,	0.0;	
	
	blipDuration 			= scalar, 	U08, 	549,	"", , 	0.01, 		0,			0.01,	1.00,	2;
	blipDelay 				= scalar, 	U08, 	550,	"", , 	0.01, 		0,			0.01,	2.50,	2;
	blipPercentAdd			= scalar, 	U08, 	551,	"", , 	1, 			0,			1,		100,	0;
	blipClutchWindow		= scalar, 	U08, 	552,	"", , 	0.1, 		0,			0.1,	10.0,	1;
	blipClutchWindowPrd		= scalar, 	U08, 	553,	"", , 	0.1, 		0,			0.01,	10.0,	1;
	blipPedalthreshold		= scalar, 	U16, 	554,	"", ,  0.03125,   	-400,		0,  	100,    0;
	di1StateMode			= bits,		U08,	556,	[0:0], "Active Low","Active High"
	di2StateMode			= bits,		U08,	556,	[1:1], "Active Low","Active High"
		
	casParkPos				= scalar,	U16,	557,	"", , 		0.03125,	-400,   0,	100,	0;
	casReadyPos				= scalar,	U16,	559,	"", , 		0.03125,	-400,   0,	100,	0;
	casLaunchPos			= scalar,	U16,	561,	"", , 		0.03125,	-400,   0,	100,	0;
	casRatePos				= scalar,	U16,	563,	"", , 		0.03125,	   0,   0,	100,	1;
	casRateTime				= scalar,	U16,	565,	"", , 		1,	0,   0,	1000,	0;

;-------------------------------------------------------------------------------
[PcVariables]
pidAdvancedMode = bits, U08,	[0:0], "Locked", "Unlock PID tuning"
;-------------------------------------------------------------------------------
[ConstantsExtensions]

;	requiresPowerCycle = TODO: -----------MOTOR DISABLED FAULT-----------


	defaultValue = conStrategy, "Basic Target Follower"
	defaultValue = conRPM_GearLimiter, "Disable"
	defaultValue = conIdleInput, "Fixed Minimum"
	defaultValue = conRPMInputDBW, "Disable"
	defaultValue = conRPMInputCAS, "CANbus"
	defaultValue = conVSSInput, "Disable"
	defaultValue = conBlipEnable, "Disable"
	defaultValue = conPWMTargetInput, "PWM Input 1"
	defaultValue = conGPOfunction, "Fault Code Flash"
	defaultValue = conTPSOutRange, " Exclude Idle Range"
	defaultValue = throttleType, "Standard"
	defaultValue = numGears, 5
	defaultValue = idleDCposTarget, 10
	defaultValue = faultMaxDev, 10
	defaultValue = faultSettleTime, 5
	defaultValue = faultMaxPos, 35
	defaultValue = canBaud, "500K"
	defaultValue = canTerm, "On"
	defaultValue = canMode11, "Enable"
	defaultValue = canMode29, "Enable"
	defaultValue = canID, 8
	defaultValue = cantxBroadcast, 15
	defaultValue = throttleControlRate, 5
	defaultValue = pidIlimitMax, 1000
	defaultValue = pidIlimitMin, 600

	defaultValue = KPCurve , 80 154 172 176 180 200 210 220 220 210 200 180 176 172 154 100
	defaultValue = KICurve , 10 25 27 28 34 44 55 75 75 54 44 32 28 22 21 16
	defaultValue = KDCurve , 50 46 44 41 39 38 37 35 35 39 40 42 44 46 47 50
	defaultValue = PIDxAxis_Error , -3000 -1000 -500 -100 -75 -50 -25 -5 5 25 50 75 100 500 1000 3000
		
	defaultValue = follower_PedalIn , 0 10 20 30 40 50 60 70 80 90 100
	defaultValue = follower_ThrottleOut , 3 5 10 16 22 30 40 55 72 90 100
	
	defaultValue = idleFixedMin, 5
	defaultValue = idleCANmaxTarget, 10
	defaultValue = devIpreload, 1000
	
	defaultValue = gearLimiter1_RPMIn , 1000 1700 2400 3100 3800 4500 5200 5900 6600 7300 8000
	defaultValue = gearLimiter1_ThrottleOut , 100 100 100 100 100 100 100 100 100 100 100
	defaultValue = gearLimiter2_RPMIn , 1000 1700 2400 3100 3800 4500 5200 5900 6600 7300 8000
	defaultValue = gearLimiter2_ThrottleOut , 100 100 100 100 100 100 100 100 100 100 100
	defaultValue = gearLimiter3_RPMIn , 1000 1700 2400 3100 3800 4500 5200 5900 6600 7300 8000
	defaultValue = gearLimiter3_ThrottleOut , 100 100 100 100 100 100 100 100 100 100 100
	defaultValue = gearLimiter4_RPMIn , 1000 1700 2400 3100 3800 4500 5200 5900 6600 7300 8000
	defaultValue = gearLimiter4_ThrottleOut , 100 100 100 100 100 100 100 100 100 100 100
	defaultValue = gearLimiter5_RPMIn , 1000 1700 2400 3100 3800 4500 5200 5900 6600 7300 8000
	defaultValue = gearLimiter5_ThrottleOut , 100 100 100 100 100 100 100 100 100 100 100
	defaultValue = gearLimiter6_RPMIn , 1000 1700 2400 3100 3800 4500 5200 5900 6600 7300 8000
	defaultValue = gearLimiter6_ThrottleOut , 100 100 100 100 100 100 100 100 100 100 100

	defaultValue = blipDuration, 0.1
	defaultValue = blipDelay, 0.5
	defaultValue = blipPercentAdd, 60
	defaultValue = blipClutchWindow, 0.5
	defaultValue = blipClutchWindowPrd,	8
	defaultValue = blipPedalthreshold,	10
	defaultValue = di1StateMode,	"Active High"
	defaultValue = di2StateMode,	"Active Low"

	defaultValue = casParkPos, 0
	defaultValue = casReadyPos, 20
	defaultValue = casLaunchPos, 25
	defaultValue = casRatePos, 1
	defaultValue = casRateTime, 1000

	defaultValue = canIn_ID_RPM,1520
	defaultValue = canIn_Off_RPM,6
	defaultValue = canIn_Mult_RPM,1
	defaultValue = canIn_Div_RPM,1
	defaultValue = canIn_Add_RPM,0
	
	defaultValue = canIn_ID_Gear,1553
	defaultValue = canIn_Off_Gear,6
	defaultValue = canIn_Mult_Gear,1
	defaultValue = canIn_Div_Gear,1
	defaultValue = canIn_Add_Gear,0
	
	defaultValue = canIn_ID_VSS,1562
	defaultValue = canIn_Off_VSS,0
	defaultValue = canIn_Mult_VSS,1
	defaultValue = canIn_Div_VSS,10
	defaultValue = canIn_Add_VSS,0
	
	defaultValue = canIn_ID_Idle,1526	
	defaultValue = canIn_Off_Idle,6
	defaultValue = canIn_Mult_Idle,16
	defaultValue = canIn_Div_Idle,1
	defaultValue = canIn_Add_Idle,0
	
	defaultValue = canOut_Sensors1_ID, 256
	defaultValue = canOut_Sensors2_ID, 257
	defaultValue = canOut_Faults1_ID, 258
	defaultValue = canOut_Faults2_ID, 259
	
	
;-------------------------------------------------------------------------------
[SettingContextHelp]
; constantName = "Help Text"
; tooltips

    conRPM_GearLimiter = "Set a curve to limit throttle opening based on RPM. Gear allows up to 6 throttle limiter curves."
	conIdleInput = "Control idle speed using a fixed minimum, a PWM output, or a CANbus input."
	idleFixedMin = "Set a fixed minimum throttle position for idle speed."
	idleCANmaxTarget = "Throttle target when CAN idle input equals 4095 ADC counts."
	conRPMInputDBW = "Accept RPM input via CANbus or PWM."
	conRPMInputCAS = "Accept RPM input via CANbus or PWM."
	conVSSInput = "Accept VSS input via CANbus or PWM."
	conBlipEnable = "Enable throttle blip function."
	conPWMTargetInput = "Use a PWM signal to control an E-Gate."
	conGPOfunction = "Assign digital output for DBW fault/check engine light."
	conTPSOutRange = "Full Range sends actual throttle position. Exclude Idle Range sends 0% TPS at idle."
	throttleType = "Standard: dual full-scale TPS. Ford Half-scale: one half-scale and one full-scale TPS."
	numGears = "Set number of gears in the transmission."

	idleDCposTarget = "Max throttle opening at 100% idle duty. Suggested default: 10%."
	faultMaxDev = "Max deviation from throttle target before fault is set."
	faultSettleTime = "Time throttle can exceed deviation before setting a fault."
	faultMaxPos = "Throttle limit during fault condition."

	canMode11 = "Enable 11-bit CAN messaging."
	canMode29 = "Enable 29-bit CAN messaging. Required for MegaSquirt passthrough."
	canBaud = "Set CANbus baud rate. MegaSquirt uses 500K."
	canID = "CANbus ID for the DBW controller. Default is 8."
	canTerm = "Enable/disable CAN termination resistor. Enable only if this device is at the end of the bus."
	cantxBroadcast = "Set how often CAN messages are sent."

	follower_PedalIn = "Pedal position input."
	follower_ThrottleOut = "Throttle position output for given pedal position. Use a smooth curve for OEM-like response."
	
	canOut_Sensors1_ID = Big Endian, Unsigned, Multiply=10,Divide=1,Add=0 
	canOut_Sensors2_ID = Big Endian, Unsigned, Multiply=10,Divide=1,Add=0 
	canOut_Faults1_ID = "Big Endian, Unsigned"
	canOut_Faults2_ID = "Big Endian, Unsigned"
	canIn_ID_Idle = "CAN idle scaling. E.g., 0–255 input = MULTIPLY=16, DIVIDE=1, ADD=0 for 0–4095 output."

	blipDuration = "Duration of throttle blip."
	blipDelay = "Delay between clutch input and throttle blip."
	blipPercentAdd = "Percent added to throttle during blip."
	blipClutchWindow = "Clutch input during this time cancels blip."
	blipClutchWindowPrd = "Blip ready period. Blip occurs if clutch input is active during this time."
	blipPedalthreshold = "Throttle blip is disabled above this pedal percentage."
	
	di1StateMode = "Active Low is pulled to ground. Active High is pulled to 5v or more"
	di2StateMode = "Active Low is pulled to ground. Active High is pulled to 5v or more"
	casParkPos = "Throttle target when ENABLE is inactive or on power-up."
	casReadyPos = "Throttle target when ENABLE is active."
	casLaunchPos = "Throttle target when LAUNCH is active."
	casRatePos = "Ramp % open during transition. When RPM curve intersects ramp, CAS follows RPM table."
	casRateTime = "Ramp time in % open per second during CAS transition."


;-------------------------------------------------------------------------------
[Menu]
   menuDialog = main

	menu = "Configuration"
		subMenu = generalSettings, "Throttle Settings",{conInput = 0},{conInput = 0}
		subMenu = casSettings, "CAS Settings", {conInput = 1}, {conInput = 1}
		subMenu = blipSettings, "Throttle Blip",{conInput = 0},{conInput = 0}
		subMenu = egateSettings, "E-Gate Settings",{conInput = 2},{conInput = 2}
		subMenu = dlg_calGroup, "Calibration"
		subMenu = pidConsent, "PID Settings"
		subMenu = pid, "PID Constants", {pidAdvancedMode = 1},{pidAdvancedMode = 1}

	
	menu = "Throttle Curves"
		subMenu = followerCurve, "Basic Follower Curve",{conInput = 0},{conInput = 0}
		subMenu = limiterRPM, "Limit by RPM Curve", {conRPM_GearLimiter = 1 && conRPMInputDBW >= 1 && conInput = 0},{conRPM_GearLimiter = 1 && conRPMInputDBW >= 1 && conInput = 0}
		groupMenu = gearLimiterCurves, "Limit by Gear Curves", {conRPM_GearLimiter = 2 && conRPMInputDBW >= 1 && conInput = 0},{conRPM_GearLimiter = 2 && conRPMInputDBW >= 1 && conInput = 0}
			groupChildMenu = gear1limiterCurve, "Gear 1", {conRPM_GearLimiter = 2 && numGears >= 1 && conRPMInputDBW >= 1 && conInput = 0}
			groupChildMenu = gear2limiterCurve, "Gear 2", {conRPM_GearLimiter = 2 && numGears >= 2 && conRPMInputDBW >= 1 && conInput = 0}
			groupChildMenu = gear3limiterCurve, "Gear 3", {conRPM_GearLimiter = 2 && numGears >= 3 && conRPMInputDBW >= 1 && conInput = 0}
			groupChildMenu = gear4limiterCurve, "Gear 4", {conRPM_GearLimiter = 2 && numGears >= 4 && conRPMInputDBW >= 1 && conInput = 0}
			groupChildMenu = gear5limiterCurve, "Gear 5", {conRPM_GearLimiter = 2 && numGears >= 5 && conRPMInputDBW >= 1 && conInput = 0}
			groupChildMenu = gear6limiterCurve, "Gear 6", {conRPM_GearLimiter = 2 && numGears >= 6 && conRPMInputDBW >= 1 && conInput = 0}
		subMenu = casRPMPos, "Position Target by RPM (CAS)", {conInput = 1},{conInput = 1}
	
	menu = "Communication"
		subMenu = canGroup1, "CANbus Configuration"


;-------------------------------------------------------------------------------
; Fields pulled from [Constants] data locations above
[UserDefined] 
	
;;;;;---------- General Settings User interface ----------------------
	dialog = baseConfig, "General"
		field = "RPM Signal Source", conRPMInputDBW, {conInput =0}
;		field = "VSS Signal Source", conVSSInput, {conInput = 100 && conInput = 0} ;todo: not yet implemented
		field = "TPS Output Range", conTPSOutRange, {conInput = 0}

	dialog = egateConfig, "General",
		field = "PWM Target Source", conPWMTargetInput, {conInput = 2}  
		field = "Target at 0% DC", , {conInput = 2}  
		field = "Target at 100% DC", , {conInput = 2}  
		
	dialog = idleConfig, "Idle"		
		field = "Idle Signal Source", conIdleInput, {conInput = 0} 
		field = "Fixed throttle minimum (%)" idleFixedMin, {conIdleInput = 0 && conInput = 0}
		field = "Throttle target at 100% DC (%)", idleDCposTarget, {conIdleInput = 1 || conIdleInput = 2 && conInput = 0}
		field = "Target at CAN value 4095ADC (%)", idleCANmaxTarget, {conIdleInput = 3 && conInput = 0}

	indicatorPanel = blipIndicatorPanel, 1, {conBlipEnable = 1 && conInput = 0}
		indicator = { blipStatus & 0b00000001 }, " BRAKE ACTIVE ", " BRAKE ACTIVE ", white, black, blue, black
		indicator = { blipStatus & 0b00000010 }, "CLUTCH ACTIVE", "CLUTCH ACTIVE", white, black, blue, black
		indicator = { blipStatus & 0b00010000 }, "  BLIP READY   ", "  BLIP READY   ", white, black, blue, black
		indicator = { blipStatus & 0b00100000 }, "  BLIP ARMED   ", "  BLIP ARMED   ", white, black, blue, black
		indicator = { blipStatus & 0b01000000 }, "  BLIP ACTIVE   ", "  BLIP ACTIVE   ", white, black, blue, black
		indicator = { blipStatus & 0b10000000 }, "BLIP DISARMED", "BLIP DISARMED", white, black, blue, black
		
	dialog = blipConfig, "Throttle Blip"
		field = "Blip Enable", conBlipEnable, {conInput = 0}
		field = "Active Below Pedal (%)", blipPedalthreshold,  {conBlipEnable = 1 && conInput = 0}
		field = "Clutch Window Start Delay (Sec)", blipClutchWindow, {conBlipEnable = 1 && conInput = 0}	;Time after brake press
		field = "Clutch Window Period (Sec)", blipClutchWindowPrd, {conBlipEnable = 1 && conInput = 0}	;Time after window Start
		field = "Blip Delay (Sec)", blipDelay, {conBlipEnable = 1 && conInput = 0}
		field = "Blip Duration (Sec)", blipDuration, {conBlipEnable = 1 && conInput = 0}
		field = "Blip Target (%)", blipPercentAdd, {conBlipEnable = 1 && conInput = 0}
		field = "Brake Input Polarity", di1StateMode, {conBlipEnable = 1 && conInput = 0}
		field = "Clutch Input Polarity", di2StateMode, {conBlipEnable = 1 && conInput = 0}
		
	dialog = indicatorPanelBlip, "Blip Status", border
		panel = blipIndicatorPanel, Center
						
	dialog = gearConfig, "Throttle Limits"
		field = "Requires an RPM Signal Source"
		field = "Limit by" , conRPM_GearLimiter, {conRPMInputDBW > 0 &&conInput = 0}
		field = "Number of gears", numGears, {conRPM_GearLimiter = 2 && conInput = 0}
		
	dialog = throttleConfig, "Special Throttle Bodies"
		field = "Throttle Body", throttleType, { conInput = 0}
		
	dialog = faultConfigThrottle, "Fault Response"
		field = "Max Position on Minor Fault (%)", faultMaxPos, {conInput = 0}
		field = "Max Deviation from Target (%)", faultMaxDev, {conInput = 0}		
		field = "Deviation Time Allowance (s)", faultSettleTime, {conInput = 0}
		field = "Fault Output", conGPOfunction, {conInput = 0}
		
	dialog = faultConfigEgate, "Fault Response"
		field = "Max Position on Minor Fault (%)", faultMaxPos, {conInput = 2}
		field = "Max Deviation from Target (%)", faultMaxDev, {conInput = 2}		
		field = "Deviation Time Allowance (s)", faultSettleTime, {conInput = 2}
		field = "Fault Output", conGPOfunction, {conInput = 2}	

	dialog = pidLoopSettings	;	Remove this entire section before releasing to Beta 
		field = "Loop Control"
		field = "!DO NOT MAKE ANY CHANGES TO THESE PARAMETERS WITHOUT REASON"
			field = "Integrator Upper Limit", pidIlimitMax
			field = "Integrator Lower Limit", pidIlimitMin
			field = "Rate (mS)", throttleControlRate 
			field = "DEV Integrator Preload", devIpreload
	dialog = disalbeAlarms, "Disable Fault Lockout"
		field = "!CAUTION: Disable at your own risk."
		field = "Lockouts will be disabled for 5 minutes."
		commandButton = "Pause Alarms", cmdPauseMajorAlarms		

	dialog = pidCurvePass, "PID Editor", yAxis
		panel = pidCurve
		
	dialog = pid, "PID Constants" , yAxis
		panel = pidLoopSettings
		panel = disalbeAlarms
		panel = pidCurvePass
	
	dialog = pidConsent, "PID Constants Unlock", yAxis
		field = "!CAUTION: Enabling this unlocks advanced PID tuning features."
		field = "!Do not make changes unless you fully understand their function or have been instructed by technical support."
		field = "#Entering advanced mode involves inherent risk and may result in unsafe operating conditions."
		radioSelect = horizontal, "PID Unlock", pidAdvancedMode
			
	
	dialog = settingsA, "", yAxis
		panel = baseConfig
		panel = throttleConfig

		panel = faultConfigThrottle	
		
	dialog = settingsB, "", yAxis	
		panel = idleConfig
		panel = gearConfig


;;;;;---------- End General Settings User Interface --------------------

;;;;;---------- CAS Settings User Interface --------------------
	indicatorPanel = casIndicatorPanel, 1, {conInput = 1}
		indicator = { casStatus & 0b00000001 }, "CAS: Disabled", "CAS: Enabled", white, black, blue, black
		indicator = { casStatus & 0b00000010 }, "Launch Input ", "Launch Input ", white, black, blue, black
		indicator = { casStatus & 0b00000100 }, " Ready Mode  ", " Ready Mode  ", white, black, blue, black
		indicator = { casStatus & 0b00001000 }, "Launch Mode ", "Launch Mode ", white, black, blue, black
		indicator = { casStatus & 0b00010000 }, "  Ramp Mode  ", "  Ramp Mode  ", white, black, blue, black
		indicator = { casStatus & 0b00100000 }, "  Table Mode  ", "  Table Mode  ", white, black, blue, black
		
	dialog = indicatorPanelCas, "CAS Status", border
		panel = casIndicatorPanel, Center	

	dialog = casConfig, "CAS Configuration"
		field = "Park Hold Position (%)", casParkPos, {conInput = 1}  
		field = "Ready Hold Position (%)", casReadyPos, {conInput = 1}  
		field = "Launch Start Position (%)", casLaunchPos, {conInput = 1}  
		field = "Ramp Open percent (over time)(%)", casRatePos, {conInput = 1}  
		field = "Ramp Open rate (mS)", casRateTime, {conInput = 1} 
		field = "RPM Signal Source", conRPMInputCAS, {conInput = 1}
		field = "Enable Input Polarity", di1StateMode, {conInput = 1}
		field = "Launch Input Polarity", di2StateMode, {conInput = 1}
		
;;;;;---------- CANBUS 	
	dialog = canset, "CANbus Settings"
		field = "Baud", canBaud	
		field = "Termination Resistor", canTerm
		field = "11-bit Messaging", canMode11
		field = "29-bit MSCAN", canMode29
		field = "MSCAN ID", canID, {canMode29 = 1}
		field = "CAN Polling Interval (mS)", cantxBroadcast, {canMode11 = 1}
		
	dialog = canAddrs_Blank, ""
		field = "          "
		
	dialog = canInAddrs_Names , ""
		field = "Message"
		field = "RPM"
		field = "Gear"
		field = "VSS"
		field = "Idle"
		
	dialog = canInAddersSelect, "Predefined Standard Addressing - Inbound Messages Selector" , yAxis
		settingSelector = "Select your ECU",  {canMode11 = 1} 
			settingOption = "MS3pro",		canIn_ID_RPM=1520,canIn_Off_RPM=6,canIn_Mult_RPM=1,canIn_Div_RPM=1,canIn_Add_RPM=0,canIn_ID_Gear=1553,canIn_Off_Gear=6,canIn_Mult_Gear=1,canIn_Div_Gear=1,canIn_Add_Gear=0,canIn_ID_VSS=1562,canIn_Off_VSS=0,canIn_Mult_VSS=1,canIn_Div_VSS=10,canIn_Add_VSS=0,canIn_ID_Idle=1526,canIn_Off_Idle=6,canIn_Mult_Idle=16,canIn_Div_Idle=1,canIn_Add_Idle=0

	dialog = canInAddrs_ID , ""
		field = "ID (dec)"
		field = "", canIn_ID_RPM, {canMode11 = 1}
		field = "", canIn_ID_Gear, {canMode11 = 1}
		field = "", canIn_ID_VSS, {canMode11 = 1}
		field = "", canIn_ID_Idle {canMode11 = 1}

	dialog = canInAddrs_Off, ""
		field = "Offset"
		field = "", canIn_Off_RPM, {canMode11 = 1}
		field = "", canIn_Off_Gear, {canMode11 = 1}
		field = "", canIn_Off_VSS, {canMode11 = 1}
		field = "", canIn_Off_Idle, {canMode11 = 1}

	dialog = canInAddrs_Mult, ""
		field = "Multiply"
		field = "", canIn_Mult_RPM, {canMode11 = 1}
		field = "", canIn_Mult_Gear, {canMode11 = 1}
		field = "", canIn_Mult_VSS, {canMode11 = 1}
		field = "", canIn_Mult_Idle, {canMode11 = 1}

	dialog = canInAddrs_Div, ""
		field = "Divide"
		field = "", canIn_Div_RPM, {canMode11 = 1}
		field = "", canIn_Div_Gear, {canMode11 = 1}
		field = "", canIn_Div_VSS, {canMode11 = 1}
		field = "", canIn_Div_Idle, {canMode11 = 1}


	dialog = canInAddrs_Add, ""
		field = "Add"
		field = "", canIn_Add_RPM, {canMode11 = 1}
		field = "", canIn_Add_Gear, {canMode11 = 1}
		field = "", canIn_Add_VSS, {canMode11 = 1}
		field = "", canIn_Add_Idle, {canMode11 = 1}


	dialog = canInAddrs, "Standard CAN Addressing - Inbound Messages", xAxis
		panel = canInAddrs_Names
		panel = canInAddrs_ID
		panel = canInAddrs_Off
		panel = canInAddrs_Mult
		panel = canInAddrs_Div		
		panel = canInAddrs_Add
		
	readoutPanel = canInreadoutPanel, 4,
		readout = CANRPMGauge
		readout = CANGearGauge
		readout = CANVSSGauge
		readout = CANIdleTargADC, "CAN Idle ADC", "", 0, 4095, 0, 0, 5000, 5000, 0

	dialog = canOutAddrs1_Off, "",
		field = "Message 1 ID (dec)", canOut_Sensors1_ID, {canMode11 = 1}
	 dialog = canOutAddrs1_exp, "",
		field = "--0/1:Pedal,  2/3:TPS (Absolute),  4/5:TPS (Relative - Excluding Idle), 6:Blip Status-----------------------"	
	
	dialog = canOutAddrs2_Off, "",		
		field = "Message 2 ID (dec)", canOut_Sensors2_ID, 	{canMode11 = 1}
	 dialog = canOutAddrs2_exp, "",
		field = "-- 01:I/O Ref Voltage 1,  2/3:I/O Ref Voltage 2,  4/5:Supply Voltage,  6/7:Motor Current  ------------------"

	dialog = canOutAddrs3_Off, "",
		field = "Message 3 ID (dec)", canOut_Faults1_ID, {canMode11 = 1}
	 dialog = canOutAddrs3_exp, "", 
		field = "-- 0/1:General Fault,  2/3:Processor Fault,  4/5:Hardware Fault --------------------------------------------------"

	dialog = canOutAddrs4_Off, "",
		field = "Message 4 ID (dec)", canOut_Faults2_ID, {canMode11 = 1}
	 dialog = canOutAddrs4_exp, "", 
		field = "--0/1:Pedal1 Fault,  2/3:Pedal2 Fault,  4/5:TPS1 Fault,  6/7:TPS2 Fault -----------------------------------------"

	dialog = canOutAddrs1, "Standard CAN Addressing - Outbound Message 1", border
		panel = canOutAddrs1_Off, West
	    panel = canOutAddrs1_exp, East

	dialog = canOutAddrs2, "Standard CAN Addressing - Outbound Message 2", border
		panel = canOutAddrs2_Off, West
		panel = canOutAddrs2_exp, East

	dialog = canOutAddrs3, "Standard CAN Addressing - Outbound Message 3", border
		panel = canOutAddrs3_Off, West
		panel = canOutAddrs3_exp, East

	dialog = canOutAddrs4, "Standard CAN Addressing - Outbound Message 4", border
		panel = canOutAddrs4_Off, West
		panel = canOutAddrs4_exp, East

	dialog = canGroup1A, "", yAxis	
		panel = canInAddersSelect
		panel = canInAddrs
		panel = canInreadoutPanel	

	dialog = canGroup1, "", yAxis
		panel = canset
		panel = canGroup1A
		panel = canOutAddrs1
		panel = canOutAddrs2
		panel = canOutAddrs3
		panel = canOutAddrs4
	
	;------------------
	dialog = generalSettings, "Throttle Settings", border
		panel = settingsA, West
		panel = settingsB, Center

	dialog = blipSettings, "Blip Setup", border
		panel = blipConfig, West
		panel = indicatorPanelBlip, East
		
	dialog = egateSettings, "E-Gate Settings", border
		panel = egateConfig, North
		panel = faultConfigEgate, South
		
	dialog = casSettings, "CAS Settings", border
		panel = casConfig, West
		panel = indicatorPanelCas, East
		
	;-----------------	
	;Hardware Fields
	;-----------------
			
;;;;;------------------	Calibration User Interface -----------------------------------
	dialog = dlg_calThrottleGroup, "Calibrate Throttle"
		field = "Start Automatic Calibration"
			commandButton = "START", cmdStartLearn
		field = "Stop Automatic Calibration"
			commandButton = "STOP", cmdStopLearn	;, clickOnCloseIfEnabled
			runtimeValue = "ADC Closed 1", tps1MinADC
			runtimeValue = "ADC Closed 2", tps2MinADC
		field = ""
			runtimeValue = "ADC Rest 1", tps1RestADC
			runtimeValue = "ADC Rest 2", tps2RestADC
		field = ""
			runtimeValue = "ADC Open 1", tps1MaxADC
			runtimeValue = "ADC Open 2", tps2MaxADC
						
	dialog = dlg_calPedalGroup, "Calibrate Pedal"		
		field = "Get Closed Throttle ADC value"
			commandButton = "Measure", cmdPedalLearnBottom, {conInput = 0}
			runtimeValue = "ADC 1", pedal1MinADC, {conInput = 0}
			runtimeValue = "ADC 2", pedal2MinADC, {conInput = 0}
		field = "Get Full Throttle ADC value"
			commandButton = "Measure", cmdPedalLearnTop, {conInput = 0}
			runtimeValue = "ADC1", pedal1MaxADC, {conInput = 0}
			runtimeValue = "ADC2", pedal2MaxADC, {conInput = 0}
	
	indicatorPanel = CalindicatorPanelDBW, 1
		indicator = { calFlags & 0b0000000000000001 }, "Pedal Low Cal'd", "Calibrate Pedal Low", white, black, red, black
		indicator = { calFlags & 0b0000000000000010 }, "Pedal High Cal'd", "Calibrate Pedal High", white, black, red, black
		indicator = { calFlags & 0b0000000000000100 }, "Throttle Cal'd", "Calibrate Throttle", white, black, red, black
		indicator = { calStat & 0b0000000000001000 }, "Calibration Idle","Calibrating Throttle", white, black, yellow, black
		indicator = { calStat & 0b0000000000010000 }, "Not Canceled", "Calibration Canceled", white, black, yellow, black
		indicator = { calStat & 0b0000000000100000 }, "No timeout", "Calibration Timeout", white, black, yellow, black
		
	indicatorPanel = CalindicatorPanelCAS, 1
		indicator = { calFlags & 0b0000000000000100 }, "Throttle Cal'd", "Calibrate Throttle", white, black, red, black
		indicator = { calStat & 0b0000000000001000 }, "Calibration Idle","Calibrating Throttle", white, black, yellow, black
		indicator = { calStat & 0b0000000000010000 }, "Not Canceled", "Calibration Canceled", white, black, yellow, black
		indicator = { calStat & 0b0000000000100000 }, "No timeout", "Calibration Timeout", white, black, yellow, black	
		
	dialog = indicatorPanelCal, "Calibration Status", card
		panel = CalindicatorPanelDBW, Center, {conInput = 0}
		panel = CalindicatorPanelCAS, Center, {conInput = 1}
		
	dialog = dlg_warning, ""
		field = "!WARNING: NEVER CALIBRATE THROTTLE ON A RUNNING ENGINE"

	dialog = dlg_calGroup, "", border
		panel = dlg_warning, North, {conInput = 0}, {conInput = 0}
		panel = dlg_calPedalGroup, West, {conInput = 0},{conInput = 0}
		panel = dlg_calThrottleGroup, Center
		panel = indicatorPanelCal, East

;;;;;-------------------- End Calibration User Interface ----------------------------------			

			
	dialog = limiterRPM, "Limit by RPM", border
		panel = rpmLimiterCurve, Center

	dialog = limiterGear1, "Limit by Gear 1", border
		panel = gear1limiterCurve, Center
		
	dialog = limiterGear2, "Limit by Gear 2", border
		panel = gear2limiterCurve, Center

	dialog = limiterGear3, "Limit by Gear 3", border
		panel = gear3limiterCurve, Center

	dialog = limiterGear4, "Limit by Gear 4", border
		panel = gear4limiterCurve, Center
		
	dialog = limiterGear5, "Limit by Gear 5", border
		panel = gear5limiterCurve
		
	dialog = limiterGear6, "Limit by Gear 6", border
		panel = gear6limiterCurve
		
	dialog = casRPMPos, "Position by RPM", border
		panel = casRPMPosCurve, Center	
				

;-------------------------------------------------------------------------------
[CurveEditor]
	curve = pidCurve, "PID Constants"
          xAxis         = -1000, 1000, 16
          yAxis         = 0, 300, 16
		  xBins		    = PIDxAxis_Error, controlError
		  yBins		    = KPCurve
		  yBins		    = KICurve
		  yBins		    = KDCurve
		  lineLabel     = "KP"
		  lineLabel     = "KI"
		  lineLabel     = "KD"
		  showTextValues = true
		  
    curve = followerCurve, "Throttle Follower"
          columnLabel   = "Pedal %", "Throttle %"
          xAxis         = 0, 100, 11
          yAxis         = 0, 100, 11
          xBins         = follower_PedalIn, normalizedPedal1Percent, readOnly
          yBins         = follower_ThrottleOut
		  
	curve = casRPMPosCurve, "Throttle Position Target"	
          columnLabel = "RPM", "Target Position %"
          xAxis       = 0, 10000, 11
          yAxis       = 0, 100, 11
          xBins       = gearLimiter1_RPMIn			;shares memory with gear 1 table and DBW Limit by RPM
          yBins       = gearLimiter1_ThrottleOut	;shares memory with gear 1 table and DBW Limit by RPM
;		  showXYDataPlot = true, rpm, tpsoutpos 

    curve = rpmLimiterCurve, "RPM Throttle Limiter"
          columnLabel = "RPM", "Max Throttle %"
          xAxis       = 0, 10000, 11
          yAxis       = 0, 100, 11
          xBins       = gearLimiter1_RPMIn			;shares memory with gear 1 table and CAS RPM Target
          yBins       = gearLimiter1_ThrottleOut	;shares memory with gear 1 table and CAS RPM Target
		  
    curve = gear1limiterCurve, "Gear 1 Throttle Limiter"
          columnLabel = "RPM", "Max Throttle %"
          xAxis       = 0, 10000, 11
          yAxis       = 0, 100, 11
          xBins       = gearLimiter1_RPMIn          ;shares memory with DBW Limit by RPM table and CAS RPM Target
          yBins       = gearLimiter1_ThrottleOut    ;shares memory with DBW Limit by RPM table and CAS RPM Target

    curve = gear2limiterCurve, "Gear 2 Throttle Limiter"
          columnLabel = "RPM", "Max Throttle %"
          xAxis       = 0, 10000, 11
          yAxis       = 0, 100, 11
          xBins       = gearLimiter2_RPMIn        
          yBins       = gearLimiter2_ThrottleOut    

    curve = gear3limiterCurve, "Gear 3 Throttle Limiter"
          columnLabel = "RPM", "Max Throttle %"
          xAxis       = 0, 10000, 11
          yAxis       = 0, 100, 11
          xBins       = gearLimiter3_RPMIn        
          yBins       = gearLimiter3_ThrottleOut    

    curve = gear4limiterCurve, "Gear 4 Throttle Limiter"
          columnLabel = "RPM", "Max Throttle %"
          xAxis       = 0, 10000, 11
          yAxis       = 0, 100, 11
          xBins       = gearLimiter4_RPMIn
          yBins       = gearLimiter4_ThrottleOut

    curve = gear5limiterCurve, "Gear 5 Throttle Limiter"
          columnLabel = "RPM", "Max Throttle %"
          xAxis       = 0, 10000, 11
          yAxis       = 0, 100, 11
          xBins       = gearLimiter5_RPMIn
          yBins       = gearLimiter5_ThrottleOut

    curve = gear6limiterCurve, "Gear 6 Throttle Limiter"
          columnLabel = "RPM", "Max Throttle %"
          xAxis       = 0, 10000, 11
          yAxis       = 0, 100, 11
          xBins       = gearLimiter6_RPMIn
          yBins       = gearLimiter6_ThrottleOut
;-------------------------------------------------------------------------------
[GaugeConfigurations]

   
   
pedal1Gauge					= pedal1ADC,		"Pedal 1 Raw",		"ADC",	0,	16384,	0,	0,	16384,	16384,	0,	0
pedal2Gauge					= pedal2ADC,		"Pedal 2 Raw",		"ADC",	0,	16384,	0,	0,	16384,	16384,	0,	0
pedalDiffPercGauge			= pedalDiffPercent,	"Pedal Difference Percent",		"%",	0,	100,	-1,	-1,	16384,	16384,	0,	0
normalizedPedal1ADCGauge	= normalizedPedal1ADC,	"Pedal 1 Normalized ADC",	"ADC",	0,	100,	-1,	-1,	16384,	16384,	0,	0
normalizedPedal1PercGauge	= normalizedPedal1Percent,	"Pedal 1 Percent",	"%",	0,	100,	-2,	-2,	16384,	16384,	0,	0
normalizedPedal2ADCGauge	= normalizedPedal2ADC,	"Pedal 2 Normalized ADC",	"ADC",	0,	100,	-1,	-1,	16384,	16384,	0,	0
normalizedPedal2PercGauge	= normalizedPedal2Percent,	"Pedal 2 Percent",	"%",	0,	100,	-2,	-2,	16384,	16384,	0,	0

tps1Gauge					= tps1ADC,		"TPS 1 Raw",		"ADC",	0,	16384,	0,	0,	16384,	16384,	0,	0
tps2Gauge					= tps2ADC,		"TPS 2 Raw",		"ADC",	0,	16384,	0,	0,	16384,	16384,	0,	0
tpsDiffPercGauge			= tpsDiffPercent,	"TPS Difference Percent",		"%",	0,	100,	0,	0,	16384,	16384,	0,	0
normalizedtps1ADCGauge		= normalizedtps1ADC,	"TPS 1 Normalized ADC",	"ADC",	0,	100,	0,	0,	16384,	16384,	0,	0
normalizedtps1PercGauge		= normalizedtps1Percent,	"TPS 1 Percent",	"%",	0,	100,	0,	0,	16384,	16384,	0,	0
normalizedtps2ADCGauge		= normalizedtps2ADC,	"TPS 2 Normalized ADC",	"ADC",	0,	100,	0,	0,	16384,	16384,	0,	0
normalizedtps2PercGauge		= normalizedtps2Percent,	"TPS 2 Percent",	"%",	0,	100,	0,	0,	16384,	16384,	0,	0

normalizedIdleTargetGauge 	= normalizedIdleTarget, "Idle Target Normalized ADC",	"ADC",	0,	100,	0,	0,	16384,	16384,	0,	0
normalizedIdleTargetPercGauge 	= normalizedIdleTargetPerc, "Idle Target Percent",	"%",	0,	100,	0,	0,	16384,	16384,	0,	0

ThrottleDutyCycle			= pwmDC_Percent, "Throttle Motor Duty Cycle Out",       "%", 0.0, 100.0, 0, 0, 6553, 6553, 0, 0
ThrottleDutyCycleADC		= pwmDC_ADC, "Throttle Motor Duty Cycle Out",       "ADC", 0.0, 100.0, 0, 0, 6553, 6553, 0, 0

closedPWMGauge 				= closedPWM,"Cal: PWM Closed",	"PWM",	0,	100,	0,	0,	16384,	16384,	0,	0
movingClosedPWMGauge 		= movingClosedPWM,"Cal: PWM Moving Closed",	"ADC",	0,	100,	0,	0,	16384,	16384,	0,	0
movingOpenPWMGauge 			= movingOpenPWM,"Cal: PWM Moving Open",	"ADC",	0,	100,	0,	0,	16384,	16384,	0,	0
openedPWMGauge 				= openedPWM,"Cal: PWM Open",	"ADC",	0,	100,	0,	0,	16384,	16384,	0,	0

vcc1Gauge					= vcc1Volts,		"Power: I/O Ref 1 Volts",	"VDC",	0.0,	80.0,	4.8,	4.875,	5.125,	5.2,	1,	1
vcc2Gauge					= vcc2Volts,		"Power: I/O Ref 2 Volts",	"VDC",	0.0,	80.0,	4.8,	4.875,	5.125,	5.2,	1,	1
battGauge					= battVolts,		"Power: Battery Volts",	"VDC",	0.0,	16.0,	11.0,	10.5,	15.0,	15.5,	1,	1
throt1CurrentLGauge			= iSupplyAmps,	"Power: Supply Current",	"A",	0.000,	25.000,	0,	0,	16384,	16384,	0,	0

freeTimeGauge				= freeTime		"Time: Free Running Timer",	"mS",	0,	100,	0,	0,	65535,	65535,	0,	0
loopTimeGauge				= t_loop		"Time: Loop Timer",	"uS",	0.0,	100,	0,	0,	65535,	65535,	0,	0
wdTimeGauge					= wdTimer		"Time: Watchdog Timer",	"uS",	0.0,	100,	0,	0,	65535,	65535,	0,	0

rpmGauge					= rpm	,		"RPM",			"RPM",	0,	65535,	0,	0,	65535,	65535,	0,	0

CANRPMGauge					= CANrpm	,		"CAN: RPM",			"RPM",	0,	65535,	0,	0,	65535,	65535,	0,	0
CANGearGauge				= CANgear,			"CAN: Gear",			"Gear",	0,	255,	0,	0,	255,	255,	0,	0	
CANVSSGauge					= CANvss,			"CAN: VSS",			""    ,	0,	65535,	0,	0,	65535,	65535,	0,	0	
CANIdleGauge				= CANIdleTargADC,	"CAN: Idle Target",			"ADC"    ,	0,	65535,	0,	0,	65535,	65535,	0,	0	

controlTargetGauge 			= controlTarget "PID: Control Target", "ADC",	0,	4095,	0,	0,	65535,	65535,	0,	0
controlPositionGauge 		= controlPosition, "PID: Control Position", "ADC",	0,	4095,	0,	0,	65535,	65535,	0,	0
controlErrorGauge 			= controlError, "PID: Control Position Error", "ADC",	-1000,	1000,	-65535,	-65535,	65535,	65535,	0,	0

KPCurve						= kPcalc , 	"PID: Calculated P coeff",    %d,   1,   750,      0, 0, 65536, 65536, 0,0 
KICurve						= kIcalc , 	"PID: Calculated I coeff",    %d,   1,   750,      0, 0, 65536, 65536, 0,0 
KDCurve						= kDcalc , 	"PID: Calculated D coeff",    %d,   1,   750,      0, 0, 65536, 65536, 0,0 

testGauge					= test,	"test"	"%",	0,	16384,	0,	0,	16384,	16384,	0,	0

diagPedal1MinADC 			= pedal1MinADC,	"Cal: Pedal 1 Min ADC"	"",	0,	16384,	0,	0,	16384,	16384,	0,	0
diagPedal1MaxADC 			= pedal1MaxADC,	"Cal: Pedal 1 Max ADC"	"",	0,	16384,	0,	0,	16384,	16384,	0,	0

diagPedal2MinADC 			= pedal2MinADC,	"Cal: Pedal 2 Min ADC"	"",	0,	16384,	0,	0,	16384,	16384,	0,	0
diagPedal2MaxADC 			= pedal2MaxADC,	"Cal: Pedal 2 Max ADC"	"",	0,	16384,	0,	0,	16384,	16384,	0,	0


diagTPS1MinADC 				= tps1MinADC,	"Cal: TPS 1 Min ADC"	"",	0,	16384,	0,	0,	16384,	16384,	0,	0
diagTPS1RestADC 			= tps1RestADC,	"Cal: TPS 1 Rest ADC"	"",	0,	16384,	0,	0,	16384,	16384,	0,	0
diagTPS1MaxADC 				= tps1MaxADC,	"Cal: TPS 1 Max ADC"	"",	0,	16384,	0,	0,	16384,	16384,	0,	0

diagTPS2MinADC 				= tps2MinADC,	"Cal: TPS 2 Min ADC"	"",	0,	16384,	0,	0,	16384,	16384,	0,	0
diagTPS2RestADC 			= tps2RestADC,	"Cal: TPS 2 Rest ADC"	"",	0,	16384,	0,	0,	16384,	16384,	0,	0
diagTPS2MaxADC 				= tps2MaxADC,	"Cal: TPS 2 Max ADC"	"",	0,	16384,	0,	0,	16384,	16384,	0,	0

tpsAlarms1bits				= tpsAlarms1, "Status: TPS 1 Word" "",	0,	65535,	0,	0,	1,	1,	0,	0
tpsAlarms2bits				= tpsAlarms2, "Status: TPS 2 Word" "",	0,	65535,	0,	0,	1,	1,	0,	0
pedalAlarms1bits			= pedalAlarms1, "Status: Pedal 1 Word" "",	0,	65535,	0,	0,	1,	1,	0,	0
pedalAlarms2bits			= pedalAlarms2, "Status: Pedal 2 Word" "",	0,	65535,	0,	0,	1,	1,	0,	0

processorAlarmbits 			= procAlarms0, "Status: Processor Word" "",	0,	65535,	0,	0,	1,	1,	0,	0
systemAlarmbits 			= gAlarms0, "Status: System Word" "",	0,	65535,	0,	0,	1,	1,	0,	0
hardwareAlarmbits 			= hardwareAlarms0, "Status: Hardware Word" "",	0,	65535,	0,	0,	1,	1,	0,	0

canStatusbits 				= canStat, "Status: CAN Word" "",	0,	65535,	0,	0,	1,	1,	0,	0
;-------------------------------------------------------------------------------

[FrontPage]

gauge1 = normalizedtps1PercGauge
gauge2 = normalizedtps2PercGauge
gauge3 = normalizedPedal1PercGauge
gauge4 = normalizedPedal2PercGauge
gauge5 = controlTargetGauge
gauge6 = controlPositionGauge
gauge7 = controlErrorGauge
gauge8 = ThrottleDutyCycle



indicator = { gAlarms0 & 0b0000000000000001 }, "No Minor Faults", "Minor Fault", white, black, red, black
indicator = { gAlarms0 & 0b0000000000000010 }, "No Major Faults", "Major Faults", white, black, red, black
indicator = { gAlarms0 & 0b0000000000000100 }, "Fault Safeties Enabled", "Fault Safeties Disabled", white, black, red, black

indicator = { calFlags & 0b0000000000000001 }, "Pedal Low Cal'd", "Calibrate Pedal Low", white, black, red, black
indicator = { calFlags & 0b0000000000000010 }, "Pedal High Cal'd", "Calibrate Pedal High", white, black, red, black
indicator = { calFlags & 0b0000000000000100 }, "Throttle Cal'd", "Calibrate Throttle", white, black, red, black
indicator = { calStat & 0b0000000000001000 }, "Calibration Idle","Calibrating Throttle", white, black, yellow, black
indicator = { calStat & 0b0000000000010000 }, "Not Canceled", "Calibration Canceled", white, black, yellow, black
indicator = { calStat & 0b0000000000100000 }, "No timeout", "Calibration Timeout", white, black, yellow, black


indicator = { (hardwareAlarms0 & 0b0000000000000011) > 0}, "VREF1 OK", "VREF1 Fault", white, black, red, black
indicator = { (hardwareAlarms0 & 0b0000000000001100) > 0}, "VREF2 OK", "VREF2 Fault", white, black, red, black
indicator = { hardwareAlarms0 & 0b0000000000010000 }, "Batt OK", "Batt Fault", white, black, red, black

indicator = { hardwareAlarms0 & 0b0000000001000000 }, "Motor Not Open", "Motor Open", white, black, red, black
indicator = { hardwareAlarms0 & 0b0000000010000000 }, "Motor Not Shorted", "Motor Short", white, black, red, black
indicator = { hardwareAlarms0 & 0b0000000100000000 }, "Motor Not Stuck", "Motor Stuck", white, black, red, black
indicator = { hardwareAlarms0 & 0b0000001000000000 }, "Target Matched", "Off Target", white, black, red, black
indicator = { hardwareAlarms0 & 0b0000010000000000 }, "Motor Driver Enabled", "Motor Driver Disabled", white, black, red, black
indicator = { hardwareAlarms0 & 0b0000100000000000 }, "Motor Direction OK", "Motor Direction Reversed", white, black, red, black
indicator = { hardwareAlarms0 & 0b0001000000000000 }, "Pedal Sensors Not Shorted", "Pedal Sensors Shorted", white, black, red, black 
indicator = { hardwareAlarms0 & 0b0010000000000000 }, "TPS Sensors Not Shorted", "TPS Sensors Shorted", white, black, red, black 


;Processor
indicator = { procAlarms0 & 0b0000000000001111 }, "Flash Ops OK", "Flash Ops Fault", white, black, red, black
indicator = { procAlarms0 & 0b0000000000010000 }, "Cal Loaded", "No Cal Loaded", white, black, red, black
indicator = { procAlarms0 & 0b0000000000100000 }, "Cal CRC OK", "Cal CRC Fail", white, black, red, black
indicator = { procAlarms0 & 0b0000000001000000 }, "Configuration Loaded", "No Configuration Loaded", white, black, red, black
indicator = { procAlarms0 & 0b0000000010000000 }, "FW OK", "Wrong Firmware", white, black, red, black

indicator = { procAlarms0 & 0b0000000000010000 }, "ROM Write Fault", "ROM Write Fault", white, black, red, black

indicator = { pedalAlarms1 & 0b0000000000100000 }, "Pedal Tracking", "Pedal Not Tracking", white, black, red, black
indicator = { tpsAlarms1 & 0b0000000000100000 }, "TPS Tracking", "TPS Not Tracking", white, black, red, black

indicator = { (pedalAlarms1 & 0b00011111) > 0}, "Pedal 1 OK", "Pedal 1 Fault", green, black, red black
indicator = { (pedalAlarms2 & 0b00011111) > 0}, "Pedal 2 OK", "Pedal 2 Fault", green, black, red black

indicator = { pedalAlarms1 & 0b00000001 }, "Pedal Sensor 1 High", "Pedal Sensor 1 High", white, black, red, black 
indicator = { pedalAlarms1 & 0b00000010 }, "Pedal Sensor 1 Low", "Pedal Sensor 1 Low", white, black, red, black 
indicator = { pedalAlarms1 & 0b00000100 }, "Pedal Sensor 1 Span", "Pedal Sensor 1 Span", white, black, red, black 
indicator = { pedalAlarms1 & 0b00001000 }, "Pedal Sensor 1 Short/Open", "Pedal Sensor 1 Short/Open", white, black, red, black 
indicator = { pedalAlarms1 & 0b00010000 }, "Pedal Sensor 1 Short High", "Pedal Sensor 1 Short High", white, black, red, black 
indicator = { pedalAlarms1 & 0b01000000 }, "Pedal Sensor 1 Cal Fault", "Pedal Sensor 1 Cal Fault", white, black, red, black 

indicator = { pedalAlarms2 & 0b00000001 }, "Pedal Sensor 2 High", "Pedal Sensor 2 High", white, black, red, black 
indicator = { pedalAlarms2 & 0b00000010 }, "Pedal Sensor 2 Low", "Pedal Sensor 2 Low", white, black, red, black 
indicator = { pedalAlarms2 & 0b00000100 }, "Pedal Sensor 2 Span", "Pedal Sensor 2 Span", white, black, red, black 
indicator = { pedalAlarms2 & 0b00001000 }, "Pedal Sensor 2 Short/Open", "Pedal Sensor 2 Short/Open", white, black, red, black 
indicator = { pedalAlarms2 & 0b00010000 }, "Pedal Sensor 2 Short High", "Pedal Sensor 2 Short High", white, black, red, black 
indicator = { pedalAlarms2 & 0b01000000 }, "Pedal Sensor 2 Cal Fault", "Pedal Sensor 2 Cal Fault", white, black, red, black 

indicator = { (tpsAlarms1 & 0b00011111) > 0}, "TPS 1 OK", "TPS 1 Fault", green, black, red black
indicator = { (tpsAlarms2 & 0b00011111) > 0}, "TPS 2 OK", "TPS 2 Fault", green, black, red black

indicator = { tpsAlarms1 & 0b00000001 }, "TPS Sensor 1 High", "TPS Sensor 1 High", white, black, red, black 
indicator = { tpsAlarms1 & 0b00000010 }, "TPS Sensor 1 Low", "TPS Sensor 1 Low", white, black, red, black 
indicator = { tpsAlarms1 & 0b00000100 }, "TPS Sensor 1 Span", "TPS Sensor 1 Span", white, black, red, black 
indicator = { tpsAlarms1 & 0b00001000 }, "TPS Sensor 1 Short/Open", "TPS Sensor 1 Short/Open", white, black, red, black 
indicator = { tpsAlarms1 & 0b00010000 }, "TPS Sensor 1 Short High", "TPS Sensor 1 Short High", white, black, red, black 
indicator = { tpsAlarms1 & 0b01000000 }, "TPS Sensor 1 Cal Fault", "TPS Sensor 1 Cal Fault", white, black, red, black 

indicator = { tpsAlarms2 & 0b00000001 }, "TPS Sensor 2 High", "TPS Sensor 2 High", white, black, red, black 
indicator = { tpsAlarms2 & 0b00000010 }, "TPS Sensor 2 Low", "TPS Sensor 2 Low", white, black, red, black 
indicator = { tpsAlarms2 & 0b00000100 }, "TPS Sensor 2 Span", "TPS Sensor 2 Span", white, black, red, black 
indicator = { tpsAlarms2 & 0b00001000 }, "TPS Sensor 2 Short/Open", "TPS Sensor 2 Short/Open", white, black, red, black 
indicator = { tpsAlarms2 & 0b00010000 }, "TPS Sensor 2 Short High", "TPS Sensor 2 Short High", white, black, red, black 
indicator = { tpsAlarms2 & 0b01000000 }, "TPS Sensor 2 Cal Fault", "TPS Sensor 2 Cal Fault", white, black, red, black 

indicator = { canStat & 0b00000001 }, "CAN TX Passive OK", "CAN TX Passive Error", white, black, red, black 
indicator = { canStat & 0b00000010 }, "CAN TX Active OK", "CAN TX Active Error", white, black, red, black 
indicator = { canStat & 0b00000100 }, "CAN RX Passive OK", "CAN RX Passive Error", white, black, red, black 
indicator = { canStat & 0b00001000 }, "CAN RX Active OK", "CAN RX Active Error", white, black, red, black 
indicator = { canStat & 0b00010000 }, "CAN Bus On", "CAN Bus Off", white, black, red, black 
indicator = { canStat }, "CAN OK", "CAN Fault", white, black, red, black 

indicator = { gConfigAlarms  & 0b00000001}, "IO: PWM1 In Config OK", "IO: PWM1 In Multiple Assignment", white, black, red, black 
indicator = { gConfigAlarms  & 0b00000010}, "IO: PWM2 In Config OK", "IO: PWM2 In Multiple Assignment", white, black, red, black

indicator = { diStatus & 0b00000001 }, "IO: Digital Input 1 Low", "IO: Digital Input 1 High", white, black, blue, black
indicator = { diStatus & 0b00000010 }, "IO: Digital Input 2 Low", "IO: Digital Input 2 High", white, black, blue, black

indicator = { dbwStatus & 0b00000001 }, "DBW: Not in Idle", "DBW: Idle", white, black, blue, black
indicator = { dbwStatus & 0b00000010 }, "DBW: RPM Limit Inactive", "DBW: RPM Limit Active", white, black, blue, black
indicator = { dbwStatus & 0b00000100 }, "DBW: Gear Limit Inactive", "DBW: Gear Limit Active", white, black, blue, black
indicator = { dbwStatus & 0b00001000 }, "DBW: Not Using Pedal1", "DBW: Using Pedal1", white, black, blue, black
indicator = { dbwStatus & 0b00010000 }, "DBW: Not Using Pedal2", "DBW: Using Pedal2", white, black, blue, black
indicator = { dbwStatus & 0b00100000 }, "DBW: Not Using TPS1", "DBW: Using TPS1", white, black, blue, black
indicator = { dbwStatus & 0b01000000 }, "DBW: Not Using TPS2", "DBW: Using TPS2", white, black, blue, black

indicator = { blipStatus & 0b00000001 }, "BLIP: BRAKE ACTIVE", "BLIP: BRAKE ACTIVE", white, black, blue, black
indicator = { blipStatus & 0b00000010 }, "BLIP: CLUTCH ACTIVE", "BLIP: CLUTCH ACTIVE", white, black, blue, black
indicator = { blipStatus & 0b00010000 }, "BLIP READY", "BLIP READY", white, black, blue, black
indicator = { blipStatus & 0b00100000 }, "BLIP ARMED", "BLIP ARMED", white, black, blue, black
indicator = { blipStatus & 0b01000000 }, "BLIP ACTIVE", "BLIP ACTIVE", white, black, blue, black
indicator = { blipStatus & 0b10000000 }, "BLIP DISARMED", "BLIP DISARMED", white, black, blue, black
indicator = { dbwStatus & 0b00100000 }, "CAS: Not Using TPS1", "CAS: Using TPS1", white, black, blue, black
indicator = { dbwStatus & 0b01000000 }, "CAS: Not Using TPS2", "CAS: Using TPS2", white, black, blue, black

indicator = { casStatus & 0b00000001 }, "CAS: Disabled", "CAS: Enabled", white, black, blue, black
indicator = { casStatus & 0b00000010 }, "CAS: Launch Input Inactive", "CAS: Launch Input Active", white, black, blue, black
indicator = { casStatus & 0b00000100 }, "CAS: Ready Mode", "CAS: Ready Mode", white, black, blue, black
indicator = { casStatus & 0b00001000 }, "CAS: Launch Mode", "CAS: Launch Mode", white, black, blue, black
indicator = { casStatus & 0b00010000 }, "CAS: Ramp Mode", "CAS: Ramp Mode", white, black, blue, black
indicator = { casStatus & 0b00100000 }, "CAS: Table Mode", "CAS: Table Mode", white, black, blue, black


;-------------------------------------------------------------------------------
[ControllerCommands] 
   
   ;[cmd][canid][TABLE] [offset H][offset L] [size H][size L] [byte1][byte 2][byte 3][byte 4][byte 5]
   
   
   cmdStartLearn = "w\$tsCanId\x07\x00\x00\x00\x05\x01\x00\x00\x00\x00"     
   cmdStopLearn =  "w\$tsCanId\x07\x00\x00\x00\x05\x02\x00\x00\x00\x00"   
   
   cmdPedalLearnTop = 		"w\$tsCanId\x07\x00\x00\x00\x05\x00\x01\x00\x00\x00"     
   cmdPedalLearnBottom =  	"w\$tsCanId\x07\x00\x00\x00\x05\x00\x02\x00\x00\x00"
   
   cmdPauseMajorAlarms = "w\$tsCanId\x07\x00\x00\x00\x05\x00\x00\x01\x00\x00" 
   
;-------------------------------------------------------------------------------
;Displayed Values I.E. Gauges. -- HEADER TYPE: MSG_REQ
[OutputChannels]  

   deadValue        = { 0 } ; Convenient unchanging value.

   ochGetCommand    = "r\$tsCanId\x07%2o%2c"   

   ochBlockSize     = 157  ;//This value has to match the last octet of the ocgGetCommand Chain


	gAlarms0			= scalar,	U16, 	0,	"",	1,	0
	procAlarms0			= scalar,	U16, 	2,	"",	1,	0
	hardwareAlarms0		= scalar,	U16, 	4,	"",	1,	0	
	pedalAlarms1		= scalar,	U08, 	6,	"",	1,	0  
	pedalAlarms2		= scalar,	U08, 	7,	"",	1,	0  
	tpsAlarms1			= scalar,	U08, 	8,	"",	1,	0   
	tpsAlarms2			= scalar,	U08, 	9,	"",	1,	0   
	calFlags			= scalar,	U08, 	10,	"",	1,	0  
	calStat				= scalar,	U08, 	11,	"",	1,	0  
	canStat				= scalar,	U16, 	12,	"",	1,	0   
	kPcalc				= scalar,	S32,	14,	"",	1,	0
	kIcalc				= scalar,	S32,	18,	"",	1,	0
	kDcalc				= scalar,	S32,	22,	"",	1,	0

	closedPWM		= scalar, 	U16, 	26,	"",	1,	0
	movingClosedPWM	= scalar, 	U16, 	28,	"",	1,	0
	movingOpenPWM	= scalar, 	U16, 	30,	"",	1,	0
	openedPWM		= scalar, 	U16, 	32,	"",	1,	0
	
	pedal1MinADC		= scalar, 	U16, 	34,	"",	1,	0
	pedal1MaxADC		= scalar, 	U16, 	36,	"",	1,	0
	pedal2MinADC		= scalar, 	U16, 	38,	"",	1,	0
	pedal2MaxADC		= scalar, 	U16, 	40,	"",	1,	0
	pedal1				= scalar, 	U16, 	42,	"",	1,	0
	pedal2				= scalar, 	U16, 	44,	"",	1,	0
	normalizedPedal1	= scalar,	S16,	48,	"",	1,	0
	normalizedPedal2	= scalar,	S16,	50,	"",	1,	0

	tps1MinADC		= scalar, 	U16, 	52,	"",	1,	0
	tps1RestADC		= scalar, 	U16, 	54,	"",	1,	0
	tps1MaxADC		= scalar, 	U16, 	56,	"",	1,	0
	tps2MinADC		= scalar, 	U16, 	58,	"",	1,	0
	tps2RestADC		= scalar, 	U16, 	60,	"",	1,	0
	tps2MaxADC		= scalar, 	U16, 	62,	"",	1,	0
	tps1		= scalar, 	U16, 	64,	"",	1,	0
	tps2		= scalar, 	U16, 	66,	"",	1,	0
	normalizedtps1	= scalar,	S16,	70,	"",	1,	0
	normalizedtps2	= scalar,	S16,	72,	"",	1,	0
	
	pwmDC		= scalar, 	U16, 	74,	"",	1,	0
	normalizedIdleTarget	= scalar, 	U16, 	76,	"",	1,	0
	iSupply	= scalar, 	U16, 	78,	"",	1,	0

	vcc1		= scalar, 	U16, 	80,	"",	1.000,	0.0
	vcc2		= scalar, 	U16, 	82,	"",	1.000,	0.0
	batt		= scalar, 	U16, 	84,	"",	1.000,	0.0
	
	gConfigAlarms = scalar, 	U16, 	86,	"",	1.000,	0.0
	diStatus	  = scalar,		U08, 	88,	"",	1,	0 
	blipStatus	  = scalar,		U08, 	89,	"",	1,	0 
	casStatus	  = scalar,		U08, 	90,	"",	1,	0 
	dbwStatus	  = scalar,		U08, 	91,	"",	1,	0 
	wdTimer 	 	= scalar,	U32,	118,	"",	1,	0
	freeTime	= scalar,	U32,	122,	"",	1,	0
	loopTime	= scalar,	U16,	126,	"",	1,	0 
	rpm	= scalar, 	U16, 	132,	"",	1,	0

	CANIdleTarg	= scalar, 	U16, 	134,	"",	1,	0
	CANrpm		= scalar, 	U16, 	136,	"",	1,	0
	CANgear		= scalar, 	U08, 	138,	"",	1,	0
	CANvss		= scalar, 	U16, 	139,	"",	1,	0
	
	controlTarget	= scalar, 	U16, 	141,	"",	1,	0	;The actual target that the position controller is currently using
	controlPosition	= scalar, 	U16, 	143,	"",	1,	0	;The actual position that the position controller is currently using
	controlError = scalar, 	S16, 	145,	"",	1,	0 	

	tpsoutpos = {(controlPosition-400)/32}

	test 		= scalar, 	U32, 	153,	"",	1,	0

	iSupplyAmps = {(iSupply/4095)*12.5}

	pedal1ADC= {pedal1}
	pedal2ADC= {pedal2}

	tps1ADC	= {tps1}
	tps2ADC	= {tps2}


	pwmDC_ADC = {pwmDC}
	pwmDC_Percent = {(pwmDC / 1600) * 100}


	NORMALIZEDADCMIN = {400}
	NORMALIZEDADCMAX = {3600}


	CANIdleTargADC = {(CANIdleTarg)}; * 1024) / 4096}

	vcc1Volts = {vcc1 * (10 / 4095)}
	vcc2Volts = {vcc2 * (10 / 4095)}
	battVolts = {batt * (30.5 / 4095)}

	normalizedPedal1ADC = {normalizedPedal1}
	normalizedPedal2ADC = {normalizedPedal2}
	normalizedPedal1Percent = {((normalizedPedal1 - NORMALIZEDADCMIN) / (NORMALIZEDADCMAX - NORMALIZEDADCMIN)) * 100}
	normalizedPedal2Percent = {((normalizedPedal2 - NORMALIZEDADCMIN) / (NORMALIZEDADCMAX - NORMALIZEDADCMIN)) * 100}
	pedalDiffPercent = {abs(normalizedPedal2Percent - normalizedPedal1Percent)} 

	normalizedtps1ADC = {normalizedtps1}
	normalizedtps2ADC = {normalizedtps2}
	normalizedtps1Percent = {((normalizedtps1- NORMALIZEDADCMIN) / (NORMALIZEDADCMAX - NORMALIZEDADCMIN)) * 100}
	normalizedtps2Percent = {((normalizedtps2- NORMALIZEDADCMIN) / (NORMALIZEDADCMAX - NORMALIZEDADCMIN)) * 100}
	tpsDiffPercent = {abs(normalizedtps2Percent - normalizedtps1Percent)} 

	normalizedIdleTargetPerc = {((normalizedIdleTarget - NORMALIZEDADCMIN) / (NORMALIZEDADCMAX - NORMALIZEDADCMIN)) * 100}

	t_loop = {loopTime * 0.015625}

conInput = {0}
;-----------------------------------------
;--  The entries are saved in the datalog file in the order in which they     --
;--  appear in the list below.                                                --
;--                                                                           --
;--   Channel - Case sensitive name of output channel to be logged.           --
;--   Label   - String written to header line of log.                       --
;--   Type    - Data type of output, converted before writing.                --
;--   Format  - C-style output format of data.                                --

[Datalog]
	entry = pedal1ADC,					"Pedal 1 Raw ADC",			int,	"%d"
	entry = pedal2ADC,					"Pedal 2 Raw ADC",			int,	"%d"
	entry = pedalDiffPercent,			"Pedal Diff %",				int,	"%d"
	entry = normalizedPedal1ADC,		"Pedal 1 Normalized ADC",	int,	"%d"
	entry = normalizedPedal1Percent,	"Pedal 1 %",				int,	"%d"
	entry = normalizedPedal2ADC,		"Pedal 2 Normalized ADC",	int,	"%d"
	entry = normalizedPedal2Percent,	"Pedal 2 %",				int,	"%d"

	entry = tps1ADC	,	"TPS 1 Raw ADC"	,	int	,	"%d"
	entry = tps2ADC	,	"TPS 2 Raw ADC"	,	int	,	"%d"
	entry = tpsDiffPercent	,	"TPS Diff %"	,	int	,	"%d"
	entry = normalizedtps1ADC	,	"TPS 1 Normalized ADC",int  ,	"%d"
	entry = normalizedtps1Percent	,"TPS 1 %",int	,	"%d"
	entry = normalizedtps2ADC	,	"TPS 2 Normalized ADC",int	,	"%d"
	entry = normalizedtps2Percent	,"TPS 2 %",int	,	"%d"
	
	diagPedal1MinADC 	= pedal1MinADC,	"Cal: Pedal 1 Min ADC", int	,	"%d"
	diagPedal1MaxADC 	= pedal1MaxADC,	"Cal: Pedal 1 Max ADC", int	,	"%d"

	diagPedal2MinADC 	= pedal2MinADC,	"Cal: Pedal 2 Min ADC", int	,	"%d"
	diagPedal2MaxADC 	= pedal2MaxADC,	"Cal: Pedal 2 Max ADC", int	,	"%d"


	diagTPS1MinADC 		= tps1MinADC,	"Cal: TPS 1 Min ADC", int	,	"%d"
	diagTPS1RestADC 	= tps1RestADC,	"Cal: TPS 1 Rest ADC", int	,	"%d"
	diagTPS1MaxADC 		= tps1MaxADC,	"Cal: TPS 1 Max ADC", int	,	"%d"

	diagTPS2MinADC 		= tps2MinADC,	"Cal: TPS 2 Min ADC", int	,	"%d"
	diagTPS2RestADC 	= tps2RestADC,	"Cal: TPS 2 Rest ADC", int	,	"%d"
	diagTPS2MaxADC 		= tps2MaxADC,	"Cal: TPS 2 Max ADC", int	,	"%d"
	
	entry = normalizedIdleTarget	,"Idle Target Normalized ADC",int	,	"%d"
	entry = normalizedIdleTargetPerc	,"Idle Target %",int	,	"%d"

	entry = pwmDC_ADC	,	"Throttle Duty Cycle ADC"	,	int	,	"%d"
	entry = pwmDC_Percent,  "Throttle Duty Cycle %" ,  int ,   "%d"
	
	entry = vcc1Volts	,	"Power: I/O Ref 1 Volts"		,	int	,	"%d"	
	entry = vcc2Volts	,	"Power: I/O Ref 2 Volts"		,	int	,	"%d"	
	entry = battVolts	,	"Power: Battery Voltage"		,	int	,	"%d"	
	entry = iSupplyAmps,	"Power: Supply Current", int, %d

	entry = freeTime	,	"Time: Free Running Timer",	int	,	"%d"
	entry = t_loop	,	"Time: Loop Timer",	int	,	"%d"
	entry = wdTimer	,	"Time: Watchdog Timer",	int	,	"%d"
	
	entry = rpm,		"RPM",	int	,	"%d"
	
	entry = CANrpm	,	"CAN: RPM",	int	,	"%d"
	entry = CANgear	,	"CAN: Gear",	int	,	"%d"
	entry = CANvss ,	"CAN: VSS",	int	,	"%d"
	entry = CANIdleTarg	,	"CAN: Idle Target",	int	,	"%d"	
	
	entry = controlTarget, 	"PID: Control Target",	,	int	,	"%d"
	entry = controlPosition, "PID: Control Position",	,	int	,	"%d"
	entry = controlError, 	"PID: Control Error",	,	int	,	"%d" 

	entry = kPcalc, "PID: Calculated P coeff",	,	int	,	"%d"
	entry = kIcalc, "PID: Calculated I coeff",	,	int	,	"%d"
	entry = kDcalc, "PID: Calculated D coeff",	,	int	,	"%d"	
	
	entry = test 		,	"test"		, 	int	,	"%d"			
				
	entry = pedalAlarms1	,	"Status: Pedal 1 Word",	int	,	"%d"
	entry = pedalAlarms2	,	"Status: Pedal 2 Word",	int	,	"%d"
	entry = tpsAlarms1	,	"Status: TPS 1 Word",	int	,	"%d"
	entry = tpsAlarms2	,	"Status: TPS 2 Word",	int	,	"%d"	
		
	entry = procAlarms0, "Status: Processor Word" ,	int	,	"%d"
	entry = gAlarms0, "Status: System Word" ,	int	,	"%d"
	entry = hardwareAlarms0, "Status: Hardware Word" ,	int	,	"%d"
	entry = canStat, "Status: CAN Word" ,	int	,	"%d"
	
	entry = blipStatus , "Status: Blip", int, "%d"	
	
	entry = dbwStatus , "Status: DBW", int, %d
	
	entry = casStatus , "Status: CAS", int, %d
	
[NOTES]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
