From c6fcd4b2447a299a4d079eef6474ec1dd9e274e4 Mon Sep 17 00:00:00 2001 From: elral <3263285+elral@users.noreply.github.com> Date: Sun, 22 Dec 2024 08:53:18 +0100 Subject: [PATCH 1/4] First changes --- MobiFlight/FirmwareFeature.cs | 1 + MobiFlight/MobiFlightModule.cs | 3 ++- MobiFlight/MobiFlightOutput.cs | 26 +++++++++++++++++++++----- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/MobiFlight/FirmwareFeature.cs b/MobiFlight/FirmwareFeature.cs index 401be2150..3c280eb36 100644 --- a/MobiFlight/FirmwareFeature.cs +++ b/MobiFlight/FirmwareFeature.cs @@ -6,5 +6,6 @@ public class FirmwareFeature public const string SetName = "1.6.0"; public const string LedModuleTypeTM1637 = "2.4.2"; public const string CustomDevices = "2.4.2"; + public const string Output_DeviceID = "3.0.0"; } } diff --git a/MobiFlight/MobiFlightModule.cs b/MobiFlight/MobiFlightModule.cs index 5c3c75ce8..8a88ad8bc 100644 --- a/MobiFlight/MobiFlightModule.cs +++ b/MobiFlight/MobiFlightModule.cs @@ -395,7 +395,8 @@ public void LoadConfig() { CmdMessenger = _cmdMessenger, Name = device.Name, - Pin = pin + Pin = pin, + OutputNumber = outputs.Count }); break; case DeviceType.LcdDisplay: diff --git a/MobiFlight/MobiFlightOutput.cs b/MobiFlight/MobiFlightOutput.cs index 054a73945..94c386532 100644 --- a/MobiFlight/MobiFlightOutput.cs +++ b/MobiFlight/MobiFlightOutput.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Text; using CommandMessenger; @@ -27,17 +28,31 @@ public DeviceType Type public CmdMessenger CmdMessenger { get; set; } public int Pin { get; set; } - - public MobiFlightOutput() { } + + public int OutputNumber { get; set; } + + public MobiFlightOutput() { + OutputNumber = 0; + } public void Set(int value) { var command = new SendCommand((int)MobiFlightModule.Command.SetPin); - command.AddArgument(Pin); command.AddArgument(value); - // Send command - Log.Instance.log($"Command: SetPin <{(int)MobiFlightModule.Command.SetPin},{Pin},{value};>.", LogSeverity.Debug); + //if (HasFirmwareFeature(FirmwareFeature.Output_DeviceID)) + { + command.AddArgument(OutputNumber); + Log.Instance.log($"Command: SetPin <{(int)MobiFlightModule.Command.SetPin},{OutputNumber},{value};>.", LogSeverity.Debug); + } + /* + else + { + command.AddArgument(Pin); + Log.Instance.log($"Command: SetPin <{(int)MobiFlightModule.Command.SetPin},{Pin},{value};>.", LogSeverity.Debug); + } + */ + // Send command CmdMessenger.SendCommand(command); } @@ -45,5 +60,6 @@ public void Stop() { Set(0); } + } } From b26633f3aae81f79818524d6447d161c5027cc51 Mon Sep 17 00:00:00 2001 From: elral <3263285+elral@users.noreply.github.com> Date: Sun, 22 Dec 2024 16:57:30 +0100 Subject: [PATCH 2/4] including FW check --- MobiFlight/MobiFlightModule.cs | 3 ++- MobiFlight/MobiFlightOutput.cs | 25 ++++++++++--------------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/MobiFlight/MobiFlightModule.cs b/MobiFlight/MobiFlightModule.cs index 8a88ad8bc..bcb75987d 100644 --- a/MobiFlight/MobiFlightModule.cs +++ b/MobiFlight/MobiFlightModule.cs @@ -396,7 +396,8 @@ public void LoadConfig() CmdMessenger = _cmdMessenger, Name = device.Name, Pin = pin, - OutputNumber = outputs.Count + OutputNumber = outputs.Count, + sendDeviceID = HasFirmwareFeature(FirmwareFeature.Output_DeviceID) }); break; case DeviceType.LcdDisplay: diff --git a/MobiFlight/MobiFlightOutput.cs b/MobiFlight/MobiFlightOutput.cs index 94c386532..3c8c710ce 100644 --- a/MobiFlight/MobiFlightOutput.cs +++ b/MobiFlight/MobiFlightOutput.cs @@ -31,27 +31,22 @@ public DeviceType Type public int OutputNumber { get; set; } - public MobiFlightOutput() { - OutputNumber = 0; - } + public bool sendDeviceID { get; set; } + public MobiFlightOutput() { } public void Set(int value) { var command = new SendCommand((int)MobiFlightModule.Command.SetPin); - command.AddArgument(value); + int output; - //if (HasFirmwareFeature(FirmwareFeature.Output_DeviceID)) - { - command.AddArgument(OutputNumber); - Log.Instance.log($"Command: SetPin <{(int)MobiFlightModule.Command.SetPin},{OutputNumber},{value};>.", LogSeverity.Debug); - } - /* + if (sendDeviceID) + output = OutputNumber; else - { - command.AddArgument(Pin); - Log.Instance.log($"Command: SetPin <{(int)MobiFlightModule.Command.SetPin},{Pin},{value};>.", LogSeverity.Debug); - } - */ + output = Pin; + + Log.Instance.log($"Command: SetPin <{(int)MobiFlightModule.Command.SetPin},{output},{value};>.", LogSeverity.Debug); + command.AddArgument(output); + command.AddArgument(value); // Send command CmdMessenger.SendCommand(command); } From d3bd09bcafd4c4e02e0c9b6fee2c85a087d7c52f Mon Sep 17 00:00:00 2001 From: elral <3263285+elral@users.noreply.github.com> Date: Sun, 22 Dec 2024 17:01:47 +0100 Subject: [PATCH 3/4] delete not required using --- MobiFlight/MobiFlightOutput.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/MobiFlight/MobiFlightOutput.cs b/MobiFlight/MobiFlightOutput.cs index 3c8c710ce..ba1065585 100644 --- a/MobiFlight/MobiFlightOutput.cs +++ b/MobiFlight/MobiFlightOutput.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Globalization; using System.Linq; using System.Text; using CommandMessenger; From 82bcccb61af93cc4732cdb5b69ac2327a0c0d448 Mon Sep 17 00:00:00 2001 From: elral <3263285+elral@users.noreply.github.com> Date: Sun, 22 Dec 2024 17:03:02 +0100 Subject: [PATCH 4/4] reformatting --- MobiFlight/MobiFlightOutput.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MobiFlight/MobiFlightOutput.cs b/MobiFlight/MobiFlightOutput.cs index ba1065585..86efbbdcd 100644 --- a/MobiFlight/MobiFlightOutput.cs +++ b/MobiFlight/MobiFlightOutput.cs @@ -31,6 +31,7 @@ public DeviceType Type public int OutputNumber { get; set; } public bool sendDeviceID { get; set; } + public MobiFlightOutput() { } public void Set(int value) @@ -44,6 +45,7 @@ public void Set(int value) output = Pin; Log.Instance.log($"Command: SetPin <{(int)MobiFlightModule.Command.SetPin},{output},{value};>.", LogSeverity.Debug); + command.AddArgument(output); command.AddArgument(value); // Send command @@ -54,6 +56,5 @@ public void Stop() { Set(0); } - } }