From c4be651d2bf5bc913d8ddba9c92076639ca7fd59 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Sat, 1 Jul 2017 18:51:02 +0200 Subject: [PATCH 1/8] uvlo initial version --- Firmware/Configuration.h | 2 ++ Firmware/Marlin.h | 6 ++++- Firmware/Marlin_main.cpp | 49 ++++++++++++++++++++++++++++++++++++++- Firmware/language_all.cpp | 5 ++++ Firmware/language_all.h | 2 ++ Firmware/language_en.h | 2 +- Firmware/pins.h | 7 +++--- Firmware/stepper.cpp | 1 + Firmware/temperature.cpp | 4 ++++ 9 files changed, 72 insertions(+), 6 deletions(-) diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index 387b10e15..e3387eaaf 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 96f1607c4..6c74b9f25 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 eabf8a0c4..f8c52f795 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 9ba394cc9..c0f3fe8ba 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 0ca88d66a..9a7e1f8fa 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 2cc2824e6..bbc77ef9b 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 1ed3958be..7bd7f5aa5 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 4cadd180e..74e97f2b9 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 b91f53131..b45f0d2f5 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; From db12119b6805eab27ed366b3f42d127b3bae6f97 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Sun, 2 Jul 2017 00:11:21 +0200 Subject: [PATCH 2/8] position saving and restoring in UVLO --- Firmware/Marlin.h | 3 +- Firmware/Marlin_main.cpp | 62 ++++++++++++++++++++++++++-------------- Firmware/stepper.cpp | 2 +- Firmware/temperature.cpp | 2 +- 4 files changed, 45 insertions(+), 24 deletions(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 6c74b9f25..914c484fe 100644 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -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)) \ No newline at end of file diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 16a177271..288392749 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -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_(); +} + diff --git a/Firmware/stepper.cpp b/Firmware/stepper.cpp index cf01cc355..f3191b347 100644 --- a/Firmware/stepper.cpp +++ b/Firmware/stepper.cpp @@ -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? diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index b45f0d2f5..5f7d9cdec 100644 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -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; From 17074e1d25b7c0949d735131a4d5316e170cd5d1 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Sun, 2 Jul 2017 21:01:23 +0200 Subject: [PATCH 3/8] saving/restoring filename and current position in bytes to eeprom, UVLO changed --- Firmware/Configuration.h | 2 ++ Firmware/Marlin.h | 6 ++++ Firmware/Marlin_main.cpp | 68 +++++++++++++++++++++++++++++++++++++--- Firmware/cardreader.h | 1 + Firmware/pins.h | 12 +++---- Firmware/ultralcd.cpp | 5 +++ 6 files changed, 84 insertions(+), 10 deletions(-) diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index 8705a4ab4..8dbe63bf3 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -49,6 +49,8 @@ #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 +#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 // 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 914c484fe..202d23b94 100644 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -356,4 +356,10 @@ void serialecho_temperatures(); void uvlo_(); void recover_print(); void setup_uvlo_interrupt(); + +extern void save_print_to_eeprom(); +extern void restore_print_from_eeprom(); +extern void position_menu(); + + #define UVLO !(PINE & (1<<4)) \ No newline at end of file diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 288392749..7ba625728 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -6748,22 +6748,49 @@ void serialecho_temperatures() { void uvlo_() { - SERIAL_ECHOLNPGM("UVLO"); - eeprom_update_byte((uint8_t*)EEPROM_UVLO, 1); + //SERIAL_ECHOLNPGM("UVLO"); + save_print_to_eeprom(); 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]); + disable_x(); + disable_y(); + planner_abort_hard(); + // Because the planner_abort_hard() initialized current_position[Z] from the stepper, + // Z baystep is no more applied. Reset it. + babystep_reset(); + // Clean the input command queue. + cmdqueue_reset(); + card.sdprinting = false; + card.closefile(); + 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); + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400, 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(); + eeprom_update_byte((uint8_t*)EEPROM_UVLO, 1); } void recover_print() { + //char cmd1[30]; + setTargetHotend0(210); //need to change to stored temperature + setTargetBed(55); homeaxis(X_AXIS); homeaxis(Y_AXIS); + /*float x_rec, y_rec; + x_rec = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 0)); + y_rec = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 4)); + strcpy(cmd1, "G1 X"); + strcat(cmd1, ftostr32(x_rec)); + strcat(cmd1, " Y"); + strcat(cmd1, ftostr32(y_rec)); + enquecommand(cmd1); + enquecommand_P(PSTR("G1 Z" STRINGIFY(-UVLO_Z_AXIS_SHIFT))); + enquecommand_P(PSTR("G1 E" STRINGIFY(DEFAULT_RETRACTION)));*/ + + 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]:"); @@ -6776,12 +6803,41 @@ void recover_print() { 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); + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400, active_extruder); st_synchronize(); + + restore_print_from_eeprom(); eeprom_update_byte((uint8_t*)EEPROM_UVLO, 0); } +void restore_print_from_eeprom() { + char cmd[30]; + char* c; + char filename[13]; + char str[5] = ".gco"; + for (int i = 0; i < 8; i++) { + filename[i] = eeprom_read_byte((uint8_t*)EEPROM_FILENAME + i); + + } + filename[8] = '\0'; + MYSERIAL.print(filename); + strcat(filename, str); + sprintf_P(cmd, PSTR("M23 %s"), filename); + for (c = &cmd[4]; *c; c++) + *c = tolower(*c); + enquecommand(cmd); + uint32_t position = eeprom_read_dword((uint32_t*)(EEPROM_FILE_POSITION)); + SERIAL_ECHOPGM("Position read from eeprom:"); + MYSERIAL.println(position); + + card.setIndex(position); + enquecommand_P(PSTR("M24")); + sprintf_P(cmd, PSTR("M26 S%d"), position); + enquecommand(cmd); +} + + void setup_uvlo_interrupt() { DDRE &= ~(1 << 4); //input pin PORTE &= ~(1 << 4); //no internal pull-up @@ -6800,3 +6856,7 @@ ISR(INT4_vect) { uvlo_(); } + +void save_print_to_eeprom() { + eeprom_update_dword((uint32_t*)(EEPROM_FILE_POSITION), card.get_sdpos()); +} diff --git a/Firmware/cardreader.h b/Firmware/cardreader.h index 3e87b3315..ec7f3e7c5 100644 --- a/Firmware/cardreader.h +++ b/Firmware/cardreader.h @@ -47,6 +47,7 @@ public: FORCE_INLINE void setIndex(long index) {sdpos = index;file.seekSet(index);}; FORCE_INLINE uint8_t percentDone(){if(!isFileOpen()) return 0; if(filesize) return sdpos/((filesize+99)/100); else return 0;}; FORCE_INLINE char* getWorkDirName(){workDir.getFilename(filename);return filename;}; + FORCE_INLINE uint32_t get_sdpos() { if (!isFileOpen()) return 0; else return(sdpos); }; bool ToshibaFlashAir_isEnabled() const { return card.getFlashAirCompatible(); } void ToshibaFlashAir_enable(bool enable) { card.setFlashAirCompatible(enable); } diff --git a/Firmware/pins.h b/Firmware/pins.h index 046cc03b1..b49651cb1 100644 --- a/Firmware/pins.h +++ b/Firmware/pins.h @@ -399,9 +399,8 @@ #define BEEPER 84 // Beeper on AUX-4 #define LCD_PINS_RS 82 - -#define LCD_PINS_ENABLE 61 -#define LCD_PINS_D4 59 +#define LCD_PINS_ENABLE 18 +#define LCD_PINS_D4 19 #define LCD_PINS_D5 70 #define LCD_PINS_D6 85 #define LCD_PINS_D7 71 @@ -413,7 +412,7 @@ #define SDCARDDETECT 15 -#define TACH_0 79 +#define TACH_0 81 #define TACH_1 80 #endif //NEWPANEL @@ -504,12 +503,13 @@ #ifdef NEWPANEL + #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_D4 59 #define LCD_PINS_D5 70 #define LCD_PINS_D6 85 #define LCD_PINS_D7 71 @@ -522,7 +522,7 @@ #define SDCARDDETECT 15 #define TACH_0 79 -#define TACH_1 80 +#define TACH_1 80 #endif //NEWPANEL #endif //ULTRA_LCD diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 6adddd502..4bb4d12e2 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -3688,6 +3688,8 @@ static void lcd_main_menu() MENU_ITEM(back, MSG_WATCH, lcd_status_screen); + + MENU_ITEM(function, PSTR("restore_print"), restore_print_from_eeprom); /* if (farm_mode && !IS_SD_PRINTING ) { @@ -4818,6 +4820,9 @@ static void menu_action_sdfile(const char* filename, char* longFilename) for (c = &cmd[4]; *c; c++) *c = tolower(*c); enquecommand(cmd); + for (int i = 0; i < 8; i++) { + eeprom_write_byte((uint8_t*)EEPROM_FILENAME + i, filename[i]); + } enquecommand_P(PSTR("M24")); lcd_return_to_status(); } From 4ae5751d95c92e516028ef7f65e114ea86c59fef Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Mon, 3 Jul 2017 14:08:27 +0200 Subject: [PATCH 4/8] added debug messages for serial --- Firmware/Marlin_main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 7ba625728..318e4a8cb 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -1601,7 +1601,11 @@ void get_command() } cmdbuffer[bufindw+serial_count+1] = 0; //terminate string cmdbuffer[bufindw] = CMDBUFFER_CURRENT_TYPE_SDCARD; + SERIAL_ECHOPGM("cmdbuffer:"); + MYSERIAL.print(cmdbuffer); ++ buflen; + SERIAL_ECHOPGM("buflen:"); + MYSERIAL.print(buflen); bufindw += strlen(cmdbuffer+bufindw+1) + 2; if (bufindw == sizeof(cmdbuffer)) bufindw = 0; From a8678cb2fde93cebb7eaaf863c4f0cc4397686b8 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Tue, 4 Jul 2017 11:31:39 +0200 Subject: [PATCH 5/8] recover print --- Firmware/Configuration.h | 4 + Firmware/Marlin.h | 2 +- Firmware/Marlin_main.cpp | 156 ++++++++++++++++++++++++++++----------- Firmware/cardreader.cpp | 2 +- Firmware/temperature.cpp | 7 +- Firmware/tmc2130.cpp | 4 + Firmware/ultralcd.cpp | 3 +- 7 files changed, 125 insertions(+), 53 deletions(-) diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index f5f8c5700..36ecee5c0 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -51,6 +51,10 @@ #define EEPROM_UVLO_CURRENT_POSITION (EEPROM_UVLO-2*4) // 2 x float for current_position in X and Y axes #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_TARGET_HOTEND (EEPROM_UVLO_CURRENT_POSITION_Z - 1) +#define EEPROM_UVLO_TARGET_BED (EEPROM_UVLO_TARGET_HOTEND - 1) + // 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 202d23b94..77ab5b88a 100644 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -209,7 +209,7 @@ void ClearToSend(); void get_coordinates(); void prepare_move(); -void kill(const char *full_screen_message = NULL); +void kill(const char *full_screen_message = NULL, unsigned char id = 0); void Stop(); bool IsStopped(); diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 61a79db15..9be8df78b 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -1227,18 +1227,21 @@ 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(); - 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]); 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(); - + 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); + lcd_update_enable(true); + lcd_update(2); + lcd_setstatuspgm(WELCOME_MSG); + } + } } @@ -1494,7 +1497,7 @@ void get_command() //If command was e-stop process now if(strcmp(cmdbuffer+bufindw+1, "M112") == 0) - kill(); + kill("", 2); // Store the current line into buffer, move to the next line. cmdbuffer[bufindw] = CMDBUFFER_CURRENT_TYPE_USB; @@ -4149,7 +4152,7 @@ Sigma_Exit: setWatch(); break; case 112: // M112 -Emergency Stop - kill(); + kill("", 3); break; case 140: // M140 set bed temp if (code_seen('S')) setTargetBed(code_value()); @@ -6028,7 +6031,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s if( (millis() - previous_millis_cmd) > max_inactive_time ) if(max_inactive_time) - kill(); + kill("", 4); if(stepper_inactive_time) { if( (millis() - previous_millis_cmd) > stepper_inactive_time ) { @@ -6070,7 +6073,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s // ---------------------------------------------------------------- if ( killCount >= KILL_DELAY) { - kill(); + kill("", 5); } #endif @@ -6102,8 +6105,11 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s check_axes_activity(); } -void kill(const char *full_screen_message) +void kill(const char *full_screen_message, unsigned char id) { + SERIAL_ECHOPGM("KILL: "); + MYSERIAL.println(int(id)); + //return; cli(); // Stop interrupts disable_heater(); @@ -6790,37 +6796,70 @@ void serialecho_temperatures() { void uvlo_() { - //SERIAL_ECHOLNPGM("UVLO"); - save_print_to_eeprom(); - 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]); - disable_x(); - disable_y(); - planner_abort_hard(); - // Because the planner_abort_hard() initialized current_position[Z] from the stepper, - // Z baystep is no more applied. Reset it. - babystep_reset(); - // Clean the input command queue. - cmdqueue_reset(); - card.sdprinting = false; - card.closefile(); + //SERIAL_ECHOLNPGM("UVLO"); + save_print_to_eeprom(); + 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]); + eeprom_update_float((float*)(EEPROM_UVLO_CURRENT_POSITION_Z), current_position[Z_AXIS]); + eeprom_update_byte((uint8_t*)EEPROM_UVLO_TARGET_HOTEND, target_temperature[active_extruder]); + eeprom_update_byte((uint8_t*)EEPROM_UVLO_TARGET_BED, target_temperature_bed); + disable_x(); + disable_y(); + planner_abort_hard(); + // Because the planner_abort_hard() initialized current_position[Z] from the stepper, + // Z baystep is no more applied. Reset it. + babystep_reset(); + // Clean the input command queue. + cmdqueue_reset(); + card.sdprinting = false; + card.closefile(); - 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], 400, 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(); - eeprom_update_byte((uint8_t*)EEPROM_UVLO, 1); + 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], 400, 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(); + eeprom_update_byte((uint8_t*)EEPROM_UVLO, 1); } void recover_print() { + char cmd[30]; + lcd_update_enable(true); + lcd_update(2); + lcd_setstatuspgm(WELCOME_MSG); //char cmd1[30]; + target_temperature[active_extruder] = eeprom_read_byte((uint8_t*)EEPROM_UVLO_TARGET_HOTEND); + target_temperature_bed = eeprom_read_byte((uint8_t*)EEPROM_UVLO_TARGET_BED); setTargetHotend0(210); //need to change to stored temperature setTargetBed(55); - homeaxis(X_AXIS); - homeaxis(Y_AXIS); + //SERIAL_ECHOPGM("Target temperature:"); + //MYSERIAL.println(target_temperature[0]); + //SERIAL_ECHOPGM("Target temp bed:"); + //MYSERIAL.println(target_temperature_bed); + //homeaxis(X_AXIS); + //homeaxis(Y_AXIS); + //home_xy(); + float z_pos = UVLO_Z_AXIS_SHIFT + eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION_Z)); + //plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); + + SERIAL_ECHOPGM("current_position[Z_AXIS]:"); + MYSERIAL.println(current_position[Z_AXIS]); + SERIAL_ECHOPGM("z_pos"); + MYSERIAL.println(z_pos); + enquecommand_P(PSTR("G28 X")); + enquecommand_P(PSTR("G28 Y")); + strcpy(cmd, "G92 Z"); + strcat(cmd, ftostr43(z_pos)); + //fprintf(cmd, PSTR("G92 Z3.3%f"), z_pos); + enquecommand(cmd); + //enquecommand_P(PSTR("G92 Z2.2")); + eeprom_update_byte((uint8_t*)EEPROM_UVLO, 0); + while ((abs(degHotend(0)- target_temperature[0])>5) || (abs(degBed() -target_temperature_bed)>3)) { //wait for heater and bed to reach target temp + delay_keep_alive(1000); + } + //enquecommand_P("G28 W"); /*float x_rec, y_rec; x_rec = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 0)); y_rec = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 4)); @@ -6833,24 +6872,27 @@ void recover_print() { enquecommand_P(PSTR("G1 E" STRINGIFY(DEFAULT_RETRACTION)));*/ - 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)); + //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[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], 400, active_extruder); - st_synchronize(); + st_synchronize();*/ + //enquecommand_P(PSTR("G1 Z" STRINGIFY(-UVLO_Z_AXIS_SHIFT))); + //enquecommand_P(PSTR("G1 E" STRINGIFY(DEFAULT_RETRACTION))); restore_print_from_eeprom(); - eeprom_update_byte((uint8_t*)EEPROM_UVLO, 0); - + SERIAL_ECHOPGM("current_position[Z_AXIS]:"); + MYSERIAL.print(current_position[Z_AXIS]); } void restore_print_from_eeprom() { @@ -6877,6 +6919,10 @@ void restore_print_from_eeprom() { enquecommand_P(PSTR("M24")); sprintf_P(cmd, PSTR("M26 S%d"), position); enquecommand(cmd); + enquecommand_P(PSTR("M83")); + //SERIAL_ECHO(cmdbuffer + bufindr + 1); + enquecommand_P(PSTR("G1 Z" STRINGIFY(-UVLO_Z_AXIS_SHIFT))); + enquecommand_P(PSTR("G1 E" STRINGIFY(DEFAULT_RETRACTION)" F2000")); } @@ -6895,10 +6941,30 @@ 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_ECHOLNPGM("INT4"); - uvlo_(); + if(IS_SD_PRINTING) uvlo_(); } void save_print_to_eeprom() { - eeprom_update_dword((uint32_t*)(EEPROM_FILE_POSITION), card.get_sdpos()); + //eeprom_update_word((uint16_t*)(EPROM_UVLO_CMD_QUEUE), bufindw - bufindr ); + //BLOCK_BUFFER_SIZE: max. 16 linear moves in planner buffer +#define TYP_GCODE_LENGTH 29 //G1 X117.489 Y22.814 E1.46695 + null + //card.get_sdpos() -> byte currently read from SD card + //bufindw -> position in circular buffer where to write + //bufindr -> position in circular buffer where to read + //bufflen -> number of lines in buffer -> for each line one special character?? + //TYP_GCODE_LENGTH* BLOCK_BUFFER_SIZE -> worst case from planner + long sd_position = card.get_sdpos() - ((bufindw > bufindr) ? (bufindw - bufindr) : sizeof(cmdbuffer) - bufindr + bufindw) - buflen - TYP_GCODE_LENGTH* BLOCK_BUFFER_SIZE; + if (sd_position < 0) sd_position = 0; + /*SERIAL_ECHOPGM("sd position before correction:"); + MYSERIAL.println(card.get_sdpos()); + SERIAL_ECHOPGM("bufindw:"); + MYSERIAL.println(bufindw); + SERIAL_ECHOPGM("bufindr:"); + MYSERIAL.println(bufindr); + SERIAL_ECHOPGM("sizeof(cmd_buffer):"); + MYSERIAL.println(sizeof(cmdbuffer)); + SERIAL_ECHOPGM("sd position after correction:"); + MYSERIAL.println(sd_position);*/ + eeprom_update_dword((uint32_t*)(EEPROM_FILE_POSITION), sd_position); } diff --git a/Firmware/cardreader.cpp b/Firmware/cardreader.cpp index f41f20ac7..28102aa1c 100644 --- a/Firmware/cardreader.cpp +++ b/Firmware/cardreader.cpp @@ -262,7 +262,7 @@ void CardReader::openFile(char* name,bool read, bool replace_current/*=true*/) SERIAL_ERROR_START; SERIAL_ERRORPGM("trying to call sub-gcode files with too many levels. MAX level is:"); SERIAL_ERRORLN(SD_PROCEDURE_DEPTH); - kill(); + kill("", 1); return; } diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index 5f7d9cdec..f5ea17496 100644 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -406,10 +406,7 @@ 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))); @@ -757,7 +754,7 @@ static float analog2temp(int raw, uint8_t e) { SERIAL_ERROR_START; SERIAL_ERROR((int)e); SERIAL_ERRORLNPGM(" - Invalid extruder number !"); - kill(); + kill("", 6); return 0.0; } #ifdef HEATER_0_USES_MAX6675 diff --git a/Firmware/tmc2130.cpp b/Firmware/tmc2130.cpp index 8fc05817f..5009fda05 100644 --- a/Firmware/tmc2130.cpp +++ b/Firmware/tmc2130.cpp @@ -162,10 +162,13 @@ void tmc2130_check_overtemp() //drivers_disabled[0] = 1; //TEST if( millis() - checktime > 1000 ) { + //SERIAL_ECHOLNPGM("drv_status:"); for(int i=0;i<4;i++) { uint32_t drv_status = 0; tmc2130_rd(cs[i], TMC2130_REG_DRV_STATUS, &drv_status); + //MYSERIAL.print(drv_status); + //SERIAL_ECHOPGM(" "); if (drv_status & ((uint32_t)1<<26)) { // BIT 26 - over temp prewarning ~120C (+-20C) SERIAL_ERRORRPGM(TMC_OVERTEMP_MSG); @@ -175,6 +178,7 @@ void tmc2130_check_overtemp() kill(TMC_OVERTEMP_MSG); } } + //SERIAL_ECHOLNPGM(""); checktime = millis(); } } diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 4533c6b2d..4ca6b9326 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -3698,7 +3698,8 @@ static void lcd_main_menu() MENU_ITEM(back, MSG_WATCH, lcd_status_screen); MENU_ITEM(function, PSTR("restore_print"), restore_print_from_eeprom); - /* if (farm_mode && !IS_SD_PRINTING ) + MENU_ITEM(function, PSTR("recover print"), recover_print); + /* if (farm_mode && !IS_SD_PRINTING ) { int tempScrool = 0; From ef7a3026264b9c257b21982b67deed69fe9352c8 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Tue, 4 Jul 2017 20:58:44 +0200 Subject: [PATCH 6/8] power panic: Z axis is lowered in position where print starts (is recovered) --- Firmware/Marlin_main.cpp | 89 +++++++++++++++++----------------------- Firmware/pins.h | 2 +- 2 files changed, 39 insertions(+), 52 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 9be8df78b..f95f7feed 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -1234,7 +1234,7 @@ void setup() // so the next time the firmware gets updated, it will know from which version it has been updated. update_current_firmware_version_to_eeprom(); 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(); + if (lcd_show_fullscreen_message_yes_no_and_wait_P(MSG_RECOVER_PRINT, false)) recover_print(); else { eeprom_update_byte((uint8_t*)EEPROM_UVLO, 0); lcd_update_enable(true); @@ -2685,6 +2685,11 @@ void process_commands() homing_flag = false; + SERIAL_ECHOLNPGM("Homing happened"); + SERIAL_ECHOPGM("Current position X AXIS:"); + MYSERIAL.println(current_position[X_AXIS]); + SERIAL_ECHOPGM("Current position Y_AXIS:"); + MYSERIAL.println(current_position[Y_AXIS]); break; #ifdef ENABLE_AUTO_BED_LEVELING @@ -6798,8 +6803,14 @@ void serialecho_temperatures() { void uvlo_() { //SERIAL_ECHOLNPGM("UVLO"); save_print_to_eeprom(); - 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]); + float current_position_bckp[2]; + + current_position_bckp[X_AXIS] = st_get_position_mm(X_AXIS); + current_position_bckp[Y_AXIS] = st_get_position_mm(Y_AXIS); + + + eeprom_update_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 0), current_position_bckp[X_AXIS]); + eeprom_update_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 4), current_position_bckp[Y_AXIS]); eeprom_update_float((float*)(EEPROM_UVLO_CURRENT_POSITION_Z), current_position[Z_AXIS]); eeprom_update_byte((uint8_t*)EEPROM_UVLO_TARGET_HOTEND, target_temperature[active_extruder]); eeprom_update_byte((uint8_t*)EEPROM_UVLO_TARGET_BED, target_temperature_bed); @@ -6829,82 +6840,52 @@ void recover_print() { lcd_update_enable(true); lcd_update(2); lcd_setstatuspgm(WELCOME_MSG); - //char cmd1[30]; + target_temperature[active_extruder] = eeprom_read_byte((uint8_t*)EEPROM_UVLO_TARGET_HOTEND); target_temperature_bed = eeprom_read_byte((uint8_t*)EEPROM_UVLO_TARGET_BED); + //x_rec = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 0)); + //y_rec = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 4)); + float z_pos = UVLO_Z_AXIS_SHIFT + eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION_Z)); setTargetHotend0(210); //need to change to stored temperature setTargetBed(55); //SERIAL_ECHOPGM("Target temperature:"); //MYSERIAL.println(target_temperature[0]); //SERIAL_ECHOPGM("Target temp bed:"); //MYSERIAL.println(target_temperature_bed); - //homeaxis(X_AXIS); - //homeaxis(Y_AXIS); - //home_xy(); - float z_pos = UVLO_Z_AXIS_SHIFT + eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION_Z)); - //plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - SERIAL_ECHOPGM("current_position[Z_AXIS]:"); - MYSERIAL.println(current_position[Z_AXIS]); - SERIAL_ECHOPGM("z_pos"); - MYSERIAL.println(z_pos); enquecommand_P(PSTR("G28 X")); enquecommand_P(PSTR("G28 Y")); strcpy(cmd, "G92 Z"); strcat(cmd, ftostr43(z_pos)); - //fprintf(cmd, PSTR("G92 Z3.3%f"), z_pos); enquecommand(cmd); - //enquecommand_P(PSTR("G92 Z2.2")); + eeprom_update_byte((uint8_t*)EEPROM_UVLO, 0); while ((abs(degHotend(0)- target_temperature[0])>5) || (abs(degBed() -target_temperature_bed)>3)) { //wait for heater and bed to reach target temp delay_keep_alive(1000); } - //enquecommand_P("G28 W"); - /*float x_rec, y_rec; - x_rec = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 0)); - y_rec = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 4)); - strcpy(cmd1, "G1 X"); - strcat(cmd1, ftostr32(x_rec)); - strcat(cmd1, " Y"); - strcat(cmd1, ftostr32(y_rec)); - enquecommand(cmd1); - enquecommand_P(PSTR("G1 Z" STRINGIFY(-UVLO_Z_AXIS_SHIFT))); - enquecommand_P(PSTR("G1 E" STRINGIFY(DEFAULT_RETRACTION)));*/ - - - //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], 400, active_extruder); - st_synchronize();*/ - - //enquecommand_P(PSTR("G1 Z" STRINGIFY(-UVLO_Z_AXIS_SHIFT))); - //enquecommand_P(PSTR("G1 E" STRINGIFY(DEFAULT_RETRACTION))); restore_print_from_eeprom(); SERIAL_ECHOPGM("current_position[Z_AXIS]:"); MYSERIAL.print(current_position[Z_AXIS]); } void restore_print_from_eeprom() { + float x_rec, y_rec; char cmd[30]; char* c; char filename[13]; char str[5] = ".gco"; + x_rec = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 0)); + y_rec = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 4)); + //SERIAL_ECHOPGM("X pos read from EEPROM:"); + //MYSERIAL.println(x_rec); + //SERIAL_ECHOPGM("Y pos read from EEPROM:"); + //MYSERIAL.println(y_rec); for (int i = 0; i < 8; i++) { filename[i] = eeprom_read_byte((uint8_t*)EEPROM_FILENAME + i); } filename[8] = '\0'; + MYSERIAL.print(filename); strcat(filename, str); sprintf_P(cmd, PSTR("M23 %s"), filename); @@ -6914,13 +6895,19 @@ void restore_print_from_eeprom() { uint32_t position = eeprom_read_dword((uint32_t*)(EEPROM_FILE_POSITION)); SERIAL_ECHOPGM("Position read from eeprom:"); MYSERIAL.println(position); + sprintf_P(cmd, PSTR("M26 %lu"), position); + //card.setIndex(int32_t(position)); //set from which SD card byte we will start + //if (card.cardOK && code_seen('S')) { + // card.setIndex(code_value_long()); + //} - card.setIndex(position); - enquecommand_P(PSTR("M24")); - sprintf_P(cmd, PSTR("M26 S%d"), position); + enquecommand_P(PSTR("M24")); //M24 - Start SD print + enquecommand_P(PSTR("M83")); //E axis relative mode + strcpy(cmd, "G1 X"); + strcat(cmd, ftostr32(x_rec)); + strcat(cmd, " Y"); + strcat(cmd, ftostr32(y_rec)); enquecommand(cmd); - enquecommand_P(PSTR("M83")); - //SERIAL_ECHO(cmdbuffer + bufindr + 1); enquecommand_P(PSTR("G1 Z" STRINGIFY(-UVLO_Z_AXIS_SHIFT))); enquecommand_P(PSTR("G1 E" STRINGIFY(DEFAULT_RETRACTION)" F2000")); } diff --git a/Firmware/pins.h b/Firmware/pins.h index b49651cb1..d19ad26b3 100644 --- a/Firmware/pins.h +++ b/Firmware/pins.h @@ -499,7 +499,7 @@ #ifdef ULTRA_LCD -#define KILL_PIN 32 +//#define KILL_PIN 32 #ifdef NEWPANEL From 2c102f8580fefe119568f48ad2f7a5a7eae6b8a6 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 5 Jul 2017 09:16:33 +0200 Subject: [PATCH 7/8] fixed SD card restore position (power panic) --- Firmware/Marlin_main.cpp | 109 ++++++++++++++++++++------------------- Firmware/ultralcd.cpp | 4 +- 2 files changed, 56 insertions(+), 57 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index f95f7feed..e903fbf74 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -6835,6 +6835,49 @@ void uvlo_() { eeprom_update_byte((uint8_t*)EEPROM_UVLO, 1); } +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"); + if (IS_SD_PRINTING) uvlo_(); +} + + +void save_print_to_eeprom() { + //eeprom_update_word((uint16_t*)(EPROM_UVLO_CMD_QUEUE), bufindw - bufindr ); + //BLOCK_BUFFER_SIZE: max. 16 linear moves in planner buffer +#define TYP_GCODE_LENGTH 29 //G1 X117.489 Y22.814 E1.46695 + null + //card.get_sdpos() -> byte currently read from SD card + //bufindw -> position in circular buffer where to write + //bufindr -> position in circular buffer where to read + //bufflen -> number of lines in buffer -> for each line one special character?? + //TYP_GCODE_LENGTH* BLOCK_BUFFER_SIZE -> worst case from planner + long sd_position = card.get_sdpos() - ((bufindw > bufindr) ? (bufindw - bufindr) : sizeof(cmdbuffer) - bufindr + bufindw) - buflen - TYP_GCODE_LENGTH* BLOCK_BUFFER_SIZE; + if (sd_position < 0) sd_position = 0; + /*SERIAL_ECHOPGM("sd position before correction:"); + MYSERIAL.println(card.get_sdpos()); + SERIAL_ECHOPGM("bufindw:"); + MYSERIAL.println(bufindw); + SERIAL_ECHOPGM("bufindr:"); + MYSERIAL.println(bufindr); + SERIAL_ECHOPGM("sizeof(cmd_buffer):"); + MYSERIAL.println(sizeof(cmdbuffer)); + SERIAL_ECHOPGM("sd position after correction:"); + MYSERIAL.println(sd_position);*/ + eeprom_update_dword((uint32_t*)(EEPROM_FILE_POSITION), sd_position); +} + void recover_print() { char cmd[30]; lcd_update_enable(true); @@ -6846,12 +6889,11 @@ void recover_print() { //x_rec = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 0)); //y_rec = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 4)); float z_pos = UVLO_Z_AXIS_SHIFT + eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION_Z)); - setTargetHotend0(210); //need to change to stored temperature - setTargetBed(55); - //SERIAL_ECHOPGM("Target temperature:"); - //MYSERIAL.println(target_temperature[0]); - //SERIAL_ECHOPGM("Target temp bed:"); - //MYSERIAL.println(target_temperature_bed); + + SERIAL_ECHOPGM("Target temperature:"); + MYSERIAL.println(target_temperature[0]); + SERIAL_ECHOPGM("Target temp bed:"); + MYSERIAL.println(target_temperature_bed); enquecommand_P(PSTR("G28 X")); enquecommand_P(PSTR("G28 Y")); @@ -6895,13 +6937,16 @@ void restore_print_from_eeprom() { uint32_t position = eeprom_read_dword((uint32_t*)(EEPROM_FILE_POSITION)); SERIAL_ECHOPGM("Position read from eeprom:"); MYSERIAL.println(position); - sprintf_P(cmd, PSTR("M26 %lu"), position); - //card.setIndex(int32_t(position)); //set from which SD card byte we will start + enquecommand_P(PSTR("M24")); //M24 - Start SD print + sprintf_P(cmd, PSTR("M26 S%lu"), position); + + //card.setIndex(long(position)); //set from which SD card byte we will start //if (card.cardOK && code_seen('S')) { // card.setIndex(code_value_long()); //} - enquecommand_P(PSTR("M24")); //M24 - Start SD print + //delay? + enquecommand(cmd); enquecommand_P(PSTR("M83")); //E axis relative mode strcpy(cmd, "G1 X"); strcat(cmd, ftostr32(x_rec)); @@ -6910,48 +6955,4 @@ void restore_print_from_eeprom() { enquecommand(cmd); enquecommand_P(PSTR("G1 Z" STRINGIFY(-UVLO_Z_AXIS_SHIFT))); enquecommand_P(PSTR("G1 E" STRINGIFY(DEFAULT_RETRACTION)" F2000")); -} - - -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"); - if(IS_SD_PRINTING) uvlo_(); -} - - -void save_print_to_eeprom() { - //eeprom_update_word((uint16_t*)(EPROM_UVLO_CMD_QUEUE), bufindw - bufindr ); - //BLOCK_BUFFER_SIZE: max. 16 linear moves in planner buffer -#define TYP_GCODE_LENGTH 29 //G1 X117.489 Y22.814 E1.46695 + null - //card.get_sdpos() -> byte currently read from SD card - //bufindw -> position in circular buffer where to write - //bufindr -> position in circular buffer where to read - //bufflen -> number of lines in buffer -> for each line one special character?? - //TYP_GCODE_LENGTH* BLOCK_BUFFER_SIZE -> worst case from planner - long sd_position = card.get_sdpos() - ((bufindw > bufindr) ? (bufindw - bufindr) : sizeof(cmdbuffer) - bufindr + bufindw) - buflen - TYP_GCODE_LENGTH* BLOCK_BUFFER_SIZE; - if (sd_position < 0) sd_position = 0; - /*SERIAL_ECHOPGM("sd position before correction:"); - MYSERIAL.println(card.get_sdpos()); - SERIAL_ECHOPGM("bufindw:"); - MYSERIAL.println(bufindw); - SERIAL_ECHOPGM("bufindr:"); - MYSERIAL.println(bufindr); - SERIAL_ECHOPGM("sizeof(cmd_buffer):"); - MYSERIAL.println(sizeof(cmdbuffer)); - SERIAL_ECHOPGM("sd position after correction:"); - MYSERIAL.println(sd_position);*/ - eeprom_update_dword((uint32_t*)(EEPROM_FILE_POSITION), sd_position); -} +} \ No newline at end of file diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 4ca6b9326..27f8bdb74 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -3685,7 +3685,6 @@ void lcd_confirm_print() } - static void lcd_main_menu() { @@ -3696,9 +3695,8 @@ static void lcd_main_menu() MENU_ITEM(back, MSG_WATCH, lcd_status_screen); - - MENU_ITEM(function, PSTR("restore_print"), restore_print_from_eeprom); MENU_ITEM(function, PSTR("recover print"), recover_print); + /* if (farm_mode && !IS_SD_PRINTING ) { From 16fffed52d850b89282ed1f7800165446128c2bb Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 5 Jul 2017 15:04:43 +0200 Subject: [PATCH 8/8] current feedrate and fan speed stored to eeprom in power panic, number of blocks (linear movements) in planner serve for counting SD card recover position, print fan speed error limit prolonged to 15s --- Firmware/Configuration.h | 2 ++ Firmware/Marlin_main.cpp | 39 ++++++++++++++++++++------------------- Firmware/planner.cpp | 4 +++- Firmware/planner.h | 2 ++ Firmware/temperature.cpp | 2 +- Firmware/ultralcd.cpp | 1 - 6 files changed, 28 insertions(+), 22 deletions(-) diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index 36ecee5c0..6852b9cf1 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -54,6 +54,8 @@ #define EEPROM_UVLO_CURRENT_POSITION_Z (EEPROM_FILE_POSITION - 4) //float for current position in Z #define EEPROM_UVLO_TARGET_HOTEND (EEPROM_UVLO_CURRENT_POSITION_Z - 1) #define EEPROM_UVLO_TARGET_BED (EEPROM_UVLO_TARGET_HOTEND - 1) +#define EEPROM_UVLO_FEEDRATE (EEPROM_UVLO_TARGET_BED - 2) +#define EEPROM_UVLO_FAN_SPEED (EEPROM_UVLO_FEEDRATE - 1) // Currently running firmware, each digit stored as uint16_t. diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index e903fbf74..1c183a632 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -6804,16 +6804,17 @@ void uvlo_() { //SERIAL_ECHOLNPGM("UVLO"); save_print_to_eeprom(); float current_position_bckp[2]; - + int feedrate_bckp = feedrate; current_position_bckp[X_AXIS] = st_get_position_mm(X_AXIS); current_position_bckp[Y_AXIS] = st_get_position_mm(Y_AXIS); - eeprom_update_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 0), current_position_bckp[X_AXIS]); eeprom_update_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 4), current_position_bckp[Y_AXIS]); eeprom_update_float((float*)(EEPROM_UVLO_CURRENT_POSITION_Z), current_position[Z_AXIS]); + EEPROM_save_B(EEPROM_UVLO_FEEDRATE, &feedrate_bckp); eeprom_update_byte((uint8_t*)EEPROM_UVLO_TARGET_HOTEND, target_temperature[active_extruder]); eeprom_update_byte((uint8_t*)EEPROM_UVLO_TARGET_BED, target_temperature_bed); + eeprom_update_byte((uint8_t*)EEPROM_UVLO_FAN_SPEED, fanSpeed); disable_x(); disable_y(); planner_abort_hard(); @@ -6857,13 +6858,13 @@ ISR(INT4_vect) { void save_print_to_eeprom() { //eeprom_update_word((uint16_t*)(EPROM_UVLO_CMD_QUEUE), bufindw - bufindr ); //BLOCK_BUFFER_SIZE: max. 16 linear moves in planner buffer -#define TYP_GCODE_LENGTH 29 //G1 X117.489 Y22.814 E1.46695 + null +#define TYP_GCODE_LENGTH 30 //G1 X117.489 Y22.814 E1.46695 + cr lf //card.get_sdpos() -> byte currently read from SD card //bufindw -> position in circular buffer where to write //bufindr -> position in circular buffer where to read //bufflen -> number of lines in buffer -> for each line one special character?? - //TYP_GCODE_LENGTH* BLOCK_BUFFER_SIZE -> worst case from planner - long sd_position = card.get_sdpos() - ((bufindw > bufindr) ? (bufindw - bufindr) : sizeof(cmdbuffer) - bufindr + bufindw) - buflen - TYP_GCODE_LENGTH* BLOCK_BUFFER_SIZE; + //number_of_blocks() returns number of linear movements buffered in planner + long sd_position = card.get_sdpos() - ((bufindw > bufindr) ? (bufindw - bufindr) : sizeof(cmdbuffer) - bufindr + bufindw) - TYP_GCODE_LENGTH* number_of_blocks(); if (sd_position < 0) sd_position = 0; /*SERIAL_ECHOPGM("sd position before correction:"); MYSERIAL.println(card.get_sdpos()); @@ -6886,8 +6887,6 @@ void recover_print() { target_temperature[active_extruder] = eeprom_read_byte((uint8_t*)EEPROM_UVLO_TARGET_HOTEND); target_temperature_bed = eeprom_read_byte((uint8_t*)EEPROM_UVLO_TARGET_BED); - //x_rec = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 0)); - //y_rec = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 4)); float z_pos = UVLO_Z_AXIS_SHIFT + eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION_Z)); SERIAL_ECHOPGM("Target temperature:"); @@ -6912,16 +6911,18 @@ void recover_print() { void restore_print_from_eeprom() { float x_rec, y_rec; + int feedrate_rec; + uint8_t fan_speed_rec; char cmd[30]; char* c; char filename[13]; char str[5] = ".gco"; x_rec = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 0)); y_rec = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 4)); - //SERIAL_ECHOPGM("X pos read from EEPROM:"); - //MYSERIAL.println(x_rec); - //SERIAL_ECHOPGM("Y pos read from EEPROM:"); - //MYSERIAL.println(y_rec); + fan_speed_rec = eeprom_read_byte((uint8_t*)EEPROM_UVLO_FAN_SPEED); + EEPROM_read_B(EEPROM_UVLO_FEEDRATE, &feedrate_rec); + SERIAL_ECHOPGM("Feedrate:"); + MYSERIAL.println(feedrate_rec); for (int i = 0; i < 8; i++) { filename[i] = eeprom_read_byte((uint8_t*)EEPROM_FILENAME + i); @@ -6939,13 +6940,6 @@ void restore_print_from_eeprom() { MYSERIAL.println(position); enquecommand_P(PSTR("M24")); //M24 - Start SD print sprintf_P(cmd, PSTR("M26 S%lu"), position); - - //card.setIndex(long(position)); //set from which SD card byte we will start - //if (card.cardOK && code_seen('S')) { - // card.setIndex(code_value_long()); - //} - - //delay? enquecommand(cmd); enquecommand_P(PSTR("M83")); //E axis relative mode strcpy(cmd, "G1 X"); @@ -6954,5 +6948,12 @@ void restore_print_from_eeprom() { strcat(cmd, ftostr32(y_rec)); enquecommand(cmd); enquecommand_P(PSTR("G1 Z" STRINGIFY(-UVLO_Z_AXIS_SHIFT))); - enquecommand_P(PSTR("G1 E" STRINGIFY(DEFAULT_RETRACTION)" F2000")); + enquecommand_P(PSTR("G1 E" STRINGIFY(DEFAULT_RETRACTION)" F480")); + enquecommand_P(PSTR("G1 E0.5")); + sprintf_P(cmd, PSTR("G1 F%d"), feedrate_rec); + enquecommand(cmd); + strcpy(cmd, "M106 S"); + strcat(cmd, itostr3(int(fan_speed_rec))); + enquecommand(cmd); + } \ No newline at end of file diff --git a/Firmware/planner.cpp b/Firmware/planner.cpp index bdfc4ca21..248b269d4 100644 --- a/Firmware/planner.cpp +++ b/Firmware/planner.cpp @@ -1215,7 +1215,9 @@ void reset_acceleration_rates() axis_steps_per_sqr_second[i] = max_acceleration_units_per_sq_second[i] * axis_steps_per_unit[i]; } } - +unsigned char number_of_blocks() { + return (block_buffer_head + BLOCK_BUFFER_SIZE - block_buffer_tail) & (BLOCK_BUFFER_SIZE - 1); +} #ifdef PLANNER_DIAGNOSTICS uint8_t planner_queue_min() { diff --git a/Firmware/planner.h b/Firmware/planner.h index 30194952d..c47cecbb0 100644 --- a/Firmware/planner.h +++ b/Firmware/planner.h @@ -199,6 +199,8 @@ void set_extrude_min_temp(float temp); void reset_acceleration_rates(); #endif +unsigned char number_of_blocks(); + // #define PLANNER_DIAGNOSTICS #ifdef PLANNER_DIAGNOSTICS // Diagnostic functions to display planner buffer underflow on the display. diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index f5ea17496..93c0b5682 100644 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -425,7 +425,7 @@ void checkFanSpeed() else fan_speed_errors[1] = 0; if (fan_speed_errors[0] > 5) fanSpeedError(0); - if (fan_speed_errors[1] > 5) fanSpeedError(1); + if (fan_speed_errors[1] > 15) fanSpeedError(1); } void fanSpeedError(unsigned char _fan) { diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 27f8bdb74..52b1d6cbb 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -3684,7 +3684,6 @@ void lcd_confirm_print() } - static void lcd_main_menu() {