Skip to content

Commit

Permalink
Attempt to fix baby stepping when no BLTouch. The baby step offset sh…
Browse files Browse the repository at this point in the history
…ould be displayed correctly. I cannot test it.
  • Loading branch information
Guizz27 committed Jul 10, 2022
1 parent 0eef643 commit de62eb8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
17 changes: 16 additions & 1 deletion Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,18 @@ void DGUSRxHandler::BabystepSet(DGUS_VP& vp, void* data_ptr) {
const int16_t data = Swap16(*(int16_t*)data_ptr);
const float offset = dgus_display.FromFixedPoint<int16_t, float, 2>(data);

#if HAS_LEVELING
const int16_t steps = ExtUI::mmToWholeSteps(offset - ExtUI::getZOffset_mm(), ExtUI::Z);
#else
const int16_t steps = ExtUI::mmToWholeSteps(offset - dgus_screen_handler.baby_offset, ExtUI::Z);
dgus_screen_handler.baby_offset = offset;
#endif

ExtUI::smartAdjustAxis_steps(steps, ExtUI::Z, true);

#if HAS_LEVELING
dgus_screen_handler.TriggerEEPROMSave();
#endif
dgus_screen_handler.TriggerFullUpdate();
}

Expand All @@ -343,15 +350,23 @@ void DGUSRxHandler::Babystep(DGUS_VP& vp, void* data_ptr) {
return;
case DGUS_Data::Adjust::INCREMENT:
steps = ExtUI::mmToWholeSteps(DGUS_PRINT_BABYSTEP, ExtUI::Z);
#if !HAS_LEVELING
dgus_screen_handler.baby_offset += DGUS_PRINT_BABYSTEP;
#endif
break;
case DGUS_Data::Adjust::DECREMENT:
steps = ExtUI::mmToWholeSteps(-DGUS_PRINT_BABYSTEP, ExtUI::Z);
#if !HAS_LEVELING
dgus_screen_handler.baby_offset -= DGUS_PRINT_BABYSTEP;
#endif
break;
}

ExtUI::smartAdjustAxis_steps(steps, ExtUI::Z, true);

dgus_screen_handler.TriggerEEPROMSave();
#if HAS_LEVELING
dgus_screen_handler.TriggerEEPROMSave();
#endif
dgus_screen_handler.TriggerFullUpdate();
}

Expand Down
5 changes: 5 additions & 0 deletions Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ DGUS_Data::StepSize DGUSScreenHandler::move_steps = DGUS_Data::StepSize::MM10;
#if HAS_LEVELING
uint16_t DGUSScreenHandler::probing_colors[] = { 0, 0 };
float DGUSScreenHandler::probing_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
#else
float DGUSScreenHandler::baby_offset = 0;
#endif
uint8_t DGUSScreenHandler::levelingPoint = 0;

Expand Down Expand Up @@ -343,6 +345,9 @@ void DGUSScreenHandler::MeshUpdate(const int8_t xpos, const int8_t ypos, const_f

void DGUSScreenHandler::PrintTimerStarted() {
TriggerScreenChange(DGUS_Screen::PRINT_STATUS);
#if !HAS_LEVELING
baby_offset = 0;
#endif
}

void DGUSScreenHandler::PrintTimerPaused() {
Expand Down
5 changes: 4 additions & 1 deletion Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,13 @@ class DGUSScreenHandler {
static DGUS_Data::StepSize offset_steps;
static DGUS_Data::StepSize move_steps;

#if HAS_LEVELING
#if HAS_LEVELING
static uint16_t probing_colors[2];
static float probing_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
#else
static float baby_offset;
#endif

static uint8_t levelingPoint;

static DGUS_Data::Extruder filament_extruder;
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/lcd/extui/dgus_reloaded/definition/DGUS_VPList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@

VP_HELPER(DGUS_Addr::LEVEL_AUTO_Grid, sizeof(int16_t) * DGUS_LEVEL_GRID_SIZE, VPFLAG_NONE, nullptr, nullptr, &DGUSTxHandler::ABLGrid),
VP_HELPER(DGUS_Addr::SP_LEVEL_AUTO_Grid, 2, VPFLAG_NONE, nullptr, nullptr, &DGUSTxHandler::ABLGridColor),
#else
VP_HELPER_TX_AUTO(DGUS_Addr::LEVEL_OFFSET_Current,
&DGUSScreenHandler::baby_offset,
(&DGUSTxHandler::ExtraToFixedPoint<float, 2>)),
#endif

VP_HELPER_TX(DGUS_Addr::FILAMENT_ExtruderIcons, &DGUSTxHandler::FilamentIcons),
Expand Down

0 comments on commit de62eb8

Please sign in to comment.