PowerPanic IV
This commit is contained in:
parent
c7d7389e27
commit
5be82962ee
2 changed files with 36 additions and 103 deletions
|
@ -125,7 +125,6 @@
|
||||||
|
|
||||||
|
|
||||||
#include "ultralcd.h"
|
#include "ultralcd.h"
|
||||||
//-//
|
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
|
|
||||||
#include "cmdqueue.h"
|
#include "cmdqueue.h"
|
||||||
|
@ -1148,8 +1147,7 @@ void setup()
|
||||||
spi_init();
|
spi_init();
|
||||||
|
|
||||||
lcd_splash();
|
lcd_splash();
|
||||||
//-//
|
Sound_Init(); // also guarantee "SET_OUTPUT(BEEPER)"
|
||||||
Sound_Init();
|
|
||||||
|
|
||||||
#ifdef W25X20CL
|
#ifdef W25X20CL
|
||||||
if (!w25x20cl_init())
|
if (!w25x20cl_init())
|
||||||
|
@ -1723,10 +1721,6 @@ void setup()
|
||||||
#endif //TMC2130
|
#endif //TMC2130
|
||||||
|
|
||||||
#ifdef UVLO_SUPPORT
|
#ifdef UVLO_SUPPORT
|
||||||
//-//
|
|
||||||
MYSERIAL.println(">>> Setup");
|
|
||||||
MYSERIAL.println(eeprom_read_byte((uint8_t*)EEPROM_UVLO),DEC);
|
|
||||||
// if (eeprom_read_byte((uint8_t*)EEPROM_UVLO) == 1) { //previous print was terminated by UVLO
|
|
||||||
if (eeprom_read_byte((uint8_t*)EEPROM_UVLO) != 0) { //previous print was terminated by UVLO
|
if (eeprom_read_byte((uint8_t*)EEPROM_UVLO) != 0) { //previous print was terminated by UVLO
|
||||||
/*
|
/*
|
||||||
if (lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_RECOVER_PRINT), false)) recover_print();
|
if (lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_RECOVER_PRINT), false)) recover_print();
|
||||||
|
@ -1753,8 +1747,7 @@ MYSERIAL.println(eeprom_read_byte((uint8_t*)EEPROM_UVLO),DEC);
|
||||||
#endif
|
#endif
|
||||||
if ( lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_RECOVER_PRINT), false) ) recover_print(0);
|
if ( lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_RECOVER_PRINT), false) ) recover_print(0);
|
||||||
else {
|
else {
|
||||||
//-//
|
eeprom_update_byte((uint8_t*)EEPROM_UVLO, 0);
|
||||||
// eeprom_update_byte((uint8_t*)EEPROM_UVLO, 0);
|
|
||||||
lcd_update_enable(true);
|
lcd_update_enable(true);
|
||||||
lcd_update(2);
|
lcd_update(2);
|
||||||
lcd_setstatuspgm(_T(WELCOME_MSG));
|
lcd_setstatuspgm(_T(WELCOME_MSG));
|
||||||
|
@ -3355,6 +3348,10 @@ void process_commands()
|
||||||
else if (code_seen("thx")) {
|
else if (code_seen("thx")) {
|
||||||
no_response = false;
|
no_response = false;
|
||||||
}
|
}
|
||||||
|
else if (code_seen("uvlo")) {
|
||||||
|
eeprom_update_byte((uint8_t*)EEPROM_UVLO,0);
|
||||||
|
enquecommand_P(PSTR("M24"));
|
||||||
|
}
|
||||||
else if (code_seen("MMURES")) {
|
else if (code_seen("MMURES")) {
|
||||||
fprintf_P(uart2io, PSTR("X0"));
|
fprintf_P(uart2io, PSTR("X0"));
|
||||||
}
|
}
|
||||||
|
@ -4766,8 +4763,6 @@ void process_commands()
|
||||||
card.openFile(strchr_pointer + 4,true);
|
card.openFile(strchr_pointer + 4,true);
|
||||||
break;
|
break;
|
||||||
case 24: //M24 - Start SD print
|
case 24: //M24 - Start SD print
|
||||||
//-//
|
|
||||||
eeprom_update_byte((uint8_t*)EEPROM_UVLO,0);
|
|
||||||
if (!card.paused)
|
if (!card.paused)
|
||||||
failstats_reset_print();
|
failstats_reset_print();
|
||||||
card.startFileprint();
|
card.startFileprint();
|
||||||
|
@ -6341,8 +6336,7 @@ Sigma_Exit:
|
||||||
unsigned long waiting_start_time = millis();
|
unsigned long waiting_start_time = millis();
|
||||||
uint8_t wait_for_user_state = 0;
|
uint8_t wait_for_user_state = 0;
|
||||||
lcd_display_message_fullscreen_P(_T(MSG_PRESS_TO_UNLOAD));
|
lcd_display_message_fullscreen_P(_T(MSG_PRESS_TO_UNLOAD));
|
||||||
//-//
|
bool bFirst=true;
|
||||||
bool bFirst=true;
|
|
||||||
while (!(wait_for_user_state == 0 && lcd_clicked())){
|
while (!(wait_for_user_state == 0 && lcd_clicked())){
|
||||||
|
|
||||||
//cnt++;
|
//cnt++;
|
||||||
|
@ -6355,13 +6349,10 @@ bool bFirst=true;
|
||||||
}
|
}
|
||||||
SET_OUTPUT(BEEPER);
|
SET_OUTPUT(BEEPER);
|
||||||
if (counterBeep == 0) {
|
if (counterBeep == 0) {
|
||||||
//-//
|
if((eSoundMode==e_SOUND_MODE_LOUD)||((eSoundMode==e_SOUND_MODE_ONCE)&&bFirst)) {
|
||||||
//if(eSoundMode==e_SOUND_MODE_LOUD)
|
bFirst=false;
|
||||||
if((eSoundMode==e_SOUND_MODE_LOUD)||((eSoundMode==e_SOUND_MODE_ONCE)&&bFirst))
|
WRITE(BEEPER, HIGH);
|
||||||
{
|
}
|
||||||
bFirst=false;
|
|
||||||
WRITE(BEEPER, HIGH);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (counterBeep == 20) {
|
if (counterBeep == 20) {
|
||||||
WRITE(BEEPER, LOW);
|
WRITE(BEEPER, LOW);
|
||||||
|
@ -6964,26 +6955,12 @@ bFirst=false;
|
||||||
disable_e2();
|
disable_e2();
|
||||||
delay(100);
|
delay(100);
|
||||||
|
|
||||||
//-//
|
Sound_MakeSound(e_SOUND_CLASS_Prompt,e_SOUND_TYPE_StandardPrompt);
|
||||||
//if(eSoundMode==e_SOUND_MODE_LOUD)
|
uint8_t counterBeep = 0;
|
||||||
// Sound_MakeSound_tmp();
|
while (!lcd_clicked() && (counterBeep < 50)) {
|
||||||
Sound_MakeSound(e_SOUND_CLASS_Prompt,e_SOUND_TYPE_StandardPrompt);
|
delay_keep_alive(100);
|
||||||
/*
|
counterBeep++;
|
||||||
WRITE(BEEPER, HIGH);
|
}
|
||||||
uint8_t counterBeep = 0;
|
|
||||||
while (!lcd_clicked() && (counterBeep < 50)) {
|
|
||||||
if (counterBeep > 5) WRITE(BEEPER, LOW);
|
|
||||||
delay_keep_alive(100);
|
|
||||||
counterBeep++;
|
|
||||||
}
|
|
||||||
WRITE(BEEPER, LOW);
|
|
||||||
*/
|
|
||||||
uint8_t counterBeep = 0;
|
|
||||||
while (!lcd_clicked() && (counterBeep < 50)) {
|
|
||||||
delay_keep_alive(100);
|
|
||||||
counterBeep++;
|
|
||||||
}
|
|
||||||
//-//
|
|
||||||
st_synchronize();
|
st_synchronize();
|
||||||
while (lcd_clicked()) delay_keep_alive(100);
|
while (lcd_clicked()) delay_keep_alive(100);
|
||||||
|
|
||||||
|
@ -8356,8 +8333,6 @@ void uvlo_()
|
||||||
{
|
{
|
||||||
unsigned long time_start = millis();
|
unsigned long time_start = millis();
|
||||||
bool sd_print = card.sdprinting;
|
bool sd_print = card.sdprinting;
|
||||||
//-//
|
|
||||||
MYSERIAL.println(">>> uvlo()");
|
|
||||||
// Conserve power as soon as possible.
|
// Conserve power as soon as possible.
|
||||||
disable_x();
|
disable_x();
|
||||||
disable_y();
|
disable_y();
|
||||||
|
@ -8495,33 +8470,17 @@ MYSERIAL.println(">>> uvlo()");
|
||||||
st_synchronize();
|
st_synchronize();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
wdt_enable(WDTO_500MS);
|
||||||
cli();
|
WRITE(BEEPER,HIGH);
|
||||||
volatile unsigned int ppcount = 0;
|
while(1)
|
||||||
SET_OUTPUT(BEEPER);
|
;
|
||||||
WRITE(BEEPER, HIGH);
|
|
||||||
for(ppcount = 0; ppcount < 2000; ppcount ++){
|
|
||||||
asm("nop");//50ns on 20Mhz, 62.5ns on 16Mhz
|
|
||||||
}
|
|
||||||
WRITE(BEEPER, LOW);
|
|
||||||
while(1){
|
|
||||||
#if 1
|
|
||||||
WRITE(BEEPER, LOW);
|
|
||||||
for(ppcount = 0; ppcount < 8000; ppcount ++){
|
|
||||||
asm("nop");//50ns on 20Mhz, 62.5ns on 16Mhz
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void uvlo_tiny()
|
void uvlo_tiny()
|
||||||
{
|
{
|
||||||
uint16_t z_microsteps=0;
|
uint16_t z_microsteps=0;
|
||||||
bool sd_print=card.sdprinting;
|
|
||||||
|
|
||||||
MYSERIAL.println(">>> uvloTiny()");
|
|
||||||
// Conserve power as soon as possible.
|
// Conserve power as soon as possible.
|
||||||
disable_x();
|
disable_x();
|
||||||
disable_y();
|
disable_y();
|
||||||
|
@ -8542,6 +8501,7 @@ sei();
|
||||||
plan_buffer_line(
|
plan_buffer_line(
|
||||||
current_position[X_AXIS],
|
current_position[X_AXIS],
|
||||||
current_position[Y_AXIS],
|
current_position[Y_AXIS],
|
||||||
|
// current_position[Z_AXIS]+float((1024-z_microsteps+7)>>4)/axis_steps_per_unit[Z_AXIS],
|
||||||
current_position[Z_AXIS]+UVLO_Z_AXIS_SHIFT+float((1024-z_microsteps+7)>>4)/axis_steps_per_unit[Z_AXIS],
|
current_position[Z_AXIS]+UVLO_Z_AXIS_SHIFT+float((1024-z_microsteps+7)>>4)/axis_steps_per_unit[Z_AXIS],
|
||||||
current_position[E_AXIS],
|
current_position[E_AXIS],
|
||||||
40, active_extruder);
|
40, active_extruder);
|
||||||
|
@ -8558,6 +8518,11 @@ eeprom_update_float((float*)(EEPROM_UVLO_TINY_CURRENT_POSITION_Z), current_posit
|
||||||
// Increment power failure counter
|
// Increment power failure counter
|
||||||
eeprom_update_byte((uint8_t*)EEPROM_POWER_COUNT, eeprom_read_byte((uint8_t*)EEPROM_POWER_COUNT) + 1);
|
eeprom_update_byte((uint8_t*)EEPROM_POWER_COUNT, eeprom_read_byte((uint8_t*)EEPROM_POWER_COUNT) + 1);
|
||||||
eeprom_update_word((uint16_t*)EEPROM_POWER_COUNT_TOT, eeprom_read_word((uint16_t*)EEPROM_POWER_COUNT_TOT) + 1);
|
eeprom_update_word((uint16_t*)EEPROM_POWER_COUNT_TOT, eeprom_read_word((uint16_t*)EEPROM_POWER_COUNT_TOT) + 1);
|
||||||
|
|
||||||
|
wdt_enable(WDTO_500MS);
|
||||||
|
WRITE(BEEPER,HIGH);
|
||||||
|
while(1)
|
||||||
|
;
|
||||||
}
|
}
|
||||||
#endif //UVLO_SUPPORT
|
#endif //UVLO_SUPPORT
|
||||||
|
|
||||||
|
@ -8611,20 +8576,8 @@ void setup_uvlo_interrupt() {
|
||||||
ISR(INT4_vect) {
|
ISR(INT4_vect) {
|
||||||
EIMSK &= ~(1 << 4); //disable INT4 interrupt to make sure that this code will be executed just once
|
EIMSK &= ~(1 << 4); //disable INT4 interrupt to make sure that this code will be executed just once
|
||||||
SERIAL_ECHOLNPGM("INT4");
|
SERIAL_ECHOLNPGM("INT4");
|
||||||
//-//
|
if(IS_SD_PRINTING && (!(eeprom_read_byte((uint8_t*)EEPROM_UVLO))) ) uvlo_();
|
||||||
// if (IS_SD_PRINTING) uvlo_();
|
if(eeprom_read_byte((uint8_t*)EEPROM_UVLO)) uvlo_tiny();
|
||||||
//if(IS_SD_PRINTING && (!(eeprom_read_byte((uint8_t*)EEPROM_UVLO))) ) uvlo_();
|
|
||||||
if(IS_SD_PRINTING && (!(eeprom_read_byte((uint8_t*)EEPROM_UVLO))) ) uvlo_();
|
|
||||||
if(eeprom_read_byte((uint8_t*)EEPROM_UVLO)) uvlo_tiny();
|
|
||||||
/*
|
|
||||||
if(IS_SD_PRINTING)
|
|
||||||
{
|
|
||||||
MYSERIAL.println(">>> ");
|
|
||||||
if(!(eeprom_read_byte((uint8_t*)EEPROM_UVLO)))
|
|
||||||
uvlo_();
|
|
||||||
else uvlo_tiny();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void recover_print(uint8_t automatic) {
|
void recover_print(uint8_t automatic) {
|
||||||
|
@ -8633,18 +8586,12 @@ void recover_print(uint8_t automatic) {
|
||||||
lcd_update(2);
|
lcd_update(2);
|
||||||
lcd_setstatuspgm(_i("Recovering print "));////MSG_RECOVERING_PRINT c=20 r=1
|
lcd_setstatuspgm(_i("Recovering print "));////MSG_RECOVERING_PRINT c=20 r=1
|
||||||
|
|
||||||
//-//
|
bool bTiny=(eeprom_read_byte((uint8_t*)EEPROM_UVLO)==2);
|
||||||
// recover_machine_state_after_power_panic(); //recover position, temperatures and extrude_multipliers
|
recover_machine_state_after_power_panic(bTiny); //recover position, temperatures and extrude_multipliers
|
||||||
MYSERIAL.println(">>> RecoverPrint");
|
|
||||||
MYSERIAL.println(eeprom_read_byte((uint8_t*)EEPROM_UVLO),DEC);
|
|
||||||
bool bTiny=(eeprom_read_byte((uint8_t*)EEPROM_UVLO)==2);
|
|
||||||
recover_machine_state_after_power_panic(bTiny); //recover position, temperatures and extrude_multipliers
|
|
||||||
|
|
||||||
// Lift the print head, so one may remove the excess priming material.
|
// Lift the print head, so one may remove the excess priming material.
|
||||||
//-//
|
if(!bTiny&&(current_position[Z_AXIS]<25))
|
||||||
//if (current_position[Z_AXIS] < 25)
|
enquecommand_P(PSTR("G1 Z25 F800"));
|
||||||
if(!bTiny&&(current_position[Z_AXIS]<25))
|
|
||||||
enquecommand_P(PSTR("G1 Z25 F800"));
|
|
||||||
// Home X and Y axes. Homing just X and Y shall not touch the babystep and the world2machine transformation status.
|
// Home X and Y axes. Homing just X and Y shall not touch the babystep and the world2machine transformation status.
|
||||||
enquecommand_P(PSTR("G28 X Y"));
|
enquecommand_P(PSTR("G28 X Y"));
|
||||||
// Set the target bed and nozzle temperatures and wait.
|
// Set the target bed and nozzle temperatures and wait.
|
||||||
|
@ -8660,15 +8607,6 @@ if(!bTiny&&(current_position[Z_AXIS]<25))
|
||||||
}
|
}
|
||||||
enquecommand_P(PSTR("G1 E" STRINGIFY(-DEFAULT_RETRACTION)" F480"));
|
enquecommand_P(PSTR("G1 E" STRINGIFY(-DEFAULT_RETRACTION)" F480"));
|
||||||
|
|
||||||
// Mark the power panic status as inactive.
|
|
||||||
//-//
|
|
||||||
MYSERIAL.println("===== before");
|
|
||||||
// eeprom_update_byte((uint8_t*)EEPROM_UVLO, 0);
|
|
||||||
MYSERIAL.println("===== after");
|
|
||||||
/*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);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
printf_P(_N("After waiting for temp:\nCurrent pos X_AXIS:%.3f\nCurrent pos Y_AXIS:%.3f\n"), current_position[X_AXIS], current_position[Y_AXIS]);
|
printf_P(_N("After waiting for temp:\nCurrent pos X_AXIS:%.3f\nCurrent pos Y_AXIS:%.3f\n"), current_position[X_AXIS], current_position[Y_AXIS]);
|
||||||
|
|
||||||
// Restart the print.
|
// Restart the print.
|
||||||
|
@ -8686,16 +8624,12 @@ void recover_machine_state_after_power_panic(bool bTiny)
|
||||||
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));
|
||||||
// Recover the logical coordinate of the Z axis at the time of the power panic.
|
// Recover the logical coordinate of the Z axis at the time of the power panic.
|
||||||
// The current position after power panic is moved to the next closest 0th full step.
|
// The current position after power panic is moved to the next closest 0th full step.
|
||||||
//-//
|
|
||||||
// current_position[Z_AXIS] = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION_Z)) +
|
|
||||||
// UVLO_Z_AXIS_SHIFT + float((1024 - eeprom_read_word((uint16_t*)(EEPROM_UVLO_Z_MICROSTEPS)) + 7) >> 4) / axis_steps_per_unit[Z_AXIS];
|
|
||||||
if(bTiny)
|
if(bTiny)
|
||||||
current_position[Z_AXIS] = eeprom_read_float((float*)(EEPROM_UVLO_TINY_CURRENT_POSITION_Z)) +
|
current_position[Z_AXIS] = eeprom_read_float((float*)(EEPROM_UVLO_TINY_CURRENT_POSITION_Z)) +
|
||||||
UVLO_Z_AXIS_SHIFT + float((1024 - eeprom_read_word((uint16_t*)(EEPROM_UVLO_TINY_Z_MICROSTEPS)) + 7) >> 4) / axis_steps_per_unit[Z_AXIS];
|
UVLO_Z_AXIS_SHIFT + float((1024 - eeprom_read_word((uint16_t*)(EEPROM_UVLO_TINY_Z_MICROSTEPS)) + 7) >> 4) / axis_steps_per_unit[Z_AXIS];
|
||||||
else
|
else
|
||||||
current_position[Z_AXIS] = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION_Z)) +
|
current_position[Z_AXIS] = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION_Z)) +
|
||||||
UVLO_Z_AXIS_SHIFT + float((1024 - eeprom_read_word((uint16_t*)(EEPROM_UVLO_Z_MICROSTEPS)) + 7) >> 4) / axis_steps_per_unit[Z_AXIS];
|
UVLO_Z_AXIS_SHIFT + float((1024 - eeprom_read_word((uint16_t*)(EEPROM_UVLO_Z_MICROSTEPS)) + 7) >> 4) / axis_steps_per_unit[Z_AXIS];
|
||||||
//-//
|
|
||||||
if (eeprom_read_byte((uint8_t*)EEPROM_UVLO_E_ABS)) {
|
if (eeprom_read_byte((uint8_t*)EEPROM_UVLO_E_ABS)) {
|
||||||
current_position[E_AXIS] = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION_E));
|
current_position[E_AXIS] = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION_E));
|
||||||
sprintf_P(cmd, PSTR("G92 E"));
|
sprintf_P(cmd, PSTR("G92 E"));
|
||||||
|
@ -8828,10 +8762,8 @@ void restore_print_from_eeprom() {
|
||||||
// Set a position in the file.
|
// Set a position in the file.
|
||||||
sprintf_P(cmd, PSTR("M26 S%lu"), position);
|
sprintf_P(cmd, PSTR("M26 S%lu"), position);
|
||||||
enquecommand(cmd);
|
enquecommand(cmd);
|
||||||
//-//
|
enquecommand_P(PSTR("G4 S0"));
|
||||||
enquecommand_P(PSTR("G4 S0"));
|
enquecommand_P(PSTR("PRUSA uvlo"));
|
||||||
// Start SD print.
|
|
||||||
enquecommand_P(PSTR("M24"));
|
|
||||||
}
|
}
|
||||||
#endif //UVLO_SUPPORT
|
#endif //UVLO_SUPPORT
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ static void Sound_DoSound_Prompt(void);
|
||||||
|
|
||||||
void Sound_Init(void)
|
void Sound_Init(void)
|
||||||
{
|
{
|
||||||
|
SET_OUTPUT(BEEPER);
|
||||||
eSoundMode=(eSOUND_MODE)eeprom_read_byte((uint8_t*)EEPROM_SOUND_MODE);
|
eSoundMode=(eSOUND_MODE)eeprom_read_byte((uint8_t*)EEPROM_SOUND_MODE);
|
||||||
if(eSoundMode==e_SOUND_MODE_NULL)
|
if(eSoundMode==e_SOUND_MODE_NULL)
|
||||||
Sound_Default(); // je potreba provest i ulozeni do EEPROM
|
Sound_Default(); // je potreba provest i ulozeni do EEPROM
|
||||||
|
|
Loading…
Reference in a new issue