Skip to content

Commit

Permalink
Added support for Grbl communication
Browse files Browse the repository at this point in the history
PathCAM now fully supports connections to a Grbl based controller
running Grbl 8.0c or later!  The installer file is also updated.
  • Loading branch information
xenovacivus committed Apr 29, 2014
1 parent de5fa92 commit 6674171
Show file tree
Hide file tree
Showing 20 changed files with 968 additions and 886 deletions.
36 changes: 19 additions & 17 deletions GUI/COMPortForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 43 additions & 28 deletions GUI/COMPortForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,14 @@ public COMPortForm(SerialPortWrapper p)
}
else
{
if (listBox1.SelectedItem == null)
if (comboBox1.SelectedItem == null || comboBox1.SelectedItem == "")
{
connect.Enabled = false;
}
//if (listBox1.SelectedItem == null)
//{
// connect.Enabled = false;
//}
}

t = new Timer();
Expand All @@ -54,41 +58,47 @@ public COMPortForm(SerialPortWrapper p)
void t_Tick(object sender, EventArgs e)
{
string [] s = port.PortNames;
bool matched = true;
if (s.Length != portNames.Length)
if (s.Length == portNames.Length)
{
matched = false;
// No change in items, do nothing.
return;
}

if (!matched)
{
object selectedObject = listBox1.SelectedItem;
portNames = s;

portNames = s;
listBox1.Items.Clear();
listBox1.Items.AddRange(portNames);

if (selectedObject != null)
{
string str = selectedObject.ToString();
SelectPortName(str);
}
if (listBox1.SelectedItem == null && !port.IsOpen)
{
connect.Enabled = false;
}
}
string lastSelected = comboBox1.SelectedItem as string;

comboBox1.Items.Clear();
comboBox1.Items.AddRange(portNames);

SelectPortName(lastSelected);

comboBox1_SelectedIndexChanged(null, EventArgs.Empty);
}

private void SelectPortName(string name)
{
for (int i = 0; i < listBox1.Items.Count; i++)
if (name == null)
{
if (listBox1.Items[i].ToString() == name)
{
listBox1.SelectedIndex = i;
}
return;
}
var index = comboBox1.Items.IndexOf(name);
if (index >= 0)
{
comboBox1.SelectedIndex = index;
}
else if (name != null && name != "")
{
comboBox1.Items.Insert(0, name);
comboBox1.SelectedIndex = 0;
}
//for (int i = 0; i < listBox1.Items.Count; i++)
//{
// if (listBox1.Items[i].ToString() == name)
// {
// listBox1.SelectedIndex = i;
// }
//}
}

private void connect_Click(object sender, EventArgs e)
Expand All @@ -103,7 +113,7 @@ private void connect_Click(object sender, EventArgs e)
try
{
int baudRate = Convert.ToInt32(this.baudBox.Text);
string portName = listBox1.SelectedItem.ToString();
string portName = comboBox1.Text;
port.Open(portName, baudRate);
connect.Text = "Disconnect";
}
Expand All @@ -123,10 +133,15 @@ private void connect_Click(object sender, EventArgs e)
}

private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{

}

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (!port.IsOpen)
{
if (listBox1.SelectedItem != null)
if (comboBox1.SelectedItem != null)
{
this.connect.Enabled = true;
}
Expand Down
4 changes: 2 additions & 2 deletions GUI/COMPortForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
12 changes: 9 additions & 3 deletions GUI/PathCAM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ private void InitializeComponent()
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(183, 23);
this.button2.TabIndex = 1;
this.button2.Text = "Add Perimeter Paths";
this.button2.Text = "Add Cutting Paths";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.PermiterRoutsClick);
//
Expand Down Expand Up @@ -353,7 +353,7 @@ private void InitializeComponent()
this.boundaryCheck.Name = "boundaryCheck";
this.boundaryCheck.Size = new System.Drawing.Size(183, 23);
this.boundaryCheck.TabIndex = 2;
this.boundaryCheck.Text = "Boundary Check Paths";
this.boundaryCheck.Text = "Add Boundary Path";
this.boundaryCheck.UseVisualStyleBackColor = true;
this.boundaryCheck.Click += new System.EventHandler(this.boundaryCheckButton_Click);
//
Expand Down Expand Up @@ -411,9 +411,10 @@ private void InitializeComponent()
this.robotControl.BackColor = System.Drawing.Color.Transparent;
this.robotControl.Location = new System.Drawing.Point(-1, 427);
this.robotControl.Name = "robotControl";
this.robotControl.Size = new System.Drawing.Size(273, 136);
this.robotControl.Size = new System.Drawing.Size(169, 136);
this.robotControl.TabIndex = 8;
this.robotControl.Visible = false;
this.robotControl.Load += new System.EventHandler(this.robotControl_Load);
//
// drawing3D
//
Expand Down Expand Up @@ -489,5 +490,10 @@ private void PathCAM_Load(object sender, EventArgs e)
robotControl.Location = new Point(0, ClientRectangle.Height - robotControl.Height);
showRobotFormCheckbox.Location = new Point(0, ClientRectangle.Height - showRobotFormCheckbox.Height + 1);
}

private void robotControl_Load(object sender, EventArgs e)
{

}
}
}
24 changes: 18 additions & 6 deletions GUI/RobotControl.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion GUI/RobotControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void RobotStatusUpdate(object o, EventArgs e)
}
else
{
StatusCommand status = o as StatusCommand;
IRobotCommandWithStatus status = o as IRobotCommandWithStatus;
if (status != null)
{
this.runButton.Enabled = true;
Expand Down
4 changes: 2 additions & 2 deletions GUI/RobotGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ public PreviousPoint(float time, Vector3 location)
Vector3 lastPosition;
void RouterPositionUpdate(object o, EventArgs e)
{
StatusCommand status = o as StatusCommand;
IRobotCommandWithStatus status = o as IRobotCommandWithStatus;
if (status != null)
{
Vector3 position = status.CurrentPosition;
float time = status.time;
float time = status.Time;
float distance = (lastPosition - position).Length;

if ((lastPosition - position).Length > 0.0001f)
Expand Down
Binary file modified Installer/PathCAM.msi
Binary file not shown.
Loading

0 comments on commit 6674171

Please sign in to comment.