position saving and restoring in UVLO
This commit is contained in:
parent
ae0c64248f
commit
db12119b68
4 changed files with 45 additions and 24 deletions
|
@ -353,6 +353,7 @@ void temp_compensation_start();
|
|||
void wait_for_heater(long codenum);
|
||||
void serialecho_temperatures();
|
||||
|
||||
void uvlo();
|
||||
void uvlo_();
|
||||
void recover_print();
|
||||
void setup_uvlo_interrupt();
|
||||
#define UVLO !(PINE & (1<<4))
|
|
@ -1202,6 +1202,7 @@ void setup()
|
|||
}
|
||||
|
||||
check_babystep(); //checking if Z babystep is in allowed range
|
||||
setup_uvlo_interrupt();
|
||||
|
||||
if (calibration_status() == CALIBRATION_STATUS_ASSEMBLED ||
|
||||
calibration_status() == CALIBRATION_STATUS_UNKNOWN) {
|
||||
|
@ -1222,6 +1223,7 @@ void setup()
|
|||
}
|
||||
if (eeprom_read_byte((uint8_t*)EEPROM_UVLO) == 1) { //previous print was terminated by UVLO
|
||||
if (lcd_show_fullscreen_message_yes_no_and_wait_P(MSG_RECOVER_PRINT)) recover_print();
|
||||
else eeprom_update_byte((uint8_t*)EEPROM_UVLO, 0);
|
||||
}
|
||||
|
||||
for (int i = 0; i<4; i++) EEPROM_read_B(EEPROM_BOWDEN_LENGTH + i * 2, &bowden_length[i]);
|
||||
|
@ -6745,38 +6747,56 @@ void serialecho_temperatures() {
|
|||
|
||||
|
||||
|
||||
void uvlo() {
|
||||
void uvlo_() {
|
||||
SERIAL_ECHOLNPGM("UVLO");
|
||||
eeprom_update_byte((uint8_t*)EEPROM_UVLO, 1);
|
||||
eeprom_update_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 0), current_position[X_AXIS]);
|
||||
eeprom_update_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 4), current_position[Y_AXIS]);
|
||||
//current_position[Z_AXIS] += 3;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
current_position[E_AXIS] -= DEFAULT_RETRACTION;
|
||||
sei(); //enable stepper driver interrupt to move Z axis
|
||||
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 40, active_extruder);
|
||||
st_synchronize();
|
||||
current_position[Z_AXIS] += UVLO_Z_AXIS_SHIFT;
|
||||
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 40, active_extruder);
|
||||
st_synchronize();
|
||||
while (1);*/
|
||||
//WRITE(BEEPER, HIGH);
|
||||
|
||||
/*while (1) {
|
||||
//first turn off heatbed
|
||||
//DDRG |= (1 << DDG5); //set as output
|
||||
PORTG &= ~(1 << 5); //set output low
|
||||
//turn off nozzle
|
||||
//DDRE |= (1 << DDE5);
|
||||
PORTE &= ~(1 << 5);
|
||||
WRITE(BEEPER, HIGH);
|
||||
}*/
|
||||
}
|
||||
|
||||
void recover_print() {
|
||||
homeaxis(X_AXIS);
|
||||
homeaxis(Y_AXIS);
|
||||
current_position[X_AXIS] = eeprom_read_float((float*)(EEPROM_BED_CALIBRATION_CENTER + 0));
|
||||
current_position[Y_AXIS] = eeprom_read_float((float*)(EEPROM_BED_CALIBRATION_CENTER + 4));
|
||||
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[X_AXIS], active_extruder);
|
||||
current_position[X_AXIS] = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 0));
|
||||
current_position[Y_AXIS] = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 4));
|
||||
/*SERIAL_ECHOPGM("Current position [X_AXIS]:");
|
||||
MYSERIAL.println(current_position[X_AXIS]);
|
||||
SERIAL_ECHOPGM("Current position [Y_AXIS]:");
|
||||
MYSERIAL.println(current_position[Y_AXIS]);*/
|
||||
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 40, active_extruder);
|
||||
st_synchronize();
|
||||
current_position[Z_AXIS] -= UVLO_Z_AXIS_SHIFT;
|
||||
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 40, active_extruder);
|
||||
st_synchronize();
|
||||
current_position[E_AXIS] += DEFAULT_RETRACTION; //unretract
|
||||
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 40, active_extruder);
|
||||
st_synchronize();
|
||||
eeprom_update_byte((uint8_t*)EEPROM_UVLO, 0);
|
||||
|
||||
}
|
||||
|
||||
void setup_uvlo_interrupt() {
|
||||
DDRE &= ~(1 << 4); //input pin
|
||||
PORTE &= ~(1 << 4); //no internal pull-up
|
||||
|
||||
//sensing falling edge
|
||||
EICRB |= (1 << 0);
|
||||
EICRB &= ~(1 << 1);
|
||||
|
||||
//enable INT4 interrupt
|
||||
EIMSK |= (1 << 4);
|
||||
}
|
||||
|
||||
ISR(INT4_vect) {
|
||||
EIMSK &= ~(1 << 4); //disable INT4 interrupt to make sure that this code will be executed just once
|
||||
SERIAL_ECHOLNPGM("INT4");
|
||||
uvlo_();
|
||||
}
|
||||
|
||||
|
|
|
@ -334,7 +334,7 @@ FORCE_INLINE void trapezoid_generator_reset() {
|
|||
// It pops blocks from the block_buffer and executes them by pulsing the stepper pins appropriately.
|
||||
ISR(TIMER1_COMPA_vect)
|
||||
{
|
||||
if (UVLO) uvlo();
|
||||
//if (UVLO) uvlo();
|
||||
// If there is no current block, attempt to pop one from the buffer
|
||||
if (current_block == NULL) {
|
||||
// Anything in the buffer?
|
||||
|
|
|
@ -1459,7 +1459,7 @@ int read_max6675()
|
|||
// Timer 0 is shared with millies
|
||||
ISR(TIMER0_COMPB_vect)
|
||||
{
|
||||
if (UVLO) uvlo();
|
||||
// if (UVLO) uvlo();
|
||||
//these variables are only accesible from the ISR, but static, so they don't lose their value
|
||||
static unsigned char temp_count = 0;
|
||||
static unsigned long raw_temp_0_value = 0;
|
||||
|
|
Loading…
Reference in a new issue