Skip to content

Commit

Permalink
Fixed scrolling passed the end of file list.
Browse files Browse the repository at this point in the history
Fixed auto leveling not starting
Fixed auto leveling not updating values when probing
  • Loading branch information
Guizz27 committed Jun 21, 2022
1 parent ef78161 commit 8fd3a64
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Marlin/src/gcode/calibrate/G28.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ void GcodeSuite::G28() {

// Disable the leveling matrix before homing
#if CAN_SET_LEVELING_AFTER_G28
const bool leveling_restore_state = parser.boolval('L', TERN1(RESTORE_LEVELING_AFTER_G28, planner.leveling_active));
const bool leveling_restore_state = ENABLED(ENABLE_LEVELING_AFTER_G28) || parser.boolval('L', TERN1(RESTORE_LEVELING_AFTER_G28, planner.leveling_active));
#endif

// Cancel any prior G29 session
Expand Down
11 changes: 7 additions & 4 deletions Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@ void DGUSRxHandler::Scroll(DGUS_VP& vp, void* data_ptr) {
break;

case DGUS_Data::Scroll::DOWN:
if (dgus_screen_handler.filelist_offset + offset >= dgus_screen_handler.filelist.count()) {
offset = dgus_screen_handler.filelist.count() - offset;
if (dgus_screen_handler.filelist_offset + offset < dgus_screen_handler.filelist.count()) {
//offset = dgus_screen_handler.filelist.count() - offset;
dgus_screen_handler.filelist_offset += offset;
// offset = 0;
}

dgus_screen_handler.filelist_offset += offset;
break;
}
DEBUG_ECHOLNPAIR_F("New offset ", dgus_screen_handler.filelist_offset, " file count ", dgus_screen_handler.filelist.count());
Expand Down Expand Up @@ -595,6 +595,9 @@ void DGUSRxHandler::Probe(DGUS_VP& vp, void* data_ptr) {
queue.enqueue_now_P(DGUS_CMD_HOME);
return;
}
else {
dgus_screen_handler.TriggerScreenChange(DGUS_Screen::LEVELING_PROBING);
}
}
#endif

Expand Down
15 changes: 8 additions & 7 deletions Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ int16_t DGUSScreenHandler::filelist_selected = -1;
DGUS_Data::StepSize DGUSScreenHandler::offset_steps = DGUS_Data::StepSize::MMP1;
DGUS_Data::StepSize DGUSScreenHandler::move_steps = DGUS_Data::StepSize::MM10;

uint16_t DGUSScreenHandler::probing_icons[] = { 0, 0 };
#if HAS_LEVELING
uint16_t DGUSScreenHandler::probing_colors[] = { 0, 0 };
float DGUSScreenHandler::probing_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
#endif
uint8_t DGUSScreenHandler::levelingPoint = 0;

DGUS_Data::Extruder DGUSScreenHandler::filament_extruder = DGUS_Data::Extruder::CURRENT;
Expand Down Expand Up @@ -326,15 +329,13 @@ void DGUSScreenHandler::MoveToLevelPoint() {
}

#if HAS_LEVELING
void DGUSScreenHandler::MeshUpdate(const int8_t xpos, const int8_t ypos) {
// if (current_screen == DGUS_Screen::LEVELING_PROBING || current_screen == DGUS_Screen::LEVELING_AUTOMATIC) {
// TriggerFullUpdate();
// }
void DGUSScreenHandler::MeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) {
probing_values[xpos][ypos] = zval;
uint8_t point = ypos * GRID_MAX_POINTS_X + xpos;
probing_icons[point < 16 ? 0 : 1] |= (1U << (point % 16));
probing_colors[point < 16 ? 0 : 1] |= (1U << (point % 16));

if (xpos >= GRID_MAX_POINTS_X - 1 && ypos >= GRID_MAX_POINTS_Y - 1 && !ExtUI::getMeshValid())
probing_icons[0] = probing_icons[1] = 0;
probing_colors[0] = probing_colors[1] = 0;

TriggerFullUpdate();
}
Expand Down
7 changes: 5 additions & 2 deletions Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class DGUSScreenHandler {
static void ConfigurationStoreRead(bool success);

static void PlayTone(const uint16_t frequency, const uint16_t duration);
static void MeshUpdate(const int8_t xpos, const int8_t ypos);
static void MeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval);
static void PrintTimerStarted();
static void PrintTimerPaused();
static void PrintTimerStopped();
Expand Down Expand Up @@ -101,7 +101,10 @@ class DGUSScreenHandler {
static DGUS_Data::StepSize offset_steps;
static DGUS_Data::StepSize move_steps;

static uint16_t probing_icons[2];
#if HAS_LEVELING
static uint16_t probing_colors[2];
static float probing_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
#endif
static uint8_t levelingPoint;

static DGUS_Data::Extruder filament_extruder;
Expand Down
10 changes: 8 additions & 2 deletions Marlin/src/lcd/extui/dgus_reloaded/DGUSSetupHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@

#include "../../../gcode/queue.h"

#if HAS_LEVELING
#include "../../../feature/bedlevel/bedlevel.h"
#endif

#if ENABLED(SDSUPPORT)
bool DGUSSetupHandler::Print() {
dgus_screen_handler.filelist.refresh();
Expand Down Expand Up @@ -133,13 +137,15 @@ bool DGUSSetupHandler::LevelingAutomatic() {

ExtUI::setLevelingActive(true);
}
COPY(dgus_screen_handler.probing_values, bedlevel.z_values);

return true;
}

bool DGUSSetupHandler::LevelingProbing() {
dgus_screen_handler.probing_icons[0] = 0;
dgus_screen_handler.probing_icons[1] = 0;
dgus_screen_handler.probing_colors[0] = 0;
dgus_screen_handler.probing_colors[1] = 0;
COPY(dgus_screen_handler.probing_values, bedlevel.z_values);

#if ENABLED(AUTO_BED_LEVELING_UBL)
queue.enqueue_now_P(PSTR("G29P1\nG29P3\nG29P5C"));
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ void DGUSTxHandler::ABLGrid(DGUS_VP& vp) {
for (int i = 0; i < DGUS_LEVEL_GRID_SIZE; i++) {
point.x = i % (GRID_MAX_POINTS_X);
point.y = i / (GRID_MAX_POINTS_X);
fixed = dgus_display.ToFixedPoint<float, int16_t, 3>(ExtUI::getMeshPoint(point));
fixed = dgus_display.ToFixedPoint<float, int16_t, 3>(dgus_screen_handler.probing_values[point.x][point.y]);
DEBUG_ECHOLNPAIR_F("grid x ", point.x, " y ", point.y, " value ", fixed);
data[i] = Swap16(fixed);
}
Expand All @@ -381,7 +381,7 @@ void DGUSTxHandler::ABLGridColor(DGUS_VP& vp) {
// Set color for each value
for (int point = 0; point < DGUS_LEVEL_GRID_SIZE; point++) {
uint16_t color = Swap16(COLOR_WHITE);
if ((dgus_screen_handler.probing_icons[point < 16 ? 0 : 1] & (1U << (point % 16))) != 0) {
if ((dgus_screen_handler.probing_colors[point < 16 ? 0 : 1] & (1U << (point % 16))) != 0) {
color = Swap16(COLOR_GREEN);
}
dgus_display.Write((uint16_t)vp.addr + point * DGUS_SP_VARIABLE_LEN + (int)DGUS_SP_Variable::COLOR, color);
Expand Down
5 changes: 3 additions & 2 deletions Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,16 @@ namespace ExtUI {

#if HAS_MESH
void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) {
dgus_screen_handler.MeshUpdate(xpos, ypos);
dgus_screen_handler.MeshUpdate(xpos, ypos, zval);
}
//#if HAS_MESH
void onLevelingStart() {}
void onLevelingDone() {}

void onMeshUpdate(const int8_t xpos, const int8_t ypos, const ExtUI::probe_state_t state) {
if (state == ExtUI::probe_state_t::G29_POINT_FINISH) {
dgus_screen_handler.MeshUpdate(xpos, ypos);
xy_uint8_t pos = { (uint8_t)xpos, (uint8_t)ypos };
dgus_screen_handler.MeshUpdate(xpos, ypos, ExtUI::getMeshPoint(pos));
}
}

Expand Down

0 comments on commit 8fd3a64

Please sign in to comment.