diff --git a/DevConsoleApp/Program.cs b/DevConsoleApp/Program.cs index 61a1b4c..ca60ff9 100644 --- a/DevConsoleApp/Program.cs +++ b/DevConsoleApp/Program.cs @@ -1,6 +1,7 @@  using PendantNamespace; using System; +using System.ComponentModel; using System.Threading; /** @@ -22,26 +23,35 @@ static void Main() pen.ButtonDown += onButtonDown; pen.ButtonUp += onButtonUp; pen.MPGRotated += onMPGRotated; + pen.PropertyChanged += onPropertyChanged; Console.ReadKey(true); Thread.Sleep(1000); } } + private static void onPropertyChanged(object sender, PropertyChangedEventArgs e) + { + Console.WriteLine($" Feed %: {pen.Inputs.FeedPC}"); + Console.WriteLine($" Speed %: {pen.Inputs.SpeedPC}"); + Console.WriteLine($" Jog Axis: {pen.Inputs.JogAxis.ToString()}"); + Console.WriteLine($" Step : {pen.Inputs.MpgStepMultiplier.ToString()}"); + } + private static void onMPGRotated(object sender, MPGRotateEventArgs e) { AxisCounter += (e.direction == MPGDirecton.Positive ? 1 : -1); - Console.WriteLine($"MPG Pos: { AxisCounter }"); + Console.WriteLine($" MPG Pos: { AxisCounter }"); } private static void onButtonUp(object sender, PendantButtonEventArgs e) { - Console.WriteLine($"Button Up: {e.button}"); + Console.WriteLine($" Button Up: {e.button}"); } static void onButtonDown(object sender, PendantButtonEventArgs e) { - Console.WriteLine($"Button Down: {e.button}"); + Console.WriteLine($" Button Down: {e.button}"); } } } diff --git a/LEETArduinoPendant.sln b/LEETArduinoPendant.sln index 96d495b..8bb6dd4 100644 --- a/LEETArduinoPendant.sln +++ b/LEETArduinoPendant.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.852 +# Visual Studio Version 17 +VisualStudioVersion = 17.6.33829.357 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DevConsoleApp", "DevConsoleApp\DevConsoleApp.csproj", "{36EC9B2F-8794-4A56-945D-9A3D6F5F6562}" EndProject @@ -16,6 +16,7 @@ Global {36EC9B2F-8794-4A56-945D-9A3D6F5F6562}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {36EC9B2F-8794-4A56-945D-9A3D6F5F6562}.Debug|Any CPU.Build.0 = Debug|Any CPU {36EC9B2F-8794-4A56-945D-9A3D6F5F6562}.Release|Any CPU.ActiveCfg = Release|Any CPU + {36EC9B2F-8794-4A56-945D-9A3D6F5F6562}.Release|Any CPU.Build.0 = Release|Any CPU {D54F1A83-C9C7-42D8-9833-DDCAA71D69A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D54F1A83-C9C7-42D8-9833-DDCAA71D69A5}.Debug|Any CPU.Build.0 = Debug|Any CPU {D54F1A83-C9C7-42D8-9833-DDCAA71D69A5}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/LEETArduinoPendant/Pendant.cs b/LEETArduinoPendant/Pendant.cs index d6fd343..0d5699c 100644 --- a/LEETArduinoPendant/Pendant.cs +++ b/LEETArduinoPendant/Pendant.cs @@ -1,6 +1,7 @@ using Solid.Arduino; using Solid.Arduino.Firmata; using System; +using System.Collections.Generic; using System.ComponentModel; using System.Threading; @@ -10,6 +11,9 @@ namespace PendantNamespace public class Pendant : IDisposable { public InputStates Inputs = new InputStates(); + + private Dictionary analogInputsCashe = new Dictionary(); + private ArduinoSession session; private ISerialConnection connection; @@ -119,6 +123,21 @@ private void AnalogStateReceived(object sender, FirmataEventArgs ev } + if (analogInputsCashe.ContainsKey(eventArgs.Value.Channel)) + { + if (analogInputsCashe[eventArgs.Value.Channel] - 1 > eventArgs.Value.Level || analogInputsCashe[eventArgs.Value.Channel] + 1 < eventArgs.Value.Level) + { + analogInputsCashe[eventArgs.Value.Channel] = eventArgs.Value.Level; + Console.WriteLine($"Analog Ch: {eventArgs.Value.Channel} Val: {eventArgs.Value.Level}"); + } + } + else + { + analogInputsCashe[eventArgs.Value.Channel] = eventArgs.Value.Level; + Console.WriteLine($"Analog Ch: {eventArgs.Value.Channel} Val: {eventArgs.Value.Level}"); + } + + //Console.WriteLine(sender); if (eventArgs.Value.Channel == 0) { @@ -157,7 +176,6 @@ private void AnalogStateReceived(object sender, FirmataEventArgs ev Inputs.FeedPC = val; } - //Console.WriteLine($"Pin: {eventArgs.Value.Channel} Val: {eventArgs.Value.Level}"); } @@ -167,6 +185,11 @@ private void DigitalStateReceived(object sender, FirmataEventArgs