Skip to content

Commit

Permalink
Merge branch 'bltouch' into 2.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Guizz27 committed Mar 31, 2021
2 parents eaca9e9 + e292c3b commit 101847e
Show file tree
Hide file tree
Showing 16 changed files with 149 additions and 137 deletions.
2 changes: 1 addition & 1 deletion Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@
* A total of 2 does fast/slow probes with a weighted average.
* A total of 3 or more adds more slow probes, taking the average.
*/
#ifdef LK4_Pro_BLTOUCH // TODO
#ifdef LK4_Pro_BLTOUCH // Set to your liking
#define MULTIPLE_PROBING 2
#define EXTRA_PROBING 1
#else
Expand Down
4 changes: 3 additions & 1 deletion Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1630,7 +1630,9 @@

//#define BABYSTEP_DISPLAY_TOTAL // Display total babysteps since last G28

#define BABYSTEP_ZPROBE_OFFSET // Combine M851 Z and Babystepping
#if HAS_BED_PROBE
#define BABYSTEP_ZPROBE_OFFSET // Combine M851 Z and Babystepping
#endif
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
//#define BABYSTEP_HOTEND_Z_OFFSET // For multiple hotends, babystep relative Z offsets
//#define BABYSTEP_ZPROBE_GFX_OVERLAY // Enable graphical overlay on Z-offset editor
Expand Down
10 changes: 4 additions & 6 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -3214,16 +3214,14 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2)
#error "DGUS_LCD_UI_RELOADED requires a heated bed."
#elif FAN_COUNT < 1
#error "DGUS_LCD_UI_RELOADED requires a fan."
#elif !HAS_BED_PROBE
#error "DGUS_LCD_UI_RELOADED requires a bed probe."
#elif !HAS_MESH
#error "DGUS_LCD_UI_RELOADED requires mesh leveling."
#elif DISABLED(ADVANCED_PAUSE_FEATURE)
#error "DGUS_LCD_UI_RELOADED requires ADVANCED_PAUSE_FEATURE."
#elif DISABLED(LEVEL_BED_CORNERS)
#error "DGUS_LCD_UI_RELOADED requires LEVEL_BED_CORNERS."
#elif DISABLED(BABYSTEP_ALWAYS_AVAILABLE)
#error "DGUS_LCD_UI_RELOADED requires BABYSTEP_ALWAYS_AVAILABLE."
#elif DISABLED(BABYSTEP_ZPROBE_OFFSET)
#error "DGUS_LCD_UI_RELOADED requires BABYSTEP_ZPROBE_OFFSET."
#elif DISABLED(BABYSTEP_ZPROBE_OFFSET) && HAS_BED_PROBE
#error "DGUS_LCD_UI_RELOADED requires BABYSTEP_ZPROBE_OFFSET with a probe."
#elif ENABLED(AUTO_BED_LEVELING_UBL) && DISABLED(UBL_SAVE_ACTIVE_ON_M500)
#warning "Without UBL_SAVE_ACTIVE_ON_M500, your mesh will not be saved when using the touchscreen."
#endif
Expand Down
108 changes: 43 additions & 65 deletions Marlin/src/lcd/extui/lib/dgus_reloaded/DGUSRxHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ const char DGUS_MDG_NOT_WHILE_PRINTING[] PROGMEM = "Impossible while printing",
#undef fr_na
#undef fr


void DGUSRxHandler::ScreenChange(DGUS_VP &vp, void *data_ptr)
{
DGUS_Screen screen = (DGUS_Screen)((uint8_t *)data_ptr)[1];
Expand Down Expand Up @@ -119,6 +118,18 @@ void DGUSRxHandler::ScreenChange(DGUS_VP &vp, void *data_ptr)
screen = DGUS_Screen::HOME;
}

#if !HAS_LEVELING
// Skip Leveling menu if no automatic leveling
if(screen == DGUS_Screen::LEVELING_MENU) {
if(dgus_screen_handler.GetCurrentScreen() == DGUS_Screen::SETTINGS_MENU) {
screen = DGUS_Screen::LEVELING_MANUAL;
}
else {
screen = DGUS_Screen::SETTINGS_MENU;
}
}
#endif

dgus_screen_handler.TriggerScreenChange(screen);
}

Expand Down Expand Up @@ -515,6 +526,7 @@ void DGUSRxHandler::RunoutControl(DGUS_VP &vp, void *data_ptr)
dgus_screen_handler.TriggerFullUpdate();
}

#if HAS_LEVELING
void DGUSRxHandler::ZOffset(DGUS_VP &vp, void *data_ptr)
{
UNUSED(vp);
Expand Down Expand Up @@ -589,62 +601,36 @@ void DGUSRxHandler::ZOffsetSetStep(DGUS_VP &vp, void *data_ptr)

dgus_screen_handler.TriggerFullUpdate();
}
#endif

void DGUSRxHandler::MoveToPoint(DGUS_VP &vp, void *data_ptr)
{
UNUSED(vp);

if (!ExtUI::isPositionKnown())
{
dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_HOMING_REQUIRED);
return;
}

if (!dgus_screen_handler.IsPrinterIdle())
{
dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_BUSY);
return;
}

