diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index 387b10e1..e3387eaa 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -47,6 +47,8 @@ #define EEPROM_TEMP_CAL_ACTIVE (EEPROM_PROBE_TEMP_SHIFT - 1) #define EEPROM_BOWDEN_LENGTH (EEPROM_TEMP_CAL_ACTIVE - 2*4) //4 x int for bowden lengths for multimaterial #define EEPROM_CALIBRATION_STATUS_PINDA (EEPROM_BOWDEN_LENGTH - 1) //0 - not calibrated; 1 - calibrated +#define EEPROM_UVLO (EEPROM_CALIBRATION_STATUS_PINDA - 1) //1 - uvlo during print +#define EEPROM_UVLO_CURRENT_POSITION (EEPROM_UVLO-2*4) // 2 x float for current_position in X and Y axes // Currently running firmware, each digit stored as uint16_t. // The flavor differentiates a dev, alpha, beta, release candidate or a release version. diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 96f1607c..6c74b9f2 100644 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -351,4 +351,8 @@ float temp_comp_interpolation(float temperature); void temp_compensation_apply(); void temp_compensation_start(); void wait_for_heater(long codenum); -void serialecho_temperatures(); \ No newline at end of file +void serialecho_temperatures(); + +void uvlo(); +void recover_print(); +#define UVLO !(PINE & (1<<4)) \ No newline at end of file diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index eabf8a0c..f8c52f79 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -1197,6 +1197,9 @@ void setup() if (eeprom_read_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA) == 255) { eeprom_write_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 0); } + if (eeprom_read_byte((uint8_t*)EEPROM_UVLO) == 255) { + eeprom_write_byte((uint8_t*)EEPROM_UVLO, 0); + } check_babystep(); //checking if Z babystep is in allowed range @@ -1217,12 +1220,18 @@ void setup() // Show the message. lcd_show_fullscreen_message_and_wait_P(MSG_FOLLOW_CALIBRATION_FLOW); } + 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(); + } + for (int i = 0; i<4; i++) EEPROM_read_B(EEPROM_BOWDEN_LENGTH + i * 2, &bowden_length[i]); lcd_update_enable(true); // Store the currently running firmware into an eeprom, // so the next time the firmware gets updated, it will know from which version it has been updated. update_current_firmware_version_to_eeprom(); + + } void trace(); @@ -6618,4 +6627,42 @@ void serialecho_temperatures() { SERIAL_PROTOCOLPGM(" B:"); SERIAL_PROTOCOL_F(degBed(), 1); SERIAL_PROTOCOLLN(""); -} \ No newline at end of file +} + + + +void 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; + + + + /* + 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); + st_synchronize(); + eeprom_update_byte((uint8_t*)EEPROM_UVLO, 0); + +} + diff --git a/Firmware/language_all.cpp b/Firmware/language_all.cpp index 9ba394cc..c0f3fe8b 100644 --- a/Firmware/language_all.cpp +++ b/Firmware/language_all.cpp @@ -2203,6 +2203,11 @@ const char * const MSG_REBOOT_LANG_TABLE[LANG_NUM] PROGMEM = { MSG_REBOOT_DE }; +const char MSG_RECOVER_PRINT_EN[] PROGMEM = "Blackout occured. Recover print?"; +const char * const MSG_RECOVER_PRINT_LANG_TABLE[1] PROGMEM = { + MSG_RECOVER_PRINT_EN +}; + const char MSG_RECTRACT_EN[] PROGMEM = "Rectract"; const char * const MSG_RECTRACT_LANG_TABLE[1] PROGMEM = { MSG_RECTRACT_EN diff --git a/Firmware/language_all.h b/Firmware/language_all.h index 0ca88d66..9a7e1f8f 100644 --- a/Firmware/language_all.h +++ b/Firmware/language_all.h @@ -414,6 +414,8 @@ extern const char* const MSG_PRUSA3D_HOWTO_LANG_TABLE[LANG_NUM]; #define MSG_PRUSA3D_HOWTO LANG_TABLE_SELECT(MSG_PRUSA3D_HOWTO_LANG_TABLE) extern const char* const MSG_REBOOT_LANG_TABLE[LANG_NUM]; #define MSG_REBOOT LANG_TABLE_SELECT(MSG_REBOOT_LANG_TABLE) +extern const char* const MSG_RECOVER_PRINT_LANG_TABLE[1]; +#define MSG_RECOVER_PRINT LANG_TABLE_SELECT_EXPLICIT(MSG_RECOVER_PRINT_LANG_TABLE, 0) extern const char* const MSG_RECTRACT_LANG_TABLE[1]; #define MSG_RECTRACT LANG_TABLE_SELECT_EXPLICIT(MSG_RECTRACT_LANG_TABLE, 0) extern const char* const MSG_REFRESH_LANG_TABLE[1]; diff --git a/Firmware/language_en.h b/Firmware/language_en.h index 2cc2824e..bbc77ef9 100644 --- a/Firmware/language_en.h +++ b/Firmware/language_en.h @@ -302,4 +302,4 @@ #define(length=17, lines=1) MSG_EXTRUDER_2 "Extruder 2" #define(length=17, lines=1) MSG_EXTRUDER_3 "Extruder 3" #define(length=17, lines=1) MSG_EXTRUDER_4 "Extruder 4" - +#define(length=20, lines=2) MSG_RECOVER_PRINT "Blackout occured. Recover print?" diff --git a/Firmware/pins.h b/Firmware/pins.h index 1ed3958b..7bd7f5aa 100644 --- a/Firmware/pins.h +++ b/Firmware/pins.h @@ -399,8 +399,9 @@ #define BEEPER 84 // Beeper on AUX-4 #define LCD_PINS_RS 82 -#define LCD_PINS_ENABLE 18 -#define LCD_PINS_D4 19 + +#define LCD_PINS_ENABLE 61 +#define LCD_PINS_D4 59 #define LCD_PINS_D5 70 #define LCD_PINS_D6 85 #define LCD_PINS_D7 71 @@ -412,7 +413,7 @@ #define SDCARDDETECT 15 -#define TACH_0 81 +#define TACH_0 79 #define TACH_1 80 #endif //NEWPANEL diff --git a/Firmware/stepper.cpp b/Firmware/stepper.cpp index 4cadd180..74e97f2b 100644 --- a/Firmware/stepper.cpp +++ b/Firmware/stepper.cpp @@ -333,6 +333,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 there is no current block, attempt to pop one from the buffer if (current_block == NULL) { // Anything in the buffer? diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index b91f5313..b45f0d2f 100644 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -407,6 +407,9 @@ void setExtruderAutoFanState(int pin, bool state) void countFanSpeed() { + SERIAL_ECHOPGM("UVLO:"); + MYSERIAL.println(UVLO); + fan_speed[0] = (fan_edge_counter[0] * (float(250) / (millis() - extruder_autofan_last_check))); fan_speed[1] = (fan_edge_counter[1] * (float(250) / (millis() - extruder_autofan_last_check))); @@ -1456,6 +1459,7 @@ int read_max6675() // Timer 0 is shared with millies ISR(TIMER0_COMPB_vect) { + 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;