-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
351 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* GRBL-Plotter. Another GCode sender for GRBL. | ||
This file is part of the GRBL-Plotter application. | ||
Copyright (C) 2015-2023 Sven Hasemann contact: [email protected] | ||
Copyright (C) 2015-2024 Sven Hasemann contact: [email protected] | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
|
@@ -75,6 +75,8 @@ public partial class MainForm : Form | |
private bool manualEdit = false; | ||
private readonly bool logMain = false; | ||
|
||
private int globalCollectionCounter = 1; | ||
|
||
#region fCTB FastColoredTextBox related | ||
// highlight code in editor | ||
// 0 : Black, 105 : DimGray , 128 : Gray, 169 : DarkGray!, 192 : Silver, 211 : LightGray , 220 : Gainsboro, 245 : Ghostwhite, 255 : White | ||
|
@@ -143,10 +145,6 @@ private void MarkErrorLine(int line) | |
{ | ||
if (LineIsInRange(line)) | ||
{ | ||
// SetTextSelection(line, line); | ||
// fCTBCode.Selection.ClearStyle(StyleGWord, StyleXAxis, StyleYAxis); | ||
// fCTBCode.Selection.SetStyle(ErrorStyle); | ||
|
||
if (this.fCTBCode.InvokeRequired) | ||
{ | ||
this.fCTBCode.BeginInvoke((MethodInvoker)delegate () | ||
|
@@ -174,12 +172,6 @@ private void ClearErrorLines() | |
{ | ||
if (LineIsInRange(myline)) | ||
{ | ||
// SetTextSelection(myline, myline); | ||
// fCTBCode.Selection.ClearStyle(ErrorStyle); | ||
// fCTBCode.Selection.SetStyle(StyleGWord); | ||
// fCTBCode.Selection.SetStyle(StyleXAxis); | ||
// fCTBCode.Selection.SetStyle(StyleYAxis); | ||
|
||
if (this.fCTBCode.InvokeRequired) | ||
{ | ||
this.fCTBCode.BeginInvoke((MethodInvoker)delegate () | ||
|
@@ -354,7 +346,7 @@ private void InsertTextAtLine(int line, string text) | |
else | ||
{ Logger.Error("InsertTextAtLine LineIsNOTInRange: {0}", line); } | ||
} | ||
|
||
System.Drawing.Point codeInsert = new System.Drawing.Point(); | ||
private int InsertCodeToFctb(string sourceGCode, bool fromFile, int lineSelected, double offsetX, double offsetY) | ||
{ | ||
/* if graphic import, add new group, | ||
|
@@ -373,6 +365,8 @@ private int InsertCodeToFctb(string sourceGCode, bool fromFile, int lineSelected | |
bool containsGroup = sourceGCode.Contains(XmlMarker.GroupStart); | ||
bool containsFigure = sourceGCode.Contains(XmlMarker.FigureStart); | ||
|
||
int newID = 0; | ||
|
||
if (fromFile) | ||
{ | ||
if (insertLineCollection > 0) | ||
|
@@ -428,7 +422,7 @@ private int InsertCodeToFctb(string sourceGCode, bool fromFile, int lineSelected | |
string line; | ||
int figureCount = 1; | ||
|
||
if(!containsCollection) { tmpCodeFinish.AppendLine(string.Format("{0} \">", XmlMarker.CollectionStart)); } | ||
if(!containsCollection) { tmpCodeFinish.AppendLine(string.Format("({0} Id=\"{1}\">)", XmlMarker.CollectionStart, globalCollectionCounter++)); } | ||
|
||
for (int k = 0; k < tmpCodeLines.Length; k++) // go through code-lines to insert | ||
{ | ||
|
@@ -451,6 +445,7 @@ private int InsertCodeToFctb(string sourceGCode, bool fromFile, int lineSelected | |
// Logger.Info("getGCodeFromText figure idStart:{0} digits:{1} final:{2} string:'{3}'-'{4}'", idStart, idCount.ToString().Length, strtIndex, line.Substring(0, idStart), line.Substring(strtIndex)); | ||
line = tmp; | ||
} | ||
newID = idCount; | ||
} | ||
if (line.Contains(XmlMarker.FigureStart)) // find figure-tag and increment id | ||
{ | ||
|
@@ -469,6 +464,7 @@ private int InsertCodeToFctb(string sourceGCode, bool fromFile, int lineSelected | |
// Logger.Info("getGCodeFromText figure idStart:{0} digits:{1} final:{2} string:'{3}'-'{4}'", idStart, idCount.ToString().Length, strtIndex, line.Substring(0, idStart), line.Substring(strtIndex)); | ||
line = tmp; | ||
} | ||
newID = idCount; | ||
} | ||
} | ||
|
||
|
@@ -483,7 +479,7 @@ private int InsertCodeToFctb(string sourceGCode, bool fromFile, int lineSelected | |
} | ||
if (line.Contains(XmlMarker.CollectionEnd)) useCode = false; | ||
} | ||
if (!containsCollection) { tmpCodeFinish.AppendLine(string.Format("{0} \">", XmlMarker.CollectionEnd)); } | ||
if (!containsCollection) { tmpCodeFinish.AppendLine(string.Format("({0} >)", XmlMarker.CollectionEnd)); } | ||
|
||
if (createGroup) | ||
{ tmpCodeFinish.AppendLine("(" + XmlMarker.CollectionStart + " Id=\"0\" Type=\"Existing code\" >)"); } // add startGroup for existing figures | ||
|
@@ -500,12 +496,14 @@ private int InsertCodeToFctb(string sourceGCode, bool fromFile, int lineSelected | |
|
||
} | ||
Logger.Info("◆◆◆◆ Insert code to existing code at line {0}", insertLineNr); | ||
codeInsert = new System.Drawing.Point(insertLineNr, newID); | ||
return insertLineNr; | ||
} | ||
else | ||
{ | ||
fCTBCode.Text = sourceGCode; | ||
Logger.Warn("⚠⚠⚠ Insert code was not possible at line: {0}", insertLineNr); | ||
codeInsert=new System.Drawing.Point(-1, -1); | ||
return -1; | ||
} | ||
} | ||
|
@@ -939,7 +937,7 @@ private bool FindFigureMarkSelection(XmlMarkerType marker, int clickedLine, Dist | |
|
||
fCTBCode.Selection.ColumnSelectionMode = false; | ||
|
||
bool gcodeIsSeleced = false; ; | ||
bool gcodeIsSeleced = false; | ||
EnableBlockCommands(gcodeIsSeleced); | ||
|
||
markedBlockType = marker; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* GRBL-Plotter. Another GCode sender for GRBL. | ||
This file is part of the GRBL-Plotter application. | ||
Copyright (C) 2015-2023 Sven Hasemann contact: [email protected] | ||
Copyright (C) 2015-2024 Sven Hasemann contact: [email protected] | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
|
@@ -151,6 +151,7 @@ private void InsertCodeFromForm(string sourceGCode, string sourceForm, GraphicsP | |
insertLineNr = XmlMarker.FindInsertPositionFigureMostTop(-1); // no group? find figure | ||
createGroup = true; | ||
} | ||
codeInsert=new System.Drawing.Point(insertLineNr, 0); | ||
|
||
Logger.Info("▀▀▀▀▀▀ InsertCodeFromForm:{0} insertCode:{1} insertAt:{2}", sourceForm, insertCode, insertLineNr); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* GRBL-Plotter. Another GCode sender for GRBL. | ||
This file is part of the GRBL-Plotter application. | ||
Copyright (C) 2015-2023 Sven Hasemann contact: [email protected] | ||
Copyright (C) 2015-2024 Sven Hasemann contact: [email protected] | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
|
@@ -25,6 +25,8 @@ You should have received a copy of the GNU General Public License | |
* 2021-11-18 add processing of accessory D0-D3 from grbl-Mega-5X - line 139 | ||
* 2022-02-24 | ||
* 2023-03-09 simplify NULL check; case GrblState.unknown: UpdateControlEnables(); | ||
* 2024-02-14 l:160 f:ProcessStatusMessage add grblDigialIn -Out | ||
* 2024-02-24 l:61 f:OnRaisePosEvent submit Grbl.StatMsg | ||
*/ | ||
|
||
using System; | ||
|
@@ -57,6 +59,7 @@ private void OnRaisePosEvent(object sender, PosEventArgs e) | |
{ | ||
// if (logPosEvent) Logger.Trace("OnRaisePosEvent {0} connect {1} status {2}", e.Status.ToString(), _serial_form.serialPortOpen, e.Status.ToString()); | ||
Grbl.Status = machineStatus = e.Status; | ||
Grbl.StatMsg = e.StatMsg; | ||
|
||
/***** Restore saved position after reset and set initial feed rate: *****/ | ||
if (ResetDetected || (e.Status == GrblState.reset)) | ||
|
@@ -157,8 +160,17 @@ private void ProcessStatusMessage(ModState StatMsg) | |
if (StatMsg.A.Contains("D")) | ||
{ | ||
string digits = StatMsg.A.Substring(StatMsg.A.IndexOf("D") + 1); // Digital pins in order '3210' | ||
int din = 0; | ||
int dout = 0; | ||
if (digits.Length == 4) | ||
{ | ||
for (int i=0; i<4; i++) | ||
{ dout |= ((digits[i] == '1')? 1:0) << (3-i); } | ||
/* SetAccessoryButton(BtnOverrideD3, (dout & 8)); | ||
SetAccessoryButton(BtnOverrideD2, (dout & 4)); | ||
SetAccessoryButton(BtnOverrideD1, (dout & 2)); | ||
SetAccessoryButton(BtnOverrideD0, (dout & 1)); | ||
*/ | ||
SetAccessoryButton(BtnOverrideD3, (digits[0] == '1')); | ||
SetAccessoryButton(BtnOverrideD2, (digits[1] == '1')); | ||
SetAccessoryButton(BtnOverrideD1, (digits[2] == '1')); | ||
|
@@ -170,15 +182,21 @@ private void ProcessStatusMessage(ModState StatMsg) | |
} | ||
else if (digits.Length == 8) | ||
{ | ||
for (int i=0; i<4; i++) | ||
{ din |= ((digits[i] == '1')? 1:0) << i; } | ||
BtnOverrideD3.BackColor = (digits[0] == '1') ? Color.Honeydew : Color.LightPink; | ||
BtnOverrideD2.BackColor = (digits[1] == '1') ? Color.Honeydew : Color.LightPink; | ||
BtnOverrideD1.BackColor = (digits[2] == '1') ? Color.Honeydew : Color.LightPink; | ||
BtnOverrideD0.BackColor = (digits[3] == '1') ? Color.Honeydew : Color.LightPink; | ||
for (int i=4; i<8; i++) | ||
{ dout |= ((digits[i] == '1')? 1:0) << (7-i-4); } | ||
SetAccessoryButton(BtnOverrideD3, (digits[4] == '1')); | ||
SetAccessoryButton(BtnOverrideD2, (digits[5] == '1')); | ||
SetAccessoryButton(BtnOverrideD1, (digits[6] == '1')); | ||
SetAccessoryButton(BtnOverrideD0, (digits[7] == '1')); | ||
} | ||
Grbl.grblDigitalIn = (byte)din; | ||
Grbl.grblDigitalOut = (byte)dout; | ||
} | ||
else | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.