Skip to content

Commit

Permalink
Version 1.7.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
svenhb authored Feb 25, 2024
1 parent e96cd51 commit bc76d9c
Show file tree
Hide file tree
Showing 10 changed files with 351 additions and 103 deletions.
1 change: 1 addition & 0 deletions GRBL-Plotter/GUI/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1253,6 +1253,7 @@ private void ProcessCommands(string command)
var MyIni = new IniFile(command);
Logger.Info(culture, "Load INI: '{0}'", command);
MyIni.ReadAll(); // ReadImport();
UpdateIniVariables();
timerUpdateControlSource = "loadFile";
UpdateWholeApplication();
StatusStripSet(2, "INI File '" + command + "' loaded", Color.Lime);
Expand Down
2 changes: 1 addition & 1 deletion GRBL-Plotter/GUI/MainForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
<value>1</value>
</data>
<data name="fCTBCode.AutoScrollMinSize" type="System.Drawing.Size, System.Drawing">
<value>214, 12</value>
<value>191, 12</value>
</data>
<metadata name="cmsFCTB.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>123, 56</value>
Expand Down
28 changes: 13 additions & 15 deletions GRBL-Plotter/GUI/MainFormFCTB.cs
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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ()
Expand Down Expand Up @@ -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 ()
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Expand Down Expand Up @@ -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
{
Expand All @@ -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
{
Expand All @@ -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;
}
}

Expand All @@ -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
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion GRBL-Plotter/GUI/MainFormGetCodeTransform.cs
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
Expand Down Expand Up @@ -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);

Expand Down
20 changes: 19 additions & 1 deletion GRBL-Plotter/GUI/MainFormInterface.cs
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
Expand All @@ -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;
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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'));
Expand All @@ -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
{
Expand Down
3 changes: 3 additions & 0 deletions GRBL-Plotter/GUI/MainFormLoadFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ private bool LoadFile(string fileName)
var MyIni = new IniFile(fileName);
Logger.Info("Load INI: '{0}'", fileName);
MyIni.ReadAll(); // ReadImport();
UpdateIniVariables();
timerUpdateControlSource = "loadFile";
UpdateControlEnables();
UpdateWholeApplication();
Expand Down Expand Up @@ -853,6 +854,7 @@ private void TbURL_TextChanged(object sender, EventArgs e)
Logger.Info("Load INI (URL): '{0}'", tBURL.Text);
var MyIni = new IniFile(tBURL.Text, true);
MyIni.ReadAll(); // ReadImport();
UpdateIniVariables();
timerUpdateControlSource = "tBURL_TextChanged";
UpdateControlEnables();
UpdateWholeApplication();
Expand Down Expand Up @@ -1759,6 +1761,7 @@ private void LoadMachineParametersToolStripMenuItem_Click(object sender, EventAr
{
var MyIni = new IniFile(openFileDialog1.FileName);
MyIni.ReadAll();
UpdateIniVariables();
LoadSettings(sender, e);
Logger.Info("Load machine parameters as {0}", openFileDialog1.FileName);
}
Expand Down
Loading

0 comments on commit bc76d9c

Please sign in to comment.