Skip to content

Commit a45e84a

Browse files
MX-Masterphkahler
authored andcommitted
+ safe height gcode parameter
1 parent 2cd0ee4 commit a45e84a

File tree

5 files changed

+24
-11
lines changed

5 files changed

+24
-11
lines changed

src/confscreen.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ void TextWindow::ScreenChangeGCodeParameter(int link, uint32_t v) {
161161
buf += SS.MmToString(SS.gCode.depth, true);
162162
break;
163163

164+
case 'h':
165+
SS.TW.edit.meaning = Edit::G_CODE_SAFE_HEIGHT;
166+
buf += SS.MmToString(SS.gCode.safeHeight, true);
167+
break;
168+
164169
case 's':
165170
SS.TW.edit.meaning = Edit::G_CODE_PASSES;
166171
buf += std::to_string(SS.gCode.passes);
@@ -492,6 +497,11 @@ bool TextWindow::EditControlDoneForConfiguration(const std::string &s) {
492497
if(e) SS.gCode.depth = (float)SS.ExprToMm(e);
493498
break;
494499
}
500+
case Edit::G_CODE_SAFE_HEIGHT: {
501+
Expr *e = Expr::From(s, /*popUpError=*/true);
502+
if(e) SS.gCode.safeHeight = (float)SS.ExprToMm(e);
503+
break;
504+
}
495505
case Edit::G_CODE_PASSES: {
496506
Expr *e = Expr::From(s, /*popUpError=*/true);
497507
if(e) SS.gCode.passes = (int)(e->Eval());

src/exportvector.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,7 @@ void SvgFileWriter::StartFile() {
11021102
fprintf(f, "stroke-dasharray:%s;\r\n", patternStr.c_str());
11031103
}
11041104
if(s->filled) {
1105-
fprintf(f, "fill:#%02x%02x%02x;\r\n", fillRgb.red, fillRgb.green, fillRgb.blue);
1105+
fprintf(f, "fill:#%02x%02x%02x;\r\n", fillRgb.red, fillRgb.green, fillRgb.blue);
11061106
}
11071107
else {
11081108
fprintf(f, "fill:none;\r\n");
@@ -1308,9 +1308,9 @@ void GCodeFileWriter::FinishAndCloseFile() {
13081308
SS.MmToString(pt->p.x).c_str(), SS.MmToString(pt->p.y).c_str(),
13091309
SS.MmToString(SS.gCode.feed).c_str());
13101310
}
1311-
// Move up to a clearance plane 5mm above the work.
1311+
// Move up to a clearance plane above the work.
13121312
fprintf(f, "G00 Z%s\r\n",
1313-
SS.MmToString(SS.gCode.depth < 0 ? +5 : -5).c_str());
1313+
SS.MmToString(SS.gCode.safeHeight).c_str());
13141314
}
13151315
}
13161316

src/solvespace.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ void SolveSpaceUI::Init() {
105105
exportCanvas.dy = settings->ThawFloat("ExportCanvas_Dy", 5.0);
106106
// Extra parameters when exporting G code
107107
gCode.depth = settings->ThawFloat("GCode_Depth", 10.0);
108+
gCode.safeHeight = settings->ThawFloat("GCode_SafeHeight", 5.0);
108109
gCode.passes = settings->ThawInt("GCode_Passes", 1);
109110
gCode.feed = settings->ThawFloat("GCode_Feed", 10.0);
110111
gCode.plungeFeed = settings->ThawFloat("GCode_PlungeFeed", 10.0);
@@ -413,7 +414,7 @@ static std::pair<int, std::string> SelectSIPrefixMm(int ord, int dim) {
413414
default:
414415
dbp ("dimensions over 3 not supported");
415416
break;
416-
}
417+
}
417418
return {0, "m"};
418419
}
419420
static std::pair<int, std::string> SelectSIPrefixInch(int deg) {

src/solvespace.h

+1
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,7 @@ class SolveSpaceUI {
598598
} exportCanvas;
599599
struct {
600600
double depth;
601+
double safeHeight;
601602
int passes;
602603
double feed;
603604
double plungeFeed;

src/ui.h

+8-7
Original file line numberDiff line numberDiff line change
@@ -314,13 +314,14 @@ class TextWindow {
314314
EXPORT_OFFSET = 110,
315315
CANVAS_SIZE = 111,
316316
G_CODE_DEPTH = 112,
317-
G_CODE_PASSES = 113,
318-
G_CODE_FEED = 114,
319-
G_CODE_PLUNGE_FEED = 115,
320-
AUTOSAVE_INTERVAL = 116,
321-
LIGHT_AMBIENT = 117,
322-
FIND_CONSTRAINT_TIMEOUT = 118,
323-
EXPLODE_DISTANCE = 119,
317+
G_CODE_SAFE_HEIGHT = 113,
318+
G_CODE_PASSES = 114,
319+
G_CODE_FEED = 115,
320+
G_CODE_PLUNGE_FEED = 116,
321+
AUTOSAVE_INTERVAL = 117,
322+
LIGHT_AMBIENT = 118,
323+
FIND_CONSTRAINT_TIMEOUT = 119,
324+
EXPLODE_DISTANCE = 120,
324325
// For TTF text
325326
TTF_TEXT = 300,
326327
// For the step dimension screen

0 commit comments

Comments
 (0)