0
0
Fork 0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2025-03-13 09:49:56 +00:00

🧑‍💻 IA Creality optional code

This commit is contained in:
Scott Lahteine 2023-10-13 09:48:14 -05:00
parent 251a84b741
commit 7944628400

View file

@ -688,7 +688,9 @@ void RTS::handleData() {
return; return;
} }
constexpr float lfrb[4] = BED_TRAMMING_INSET_LFRB; #if ENABLED(LCD_BED_TRAMMING)
constexpr float lfrb[4] = BED_TRAMMING_INSET_LFRB;
#endif
switch (Checkkey) { switch (Checkkey) {
case Printfile: case Printfile:
@ -785,26 +787,30 @@ void RTS::handleData() {
} }
break; break;
case Zoffset: #if HAS_BED_PROBE
float tmp_zprobe_offset;
if (recdat.data[0] >= 32768)
tmp_zprobe_offset = (float(recdat.data[0]) - 65536) / 100;
else
tmp_zprobe_offset = float(recdat.data[0]) / 100;
if (WITHIN((tmp_zprobe_offset), Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) {
int16_t tmpSteps = mmToWholeSteps(getZOffset_mm() - tmp_zprobe_offset, axis_t(Z));
if (tmpSteps == 0) tmpSteps = getZOffset_mm() < tmp_zprobe_offset ? 1 : -1;
smartAdjustAxis_steps(-tmpSteps, axis_t(Z), false);
char zOffs[20], tmp1[11];
sprintf_P(zOffs, PSTR("Z Offset : %s"), dtostrf(getZOffset_mm(), 1, 3, tmp1));
onStatusChanged(zOffs);
}
else {
onStatusChanged(F("Requested Offset Beyond Limits"));
}
sendData(getZOffset_mm() * 100, ProbeOffset_Z); case Zoffset:
break; float tmp_zprobe_offset;
if (recdat.data[0] >= 32768)
tmp_zprobe_offset = (float(recdat.data[0]) - 65536) / 100;
else
tmp_zprobe_offset = float(recdat.data[0]) / 100;
if (WITHIN((tmp_zprobe_offset), Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) {
int16_t tmpSteps = mmToWholeSteps(getZOffset_mm() - tmp_zprobe_offset, axis_t(Z));
if (tmpSteps == 0) tmpSteps = getZOffset_mm() < tmp_zprobe_offset ? 1 : -1;
smartAdjustAxis_steps(-tmpSteps, axis_t(Z), false);
char zOffs[20], tmp1[11];
sprintf_P(zOffs, PSTR("Z Offset : %s"), dtostrf(getZOffset_mm(), 1, 3, tmp1));
onStatusChanged(zOffs);
}
else {
onStatusChanged(F("Requested Offset Beyond Limits"));
}
sendData(getZOffset_mm() * 100, ProbeOffset_Z);
break;
#endif // HAS_BED_PROBE
case TempControl: case TempControl:
if (recdat.data[0] == 0) { if (recdat.data[0] == 0) {
@ -1106,29 +1112,31 @@ void RTS::handleData() {
sendData(getZOffset_mm() * 100, ProbeOffset_Z); sendData(getZOffset_mm() * 100, ProbeOffset_Z);
break; break;
} }
case 2: { // Z-axis to Up
if (WITHIN((getZOffset_mm() + 0.1), Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) { #if HAS_BED_PROBE
smartAdjustAxis_steps(getAxisSteps_per_mm(Z) / 10, axis_t(Z), false);
//setZOffset_mm(getZOffset_mm() + 0.1); case 2: { // Z-axis to Up
sendData(getZOffset_mm() * 100, ProbeOffset_Z); if (WITHIN((getZOffset_mm() + 0.1), Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) {
char zOffs[20], tmp1[11]; smartAdjustAxis_steps(getAxisSteps_per_mm(Z) / 10, axis_t(Z), false);
sprintf_P(zOffs, PSTR("Z Offset : %s"), dtostrf(getZOffset_mm(), 1, 3, tmp1)); //setZOffset_mm(getZOffset_mm() + 0.1);
onStatusChanged(zOffs); sendData(getZOffset_mm() * 100, ProbeOffset_Z);
onStatusChanged(MString<20>(GET_TEXT_F(MSG_UBL_Z_OFFSET), p_float_t(getZOffset_mm(), 3)));
}
break;
} }
break; case 3: { // Z-axis to Down
} if (WITHIN((getZOffset_mm() - 0.1), Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) {
case 3: { // Z-axis to Down smartAdjustAxis_steps(-getAxisSteps_per_mm(Z) / 10, axis_t(Z), false);
if (WITHIN((getZOffset_mm() - 0.1), Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) { //babystepAxis_steps(int16_t(-getAxisSteps_per_mm(Z)) / 10, axis_t(Z));
smartAdjustAxis_steps(-getAxisSteps_per_mm(Z) / 10, axis_t(Z), false); //setZOffset_mm(getZOffset_mm() - 0.1);
//babystepAxis_steps(int16_t(-getAxisSteps_per_mm(Z)) / 10, axis_t(Z)); sendData(getZOffset_mm() * 100, ProbeOffset_Z);
//setZOffset_mm(getZOffset_mm() - 0.1); onStatusChanged(MString<20>(GET_TEXT_F(MSG_UBL_Z_OFFSET), p_float_t(getZOffset_mm(), 3)));
sendData(getZOffset_mm() * 100, ProbeOffset_Z); }
char zOffs[20], tmp1[11]; break;
sprintf_P(zOffs, PSTR("Z Offset : %s"), dtostrf(getZOffset_mm(), 1, 3, tmp1));
onStatusChanged(zOffs);
} }
break;
} #endif // HAS_BED_PROBE
case 4: { // Assistant Level case 4: { // Assistant Level
TERN_(HAS_MESH, setLevelingActive(false)); TERN_(HAS_MESH, setLevelingActive(false));
injectCommands(isPositionKnown() ? F("G1 F1000 Z0.0") : F("G28\nG1 F1000 Z0.0")); injectCommands(isPositionKnown() ? F("G1 F1000 Z0.0") : F("G28\nG1 F1000 Z0.0"));
@ -1140,7 +1148,7 @@ void RTS::handleData() {
#if ENABLED(MESH_BED_LEVELING) #if ENABLED(MESH_BED_LEVELING)
sendData(ExchangePageBase + 93, ExchangepageAddr); sendData(ExchangePageBase + 93, ExchangepageAddr);
#else #else
waitway = 3; // only for prohibiting to receive massage waitway = 3; // Only for prohibiting to receive message
sendData(3, AutolevelIcon); sendData(3, AutolevelIcon);
uint8_t abl_probe_index = 0; uint8_t abl_probe_index = 0;
while (abl_probe_index < 25) { while (abl_probe_index < 25) {
@ -1153,65 +1161,74 @@ void RTS::handleData() {
break; break;
} }
case 6: { // Assitant Level , Centre 1 #if ENABLED(LCD_BED_TRAMMING)
setAxisPosition_mm(BED_TRAMMING_Z_HOP, axis_t(Z)); case 6: { // Bed Tramming, Centre 1
setAxisPosition_mm(X_CENTER, axis_t(X)); setAxisPosition_mm(BED_TRAMMING_Z_HOP, axis_t(Z));
setAxisPosition_mm(Y_CENTER, axis_t(Y)); setAxisPosition_mm(X_CENTER, axis_t(X));
waitway = 6; setAxisPosition_mm(Y_CENTER, axis_t(Y));
break; waitway = 6;
} break;
case 7: { // Assitant Level , Front Left 2 }
setAxisPosition_mm(BED_TRAMMING_Z_HOP, axis_t(Z)); case 7: { // Bed Tramming, Front Left 2
setAxisPosition_mm(X_MIN_BED + lfrb[0], axis_t(X)); setAxisPosition_mm(BED_TRAMMING_Z_HOP, axis_t(Z));
setAxisPosition_mm(Y_MIN_BED + lfrb[1], axis_t(Y)); setAxisPosition_mm(X_MIN_BED + lfrb[0], axis_t(X));
waitway = 6; setAxisPosition_mm(Y_MIN_BED + lfrb[1], axis_t(Y));
break; waitway = 6;
} break;
case 8: { // Assitant Level , Front Right 3 }
setAxisPosition_mm(BED_TRAMMING_Z_HOP, axis_t(Z)); case 8: { // Bed Tramming, Front Right 3
setAxisPosition_mm(X_MAX_BED - lfrb[2], axis_t(X)); setAxisPosition_mm(BED_TRAMMING_Z_HOP, axis_t(Z));
setAxisPosition_mm(Y_MIN_BED + lfrb[1], axis_t(Y)); setAxisPosition_mm(X_MAX_BED - lfrb[2], axis_t(X));
waitway = 6; setAxisPosition_mm(Y_MIN_BED + lfrb[1], axis_t(Y));
break; waitway = 6;
} break;
case 9: { // Assitant Level , Back Right 4 }
setAxisPosition_mm(BED_TRAMMING_Z_HOP, axis_t(Z)); case 9: { // Bed Tramming, Back Right 4
setAxisPosition_mm(X_MAX_BED - lfrb[2], axis_t(X)); setAxisPosition_mm(BED_TRAMMING_Z_HOP, axis_t(Z));
setAxisPosition_mm(Y_MAX_BED - lfrb[3], axis_t(Y)); setAxisPosition_mm(X_MAX_BED - lfrb[2], axis_t(X));
waitway = 6; setAxisPosition_mm(Y_MAX_BED - lfrb[3], axis_t(Y));
break; waitway = 6;
} break;
case 10: { // Assitant Level , Back Left 5 }
setAxisPosition_mm(BED_TRAMMING_Z_HOP, axis_t(Z)); case 10: { // Bed Tramming, Back Left 5
setAxisPosition_mm(X_MIN_BED + lfrb[0], axis_t(X)); setAxisPosition_mm(BED_TRAMMING_Z_HOP, axis_t(Z));
setAxisPosition_mm(Y_MAX_BED - lfrb[3], axis_t(Y)); setAxisPosition_mm(X_MIN_BED + lfrb[0], axis_t(X));
waitway = 6; setAxisPosition_mm(Y_MAX_BED - lfrb[3], axis_t(Y));
break; waitway = 6;
} break;
}
#endif // LCD_BED_TRAMMING
case 11: { // Autolevel switch case 11: { // Autolevel switch
#if HAS_MESH #if HAS_MESH
const bool gla = !getLevelingActive(); const bool gla = !getLevelingActive();
setLevelingActive(gla); setLevelingActive(gla);
sendData(gla ? 3 : 2, AutoLevelIcon); sendData(gla ? 3 : 2, AutoLevelIcon);
#endif #endif
sendData(getZOffset_mm() * 100, ProbeOffset_Z); #if HAS_BED_PROBE
break; sendData(getZOffset_mm() * 100, ProbeOffset_Z);
} #endif
case 12: {
injectCommands(F("G26R255"));
onStatusChanged(F("Beginning G26.. Heating"));
break;
}
case 13: {
injectCommands(F("G29S1"));
onStatusChanged(F("Begin Manual Mesh"));
break;
}
case 14: {
injectCommands(F("G29S2"));
onStatusChanged(F("Moving to Next Mesh Point"));
break; break;
} }
#if ENABLED(G26_MESH_VALIDATION)
case 12: {
injectCommands(F("G26R255"));
onStatusChanged(F("Beginning G26.. Heating"));
break;
}
#endif
#if ENABLED(MESH_BED_LEVELING)
case 13: {
injectCommands(F("G29S1"));
onStatusChanged(F("Begin Manual Mesh"));
break;
}
case 14: {
injectCommands(F("G29S2"));
onStatusChanged(F("Moving to Next Mesh Point"));
break;
}
#endif
case 15: { case 15: {
injectCommands(F("M211S0\nG91\nG1Z-0.025\nG90\nM211S1")); injectCommands(F("M211S0\nG91\nG1Z-0.025\nG90\nM211S1"));
onStatusChanged(F("Moved down 0.025")); onStatusChanged(F("Moved down 0.025"));
@ -1422,13 +1439,14 @@ void RTS::handleData() {
break; break;
} }
case 5: { #if ENABLED(PIDTEMPBED)
#if ENABLED(PIDTEMPBED) case 5: {
onStatusChanged(F("Bed PID Started")); onStatusChanged(F("Bed PID Started"));
startBedPIDTune(static_cast<celsius_t>(pid_bedAutoTemp)); startBedPIDTune(static_cast<celsius_t>(pid_bedAutoTemp));
#endif break;
break; }
} #endif
case 6: { case 6: {
injectCommands(F("M500")); injectCommands(F("M500"));
break; break;