diff --git a/CHANGES.txt b/CHANGES.txt
index 4f287e3..6fcef9e 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,7 @@
This file documents changes made:
+V1.0.9.7 - 2016 Oct 12
+ - Adapt to new Gbrl 1.1a reports, etc.
+ - Added button to clear Pin states, makes them latch on even a single report
V1.0.9.6 - 2016 Aug 27
- Change spacebar to control Hold/Resume Issue #62
- Enable use of Enter for Grbl Settings and Offsets
diff --git a/Grbl-Panel/CHANGES.txt b/Grbl-Panel/CHANGES.txt
index 4f287e3..6fcef9e 100644
--- a/Grbl-Panel/CHANGES.txt
+++ b/Grbl-Panel/CHANGES.txt
@@ -1,4 +1,7 @@
This file documents changes made:
+V1.0.9.7 - 2016 Oct 12
+ - Adapt to new Gbrl 1.1a reports, etc.
+ - Added button to clear Pin states, makes them latch on even a single report
V1.0.9.6 - 2016 Aug 27
- Change spacebar to control Hold/Resume Issue #62
- Enable use of Enter for Grbl Settings and Offsets
diff --git a/Grbl-Panel/GrblGcode.vb b/Grbl-Panel/GrblGcode.vb
index 7c846a2..673b857 100644
--- a/Grbl-Panel/GrblGcode.vb
+++ b/Grbl-Panel/GrblGcode.vb
@@ -104,7 +104,7 @@ Partial Class GrblGui
_runMode = False
gcodeview.fileMode = False
- If Not (data.StartsWith("$") Or data.StartsWith("?")) Then
+ If (data.StartsWith("$J") Or Not (data.StartsWith("$") Or data.StartsWith("?"))) Then
' add to display
' _gui.gcodeview.Insert(data, 0)
With gcodeview
diff --git a/Grbl-Panel/GrblGui.vb b/Grbl-Panel/GrblGui.vb
index 38f63ff..549bc47 100644
--- a/Grbl-Panel/GrblGui.vb
+++ b/Grbl-Panel/GrblGui.vb
@@ -5,6 +5,7 @@ Imports System.Threading.Thread
Public Class GrblGui
+ Public GrblVersion As Integer ' 0 for 0.x, 1 for 1.x version
Public WithEvents grblPort As GrblIF ' Public so that the timer thread can see grblPort
Private status As GrblStatus ' For status polling
Private jogging As GrblJogging ' for jogging control
@@ -15,7 +16,7 @@ Public Class GrblGui
Public state As GrblState ' to track gcode state
Public settings As GrblSettings ' To handle Settings related ops
Public ovrrides As GrblOverrides ' to display overrides
- Public pins As GrblPins ' to display pin states
+ Public pins As GrblPins ' to display Pin states
Private _exitClicked As Boolean = False ' to separate Close (x) from File/Exit
@@ -491,7 +492,7 @@ Public Class GrblGui
gbSettingsPosition.Enabled = False
gbGrblSettings.Enabled = False
- btnStatusGetParser.Enabled = False
+ btnStatusClearPins.Enabled = False
Case "Disconnected"
' We are not connected so not much you can do
gbJogging.Enabled = False
@@ -506,7 +507,7 @@ Public Class GrblGui
gbSettingsPosition.Enabled = False
gbGrblSettings.Enabled = False
- btnStatusGetParser.Enabled = False
+ btnStatusClearPins.Enabled = False
Case "Idle"
' General use, no gcode streaming
gbJogging.Enabled = True
@@ -521,7 +522,7 @@ Public Class GrblGui
gbSettingsPosition.Enabled = True
gbGrblSettings.Enabled = True
- btnStatusGetParser.Enabled = True
+ btnStatusClearPins.Enabled = True
End Select
End Sub
diff --git a/Grbl-Panel/GrblJogging.vb b/Grbl-Panel/GrblJogging.vb
index bbb086b..74e2056 100644
--- a/Grbl-Panel/GrblJogging.vb
+++ b/Grbl-Panel/GrblJogging.vb
@@ -71,7 +71,9 @@ Partial Class GrblGui
Case "Z-"
gcode.sendGCodeLine(createJogCommand("Z-"))
End Select
- gcode.sendGCodeLine("G90")
+ If GrblVersion = 0 Then
+ gcode.sendGCodeLine("G90")
+ End If
End Sub
Private Sub cbSettingsMetric_CheckedChanged(sender As Object, e As EventArgs) Handles cbSettingsMetric.CheckedChanged
@@ -134,7 +136,12 @@ Partial Class GrblGui
Public Function createJogCommand(ByVal axis As String) As String
' Builds a jog command from various inputs
' Jog in incremental mode, leave parser in absolute mode!
- Return "G91 " + whichUnits() + " G01 " + axis + whichDistance() + " F" + whichFeedRate()
+ If GrblVersion = 0 Then
+ Return "G91 " + whichUnits() + " G01 " + axis + whichDistance() + " F" + whichFeedRate()
+ End If
+ If GrblVersion = 1 Then
+ Return "$J=G91" + whichUnits() + axis + whichDistance() + " F" + whichFeedRate()
+ End If
End Function
'''
''' Return value of current Distance Increment
diff --git a/Grbl-Panel/GrblOverrides.vb b/Grbl-Panel/GrblOverrides.vb
index 2b3ff9c..497314c 100644
--- a/Grbl-Panel/GrblOverrides.vb
+++ b/Grbl-Panel/GrblOverrides.vb
@@ -6,9 +6,10 @@ Partial Class grblgui
''' Class to handle overrides related functionality
'''
Public Enum overrideChars
- CMD_SAFETY_DOOR = 132 '0x84
- CMD_DEBUG_REPORT = 133 '0x85 ' Only When DEBUG enabled, sends debug report In '{}' braces.
- CMD_FEED_OVR_RESET = 144 '0x90 ' Restores feed override value To 100%.
+ CMD_SAFETY_DOOR = 132 '0x84
+ CMD_JOG_CANCEL = 133 ' 0x85
+ CMD_DEBUG_REPORT = 133 '0x86 ' Only When DEBUG enabled, sends debug report In '{}' braces.
+ CMD_FEED_OVR_RESET = 144 '0x90 ' Restores feed override value To 100%.
CMD_FEED_OVR_COARSE_PLUS = 145 '0x91
CMD_FEED_OVR_COARSE_MINUS = 146 ' 0x92
CMD_FEED_OVR_FINE_PLUS = 147 ' 0x93
@@ -17,12 +18,14 @@ Partial Class grblgui
CMD_RAPID_OVR_MEDIUM = 150 '0x96
CMD_RAPID_OVR_LOW = 151 ' 0x97
' CMD_RAPID_OVR_EXTRA_LOW 0x98 ' *Not SUPPORTED*
- CMD_SPINDLE_OVR_RESET = 153 ' 0x99 ' Restores spindle override value To 100%.
+ CMD_SPINDLE_OVR_RESET = 153 ' 0x99 ' Restores spindle override value To 100%.
CMD_SPINDLE_OVR_COARSE_PLUS = 154 ' 0x9A
CMD_SPINDLE_OVR_COARSE_MINUS = 155 ' 0x9B
CMD_SPINDLE_OVR_FINE_PLUS = 156 ' 0x9C
CMD_SPINDLE_OVR_FINE_MINUS = 157 '0x9D
- CMD_SPINDLE_OVR_STOP = 158 '0x9E
+ CMD_SPINDLE_OVR_STOP = 158 '0x9E aka Toogle Spindle Stop
+ CMD_TOGGLE_FLOOD = 160 ' 0xA0
+ CMD_TOGGLE_MIST = 161 ' 0xA1
End Enum
Public Class GrblOverrides
Private _gui As GrblGui
@@ -58,20 +61,43 @@ Partial Class grblgui
Public Sub showOverrides(ByVal data As String)
- Dim _ovrIndex As Integer
- Dim _ovr As String()
-
- _ovrIndex = data.LastIndexOf("OVR:")
- If _ovrIndex = -1 Then
- Return
- Else
- data = data.Remove(data.Length - 3, 3) ' Remove > and vbCrLf
- ' We have Grbl V1.0 or later so display overrides
- _ovr = data.Substring(_ovrIndex + 4).Split(",")
- tbFeedOvr.Text = _ovr(0) + "%"
- tbRapidOvr.Text = _ovr(1) + "%"
- tbSpindleOvr.Text = _ovr(2) + "%"
+ ' Process Override values, Grbl 1.x only
+ If data.Contains("Ov:") Or data.Contains("T:") Then
+ data = data.Remove(data.Length - 3, 3)
+ Dim statusMessage = Split(data, "|")
+ For Each item As String In statusMessage
+ Dim portion() As String = Split(item, ":")
+ Select Case portion(0)
+ Case "Ov"
+ Dim ovr = Split(portion(1), ",")
+ tbFeedOvr.Text = ovr(0) + "%"
+ tbRapidOvr.Text = ovr(1) + "%"
+ tbSpindleOvr.Text = ovr(2) + "%"
+ If Not data.Contains("T") Then
+ btnSpindleOverride.BackColor = Color.Transparent
+ End If
+ Case "T"
+ If portion(1).Contains("S") Then
+ btnSpindleOverride.BackColor = Color.Crimson
+ End If
+ If portion(1).Contains("F") Then
+ If btnFloodOverride.BackColor = Color.Crimson Then
+ btnFloodOverride.BackColor = Color.Transparent
+ Else
+ btnFloodOverride.BackColor = Color.Crimson
+ End If
+ End If
+ If portion(1).Contains("M") Then
+ If btnMistOverride.BackColor = Color.Crimson Then
+ btnMistOverride.BackColor = Color.Transparent
+ Else
+ btnMistOverride.BackColor = Color.Crimson
+ End If
+ End If
+ End Select
+ Next
End If
+
End Sub
'''
''' Handles the Click event of the btnFeedOverride controls.
@@ -137,9 +163,27 @@ Partial Class grblgui
grblPort.sendData(Chr(overrideChars.CMD_SPINDLE_OVR_RESET))
End Select
End Sub
+ '''
+ ''' Handle toggle of some overrides, constrained by present state
+ '''
+ '''
+ '''
+ Private Sub btnToggleOverride_Click(sender As Object, e As EventArgs) Handles btnSpindleOverride.Click, btnMistOverride.Click, btnFloodOverride.Click
+ ' Spindle toggle only in Hold
+ ' Coolant and Mist in Idle,Run or Hold
+ Dim btn As Button = sender
+ Select Case DirectCast(btn.Tag, String)
+ Case "SpindleOverride"
+ grblPort.sendData(Chr(overrideChars.CMD_SPINDLE_OVR_STOP))
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnRapidMinus.Click
-
- grblPort.sendData(Chr(overrideChars.CMD_DEBUG_REPORT))
+ If btnSpindleOverride.BackColor = Color.Crimson Then
+ btnSpindleOverride.BackColor = Color.Transparent
+ End If
+ Case "FloodOverride"
+ grblPort.sendData(Chr(overrideChars.CMD_TOGGLE_FLOOD))
+ Case "MistOverride"
+ grblPort.sendData(Chr(overrideChars.CMD_TOGGLE_MIST))
+ End Select
+ ' btn colour changes based on T:SFM response handled in showOverrides()
End Sub
End Class
diff --git a/Grbl-Panel/GrblPins.vb b/Grbl-Panel/GrblPins.vb
index 1edae0f..d9e7022 100644
--- a/Grbl-Panel/GrblPins.vb
+++ b/Grbl-Panel/GrblPins.vb
@@ -60,6 +60,9 @@ Partial Class GrblGui
_gui.gbPinStatus.Visible = value
If value = True Then
With _gui
+ .cbLimitX.Visible = True
+ .cbLimitY.Visible = True
+ .cbLimitZ.Visible = True
.cbProbePin.Visible = True
.cbResetAbort.Visible = True
.cbFeedHold.Visible = True
@@ -76,38 +79,63 @@ Partial Class GrblGui
Public Sub showGrblPins(ByVal data As String)
Dim pos As Integer
- If data(0) = vbLf Or data(0) = vbCr Then
- Return ' nothing to do
- End If
+ If data = vbCrLf Then Return
- ' Show X, Y, Z limit pin state
- If Not pins.LimitsSeen Then
- If data.Contains("Lim:") Or data.Contains("Pin:") Then
+ ' We are on Grbl 0.9
+ If GrblVersion = 0 And data.Contains("Lim:") Then
+ ' We need to show Limit pins
+ If Not pins.LimitsSeen Then
pins.LimitsSeen = True
End If
- End If
-
- If Not pins.PinsSeen Then
- If data.Contains("Pin:") Then
- pins.PinsSeen = True
- End If
- End If
-
- If data.Contains("Lim:") Or data.Contains("Pin:") Then
- ' We need to show Limit pins
- pos = InStr(data, "Lim:") + InStr(data, "Pin:")
+ pos = InStr(data, "Lim:")
cbLimitZ.Checked = (data(pos + 3) = "1")
cbLimitY.Checked = (data(pos + 4) = "1")
cbLimitX.Checked = (data(pos + 5) = "1")
End If
- ' pos 6 and 8 are delimiters "|"
- If data.Contains("Pin:") Then
- ' Show other pins
- cbProbePin.Checked = (data(pos + 7) = "0")
- cbStartResume.Checked = (data(pos + 9) = "1")
- cbFeedHold.Checked = (data(pos + 10) = "1")
- cbResetAbort.Checked = (data(pos + 11) = "1")
+ ' Are we on Grbl 1.0 or later?
+ If GrblVersion = 1 And data(0) = "<" Then
+ If data.Contains("Pn:") Then
+ ' Show other pins
+ Dim pinlist As String
+ If Not pins.PinsSeen Then
+ pins.PinsSeen = True
+ End If
+ data = data.Remove(data.Length - 3, 3)
+ Dim statusMessage = Split(data, "|")
+ For Each item As String In statusMessage
+ Dim portion() As String = Split(item, ":")
+ Select Case portion(0)
+ Case "Pn"
+ pinlist = portion(1)
+ cbProbePin.Checked = InStr(pinlist, "P")
+ cbDoorOpen.Checked = InStr(pinlist, "D")
+ cbFeedHold.Checked = InStr(pinlist, "H")
+ cbResetAbort.Checked = InStr(pinlist, "R")
+ cbStartResume.Checked = InStr(pinlist, "S")
+
+ cbLimitX.Checked = InStr(pinlist, "X")
+ cbLimitY.Checked = InStr(pinlist, "Y")
+ cbLimitZ.Checked = InStr(pinlist, "Z")
+ End Select
+ Next
+ ' We don't clear, use the provided button.
+ ' This makes the pin occurance latch
+ End If
End If
End Sub
+
+
+ Private Sub btnStatusClearPins_Click(sender As Object, e As EventArgs) Handles btnStatusClearPins.Click
+ ' Clear pins if set
+ cbProbePin.Checked = False
+ cbDoorOpen.Checked = False
+ cbFeedHold.Checked = False
+ cbResetAbort.Checked = False
+ cbStartResume.Checked = False
+
+ cbLimitX.Checked = False
+ cbLimitY.Checked = False
+ cbLimitZ.Checked = False
+ End Sub
End Class
\ No newline at end of file
diff --git a/Grbl-Panel/GrblPosition.vb b/Grbl-Panel/GrblPosition.vb
index 7c833a5..9e00fc6 100644
--- a/Grbl-Panel/GrblPosition.vb
+++ b/Grbl-Panel/GrblPosition.vb
@@ -41,32 +41,112 @@ Partial Class GrblGui
End If
End Sub
+
+ Private _wcoX As Decimal
+ Public Property wcoX() As Decimal
+ Get
+ Return _wcoX
+ End Get
+ Set(ByVal value As Decimal)
+ _wcoX = value
+ End Set
+ End Property
+ Private _wcoY As Decimal
+ Public Property wcoY() As Decimal
+ Get
+ Return _wcoY
+ End Get
+ Set(ByVal value As Decimal)
+ _wcoY = value
+ End Set
+ End Property
+
+ Private _wcoZ As Decimal
+ Public Property wcoZ() As Decimal
+ Get
+ Return _wcoZ
+ End Get
+ Set(ByVal value As Decimal)
+ _wcoZ = value
+ End Set
+ End Property
End Class
Public Sub showGrblPositions(ByVal data As String)
' Show data in the Positions group (from our own thread)
- If (data.Contains("MPos:")) Then
- ' Lets display the values
- data = data.Remove(data.Length - 3, 3) ' Remove the "> " at end
- Dim positions = Split(data, ":")
- Dim machPos = Split(positions(1), ",")
- Dim workPos = Split(positions(2), ",")
-
- tbMachX.Text = machPos(0).ToString
- tbMachY.Text = machPos(1).ToString
- tbMachZ.Text = machPos(2).ToString
-
- tbWorkX.Text = workPos(0).ToString
- tbWorkY.Text = workPos(1).ToString
- tbWorkZ.Text = workPos(2).ToString
-
- 'Set same values into the repeater view on Offsets page
- tbOffSetsMachX.Text = machPos(0).ToString
- tbOffSetsMachY.Text = machPos(1).ToString
- tbOffSetsMachZ.Text = machPos(2).ToString
+ If data = vbCrLf Then Return
+
+ If GrblVersion = 0 Then
+ ' Grbl versions 0.x
+ If (data.Contains("MPos:")) Then
+ ' Lets display the values
+ data = data.Remove(data.Length - 3, 3) ' Remove the "> " at end
+ Dim positions = Split(data, ":")
+ Dim machPos = Split(positions(1), ",")
+ Dim workPos = Split(positions(2), ",")
+
+ tbMachX.Text = machPos(0).ToString
+ tbMachY.Text = machPos(1).ToString
+ tbMachZ.Text = machPos(2).ToString
+
+ tbWorkX.Text = workPos(0).ToString
+ tbWorkY.Text = workPos(1).ToString
+ tbWorkZ.Text = workPos(2).ToString
+
+ 'Set same values into the repeater view on Offsets page
+ tbOffSetsMachX.Text = machPos(0).ToString
+ tbOffSetsMachY.Text = machPos(1).ToString
+ tbOffSetsMachZ.Text = machPos(2).ToString
+ End If
+ End If
+ If GrblVersion = 1 Then
+ ' Grbl/Gnea versions 1.x
+ If data.StartsWith("<") Then
+ data = data.Remove(data.Length - 3, 3)
+ Dim statusMessage = Split(data, "|")
+ For Each item As String In statusMessage
+ Dim portion() As String = Split(item, ":")
+ ' Pn, Ov, T are handled in their respective objects
+ Select Case portion(0)
+ Case "WCO"
+ ' WCO appears now and then or if it changes
+ Dim wco = Split(portion(1), ",")
+ position.wcoX = wco(0)
+ position.wcoY = wco(1)
+ position.wcoZ = wco(2)
+ Case "MPos"
+ ' We get Mpos but no WPos depending on $10
+ Dim machPos = Split(portion(1), ",")
+ tbMachX.Text = machPos(0).ToString
+ tbMachY.Text = machPos(1).ToString
+ tbMachZ.Text = machPos(2).ToString
+
+ tbWorkX.Text = (machPos(0) - position.wcoX).ToString("0.000")
+ tbWorkY.Text = (machPos(1) - position.wcoY).ToString("0.000")
+ tbWorkZ.Text = (machPos(2) - position.wcoZ).ToString("0.000")
+
+ 'Set same values into the repeater view on Offsets page
+ tbOffSetsMachX.Text = tbMachX.Text
+ tbOffSetsMachY.Text = tbMachY.Text
+ tbOffSetsMachZ.Text = tbMachZ.Text
+ Case "WPos"
+ ' We get WPos but no MPos depending on $10
+ Dim workPos = Split(portion(1), ",")
+ tbWorkX.Text = workPos(0).ToString
+ tbWorkY.Text = workPos(1).ToString
+ tbWorkZ.Text = workPos(2).ToString
+
+ tbMachX.Text = (workPos(0) + position.wcoX).ToString("0.000")
+ tbMachY.Text = (workPos(1) + position.wcoY).ToString("0.000")
+ tbMachZ.Text = (workPos(2) + position.wcoZ).ToString("0.000")
+
+ End Select
+ Next
+
+ End If
End If
End Sub
diff --git a/Grbl-Panel/GrblSettings.vb b/Grbl-Panel/GrblSettings.vb
index 1711e8e..bdbd2a5 100644
--- a/Grbl-Panel/GrblSettings.vb
+++ b/Grbl-Panel/GrblSettings.vb
@@ -154,7 +154,7 @@ Partial Class GrblGui
' Event template for Settings Retrieved indication
Public Event GrblSettingsRetrieved()
- Private newPropertyValue As String
+
Public Sub RefreshSettings()
_nextParam = 0
gcode.sendGCodeLine("$$")
diff --git a/Grbl-Panel/GrblState.vb b/Grbl-Panel/GrblState.vb
index e6325e5..1c93d08 100644
--- a/Grbl-Panel/GrblState.vb
+++ b/Grbl-Panel/GrblState.vb
@@ -24,7 +24,7 @@
End If
End Sub
- Private Sub GrblConnected(ByVal msg As String) ' Handles GrblGui.Connected Event
+ Public Sub GrblConnected(ByVal msg As String) ' Handles GrblGui.Connected Event
If msg = "Connected" Then
' We are connected to Grbl so populate the State
diff --git a/Grbl-Panel/GrblStatus.vb b/Grbl-Panel/GrblStatus.vb
index 12a4125..b629a99 100644
--- a/Grbl-Panel/GrblStatus.vb
+++ b/Grbl-Panel/GrblStatus.vb
@@ -106,13 +106,7 @@ Partial Class GrblGui
grblPort.sendData("~")
End Sub
- Private Sub btnStatusGetParser_Click(sender As Object, e As EventArgs) Handles btnStatusGetParser.Click
- ' Send request for Parser State, response handler picks it up and displays
- grblPort.sendData("$G")
- End Sub
-
Public Sub showGrblStatus(ByVal data As String)
-
' TODO This needs tidying up, pre-process message to remove leading, trailing < [ , etc. so
' we have a clean code flow below, create a messageType variable?
'Console.WriteLine("showGrblStatus: " + data)
@@ -140,72 +134,156 @@ Partial Class GrblGui
Me.lbResponses.TopIndex = Me.lbResponses.Items.Count - 1
End If
- ' Split out the Q and Buffer sizes
- ' (Look for Buf:nn,RX:nnn)
- If (data.Contains("Buf:")) Then
- ' Lets display the values
- data = data.Remove(data.Length - 3, 3) ' Remove the "> " at end
- Dim positions = Split(data, ":")
- Try
- Dim buffer = Split(positions(3), ",")
- Dim rx = Split(positions(4), ",")
- prgbRxBuf.Value = rx(0)
- prgBarQ.Value = buffer(0)
- Catch
- ' do nothing, should have Status Report mask = 15
- End Try
- End If
+ If data.StartsWith("Grbl") Then
+ ' set Grbl version, 0.x or 1.x
+ GrblVersion = data.Substring(5, 1)
+ If GrblVersion = 1 Then
+ pins.PinsSeen = True ' Show all pins
+ Else
+ pins.LimitsSeen = True ' Show limit pins only
+ End If
- ' Show status on the buttons
- ' Extract status
- Dim status = Split(data, ",")
- ' Set indicators
- If Not IsNothing(status) Then 'And status(0).StartsWith("<") Then
- statusSetIndicators(status(0))
- End If
+ ' Something reset the Grbl device, likely a physical Reset
+ ' Stop what we are doing and clear out for restart
+ state.GrblConnected("Connected") ' Reset State object
+ gcode.ResetGcode(False)
- ' Set button states
- If status(0) = " " at end
+ Dim positions = Split(data, ":")
+ Try
+ Dim buffer = Split(positions(3), ",")
+ Dim rx = Split(positions(4), ",")
+ prgbRxBuf.Value = rx(0)
+ prgBarQ.Value = buffer(0)
+ Catch
+ ' do nothing, should have Status Report mask = 15
+ End Try
+ End If
+
+ ' Show status on the buttons
+ ' Extract status
+ Dim status = Split(data, ",")
+ ' Set indicators
+ If Not IsNothing(status) Then 'And status(0).StartsWith("<") Then
+ statusSetIndicators(status(0))
+ End If
- ' Display the Parser state if that is the message type
- If data(0) = "[" And data.Contains("F") Then ' we have a Parser status message
- state.ProcessGCode(data)
+ ' Set button states
+ If status(0) = "