const uint8_t point = ((uint8_t *)data_ptr)[1];
constexpr float lfrb[4] = LEVEL_CORNERS_INSET_LFRB;
float x, y;
dgus_screen_handler.levelingPoint = ((uint8_t *)data_ptr)[1];

switch (point)
if (!ExtUI::isPositionKnown())
{
default:
dgus_screen_handler.SetMessageLinePGM(NUL_STR, 1);
dgus_screen_handler.SetMessageLinePGM(DGUS_MSG_HOMING, 2);
dgus_screen_handler.SetMessageLinePGM(NUL_STR, 3);
dgus_screen_handler.SetMessageLinePGM(NUL_STR, 4);
dgus_screen_handler.ShowWaitScreen(DGUS_Screen::LEVELING_MANUAL);
queue.enqueue_now_P(DGUS_CMD_HOME);
return;
case 1:
x = DGUS_LEVEL_CENTER_X;
y = DGUS_LEVEL_CENTER_Y;
break;
case 2:
x = X_MIN_POS + lfrb[0];
y = Y_MIN_POS + lfrb[1];
break;
case 3:
x = X_MAX_POS - lfrb[2];
y = Y_MIN_POS + lfrb[1];
break;
case 4:
x = X_MAX_POS - lfrb[2];
y = Y_MAX_POS - lfrb[3];
break;
case 5:
x = X_MIN_POS + lfrb[0];
y = Y_MAX_POS - lfrb[3];
break;
}

if (ExtUI::getAxisPosition_mm(ExtUI::Z) < Z_MIN_POS + LEVEL_CORNERS_Z_HOP)
{
ExtUI::setAxisPosition_mm(Z_MIN_POS + LEVEL_CORNERS_Z_HOP, ExtUI::Z);
}
ExtUI::setAxisPosition_mm(x, ExtUI::X);
ExtUI::setAxisPosition_mm(y, ExtUI::Y);
ExtUI::setAxisPosition_mm(Z_MIN_POS + LEVEL_CORNERS_HEIGHT, ExtUI::Z);
dgus_screen_handler.MoveToLevelPoint();

}

#if HAS_LEVELING
void DGUSRxHandler::Probe(DGUS_VP &vp, void *data_ptr)
{
UNUSED(vp);
Expand All @@ -655,43 +641,35 @@ void DGUSRxHandler::Probe(DGUS_VP &vp, void *data_ptr)
return;
#endif

if (!ExtUI::isPositionKnown()) {
dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_HOMING_REQUIRED);
return;
}

if (!dgus_screen_handler.IsPrinterIdle())
{
dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_BUSY);
return;
}

dgus_screen_handler.TriggerScreenChange(DGUS_Screen::LEVELING_PROBING);

#if ENABLED(AUTO_BED_LEVELING_UBL)
queue.enqueue_now_P(PSTR("G29P1\nG29P3\nG29P5C"));
#else
queue.enqueue_now_P(PSTR("G29"));
#endif
// queue.enqueue_now_P(DGUS_CMD_EEPROM_SAVE);
}

void DGUSRxHandler::DisableABL(DGUS_VP &vp, void *data_ptr)
{
UNUSED(vp);
UNUSED(data_ptr);

if (!dgus_screen_handler.IsPrinterIdle())
{
dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_BUSY);
if (!ExtUI::isPositionKnown()) {
// Home
// dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_HOMING_REQUIRED);
dgus_screen_handler.SetMessageLinePGM(NUL_STR, 1);
dgus_screen_handler.SetMessageLinePGM(DGUS_MSG_HOMING, 2);
dgus_screen_handler.SetMessageLinePGM(NUL_STR, 3);
dgus_screen_handler.SetMessageLinePGM(NUL_STR, 4);
dgus_screen_handler.ShowWaitScreen(DGUS_Screen::LEVELING_PROBING);

queue.enqueue_now_P(DGUS_CMD_HOME);
return;
}

ExtUI::setLevelingActive(false);
// dgus_screen_handler.TriggerScreenChange(DGUS_Screen::LEVELING_PROBING);

// dgus_screen_handler.TriggerEEPROMSave();
dgus_screen_handler.TriggerFullUpdate();
// #if ENABLED(AUTO_BED_LEVELING_UBL)
// queue.enqueue_now_P(PSTR("G29P1\nG29P3\nG29P5C"));
// #else
// queue.enqueue_now_P(PSTR("G29"));
// #endif
// queue.enqueue_now_P(DGUS_CMD_EEPROM_SAVE);
}
#endif

