Skip to content

Commit

Permalink
v1.0.2 add debugging app
Browse files Browse the repository at this point in the history
  • Loading branch information
swindex committed Oct 21, 2023
1 parent 02ffc3d commit e31af6b
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 8 deletions.
16 changes: 13 additions & 3 deletions DevConsoleApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

using PendantNamespace;
using System;
using System.ComponentModel;
using System.Threading;

/**
Expand All @@ -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}");
}
}
}
5 changes: 3 additions & 2 deletions LEETArduinoPendant.sln
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
26 changes: 25 additions & 1 deletion LEETArduinoPendant/Pendant.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Solid.Arduino;
using Solid.Arduino.Firmata;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Threading;

Expand All @@ -10,6 +11,9 @@ namespace PendantNamespace
public class Pendant : IDisposable
{
public InputStates Inputs = new InputStates();

private Dictionary<int, long> analogInputsCashe = new Dictionary<int,long>();

private ArduinoSession session;
private ISerialConnection connection;

Expand Down Expand Up @@ -119,6 +123,21 @@ private void AnalogStateReceived(object sender, FirmataEventArgs<AnalogState> 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)
{
Expand Down Expand Up @@ -157,7 +176,6 @@ private void AnalogStateReceived(object sender, FirmataEventArgs<AnalogState> ev
Inputs.FeedPC = val;
}

//Console.WriteLine($"Pin: {eventArgs.Value.Channel} Val: {eventArgs.Value.Level}");
}


Expand All @@ -167,6 +185,11 @@ private void DigitalStateReceived(object sender, FirmataEventArgs<DigitalPortSta
//Console.WriteLine(sender);
var port = eventArgs.Value.Port;

string binaryString = Convert.ToString(eventArgs.Value.Pins, 2); // Convert to binary
binaryString = binaryString.PadLeft(9, '0');
Console.WriteLine($"Digital Port: {port} Pins : {binaryString}");


if (port == 0 && eventArgs.Value.IsSet(2))
{
if (PressButton(PendantButton.Enable))
Expand Down Expand Up @@ -278,6 +301,7 @@ private void DigitalStateReceived(object sender, FirmataEventArgs<DigitalPortSta
}



/*Console.Write($"port: {eventArgs.Value.Port} Pins 0: {(eventArgs.Value.IsSet(0) ? 'X' : ' ') }");
Console.Write($"port: {eventArgs.Value.Port} Pins 1: {(eventArgs.Value.IsSet(1) ? 'X' : ' ') }");
Console.Write($"port: {eventArgs.Value.Port} Pins 2: {(eventArgs.Value.IsSet(2) ? 'X' : ' ') }");
Expand Down
4 changes: 2 additions & 2 deletions LEETArduinoPendant/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.2.0")]
[assembly: AssemblyFileVersion("1.0.2.0")]
Binary file added LEETArduinoPendantRelease/DevConsoleApp.exe
Binary file not shown.
Binary file modified LEETArduinoPendantRelease/LEETArduinoPendant.dll
Binary file not shown.
3 changes: 3 additions & 0 deletions LEETArduinoPendantRelease/REDME.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
A UCCNC Plugin to receive commands from an Arduino Nano-powered CNC Pendant
Uses Solid.Arduino library to talk to Arduino Nano

## DevConsoleApp
- use this diagnistics app to check if all pins are properly detected

## The full list of components, pictures and videos used can be found here:
https://zero-divide.net/?article_id=5319_custom-cnc-pendant-project

Expand Down

0 comments on commit e31af6b

Please sign in to comment.