Merge pull request #4420 from gudnimg/PFW-1543
PFW-1543 Save print type in EEPROM
This commit is contained in:
commit
2027a54873
|
|
@ -288,9 +288,6 @@ extern bool mesh_bed_leveling_flag;
|
|||
extern bool saved_printing;
|
||||
extern uint32_t saved_sdpos;
|
||||
extern uint8_t saved_printing_type;
|
||||
#define PRINTING_TYPE_SD 0
|
||||
#define PRINTING_TYPE_USB 1
|
||||
#define PRINTING_TYPE_NONE 2
|
||||
|
||||
extern uint16_t saved_extruder_temperature; //!< Active extruder temperature
|
||||
extern uint8_t saved_bed_temperature; //!< Bed temperature
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ static bool chdkActive = false;
|
|||
//! @{
|
||||
bool saved_printing = false; //!< Print is paused and saved in RAM
|
||||
uint32_t saved_sdpos = 0; //!< SD card position, or line number in case of USB printing
|
||||
uint8_t saved_printing_type = PRINTING_TYPE_SD;
|
||||
uint8_t saved_printing_type = PowerPanic::PRINT_TYPE_SD;
|
||||
float saved_pos[NUM_AXIS] = { X_COORD_INVALID, 0, 0, 0 };
|
||||
uint16_t saved_feedrate2 = 0; //!< Default feedrate (truncated from float)
|
||||
static int saved_feedmultiply2 = 0;
|
||||
|
|
@ -638,9 +638,9 @@ void crashdet_cancel()
|
|||
{
|
||||
saved_printing = false;
|
||||
tmc2130_sg_stop_on_crash = true;
|
||||
if (saved_printing_type == PRINTING_TYPE_SD) {
|
||||
if (saved_printing_type == PowerPanic::PRINT_TYPE_SD) {
|
||||
print_stop();
|
||||
}else if(saved_printing_type == PRINTING_TYPE_USB){
|
||||
}else if(saved_printing_type == PowerPanic::PRINT_TYPE_USB){
|
||||
SERIAL_ECHOLNRPGM(MSG_OCTOPRINT_CANCEL); //for Octoprint: works the same as clicking "Abort" button in Octoprint GUI
|
||||
cmdqueue_reset();
|
||||
}
|
||||
|
|
@ -1457,7 +1457,7 @@ void setup()
|
|||
}
|
||||
eeprom_write_byte((uint8_t*)EEPROM_TEMP_CAL_ACTIVE, 0);
|
||||
}
|
||||
eeprom_init_default_byte((uint8_t*)EEPROM_UVLO, NO_PENDING_RECOVERY);
|
||||
eeprom_init_default_byte((uint8_t*)EEPROM_UVLO, PowerPanic::NO_PENDING_RECOVERY);
|
||||
eeprom_init_default_byte((uint8_t*)EEPROM_SD_SORT, 0);
|
||||
|
||||
//mbl_mode_init();
|
||||
|
|
@ -1578,7 +1578,7 @@ void setup()
|
|||
fw_crash_init();
|
||||
|
||||
#ifdef UVLO_SUPPORT
|
||||
if (eeprom_read_byte((uint8_t*)EEPROM_UVLO) != NO_PENDING_RECOVERY) { //previous print was terminated by UVLO
|
||||
if (eeprom_read_byte((uint8_t*)EEPROM_UVLO) != PowerPanic::NO_PENDING_RECOVERY) { //previous print was terminated by UVLO
|
||||
manage_heater(); // Update temperatures
|
||||
#ifdef DEBUG_UVLO_AUTOMATIC_RECOVER
|
||||
printf_P(_N("Power panic detected!\nCurrent bed temp:%d\nSaved bed temp:%d\n"), (int)degBed(), eeprom_read_byte((uint8_t*)EEPROM_UVLO_TARGET_BED));
|
||||
|
|
@ -1596,7 +1596,7 @@ void setup()
|
|||
if ( lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_RECOVER_PRINT), false) == LCD_LEFT_BUTTON_CHOICE) {
|
||||
recover_print(0);
|
||||
} else {
|
||||
eeprom_update_byte((uint8_t*)EEPROM_UVLO, NO_PENDING_RECOVERY);
|
||||
eeprom_update_byte((uint8_t*)EEPROM_UVLO, PowerPanic::NO_PENDING_RECOVERY);
|
||||
lcd_update_enable(true);
|
||||
lcd_update(2);
|
||||
lcd_setstatuspgm(MSG_WELCOME);
|
||||
|
|
@ -1727,7 +1727,7 @@ void loop()
|
|||
KEEPALIVE_STATE(NOT_BUSY);
|
||||
}
|
||||
|
||||
if (isPrintPaused && saved_printing_type == PRINTING_TYPE_USB) { //keep believing that usb is being printed. Prevents accessing dangerous menus while pausing.
|
||||
if (isPrintPaused && saved_printing_type == PowerPanic::PRINT_TYPE_USB) { //keep believing that usb is being printed. Prevents accessing dangerous menus while pausing.
|
||||
usb_timer.start();
|
||||
}
|
||||
else if (usb_timer.expired(10000)) { //just need to check if it expired. Nothing else is needed to be done.
|
||||
|
|
@ -4083,7 +4083,7 @@ void process_commands()
|
|||
printf_P(_N("E0:%d RPM\nPRN0:%d RPM\n"), 60*fan_speed[0], 60*fan_speed[1]);
|
||||
}
|
||||
else if (code_seen_P(PSTR("uvlo"))) { // PRUSA uvlo
|
||||
eeprom_update_byte((uint8_t*)EEPROM_UVLO, NO_PENDING_RECOVERY);
|
||||
eeprom_update_byte((uint8_t*)EEPROM_UVLO, PowerPanic::NO_PENDING_RECOVERY);
|
||||
enquecommand_P(MSG_M24);
|
||||
}
|
||||
else if (code_seen_P(PSTR("MMURES"))) // PRUSA MMURES
|
||||
|
|
@ -10350,7 +10350,7 @@ void save_print_file_state() {
|
|||
saved_sdpos -= sdlen_planner;
|
||||
sdlen_cmdqueue = cmdqueue_calc_sd_length(); //length of sd commands in cmdqueue
|
||||
saved_sdpos -= sdlen_cmdqueue;
|
||||
saved_printing_type = PRINTING_TYPE_SD;
|
||||
saved_printing_type = PowerPanic::PRINT_TYPE_SD;
|
||||
}
|
||||
else if (usb_timer.running()) { //reuse saved_sdpos for storing line number
|
||||
saved_sdpos = gcode_LastN; //start with line number of command added recently to cmd queue
|
||||
|
|
@ -10358,10 +10358,10 @@ void save_print_file_state() {
|
|||
nlines = planner_calc_sd_length(); //number of lines of commands in planner
|
||||
saved_sdpos -= nlines;
|
||||
saved_sdpos -= buflen; //number of blocks in cmd buffer
|
||||
saved_printing_type = PRINTING_TYPE_USB;
|
||||
saved_printing_type = PowerPanic::PRINT_TYPE_USB;
|
||||
}
|
||||
else {
|
||||
saved_printing_type = PRINTING_TYPE_NONE;
|
||||
saved_printing_type = PowerPanic::PRINT_TYPE_NONE;
|
||||
//not sd printing nor usb printing
|
||||
}
|
||||
|
||||
|
|
@ -10455,11 +10455,11 @@ void save_print_file_state() {
|
|||
}
|
||||
|
||||
void restore_print_file_state() {
|
||||
if (saved_printing_type == PRINTING_TYPE_SD) { //was sd printing
|
||||
if (saved_printing_type == PowerPanic::PRINT_TYPE_SD) { //was sd printing
|
||||
card.setIndex(saved_sdpos);
|
||||
sdpos_atomic = saved_sdpos;
|
||||
card.sdprinting = true;
|
||||
} else if (saved_printing_type == PRINTING_TYPE_USB) { //was usb printing
|
||||
} else if (saved_printing_type == PowerPanic::PRINT_TYPE_USB) { //was usb printing
|
||||
gcode_LastN = saved_sdpos; //saved_sdpos was reused for storing line number when usb printing
|
||||
serial_count = 0;
|
||||
FlushSerialRequestResend();
|
||||
|
|
@ -10651,7 +10651,7 @@ void restore_print_from_ram_and_continue(float e_move)
|
|||
restore_print_file_state();
|
||||
|
||||
lcd_setstatuspgm(MSG_WELCOME);
|
||||
saved_printing_type = PRINTING_TYPE_NONE;
|
||||
saved_printing_type = PowerPanic::PRINT_TYPE_NONE;
|
||||
saved_printing = false;
|
||||
planner_aborted = true; // unroll the stack
|
||||
}
|
||||
|
|
@ -10659,9 +10659,9 @@ void restore_print_from_ram_and_continue(float e_move)
|
|||
// Cancel the state related to a currently saved print
|
||||
void cancel_saved_printing()
|
||||
{
|
||||
eeprom_update_byte((uint8_t*)EEPROM_UVLO, NO_PENDING_RECOVERY);
|
||||
eeprom_update_byte((uint8_t*)EEPROM_UVLO, PowerPanic::NO_PENDING_RECOVERY);
|
||||
saved_start_position[0] = SAVED_START_POSITION_UNSET;
|
||||
saved_printing_type = PRINTING_TYPE_NONE;
|
||||
saved_printing_type = PowerPanic::PRINT_TYPE_NONE;
|
||||
saved_printing = false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include "temperature.h"
|
||||
#include "language.h"
|
||||
#include "Prusa_farm.h"
|
||||
#include "power_panic.h"
|
||||
|
||||
#ifdef SDSUPPORT
|
||||
|
||||
|
|
@ -557,7 +558,7 @@ void CardReader::getStatus(bool arg_P)
|
|||
{
|
||||
if (isPrintPaused)
|
||||
{
|
||||
if (saved_printing && (saved_printing_type == PRINTING_TYPE_SD))
|
||||
if (saved_printing && (saved_printing_type == PowerPanic::PRINT_TYPE_SD))
|
||||
SERIAL_PROTOCOLLNPGM("SD print paused");
|
||||
else
|
||||
SERIAL_PROTOCOLLNPGM("Print saved");
|
||||
|
|
|
|||
|
|
@ -134,7 +134,9 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP
|
|||
| 0x0F95 3989 | char | EEPROM_FILENAME | ??? | ffh 255 | Power Panic Filename | ??? | D3 Ax0f95 C8
|
||||
| 0x0F91 3985 | unint32 | EEPROM_FILE_POSITION | ??? | ff ff ff ffh | Power Panic File Position | ??? | D3 Ax0f91 C4
|
||||
| 0x0F8D 3981 | float | EEPROM_UVLO_CURRENT_POSITION_Z | ??? | ff ff ff ffh | Power Panic Z Position | ^ | D3 Ax0f8d C4
|
||||
| 0x0F8C 3980 | ??? | EEPROM_UVLO_UNUSED_001 | ??? | ffh 255 | Power Panic _unused_ | ^ | D3 Ax0f8c C1
|
||||
| 0x0F8C 3980 | uint8 | EEPROM_UVLO_PRINT_TYPE | 00h 0 | ffh 255 | Power Panic print type: SD | ??? | D3 Ax0f8c C1
|
||||
| ^ | ^ | ^ | 01h 1 | ^ | Power Panic print type: USB | ^ | ^
|
||||
| ^ | ^ | ^ | 02h 2 | ^ | Power Panic print type: None | ^ | ^
|
||||
| 0x0F8B 3979 | uint8 | EEPROM_UVLO_TARGET_BED | ??? | ffh 255 | Power Panic Bed temperature | ^ | D3 Ax0f8b C1
|
||||
| 0x0F89 3977 | uint16 | EEPROM_UVLO_FEEDRATE | ??? | ff ffh 65535 | Power Panic Feedrate | ^ | D3 Ax0f89 C2
|
||||
| 0x0F88 3976 | uint8 | EEPROM_UVLO_FAN_SPEED | ??? | ffh 255 | Power Panic Fan speed | ^ | D3 Ax0f88 C1
|
||||
|
|
@ -424,8 +426,8 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP
|
|||
#define EEPROM_FILENAME (EEPROM_UVLO_CURRENT_POSITION - 8) //8chars to store filename without extension
|
||||
#define EEPROM_FILE_POSITION (EEPROM_FILENAME - 4) //32 bit for uint32_t file position
|
||||
#define EEPROM_UVLO_CURRENT_POSITION_Z (EEPROM_FILE_POSITION - 4) //float for current position in Z
|
||||
#define EEPROM_UVLO_UNUSED_001 (EEPROM_UVLO_CURRENT_POSITION_Z - 1) // uint8_t (unused)
|
||||
#define EEPROM_UVLO_TARGET_BED (EEPROM_UVLO_UNUSED_001 - 1)
|
||||
#define EEPROM_UVLO_PRINT_TYPE (EEPROM_UVLO_CURRENT_POSITION_Z - 1) // uint8_t
|
||||
#define EEPROM_UVLO_TARGET_BED (EEPROM_UVLO_PRINT_TYPE - 1)
|
||||
#define EEPROM_UVLO_FEEDRATE (EEPROM_UVLO_TARGET_BED - 2) //uint16_t
|
||||
#define EEPROM_UVLO_FAN_SPEED (EEPROM_UVLO_FEEDRATE - 1)
|
||||
#define EEPROM_FAN_CHECK_ENABLED (EEPROM_UVLO_FAN_SPEED - 1)
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ void uvlo_() {
|
|||
unsigned long time_start = _millis();
|
||||
|
||||
// True if a print is already saved to RAM
|
||||
bool sd_print_saved_in_ram = saved_printing && (saved_printing_type == PRINTING_TYPE_SD);
|
||||
bool sd_print_saved_in_ram = saved_printing && (saved_printing_type == PowerPanic::PRINT_TYPE_SD);
|
||||
|
||||
// Flag to decide whether or not to set EEPROM_UVLO bit
|
||||
bool sd_print = card.sdprinting || sd_print_saved_in_ram;
|
||||
|
|
@ -189,6 +189,7 @@ void uvlo_() {
|
|||
eeprom_update_block(saved_start_position, (float *)EEPROM_UVLO_SAVED_START_POSITION, sizeof(saved_start_position));
|
||||
|
||||
eeprom_update_word((uint16_t*)EEPROM_UVLO_SAVED_SEGMENT_IDX, saved_segment_idx);
|
||||
eeprom_update_byte((uint8_t*)EEPROM_UVLO_PRINT_TYPE, saved_printing_type);
|
||||
|
||||
#ifdef LIN_ADVANCE
|
||||
eeprom_update_float((float*)(EEPROM_UVLO_LA_K), extruder_advance_K);
|
||||
|
|
@ -198,7 +199,7 @@ void uvlo_() {
|
|||
// Note: Recovering a print from EEPROM currently assumes the user
|
||||
// is printing from an SD card, this is why this EEPROM byte is only set
|
||||
// when SD card print is detected
|
||||
if(sd_print) eeprom_update_byte((uint8_t*)EEPROM_UVLO, PENDING_RECOVERY);
|
||||
if(sd_print) eeprom_update_byte((uint8_t*)EEPROM_UVLO, PowerPanic::PENDING_RECOVERY);
|
||||
|
||||
// Increment power failure counter
|
||||
eeprom_increment_byte((uint8_t*)EEPROM_POWER_COUNT);
|
||||
|
|
@ -271,7 +272,7 @@ static void uvlo_tiny() {
|
|||
}
|
||||
|
||||
// Update the the "power outage" flag.
|
||||
eeprom_update_byte((uint8_t*)EEPROM_UVLO, PENDING_RECOVERY_RETRY);
|
||||
eeprom_update_byte((uint8_t*)EEPROM_UVLO, PowerPanic::PENDING_RECOVERY_RETRY);
|
||||
|
||||
// Increment power failure counter
|
||||
eeprom_increment_byte((uint8_t*)EEPROM_POWER_COUNT);
|
||||
|
|
@ -293,7 +294,7 @@ void setup_uvlo_interrupt() {
|
|||
EIMSK |= (1 << 4);
|
||||
|
||||
// check if power was lost before we armed the interrupt
|
||||
if(!(PINE & (1 << 4)) && eeprom_read_byte((uint8_t*)EEPROM_UVLO) != NO_PENDING_RECOVERY)
|
||||
if(!(PINE & (1 << 4)) && eeprom_read_byte((uint8_t*)EEPROM_UVLO) != PowerPanic::NO_PENDING_RECOVERY)
|
||||
{
|
||||
SERIAL_ECHOLNRPGM(MSG_INT4);
|
||||
uvlo_drain_reset();
|
||||
|
|
@ -303,7 +304,7 @@ void setup_uvlo_interrupt() {
|
|||
ISR(INT4_vect) {
|
||||
EIMSK &= ~(1 << 4); //disable INT4 interrupt to make sure that this code will be executed just once
|
||||
SERIAL_ECHOLNRPGM(MSG_INT4);
|
||||
if (eeprom_read_byte((uint8_t*)EEPROM_UVLO) == NO_PENDING_RECOVERY)
|
||||
if (eeprom_read_byte((uint8_t*)EEPROM_UVLO) == PowerPanic::NO_PENDING_RECOVERY)
|
||||
{
|
||||
if(printer_active()) {
|
||||
uvlo_();
|
||||
|
|
@ -326,7 +327,7 @@ void recover_print(uint8_t automatic) {
|
|||
|
||||
// Lift the print head 25mm, first to avoid collisions with oozed material with the print,
|
||||
// and second also so one may remove the excess priming material.
|
||||
if(eeprom_read_byte((uint8_t*)EEPROM_UVLO) == PENDING_RECOVERY)
|
||||
if(eeprom_read_byte((uint8_t*)EEPROM_UVLO) == PowerPanic::PENDING_RECOVERY)
|
||||
{
|
||||
enquecommandf_P(PSTR("G1 Z%.3f F800"), current_position[Z_AXIS] + 25);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,20 @@
|
|||
#pragma once
|
||||
|
||||
namespace PowerPanic {
|
||||
enum PowerPanicFlag : uint8_t {
|
||||
NO_PENDING_RECOVERY = 0,
|
||||
PENDING_RECOVERY = 1, // First power panic, print state is saved in EEPROM
|
||||
PENDING_RECOVERY_RETRY = 2, // Power outage occured during recovery, print is still saved in EEPROM
|
||||
};
|
||||
|
||||
// Types of printjobs possible when power panic is triggered
|
||||
enum PrintType : uint8_t {
|
||||
PRINT_TYPE_SD = 0,
|
||||
PRINT_TYPE_USB = 1,
|
||||
PRINT_TYPE_NONE = 2,
|
||||
};
|
||||
} // namespace PowerPanic
|
||||
|
||||
void uvlo_();
|
||||
void recover_print(uint8_t automatic);
|
||||
void setup_uvlo_interrupt();
|
||||
|
|
|
|||
Loading…
Reference in New Issue