+ safe height gcode parameter

This commit is contained in:
MX_Master 2021-10-13 23:16:55 +06:00 committed by phkahler
parent 2cd0ee4b33
commit a45e84a2ff
5 changed files with 24 additions and 11 deletions

View File

@ -161,6 +161,11 @@ void TextWindow::ScreenChangeGCodeParameter(int link, uint32_t v) {
buf += SS.MmToString(SS.gCode.depth, true); buf += SS.MmToString(SS.gCode.depth, true);
break; break;
case 'h':
SS.TW.edit.meaning = Edit::G_CODE_SAFE_HEIGHT;
buf += SS.MmToString(SS.gCode.safeHeight, true);
break;
case 's': case 's':
SS.TW.edit.meaning = Edit::G_CODE_PASSES; SS.TW.edit.meaning = Edit::G_CODE_PASSES;
buf += std::to_string(SS.gCode.passes); buf += std::to_string(SS.gCode.passes);
@ -492,6 +497,11 @@ bool TextWindow::EditControlDoneForConfiguration(const std::string &s) {
if(e) SS.gCode.depth = (float)SS.ExprToMm(e); if(e) SS.gCode.depth = (float)SS.ExprToMm(e);
break; break;
} }
case Edit::G_CODE_SAFE_HEIGHT: {
Expr *e = Expr::From(s, /*popUpError=*/true);
if(e) SS.gCode.safeHeight = (float)SS.ExprToMm(e);
break;
}
case Edit::G_CODE_PASSES: { case Edit::G_CODE_PASSES: {
Expr *e = Expr::From(s, /*popUpError=*/true); Expr *e = Expr::From(s, /*popUpError=*/true);
if(e) SS.gCode.passes = (int)(e->Eval()); if(e) SS.gCode.passes = (int)(e->Eval());

View File

@ -1102,7 +1102,7 @@ void SvgFileWriter::StartFile() {
fprintf(f, "stroke-dasharray:%s;\r\n", patternStr.c_str()); fprintf(f, "stroke-dasharray:%s;\r\n", patternStr.c_str());
} }
if(s->filled) { if(s->filled) {
fprintf(f, "fill:#%02x%02x%02x;\r\n", fillRgb.red, fillRgb.green, fillRgb.blue); fprintf(f, "fill:#%02x%02x%02x;\r\n", fillRgb.red, fillRgb.green, fillRgb.blue);
} }
else { else {
fprintf(f, "fill:none;\r\n"); fprintf(f, "fill:none;\r\n");
@ -1308,9 +1308,9 @@ void GCodeFileWriter::FinishAndCloseFile() {
SS.MmToString(pt->p.x).c_str(), SS.MmToString(pt->p.y).c_str(), SS.MmToString(pt->p.x).c_str(), SS.MmToString(pt->p.y).c_str(),
SS.MmToString(SS.gCode.feed).c_str()); SS.MmToString(SS.gCode.feed).c_str());
} }
// Move up to a clearance plane 5mm above the work. // Move up to a clearance plane above the work.
fprintf(f, "G00 Z%s\r\n", fprintf(f, "G00 Z%s\r\n",
SS.MmToString(SS.gCode.depth < 0 ? +5 : -5).c_str()); SS.MmToString(SS.gCode.safeHeight).c_str());
} }
} }

View File

@ -105,6 +105,7 @@ void SolveSpaceUI::Init() {
exportCanvas.dy = settings->ThawFloat("ExportCanvas_Dy", 5.0); exportCanvas.dy = settings->ThawFloat("ExportCanvas_Dy", 5.0);
// Extra parameters when exporting G code // Extra parameters when exporting G code
gCode.depth = settings->ThawFloat("GCode_Depth", 10.0); gCode.depth = settings->ThawFloat("GCode_Depth", 10.0);
gCode.safeHeight = settings->ThawFloat("GCode_SafeHeight", 5.0);
gCode.passes = settings->ThawInt("GCode_Passes", 1); gCode.passes = settings->ThawInt("GCode_Passes", 1);
gCode.feed = settings->ThawFloat("GCode_Feed", 10.0); gCode.feed = settings->ThawFloat("GCode_Feed", 10.0);
gCode.plungeFeed = settings->ThawFloat("GCode_PlungeFeed", 10.0); gCode.plungeFeed = settings->ThawFloat("GCode_PlungeFeed", 10.0);
@ -413,7 +414,7 @@ static std::pair<int, std::string> SelectSIPrefixMm(int ord, int dim) {
default: default:
dbp ("dimensions over 3 not supported"); dbp ("dimensions over 3 not supported");
break; break;
} }
return {0, "m"}; return {0, "m"};
} }
static std::pair<int, std::string> SelectSIPrefixInch(int deg) { static std::pair<int, std::string> SelectSIPrefixInch(int deg) {

View File

@ -598,6 +598,7 @@ public:
} exportCanvas; } exportCanvas;
struct { struct {
double depth; double depth;
double safeHeight;
int passes; int passes;
double feed; double feed;
double plungeFeed; double plungeFeed;

View File

@ -314,13 +314,14 @@ public:
EXPORT_OFFSET = 110, EXPORT_OFFSET = 110,
CANVAS_SIZE = 111, CANVAS_SIZE = 111,
G_CODE_DEPTH = 112, G_CODE_DEPTH = 112,
G_CODE_PASSES = 113, G_CODE_SAFE_HEIGHT = 113,
G_CODE_FEED = 114, G_CODE_PASSES = 114,
G_CODE_PLUNGE_FEED = 115, G_CODE_FEED = 115,
AUTOSAVE_INTERVAL = 116, G_CODE_PLUNGE_FEED = 116,
LIGHT_AMBIENT = 117, AUTOSAVE_INTERVAL = 117,
FIND_CONSTRAINT_TIMEOUT = 118, LIGHT_AMBIENT = 118,
EXPLODE_DISTANCE = 119, FIND_CONSTRAINT_TIMEOUT = 119,
EXPLODE_DISTANCE = 120,
// For TTF text // For TTF text
TTF_TEXT = 300, TTF_TEXT = 300,
// For the step dimension screen // For the step dimension screen