saving/restoring filename and current position in bytes to eeprom, UVLO changed
This commit is contained in:
parent
29499510f4
commit
17074e1d25
|
|
@ -49,6 +49,8 @@
|
||||||
#define EEPROM_CALIBRATION_STATUS_PINDA (EEPROM_BOWDEN_LENGTH - 1) //0 - not calibrated; 1 - calibrated
|
#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 (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_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.
|
// Currently running firmware, each digit stored as uint16_t.
|
||||||
// The flavor differentiates a dev, alpha, beta, release candidate or a release version.
|
// The flavor differentiates a dev, alpha, beta, release candidate or a release version.
|
||||||
|
|
|
||||||
|
|
@ -356,4 +356,10 @@ void serialecho_temperatures();
|
||||||
void uvlo_();
|
void uvlo_();
|
||||||
void recover_print();
|
void recover_print();
|
||||||
void setup_uvlo_interrupt();
|
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))
|
#define UVLO !(PINE & (1<<4))
|
||||||
|
|
@ -6748,22 +6748,49 @@ void serialecho_temperatures() {
|
||||||
|
|
||||||
|
|
||||||
void uvlo_() {
|
void uvlo_() {
|
||||||
SERIAL_ECHOLNPGM("UVLO");
|
//SERIAL_ECHOLNPGM("UVLO");
|
||||||
eeprom_update_byte((uint8_t*)EEPROM_UVLO, 1);
|
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 + 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 + 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;
|
current_position[E_AXIS] -= DEFAULT_RETRACTION;
|
||||||
sei(); //enable stepper driver interrupt to move Z axis
|
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();
|
st_synchronize();
|
||||||
current_position[Z_AXIS] += UVLO_Z_AXIS_SHIFT;
|
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);
|
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 40, active_extruder);
|
||||||
st_synchronize();
|
st_synchronize();
|
||||||
|
eeprom_update_byte((uint8_t*)EEPROM_UVLO, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void recover_print() {
|
void recover_print() {
|
||||||
|
//char cmd1[30];
|
||||||
|
setTargetHotend0(210); //need to change to stored temperature
|
||||||
|
setTargetBed(55);
|
||||||
homeaxis(X_AXIS);
|
homeaxis(X_AXIS);
|
||||||
homeaxis(Y_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[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[Y_AXIS] = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 4));
|
||||||
/*SERIAL_ECHOPGM("Current position [X_AXIS]:");
|
/*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);
|
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 40, active_extruder);
|
||||||
st_synchronize();
|
st_synchronize();
|
||||||
current_position[E_AXIS] += DEFAULT_RETRACTION; //unretract
|
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();
|
st_synchronize();
|
||||||
|
|
||||||
|
restore_print_from_eeprom();
|
||||||
eeprom_update_byte((uint8_t*)EEPROM_UVLO, 0);
|
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() {
|
void setup_uvlo_interrupt() {
|
||||||
DDRE &= ~(1 << 4); //input pin
|
DDRE &= ~(1 << 4); //input pin
|
||||||
PORTE &= ~(1 << 4); //no internal pull-up
|
PORTE &= ~(1 << 4); //no internal pull-up
|
||||||
|
|
@ -6800,3 +6856,7 @@ ISR(INT4_vect) {
|
||||||
uvlo_();
|
uvlo_();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void save_print_to_eeprom() {
|
||||||
|
eeprom_update_dword((uint32_t*)(EEPROM_FILE_POSITION), card.get_sdpos());
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ public:
|
||||||
FORCE_INLINE void setIndex(long index) {sdpos = index;file.seekSet(index);};
|
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 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 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(); }
|
bool ToshibaFlashAir_isEnabled() const { return card.getFlashAirCompatible(); }
|
||||||
void ToshibaFlashAir_enable(bool enable) { card.setFlashAirCompatible(enable); }
|
void ToshibaFlashAir_enable(bool enable) { card.setFlashAirCompatible(enable); }
|
||||||
|
|
|
||||||
|
|
@ -399,9 +399,8 @@
|
||||||
|
|
||||||
#define BEEPER 84 // Beeper on AUX-4
|
#define BEEPER 84 // Beeper on AUX-4
|
||||||
#define LCD_PINS_RS 82
|
#define LCD_PINS_RS 82
|
||||||
|
#define LCD_PINS_ENABLE 18
|
||||||
#define LCD_PINS_ENABLE 61
|
#define LCD_PINS_D4 19
|
||||||
#define LCD_PINS_D4 59
|
|
||||||
#define LCD_PINS_D5 70
|
#define LCD_PINS_D5 70
|
||||||
#define LCD_PINS_D6 85
|
#define LCD_PINS_D6 85
|
||||||
#define LCD_PINS_D7 71
|
#define LCD_PINS_D7 71
|
||||||
|
|
@ -413,7 +412,7 @@
|
||||||
|
|
||||||
#define SDCARDDETECT 15
|
#define SDCARDDETECT 15
|
||||||
|
|
||||||
#define TACH_0 79
|
#define TACH_0 81
|
||||||
#define TACH_1 80
|
#define TACH_1 80
|
||||||
|
|
||||||
#endif //NEWPANEL
|
#endif //NEWPANEL
|
||||||
|
|
@ -504,12 +503,13 @@
|
||||||
|
|
||||||
#ifdef NEWPANEL
|
#ifdef NEWPANEL
|
||||||
|
|
||||||
|
|
||||||
#define BEEPER 84 // Beeper on AUX-4
|
#define BEEPER 84 // Beeper on AUX-4
|
||||||
#define LCD_PINS_RS 82
|
#define LCD_PINS_RS 82
|
||||||
//#define LCD_PINS_ENABLE 18
|
//#define LCD_PINS_ENABLE 18
|
||||||
//#define LCD_PINS_D4 19
|
//#define LCD_PINS_D4 19
|
||||||
#define LCD_PINS_ENABLE 61
|
#define LCD_PINS_ENABLE 61
|
||||||
#define LCD_PINS_D4 59
|
#define LCD_PINS_D4 59
|
||||||
#define LCD_PINS_D5 70
|
#define LCD_PINS_D5 70
|
||||||
#define LCD_PINS_D6 85
|
#define LCD_PINS_D6 85
|
||||||
#define LCD_PINS_D7 71
|
#define LCD_PINS_D7 71
|
||||||
|
|
@ -522,7 +522,7 @@
|
||||||
#define SDCARDDETECT 15
|
#define SDCARDDETECT 15
|
||||||
|
|
||||||
#define TACH_0 79
|
#define TACH_0 79
|
||||||
#define TACH_1 80
|
#define TACH_1 80
|
||||||
|
|
||||||
#endif //NEWPANEL
|
#endif //NEWPANEL
|
||||||
#endif //ULTRA_LCD
|
#endif //ULTRA_LCD
|
||||||
|
|
|
||||||
|
|
@ -3688,6 +3688,8 @@ static void lcd_main_menu()
|
||||||
|
|
||||||
|
|
||||||
MENU_ITEM(back, MSG_WATCH, lcd_status_screen);
|
MENU_ITEM(back, MSG_WATCH, lcd_status_screen);
|
||||||
|
|
||||||
|
MENU_ITEM(function, PSTR("restore_print"), restore_print_from_eeprom);
|
||||||
/* if (farm_mode && !IS_SD_PRINTING )
|
/* 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++)
|
for (c = &cmd[4]; *c; c++)
|
||||||
*c = tolower(*c);
|
*c = tolower(*c);
|
||||||
enquecommand(cmd);
|
enquecommand(cmd);
|
||||||
|
for (int i = 0; i < 8; i++) {
|
||||||
|
eeprom_write_byte((uint8_t*)EEPROM_FILENAME + i, filename[i]);
|
||||||
|
}
|
||||||
enquecommand_P(PSTR("M24"));
|
enquecommand_P(PSTR("M24"));
|
||||||
lcd_return_to_status();
|
lcd_return_to_status();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue