Apply to E3S1PRO

This commit is contained in:
Scott Lahteine
2025-11-17 15:32:11 -06:00
parent 0c98019093
commit cf0e921f3e
3 changed files with 36 additions and 102 deletions
@@ -395,30 +395,13 @@ void DGUSReturnKeyCodeHandler::Command_SettingsMenu(DGUS_VP &vp, void *data) {
}
}
static void _gotoTrammingPoint(unsigned char point) {
#if ENABLED(BED_TRAMMING_USE_PROBE)
const float lfrb[4] = {
(X_MIN_BED) + probe.min_x(),
(Y_MIN_BED) + probe.min_y(),
(X_MAX_BED) - probe.max_x(),
(Y_MAX_BED) - probe.max_y()
};
#endif
float x, y;
switch (point) {
default: return;
case 1: x = X_CENTER; y = Y_CENTER; break;
case 2: x = X_MIN_BED + lfrb[0]; y = Y_MIN_BED + lfrb[1]; break;
case 3: x = X_MAX_BED - lfrb[2]; y = Y_MIN_BED + lfrb[1]; break;
case 4: x = X_MAX_BED - lfrb[2]; y = Y_MAX_BED - lfrb[3]; break;
case 5: x = X_MIN_BED + lfrb[0]; y = Y_MAX_BED - lfrb[3]; break;
}
static void _gotoTrammingPoint(const NamedPlace place) {
const xy_pos_t xy = tram_point_by_place(place);
if (BED_TRAMMING_Z_HOP)
ExtUI::setAxisPosition_mm(ExtUI::getAxisPosition_mm(ExtUI::Z) + (BED_TRAMMING_Z_HOP), ExtUI::Z);
ExtUI::setAxisPosition_mm(x, ExtUI::X);
ExtUI::setAxisPosition_mm(y, ExtUI::Y);
ExtUI::setAxisPosition_mm(xy.x, ExtUI::X);
ExtUI::setAxisPosition_mm(xy.y, ExtUI::Y);
ExtUI::setAxisPosition_mm((Z_MIN_POS) + (BED_TRAMMING_HEIGHT), ExtUI::Z);
}
@@ -430,7 +413,7 @@ void DGUSReturnKeyCodeHandler::Command_Leveling(DGUS_VP &vp, void *data) {
case DGUS_Data::LevelingCommand::Show_AuxLeveling:
if (ExtUI::isPositionKnown())
screen.triggerScreenChange(DGUS_ScreenID::LEVELINGMODE);
_gotoTrammingPoint(1);
_gotoTrammingPoint(CC);
break;
case DGUS_Data::LevelingCommand::Show_Settings_Leveling:
@@ -438,25 +421,11 @@ void DGUSReturnKeyCodeHandler::Command_Leveling(DGUS_VP &vp, void *data) {
screen.homeThenChangeScreen(DGUS_ScreenID::LEVELING);
break;
case DGUS_Data::LevelingCommand::Goto_Center:
_gotoTrammingPoint(1);
break;
case DGUS_Data::LevelingCommand::Goto_LF:
_gotoTrammingPoint(2);
break;
case DGUS_Data::LevelingCommand::Goto_RF:
_gotoTrammingPoint(3);
break;
case DGUS_Data::LevelingCommand::Goto_RB:
_gotoTrammingPoint(4);
break;
case DGUS_Data::LevelingCommand::Goto_LB:
_gotoTrammingPoint(5);
break;
case DGUS_Data::LevelingCommand::Goto_CC: _gotoTrammingPoint(CC); break;
case DGUS_Data::LevelingCommand::Goto_LF: _gotoTrammingPoint(LF); break;
case DGUS_Data::LevelingCommand::Goto_RF: _gotoTrammingPoint(RF); break;
case DGUS_Data::LevelingCommand::Goto_RB: _gotoTrammingPoint(RB); break;
case DGUS_Data::LevelingCommand::Goto_LB: _gotoTrammingPoint(LB); break;
default:
#if ALL(DEBUG_DGUSLCD, DGUS_UNKNOWN_COMMAND_DEBUG)
@@ -136,7 +136,7 @@ namespace DGUS_Data {
enum class LevelingCommand : uint16_t {
Show_Settings_Leveling = 1,
Show_AuxLeveling = 4,
Goto_Center = 5,
Goto_CC = 5,
Goto_LF = 6,
Goto_RF = 7,
Goto_RB = 8,
+25 -60
View File
@@ -54,7 +54,7 @@ enum NamedPlace : uint8_t { NOPOINT = 0, LF, RF, RB, LB, FC, RC, LC, BC, CC };
//#define BED_TRAMMING_LEVELING_ORDER { LB, RB } // 3-Point tramming - Front
#endif
constexpr int8_t lco[] = BED_TRAMMING_LEVELING_ORDER;
constexpr NamedPlace lco[] = BED_TRAMMING_LEVELING_ORDER;
constexpr bool tramming_3_points = COUNT(lco) == 2;
static_assert(tramming_3_points || COUNT(lco) == 4, "BED_TRAMMING_LEVELING_ORDER must have exactly 2 or 4 corners.");
constexpr bool corners_are(NamedPlace a, NamedPlace b) {
@@ -68,6 +68,26 @@ constexpr int8_t nr_edge_points = tramming_3_points ? 3 : 4;
constexpr int8_t available_points = nr_edge_points + ENABLED(BED_TRAMMING_INCLUDE_CENTER);
constexpr int8_t center_index = TERN(BED_TRAMMING_INCLUDE_CENTER, available_points - 1, -1);
inline static xy_pos_t tram_point_by_place(const uint8_t p) {
#if ENABLED(BED_TRAMMING_USE_PROBE)
constexpr float slop = 0.01f;
const xy_pos_t lf = { (X_MIN_BED) + probe.min_x() + slop, (Y_MIN_BED) + probe.min_y() + slop },
rb = { (X_MAX_BED) - probe.max_x() - slop, (Y_MAX_BED) - probe.max_y() - slop };
#endif
switch (p) {
default:
case CC: return { X_CENTER, Y_CENTER }; // Center
case LF: return lf; // Left Front
case RF: return xy_pos_t({ rb.x, lf.y }); // Right Front
case RB: return rb; // Right Back
case LB: return xy_pos_t({ lf.x, rb.y }); // Left Back
case FC: return xy_pos_t({ (lf.x + rb.x) / 2, lf.y }); // Front Center
case RC: return xy_pos_t({ rb.x, (lf.y + rb.y) / 2 }); // Right Center
case LC: return xy_pos_t({ lf.x, (lf.y + rb.y) / 2 }); // Left Center
case BC: return xy_pos_t({ (lf.x + rb.x) / 2, rb.y }); // Back Center
}
}
// Center of the opposite edge for the 3rd point
constexpr NamedPlace third_place() {
if (corners_are(LB, RB)) return FC; // Front Center
@@ -76,25 +96,11 @@ constexpr NamedPlace third_place() {
return BC; // Back Center
}
static inline xy_pos_t third_point() {
#if ENABLED(BED_TRAMMING_USE_PROBE)
constexpr float slop = 0.01f;
const xy_pos_t lf = { (X_MIN_BED) + probe.min_x() + slop, (Y_MIN_BED) + probe.min_y() + slop },
rb = { (X_MAX_BED) - probe.max_x() - slop, (Y_MAX_BED) - probe.max_y() - slop };
#endif
switch (third_place()) {
case FC: return xy_pos_t({ (lf.x + rb.x) / 2, lf.y }); // Front Center
case RC: return xy_pos_t({ rb.x, (lf.y + rb.y) / 2 }); // Right Center
case LC: return xy_pos_t({ lf.x, (lf.y + rb.y) / 2 }); // Left Center
case BC: return xy_pos_t({ (lf.x + rb.x) / 2, rb.y }); // Back Center
}
}
static inline NamedPlace tram_place_by_index(const uint8_t i) {
static inline NamedPlace tram_place_by_index(const int8_t i) {
if (tramming_3_points) {
switch (i) {
case 0 ... 1: return lco[i]; // 1st and 2nd point set explicitly by config
case 2: return third_point(); // 3rd point is based on the other two
case 2: return third_place(); // 3rd point is based on the other two
#if ENABLED(BED_TRAMMING_INCLUDE_CENTER)
case 3: return CC; // 4th point is optional center
#endif
@@ -102,51 +108,10 @@ static inline NamedPlace tram_place_by_index(const uint8_t i) {
}
else {
// Four-Corner Bed Tramming with optional center
return TERN0(BED_TRAMMING_INCLUDE_CENTER, i == center_index) ? CC : return lco[i];
return TERN0(BED_TRAMMING_INCLUDE_CENTER, i == center_index) ? CC : lco[i];
}
}
inline static xy_pos_t tram_point_by_index(const uint8_t i) {
#if ENABLED(BED_TRAMMING_USE_PROBE)
constexpr float slop = 0.01f;
const xy_pos_t lf = { (X_MIN_BED) + probe.min_x() + slop, (Y_MIN_BED) + probe.min_y() + slop },
rb = { (X_MAX_BED) - probe.max_x() - slop, (Y_MAX_BED) - probe.max_y() - slop };
#endif
if (tramming_3_points) {
switch (i) {
case 0 ... 1:
// First two corners set explicitly by the configuration
switch (lco[i]) {
default:
case LF: return lf; // Left Front
case RF: return xy_pos_t({ rb.x, lf.y }); // Right Front
case RB: return rb; // Right Back
case LB: return xy_pos_t({ lf.x, rb.y }); // Left Back
}
break;
// 3rd point is based on the other two
case 2: return third_point();
// 4th point is optional center
#if ENABLED(BED_TRAMMING_INCLUDE_CENTER)
case 3: return xy_pos_t({ X_CENTER, Y_CENTER });
#endif
}
}
else {
// Four-Corner Bed Tramming with optional center
if (TERN0(BED_TRAMMING_INCLUDE_CENTER, i == center_index)) {
return xy_pos_t({ X_CENTER, Y_CENTER });
}
else {
switch (lco[i]) {
case LF: return lf; // Left Front
case RF: return xy_pos_t({ rb.x, lf.y }); // Right Front
case RB: return rb; // Right Back
case LB: return xy_pos_t({ lf.x, rb.y }); // Left Back
}
}
}
return lf;
return tram_point_by_place(tram_place_by_index(i));
}