From 6a1eca80688838381f6f7401076eaddb16047922 Mon Sep 17 00:00:00 2001 From: Mark van Renswoude Date: Sun, 16 Feb 2014 17:51:14 +0000 Subject: [PATCH 1/8] Released version 1.0.5 From f3257a15b84e992eebc7b3918b88e6e756bfa7d9 Mon Sep 17 00:00:00 2001 From: Mark van Renswoude Date: Wed, 2 Jul 2014 21:50:54 +0000 Subject: [PATCH 2/8] Branch for version 1.0.6 - adding fuel level support From b30d1ec59dc9ce9e5818002475ce6d58f8c5cda9 Mon Sep 17 00:00:00 2001 From: Mark van Renswoude Date: Wed, 2 Jul 2014 22:23:17 +0000 Subject: [PATCH 3/8] Added fuel level function --- G940LEDControl/Forms/ButtonFunctionFrm.dfm | 14 +++-- G940LEDControl/G940LEDControl.dproj | 8 +-- G940LEDControl/G940LEDControl.res | Bin 28524 -> 27828 bytes G940LEDControl/Units/FSXLEDFunction.pas | 37 ++++++++++++ .../Units/FSXLEDFunctionProvider.pas | 3 + G940LEDControl/Units/FSXLEDFunctionWorker.pas | 53 +++++++++++++++++- G940LEDControl/Units/FSXResources.pas | 26 +++++++++ 7 files changed, 130 insertions(+), 11 deletions(-) diff --git a/G940LEDControl/Forms/ButtonFunctionFrm.dfm b/G940LEDControl/Forms/ButtonFunctionFrm.dfm index a9f3300..ddbe85c 100644 --- a/G940LEDControl/Forms/ButtonFunctionFrm.dfm +++ b/G940LEDControl/Forms/ButtonFunctionFrm.dfm @@ -5,7 +5,7 @@ object ButtonFunctionForm: TButtonFunctionForm BorderIcons = [biSystemMenu] BorderStyle = bsDialog Caption = 'Configure button' - ClientHeight = 484 + ClientHeight = 561 ClientWidth = 692 Color = clBtnFace Font.Charset = DEFAULT_CHARSET @@ -31,7 +31,7 @@ object ButtonFunctionForm: TButtonFunctionForm object pnlButtons: TPanel AlignWithMargins = True Left = 0 - Top = 441 + Top = 518 Width = 692 Height = 43 Margins.Left = 0 @@ -41,6 +41,7 @@ object ButtonFunctionForm: TButtonFunctionForm Align = alBottom BevelOuter = bvNone TabOrder = 3 + ExplicitTop = 441 DesignSize = ( 692 43) @@ -80,7 +81,7 @@ object ButtonFunctionForm: TButtonFunctionForm Left = 8 Top = 60 Width = 257 - Height = 373 + Height = 450 Margins.Left = 8 Margins.Top = 8 Margins.Right = 0 @@ -103,6 +104,7 @@ object ButtonFunctionForm: TButtonFunctionForm OnGetText = vstFunctionsGetText OnPaintText = vstFunctionsPaintText OnIncrementalSearch = vstFunctionsIncrementalSearch + ExplicitHeight = 373 Columns = < item Position = 0 @@ -115,7 +117,7 @@ object ButtonFunctionForm: TButtonFunctionForm Left = 273 Top = 60 Width = 411 - Height = 373 + Height = 450 Margins.Left = 8 Margins.Top = 8 Margins.Right = 8 @@ -123,6 +125,7 @@ object ButtonFunctionForm: TButtonFunctionForm Align = alClient BevelOuter = bvNone TabOrder = 2 + ExplicitHeight = 373 object pnlName: TPanel Left = 0 Top = 0 @@ -190,10 +193,11 @@ object ButtonFunctionForm: TButtonFunctionForm Left = 0 Top = 97 Width = 411 - Height = 276 + Height = 353 Align = alClient BorderStyle = bsNone TabOrder = 1 + ExplicitHeight = 276 end end object pnlHeader: TPanel diff --git a/G940LEDControl/G940LEDControl.dproj b/G940LEDControl/G940LEDControl.dproj index c318d2e..813da3d 100644 --- a/G940LEDControl/G940LEDControl.dproj +++ b/G940LEDControl/G940LEDControl.dproj @@ -8,7 +8,7 @@ VCL 13.4 True - Release + Debug Win32 1 Application @@ -103,7 +103,7 @@ false CompanyName=;FileDescription=;FileVersion=0.2.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=0.2;Comments= - F:\Components\X2Utils\Resources\VistaManAsInvoker.manifest + $(BDS)\bin\default_app.manifest 1033 @@ -200,9 +200,7 @@ 1.0.0.0 - - ExpressPivotGrid 2 OLAP by Developer Express Inc. - + False diff --git a/G940LEDControl/G940LEDControl.res b/G940LEDControl/G940LEDControl.res index 906ddee2cba7b0ebdff29348afd88ed20b99346a..4ed79be010dbe416f03dd8eaf98310de00f0dc36 100644 GIT binary patch delta 13 VcmaEJk8#UQ#t90WZ!k^C0RS>q2A2Q; delta 714 zcmaKqy-EX75QV=D5ezo|yucQg5)z4mg$O25BOwtZ!A^q47>K(eiKx}Sf`vt1!BVmH zEo^M8ECpLD*gK|s}Uo|&D2i@Gwea1K!uVGHpF(xMSu zNg3I+W7!j+&j}Zr$RIY(2$ZH`RJ 0 then begin @@ -651,4 +659,47 @@ begin SetCurrentState(FSXStateUIDOff); end; + +{ TFSXFuelFunctionWorker } +procedure TFSXFuelFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition); +begin + ADefinition.AddVariable('FUEL TOTAL CAPACITY', FSX_UNIT_NUMBER, SIMCONNECT_DATAType_FLOAT64); + ADefinition.AddVariable('FUEL TOTAL QUANTITY', FSX_UNIT_NUMBER, SIMCONNECT_DATAType_FLOAT64); +end; + + +procedure TFSXFuelFunctionWorker.HandleData(AData: Pointer); +type + PFuelData = ^TFuelData; + TFuelData = packed record + TotalCapacity: Double; + TotalQuantity: Double; + end; + +var + fuelData: PFuelData; + percentage: Integer; + +begin + fuelData := AData; + + if fuelData^.TotalCapacity > 0 then + begin + percentage := Ceil(fuelData^.TotalQuantity / fuelData^.TotalCapacity * 100); + case percentage of + 0: SetCurrentState(FSXStateUIDFuelEmpty); + 1: SetCurrentState(FSXStateUIDFuel0to1); + 2: SetCurrentState(FSXStateUIDFuel1to2); + 3..5: SetCurrentState(FSXStateUIDFuel2to5); + 6..10: SetCurrentState(FSXStateUIDFuel5to10); + 11..20: SetCurrentState(FSXStateUIDFuel10to20); + 21..50: SetCurrentState(FSXStateUIDFuel20to50); + 51..75: SetCurrentState(FSXStateUIDFuel50to75); + else + SetCurrentState(FSXStateUIDFuel75to100); + end; + end else + SetCurrentState(FSXStateUIDFuelNotAvailable); +end; + end. diff --git a/G940LEDControl/Units/FSXResources.pas b/G940LEDControl/Units/FSXResources.pas index 11f3dd5..55d1197 100644 --- a/G940LEDControl/Units/FSXResources.pas +++ b/G940LEDControl/Units/FSXResources.pas @@ -194,6 +194,32 @@ const FSXFunctionDisplayNameAutoPilotNav = 'Autopilot nav'; + FSXFunctionUIDFuel = 'fuelLevel'; + FSXFunctionDisplayNameFuel = 'Fuel Level'; + + FSXStateUIDFuelNotAvailable = 'notAvailable'; + FSXStateUIDFuelEmpty = 'empty'; + FSXStateUIDFuel0to1 = '0To1'; + FSXStateUIDFuel1to2 = '1To2'; + FSXStateUIDFuel2to5 = '2To5'; + FSXStateUIDFuel5to10 = '5To10'; + FSXStateUIDFuel10to20 = '10To20'; + FSXStateUIDFuel20to50 = '20To50'; + FSXStateUIDFuel50to75 = '50To75'; + FSXStateUIDFuel75to100 = '75To100'; + + FSXStateDisplayNameFuelNotAvailable = 'Not available'; + FSXStateDisplayNameFuelEmpty = 'Empty'; + FSXStateDisplayNameFuel0to1 = '< 1%'; + FSXStateDisplayNameFuel1to2 = '< 2%'; + FSXStateDisplayNameFuel2to5 = '< 5%'; + FSXStateDisplayNameFuel5to10 = '< 10%'; + FSXStateDisplayNameFuel10to20 = '< 20%'; + FSXStateDisplayNameFuel20to50 = '< 50%'; + FSXStateDisplayNameFuel50to75 = '< 75%'; + FSXStateDisplayNameFuel75to100 = '75% - Full'; + + FSXMenuProfiles = 'G940 Profile'; FSXMenuProfileFormat = 'G940: %s'; From 6ad8593423344e415cd54732a6f89bc2acae4a98 Mon Sep 17 00:00:00 2001 From: Mark van Renswoude Date: Wed, 2 Jul 2014 22:45:10 +0000 Subject: [PATCH 4/8] Updated version info --- G940LEDControl/G940LEDControl.dproj | 6 +++--- G940LEDControl/G940LEDControl.res | Bin 27828 -> 28524 bytes 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/G940LEDControl/G940LEDControl.dproj b/G940LEDControl/G940LEDControl.dproj index 813da3d..e0f847e 100644 --- a/G940LEDControl/G940LEDControl.dproj +++ b/G940LEDControl/G940LEDControl.dproj @@ -8,7 +8,7 @@ VCL 13.4 True - Debug + Release Win32 1 Application @@ -82,10 +82,10 @@ RELEASE;$(DCC_Define) - 5 + 6 1 0 - CompanyName=X²Software;FileDescription=G940 LED Control;FileVersion=1.0.5.0;InternalName=;LegalCopyright=© 2011 X²Software;LegalTrademarks=;OriginalFilename=G940LEDControl.exe;ProductName=G940 LED Control;ProductVersion=1.0;Comments= + CompanyName=X²Software;FileDescription=G940 LED Control;FileVersion=1.0.6.0;InternalName=;LegalCopyright=© 2011 X²Software;LegalTrademarks=;OriginalFilename=G940LEDControl.exe;ProductName=G940 LED Control;ProductVersion=1.0;Comments= 1033 $(BDS)\bin\default_app.manifest diff --git a/G940LEDControl/G940LEDControl.res b/G940LEDControl/G940LEDControl.res index 4ed79be010dbe416f03dd8eaf98310de00f0dc36..2a5413701b127f18b994f3781ee2b5691d8952e5 100644 GIT binary patch delta 714 zcmaKqy-EX75QWc%MHCxPxh5xRX^_30?YS<^s0wdJb?Tw5JA zf%bK(fUsw>94O^DYxXW;ORJj2pC{&AT{VcmhE9W5(}ExB0ptLbfiCg)#{ON+lNZ+s z3%L6_wgkF_wn_0Vz&7PfQBP(1E^wP-z9kz#(nv^+20oWR)f+4Ow$bJ6a&V zOk4{}9pytHyD&HXw{!-$bVsQb!n1sy{_dlqMS!Z~JTp537k6b|(H!C?q85@3q@fXB zp^R+WvFrgD=tLJxWRMtV4D{bLmf5nSB*yQVL=zG7G;6J|+s(whCtH`6>@RZwA+y^) Q-8B;HnQ`CTd+)aM4cS0!DF6Tf delta 13 VcmaEJk8#UQ#t90WZ!k^C0RS>q2A2Q; From 388d5ddfafa79c260c48ad0d91deee5d57e3cc79 Mon Sep 17 00:00:00 2001 From: Mark van Renswoude Date: Mon, 1 Sep 2014 06:08:31 +0000 Subject: [PATCH 5/8] Added: setup Fixed: "Path not found" error on first startup --- G940LEDControl/Forms/MainFrm.dfm | 8 ++++++ G940LEDControl/Forms/MainFrm.pas | 7 +++-- G940LEDControl/G940LEDControl.dproj | 3 +- G940LEDControl/G940LEDControl.res | Bin 28524 -> 28524 bytes Setup/G940LEDControl.iss | 41 ++++++++++++++++++++++++++++ 5 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 Setup/G940LEDControl.iss diff --git a/G940LEDControl/Forms/MainFrm.dfm b/G940LEDControl/Forms/MainFrm.dfm index c2798a3..d27b513 100644 --- a/G940LEDControl/Forms/MainFrm.dfm +++ b/G940LEDControl/Forms/MainFrm.dfm @@ -34,6 +34,10 @@ object MainForm: TMainForm TabOrder = 0 object tsButtons: TTabSheet Caption = ' Button assignment ' + ExplicitLeft = 0 + ExplicitTop = 0 + ExplicitWidth = 0 + ExplicitHeight = 0 DesignSize = ( 442 452) @@ -418,6 +422,10 @@ object MainForm: TMainForm object tsAbout: TTabSheet Caption = 'About' ImageIndex = 1 + ExplicitLeft = 0 + ExplicitTop = 0 + ExplicitWidth = 0 + ExplicitHeight = 0 object lblVersionCaption: TLabel Left = 16 Top = 67 diff --git a/G940LEDControl/Forms/MainFrm.pas b/G940LEDControl/Forms/MainFrm.pas index 92b669b..e213103 100644 --- a/G940LEDControl/Forms/MainFrm.pas +++ b/G940LEDControl/Forms/MainFrm.pas @@ -222,8 +222,9 @@ const DefaultProfileName = 'Default'; ProfilePostfixModified = ' (modified)'; - FilenameProfiles = 'G940LEDControl\Profiles.xml'; - FilenameSettings = 'G940LEDControl\Settings.xml'; + UserDataPath = 'G940LEDControl\'; + FilenameProfiles = UserDataPath + 'Profiles.xml'; + FilenameSettings = UserDataPath + 'Settings.xml'; TextStateSearching = 'Searching...'; TextStateNotFound = 'Not found'; @@ -291,6 +292,8 @@ begin FindLEDControls; + ForceDirectories(App.UserPath + UserDataPath); + FProfilesFilename := App.UserPath + FilenameProfiles; LoadProfiles; diff --git a/G940LEDControl/G940LEDControl.dproj b/G940LEDControl/G940LEDControl.dproj index e0f847e..5bcedf3 100644 --- a/G940LEDControl/G940LEDControl.dproj +++ b/G940LEDControl/G940LEDControl.dproj @@ -82,10 +82,11 @@ RELEASE;$(DCC_Define) + 1 6 1 0 - CompanyName=X²Software;FileDescription=G940 LED Control;FileVersion=1.0.6.0;InternalName=;LegalCopyright=© 2011 X²Software;LegalTrademarks=;OriginalFilename=G940LEDControl.exe;ProductName=G940 LED Control;ProductVersion=1.0;Comments= + CompanyName=X²Software;FileDescription=G940 LED Control;FileVersion=1.0.6.1;InternalName=;LegalCopyright=© 2011 X²Software;LegalTrademarks=;OriginalFilename=G940LEDControl.exe;ProductName=G940 LED Control;ProductVersion=1.0;Comments= 1033 $(BDS)\bin\default_app.manifest diff --git a/G940LEDControl/G940LEDControl.res b/G940LEDControl/G940LEDControl.res index 2a5413701b127f18b994f3781ee2b5691d8952e5..bc71e1a8db97b3cc217c2704663e6a88126df61c 100644 GIT binary patch delta 21 dcmaEJkMYet#t9{ij2laZ85s>XcQQWC1psLY2$lc< delta 21 dcmaEJkMYet#t9{i3>!;@85s>WcQQWC1psLG2$TQ- diff --git a/Setup/G940LEDControl.iss b/Setup/G940LEDControl.iss new file mode 100644 index 0000000..5512b93 --- /dev/null +++ b/Setup/G940LEDControl.iss @@ -0,0 +1,41 @@ +#define AppName "G940 LED Control" +#define AppExeName "G940LEDControl.exe" +#define AppVersion GetFileVersion("..\G940LEDControl\Bin\" + AppExeName) +#define AppPublisher "X²Software" +#define AppURL "http://g940.x2software.net/r" + +[Setup] +AppId={{704baf93-d22e-471b-bdcf-d21d82d73398} +AppName={#AppName} +AppVersion={#AppVersion} +AppPublisher={#AppPublisher} +AppPublisherURL={#AppURL} +AppSupportURL={#AppURL} +AppUpdatesURL={#AppURL} +DefaultDirName={pf}\{#AppName} +DefaultGroupName={#AppName} +AllowNoIcons=yes +;LicenseFile=..\license.txt +OutputDir=output +OutputBaseFilename=G940LEDControlSetup-{#AppVersion} +Compression=lzma +SolidCompression=yes + +[Languages] +Name: "english"; MessagesFile: "compiler:Default.isl" + +[Tasks] +Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked + +[Files] +Source: "..\G940LEDControl\Bin\{#AppExeName}"; DestDir: "{app}"; Flags: ignoreversion +Source: "..\G940LEDControl\Bin\LogiJoystickDLL.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "..\G940LEDControl\Bin\SimConnect.dll"; DestDir: "{app}"; Flags: ignoreversion + +[Icons] +Name: "{group}\{#AppName}"; Filename: "{app}\{#AppExeName}" +Name: "{commondesktop}\{#AppName}"; Filename: "{app}\{#AppExeName}"; Tasks: desktopicon + +[Run] +Filename: "{app}\{#AppExeName}"; Description: "{cm:LaunchProgram,{#AppName}}"; Flags: nowait postinstall skipifsilent + From 22facfa9ba9d6e8dd47c737404cf25964ca0ad4e Mon Sep 17 00:00:00 2001 From: Mark van Renswoude Date: Wed, 4 Mar 2015 16:14:07 +0000 Subject: [PATCH 6/8] Added: throttle state function Added: experimental ATC visibility function --- G940LEDControl/Forms/MainFrm.dfm | 8 +- G940LEDControl/G940LEDControl.dproj | 19 +- G940LEDControl/G940LEDControl.res | Bin 28524 -> 28540 bytes G940LEDControl/Units/FSXLEDFunction.pas | 75 ++++++++ .../Units/FSXLEDFunctionProvider.pas | 4 + G940LEDControl/Units/FSXLEDFunctionWorker.pas | 167 +++++++++++++++++- G940LEDControl/Units/FSXResources.pas | 27 +++ 7 files changed, 280 insertions(+), 20 deletions(-) diff --git a/G940LEDControl/Forms/MainFrm.dfm b/G940LEDControl/Forms/MainFrm.dfm index d27b513..d8a16ae 100644 --- a/G940LEDControl/Forms/MainFrm.dfm +++ b/G940LEDControl/Forms/MainFrm.dfm @@ -1,7 +1,7 @@ object MainForm: TMainForm Left = 0 Top = 0 - ActiveControl = cbProfileMenu + ActiveControl = cmbProfiles BorderIcons = [biSystemMenu, biMinimize] BorderStyle = bsSingle Caption = 'G940 LED Control' @@ -29,15 +29,11 @@ object MainForm: TMainForm Margins.Top = 8 Margins.Right = 8 Margins.Bottom = 8 - ActivePage = tsConfiguration + ActivePage = tsButtons Align = alClient TabOrder = 0 object tsButtons: TTabSheet Caption = ' Button assignment ' - ExplicitLeft = 0 - ExplicitTop = 0 - ExplicitWidth = 0 - ExplicitHeight = 0 DesignSize = ( 442 452) diff --git a/G940LEDControl/G940LEDControl.dproj b/G940LEDControl/G940LEDControl.dproj index 5bcedf3..1b17187 100644 --- a/G940LEDControl/G940LEDControl.dproj +++ b/G940LEDControl/G940LEDControl.dproj @@ -49,18 +49,17 @@ true + 7 rtl;dbrtl;$(DCC_UsePackage) Lib - 0 Bin ..\Shared;$(DCC_UnitSearchPath) true - 2 None G940LEDControl_Icon.ico Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;System.Win;$(DCC_Namespace) - CompanyName=X²Software;FileDescription=G940 LED Control;FileVersion=0.2.0.0;InternalName=;LegalCopyright=© 2011 X²Software;LegalTrademarks=;OriginalFilename=G940LEDControl.exe;ProductName=G940 LED Control;ProductVersion=0.2;Comments= - 1043 + CompanyName=X²Software;FileDescription=G940 LED Control;FileVersion=1.0.7.0;InternalName=;LegalCopyright=© 2011 - 2015 X²Software;LegalTrademarks=;OriginalFilename=G940LEDControl.exe;ProductName=G940 LED Control;ProductVersion=1.0;Comments= + 1033 G940LEDControl_Icon.ico @@ -71,7 +70,6 @@ false false Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) - 1033 $(BDS)\bin\default_app.manifest @@ -82,12 +80,6 @@ RELEASE;$(DCC_Define) - 1 - 6 - 1 - 0 - CompanyName=X²Software;FileDescription=G940 LED Control;FileVersion=1.0.6.1;InternalName=;LegalCopyright=© 2011 X²Software;LegalTrademarks=;OriginalFilename=G940LEDControl.exe;ProductName=G940 LED Control;ProductVersion=1.0;Comments= - 1033 $(BDS)\bin\default_app.manifest @@ -105,7 +97,6 @@ false CompanyName=;FileDescription=;FileVersion=0.2.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=0.2;Comments= $(BDS)\bin\default_app.manifest - 1033 @@ -201,7 +192,9 @@ 1.0.0.0 - + + JVCL BDE Components + False diff --git a/G940LEDControl/G940LEDControl.res b/G940LEDControl/G940LEDControl.res index bc71e1a8db97b3cc217c2704663e6a88126df61c..b71b0cd664668aecab031a26a4b2112741a13fd6 100644 GIT binary patch delta 73 zcmaEJkMYkv#t90HD<&$+0|`fCW(EfKiRG$H9844EDKS2ock delta 77 zcmex!kMYet#t90HGbSp^0|`fCW=00KiRG$HKNu&@Q)0X_@!(-@GX^~dLk0#04+f#h h{fzp;5e%Ccf*JA|(iln@${7+FiWpKiKV+Pp3jobU7aafq diff --git a/G940LEDControl/Units/FSXLEDFunction.pas b/G940LEDControl/Units/FSXLEDFunction.pas index cdb849f..891a6c6 100644 --- a/G940LEDControl/Units/FSXLEDFunction.pas +++ b/G940LEDControl/Units/FSXLEDFunction.pas @@ -82,6 +82,13 @@ type function GetWorkerClass: TCustomLEDMultiStateFunctionWorkerClass; override; end; + TFSXThrottleFunction = class(TCustomFSXFunction) + protected + function GetCategoryName: string; override; + procedure RegisterStates; override; + function GetWorkerClass: TCustomLEDMultiStateFunctionWorkerClass; override; + end; + { Control surfaces } TFSXFlapsFunction = class(TCustomFSXFunction) @@ -208,6 +215,19 @@ type end; + { ATC } + TFSXATCVisibilityFunction = class(TCustomMultiStateLEDFunction) + protected + procedure RegisterStates; override; + + function GetCategoryName: string; override; + function GetDisplayName: string; override; + function GetUID: string; override; + + function GetWorkerClass: TCustomLEDMultiStateFunctionWorkerClass; override; + end; + + implementation uses FSXLEDFunctionWorker, @@ -384,6 +404,29 @@ begin end; +{ TFSXThrottleFunction } +function TFSXThrottleFunction.GetCategoryName: string; +begin + Result := FSXCategoryEngines; +end; + + +procedure TFSXThrottleFunction.RegisterStates; +begin + RegisterState(TLEDState.Create(FSXStateUIDThrottleNoEngines, FSXStateDisplayNameThrottleNoThrottles, lcOff)); + RegisterState(TLEDState.Create(FSXStateUIDThrottleOff, FSXStateDisplayNameThrottleOff, lcGreen)); + RegisterState(TLEDState.Create(FSXStateUIDThrottlePartial, FSXStateDisplayNameThrottlePartial, lcAmber)); + RegisterState(TLEDState.Create(FSXStateUIDThrottleFull, FSXStateDisplayNameThrottleFull, lcRed)); + RegisterState(TLEDState.Create(FSXStateUIDThrottleReverse, FSXStateDisplayNameThrottleReverse, lcFlashingAmberNormal)); +end; + + +function TFSXThrottleFunction.GetWorkerClass: TCustomLEDMultiStateFunctionWorkerClass; +begin + Result := TFSXThrottleFunctionWorker; +end; + + { TFSXFlapsFunction } function TFSXFlapsFunction.GetCategoryName: string; begin @@ -617,4 +660,36 @@ begin Result := TFSXFuelFunctionWorker; end; + +{ TFSXATCFunction } +procedure TFSXATCVisibilityFunction.RegisterStates; +begin + RegisterState(TLEDState.Create(FSXStateUIDATCHidden, FSXStateDisplayNameATCHidden, lcGreen)); + RegisterState(TLEDState.Create(FSXStateUIDATCVisible, FSXStateDisplayNameATCVisible, lcFlashingAmberNormal)); +end; + + +function TFSXATCVisibilityFunction.GetCategoryName: string; +begin + Result := FSXCategoryATC; +end; + + +function TFSXATCVisibilityFunction.GetDisplayName: string; +begin + Result := FSXFunctionDisplayNameATCVisibility; +end; + + +function TFSXATCVisibilityFunction.GetUID: string; +begin + Result := FSXFunctionUIDATCVisibility; +end; + + +function TFSXATCVisibilityFunction.GetWorkerClass: TCustomLEDMultiStateFunctionWorkerClass; +begin + Result := TFSXATCVisibilityFunctionWorker; +end; + end. diff --git a/G940LEDControl/Units/FSXLEDFunctionProvider.pas b/G940LEDControl/Units/FSXLEDFunctionProvider.pas index 413eba0..0a0ad92 100644 --- a/G940LEDControl/Units/FSXLEDFunctionProvider.pas +++ b/G940LEDControl/Units/FSXLEDFunctionProvider.pas @@ -139,6 +139,7 @@ begin { Engines } RegisterFunction(TFSXEngineAntiIceFunction.Create( Self, FSXFunctionDisplayNameEngineAntiIce, FSXFunctionUIDEngineAntiIce)); RegisterFunction(TFSXEngineFunction.Create( Self, FSXFunctionDisplayNameEngine, FSXFunctionUIDEngine)); + RegisterFunction(TFSXThrottleFunction.Create( Self, FSXFunctionDisplayNameThrottle, FSXFunctionUIDThrottle)); { Control surfaces } RegisterFunction(TFSXFlapsFunction.Create( Self, FSXFunctionDisplayNameFlaps, FSXFunctionUIDFlaps)); @@ -167,6 +168,9 @@ begin { Fuel } RegisterFunction(TFSXFuelFunction.Create( Self, FSXFunctionDisplayNameFuel, FSXFunctionUIDFuel)); + + { ATC } + RegisterFunction(TFSXATCVisibilityFunction.Create(FSXProviderUID)); end; diff --git a/G940LEDControl/Units/FSXLEDFunctionWorker.pas b/G940LEDControl/Units/FSXLEDFunctionWorker.pas index 9f66012..a617df0 100644 --- a/G940LEDControl/Units/FSXLEDFunctionWorker.pas +++ b/G940LEDControl/Units/FSXLEDFunctionWorker.pas @@ -2,8 +2,12 @@ unit FSXLEDFunctionWorker; interface uses + OtlTaskControl, + FSXLEDFunctionProvider, - FSXSimConnectIntf; + FSXSimConnectIntf, + LEDFunction, + LEDFunctionIntf; type @@ -64,6 +68,12 @@ type procedure HandleData(AData: Pointer); override; end; + TFSXThrottleFunctionWorker = class(TCustomFSXFunctionWorker) + protected + procedure RegisterVariables(ADefinition: IFSXSimConnectDefinition); override; + procedure HandleData(AData: Pointer); override; + end; + { Control surfaces } TFSXFlapsFunctionWorker = class(TCustomFSXFunctionWorker) @@ -173,10 +183,23 @@ type end; + { ATC } + TFSXATCVisibilityFunctionWorker = class(TCustomLEDMultiStateFunctionWorker) + private + FMonitorTask: IOmniTaskControl; + public + constructor Create(const AProviderUID: string; const AFunctionUID: string; AStates: ILEDMultiStateFunction; ASettings: ILEDFunctionWorkerSettings; const APreviousState: string = ''); override; + destructor Destroy; override; + end; + + implementation uses System.Math, System.SysUtils, + Winapi.Windows, + + OtlTask, FSXResources, LEDStateIntf, @@ -455,6 +478,64 @@ begin end; +{ TFSXThrottleFunctionWorker } +procedure TFSXThrottleFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition); +var + engineIndex: Integer; + +begin + ADefinition.AddVariable('NUMBER OF ENGINES', FSX_UNIT_NUMBER, SIMCONNECT_DATAType_INT32); + + for engineIndex := 1 to FSX_MAX_ENGINES do + ADefinition.AddVariable(Format('GENERAL ENG THROTTLE LEVER POSITION:%d', [engineIndex]), FSX_UNIT_PERCENT, SIMCONNECT_DATAType_FLOAT64); +end; + + +procedure TFSXThrottleFunctionWorker.HandleData(AData: Pointer); +type + PThrottleData = ^TThrottleData; + TThrottleData = packed record + NumberOfEngines: Integer; + Position: array[1..FSX_MAX_ENGINES] of Double; + end; + +var + throttleData: PThrottleData; + reverse: Boolean; + totalPosition: Double; + engineIndex: Integer; + +begin + throttleData := AData; + + if throttleData^.NumberOfEngines > 0 then + begin + reverse := False; + totalPosition := 0; + + for engineIndex := 1 to throttleData^.NumberOfEngines do + begin + if throttleData^.Position[engineIndex] < 0 then + begin + reverse := True; + break; + end else + totalPosition := totalPosition + throttleData^.Position[engineIndex]; + end; + + if reverse then + SetCurrentState(FSXStateUIDThrottleReverse) + else + case Trunc(totalPosition / throttleData^.NumberOfEngines) of + 0..5: SetCurrentState(FSXStateUIDThrottleOff); + 95..100: SetCurrentState(FSXStateUIDThrottleFull); + else SetCurrentState(FSXStateUIDThrottlePartial); + end; + end else + SetCurrentState(FSXStateUIDThrottleNoEngines); +end; + + { TFSXFlapsFunctionWorker } procedure TFSXFlapsFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition); begin @@ -702,4 +783,88 @@ begin SetCurrentState(FSXStateUIDFuelNotAvailable); end; + +type + TFSXATCVisibilityStateChanged = reference to procedure(AVisible: Boolean); + + TFSXATCVisibilityTask = class(TOmniWorker) + private + FOnStateChanged: TFSXATCVisibilityStateChanged; + FVisible: Boolean; + public + constructor Create(AOnStateChanged: TFSXATCVisibilityStateChanged); + procedure Run; + end; + + +{ TFSXATCVisibilityFunctionWorker } +constructor TFSXATCVisibilityFunctionWorker.Create(const AProviderUID, AFunctionUID: string; AStates: ILEDMultiStateFunction; ASettings: ILEDFunctionWorkerSettings; const APreviousState: string); +begin + inherited Create(AProviderUID, AFunctionUID, AStates, ASettings, APreviousState); + + FMonitorTask := CreateTask(TFSXATCVisibilityTask.Create( + procedure(AVisible: Boolean) + begin + if AVisible then + SetCurrentState(FSXStateUIDATCVisible) + else + SetCurrentState(FSXStateUIDATCHidden); + end)) + .SetTimer(1, MSecsPerSec, @TFSXATCVisibilityTask.Run) + .Run; +end; + + +destructor TFSXATCVisibilityFunctionWorker.Destroy; +begin + FMonitorTask.Terminate; + FMonitorTask := nil; + + inherited Destroy; +end; + + +{ TFSXATCVisibilityTask } +constructor TFSXATCVisibilityTask.Create(AOnStateChanged: TFSXATCVisibilityStateChanged); +begin + inherited Create; + + FOnStateChanged := AOnStateChanged; + FVisible := False; +end; + + +procedure TFSXATCVisibilityTask.Run; +const + ClassNameMainWindow = 'FS98MAIN'; + ClassNameChildWindow = 'FS98CHILD'; + ClassNameFloatWindow = 'FS98FLOAT'; + WindowTitleATC = 'ATC Menu'; + +var + visible: Boolean; + mainWindow: THandle; + atcWindow: THandle; + +begin + { Docked } + atcWindow := 0; + mainWindow := FindWindow(ClassNameMainWindow, nil); + if mainWindow <> 0 then + atcWindow := FindWindowEx(mainWindow, 0, ClassNameChildWindow, WindowTitleATC); + + { Undocked } + if atcWindow = 0 then + atcWindow := FindWindow(ClassNameFloatWindow, WindowTitleATC); + + + visible := (atcWindow <> 0) and IsWindowVisible(atcWindow); + + if visible <> FVisible then + begin + FVisible := visible; + FOnStateChanged(visible); + end; +end; + end. diff --git a/G940LEDControl/Units/FSXResources.pas b/G940LEDControl/Units/FSXResources.pas index 55d1197..70a5507 100644 --- a/G940LEDControl/Units/FSXResources.pas +++ b/G940LEDControl/Units/FSXResources.pas @@ -12,6 +12,7 @@ const FSXCategoryLights = FSXCategory + ' - Lights'; FSXCategoryAutoPilot = FSXCategory + ' - Autopilot'; FSXCategoryRadios = FSXCategory + ' - Radios'; + FSXCategoryATC = FSXCategory + ' - ATC'; FSXStateUIDOn = 'on'; FSXStateUIDOff = 'off'; @@ -40,6 +41,22 @@ const FSXStateDisplayNameEngineOnFire = 'On fire'; + FSXFunctionUIDThrottle = 'throttle'; + FSXFunctionDisplayNameThrottle = 'Throttle'; + + FSXStateUIDThrottleNoEngines = 'noEngines'; + FSXStateUIDThrottleOff = 'off'; + FSXStateUIDThrottlePartial = 'partial'; + FSXStateUIDThrottleFull = 'full'; + FSXStateUIDThrottleReverse = 'reverse'; + + FSXStateDisplayNameThrottleNoThrottles = 'No engines'; + FSXStateDisplayNameThrottleOff = 'Off'; + FSXStateDisplayNameThrottlePartial = 'Partial'; + FSXStateDisplayNameThrottleFull = 'Full'; + FSXStateDisplayNameThrottleReverse = 'Reversed'; + + FSXFunctionUIDGear = 'gear'; FSXFunctionDisplayNameGear = 'Landing gear'; @@ -220,6 +237,16 @@ const FSXStateDisplayNameFuel75to100 = '75% - Full'; + FSXFunctionUIDATCVisibility = 'atcVisiblity'; + FSXFunctionDisplayNameATCVisibility = 'ATC Visibility (experimental)'; + + FSXStateUIDATCHidden = 'hidden'; + FSXStateUIDATCVisible = 'visible'; + + FSXStateDisplayNameATCHidden = 'Hidden'; + FSXStateDisplayNameATCVisible = 'Visible'; + + FSXMenuProfiles = 'G940 Profile'; FSXMenuProfileFormat = 'G940: %s'; From f0d3feb6cf1c95d2124b0e46bcde77081ff5252f Mon Sep 17 00:00:00 2001 From: Mark van Renswoude Date: Wed, 4 Mar 2015 16:37:22 +0000 Subject: [PATCH 7/8] Fixed URL in setup --- Setup/G940LEDControl.iss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Setup/G940LEDControl.iss b/Setup/G940LEDControl.iss index 5512b93..57d5b1b 100644 --- a/Setup/G940LEDControl.iss +++ b/Setup/G940LEDControl.iss @@ -2,7 +2,7 @@ #define AppExeName "G940LEDControl.exe" #define AppVersion GetFileVersion("..\G940LEDControl\Bin\" + AppExeName) #define AppPublisher "X²Software" -#define AppURL "http://g940.x2software.net/r" +#define AppURL "http://g940.x2software.net/" [Setup] AppId={{704baf93-d22e-471b-bdcf-d21d82d73398} From f3b7a0c45f96e1c1d218d9d47d9fe6fbf961e25b Mon Sep 17 00:00:00 2001 From: Mark van Renswoude Date: Sat, 14 Mar 2015 09:43:15 +0000 Subject: [PATCH 8/8] Added: pitot heat --- G940LEDControl/G940LEDControl.dproj | 2 +- G940LEDControl/G940LEDControl.res | Bin 28540 -> 27828 bytes G940LEDControl/Units/FSXLEDFunction.pas | 57 ++++++++ .../Units/FSXLEDFunctionProvider.pas | 4 + G940LEDControl/Units/FSXLEDFunctionWorker.pas | 133 ++++++++++-------- G940LEDControl/Units/FSXResources.pas | 30 ++++ 6 files changed, 169 insertions(+), 57 deletions(-) diff --git a/G940LEDControl/G940LEDControl.dproj b/G940LEDControl/G940LEDControl.dproj index 1b17187..f5522cf 100644 --- a/G940LEDControl/G940LEDControl.dproj +++ b/G940LEDControl/G940LEDControl.dproj @@ -8,7 +8,7 @@ VCL 13.4 True - Release + Debug Win32 1 Application diff --git a/G940LEDControl/G940LEDControl.res b/G940LEDControl/G940LEDControl.res index b71b0cd664668aecab031a26a4b2112741a13fd6..4ed79be010dbe416f03dd8eaf98310de00f0dc36 100644 GIT binary patch delta 13 Vcmex!k8#UQ#t90WUocI{0RS^*2DbnJ delta 730 zcmaKqPcH*u5XPTvHbGp7liMB~X;g|hNmNP2zaWj9G*mUI-KMSJv|qu&ho~cQ^+8;m zdiMnczj@o$R>He^=bf3%JTvpmKEHY&Z{A%Hw^LFe>FaBP>!C^W8uOikXs5Esq7HR} z%70r$TcF~>b#Ar$}&O^1-P*tHSz*SXK8R$^w ziU{kF<yW-wFy0oNm{5fJSRac4lTiPjMl^yu8o=oIp;b~s2e3&wD;j8IKXwuHSMhC!(U^PJNV`P*jCaq=n8jsV&ZxdIc zrJ8avkaaq@`762rTza6?0%;k(KyyFVBHCY5?P?0(y&jHnY4FLEW_5W 0 then + SetCurrentState(FSXStateUIDOn) + else + SetCurrentState(FSXStateUIDOff); +end; + + { TFSXBatteryMasterFunctionWorker } procedure TFSXBatteryMasterFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition); begin @@ -213,15 +238,6 @@ begin end; -procedure TFSXBatteryMasterFunctionWorker.HandleData(AData: Pointer); -begin - if PCardinal(AData)^ <> 0 then - SetCurrentState(FSXStateUIDOn) - else - SetCurrentState(FSXStateUIDOff); -end; - - { TFSXDeIceFunctionWorker } procedure TFSXDeIceFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition); begin @@ -229,15 +245,6 @@ begin end; -procedure TFSXDeIceFunctionWorker.HandleData(AData: Pointer); -begin - if PCardinal(AData)^ <> 0 then - SetCurrentState(FSXStateUIDOn) - else - SetCurrentState(FSXStateUIDOff); -end; - - { TFSXExitDoorFunctionWorker } procedure TFSXExitDoorFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition); begin @@ -306,15 +313,6 @@ begin end; -procedure TFSXParkingBrakeFunctionWorker.HandleData(AData: Pointer); -begin - if PCardinal(AData)^ <> 0 then - SetCurrentState(FSXStateUIDOn) - else - SetCurrentState(FSXStateUIDOff); -end; - - { TFSXPressDumpSwitchFunctionWorker } procedure TFSXPressDumpSwitchFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition); begin @@ -322,15 +320,6 @@ begin end; -procedure TFSXPressDumpSwitchFunctionWorker.HandleData(AData: Pointer); -begin - if PCardinal(AData)^ <> 0 then - SetCurrentState(FSXStateUIDOn) - else - SetCurrentState(FSXStateUIDOff); -end; - - { TFSXTailHookFunctionWorker } procedure TFSXTailHookFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition); begin @@ -348,6 +337,47 @@ begin end; +{ TFSXPitotOnOffFunctionWorker } +procedure TFSXPitotOnOffFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition); +begin + ADefinition.AddVariable('PITOT HEAT', FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); +end; + + +{ TFSXPitotWarningFunctionWorker } +procedure TFSXPitotWarningFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition); +begin + ADefinition.AddVariable('PITOT HEAT', FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); + ADefinition.AddVariable('PITOT ICE PCT', FSX_UNIT_PERCENT, SIMCONNECT_DATAType_FLOAT64); +end; + + +procedure TFSXPitotWarningFunctionWorker.HandleData(AData: Pointer); +type + PPitotData = ^TPitotData; + TPitotData = packed record + HeatActive: Cardinal; + IcePercentage: Double; + end; + +var + pitotData: PPitotData; + heatActive: Boolean; + +begin + pitotData := AData; + heatActive := (pitotData^.HeatActive <> 0); + + case Trunc(pitotData^.IcePercentage) of + 25..49: SetCurrentState(IfThen(heatActive, FSXStateUIDPitotOnIce25to50, FSXStateUIDPitotOffIce25to50)); + 50..74: SetCurrentState(IfThen(heatActive, FSXStateUIDPitotOnIce50to75, FSXStateUIDPitotOffIce50to75)); + 75..99: SetCurrentState(IfThen(heatActive, FSXStateUIDPitotOnIce75to100, FSXStateUIDPitotOffIce75to100)); + 100: SetCurrentState(IfThen(heatActive, FSXStateUIDPitotOnIceFull, FSXStateUIDPitotOffIceFull)); + else SetCurrentState(IfThen(heatActive, FSXStateUIDPitotOnIceNone, FSXStateUIDPitotOffIceNone)); + end; +end; + + { TFSXEngineAntiIceFunctionWorker } procedure TFSXEngineAntiIceFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition); var @@ -732,15 +762,6 @@ begin end; -procedure TFSXAvionicsMasterFunctionWorker.HandleData(AData: Pointer); -begin - if PCardinal(AData)^ <> 0 then - SetCurrentState(FSXStateUIDOn) - else - SetCurrentState(FSXStateUIDOff); -end; - - { TFSXFuelFunctionWorker } procedure TFSXFuelFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition); begin diff --git a/G940LEDControl/Units/FSXResources.pas b/G940LEDControl/Units/FSXResources.pas index 70a5507..7399447 100644 --- a/G940LEDControl/Units/FSXResources.pas +++ b/G940LEDControl/Units/FSXResources.pas @@ -13,6 +13,7 @@ const FSXCategoryAutoPilot = FSXCategory + ' - Autopilot'; FSXCategoryRadios = FSXCategory + ' - Radios'; FSXCategoryATC = FSXCategory + ' - ATC'; + FSXCategoryInstruments = FSXCategory + ' - Instruments'; FSXStateUIDOn = 'on'; FSXStateUIDOff = 'off'; @@ -247,6 +248,35 @@ const FSXStateDisplayNameATCVisible = 'Visible'; + FSXFunctionUIDPitotOnOff = 'pitotOnOff'; + FSXFunctionDisplayNamePitotOnOff = 'Pitot heat (on / off only)'; + + + FSXFunctionUIDPitotWarning = 'pitotWarning'; + FSXFunctionDisplayNamePitotWarning = 'Pitot heat (including warnings)'; + + FSXStateUIDPitotOffIceNone = 'off0'; + FSXStateUIDPitotOffIce25to50 = 'off25To50'; + FSXStateUIDPitotOffIce50to75 = 'off50To75'; + FSXStateUIDPitotOffIce75to100 = 'off75To100'; + FSXStateUIDPitotOffIceFull = 'off100'; + FSXStateUIDPitotOnIceNone = 'on0'; + FSXStateUIDPitotOnIce25to50 = 'on25To50'; + FSXStateUIDPitotOnIce50to75 = 'on50To75'; + FSXStateUIDPitotOnIce75to100 = 'on75To100'; + FSXStateUIDPitotOnIceFull = 'on100'; + + FSXStateDisplayNamePitotOffIceNone = 'Heat off - No ice'; + FSXStateDisplayNamePitotOffIce25to50 = 'Heat off - > 25% iced'; + FSXStateDisplayNamePitotOffIce50to75 = 'Heat off - > 50% iced'; + FSXStateDisplayNamePitotOffIce75to100 = 'Heat off - > 75% iced'; + FSXStateDisplayNamePitotOffIceFull = 'Heat off - Fully iced'; + FSXStateDisplayNamePitotOnIceNone = 'Heat on - No ice'; + FSXStateDisplayNamePitotOnIce25to50 = 'Heat on - > 25% iced'; + FSXStateDisplayNamePitotOnIce50to75 = 'Heat on - > 50% iced'; + FSXStateDisplayNamePitotOnIce75to100 = 'Heat on - > 75% iced'; + FSXStateDisplayNamePitotOnIceFull = 'Heat on - Fully iced'; + FSXMenuProfiles = 'G940 Profile'; FSXMenuProfileFormat = 'G940: %s';