diff --git a/G940LEDControl/Forms/MainFrm.dfm b/G940LEDControl/Forms/MainFrm.dfm index ea9ac7a..f69ef25 100644 --- a/G940LEDControl/Forms/MainFrm.dfm +++ b/G940LEDControl/Forms/MainFrm.dfm @@ -28,7 +28,7 @@ object MainForm: TMainForm Margins.Top = 8 Margins.Right = 8 Margins.Bottom = 8 - ActivePage = tsAbout + ActivePage = tsFSX Align = alClient TabOrder = 1 object tsFSX: TTabSheet @@ -275,6 +275,10 @@ object MainForm: TMainForm Caption = 'Extra' ImageIndex = 1 TabVisible = False + ExplicitLeft = 0 + ExplicitTop = 0 + ExplicitWidth = 0 + ExplicitHeight = 0 object GroupBox1: TGroupBox AlignWithMargins = True Left = 6 @@ -438,7 +442,6 @@ object MainForm: TMainForm object tsAbout: TTabSheet Caption = 'About' ImageIndex = 1 - ExplicitLeft = 12 object lblVersionCaption: TLabel Left = 16 Top = 67 diff --git a/G940LEDControl/G940LEDControl.dproj b/G940LEDControl/G940LEDControl.dproj index 4edf5e7..6346c56 100644 --- a/G940LEDControl/G940LEDControl.dproj +++ b/G940LEDControl/G940LEDControl.dproj @@ -81,9 +81,8 @@ RELEASE;$(DCC_Define) - 1 - 3 - CompanyName=X²Software;FileDescription=G940 LED Control;FileVersion=0.3.1.0;InternalName=;LegalCopyright=© 2011 X²Software;LegalTrademarks=;OriginalFilename=G940LEDControl.exe;ProductName=G940 LED Control;ProductVersion=0.3;Comments= + 4 + CompanyName=X²Software;FileDescription=G940 LED Control;FileVersion=0.4.0.0;InternalName=;LegalCopyright=© 2011 X²Software;LegalTrademarks=;OriginalFilename=G940LEDControl.exe;ProductName=G940 LED Control;ProductVersion=0.4;Comments= 1033 $(BDS)\bin\default_app.manifest diff --git a/G940LEDControl/G940LEDControl.res b/G940LEDControl/G940LEDControl.res index e8d7e2c..2f3e5fd 100644 Binary files a/G940LEDControl/G940LEDControl.res and b/G940LEDControl/G940LEDControl.res differ diff --git a/G940LEDControl/Units/FSXLEDStateProvider.pas b/G940LEDControl/Units/FSXLEDStateProvider.pas index 871779d..7ef0c4e 100644 --- a/G940LEDControl/Units/FSXLEDStateProvider.pas +++ b/G940LEDControl/Units/FSXLEDStateProvider.pas @@ -31,6 +31,11 @@ const FUNCTION_FSX_SPOILERS = FUNCTION_PROVIDER_OFFSET + 13; + FUNCTION_FSX_PRESSURIZATIONDUMPSWITCH = FUNCTION_PROVIDER_OFFSET + 14; + FUNCTION_FSX_CARBHEAT = FUNCTION_PROVIDER_OFFSET + 15; + FUNCTION_FSX_AUTOPILOT = FUNCTION_PROVIDER_OFFSET + 16; + FUNCTION_FSX_FUELPUMP = FUNCTION_PROVIDER_OFFSET + 17; + type TFSXLEDStateProvider = class(TLEDStateProvider) @@ -97,27 +102,6 @@ const EVENT_ZOOM = 10; - FSX_VARIABLE_ISGEARRETRACTABLE = 'IS GEAR RETRACTABLE'; - FSX_VARIABLE_GEARTOTALPCTEXTENDED = 'GEAR TOTAL PCT EXTENDED'; - FSX_VARIABLE_LIGHTONSTATES = 'LIGHT ON STATES'; - FSX_VARIABLE_PARKINGBRAKE = 'BRAKE PARKING INDICATOR'; - FSX_VARIABLE_NUMBEROFENGINES = 'NUMBER OF ENGINES'; - FSX_VARIABLE_ENGCOMBUSTION = 'GENERAL ENG COMBUSTION:%d'; - FSX_VARIABLE_ENGFAILED = 'ENG FAILED:%d'; - FSX_VARIABLE_ENGONFIRE = 'ENG ON FIRE:%d'; - FSX_VARIABLE_ENGTHROTTLELEVERPOS = 'GENERAL ENG THROTTLE LEVER POSITION:%d'; - FSX_VARIABLE_GEARDAMAGEBYSPEED = 'GEAR DAMAGE BY SPEED'; - FSX_VARIABLE_GEARSPEEDEXCEEDED = 'GEAR SPEED EXCEEDED'; - FSX_VARIABLE_CANOPYOPEN = 'CANOPY OPEN'; - FSX_VARIABLE_FLAPSAVAILABLE = 'FLAPS AVAILABLE'; - FSX_VARIABLE_FLAPSHANDLEPERCENT = 'FLAPS HANDLE PERCENT'; - FSX_VARIABLE_AVIONICSMASTERSWITCH = 'AVIONICS MASTER SWITCH'; - FSX_VARIABLE_ELECTRICALMASTERBATTERY = 'ELECTRICAL MASTER BATTERY'; - FSX_VARIABLE_SPOILERSAVAILABLE = 'SPOILER AVAILABLE'; - FSX_VARIABLE_SPOILERSHANDLEPOSITION = 'SPOILERS HANDLE POSITION'; - - - FSX_UNIT_PERCENT = 'percent'; FSX_UNIT_MASK = 'mask'; FSX_UNIT_BOOL = 'bool'; @@ -131,23 +115,6 @@ const FSX_LIGHTON_CABIN = $0200; - CATEGORY_DYNAMIC = 'Dynamic'; - FUNCTION_DESC_FSX_ENGINE = 'Engine'; - FUNCTION_DESC_FSX_INSTRUMENTLIGHTS = 'Instrument lights'; - FUNCTION_DESC_FSX_GEAR = 'Landing gear'; - FUNCTION_DESC_FSX_LANDINGLIGHTS = 'Landing lights'; - FUNCTION_DESC_FSX_PARKINGBRAKE = 'Parking brake'; - - FUNCTION_DESC_FSX_EXITDOOR = 'Exit door'; - FUNCTION_DESC_FSX_STROBELIGHTS = 'Strobe lights'; - FUNCTION_DESC_FSX_NAVLIGHTS = 'Nav lights'; - FUNCTION_DESC_FSX_BEACONLIGHTS = 'Beacon lights'; - FUNCTION_DESC_FSX_FLAPS = 'Flaps'; - FUNCTION_DESC_FSX_BATTERYMASTER = 'Battery master switch'; - FUNCTION_DESC_FSX_AVIONICSMASTER = 'Avionics master switch'; - - FUNCTION_DESC_FSX_SPOILERS = 'Spoilers (air brake)'; - type TThrottleData = packed record NumberOfEngines: Integer; @@ -161,22 +128,25 @@ class procedure TFSXLEDStateProvider.EnumFunctions(AConsumer: IFunctionConsumer) begin inherited; - AConsumer.SetCategory(CATEGORY_DYNAMIC); - AConsumer.AddFunction(FUNCTION_FSX_ENGINE, FUNCTION_DESC_FSX_ENGINE); - AConsumer.AddFunction(FUNCTION_FSX_INSTRUMENTLIGHTS, FUNCTION_DESC_FSX_INSTRUMENTLIGHTS); - AConsumer.AddFunction(FUNCTION_FSX_GEAR, FUNCTION_DESC_FSX_GEAR); - AConsumer.AddFunction(FUNCTION_FSX_LANDINGLIGHTS, FUNCTION_DESC_FSX_LANDINGLIGHTS); - AConsumer.AddFunction(FUNCTION_FSX_PARKINGBRAKE, FUNCTION_DESC_FSX_PARKINGBRAKE); + AConsumer.SetCategory('Dynamic'); - AConsumer.AddFunction(FUNCTION_FSX_EXITDOOR, FUNCTION_DESC_FSX_EXITDOOR); - AConsumer.AddFunction(FUNCTION_FSX_STROBELIGHTS, FUNCTION_DESC_FSX_STROBELIGHTS); - AConsumer.AddFunction(FUNCTION_FSX_NAVLIGHTS, FUNCTION_DESC_FSX_NAVLIGHTS); - AConsumer.AddFunction(FUNCTION_FSX_BEACONLIGHTS, FUNCTION_DESC_FSX_BEACONLIGHTS); - AConsumer.AddFunction(FUNCTION_FSX_FLAPS, FUNCTION_DESC_FSX_FLAPS); - AConsumer.AddFunction(FUNCTION_FSX_BATTERYMASTER, FUNCTION_DESC_FSX_BATTERYMASTER); - AConsumer.AddFunction(FUNCTION_FSX_AVIONICSMASTER, FUNCTION_DESC_FSX_AVIONICSMASTER); - - AConsumer.AddFunction(FUNCTION_FSX_SPOILERS, FUNCTION_DESC_FSX_SPOILERS); + AConsumer.AddFunction(FUNCTION_FSX_AUTOPILOT, 'Auto pilot (main)'); + AConsumer.AddFunction(FUNCTION_FSX_AVIONICSMASTER, 'Avionics master switch'); + AConsumer.AddFunction(FUNCTION_FSX_BATTERYMASTER, 'Battery master switch'); + AConsumer.AddFunction(FUNCTION_FSX_BEACONLIGHTS, 'Beacon lights'); +// AConsumer.AddFunction(FUNCTION_FSX_CARBHEAT, 'Carburator heat / anti-ice'); + AConsumer.AddFunction(FUNCTION_FSX_ENGINE, 'Engine'); + AConsumer.AddFunction(FUNCTION_FSX_EXITDOOR, 'Exit door'); + AConsumer.AddFunction(FUNCTION_FSX_FLAPS, 'Flaps'); +// AConsumer.AddFunction(FUNCTION_FSX_FUELPUMP, 'Fuel boost pump'); + AConsumer.AddFunction(FUNCTION_FSX_GEAR, 'Landing gear'); + AConsumer.AddFunction(FUNCTION_FSX_INSTRUMENTLIGHTS, 'Instrument lights'); + AConsumer.AddFunction(FUNCTION_FSX_LANDINGLIGHTS, 'Landing lights'); + AConsumer.AddFunction(FUNCTION_FSX_NAVLIGHTS, 'Nav lights'); + AConsumer.AddFunction(FUNCTION_FSX_PARKINGBRAKE, 'Parking brake'); + AConsumer.AddFunction(FUNCTION_FSX_PRESSURIZATIONDUMPSWITCH, 'Pressurization dump switch'); + AConsumer.AddFunction(FUNCTION_FSX_SPOILERS, 'Spoilers (air brake)'); + AConsumer.AddFunction(FUNCTION_FSX_STROBELIGHTS, 'Strobe lights'); end; @@ -267,44 +237,42 @@ begin { Gear } if Consumer.FunctionMap.HasFunction(FUNCTION_FSX_GEAR) then begin - AddVariable(DEFINITION_GEAR, FSX_VARIABLE_ISGEARRETRACTABLE, FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); - AddVariable(DEFINITION_GEAR, FSX_VARIABLE_GEARTOTALPCTEXTENDED, FSX_UNIT_PERCENT, SIMCONNECT_DATAType_FLOAT64); - AddVariable(DEFINITION_GEAR, FSX_VARIABLE_GEARDAMAGEBYSPEED, FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); - AddVariable(DEFINITION_GEAR, FSX_VARIABLE_GEARSPEEDEXCEEDED, FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); + AddVariable(DEFINITION_GEAR, 'IS GEAR RETRACTABLE', FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); + AddVariable(DEFINITION_GEAR, 'GEAR TOTAL PCT EXTENDED', FSX_UNIT_PERCENT, SIMCONNECT_DATAType_FLOAT64); + AddVariable(DEFINITION_GEAR, 'GEAR DAMAGE BY SPEED', FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); + AddVariable(DEFINITION_GEAR, 'GEAR SPEED EXCEEDED', FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); AddDefinition(DEFINITION_GEAR); end; { Lights } - if Consumer.FunctionMap.HasFunction(FUNCTION_FSX_LANDINGLIGHTS) or - Consumer.FunctionMap.HasFunction(FUNCTION_FSX_INSTRUMENTLIGHTS) or - Consumer.FunctionMap.HasFunction(FUNCTION_FSX_STROBELIGHTS) or - Consumer.FunctionMap.HasFunction(FUNCTION_FSX_NAVLIGHTS) or - Consumer.FunctionMap.HasFunction(FUNCTION_FSX_BEACONLIGHTS) then + if Consumer.FunctionMap.HasFunction([FUNCTION_FSX_LANDINGLIGHTS, FUNCTION_FSX_INSTRUMENTLIGHTS, + FUNCTION_FSX_STROBELIGHTS, FUNCTION_FSX_NAVLIGHTS, + FUNCTION_FSX_BEACONLIGHTS]) then begin - AddVariable(DEFINITION_LIGHTS, FSX_VARIABLE_LIGHTONSTATES, FSX_UNIT_MASK, SIMCONNECT_DATATYPE_INT32); + AddVariable(DEFINITION_LIGHTS, 'LIGHT ON STATES', FSX_UNIT_MASK, SIMCONNECT_DATATYPE_INT32); AddDefinition(DEFINITION_LIGHTS); end; { Parking brake } if Consumer.FunctionMap.HasFunction(FUNCTION_FSX_PARKINGBRAKE) then begin - AddVariable(DEFINITION_PARKINGBRAKE, FSX_VARIABLE_PARKINGBRAKE, FSX_UNIT_BOOL, SIMCONNECT_DATATYPE_INT32); + AddVariable(DEFINITION_PARKINGBRAKE, 'BRAKE PARKING INDICATOR', FSX_UNIT_BOOL, SIMCONNECT_DATATYPE_INT32); AddDefinition(DEFINITION_PARKINGBRAKE); end; { Engine } if Consumer.FunctionMap.HasFunction(FUNCTION_FSX_ENGINE) then begin - AddVariable(DEFINITION_ENGINE, FSX_VARIABLE_NUMBEROFENGINES, FSX_UNIT_NUMBER, SIMCONNECT_DATAType_INT32); + AddVariable(DEFINITION_ENGINE, 'NUMBER OF ENGINES', FSX_UNIT_NUMBER, SIMCONNECT_DATAType_INT32); for engineIndex := 1 to MAX_ENGINES do - AddVariable(DEFINITION_ENGINE, Format(FSX_VARIABLE_ENGCOMBUSTION, [engineIndex]), FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); + AddVariable(DEFINITION_ENGINE, Format('GENERAL ENG COMBUSTION:%d', [engineIndex]), FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); for engineIndex := 1 to MAX_ENGINES do - AddVariable(DEFINITION_ENGINE, Format(FSX_VARIABLE_ENGFAILED, [engineIndex]), FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); + AddVariable(DEFINITION_ENGINE, Format('ENG FAILED:%d', [engineIndex]), FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); for engineIndex := 1 to MAX_ENGINES do - AddVariable(DEFINITION_ENGINE, Format(FSX_VARIABLE_ENGONFIRE, [engineIndex]), FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); + AddVariable(DEFINITION_ENGINE, Format('ENG ON FIRE:%d', [engineIndex]), FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); AddDefinition(DEFINITION_ENGINE); end; @@ -312,27 +280,34 @@ begin { Exit door } if Consumer.FunctionMap.HasFunction(FUNCTION_FSX_EXITDOOR) then begin - AddVariable(DEFINITION_EXITDOOR, FSX_VARIABLE_CANOPYOPEN, FSX_UNIT_PERCENT, SIMCONNECT_DATAType_FLOAT64); + AddVariable(DEFINITION_EXITDOOR, 'CANOPY OPEN', FSX_UNIT_PERCENT, SIMCONNECT_DATAType_FLOAT64); AddDefinition(DEFINITION_EXITDOOR); end; { Flaps & spoilers } - if Consumer.FunctionMap.HasFunction(FUNCTION_FSX_FLAPS) or - Consumer.FunctionMap.HasFunction(FUNCTION_FSX_SPOILERS) then + if Consumer.FunctionMap.HasFunction([FUNCTION_FSX_FLAPS, FUNCTION_FSX_SPOILERS]) then begin - AddVariable(DEFINITION_FLAPSSPOILERS, FSX_VARIABLE_FLAPSAVAILABLE, FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); - AddVariable(DEFINITION_FLAPSSPOILERS, FSX_VARIABLE_FLAPSHANDLEPERCENT, FSX_UNIT_PERCENT, SIMCONNECT_DATAType_FLOAT64); - AddVariable(DEFINITION_FLAPSSPOILERS, FSX_VARIABLE_SPOILERSAVAILABLE, FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); - AddVariable(DEFINITION_FLAPSSPOILERS, FSX_VARIABLE_SPOILERSHANDLEPOSITION, FSX_UNIT_PERCENT, SIMCONNECT_DATAType_FLOAT64); + AddVariable(DEFINITION_FLAPSSPOILERS, 'FLAPS AVAILABLE', FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); + AddVariable(DEFINITION_FLAPSSPOILERS, 'FLAPS HANDLE PERCENT', FSX_UNIT_PERCENT, SIMCONNECT_DATAType_FLOAT64); + AddVariable(DEFINITION_FLAPSSPOILERS, 'SPOILER AVAILABLE', FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); + AddVariable(DEFINITION_FLAPSSPOILERS, 'SPOILERS HANDLE POSITION', FSX_UNIT_PERCENT, SIMCONNECT_DATAType_FLOAT64); AddDefinition(DEFINITION_FLAPSSPOILERS); end; { Master switches } - if Consumer.FunctionMap.HasFunction(FUNCTION_FSX_BATTERYMASTER) or - Consumer.FunctionMap.HasFunction(FUNCTION_FSX_AVIONICSMASTER) then + if Consumer.FunctionMap.HasFunction([FUNCTION_FSX_BATTERYMASTER, FUNCTION_FSX_AVIONICSMASTER, + FUNCTION_FSX_PRESSURIZATIONDUMPSWITCH, FUNCTION_FSX_CARBHEAT, + FUNCTION_FSX_AUTOPILOT, FUNCTION_FSX_FUELPUMP]) then begin - AddVariable(DEFINITION_SWITCHES, FSX_VARIABLE_AVIONICSMASTERSWITCH, FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); - AddVariable(DEFINITION_SWITCHES, FSX_VARIABLE_ELECTRICALMASTERBATTERY, FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); + AddVariable(DEFINITION_SWITCHES, 'AVIONICS MASTER SWITCH', FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); + AddVariable(DEFINITION_SWITCHES, 'ELECTRICAL MASTER BATTERY', FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); + AddVariable(DEFINITION_SWITCHES, 'PRESSURIZATION DUMP SWITCH', FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); +// AddVariable(DEFINITION_SWITCHES, 'CARB HEAT AVAILABLE', FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); +// AddVariable(DEFINITION_SWITCHES, 'PANEL ANTI ICE SWITCH', FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); + AddVariable(DEFINITION_SWITCHES, 'AUTOPILOT AVAILABLE', FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); + AddVariable(DEFINITION_SWITCHES, 'AUTOPILOT MASTER', FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); +// AddVariable(DEFINITION_SWITCHES, 'fuel pump?', FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); + AddDefinition(DEFINITION_SWITCHES); end; @@ -567,11 +542,19 @@ end; procedure TFSXLEDStateProvider.HandleSwitchesData(AData: Pointer); +const + ONOFF_STATE: array[Boolean] of TLEDState = (lsRed, lsGreen); + type PSwitchesData = ^TSwitchesData; TSwitchesData = packed record AvionicsSwitch: Cardinal; BatterySwitch: Cardinal; + PressurizationDumpSwitch: Cardinal; +// CarbHeatAvailable: Cardinal; +// AntiIceSwitch: Cardinal; + AutoPilotAvailable: Cardinal; + AutoPilotMaster: Cardinal; end; var @@ -580,15 +563,19 @@ var begin switchesData := AData; - if switchesData^.AvionicsSwitch <> 0 then - Consumer.SetStateByFunction(FUNCTION_FSX_AVIONICSMASTER, lsGreen) - else - Consumer.SetStateByFunction(FUNCTION_FSX_AVIONICSMASTER, lsRed); + Consumer.SetStateByFunction(FUNCTION_FSX_AVIONICSMASTER, ONOFF_STATE[switchesData^.AvionicsSwitch <> 0]); + Consumer.SetStateByFunction(FUNCTION_FSX_BATTERYMASTER, ONOFF_STATE[switchesData^.BatterySwitch <> 0]); + Consumer.SetStateByFunction(FUNCTION_FSX_PRESSURIZATIONDUMPSWITCH, ONOFF_STATE[switchesData^.PressurizationDumpSwitch <> 0]); - if switchesData^.BatterySwitch <> 0 then - Consumer.SetStateByFunction(FUNCTION_FSX_BATTERYMASTER, lsGreen) +// if switchesData^.CarbHeatAvailable <> 0 then +// Consumer.SetStateByFunction(FUNCTION_FSX_CARBHEAT, ONOFF_STATE[switchesData^.AntiIceSwitch <> 0]) +// else +// Consumer.SetStateByFunction(FUNCTION_FSX_CARBHEAT, lsOff); + + if switchesData^.AutoPilotAvailable <> 0 then + Consumer.SetStateByFunction(FUNCTION_FSX_AUTOPILOT, ONOFF_STATE[switchesData^.AutoPilotMaster <> 0]) else - Consumer.SetStateByFunction(FUNCTION_FSX_BATTERYMASTER, lsRed); + Consumer.SetStateByFunction(FUNCTION_FSX_AUTOPILOT, lsOff); end; diff --git a/G940LEDControl/Units/LEDFunctionMap.pas b/G940LEDControl/Units/LEDFunctionMap.pas index 3d9dd83..2b68e7a 100644 --- a/G940LEDControl/Units/LEDFunctionMap.pas +++ b/G940LEDControl/Units/LEDFunctionMap.pas @@ -25,7 +25,8 @@ type procedure SetFunction(ALEDIndex, AFunction: Integer); function GetFunction(ALEDIndex: Integer): Integer; - function HasFunction(AFunction: Integer): Boolean; + function HasFunction(AFunction: Integer): Boolean; overload; + function HasFunction(AFunctions: array of Integer): Boolean; overload; function FindFirst(AFunction: Integer; out ALEDIndex: Integer): Boolean; function FindNext(AFunction: Integer; out ALEDIndex: Integer): Boolean; @@ -102,6 +103,21 @@ begin end; +function TLEDFunctionMap.HasFunction(AFunctions: array of Integer): Boolean; +var + functionNo: Integer; + +begin + Result := False; + + for functionNo in AFunctions do + begin + Result := HasFunction(functionNo); + if Result then + break; + end; +end; + function TLEDFunctionMap.HasFunction(AFunction: Integer): Boolean; var ledIndex: Integer;