From d567ca2a91eb8b1f0da7c11ece6e083a1dcccbf2 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Mon, 11 Jun 2018 18:10:16 -0700 Subject: [PATCH] Improved marlin eeprom settings did not implement lcd brightness issue: MatterHackers/MCCentral#3526 Reading and saving wrong values to EEPROM --- EeProm/EePromMarlinSettings.cs | 141 ++++++++++++++++++++++++++++++--- EeProm/EePromMarlinWindow.cs | 42 +++++++--- 2 files changed, 161 insertions(+), 22 deletions(-) diff --git a/EeProm/EePromMarlinSettings.cs b/EeProm/EePromMarlinSettings.cs index c5e133ce5..9c944fa17 100644 --- a/EeProm/EePromMarlinSettings.cs +++ b/EeProm/EePromMarlinSettings.cs @@ -53,20 +53,27 @@ namespace MatterHackers.MatterControl.EeProm public string ay = "0"; public string az = "0"; public string ae = "0"; - public string acc = "0"; - public string racc = "0"; + public string acc_printing_moves_legacy = "0"; + public string acc_printing_moves = "0"; + public string acc_retraction = "0"; + public string acc_travel_moves = "0"; public string avs = "0"; public string avt = "0"; public string avb = "0"; public string avx = "0"; public string avz = "0"; + public string ave = "0"; public string ppid = "0"; public string ipid = "0"; public string dpid = "0"; + public string bed_ppid = "0"; + public string bed_ipid = "0"; + public string bed_dpid = "0"; public string hox = "0"; public string hoy = "0"; public string hoz = "0"; public bool hasPID = false; + public bool bed_HasPID = false; private bool changed = false; private PrinterConnection printerConnection; @@ -162,13 +169,21 @@ namespace MatterHackers.MatterControl.EeProm { foundSetting = true; mode = "M204"; - if (token[0] == 'S') + if (token[0] == 'S') // legacy printing { - acc = token.Substring(1); + acc_printing_moves_legacy = token.Substring(1); } - if (token[0] == 'T') + if (token[0] == 'P') // printing { - racc = token.Substring(1); + acc_printing_moves = token.Substring(1); + } + if (token[0] == 'T') // travel + { + acc_travel_moves = token.Substring(1); + } + if (token[0] == 'R') // retraction + { + acc_retraction = token.Substring(1); } } if (((token == "M205") || (mode == "M205"))) @@ -214,6 +229,24 @@ namespace MatterHackers.MatterControl.EeProm dpid = token.Substring(1); } } + if (((token == "M304") || (mode == "M304"))) + { + foundSetting = true; + mode = "M304"; + bed_HasPID = true; + if (token[0] == 'P') + { + bed_ppid = token.Substring(1); + } + if (token[0] == 'I') + { + bed_ipid = token.Substring(1); + } + if (token[0] == 'D') + { + bed_dpid = token.Substring(1); + } + } if (((token == "M206") || (mode == "M206"))) { foundSetting = true; @@ -244,10 +277,17 @@ namespace MatterHackers.MatterControl.EeProm string cmdsteps = "M92 X" + sx + " Y" + sy + " Z" + sz + " E" + se; string cmdfeed = "M203 X" + fx + " Y" + fy + " Z" + fz + " E" + fe; string cmdmacc = "M201 X" + ax + " Y" + ay + " Z" + az + " E" + ae; - string cmdacc = "M204 S" + acc + " T" + racc; + + string cmdacc = "M204"; + if (acc_printing_moves_legacy != "0") cmdacc += $" S{acc_printing_moves_legacy}"; + if (acc_printing_moves != "0") cmdacc += $" P{acc_printing_moves}"; + if (acc_travel_moves != "0") cmdacc += $" T{acc_travel_moves}"; + if (acc_retraction != "0") cmdacc += $" R{acc_retraction}"; + string cmdav = "M205 S" + avs + " T" + avt + " B" + avb + " X" + avx + " Z" + avz; string cmdho = "M206 X" + hox + " Y" + hoy + " Z" + hoz; string cmdpid = "M301 P" + ppid + " I" + ipid + " D" + dpid; + string cmdbed_pid = "M304 P" + bed_ppid + " I" + bed_ipid + " D" + bed_dpid; printerConnection.QueueLine(cmdsteps); printerConnection.QueueLine(cmdfeed); @@ -403,16 +443,67 @@ namespace MatterHackers.MatterControl.EeProm set { if (ae.Equals(value)) return; ae = value; changed = true; } } - public string ACC + public string AccPrintingMoves { - get { return acc; } - set { if (acc.Equals(value)) return; acc = value; changed = true; } + get + { + if(acc_printing_moves_legacy != "0") + { + return acc_printing_moves_legacy; + } + + return acc_printing_moves; + } + + set + { + // prefer legacy + if (acc_printing_moves_legacy != "0" + && acc_printing_moves_legacy != value) + { + acc_printing_moves_legacy = value; + changed = true; + } + else if (acc_printing_moves != value) + { + acc_printing_moves = value; + changed = true; + } + } } - public string RACC + public string AccTravelMoves { - get { return racc; } - set { if (racc.Equals(value)) return; racc = value; changed = true; } + get + { + return acc_travel_moves; + } + + set + { + if (acc_travel_moves != value) + { + acc_travel_moves = value; + changed = true; + } + } + } + + public string AccRetraction + { + get + { + return acc_travel_moves; + } + + set + { + if (acc_retraction != value) + { + acc_retraction = value; + changed = true; + } + } } public string AVS @@ -470,6 +561,12 @@ namespace MatterHackers.MatterControl.EeProm set { if (avz.Equals(value)) return; avz = value; changed = true; } } + public string AVE + { + get { return ave; } + set { if (ave.Equals(value)) return; ave = value; changed = true; } + } + public string PPID { get { return ppid; } @@ -488,6 +585,24 @@ namespace MatterHackers.MatterControl.EeProm set { if (dpid.Equals(value)) return; dpid = value; changed = true; } } + public string BED_PPID + { + get { return bed_ppid; } + set { if (bed_ppid.Equals(value)) return; bed_ppid = value; changed = true; } + } + + public string BED_IPID + { + get { return bed_ipid; } + set { if (bed_ipid.Equals(value)) return; bed_ipid = value; changed = true; } + } + + public string BED_DPID + { + get { return bed_dpid; } + set { if (bed_dpid.Equals(value)) return; bed_dpid = value; changed = true; } + } + public string HOX { get { return hox; } diff --git a/EeProm/EePromMarlinWindow.cs b/EeProm/EePromMarlinWindow.cs index 6c24a9ea4..27b0937a6 100644 --- a/EeProm/EePromMarlinWindow.cs +++ b/EeProm/EePromMarlinWindow.cs @@ -56,13 +56,18 @@ namespace MatterHackers.MatterControl.EeProm private MHNumberEdit maxAccelerationMmPerSSqrdZ; private MHNumberEdit maxAccelerationMmPerSSqrdE; - private MHNumberEdit acceleration; - private MHNumberEdit retractAcceleration; + private MHNumberEdit accelerationPrintingMoves; + private MHNumberEdit accelerationRetraction; + private MHNumberEdit accelerationTravelMoves; private MHNumberEdit pidP; private MHNumberEdit pidI; private MHNumberEdit pidD; + private MHNumberEdit bedPidP; + private MHNumberEdit bedPidI; + private MHNumberEdit bedPidD; + private MHNumberEdit homingOffsetX; private MHNumberEdit homingOffsetY; private MHNumberEdit homingOffsetZ; @@ -73,6 +78,7 @@ namespace MatterHackers.MatterControl.EeProm private MHNumberEdit maxXYJerk; private MHNumberEdit maxZJerk; + private MHNumberEdit maxEJerk; private EventHandler unregisterEvents; @@ -154,14 +160,20 @@ namespace MatterHackers.MatterControl.EeProm "Z:", ref maxAccelerationMmPerSSqrdZ, "E:", ref maxAccelerationMmPerSSqrdE)); - conterContent.AddChild(CreateField("Acceleration".Localize() + ":", ref acceleration)); - conterContent.AddChild(CreateField("Retract Acceleration".Localize() + ":", ref retractAcceleration)); + conterContent.AddChild(CreateField("Acceleration Printing".Localize() + ":", ref accelerationPrintingMoves)); + conterContent.AddChild(CreateField("Acceleration Travel".Localize() + ":", ref accelerationTravelMoves)); + conterContent.AddChild(CreateField("Retract Acceleration".Localize() + ":", ref accelerationRetraction)); - conterContent.AddChild(Create3FieldSet("PID settings".Localize() + ":", + conterContent.AddChild(Create3FieldSet("PID Settings".Localize() + ":", "P:", ref pidP, "I:", ref pidI, "D:", ref pidD)); + conterContent.AddChild(Create3FieldSet("Bed PID Settings".Localize() + ":", + "P:", ref bedPidP, + "I:", ref bedPidI, + "D:", ref bedPidD)); + conterContent.AddChild(Create3FieldSet("Homing Offset".Localize() + ":", "X:", ref homingOffsetX, "Y:", ref homingOffsetY, @@ -172,6 +184,7 @@ namespace MatterHackers.MatterControl.EeProm conterContent.AddChild(CreateField("Minimum segment time [ms]".Localize() + ":", ref minSegmentTime)); conterContent.AddChild(CreateField("Maximum X-Y jerk [mm/s]".Localize() + ":", ref maxXYJerk)); conterContent.AddChild(CreateField("Maximum Z jerk [mm/s]".Localize() + ":", ref maxZJerk)); + conterContent.AddChild(CreateField("Maximum E jerk [mm/s]".Localize() + ":", ref maxEJerk)); GuiWidget topBottomSpacer = new GuiWidget(1, 1); topBottomSpacer.VAnchor = VAnchor.Stretch; @@ -415,17 +428,23 @@ namespace MatterHackers.MatterControl.EeProm maxAccelerationMmPerSSqrdY.Text = currentEePromSettings.AY; maxAccelerationMmPerSSqrdZ.Text = currentEePromSettings.AZ; maxAccelerationMmPerSSqrdE.Text = currentEePromSettings.AE; - acceleration.Text = currentEePromSettings.ACC; - retractAcceleration.Text = currentEePromSettings.RACC; + accelerationPrintingMoves.Text = currentEePromSettings.AccPrintingMoves; + accelerationTravelMoves.Text = currentEePromSettings.AccTravelMoves; + accelerationRetraction.Text = currentEePromSettings.AccRetraction; minFeedrate.Text = currentEePromSettings.AVS; minTravelFeedrate.Text = currentEePromSettings.AVT; minSegmentTime.Text = currentEePromSettings.AVB; maxXYJerk.Text = currentEePromSettings.AVX; maxZJerk.Text = currentEePromSettings.AVZ; + maxEJerk.Text = currentEePromSettings.AVE; pidP.Enabled = pidI.Enabled = pidD.Enabled = currentEePromSettings.hasPID; pidP.Text = currentEePromSettings.PPID; pidI.Text = currentEePromSettings.IPID; pidD.Text = currentEePromSettings.DPID; + bedPidP.Enabled = bedPidI.Enabled = bedPidD.Enabled = currentEePromSettings.bed_HasPID; + bedPidP.Text = currentEePromSettings.BED_PPID; + bedPidI.Text = currentEePromSettings.BED_IPID; + pidD.Text = currentEePromSettings.BED_DPID; homingOffsetX.Text = currentEePromSettings.hox; homingOffsetY.Text = currentEePromSettings.hoy; homingOffsetZ.Text = currentEePromSettings.hoz; @@ -445,16 +464,21 @@ namespace MatterHackers.MatterControl.EeProm currentEePromSettings.AY = maxAccelerationMmPerSSqrdY.Text; currentEePromSettings.AZ = maxAccelerationMmPerSSqrdZ.Text; currentEePromSettings.AE = maxAccelerationMmPerSSqrdE.Text; - currentEePromSettings.ACC = acceleration.Text; - currentEePromSettings.RACC = retractAcceleration.Text; + currentEePromSettings.AccPrintingMoves = accelerationPrintingMoves.Text; + currentEePromSettings.AccTravelMoves = accelerationTravelMoves.Text; + currentEePromSettings.AccRetraction = accelerationRetraction.Text; currentEePromSettings.AVS = minFeedrate.Text; currentEePromSettings.AVT = minTravelFeedrate.Text; currentEePromSettings.AVB = minSegmentTime.Text; currentEePromSettings.AVX = maxXYJerk.Text; currentEePromSettings.AVZ = maxZJerk.Text; + currentEePromSettings.AVE = maxEJerk.Text; currentEePromSettings.PPID = pidP.Text; currentEePromSettings.IPID = pidI.Text; currentEePromSettings.DPID = pidD.Text; + currentEePromSettings.BED_PPID = bedPidP.Text; + currentEePromSettings.BED_IPID = bedPidI.Text; + currentEePromSettings.BED_DPID = bedPidD.Text; currentEePromSettings.HOX = homingOffsetX.Text; currentEePromSettings.HOY = homingOffsetY.Text; currentEePromSettings.HOZ = homingOffsetZ.Text;