DRO works properly with work offsets. Offsets can be zeroed.

This commit is contained in:
2023-05-04 15:57:34 +03:00
parent cacbe1b8aa
commit 3ea1ca5efa
3 changed files with 219 additions and 167 deletions
+57 -11
View File
@@ -373,16 +373,25 @@ std::string grbl::setting_description(int number) {
case 75:
return "Bluetooth service ()\nBluetooth service name.";
case 80: return "Spindle P-gain";
case 81: return "Spindle I-gain";
case 82: return "Spindle D-gain";
case 84: return "Spindle PID max error";
case 85: return "Spindle PID max I error\nSpindle PID max integrator error";
case 80:
return "Spindle P-gain";
case 81:
return "Spindle I-gain";
case 82:
return "Spindle D-gain";
case 84:
return "Spindle PID max error";
case 85:
return "Spindle PID max I error\nSpindle PID max integrator error";
case 90: return "Spindle sync P-gain";
case 91: return "Spindle sync I-gain";
case 92: return "Spindle sync D-gain";
case 95: return "Spindle sync PID max I error\nSpindle sync PID max integrator error";
case 90:
return "Spindle sync P-gain";
case 91:
return "Spindle sync I-gain";
case 92:
return "Spindle sync D-gain";
case 95:
return "Spindle sync PID max I error\nSpindle sync PID max integrator error";
case 100:
return "X-axis travel resolution (step/mm)\nX-axis travel resolution in steps per millimeter.";
@@ -609,6 +618,30 @@ const std::map<std::string, std::string, grbl::parameters_cmp>& grbl::machine::g
return parameters;
}
void grbl::machine::zero_offset(int which) {
while (awaiting_responses > 0);
pipe->send("G10 L20 P" + std::to_string(1 + which) + " X0 Y0 Z0"); // P1 => G54
awaiting_responses++;
while (awaiting_responses > 0);
pipe->send("$#");
awaiting_responses++;
while (awaiting_responses > 0);
listener->on_parameters_reloaded();
}
void grbl::machine::zero_offset_axis(int offset_index, int axis) {
while (awaiting_responses > 0);
pipe->send("G10 L20 P" + std::to_string(1 + offset_index) + " " + char('X' + axis) + "0"); // P1 => G54
awaiting_responses++;
while (awaiting_responses > 0);
pipe->send("$#");
awaiting_responses++;
while (awaiting_responses > 0);
listener->on_parameters_reloaded();
}
bool grbl::jog_state::no_jogging() const {
return !(up_pressed || down_pressed || left_pressed || right_pressed || z_up_pressed || z_down_pressed);
}
@@ -678,7 +711,7 @@ void grbl::machine_state_init::move_to_next_init_stage() {
switch (init_state) {
case init_stage::start:
init_state = init_stage::set_work_pos;
cnc->pipe->send("$10=0");
cnc->pipe->send("$10=1"); // machine pos in report, please
break;
case init_stage::set_work_pos:
init_state = init_stage::fetch_settings;
@@ -714,18 +747,31 @@ void grbl::machine_state_idle::on_exit(grbl::machine *m) {
void grbl::machine_state_idle::on_line_received(std::string line) {
if (starts_with(line, "ok")) {
if (cnc->awaiting_responses > 0) {
cnc->awaiting_responses--;
}
} else if (starts_with(line, "error")) {
if (cnc->awaiting_responses > 0) {
cnc->awaiting_responses--;
}
} else if (starts_with(line, "Grbl")) {
cnc->listener->on_banner(line);
cnc->reset_machine_state();
} else if (starts_with(line, "<")) {
cnc->last_report = parse_status_report(line, cnc->last_report);
cnc->listener->on_realtime_status_report(cnc->last_report);
} else if (starts_with(line, "[MSG:")) {
cnc->listener->on_message(line.substr(5, line.size() - 6));
} else if (starts_with(line, "ALARM:")) {
cnc->listener->on_alarm(std::stoi(line.substr(6)));
} else if (starts_with(line, "$")) {
auto pieces = split_string(line, "=");
cnc->settings[pieces[0]] = pieces[1];
} else if (starts_with(line, "[G") || starts_with(line, "[H") || starts_with(line, "[T") || starts_with(line, "[P")) {
line = line.substr(1, line.size() - 2);
// TODO: some parameters have more than two :
auto pieces = split_string(line, ":");
cnc->parameters[pieces[0]] = pieces[1];
}
}