Reduce duplication and code size
This commit is contained in:
parent
35a67ad51f
commit
5b6a057037
|
|
@ -594,6 +594,14 @@ void crashdet_restore_print_and_continue()
|
||||||
// babystep_apply();
|
// babystep_apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void crashdet_fmt_error(char* buf, uint8_t mask)
|
||||||
|
{
|
||||||
|
if(mask & X_AXIS_MASK) *buf++ = axis_codes[X_AXIS];
|
||||||
|
if(mask & Y_AXIS_MASK) *buf++ = axis_codes[Y_AXIS];
|
||||||
|
*buf++ = ' ';
|
||||||
|
strcpy_P(buf, _T(MSG_CRASH_DETECTED));
|
||||||
|
}
|
||||||
|
|
||||||
void crashdet_detected(uint8_t mask)
|
void crashdet_detected(uint8_t mask)
|
||||||
{
|
{
|
||||||
st_synchronize();
|
st_synchronize();
|
||||||
|
|
@ -619,21 +627,18 @@ void crashdet_detected(uint8_t mask)
|
||||||
{
|
{
|
||||||
eeprom_update_byte((uint8_t*)EEPROM_CRASH_COUNT_X, eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_X) + 1);
|
eeprom_update_byte((uint8_t*)EEPROM_CRASH_COUNT_X, eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_X) + 1);
|
||||||
eeprom_update_word((uint16_t*)EEPROM_CRASH_COUNT_X_TOT, eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_X_TOT) + 1);
|
eeprom_update_word((uint16_t*)EEPROM_CRASH_COUNT_X_TOT, eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_X_TOT) + 1);
|
||||||
strcat(msg, "X");
|
|
||||||
}
|
}
|
||||||
if (mask & Y_AXIS_MASK)
|
if (mask & Y_AXIS_MASK)
|
||||||
{
|
{
|
||||||
eeprom_update_byte((uint8_t*)EEPROM_CRASH_COUNT_Y, eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_Y) + 1);
|
eeprom_update_byte((uint8_t*)EEPROM_CRASH_COUNT_Y, eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_Y) + 1);
|
||||||
eeprom_update_word((uint16_t*)EEPROM_CRASH_COUNT_Y_TOT, eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_Y_TOT) + 1);
|
eeprom_update_word((uint16_t*)EEPROM_CRASH_COUNT_Y_TOT, eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_Y_TOT) + 1);
|
||||||
strcat(msg, "Y");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lcd_update_enable(true);
|
lcd_update_enable(true);
|
||||||
lcd_update(2);
|
lcd_update(2);
|
||||||
|
|
||||||
// prepare the status message with the _current_ axes status
|
// prepare the status message with the _current_ axes status
|
||||||
strcat(msg, " ");
|
crashdet_fmt_error(msg, mask);
|
||||||
strcat_P(msg, _T(MSG_CRASH_DETECTED));
|
|
||||||
lcd_setstatus(msg);
|
lcd_setstatus(msg);
|
||||||
|
|
||||||
gcode_G28(true, true, false); //home X and Y
|
gcode_G28(true, true, false); //home X and Y
|
||||||
|
|
@ -647,11 +652,9 @@ void crashdet_detected(uint8_t mask)
|
||||||
// notify the user of *all* the axes previously affected, not just the last one
|
// notify the user of *all* the axes previously affected, not just the last one
|
||||||
lcd_update_enable(false);
|
lcd_update_enable(false);
|
||||||
lcd_clear();
|
lcd_clear();
|
||||||
if (crashDet_axes & X_AXIS_MASK) lcd_putc('X');
|
crashdet_fmt_error(msg, crashDet_axes);
|
||||||
if (crashDet_axes & Y_AXIS_MASK) lcd_putc('Y');
|
|
||||||
crashDet_axes = 0;
|
crashDet_axes = 0;
|
||||||
lcd_putc(' ');
|
lcd_print(msg);
|
||||||
lcd_puts_P(_T(MSG_CRASH_DETECTED));
|
|
||||||
|
|
||||||
// ask whether to resume printing
|
// ask whether to resume printing
|
||||||
lcd_set_cursor(0, 1);
|
lcd_set_cursor(0, 1);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue