E3 V2 DWIN: Z-Offset, cleanup, versatility (#19384)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
cosmoderp
2020-09-17 06:35:04 -04:00
committed by GitHub
parent 5926bacea1
commit 073b7f1e3a
9 changed files with 1357 additions and 1087 deletions

View File

@ -576,7 +576,7 @@ volatile bool Temperature::raw_temps_ready = false;
#define MAX_CYCLE_TIME_PID_AUTOTUNE 20L
#endif
if ((ms - _MIN(t1, t2)) > (MAX_CYCLE_TIME_PID_AUTOTUNE * 60L * 1000L)) {
TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(0));
TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0));
TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TUNING_TIMEOUT));
SERIAL_ECHOLNPGM(STR_PID_TIMEOUT);
break;
@ -812,12 +812,16 @@ void Temperature::_temp_error(const heater_id_t heater_id, PGM_P const serial_ms
}
void Temperature::max_temp_error(const heater_id_t heater_id) {
TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(1));
#if ENABLED(DWIN_CREALITY_LCD) && (HAS_HOTEND || HAS_HEATED_BED)
DWIN_Popup_Temperature(1);
#endif
_temp_error(heater_id, PSTR(STR_T_MAXTEMP), GET_TEXT(MSG_ERR_MAXTEMP));
}
void Temperature::min_temp_error(const heater_id_t heater_id) {
TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(0));
#if ENABLED(DWIN_CREALITY_LCD) && (HAS_HOTEND || HAS_HEATED_BED)
DWIN_Popup_Temperature(0);
#endif
_temp_error(heater_id, PSTR(STR_T_MINTEMP), GET_TEXT(MSG_ERR_MINTEMP));
}
@ -1055,7 +1059,7 @@ void Temperature::manage_heater() {
// Make sure temperature is increasing
if (watch_hotend[e].next_ms && ELAPSED(ms, watch_hotend[e].next_ms)) { // Time to check this extruder?
if (degHotend(e) < watch_hotend[e].target) { // Failed to increase enough?
TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(0));
TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0));
_temp_error((heater_id_t)e, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD));
}
else // Start again if the target is still far off
@ -1098,7 +1102,7 @@ void Temperature::manage_heater() {
// Make sure temperature is increasing
if (watch_bed.elapsed(ms)) { // Time to check the bed?
if (degBed() < watch_bed.target) { // Failed to increase enough?
TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(0));
TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0));
_temp_error(H_BED, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD));
}
else // Start again if the target is still far off
@ -2023,7 +2027,7 @@ void Temperature::init() {
state = TRRunaway;
case TRRunaway:
TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(0));
TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0));
_temp_error(heater_id, str_t_thermal_runaway, GET_TEXT(MSG_THERMAL_RUNAWAY));
}
}
@ -2440,14 +2444,8 @@ void Temperature::tick() {
#if DISABLED(SLOW_PWM_HEATERS)
#if HAS_HOTEND || HAS_HEATED_BED || HAS_HEATED_CHAMBER
constexpr uint8_t pwm_mask =
#if ENABLED(SOFT_PWM_DITHER)
_BV(SOFT_PWM_SCALE) - 1
#else
0
#endif
;
#if ANY(HAS_HOTEND, HAS_HEATED_BED, HAS_HEATED_CHAMBER, FAN_SOFT_PWM)
constexpr uint8_t pwm_mask = TERN0(SOFT_PWM_DITHER, _BV(SOFT_PWM_SCALE) - 1);
#define _PWM_MOD(N,S,T) do{ \
const bool on = S.add(pwm_mask, T.soft_pwm_amount); \
WRITE_HEATER_##N(on); \