merging changes from upstream

This commit is contained in:
PavelSindler 2019-01-28 11:00:42 +01:00
commit 7889305702
2 changed files with 74 additions and 56 deletions

View File

@ -1539,7 +1539,7 @@ void adc_ready(void) //callback from adc when sampling finished
// Timer 0 is shared with millies // Timer 0 is shared with millies
ISR(TIMER0_COMPB_vect) ISR(TIMER0_COMPB_vect) // @ 1kHz ~ 1ms
{ {
static bool _lock = false; static bool _lock = false;
if (_lock) return; if (_lock) return;

View File

@ -158,7 +158,26 @@ static bool lcd_selfcheck_pulleys(int axis);
#endif //TMC2130 #endif //TMC2130
static bool lcd_selfcheck_check_heater(bool _isbed); static bool lcd_selfcheck_check_heater(bool _isbed);
static int lcd_selftest_screen(int _step, int _progress, int _progress_scale, bool _clear, int _delay); enum class testScreen
{
extruderFan,
printFan,
fansOk,
endStops,
axisX,
axisY,
axisZ,
bed,
hotend,
hotendOk,
fsensor,
fsensorOk,
allCorrect,
failed,
home,
};
static int lcd_selftest_screen(testScreen screen, int _progress, int _progress_scale, bool _clear, int _delay);
static void lcd_selftest_screen_step(int _row, int _col, int _state, const char *_name, const char *_indicator); static void lcd_selftest_screen_step(int _row, int _col, int _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(int _fan, bool check_opposite);
static bool lcd_selftest_fan_dialog(int _fan); static bool lcd_selftest_fan_dialog(int _fan);
@ -6295,7 +6314,7 @@ bool lcd_selftest()
delay(2000); delay(2000);
KEEPALIVE_STATE(IN_HANDLER); KEEPALIVE_STATE(IN_HANDLER);
_progress = lcd_selftest_screen(-1, _progress, 3, true, 2000); _progress = lcd_selftest_screen(testScreen::extruderFan, _progress, 3, true, 2000);
#if (defined(FANCHECK) && defined(TACH_0)) #if (defined(FANCHECK) && defined(TACH_0))
_result = lcd_selftest_fan_dialog(0); _result = lcd_selftest_fan_dialog(0);
#else //defined(TACH_0) #else //defined(TACH_0)
@ -6310,7 +6329,7 @@ bool lcd_selftest()
if (_result) if (_result)
{ {
_progress = lcd_selftest_screen(0, _progress, 3, true, 2000); _progress = lcd_selftest_screen(testScreen::printFan, _progress, 3, true, 2000);
#if (defined(FANCHECK) && defined(TACH_1)) #if (defined(FANCHECK) && defined(TACH_1))
_result = lcd_selftest_fan_dialog(1); _result = lcd_selftest_fan_dialog(1);
#else //defined(TACH_1) #else //defined(TACH_1)
@ -6326,7 +6345,7 @@ bool lcd_selftest()
if (_result) if (_result)
{ {
_progress = lcd_selftest_screen(1, _progress, 3, true, 2000); _progress = lcd_selftest_screen(testScreen::fansOk, _progress, 3, true, 2000);
#ifndef TMC2130 #ifndef TMC2130
_result = lcd_selfcheck_endstops(); _result = lcd_selfcheck_endstops();
#else #else
@ -6337,7 +6356,7 @@ bool lcd_selftest()
if (_result) if (_result)
{ {
//current_position[Z_AXIS] += 15; //move Z axis higher to avoid false triggering of Z end stop in case that we are very low - just above heatbed //current_position[Z_AXIS] += 15; //move Z axis higher to avoid false triggering of Z end stop in case that we are very low - just above heatbed
_progress = lcd_selftest_screen(3, _progress, 3, true, 2000); _progress = lcd_selftest_screen(testScreen::axisX, _progress, 3, true, 2000);
#ifdef TMC2130 #ifdef TMC2130
_result = lcd_selfcheck_axis_sg(X_AXIS); _result = lcd_selfcheck_axis_sg(X_AXIS);
#else #else
@ -6350,7 +6369,7 @@ bool lcd_selftest()
if (_result) if (_result)
{ {
_progress = lcd_selftest_screen(3, _progress, 3, true, 0); _progress = lcd_selftest_screen(testScreen::axisX, _progress, 3, true, 0);
#ifndef TMC2130 #ifndef TMC2130
_result = lcd_selfcheck_pulleys(X_AXIS); _result = lcd_selfcheck_pulleys(X_AXIS);
@ -6360,7 +6379,7 @@ bool lcd_selftest()
if (_result) if (_result)
{ {
_progress = lcd_selftest_screen(4, _progress, 3, true, 1500); _progress = lcd_selftest_screen(testScreen::axisY, _progress, 3, true, 1500);
#ifdef TMC2130 #ifdef TMC2130
_result = lcd_selfcheck_axis_sg(Y_AXIS); _result = lcd_selfcheck_axis_sg(Y_AXIS);
#else #else
@ -6370,7 +6389,7 @@ bool lcd_selftest()
if (_result) if (_result)
{ {
_progress = lcd_selftest_screen(4, _progress, 3, true, 0); _progress = lcd_selftest_screen(testScreen::axisZ, _progress, 3, true, 0);
#ifndef TMC2130 #ifndef TMC2130
_result = lcd_selfcheck_pulleys(Y_AXIS); _result = lcd_selfcheck_pulleys(Y_AXIS);
#endif // TMC2130 #endif // TMC2130
@ -6391,7 +6410,7 @@ bool lcd_selftest()
current_position[Z_AXIS] = current_position[Z_AXIS] + 10; current_position[Z_AXIS] = current_position[Z_AXIS] + 10;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder); plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder);
st_synchronize(); st_synchronize();
_progress = lcd_selftest_screen(5, _progress, 3, true, 1500); _progress = lcd_selftest_screen(testScreen::axisZ, _progress, 3, true, 1500);
_result = lcd_selfcheck_axis(2, Z_MAX_POS); _result = lcd_selfcheck_axis(2, Z_MAX_POS);
if (eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE) != 1) { if (eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE) != 1) {
enquecommand_P(PSTR("G28 W")); enquecommand_P(PSTR("G28 W"));
@ -6405,11 +6424,11 @@ bool lcd_selftest()
current_position[Z_AXIS] = current_position[Z_AXIS] + 10; current_position[Z_AXIS] = current_position[Z_AXIS] + 10;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder); plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder);
st_synchronize(); st_synchronize();
_progress = lcd_selftest_screen(13, 0, 2, true, 0); _progress = lcd_selftest_screen(testScreen::home, 0, 2, true, 0);
bool bres = tmc2130_home_calibrate(X_AXIS); bool bres = tmc2130_home_calibrate(X_AXIS);
_progress = lcd_selftest_screen(13, 1, 2, true, 0); _progress = lcd_selftest_screen(testScreen::home, 1, 2, true, 0);
bres &= tmc2130_home_calibrate(Y_AXIS); bres &= tmc2130_home_calibrate(Y_AXIS);
_progress = lcd_selftest_screen(13, 2, 2, true, 0); _progress = lcd_selftest_screen(testScreen::home, 2, 2, true, 0);
if (bres) if (bres)
eeprom_update_byte((uint8_t*)EEPROM_TMC2130_HOME_ENABLED, 1); eeprom_update_byte((uint8_t*)EEPROM_TMC2130_HOME_ENABLED, 1);
_result = bres; _result = bres;
@ -6418,18 +6437,18 @@ bool lcd_selftest()
if (_result) if (_result)
{ {
_progress = lcd_selftest_screen(6, _progress, 3, true, 2000); //check bed _progress = lcd_selftest_screen(testScreen::bed, _progress, 3, true, 2000);
_result = lcd_selfcheck_check_heater(true); _result = lcd_selfcheck_check_heater(true);
} }
if (_result) if (_result)
{ {
_progress = lcd_selftest_screen(7, _progress, 3, true, 1000); //check nozzle _progress = lcd_selftest_screen(testScreen::hotend, _progress, 3, true, 1000);
_result = lcd_selfcheck_check_heater(false); _result = lcd_selfcheck_check_heater(false);
} }
if (_result) if (_result)
{ {
_progress = lcd_selftest_screen(8, _progress, 3, true, 2000); //nozzle ok _progress = lcd_selftest_screen(testScreen::hotendOk, _progress, 3, true, 2000); //nozzle ok
} }
#ifdef FILAMENT_SENSOR #ifdef FILAMENT_SENSOR
if (_result) if (_result)
@ -6458,11 +6477,11 @@ bool lcd_selftest()
#endif //FILAMENT_SENSOR #endif //FILAMENT_SENSOR
if (_result) if (_result)
{ {
_progress = lcd_selftest_screen(11, _progress, 3, true, 5000); //all correct _progress = lcd_selftest_screen(testScreen::allCorrect, _progress, 3, true, 5000); //all correct
} }
else else
{ {
_progress = lcd_selftest_screen(12, _progress, 3, true, 5000); _progress = lcd_selftest_screen(testScreen::failed, _progress, 3, true, 5000);
} }
lcd_reset_alert_level(); lcd_reset_alert_level();
enquecommand_P(PSTR("M84")); enquecommand_P(PSTR("M84"));
@ -6669,7 +6688,7 @@ static bool lcd_selfcheck_axis(int _axis, int _travel)
} }
else else
{ {
_progress = lcd_selftest_screen(3 + _axis, _progress, 3, false, 0); _progress = lcd_selftest_screen(static_cast<testScreen>(static_cast<int>(testScreen::axisX) + _axis), _progress, 3, false, 0);
_lcd_refresh = 0; _lcd_refresh = 0;
} }
@ -6836,7 +6855,7 @@ static bool lcd_selfcheck_check_heater(bool _isbed)
manage_heater(); manage_heater();
manage_inactivity(true); manage_inactivity(true);
_progress = (_isbed) ? lcd_selftest_screen(6, _progress, 2, false, 400) : lcd_selftest_screen(7, _progress, 2, false, 400); _progress = (_isbed) ? lcd_selftest_screen(testScreen::bed, _progress, 2, false, 400) : lcd_selftest_screen(testScreen::hotend, _progress, 2, false, 400);
/*if (_isbed) { /*if (_isbed) {
MYSERIAL.print("Bed temp:"); MYSERIAL.print("Bed temp:");
MYSERIAL.println(degBed()); MYSERIAL.println(degBed());
@ -7046,16 +7065,16 @@ static bool selftest_irsensor()
TempBackup tempBackup; TempBackup tempBackup;
setTargetHotend(ABS_PREHEAT_HOTEND_TEMP,active_extruder); setTargetHotend(ABS_PREHEAT_HOTEND_TEMP,active_extruder);
mmu_wait_for_heater_blocking(); mmu_wait_for_heater_blocking();
progress = lcd_selftest_screen(9, 0, 1, true, 0); progress = lcd_selftest_screen(testScreen::fsensor, 0, 1, true, 0);
mmu_filament_ramming(); mmu_filament_ramming();
} }
progress = lcd_selftest_screen(9, progress, 1, true, 0); progress = lcd_selftest_screen(testScreen::fsensor, progress, 1, true, 0);
mmu_command(MMU_CMD_U0); mmu_command(MMU_CMD_U0);
manage_response(false, false); manage_response(false, false);
for(uint_least8_t i = 0; i < 200; ++i) for(uint_least8_t i = 0; i < 200; ++i)
{ {
if (0 == (i % 32)) progress = lcd_selftest_screen(9, progress, 1, true, 0); if (0 == (i % 32)) progress = lcd_selftest_screen(testScreen::fsensor, progress, 1, true, 0);
mmu_load_step(false); mmu_load_step(false);
while (blocks_queued()) while (blocks_queued())
@ -7233,12 +7252,11 @@ static bool lcd_selftest_fan_dialog(int _fan)
return _result; return _result;
} }
static int lcd_selftest_screen(int _step, int _progress, int _progress_scale, bool _clear, int _delay) static int lcd_selftest_screen(testScreen screen, int _progress, int _progress_scale, bool _clear, int _delay)
{ {
lcd_update_enable(false); lcd_update_enable(false);
int _step_block = 0;
const char *_indicator = (_progress >= _progress_scale) ? "-" : "|"; const char *_indicator = (_progress >= _progress_scale) ? "-" : "|";
if (_clear) lcd_clear(); if (_clear) lcd_clear();
@ -7246,58 +7264,58 @@ static int lcd_selftest_screen(int _step, int _progress, int _progress_scale, bo
lcd_set_cursor(0, 0); lcd_set_cursor(0, 0);
if (_step == -1) lcd_puts_P(_T(MSG_SELFTEST_FAN)); if (screen == testScreen::extruderFan) lcd_puts_P(_T(MSG_SELFTEST_FAN));
if (_step == 0) lcd_puts_P(_T(MSG_SELFTEST_FAN)); if (screen == testScreen::printFan) lcd_puts_P(_T(MSG_SELFTEST_FAN));
if (_step == 1) lcd_puts_P(_T(MSG_SELFTEST_FAN)); if (screen == testScreen::fansOk) lcd_puts_P(_T(MSG_SELFTEST_FAN));
if (_step == 2) lcd_puts_P(_i("Checking endstops"));////MSG_SELFTEST_CHECK_ENDSTOPS c=20 r=0 if (screen == testScreen::endStops) lcd_puts_P(_i("Checking endstops"));////MSG_SELFTEST_CHECK_ENDSTOPS c=20 r=0
if (_step == 3) lcd_puts_P(_i("Checking X axis "));////MSG_SELFTEST_CHECK_X c=20 r=0 if (screen == testScreen::axisX) lcd_puts_P(_i("Checking X axis "));////MSG_SELFTEST_CHECK_X c=20 r=0
if (_step == 4) lcd_puts_P(_i("Checking Y axis "));////MSG_SELFTEST_CHECK_Y c=20 r=0 if (screen == testScreen::axisY) lcd_puts_P(_i("Checking Y axis "));////MSG_SELFTEST_CHECK_Y c=20 r=0
if (_step == 5) lcd_puts_P(_i("Checking Z axis "));////MSG_SELFTEST_CHECK_Z c=20 r=0 if (screen == testScreen::axisZ) lcd_puts_P(_i("Checking Z axis "));////MSG_SELFTEST_CHECK_Z c=20 r=0
if (_step == 6) lcd_puts_P(_T(MSG_SELFTEST_CHECK_BED)); if (screen == testScreen::bed) lcd_puts_P(_T(MSG_SELFTEST_CHECK_BED));
if (_step == 7 if (screen == testScreen::hotend
|| _step == 8) lcd_puts_P(_i("Checking hotend "));////MSG_SELFTEST_CHECK_HOTEND c=20 r=0 || screen == testScreen::hotendOk) lcd_puts_P(_i("Checking hotend "));////MSG_SELFTEST_CHECK_HOTEND c=20 r=0
if (_step == 9) lcd_puts_P(_T(MSG_SELFTEST_CHECK_FSENSOR)); if (screen == testScreen::fsensor) lcd_puts_P(_T(MSG_SELFTEST_CHECK_FSENSOR));
if (_step == 10) lcd_puts_P(_T(MSG_SELFTEST_CHECK_FSENSOR)); if (screen == testScreen::fsensorOk) lcd_puts_P(_T(MSG_SELFTEST_CHECK_FSENSOR));
if (_step == 11) lcd_puts_P(_i("All correct "));////MSG_SELFTEST_CHECK_ALLCORRECT c=20 r=0 if (screen == testScreen::allCorrect) lcd_puts_P(_i("All correct "));////MSG_SELFTEST_CHECK_ALLCORRECT c=20 r=0
if (_step == 12) lcd_puts_P(_T(MSG_SELFTEST_FAILED)); if (screen == testScreen::failed) lcd_puts_P(_T(MSG_SELFTEST_FAILED));
if (_step == 13) lcd_puts_P(PSTR("Calibrating home")); if (screen == testScreen::home) lcd_puts_P(_i("Calibrating home"));////c=20 r=1
lcd_set_cursor(0, 1); lcd_set_cursor(0, 1);
lcd_puts_P(separator); lcd_puts_P(separator);
if ((_step >= -1) && (_step <= 1)) if ((screen >= testScreen::extruderFan) && (screen <= testScreen::fansOk))
{ {
//SERIAL_ECHOLNPGM("Fan test"); //SERIAL_ECHOLNPGM("Fan test");
lcd_puts_at_P(0, 2, _i("Extruder fan:"));////MSG_SELFTEST_EXTRUDER_FAN_SPEED c=18 r=0 lcd_puts_at_P(0, 2, _i("Extruder fan:"));////MSG_SELFTEST_EXTRUDER_FAN_SPEED c=18 r=0
lcd_set_cursor(18, 2); lcd_set_cursor(18, 2);
(_step < 0) ? lcd_print(_indicator) : lcd_print("OK"); (screen < testScreen::printFan) ? lcd_print(_indicator) : lcd_print("OK");
lcd_puts_at_P(0, 3, _i("Print fan:"));////MSG_SELFTEST_PRINT_FAN_SPEED c=18 r=0 lcd_puts_at_P(0, 3, _i("Print fan:"));////MSG_SELFTEST_PRINT_FAN_SPEED c=18 r=0
lcd_set_cursor(18, 3); lcd_set_cursor(18, 3);
(_step < 1) ? lcd_print(_indicator) : lcd_print("OK"); (screen < testScreen::fansOk) ? lcd_print(_indicator) : lcd_print("OK");
} }
else if (_step >= 9 && _step <= 10) else if (screen >= testScreen::fsensor && screen <= testScreen::fsensorOk)
{ {
lcd_puts_at_P(0, 2, _i("Filament sensor:"));////MSG_SELFTEST_FILAMENT_SENSOR c=18 r=0 lcd_puts_at_P(0, 2, _i("Filament sensor:"));////MSG_SELFTEST_FILAMENT_SENSOR c=18 r=0
lcd_set_cursor(18, 2); lcd_set_cursor(18, 2);
(_step == 9) ? lcd_print(_indicator) : lcd_print("OK"); (screen == testScreen::fsensor) ? lcd_print(_indicator) : lcd_print("OK");
} }
else if (_step < 9) else if (screen < testScreen::fsensor)
{ {
//SERIAL_ECHOLNPGM("Other tests"); //SERIAL_ECHOLNPGM("Other tests");
_step_block = 3; testScreen _step_block = testScreen::axisX;
lcd_selftest_screen_step(2, 2, ((_step == _step_block) ? 1 : (_step < _step_block) ? 0 : 2), "X", _indicator); lcd_selftest_screen_step(2, 2, ((screen == _step_block) ? 1 : (screen < _step_block) ? 0 : 2), "X", _indicator);
_step_block = 4; _step_block = testScreen::axisY;
lcd_selftest_screen_step(2, 8, ((_step == _step_block) ? 1 : (_step < _step_block) ? 0 : 2), "Y", _indicator); lcd_selftest_screen_step(2, 8, ((screen == _step_block) ? 1 : (screen < _step_block) ? 0 : 2), "Y", _indicator);
_step_block = 5; _step_block = testScreen::axisZ;
lcd_selftest_screen_step(2, 14, ((_step == _step_block) ? 1 : (_step < _step_block) ? 0 : 2), "Z", _indicator); lcd_selftest_screen_step(2, 14, ((screen == _step_block) ? 1 : (screen < _step_block) ? 0 : 2), "Z", _indicator);
_step_block = 6; _step_block = testScreen::bed;
lcd_selftest_screen_step(3, 0, ((_step == _step_block) ? 1 : (_step < _step_block) ? 0 : 2), "Bed", _indicator); lcd_selftest_screen_step(3, 0, ((screen == _step_block) ? 1 : (screen < _step_block) ? 0 : 2), "Bed", _indicator);
_step_block = 7; _step_block = testScreen::hotend;
lcd_selftest_screen_step(3, 9, ((_step == _step_block) ? 1 : (_step < _step_block) ? 0 : 2), "Hotend", _indicator); lcd_selftest_screen_step(3, 9, ((screen == _step_block) ? 1 : (screen < _step_block) ? 0 : 2), "Hotend", _indicator);
} }
if (_delay > 0) delay_keep_alive(_delay); if (_delay > 0) delay_keep_alive(_delay);