|
@@ -1296,9 +1296,12 @@ void setup()
|
|
|
|
|
|
#endif
|
|
|
|
|
|
+ #ifdef UVLO_SUPPORT
|
|
|
+ setup_uvlo_interrupt();
|
|
|
+ #endif
|
|
|
|
|
|
st_init();
|
|
|
-
|
|
|
+
|
|
|
#ifdef TMC2130
|
|
|
tmc2130_mode = silentMode?TMC2130_MODE_SILENT:TMC2130_MODE_NORMAL;
|
|
|
update_mode_profile();
|
|
@@ -1500,10 +1503,6 @@ void setup()
|
|
|
}
|
|
|
check_babystep();
|
|
|
|
|
|
-#ifdef UVLO_SUPPORT
|
|
|
- setup_uvlo_interrupt();
|
|
|
-#endif
|
|
|
-
|
|
|
#if !defined(DEBUG_DISABLE_FANCHECK) && defined(FANCHECK) && defined(TACH_1) && TACH_1 >-1
|
|
|
setup_fan_interrupt();
|
|
|
#endif
|
|
@@ -8689,7 +8688,6 @@ void serialecho_temperatures() {
|
|
|
}
|
|
|
|
|
|
extern uint32_t sdpos_atomic;
|
|
|
-
|
|
|
#ifdef UVLO_SUPPORT
|
|
|
|
|
|
void uvlo_()
|
|
@@ -8760,26 +8758,15 @@ void uvlo_()
|
|
|
st_synchronize();
|
|
|
disable_e0();
|
|
|
|
|
|
- plan_buffer_line(
|
|
|
- current_position[X_AXIS],
|
|
|
- current_position[Y_AXIS],
|
|
|
- current_position[Z_AXIS] + UVLO_Z_AXIS_SHIFT + float((1024 - z_microsteps + 7) >> 4) / cs.axis_steps_per_unit[Z_AXIS],
|
|
|
+ plan_buffer_line(
|
|
|
+ current_position[X_AXIS],
|
|
|
+ current_position[Y_AXIS],
|
|
|
+ current_position[Z_AXIS] + UVLO_Z_AXIS_SHIFT + float((1024 - z_microsteps + 7) >> 4) / cs.axis_steps_per_unit[Z_AXIS],
|
|
|
current_position[E_AXIS] - default_retraction,
|
|
|
40, active_extruder);
|
|
|
-
|
|
|
- st_synchronize();
|
|
|
- disable_e0();
|
|
|
-
|
|
|
- plan_buffer_line(
|
|
|
- current_position[X_AXIS],
|
|
|
- current_position[Y_AXIS],
|
|
|
- current_position[Z_AXIS] + UVLO_Z_AXIS_SHIFT + float((1024 - z_microsteps + 7) >> 4) / cs.axis_steps_per_unit[Z_AXIS],
|
|
|
- current_position[E_AXIS] - default_retraction,
|
|
|
- 40, active_extruder);
|
|
|
st_synchronize();
|
|
|
disable_e0();
|
|
|
disable_z();
|
|
|
-
|
|
|
|
|
|
|
|
|
eeprom_update_dword((uint32_t*)(EEPROM_FILE_POSITION), sd_position);
|
|
@@ -8823,8 +8810,8 @@ void uvlo_()
|
|
|
|
|
|
eeprom_update_byte((uint8_t*)EEPROM_POWER_COUNT, eeprom_read_byte((uint8_t*)EEPROM_POWER_COUNT) + 1);
|
|
|
eeprom_update_word((uint16_t*)EEPROM_POWER_COUNT_TOT, eeprom_read_word((uint16_t*)EEPROM_POWER_COUNT_TOT) + 1);
|
|
|
- printf_P(_N("UVLO - end %d\n"), _millis() - time_start);
|
|
|
-
|
|
|
+ printf_P(_N("UVLO - end %d\n"), _millis() - time_start);
|
|
|
+
|
|
|
#if 0
|
|
|
|
|
|
current_position[X_AXIS] = (current_position[X_AXIS] < 0.5f * (X_MIN_POS + X_MAX_POS)) ? X_MIN_POS : X_MAX_POS;
|
|
@@ -8859,23 +8846,13 @@ z_microsteps=tmc2130_rd_MSCNT(Z_TMC2130_CS);
|
|
|
#endif
|
|
|
|
|
|
planner_abort_hard();
|
|
|
-sei();
|
|
|
-plan_buffer_line(
|
|
|
- current_position[X_AXIS],
|
|
|
- current_position[Y_AXIS],
|
|
|
-
|
|
|
- current_position[Z_AXIS]+UVLO_Z_AXIS_SHIFT+float((1024-z_microsteps+7)>>4)/cs.axis_steps_per_unit[Z_AXIS],
|
|
|
- current_position[E_AXIS],
|
|
|
- 40, active_extruder);
|
|
|
-st_synchronize();
|
|
|
disable_z();
|
|
|
|
|
|
|
|
|
|
|
|
eeprom_update_byte((uint8_t*)EEPROM_UVLO,2);
|
|
|
|
|
|
-eeprom_update_word((uint16_t*)(EEPROM_UVLO_TINY_Z_MICROSTEPS),z_microsteps);
|
|
|
-eeprom_update_float((float*)(EEPROM_UVLO_TINY_CURRENT_POSITION_Z), current_position[Z_AXIS]);
|
|
|
+eeprom_update_word((uint16_t*)(EEPROM_UVLO_Z_MICROSTEPS),z_microsteps);
|
|
|
|
|
|
|
|
|
eeprom_update_byte((uint8_t*)EEPROM_POWER_COUNT, eeprom_read_byte((uint8_t*)EEPROM_POWER_COUNT) + 1);
|
|
@@ -8946,15 +8923,13 @@ ISR(INT4_vect) {
|
|
|
if(eeprom_read_byte((uint8_t*)EEPROM_UVLO)) uvlo_tiny();
|
|
|
}
|
|
|
|
|
|
-void recover_print(uint8_t automatic) {
|
|
|
+void recover_print(uint8_t automatic) {
|
|
|
char cmd[30];
|
|
|
lcd_update_enable(true);
|
|
|
lcd_update(2);
|
|
|
- lcd_setstatuspgm(_i("Recovering print "));
|
|
|
-
|
|
|
+ printf_P(_N("UVLO - end %d\n"), _millis() - time_start);
|
|
|
bool bTiny=(eeprom_read_byte((uint8_t*)EEPROM_UVLO)==2);
|
|
|
recover_machine_state_after_power_panic(bTiny);
|
|
|
-
|
|
|
|
|
|
if(!bTiny&&(current_position[Z_AXIS]<25))
|
|
|
enquecommand_P(PSTR("G1 Z25 F800"));
|
|
@@ -8977,8 +8952,7 @@ void recover_print(uint8_t automatic) {
|
|
|
|
|
|
|
|
|
restore_print_from_eeprom();
|
|
|
-
|
|
|
- printf_P(_N("Current pos Z_AXIS:%.3f\nCurrent pos E_AXIS:%.3f\n"), current_position[Z_AXIS], current_position[E_AXIS]);
|
|
|
+ printf_P(_N("Current pos Z_AXIS:%.3f\nCurrent pos E_AXIS:%.3f\n"), current_position[Z_AXIS], current_position[E_AXIS]);
|
|
|
}
|
|
|
|
|
|
void recover_machine_state_after_power_panic(bool bTiny)
|
|
@@ -8990,12 +8964,14 @@ void recover_machine_state_after_power_panic(bool bTiny)
|
|
|
current_position[Y_AXIS] = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 4));
|
|
|
|
|
|
|
|
|
- if(bTiny)
|
|
|
- current_position[Z_AXIS] = eeprom_read_float((float*)(EEPROM_UVLO_TINY_CURRENT_POSITION_Z)) +
|
|
|
- UVLO_Z_AXIS_SHIFT + float((1024 - eeprom_read_word((uint16_t*)(EEPROM_UVLO_TINY_Z_MICROSTEPS)) + 7) >> 4) / cs.axis_steps_per_unit[Z_AXIS];
|
|
|
- else
|
|
|
+ if(bTiny){
|
|
|
+ current_position[Z_AXIS] = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION_Z)) +
|
|
|
+ UVLO_Z_AXIS_SHIFT + float((1024 - eeprom_read_word((uint16_t*)(EEPROM_UVLO_Z_MICROSTEPS)) + 7) >> 4) / cs.axis_steps_per_unit[Z_AXIS];
|
|
|
+ }
|
|
|
+ else{
|
|
|
current_position[Z_AXIS] = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION_Z)) +
|
|
|
UVLO_Z_AXIS_SHIFT + float((1024 - eeprom_read_word((uint16_t*)(EEPROM_UVLO_Z_MICROSTEPS)) + 7) >> 4) / cs.axis_steps_per_unit[Z_AXIS];
|
|
|
+ }
|
|
|
if (eeprom_read_byte((uint8_t*)EEPROM_UVLO_E_ABS)) {
|
|
|
current_position[E_AXIS] = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION_E));
|
|
|
sprintf_P(cmd, PSTR("G92 E"));
|
|
@@ -9038,7 +9014,7 @@ void recover_machine_state_after_power_panic(bool bTiny)
|
|
|
axis_known_position[X_AXIS] = true; enable_x();
|
|
|
axis_known_position[Y_AXIS] = true; enable_y();
|
|
|
axis_known_position[Z_AXIS] = true; enable_z();
|
|
|
-
|
|
|
+
|
|
|
SERIAL_ECHOPGM("recover_machine_state_after_power_panic, initial ");
|
|
|
print_physical_coordinates();
|
|
|
|
|
@@ -9103,7 +9079,8 @@ void restore_print_from_eeprom() {
|
|
|
strcat_P(cmd, PSTR(" F2000"));
|
|
|
enquecommand(cmd);
|
|
|
|
|
|
- strcpy_P(cmd, PSTR("G1 Z")); strcat(cmd, ftostr32(eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION_Z))));
|
|
|
+ strcpy_P(cmd, PSTR("G1 Z")); strcat(cmd, ftostr32(current_position[Z_AXIS] - (UVLO_Z_AXIS_SHIFT +
|
|
|
+ float((1024 - eeprom_read_word((uint16_t*)(EEPROM_UVLO_Z_MICROSTEPS)) + 7) >> 4) / cs.axis_steps_per_unit[Z_AXIS])));
|
|
|
enquecommand(cmd);
|
|
|
|
|
|
enquecommand_P(PSTR("G1 E" STRINGIFY(2*default_retraction)" F480"));
|