diff --git a/G940LEDControl/Units/FSXLEDFunction.pas b/G940LEDControl/Units/FSXLEDFunction.pas index acf7aa6..1283ede 100644 --- a/G940LEDControl/Units/FSXLEDFunction.pas +++ b/G940LEDControl/Units/FSXLEDFunction.pas @@ -276,7 +276,10 @@ end; { TFSXFlapsFunction } procedure TFSXFlapsFunction.RegisterStates; begin - // #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXFlapsFunction.RegisterStates + RegisterState(TLEDState.Create(FSXStateUIDFlapsNotAvailable, FSXStateDisplayNameFlapsNotAvailable, lcOff)); + RegisterState(TLEDState.Create(FSXStateUIDFlapsRetracted, FSXStateDisplayNameFlapsRetracted, lcGreen)); + RegisterState(TLEDState.Create(FSXStateUIDFlapsBetween, FSXStateDisplayNameFlapsBetween, lcAmber)); + RegisterState(TLEDState.Create(FSXStateUIDFlapsExtended, FSXStateDisplayNameFlapsExtended, lcRed)); end; @@ -289,7 +292,10 @@ end; { TFSXSpoilersFunction } procedure TFSXSpoilersFunction.RegisterStates; begin - // #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXSpoilersFunction.RegisterStates + RegisterState(TLEDState.Create(FSXStateUIDSpoilersNotAvailable, FSXStateDisplayNameSpoilersNotAvailable, lcOff)); + RegisterState(TLEDState.Create(FSXStateUIDSpoilersRetracted, FSXStateDisplayNameSpoilersRetracted, lcGreen)); + RegisterState(TLEDState.Create(FSXStateUIDSpoilersBetween, FSXStateDisplayNameSpoilersBetween, lcAmber)); + RegisterState(TLEDState.Create(FSXStateUIDSpoilersExtended, FSXStateDisplayNameSpoilersExtended, lcRed)); end; diff --git a/G940LEDControl/Units/FSXLEDFunctionWorker.pas b/G940LEDControl/Units/FSXLEDFunctionWorker.pas index 7d97d89..711a298 100644 --- a/G940LEDControl/Units/FSXLEDFunctionWorker.pas +++ b/G940LEDControl/Units/FSXLEDFunctionWorker.pas @@ -316,39 +316,85 @@ end; { TFSXTailHookFunctionWorker } procedure TFSXTailHookFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition); begin - // #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXTailHookFunctionWorker.RegisterVariables + ADefinition.AddVariable('TAILHOOK POSITION', FSX_UNIT_PERCENT, SIMCONNECT_DATAType_FLOAT64); end; procedure TFSXTailHookFunctionWorker.HandleData(AData: Pointer); begin - // #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXTailHookFunctionWorker.HandleData + case Trunc(PDouble(AData)^) of + 0..5: SetCurrentState(FSXStateUIDTailHookRetracted); + 95..100: SetCurrentState(FSXStateUIDTailHookBetween); + else SetCurrentState(FSXStateUIDTailHookExtended); + end; end; { TFSXFlapsFunctionWorker } procedure TFSXFlapsFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition); begin - // #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXFlapsFunctionWorker.RegisterVariables + ADefinition.AddVariable('FLAPS AVAILABLE', FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); + ADefinition.AddVariable('FLAPS HANDLE PERCENT', FSX_UNIT_PERCENT, SIMCONNECT_DATAType_FLOAT64); end; procedure TFSXFlapsFunctionWorker.HandleData(AData: Pointer); +type + PFlapsData = ^TFlapsData; + TFlapsData = packed record + FlapsAvailable: Cardinal; + FlapsHandlePercent: Double; + end; + +var + flapsData: PFlapsData; + begin - // #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXFlapsFunctionWorker.HandleData + flapsData := AData; + + if flapsData^.FlapsAvailable <> 0 then + begin + case Trunc(flapsData^.FlapsHandlePercent) of + 0..5: SetCurrentState(FSXStateUIDFlapsRetracted); + 95..100: SetCurrentState(FSXStateUIDFlapsExtended); + else SetCurrentState(FSXStateUIDFlapsBetween); + end; + end else + SetCurrentState(FSXStateUIDFlapsNotAvailable); end; { TFSXSpoilersFunctionWorker } procedure TFSXSpoilersFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition); begin - // #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXSpoilersFunctionWorker.RegisterVariables + ADefinition.AddVariable('SPOILER AVAILABLE', FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); + ADefinition.AddVariable('SPOILERS HANDLE POSITION', FSX_UNIT_PERCENT, SIMCONNECT_DATAType_FLOAT64); end; procedure TFSXSpoilersFunctionWorker.HandleData(AData: Pointer); +type + PSpoilersData = ^TSpoilersData; + TSpoilersData = packed record + SpoilersAvailable: Cardinal; + SpoilersHandlePercent: Double; + end; + +var + spoilersData: PSpoilersData; + begin - // #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXSpoilersFunctionWorker.HandleData + SpoilersData := AData; + + if SpoilersData^.SpoilersAvailable <> 0 then + begin + case Trunc(SpoilersData^.SpoilersHandlePercent) of + 0..5: SetCurrentState(FSXStateUIDSpoilersRetracted); + 95..100: SetCurrentState(FSXStateUIDSpoilersExtended); + else SetCurrentState(FSXStateUIDSpoilersBetween); + end; + end else + SetCurrentState(FSXStateUIDSpoilersNotAvailable); end; diff --git a/G940LEDControl/Units/FSXResources.pas b/G940LEDControl/Units/FSXResources.pas index f22919e..1e9a7c7 100644 --- a/G940LEDControl/Units/FSXResources.pas +++ b/G940LEDControl/Units/FSXResources.pas @@ -102,9 +102,31 @@ const FSXFunctionUIDFlaps = 'flaps'; FSXFunctionDisplayNameFlaps = 'Flaps'; + FSXStateUIDFlapsNotAvailable = 'notAvailable'; + FSXStateUIDFlapsRetracted = 'retracted'; + FSXStateUIDFlapsBetween = 'between'; + FSXStateUIDFlapsExtended = 'extended'; + + FSXStateDisplayNameFlapsNotAvailable = 'No flaps'; + FSXStateDisplayNameFlapsRetracted = 'Retracted'; + FSXStateDisplayNameFlapsBetween = 'Extending / retracting'; + FSXStateDisplayNameFlapsExtended = 'Extended'; + + FSXFunctionUIDSpoilers = 'spoilers'; FSXFunctionDisplayNameSpoilers = 'Spoilers'; + FSXStateUIDSpoilersNotAvailable = 'notAvailable'; + FSXStateUIDSpoilersRetracted = 'retracted'; + FSXStateUIDSpoilersBetween = 'between'; + FSXStateUIDSpoilersExtended = 'extended'; + + FSXStateDisplayNameSpoilersNotAvailable = 'No spoilers'; + FSXStateDisplayNameSpoilersRetracted = 'Retracted'; + FSXStateDisplayNameSpoilersBetween = 'Extending / retracting'; + FSXStateDisplayNameSpoilersExtended = 'Extended'; + + FSXFunctionUIDBatteryMaster = 'batteryMaster'; FSXFunctionDisplayNameBatteryMaster = 'Battery master';