optimise fan check selftest code
Tested on MK3S+ Change in memory: Flash: -174 bytes SRAM: 0 bytes
This commit is contained in:
parent
d6c81dab62
commit
3dda8b5c00
|
|
@ -191,9 +191,9 @@ enum class TestError : uint_least8_t
|
||||||
};
|
};
|
||||||
|
|
||||||
static uint8_t lcd_selftest_screen(TestScreen screen, uint8_t _progress, uint8_t _progress_scale, bool _clear, uint16_t _delay);
|
static uint8_t lcd_selftest_screen(TestScreen screen, uint8_t _progress, uint8_t _progress_scale, bool _clear, uint16_t _delay);
|
||||||
static void lcd_selftest_screen_step(uint8_t _row, uint8_t _col, uint8_t _state, const char *_name, const char _indicator);
|
static void lcd_selftest_screen_step(const uint8_t _row, const uint8_t _col, const uint8_t _state, const char *_name, const char _indicator);
|
||||||
static bool lcd_selftest_manual_fan_check(int _fan, bool check_opposite,
|
static bool lcd_selftest_manual_fan_check(const uint8_t _fan, const bool check_opposite,
|
||||||
bool _default=false);
|
const bool _default=false);
|
||||||
|
|
||||||
#ifdef FANCHECK
|
#ifdef FANCHECK
|
||||||
/** Enumerate for lcd_selftest_fan_auto function.
|
/** Enumerate for lcd_selftest_fan_auto function.
|
||||||
|
|
@ -5027,16 +5027,22 @@ static void lcd_test_menu()
|
||||||
}
|
}
|
||||||
#endif //LCD_TEST
|
#endif //LCD_TEST
|
||||||
|
|
||||||
|
/// @brief Set print fan speed
|
||||||
|
/// @param speed ranges from 0 to 255
|
||||||
|
static void lcd_selftest_setfan(const uint8_t speed) {
|
||||||
|
fanSpeed = speed;
|
||||||
|
#ifdef FAN_SOFT_PWM
|
||||||
|
fanSpeedSoftPwm = speed;
|
||||||
|
#endif
|
||||||
|
manage_heater();
|
||||||
|
}
|
||||||
|
|
||||||
static bool fan_error_selftest()
|
static bool fan_error_selftest()
|
||||||
{
|
{
|
||||||
#ifdef FANCHECK
|
#ifdef FANCHECK
|
||||||
if (!fans_check_enabled) return 0;
|
if (!fans_check_enabled) return 0;
|
||||||
|
|
||||||
fanSpeed = 255;
|
lcd_selftest_setfan(255);
|
||||||
#ifdef FAN_SOFT_PWM
|
|
||||||
fanSpeedSoftPwm = 255;
|
|
||||||
#endif //FAN_SOFT_PWM
|
|
||||||
manage_heater(); //enables print fan
|
|
||||||
setExtruderAutoFanState(3); //force enables the hotend fan
|
setExtruderAutoFanState(3); //force enables the hotend fan
|
||||||
#ifdef FAN_SOFT_PWM
|
#ifdef FAN_SOFT_PWM
|
||||||
extruder_autofan_last_check = _millis();
|
extruder_autofan_last_check = _millis();
|
||||||
|
|
@ -5044,12 +5050,8 @@ static bool fan_error_selftest()
|
||||||
#endif //FAN_SOFT_PWM
|
#endif //FAN_SOFT_PWM
|
||||||
_delay(1000); //delay_keep_alive would turn off hotend fan, because temerature is too low (maybe)
|
_delay(1000); //delay_keep_alive would turn off hotend fan, because temerature is too low (maybe)
|
||||||
manage_heater();
|
manage_heater();
|
||||||
fanSpeed = 0;
|
setExtruderAutoFanState(1); //releases lock on the hotend fan
|
||||||
setExtruderAutoFanState(1); //releases lock on the hotend fan
|
lcd_selftest_setfan(0);
|
||||||
#ifdef FAN_SOFT_PWM
|
|
||||||
fanSpeedSoftPwm = 0;
|
|
||||||
#endif //FAN_SOFT_PWM
|
|
||||||
manage_heater();
|
|
||||||
#ifdef TACH_0
|
#ifdef TACH_0
|
||||||
if (fan_speed[0] <= 20) { //hotend fan error
|
if (fan_speed[0] <= 20) { //hotend fan error
|
||||||
LCD_ALERTMESSAGERPGM(MSG_FANCHECK_HOTEND);
|
LCD_ALERTMESSAGERPGM(MSG_FANCHECK_HOTEND);
|
||||||
|
|
@ -6878,8 +6880,8 @@ static bool selftest_irsensor()
|
||||||
#endif //(FILAMENT_SENSOR_TYPE == FSENSOR_IR) || (FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG)
|
#endif //(FILAMENT_SENSOR_TYPE == FSENSOR_IR) || (FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG)
|
||||||
#endif //FILAMENT_SENSOR
|
#endif //FILAMENT_SENSOR
|
||||||
|
|
||||||
static bool lcd_selftest_manual_fan_check(int _fan, bool check_opposite,
|
static bool lcd_selftest_manual_fan_check(const uint8_t _fan, const bool check_opposite,
|
||||||
bool _default)
|
const bool _default)
|
||||||
{
|
{
|
||||||
|
|
||||||
bool _result = check_opposite;
|
bool _result = check_opposite;
|
||||||
|
|
@ -6897,20 +6899,14 @@ static bool lcd_selftest_manual_fan_check(int _fan, bool check_opposite,
|
||||||
case 1:
|
case 1:
|
||||||
// object cooling fan
|
// object cooling fan
|
||||||
lcd_puts_at_P(0, 1, check_opposite ? _T(MSG_SELFTEST_HOTEND_FAN) : _T(MSG_SELFTEST_PART_FAN));
|
lcd_puts_at_P(0, 1, check_opposite ? _T(MSG_SELFTEST_HOTEND_FAN) : _T(MSG_SELFTEST_PART_FAN));
|
||||||
SET_OUTPUT(FAN_PIN);
|
lcd_selftest_setfan(255);
|
||||||
#ifdef FAN_SOFT_PWM
|
|
||||||
fanSpeedSoftPwm = 255;
|
|
||||||
#else //FAN_SOFT_PWM
|
|
||||||
analogWrite(FAN_PIN, 255);
|
|
||||||
#endif //FAN_SOFT_PWM
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
_delay(500);
|
_delay(500);
|
||||||
|
|
||||||
lcd_puts_at_P(1, 2, _T(MSG_SELFTEST_FAN_YES));
|
lcd_puts_at_P(1, 2, _T(MSG_SELFTEST_FAN_YES));
|
||||||
lcd_putc_at(0, 3, '>');
|
lcd_putc_at(0, 3, '>');
|
||||||
lcd_puts_at_P(1, 3, _T(MSG_SELFTEST_FAN_NO));
|
lcd_puts_P(_T(MSG_SELFTEST_FAN_NO));
|
||||||
|
|
||||||
lcd_encoder = _default;
|
lcd_encoder = _default;
|
||||||
|
|
||||||
|
|
@ -6922,52 +6918,30 @@ static bool lcd_selftest_manual_fan_check(int _fan, bool check_opposite,
|
||||||
if (lcd_encoder < 0) {
|
if (lcd_encoder < 0) {
|
||||||
_result = !check_opposite;
|
_result = !check_opposite;
|
||||||
lcd_putc_at(0, 2, '>');
|
lcd_putc_at(0, 2, '>');
|
||||||
lcd_puts_at_P(1, 2, _T(MSG_SELFTEST_FAN_YES));
|
|
||||||
lcd_putc_at(0, 3, ' ');
|
lcd_putc_at(0, 3, ' ');
|
||||||
lcd_puts_at_P(1, 3, _T(MSG_SELFTEST_FAN_NO));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lcd_encoder > 0) {
|
if (lcd_encoder > 0) {
|
||||||
_result = check_opposite;
|
_result = check_opposite;
|
||||||
lcd_putc_at(0, 2, ' ');
|
lcd_putc_at(0, 2, ' ');
|
||||||
lcd_puts_at_P(1, 2, _T(MSG_SELFTEST_FAN_YES));
|
|
||||||
lcd_putc_at(0, 3, '>');
|
lcd_putc_at(0, 3, '>');
|
||||||
lcd_puts_at_P(1, 3, _T(MSG_SELFTEST_FAN_NO));
|
|
||||||
}
|
}
|
||||||
lcd_encoder = 0;
|
lcd_encoder = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
manage_heater();
|
manage_heater();
|
||||||
manage_inactivity(true);
|
manage_inactivity(true);
|
||||||
_delay(100);
|
_delay(100);
|
||||||
|
|
||||||
} while (!lcd_clicked());
|
} while (!lcd_clicked());
|
||||||
KEEPALIVE_STATE(IN_HANDLER);
|
KEEPALIVE_STATE(IN_HANDLER);
|
||||||
setExtruderAutoFanState(0);
|
setExtruderAutoFanState(0); // Turn off hotend fan
|
||||||
SET_OUTPUT(FAN_PIN);
|
lcd_selftest_setfan(0); // Turn off print fan
|
||||||
#ifdef FAN_SOFT_PWM
|
|
||||||
fanSpeedSoftPwm = 0;
|
|
||||||
#else //FAN_SOFT_PWM
|
|
||||||
analogWrite(FAN_PIN, 0);
|
|
||||||
#endif //FAN_SOFT_PWM
|
|
||||||
fanSpeed = 0;
|
|
||||||
manage_heater();
|
|
||||||
|
|
||||||
return _result;
|
return _result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef FANCHECK
|
#ifdef FANCHECK
|
||||||
// Set print fan speed
|
|
||||||
static void lcd_selftest_setfan(uint8_t speed) {
|
|
||||||
// set the fan speed
|
|
||||||
fanSpeed = speed;
|
|
||||||
#ifdef FAN_SOFT_PWM
|
|
||||||
fanSpeedSoftPwm = speed;
|
|
||||||
#endif
|
|
||||||
manage_heater();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Wait for the specified number of seconds while displaying some single-character indicator on the
|
// Wait for the specified number of seconds while displaying some single-character indicator on the
|
||||||
// screen coordinate col/row, then perform fan measurement
|
// screen coordinate col/row, then perform fan measurement
|
||||||
static void lcd_selftest_measure_fans(uint8_t delay, uint8_t col, uint8_t row) {
|
static void lcd_selftest_measure_fans(uint8_t delay, uint8_t col, uint8_t row) {
|
||||||
|
|
@ -7098,21 +7072,19 @@ static uint8_t lcd_selftest_screen(TestScreen screen, uint8_t _progress, uint8_t
|
||||||
return (_progress >= _progress_scale * 2) ? 0 : _progress;
|
return (_progress >= _progress_scale * 2) ? 0 : _progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lcd_selftest_screen_step(uint8_t _row, uint8_t _col, uint8_t _state, const char *_name_PROGMEM, const char _indicator)
|
static void lcd_selftest_screen_step(const uint8_t _row, const uint8_t _col, const uint8_t _state, const char *_name_PROGMEM, const char _indicator)
|
||||||
{
|
{
|
||||||
lcd_set_cursor(_col, _row);
|
lcd_set_cursor(_col, _row);
|
||||||
uint8_t strlenNameP = strlen_P(_name_PROGMEM);
|
|
||||||
|
|
||||||
switch (_state)
|
switch (_state)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
lcd_puts_P(_name_PROGMEM);
|
lcd_puts_P(_name_PROGMEM);
|
||||||
lcd_putc_at(_col + strlenNameP, _row, ':');
|
lcd_putc(':');
|
||||||
lcd_putc(_indicator);
|
lcd_putc(_indicator);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
lcd_puts_P(_name_PROGMEM);
|
lcd_puts_P(_name_PROGMEM);
|
||||||
lcd_putc_at(_col + strlenNameP, _row, ':');
|
lcd_putc(':');
|
||||||
lcd_puts_P(MSG_OK_CAPS);
|
lcd_puts_P(MSG_OK_CAPS);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue