|
@@ -125,6 +125,8 @@
|
|
|
|
|
|
|
|
|
|
#include "ultralcd.h"
|
|
#include "ultralcd.h"
|
|
|
|
+//-//
|
|
|
|
+#include "sound.h"
|
|
|
|
|
|
#include "cmdqueue.h"
|
|
#include "cmdqueue.h"
|
|
|
|
|
|
@@ -1146,6 +1148,8 @@ void setup()
|
|
spi_init();
|
|
spi_init();
|
|
|
|
|
|
lcd_splash();
|
|
lcd_splash();
|
|
|
|
+//-//
|
|
|
|
+ Sound_Init();
|
|
|
|
|
|
#ifdef W25X20CL
|
|
#ifdef W25X20CL
|
|
if (!w25x20cl_init())
|
|
if (!w25x20cl_init())
|
|
@@ -1719,7 +1723,11 @@ void setup()
|
|
#endif //TMC2130
|
|
#endif //TMC2130
|
|
|
|
|
|
#ifdef UVLO_SUPPORT
|
|
#ifdef UVLO_SUPPORT
|
|
- if (eeprom_read_byte((uint8_t*)EEPROM_UVLO) == 1) { //previous print was terminated by UVLO
|
|
|
|
|
|
+//-//
|
|
|
|
+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 (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();
|
|
else {
|
|
else {
|
|
@@ -1745,7 +1753,8 @@ void setup()
|
|
#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));
|
|
@@ -4757,6 +4766,8 @@ 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();
|
|
@@ -6330,6 +6341,8 @@ 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;
|
|
while (!(wait_for_user_state == 0 && lcd_clicked())){
|
|
while (!(wait_for_user_state == 0 && lcd_clicked())){
|
|
|
|
|
|
//cnt++;
|
|
//cnt++;
|
|
@@ -6342,7 +6355,13 @@ Sigma_Exit:
|
|
}
|
|
}
|
|
SET_OUTPUT(BEEPER);
|
|
SET_OUTPUT(BEEPER);
|
|
if (counterBeep == 0) {
|
|
if (counterBeep == 0) {
|
|
|
|
+//-//
|
|
|
|
+//if(eSoundMode==e_SOUND_MODE_LOUD)
|
|
|
|
+if((eSoundMode==e_SOUND_MODE_LOUD)||((eSoundMode==e_SOUND_MODE_ONCE)&&bFirst))
|
|
|
|
+{
|
|
|
|
+bFirst=false;
|
|
WRITE(BEEPER, HIGH);
|
|
WRITE(BEEPER, HIGH);
|
|
|
|
+}
|
|
}
|
|
}
|
|
if (counterBeep == 20) {
|
|
if (counterBeep == 20) {
|
|
WRITE(BEEPER, LOW);
|
|
WRITE(BEEPER, LOW);
|
|
@@ -6945,7 +6964,11 @@ Sigma_Exit:
|
|
disable_e2();
|
|
disable_e2();
|
|
delay(100);
|
|
delay(100);
|
|
|
|
|
|
-
|
|
|
|
|
|
+//-//
|
|
|
|
+//if(eSoundMode==e_SOUND_MODE_LOUD)
|
|
|
|
+// Sound_MakeSound_tmp();
|
|
|
|
+Sound_MakeSound(e_SOUND_CLASS_Prompt,e_SOUND_TYPE_StandardPrompt);
|
|
|
|
+/*
|
|
WRITE(BEEPER, HIGH);
|
|
WRITE(BEEPER, HIGH);
|
|
uint8_t counterBeep = 0;
|
|
uint8_t counterBeep = 0;
|
|
while (!lcd_clicked() && (counterBeep < 50)) {
|
|
while (!lcd_clicked() && (counterBeep < 50)) {
|
|
@@ -6954,6 +6977,13 @@ Sigma_Exit:
|
|
counterBeep++;
|
|
counterBeep++;
|
|
}
|
|
}
|
|
WRITE(BEEPER, LOW);
|
|
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);
|
|
|
|
|
|
@@ -8326,6 +8356,8 @@ 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();
|
|
@@ -8482,6 +8514,51 @@ void uvlo_()
|
|
|
|
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+void uvlo_tiny()
|
|
|
|
+{
|
|
|
|
+uint16_t z_microsteps=0;
|
|
|
|
+bool sd_print=card.sdprinting;
|
|
|
|
+
|
|
|
|
+MYSERIAL.println(">>> uvloTiny()");
|
|
|
|
+// Conserve power as soon as possible.
|
|
|
|
+disable_x();
|
|
|
|
+disable_y();
|
|
|
|
+disable_e0();
|
|
|
|
+
|
|
|
|
+#ifdef TMC2130
|
|
|
|
+tmc2130_set_current_h(Z_AXIS, 20);
|
|
|
|
+tmc2130_set_current_r(Z_AXIS, 20);
|
|
|
|
+#endif //TMC2130
|
|
|
|
+
|
|
|
|
+// Read out the current Z motor microstep counter
|
|
|
|
+#ifdef TMC2130
|
|
|
|
+z_microsteps=tmc2130_rd_MSCNT(Z_TMC2130_CS);
|
|
|
|
+#endif //TMC2130
|
|
|
|
+
|
|
|
|
+planner_abort_hard();
|
|
|
|
+sei();
|
|
|
|
+plan_buffer_line(
|
|
|
|
+ current_position[X_AXIS],
|
|
|
|
+ current_position[Y_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],
|
|
|
|
+ 40, active_extruder);
|
|
|
|
+st_synchronize();
|
|
|
|
+disable_z();
|
|
|
|
+
|
|
|
|
+// Finaly store the "power outage" flag.
|
|
|
|
+//if(sd_print)
|
|
|
|
+ eeprom_update_byte((uint8_t*)EEPROM_UVLO,2);
|
|
|
|
+
|
|
|
|
+eeprom_update_word((uint16_t*)(EEPROM_UVLO_TINY_Z_MICROSTEPS),z_microsteps);
|
|
|
|
+eeprom_update_float((float*)(EEPROM_UVLO_TINY_CURRENT_POSITION_Z), current_position[Z_AXIS]);
|
|
|
|
+
|
|
|
|
+// Increment power failure counter
|
|
|
|
+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);
|
|
|
|
+}
|
|
#endif //UVLO_SUPPORT
|
|
#endif //UVLO_SUPPORT
|
|
|
|
|
|
#if (defined(FANCHECK) && defined(TACH_1) && (TACH_1 >-1))
|
|
#if (defined(FANCHECK) && defined(TACH_1) && (TACH_1 >-1))
|
|
@@ -8534,7 +8611,20 @@ 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) uvlo_();
|
|
|
|
|
|
+//-//
|
|
|
|
+// if (IS_SD_PRINTING) uvlo_();
|
|
|
|
+//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) {
|
|
@@ -8543,10 +8633,17 @@ 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
|
|
|
|
|
|
- recover_machine_state_after_power_panic(); //recover position, temperatures and extrude_multipliers
|
|
|
|
|
|
+//-//
|
|
|
|
+// recover_machine_state_after_power_panic(); //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 (current_position[Z_AXIS] < 25)
|
|
|
|
|
|
+//-//
|
|
|
|
+//if (current_position[Z_AXIS] < 25)
|
|
|
|
+if(!bTiny&&(current_position[Z_AXIS]<25))
|
|
enquecommand_P(PSTR("G1 Z25 F800"));
|
|
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"));
|
|
@@ -8564,7 +8661,10 @@ void recover_print(uint8_t automatic) {
|
|
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.
|
|
// Mark the power panic status as inactive.
|
|
- eeprom_update_byte((uint8_t*)EEPROM_UVLO, 0);
|
|
|
|
|
|
+//-//
|
|
|
|
+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
|
|
/*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);
|
|
delay_keep_alive(1000);
|
|
}*/
|
|
}*/
|
|
@@ -8577,7 +8677,7 @@ void recover_print(uint8_t automatic) {
|
|
printf_P(_N("Current pos Z_AXIS:%.3f\nCurrent pos E_AXIS:%.3f\n"), current_position[Z_AXIS], current_position[E_AXIS]);
|
|
printf_P(_N("Current pos Z_AXIS:%.3f\nCurrent pos E_AXIS:%.3f\n"), current_position[Z_AXIS], current_position[E_AXIS]);
|
|
}
|
|
}
|
|
|
|
|
|
-void recover_machine_state_after_power_panic()
|
|
|
|
|
|
+void recover_machine_state_after_power_panic(bool bTiny)
|
|
{
|
|
{
|
|
char cmd[30];
|
|
char cmd[30];
|
|
// 1) Recover the logical cordinates at the time of the power panic.
|
|
// 1) Recover the logical cordinates at the time of the power panic.
|
|
@@ -8586,8 +8686,16 @@ void recover_machine_state_after_power_panic()
|
|
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)) +
|
|
|
|
|
|
+//-//
|
|
|
|
+// 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)
|
|
|
|
+ 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];
|
|
|
|
+ else
|
|
|
|
+ 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"));
|
|
@@ -8720,6 +8828,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"));
|
|
// Start SD print.
|
|
// Start SD print.
|
|
enquecommand_P(PSTR("M24"));
|
|
enquecommand_P(PSTR("M24"));
|
|
}
|
|
}
|