void DGUSRxHandler::FilamentSelect(DGUS_VP &vp, void *data_ptr)
{
Expand Down
7 changes: 4 additions & 3 deletions Marlin/src/lcd/extui/lib/dgus_reloaded/DGUSRxHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,16 @@ namespace DGUSRxHandler {

void Steppers(DGUS_VP &, void *);
void RunoutControl(DGUS_VP &, void *);

#if HAS_LEVELING
void ZOffset(DGUS_VP &, void *);
void ZOffsetStep(DGUS_VP &, void *);
void ZOffsetSetStep(DGUS_VP &, void *);

#endif
void MoveToPoint(DGUS_VP &, void *);

#if HAS_LEVELING
void Probe(DGUS_VP &, void *);
void DisableABL(DGUS_VP &, void *);
#endif

void FilamentSelect(DGUS_VP &, void *);
void FilamentLength(DGUS_VP &, void *);
Expand Down
50 changes: 49 additions & 1 deletion Marlin/src/lcd/extui/lib/dgus_reloaded/DGUSScreenHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ 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 };
uint8_t DGUSScreenHandler::levelingPoint = 0;

DGUS_Data::Extruder DGUSScreenHandler::filament_extruder = DGUS_Data::Extruder::CURRENT;
uint16_t DGUSScreenHandler::filament_length = DGUS_DEFAULT_FILAMENT_LEN;
Expand Down Expand Up @@ -165,6 +166,7 @@ void DGUSScreenHandler::Loop() {
return;
}

#if HAS_LEVELING
if (current_screen == DGUS_Screen::LEVELING_PROBING
&& IsPrinterIdle()) {
dgus_display.PlaySound(3);
Expand All @@ -176,6 +178,7 @@ void DGUSScreenHandler::Loop() {
MoveToScreen(DGUS_Screen::LEVELING_AUTOMATIC);
return;
}
#endif

if (status_expire > 0 && ELAPSED(ms, status_expire)) {
SetStatusMessagePGM(NUL_STR, 0);
Expand Down Expand Up @@ -235,8 +238,9 @@ void DGUSScreenHandler::StoreSettings(char *buff) {
data.initialized = true;
data.volume = dgus_display.GetVolume();
data.brightness = dgus_display.GetBrightness();
#if HAS_LEVELING
data.abl = (ExtUI::getLevelingActive() && ExtUI::getMeshValid());

#endif
memcpy(buff, &data, sizeof(data));
}

Expand All @@ -250,11 +254,13 @@ void DGUSScreenHandler::LoadSettings(const char *buff) {
dgus_display.SetVolume(data.initialized ? data.volume : DGUS_DEFAULT_VOLUME);
dgus_display.SetBrightness(data.initialized ? data.brightness : DGUS_DEFAULT_BRIGHTNESS);

#if HAS_LEVELING
if (data.initialized) {
leveling_active = (data.abl && ExtUI::getMeshValid());

ExtUI::setLevelingActive(leveling_active);
}
#endif
}

void DGUSScreenHandler::ConfigurationStoreWritten(bool success) {
Expand Down Expand Up @@ -287,6 +293,47 @@ void DGUSScreenHandler::PlayTone(const uint16_t frequency, const uint16_t durati
}
}

void DGUSScreenHandler::MoveToLevelPoint() {
constexpr float lfrb[4] = LEVEL_CORNERS_INSET_LFRB;
float x, y;

switch (levelingPoint)
{
default:
return;
case 1:
x = DGUS_LEVEL_CENTER_X;
y = DGUS_LEVEL_CENTER_Y;
break;
case 2:
x = X_MIN_POS + lfrb[0];
y = Y_MIN_POS + lfrb[1];
break;
case 3:
x = X_MAX_POS - lfrb[2];
y = Y_MIN_POS + lfrb[1];
break;
case 4:
x = X_MAX_POS - lfrb[2];
y = Y_MAX_POS - lfrb[3];
break;
case 5:
x = X_MIN_POS + lfrb[0];
y = Y_MAX_POS - lfrb[3];
break;
};

if (ExtUI::getAxisPosition_mm(ExtUI::Z) < Z_MIN_POS + LEVEL_CORNERS_Z_HOP)
{
ExtUI::setAxisPosition_mm(Z_MIN_POS + LEVEL_CORNERS_Z_HOP, ExtUI::Z);
}
ExtUI::setAxisPosition_mm(x, ExtUI::X);
ExtUI::setAxisPosition_mm(y, ExtUI::Y);
ExtUI::setAxisPosition_mm(Z_MIN_POS + LEVEL_CORNERS_HEIGHT, ExtUI::Z);
levelingPoint = 0;
}

#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();
Expand All @@ -303,6 +350,7 @@ void DGUSScreenHandler::MeshUpdate(const int8_t xpos, const int8_t ypos) {

TriggerFullUpdate();
}
#endif

void DGUSScreenHandler::PrintTimerStarted() {
TriggerScreenChange(DGUS_Screen::PRINT_STATUS);
Expand Down
3 changes: 3 additions & 0 deletions Marlin/src/lcd/extui/lib/dgus_reloaded/DGUSScreenHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ class DGUSScreenHandler {

static bool IsPrinterIdle();

static void MoveToLevelPoint();

static uint8_t debug_count;

#if ENABLED(SDSUPPORT)
Expand All @@ -101,6 +103,7 @@ class DGUSScreenHandler {
static DGUS_Data::StepSize move_steps;

static uint16_t probing_icons[2];
static uint8_t levelingPoint;

static DGUS_Data::Extruder filament_extruder;
static uint16_t filament_length;
Expand Down
Loading

0 comments on commit 101847e

Please sign in to comment.