Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filament and Z-Probe detection to ProUI endstop_diag.cpp #27423

Open
wants to merge 11 commits into
base: bugfix-2.1.x
Choose a base branch
from
Open
2 changes: 2 additions & 0 deletions Marlin/src/core/language.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@
#define STR_OFF "OFF"
#define STR_ENDSTOP_HIT "TRIGGERED"
#define STR_ENDSTOP_OPEN "open"
#define STR_FILAMENT_PRESENT "PRESENT"
#define STR_RUNOUT_DETECTED "Runout Detected"
#define STR_DUPLICATION_MODE "Duplication mode: "
#define STR_SOFT_MIN " Min: "
#define STR_SOFT_MAX " Max: "
Expand Down
29 changes: 16 additions & 13 deletions Marlin/src/lcd/e3v2/proui/endstop_diag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,12 @@ void draw_es_label(FSTR_P const flabel=nullptr) {
DWINUI::moveBy(0, 25);
}

void draw_es_state(const bool is_hit) {
void draw_es_state(const bool is_hit, const bool is_fil) {
const uint8_t LM = 130;
DWINUI::cursor.x = LM;
dwinDrawRectangle(1, hmiData.colorPopupBg, LM, DWINUI::cursor.y, LM + 100, DWINUI::cursor.y + 20);
is_hit ? DWINUI::drawString(RGB(31,31,16), F(STR_ENDSTOP_HIT)) : DWINUI::drawString(RGB(16,63,16), F(STR_ENDSTOP_OPEN));
dwinDrawRectangle(1, hmiData.colorPopupBg, LM, DWINUI::cursor.y, LM + 120, DWINUI::cursor.y + 20);
is_fil ? (is_hit ? DWINUI::drawString(RGB(16, 63, 16), F(STR_FILAMENT_PRESENT)) : DWINUI::drawString(RGB(31, 31, 16), F(STR_RUNOUT_DETECTED))) :
(is_hit ? DWINUI::drawString(RGB(31, 31, 16), F(STR_ENDSTOP_HIT)) : DWINUI::drawString(RGB(16, 63, 16), F(STR_ENDSTOP_OPEN)));
DWINUI::moveBy(0, 25);
}

Expand All @@ -72,21 +73,23 @@ void ESDiag::draw() {
drawPopupBkgd();
DWINUI::drawButton(BTN_Continue, 86, 250);
DWINUI::cursor.y = 80;
#define ES_LABEL(S) draw_es_label(F(STR_##S))
TERN_(USE_X_MIN, ES_LABEL(X_MIN)); TERN_(USE_X_MAX, ES_LABEL(X_MAX));
TERN_(USE_Y_MIN, ES_LABEL(Y_MIN)); TERN_(USE_Y_MAX, ES_LABEL(Y_MAX));
TERN_(USE_Z_MIN, ES_LABEL(Z_MIN)); TERN_(USE_Z_MAX, ES_LABEL(Z_MAX));
TERN_(HAS_FILAMENT_SENSOR, draw_es_label(F(STR_FILAMENT)));
#define ESLABEL(S) draw_es_label(F(STR_##S))
TERN_(USE_X_MIN, ESLABEL(X_MIN)); TERN_(USE_X_MAX, ESLABEL(X_MAX));
TERN_(USE_Y_MIN, ESLABEL(Y_MIN)); TERN_(USE_Y_MAX, ESLABEL(Y_MAX));
IF_DISABLED(USE_Z_MIN_PROBE, TERN_(USE_Z_MIN, ESLABEL(Z_MIN)); TERN_(USE_Z_MAX, ESLABEL(Z_MAX)));
TERN_(HAS_FILAMENT_SENSOR, ESLABEL(FILAMENT));
TERN_(USE_Z_MIN_PROBE, ESLABEL(Z_PROBE));
update();
}

void ESDiag::update() {
DWINUI::cursor.y = 80;
#define ES_REPORT(S) draw_es_state(READ(S##_PIN) == S##_ENDSTOP_HIT_STATE)
TERN_(USE_X_MIN, ES_REPORT(X_MIN)); TERN_(USE_X_MAX, ES_REPORT(X_MAX));
TERN_(USE_Y_MIN, ES_REPORT(Y_MIN)); TERN_(USE_Y_MAX, ES_REPORT(Y_MAX));
TERN_(USE_Z_MIN, ES_REPORT(Z_MIN)); TERN_(USE_Z_MAX, ES_REPORT(Z_MAX));
TERN_(HAS_FILAMENT_SENSOR, draw_es_state(READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE));
#define ESREPORT(S) draw_es_state(READ(S##_PIN) == S##_ENDSTOP_HIT_STATE, false)
TERN_(USE_X_MIN, ESREPORT(X_MIN)); TERN_(USE_X_MAX, ESREPORT(X_MAX));
TERN_(USE_Y_MIN, ESREPORT(Y_MIN)); TERN_(USE_Y_MAX, ESREPORT(Y_MAX));
IF_DISABLED(USE_Z_MIN_PROBE, TERN_(USE_Z_MIN, ESREPORT(Z_MIN)); TERN_(USE_Z_MAX, ESREPORT(Z_MAX)));
TERN_(HAS_FILAMENT_SENSOR, draw_es_state(READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE, true));
TERN_(USE_Z_MIN_PROBE, ESREPORT(Z_MIN_PROBE));
dwinUpdateLCD();
}

Expand Down