Merge branch 'MK3' into MK3-private_build

Fixed merging
This commit is contained in:
3d-gussner 2018-02-03 07:37:14 +01:00
commit 2dca6efa94
18 changed files with 279 additions and 134 deletions

View File

@ -7,8 +7,8 @@
#define STR(x) STR_HELPER(x) #define STR(x) STR_HELPER(x)
// Firmware version // Firmware version
#define FW_VERSION "3.1.1-RC5" #define FW_VERSION "3.1.1"
#define FW_COMMIT_NR 151 #define FW_COMMIT_NR 197
// FW_VERSION_UNKNOWN means this is an unofficial build. // FW_VERSION_UNKNOWN means this is an unofficial build.
// The firmware should only be checked into github with this symbol. // The firmware should only be checked into github with this symbol.
#define FW_DEV_VERSION FW_VERSION_UNKNOWN #define FW_DEV_VERSION FW_VERSION_UNKNOWN
@ -93,25 +93,28 @@
#define EEPROM_UVLO_FAN_SPEED (EEPROM_UVLO_FEEDRATE - 1) #define EEPROM_UVLO_FAN_SPEED (EEPROM_UVLO_FEEDRATE - 1)
#define EEPROM_FAN_CHECK_ENABLED (EEPROM_UVLO_FAN_SPEED - 1) #define EEPROM_FAN_CHECK_ENABLED (EEPROM_UVLO_FAN_SPEED - 1)
#define EEPROM_UVLO_MESH_BED_LEVELING (EEPROM_FAN_CHECK_ENABLED - 9*2) #define EEPROM_UVLO_MESH_BED_LEVELING (EEPROM_FAN_CHECK_ENABLED - 9*2)
#define EEPROM_UVLO_Z_MICROSTEPS (EEPROM_UVLO_MESH_BED_LEVELING - 2) #define EEPROM_UVLO_Z_MICROSTEPS (EEPROM_UVLO_MESH_BED_LEVELING - 2)
#define EEPROM_UVLO_E_ABS (EEPROM_UVLO_Z_MICROSTEPS - 1) #define EEPROM_UVLO_E_ABS (EEPROM_UVLO_Z_MICROSTEPS - 1)
#define EEPROM_UVLO_CURRENT_POSITION_E (EEPROM_UVLO_E_ABS - 4) //float for current position in E #define EEPROM_UVLO_CURRENT_POSITION_E (EEPROM_UVLO_E_ABS - 4) //float for current position in E
// Crash detection mode EEPROM setting // Crash detection mode EEPROM setting
#define EEPROM_CRASH_DET (EEPROM_UVLO_MESH_BED_LEVELING-12) #define EEPROM_CRASH_DET (EEPROM_UVLO_CURRENT_POSITION_E - 5) // float (orig EEPROM_UVLO_MESH_BED_LEVELING-12)
// Crash detection counter Y (last print)
#define EEPROM_CRASH_COUNT_Y (EEPROM_CRASH_DET - 1) // uint8 (orig EEPROM_UVLO_MESH_BED_LEVELING-15)
// Filament sensor on/off EEPROM setting // Filament sensor on/off EEPROM setting
#define EEPROM_FSENSOR (EEPROM_UVLO_MESH_BED_LEVELING-14) #define EEPROM_FSENSOR (EEPROM_CRASH_COUNT_Y - 1) // uint8 (orig EEPROM_UVLO_MESH_BED_LEVELING-14)
// Crash detection counter // Crash detection counter X (last print)
#define EEPROM_CRASH_COUNT (EEPROM_UVLO_MESH_BED_LEVELING-15) #define EEPROM_CRASH_COUNT_X (EEPROM_FSENSOR - 1) // uint8 (orig EEPROM_UVLO_MESH_BED_LEVELING-15)
// Filament runout/error coutner // Filament runout/error coutner (last print)
#define EEPROM_FERROR_COUNT (EEPROM_UVLO_MESH_BED_LEVELING-16) #define EEPROM_FERROR_COUNT (EEPROM_CRASH_COUNT_X - 1) // uint8 (orig EEPROM_UVLO_MESH_BED_LEVELING-16)
// Power loss errors // Power loss errors (last print)
#define EEPROM_POWER_COUNT (EEPROM_UVLO_MESH_BED_LEVELING-17) #define EEPROM_POWER_COUNT (EEPROM_FERROR_COUNT - 1) // uint8 (orig EEPROM_UVLO_MESH_BED_LEVELING-17)
#define EEPROM_XYZ_CAL_SKEW (EEPROM_POWER_COUNT - 4) //float for skew backup #define EEPROM_XYZ_CAL_SKEW (EEPROM_POWER_COUNT - 4) // float for skew backup
#define EEPROM_WIZARD_ACTIVE (EEPROM_XYZ_CAL_SKEW - 1) #define EEPROM_WIZARD_ACTIVE (EEPROM_XYZ_CAL_SKEW - 1)
#define EEPROM_BELTSTATUS_X (EEPROM_WIZARD_ACTIVE - 2) //uint16 #define EEPROM_BELTSTATUS_X (EEPROM_WIZARD_ACTIVE - 2) // uint16
#define EEPROM_BELTSTATUS_Y (EEPROM_BELTSTATUS_X - 2) //uint16 #define EEPROM_BELTSTATUS_Y (EEPROM_BELTSTATUS_X - 2) // uint16
#define EEPROM_DIR_DEPTH (EEPROM_BELTSTATUS_Y-1) #define EEPROM_DIR_DEPTH (EEPROM_BELTSTATUS_Y-1)
#define EEPROM_DIRS (EEPROM_DIR_DEPTH-80) //8 chars for each dir name, max 10 levels #define EEPROM_DIRS (EEPROM_DIR_DEPTH-80) //8 chars for each dir name, max 10 levels
@ -126,6 +129,15 @@
#define EEPROM_BED_CORRECTION_REAR_RIGHT (EEPROM_BED_CORRECTION_FRONT_RIGHT - 1) #define EEPROM_BED_CORRECTION_REAR_RIGHT (EEPROM_BED_CORRECTION_FRONT_RIGHT - 1)
#define EEPROM_BED_CORRECTION_REAR_LEFT (EEPROM_BED_CORRECTION_REAR_RIGHT - 1) #define EEPROM_BED_CORRECTION_REAR_LEFT (EEPROM_BED_CORRECTION_REAR_RIGHT - 1)
// End Hyperfine Bed Tuning // End Hyperfine Bed Tuning
// Crash detection counter X (total)
#define EEPROM_CRASH_COUNT_X_TOT (EEPROM_FSENS_AUTOLOAD_ENABLED - 2) // uint16
// Crash detection counter Y (total)
#define EEPROM_CRASH_COUNT_Y_TOT (EEPROM_CRASH_COUNT_X_TOT - 2) // uint16
// Filament runout/error coutner (total)
#define EEPROM_FERROR_COUNT_TOT (EEPROM_CRASH_COUNT_Y_TOT - 2) // uint16
// Power loss errors (total)
#define EEPROM_POWER_COUNT_TOT (EEPROM_FERROR_COUNT_TOT - 2) // uint16
//TMC2130 configuration //TMC2130 configuration
#define EEPROM_TMC_AXIS_SIZE //axis configuration block size #define EEPROM_TMC_AXIS_SIZE //axis configuration block size

View File

@ -47,7 +47,7 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size)
// wrong data being written to the variables. // wrong data being written to the variables.
// ALSO: always make sure the variables in the Store and retrieve sections are in the same order. // ALSO: always make sure the variables in the Store and retrieve sections are in the same order.
#define EEPROM_VERSION "V1" #define EEPROM_VERSION "V2"
#ifdef EEPROM_SETTINGS #ifdef EEPROM_SETTINGS
void Config_StoreSettings(uint16_t offset, uint8_t level) void Config_StoreSettings(uint16_t offset, uint8_t level)
@ -285,9 +285,10 @@ void Config_PrintSettings(uint8_t level)
#ifdef EEPROM_SETTINGS #ifdef EEPROM_SETTINGS
void Config_RetrieveSettings(uint16_t offset, uint8_t level) bool Config_RetrieveSettings(uint16_t offset, uint8_t level)
{ {
int i=offset; int i=offset;
bool previous_settings_retrieved = true;
char stored_ver[4]; char stored_ver[4];
char ver[4]=EEPROM_VERSION; char ver[4]=EEPROM_VERSION;
EEPROM_READ_VAR(i,stored_ver); //read stored version EEPROM_READ_VAR(i,stored_ver); //read stored version
@ -386,10 +387,18 @@ void Config_RetrieveSettings(uint16_t offset, uint8_t level)
else else
{ {
Config_ResetDefault(); Config_ResetDefault();
//Return false to inform user that eeprom version was changed and firmware is using default hardcoded settings now.
//In case that storing to eeprom was not used yet, do not inform user that hardcoded settings are used.
if (eeprom_read_byte((uint8_t *)offset) != 0xFF ||
eeprom_read_byte((uint8_t *)offset + 1) != 0xFF ||
eeprom_read_byte((uint8_t *)offset + 2) != 0xFF) {
previous_settings_retrieved = false;
}
} }
#ifdef EEPROM_CHITCHAT #ifdef EEPROM_CHITCHAT
Config_PrintSettings(); Config_PrintSettings();
#endif #endif
return previous_settings_retrieved;
} }
#endif #endif

View File

@ -14,7 +14,7 @@ FORCE_INLINE void Config_PrintSettings() {}
#ifdef EEPROM_SETTINGS #ifdef EEPROM_SETTINGS
void Config_StoreSettings(uint16_t offset, uint8_t level = 0); void Config_StoreSettings(uint16_t offset, uint8_t level = 0);
void Config_RetrieveSettings(uint16_t offset, uint8_t level = 0); bool Config_RetrieveSettings(uint16_t offset, uint8_t level = 0);
#else #else
FORCE_INLINE void Config_StoreSettings() {} FORCE_INLINE void Config_StoreSettings() {}
FORCE_INLINE void Config_RetrieveSettings() { Config_ResetDefault(); Config_PrintSettings(); } FORCE_INLINE void Config_RetrieveSettings() { Config_ResetDefault(); Config_PrintSettings(); }

View File

@ -104,7 +104,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
#define MINTEMP_MINAMBIENT 25 #define MINTEMP_MINAMBIENT 25
#define MINTEMP_MINAMBIENT_RAW 978 #define MINTEMP_MINAMBIENT_RAW 978
//#define DEBUG_BUILD
#ifdef DEBUG_BUILD #ifdef DEBUG_BUILD
//#define _NO_ASM //#define _NO_ASM
#define DEBUG_DCODES //D codes #define DEBUG_DCODES //D codes
@ -119,7 +119,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
//#define DEBUG_DISABLE_YMAXLIMIT //y max limit ignored //#define DEBUG_DISABLE_YMAXLIMIT //y max limit ignored
//#define DEBUG_DISABLE_ZMINLIMIT //z min limit ignored //#define DEBUG_DISABLE_ZMINLIMIT //z min limit ignored
//#define DEBUG_DISABLE_ZMAXLIMIT //z max limit ignored //#define DEBUG_DISABLE_ZMAXLIMIT //z max limit ignored
//#define DEBUG_DISABLE_STARTMSGS //no startup messages #define DEBUG_DISABLE_STARTMSGS //no startup messages
//#define DEBUG_DISABLE_MINTEMP //mintemp error ignored //#define DEBUG_DISABLE_MINTEMP //mintemp error ignored
//#define DEBUG_DISABLE_SWLIMITS //sw limits ignored //#define DEBUG_DISABLE_SWLIMITS //sw limits ignored
//#define DEBUG_DISABLE_LCD_STATUS_LINE //empty four lcd line //#define DEBUG_DISABLE_LCD_STATUS_LINE //empty four lcd line
@ -159,16 +159,28 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
#define TMC2130_PWM_AUTO_Y 1 // PWMCONF #define TMC2130_PWM_AUTO_Y 1 // PWMCONF
#define TMC2130_PWM_FREQ_Y 2 // PWMCONF #define TMC2130_PWM_FREQ_Y 2 // PWMCONF
/* //not used #define TMC2130_PWM_GRAD_E 2 // PWMCONF
#define TMC2130_PWM_AMPL_E 235 // PWMCONF
#define TMC2130_PWM_AUTO_E 1 // PWMCONF
#define TMC2130_PWM_FREQ_E 2 // PWMCONF
#define TMC2130_PWM_GRAD_Z 4 // PWMCONF #define TMC2130_PWM_GRAD_Z 4 // PWMCONF
#define TMC2130_PWM_AMPL_Z 200 // PWMCONF #define TMC2130_PWM_AMPL_Z 200 // PWMCONF
#define TMC2130_PWM_AUTO_Z 1 // PWMCONF #define TMC2130_PWM_AUTO_Z 1 // PWMCONF
#define TMC2130_PWM_FREQ_Z 2 // PWMCONF #define TMC2130_PWM_FREQ_Z 2 // PWMCONF
#define TMC2130_PWM_GRAD_E 4 // PWMCONF #define TMC2130_PWM_GRAD_E 4 // PWMCONF
#define TMC2130_PWM_AMPL_E 200 // PWMCONF #define TMC2130_PWM_AMPL_E 240 // PWMCONF
#define TMC2130_PWM_AUTO_E 1 // PWMCONF #define TMC2130_PWM_AUTO_E 1 // PWMCONF
#define TMC2130_PWM_FREQ_E 2 // PWMCONF #define TMC2130_PWM_FREQ_E 2 // PWMCONF
*/
#define TMC2130_TOFF_XYZ 3 // CHOPCONF // fchop = 27.778kHz
#define TMC2130_TOFF_E 3 // CHOPCONF // fchop = 27.778kHz
//#define TMC2130_TOFF_E 4 // CHOPCONF // fchop = 21.429kHz
//#define TMC2130_TOFF_E 5 // CHOPCONF // fchop = 17.442kHz
//#define TMC2130_STEALTH_E // Extruder stealthChop mode
//#define TMC2130_CNSTOFF_E // Extruder constant-off-time mode (similar to MK2)
//#define TMC2130_PWM_DIV 683 // PWM frequency divider (1024, 683, 512, 410) //#define TMC2130_PWM_DIV 683 // PWM frequency divider (1024, 683, 512, 410)
#define TMC2130_PWM_DIV 512 // PWM frequency divider (1024, 683, 512, 410) #define TMC2130_PWM_DIV 512 // PWM frequency divider (1024, 683, 512, 410)
@ -193,6 +205,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
//new settings is possible for vsense = 1, running current value > 31 set vsense to zero and shift both currents by 1 bit right (Z axis only) //new settings is possible for vsense = 1, running current value > 31 set vsense to zero and shift both currents by 1 bit right (Z axis only)
#define TMC2130_CURRENTS_H {13, 20, 25, 35} // default holding currents for all axes #define TMC2130_CURRENTS_H {13, 20, 25, 35} // default holding currents for all axes
#define TMC2130_CURRENTS_R {13, 20, 25, 35} // default running currents for all axes #define TMC2130_CURRENTS_R {13, 20, 25, 35} // default running currents for all axes
#define TMC2130_UNLOAD_CURRENT_R 12 // lowe current for M600 to protect filament sensor
//#define TMC2130_DEBUG //#define TMC2130_DEBUG
//#define TMC2130_DEBUG_WR //#define TMC2130_DEBUG_WR

View File

@ -449,7 +449,7 @@ void dcode_10()
void dcode_12() void dcode_12()
{//Reset Filament error, Power loss and crash counter ( Do it before every print and you can get stats for the print ) {//Reset Filament error, Power loss and crash counter ( Do it before every print and you can get stats for the print )
LOG("D12 - Reset failstat counters\n"); LOG("D12 - Reset failstat counters\n");
eeprom_update_byte((uint8_t*)EEPROM_CRASH_COUNT, 0x00); eeprom_update_byte((uint8_t*)EEPROM_CRASH_COUNT_X, 0x00);
eeprom_update_byte((uint8_t*)EEPROM_FERROR_COUNT, 0x00); eeprom_update_byte((uint8_t*)EEPROM_FERROR_COUNT, 0x00);
eeprom_update_byte((uint8_t*)EEPROM_POWER_COUNT, 0x00); eeprom_update_byte((uint8_t*)EEPROM_POWER_COUNT, 0x00);
} }
@ -491,7 +491,8 @@ void dcode_9125()
LOG("D9125 - PAT9125\n"); LOG("D9125 - PAT9125\n");
if ((strchr_pointer[1+4] == '?') || (strchr_pointer[1+4] == 0)) if ((strchr_pointer[1+4] == '?') || (strchr_pointer[1+4] == 0))
{ {
printf("res_x=%d res_y=%d x=%d y=%d b=%d s=%d\n", pat9125_xres, pat9125_yres, pat9125_x, pat9125_y, pat9125_b, pat9125_s); // printf("res_x=%d res_y=%d x=%d y=%d b=%d s=%d\n", pat9125_xres, pat9125_yres, pat9125_x, pat9125_y, pat9125_b, pat9125_s);
printf("x=%d y=%d b=%d s=%d\n", pat9125_x, pat9125_y, pat9125_b, pat9125_s);
return; return;
} }
if (strchr_pointer[1+4] == '!') if (strchr_pointer[1+4] == '!')

View File

@ -604,7 +604,7 @@ void crashdet_disable()
{ {
// MYSERIAL.println("crashdet_disable"); // MYSERIAL.println("crashdet_disable");
tmc2130_sg_stop_on_crash = false; tmc2130_sg_stop_on_crash = false;
tmc2130_sg_crash = false; tmc2130_sg_crash = 0;
eeprom_update_byte((uint8_t*)EEPROM_CRASH_DET, 0x00); eeprom_update_byte((uint8_t*)EEPROM_CRASH_DET, 0x00);
CrashDetectMenu = 0; CrashDetectMenu = 0;
} }
@ -633,7 +633,7 @@ void crashdet_stop_and_save_print2()
sei(); sei();
} }
void crashdet_detected() void crashdet_detected(uint8_t mask)
{ {
// printf("CRASH_DETECTED"); // printf("CRASH_DETECTED");
/* while (!is_buffer_empty()) /* while (!is_buffer_empty())
@ -646,11 +646,17 @@ void crashdet_detected()
lcd_update_enable(true); lcd_update_enable(true);
lcd_implementation_clear(); lcd_implementation_clear();
lcd_update(2); lcd_update(2);
// Increment crash counter if (mask & X_AXIS_MASK)
uint8_t crash_count = eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT); {
crash_count++; eeprom_update_byte((uint8_t*)EEPROM_CRASH_COUNT_X, eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_X) + 1);
eeprom_update_byte((uint8_t*)EEPROM_CRASH_COUNT, crash_count); eeprom_update_word((uint16_t*)EEPROM_CRASH_COUNT_X_TOT, eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_X_TOT) + 1);
}
if (mask & Y_AXIS_MASK)
{
eeprom_update_byte((uint8_t*)EEPROM_CRASH_COUNT_Y, eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_Y) + 1);
eeprom_update_word((uint16_t*)EEPROM_CRASH_COUNT_Y_TOT, eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_Y_TOT) + 1);
}
#ifdef AUTOMATIC_RECOVERY_AFTER_CRASH #ifdef AUTOMATIC_RECOVERY_AFTER_CRASH
bool yesno = true; bool yesno = true;
@ -684,6 +690,13 @@ void crashdet_cancel()
tmc2130_sg_stop_on_crash = true; tmc2130_sg_stop_on_crash = true;
} }
void failstats_reset_print()
{
eeprom_update_byte((uint8_t *)EEPROM_CRASH_COUNT_X, 0);
eeprom_update_byte((uint8_t *)EEPROM_CRASH_COUNT_Y, 0);
eeprom_update_byte((uint8_t *)EEPROM_FERROR_COUNT, 0);
eeprom_update_byte((uint8_t *)EEPROM_POWER_COUNT, 0);
}
#ifdef MESH_BED_LEVELING #ifdef MESH_BED_LEVELING
@ -719,10 +732,16 @@ void factory_reset(char level, bool quiet)
eeprom_update_dword((uint32_t *)EEPROM_TOTALTIME, 0); eeprom_update_dword((uint32_t *)EEPROM_TOTALTIME, 0);
eeprom_update_dword((uint32_t *)EEPROM_FILAMENTUSED, 0); eeprom_update_dword((uint32_t *)EEPROM_FILAMENTUSED, 0);
eeprom_update_byte((uint8_t *)EEPROM_POWER_COUNT, 0); eeprom_update_byte((uint8_t *)EEPROM_CRASH_COUNT_X, 0);
eeprom_update_byte((uint8_t *)EEPROM_CRASH_COUNT, 0); eeprom_update_byte((uint8_t *)EEPROM_CRASH_COUNT_Y, 0);
eeprom_update_byte((uint8_t *)EEPROM_FERROR_COUNT, 0); eeprom_update_byte((uint8_t *)EEPROM_FERROR_COUNT, 0);
eeprom_update_byte((uint8_t *)EEPROM_POWER_COUNT, 0);
eeprom_update_word((uint16_t *)EEPROM_CRASH_COUNT_X_TOT, 0);
eeprom_update_word((uint16_t *)EEPROM_CRASH_COUNT_Y_TOT, 0);
eeprom_update_word((uint16_t *)EEPROM_FERROR_COUNT_TOT, 0);
eeprom_update_word((uint16_t *)EEPROM_POWER_COUNT_TOT, 0);
lcd_menu_statistics(); lcd_menu_statistics();
break; break;
@ -991,7 +1010,7 @@ void setup()
SERIAL_ECHOLN((int)sizeof(block_t)*BLOCK_BUFFER_SIZE); SERIAL_ECHOLN((int)sizeof(block_t)*BLOCK_BUFFER_SIZE);
//lcd_update_enable(false); // why do we need this?? - andre //lcd_update_enable(false); // why do we need this?? - andre
// loads data from EEPROM if available else uses defaults (and resets step acceleration rate) // loads data from EEPROM if available else uses defaults (and resets step acceleration rate)
Config_RetrieveSettings(EEPROM_OFFSET); bool previous_settings_retrieved = Config_RetrieveSettings(EEPROM_OFFSET);
SdFatUtil::set_stack_guard(); //writes magic number at the end of static variables to protect against overwriting static memory by stack SdFatUtil::set_stack_guard(); //writes magic number at the end of static variables to protect against overwriting static memory by stack
tp_init(); // Initialize temperature loop tp_init(); // Initialize temperature loop
@ -1091,12 +1110,14 @@ void setup()
// Force SD card update. Otherwise the SD card update is done from loop() on card.checkautostart(false), // Force SD card update. Otherwise the SD card update is done from loop() on card.checkautostart(false),
// but this times out if a blocking dialog is shown in setup(). // but this times out if a blocking dialog is shown in setup().
card.initsd(); card.initsd();
if (eeprom_read_byte((uint8_t*)EEPROM_POWER_COUNT) == 0xff) if (eeprom_read_byte((uint8_t*)EEPROM_POWER_COUNT) == 0xff) eeprom_write_byte((uint8_t*)EEPROM_POWER_COUNT, 0);
eeprom_write_byte((uint8_t*)EEPROM_POWER_COUNT, 0); if (eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_X) == 0xff) eeprom_write_byte((uint8_t*)EEPROM_CRASH_COUNT_X, 0);
if (eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT) == 0xff) if (eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_Y) == 0xff) eeprom_write_byte((uint8_t*)EEPROM_CRASH_COUNT_Y, 0);
eeprom_write_byte((uint8_t*)EEPROM_CRASH_COUNT, 0); if (eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT) == 0xff) eeprom_write_byte((uint8_t*)EEPROM_FERROR_COUNT, 0);
if (eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT) == 0xff) if (eeprom_read_word((uint16_t*)EEPROM_POWER_COUNT_TOT) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_POWER_COUNT_TOT, 0);
eeprom_write_byte((uint8_t*)EEPROM_FERROR_COUNT, 0); if (eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_X_TOT) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_CRASH_COUNT_X_TOT, 0);
if (eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_Y_TOT) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_CRASH_COUNT_Y_TOT, 0);
if (eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_FERROR_COUNT_TOT, 0);
#ifdef SNMM #ifdef SNMM
if (eeprom_read_dword((uint32_t*)EEPROM_BOWDEN_LENGTH) == 0x0ffffffff) { //bowden length used for SNMM if (eeprom_read_dword((uint32_t*)EEPROM_BOWDEN_LENGTH) == 0x0ffffffff) { //bowden length used for SNMM
int _z = BOWDEN_LENGTH; int _z = BOWDEN_LENGTH;
@ -1151,6 +1172,8 @@ void setup()
show_fw_version_warnings(); show_fw_version_warnings();
if (!previous_settings_retrieved) lcd_show_fullscreen_message_and_wait_P(MSG_DEFAULT_SETTINGS_LOADED); //if EEPROM version was changed, inform user that default setting were loaded
if (eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE) == 1) { if (eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE) == 1) {
lcd_wizard(0); lcd_wizard(0);
} }
@ -1473,9 +1496,15 @@ void loop()
tmc2130_check_overtemp(); tmc2130_check_overtemp();
if (tmc2130_sg_crash) if (tmc2130_sg_crash)
{ {
tmc2130_sg_crash = false; uint8_t crash = tmc2130_sg_crash;
tmc2130_sg_crash = 0;
// crashdet_stop_and_save_print(); // crashdet_stop_and_save_print();
enquecommand_P((PSTR("CRASH_DETECTED"))); switch (crash)
{
case 1: enquecommand_P((PSTR("CRASH_DETECTEDX"))); break;
case 2: enquecommand_P((PSTR("CRASH_DETECTEDY"))); break;
case 3: enquecommand_P((PSTR("CRASH_DETECTEDXY"))); break;
}
} }
#endif //TMC2130 #endif //TMC2130
@ -2276,7 +2305,12 @@ void process_commands()
} }
else if(code_seen("CRASH_DETECTED")) else if(code_seen("CRASH_DETECTED"))
crashdet_detected(); {
uint8_t mask = 0;
if (code_seen("X")) mask |= X_AXIS_MASK;
if (code_seen("Y")) mask |= Y_AXIS_MASK;
crashdet_detected(mask);
}
else if(code_seen("CRASH_RECOVER")) else if(code_seen("CRASH_RECOVER"))
crashdet_recover(); crashdet_recover();
else if(code_seen("CRASH_CANCEL")) else if(code_seen("CRASH_CANCEL"))
@ -3109,6 +3143,9 @@ void process_commands()
#ifdef PINDA_THERMISTOR #ifdef PINDA_THERMISTOR
if (true) if (true)
{ {
lcd_show_fullscreen_message_and_wait_P(MSG_TEMP_CAL_WARNING);
bool result = lcd_show_fullscreen_message_yes_no_and_wait_P(MSG_STEEL_SHEET_CHECK, false, false);
if(result) lcd_show_fullscreen_message_and_wait_P(MSG_REMOVE_STEEL_SHEET);
if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS])) { if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS])) {
// We don't know where we are! HOME! // We don't know where we are! HOME!
// Push the commands to the front of the message queue in the reverse order! // Push the commands to the front of the message queue in the reverse order!
@ -3945,15 +3982,7 @@ void process_commands()
lcd_update(2); lcd_update(2);
break; break;
default: default:
printf("Unknown G code: "); printf_P(PSTR("Unknown G code: %s \n"), cmdbuffer + bufindr + CMDHDRSIZE);
printf(cmdbuffer + bufindr + CMDHDRSIZE);
printf("\n");
} }
} // end if(code_seen('G')) } // end if(code_seen('G'))
@ -3964,9 +3993,7 @@ void process_commands()
/*for (++strchr_pointer; *strchr_pointer == ' ' || *strchr_pointer == '\t'; ++strchr_pointer);*/ /*for (++strchr_pointer; *strchr_pointer == ' ' || *strchr_pointer == '\t'; ++strchr_pointer);*/
if (*(strchr_pointer+index) < '0' || *(strchr_pointer+index) > '9') { if (*(strchr_pointer+index) < '0' || *(strchr_pointer+index) > '9') {
printf("Invalid M code: "); printf_P(PSTR("Invalid M code: %s \n"), cmdbuffer + bufindr + CMDHDRSIZE);
printf(cmdbuffer + bufindr + CMDHDRSIZE);
printf("\n");
} else } else
switch((int)code_value()) switch((int)code_value())
@ -4061,6 +4088,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
if (!card.paused)
failstats_reset_print();
card.startFileprint(); card.startFileprint();
starttime=millis(); starttime=millis();
break; break;
@ -5804,6 +5833,10 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
//plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], 3500 / 60, active_extruder); //plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], 3500 / 60, active_extruder);
target[E_AXIS] -= FILAMENTCHANGE_FINALRETRACT; target[E_AXIS] -= FILAMENTCHANGE_FINALRETRACT;
st_synchronize();
uint8_t tmc2130_current_r_bckp = tmc2130_current_r[E_AXIS];
tmc2130_set_current_r(E_AXIS, TMC2130_UNLOAD_CURRENT_R);
target[E_AXIS] -= 45; target[E_AXIS] -= 45;
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], 5200 / 60, active_extruder); plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], 5200 / 60, active_extruder);
st_synchronize(); st_synchronize();
@ -5814,6 +5847,7 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], 1000 / 60, active_extruder); plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], 1000 / 60, active_extruder);
st_synchronize(); st_synchronize();
tmc2130_set_current_r(E_AXIS, tmc2130_current_r_bckp);
#endif // SNMM #endif // SNMM
@ -6221,7 +6255,7 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
lcd_setstatuspgm(MSG_UNLOADING_FILAMENT); lcd_setstatuspgm(MSG_UNLOADING_FILAMENT);
// extr_unload2(); // extr_unload2();
current_position[E_AXIS] -= 45; current_position[E_AXIS] -= 45;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 5200 / 60, active_extruder); plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 5200 / 60, active_extruder);
st_synchronize(); st_synchronize();
@ -6269,9 +6303,7 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
FlushSerialRequestResend(); FlushSerialRequestResend();
break; break;
default: default:
printf("Unknown M code: "); printf_P(PSTR("Unknown M code: %s \n"), cmdbuffer + bufindr + CMDHDRSIZE);
printf(cmdbuffer + bufindr + CMDHDRSIZE);
printf("\n");
} }
} // end if(code_seen('M')) (end of M codes) } // end if(code_seen('M')) (end of M codes)
@ -7634,9 +7666,8 @@ void uvlo_()
disable_z(); disable_z();
// Increment power failure counter // Increment power failure counter
uint8_t power_count = eeprom_read_byte((uint8_t*)EEPROM_POWER_COUNT); eeprom_update_byte((uint8_t*)EEPROM_POWER_COUNT, eeprom_read_byte((uint8_t*)EEPROM_POWER_COUNT) + 1);
power_count++; eeprom_update_word((uint16_t*)EEPROM_POWER_COUNT_TOT, eeprom_read_word((uint16_t*)EEPROM_POWER_COUNT_TOT) + 1);
eeprom_update_byte((uint8_t*)EEPROM_POWER_COUNT, power_count);
SERIAL_ECHOLNPGM("UVLO - end"); SERIAL_ECHOLNPGM("UVLO - end");
MYSERIAL.println(millis() - time_start); MYSERIAL.println(millis() - time_start);

View File

@ -25,6 +25,7 @@ CardReader::CardReader()
sdpos = 0; sdpos = 0;
sdprinting = false; sdprinting = false;
cardOK = false; cardOK = false;
paused = false;
saving = false; saving = false;
logging = false; logging = false;
autostart_atmillis=0; autostart_atmillis=0;
@ -240,6 +241,7 @@ void CardReader::startFileprint()
if(cardOK) if(cardOK)
{ {
sdprinting = true; sdprinting = true;
paused = false;
#ifdef SDCARD_SORT_ALPHA #ifdef SDCARD_SORT_ALPHA
//flush_presort(); //flush_presort();
#endif #endif
@ -251,6 +253,7 @@ void CardReader::pauseSDPrint()
if(sdprinting) if(sdprinting)
{ {
sdprinting = false; sdprinting = false;
paused = true;
} }
} }
@ -333,6 +336,7 @@ void CardReader::openFile(char* name,bool read, bool replace_current/*=true*/)
SERIAL_ECHOLN(name); SERIAL_ECHOLN(name);
} }
sdprinting = false; sdprinting = false;
paused = false;
SdFile myDir; SdFile myDir;

View File

@ -75,6 +75,7 @@ public:
bool logging; bool logging;
bool sdprinting ; bool sdprinting ;
bool cardOK ; bool cardOK ;
bool paused ;
char filename[13]; char filename[13];
uint16_t creationTime, creationDate; uint16_t creationTime, creationDate;
uint32_t cluster, position; uint32_t cluster, position;

View File

@ -4,8 +4,10 @@
#include "fsensor.h" #include "fsensor.h"
#include "pat9125.h" #include "pat9125.h"
#include "stepper.h"
#include "planner.h" #include "planner.h"
#include "fastio.h" #include "fastio.h"
#include "cmdqueue.h"
//#include "LiquidCrystal.h" //#include "LiquidCrystal.h"
//extern LiquidCrystal lcd; //extern LiquidCrystal lcd;
@ -257,18 +259,28 @@ void fsensor_update()
if (!fsensor_enabled) return; if (!fsensor_enabled) return;
if (fsensor_err_cnt > FSENSOR_ERR_MAX) if (fsensor_err_cnt > FSENSOR_ERR_MAX)
{ {
// MYSERIAL.println("fsensor_update (fsensor_err_cnt > FSENSOR_ERR_MAX)"); fsensor_stop_and_save_print();
/* if (fsensor_ignore_error)
fsensor_err_cnt = 0;
enquecommand_front_P((PSTR("G1 E-3 F200")));
process_commands();
cmdqueue_pop_front();
st_synchronize();
enquecommand_front_P((PSTR("G1 E3 F200")));
process_commands();
cmdqueue_pop_front();
st_synchronize();
if (fsensor_err_cnt == 0)
{ {
MYSERIAL.println("fsensor_update - error ignored)"); fsensor_restore_print_and_continue();
fsensor_ignore_error = false;
} }
else*/ else
{ {
fsensor_stop_and_save_print(); eeprom_update_byte((uint8_t*)EEPROM_FERROR_COUNT, eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT) + 1);
uint8_t ferror_count = eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT); eeprom_update_word((uint16_t*)EEPROM_FERROR_COUNT_TOT, eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT) + 1);
ferror_count++;
eeprom_update_byte((uint8_t*)EEPROM_FERROR_COUNT, ferror_count);
enquecommand_front_P((PSTR("M600"))); enquecommand_front_P((PSTR("M600")));
fsensor_M600 = true; fsensor_M600 = true;
fsensor_enabled = false; fsensor_enabled = false;

View File

@ -519,8 +519,10 @@ const char * const MSG_DATE_LANG_TABLE[LANG_NUM] PROGMEM = {
}; };
const char MSG_DEFAULT_SETTINGS_LOADED_EN[] PROGMEM = "Default settings loaded"; const char MSG_DEFAULT_SETTINGS_LOADED_EN[] PROGMEM = "Default settings loaded";
const char * const MSG_DEFAULT_SETTINGS_LOADED_LANG_TABLE[1] PROGMEM = { const char MSG_DEFAULT_SETTINGS_LOADED_CZ[] PROGMEM = "Nahrano vychozi nastaveni";
MSG_DEFAULT_SETTINGS_LOADED_EN const char * const MSG_DEFAULT_SETTINGS_LOADED_LANG_TABLE[LANG_NUM] PROGMEM = {
MSG_DEFAULT_SETTINGS_LOADED_EN,
MSG_DEFAULT_SETTINGS_LOADED_CZ
}; };
const char MSG_DISABLE_STEPPERS_EN[] PROGMEM = "Disable steppers"; const char MSG_DISABLE_STEPPERS_EN[] PROGMEM = "Disable steppers";
@ -2197,6 +2199,11 @@ const char * const MSG_TEMP_CALIBRATION_ON_LANG_TABLE[LANG_NUM] PROGMEM = {
MSG_TEMP_CALIBRATION_ON_CZ MSG_TEMP_CALIBRATION_ON_CZ
}; };
const char MSG_TEMP_CAL_WARNING_EN[] PROGMEM = "Stable ambient temperature 21-26C is needed a rigid stand is required.";
const char * const MSG_TEMP_CAL_WARNING_LANG_TABLE[1] PROGMEM = {
MSG_TEMP_CAL_WARNING_EN
};
const char MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_OFF_EN[] PROGMEM = "SD card [normal]"; const char MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_OFF_EN[] PROGMEM = "SD card [normal]";
const char * const MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_OFF_LANG_TABLE[1] PROGMEM = { const char * const MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_OFF_LANG_TABLE[1] PROGMEM = {
MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_OFF_EN MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_OFF_EN

View File

@ -184,8 +184,8 @@ extern const char* const MSG_CURRENT_LANG_TABLE[LANG_NUM];
#define MSG_CURRENT LANG_TABLE_SELECT(MSG_CURRENT_LANG_TABLE) #define MSG_CURRENT LANG_TABLE_SELECT(MSG_CURRENT_LANG_TABLE)
extern const char* const MSG_DATE_LANG_TABLE[LANG_NUM]; extern const char* const MSG_DATE_LANG_TABLE[LANG_NUM];
#define MSG_DATE LANG_TABLE_SELECT(MSG_DATE_LANG_TABLE) #define MSG_DATE LANG_TABLE_SELECT(MSG_DATE_LANG_TABLE)
extern const char* const MSG_DEFAULT_SETTINGS_LOADED_LANG_TABLE[1]; extern const char* const MSG_DEFAULT_SETTINGS_LOADED_LANG_TABLE[LANG_NUM];
#define MSG_DEFAULT_SETTINGS_LOADED LANG_TABLE_SELECT_EXPLICIT(MSG_DEFAULT_SETTINGS_LOADED_LANG_TABLE, 0) #define MSG_DEFAULT_SETTINGS_LOADED LANG_TABLE_SELECT(MSG_DEFAULT_SETTINGS_LOADED_LANG_TABLE)
extern const char* const MSG_DISABLE_STEPPERS_LANG_TABLE[LANG_NUM]; extern const char* const MSG_DISABLE_STEPPERS_LANG_TABLE[LANG_NUM];
#define MSG_DISABLE_STEPPERS LANG_TABLE_SELECT(MSG_DISABLE_STEPPERS_LANG_TABLE) #define MSG_DISABLE_STEPPERS LANG_TABLE_SELECT(MSG_DISABLE_STEPPERS_LANG_TABLE)
extern const char* const MSG_DWELL_LANG_TABLE[1]; extern const char* const MSG_DWELL_LANG_TABLE[1];
@ -724,6 +724,8 @@ extern const char* const MSG_TEMP_CALIBRATION_OFF_LANG_TABLE[LANG_NUM];
#define MSG_TEMP_CALIBRATION_OFF LANG_TABLE_SELECT(MSG_TEMP_CALIBRATION_OFF_LANG_TABLE) #define MSG_TEMP_CALIBRATION_OFF LANG_TABLE_SELECT(MSG_TEMP_CALIBRATION_OFF_LANG_TABLE)
extern const char* const MSG_TEMP_CALIBRATION_ON_LANG_TABLE[LANG_NUM]; extern const char* const MSG_TEMP_CALIBRATION_ON_LANG_TABLE[LANG_NUM];
#define MSG_TEMP_CALIBRATION_ON LANG_TABLE_SELECT(MSG_TEMP_CALIBRATION_ON_LANG_TABLE) #define MSG_TEMP_CALIBRATION_ON LANG_TABLE_SELECT(MSG_TEMP_CALIBRATION_ON_LANG_TABLE)
extern const char* const MSG_TEMP_CAL_WARNING_LANG_TABLE[1];
#define MSG_TEMP_CAL_WARNING LANG_TABLE_SELECT_EXPLICIT(MSG_TEMP_CAL_WARNING_LANG_TABLE, 0)
extern const char* const MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_OFF_LANG_TABLE[1]; extern const char* const MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_OFF_LANG_TABLE[1];
#define MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_OFF LANG_TABLE_SELECT_EXPLICIT(MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_OFF_LANG_TABLE, 0) #define MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_OFF LANG_TABLE_SELECT_EXPLICIT(MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_OFF_LANG_TABLE, 0)
extern const char* const MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_ON_LANG_TABLE[1]; extern const char* const MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_ON_LANG_TABLE[1];

View File

@ -375,6 +375,7 @@
#define MSG_CHECK_IDLER "Prosim otevrete idler a manualne odstrante filament." #define MSG_CHECK_IDLER "Prosim otevrete idler a manualne odstrante filament."
#define MSG_FILE_INCOMPLETE "Soubor nekompletni. Pokracovat?" #define MSG_FILE_INCOMPLETE "Soubor nekompletni. Pokracovat?"
#define MSG_FILE_CNT "Nektere soubory nebudou setrideny. Maximalni pocet souboru pro setrideni je 100." #define MSG_FILE_CNT "Nektere soubory nebudou setrideny. Maximalni pocet souboru pro setrideni je 100."
#define MSG_DEFAULT_SETTINGS_LOADED "Nahrano vychozi nastaveni"
#define MSG_SORT_TIME "Trideni [Cas]" #define MSG_SORT_TIME "Trideni [Cas]"
#define MSG_SORT_ALPHA "Trideni [Abeceda]" #define MSG_SORT_ALPHA "Trideni [Abeceda]"
#define MSG_SORT_NONE "Trideni [Zadne]" #define MSG_SORT_NONE "Trideni [Zadne]"

View File

@ -374,6 +374,7 @@
#define(length=20, lines=4) MSG_REMOVE_STEEL_SHEET "Please remove steel sheet from heatbed." #define(length=20, lines=4) MSG_REMOVE_STEEL_SHEET "Please remove steel sheet from heatbed."
#define(length=20, lines=2) MSG_CALIBRATE_Z_AUTO "Calibrating Z" #define(length=20, lines=2) MSG_CALIBRATE_Z_AUTO "Calibrating Z"
#define(length=20, lines=2) MSG_STEEL_SHEET_CHECK "Is steel sheet on heatbed?" #define(length=20, lines=2) MSG_STEEL_SHEET_CHECK "Is steel sheet on heatbed?"
#define(length=20, lines=4) MSG_TEMP_CAL_WARNING "Stable ambient temperature 21-26C is needed a rigid stand is required."
#define MSG_SELFTEST_AXIS "Axis" #define MSG_SELFTEST_AXIS "Axis"
#define MSG_SELFTEST_AXIS_LENGTH "Axis length" #define MSG_SELFTEST_AXIS_LENGTH "Axis length"

View File

@ -362,10 +362,10 @@ unsigned long watchmillis[EXTRUDERS] = ARRAY_BY_EXTRUDERS(0,0,0);
int p; int p;
if (extruder<0){ if (extruder<0){
p=soft_pwm_bed; p=soft_pwm_bed;
SERIAL_PROTOCOLPGM("ok B:"); SERIAL_PROTOCOLPGM("B:");
}else{ }else{
p=soft_pwm[extruder]; p=soft_pwm[extruder];
SERIAL_PROTOCOLPGM("ok T:"); SERIAL_PROTOCOLPGM("T:");
} }
SERIAL_PROTOCOL(input); SERIAL_PROTOCOL(input);
@ -500,12 +500,12 @@ void fanSpeedError(unsigned char _fan) {
} }
} }
else { else {
setTargetHotend0(0); setTargetHotend0(0);
SERIAL_ECHOLNPGM("// action:pause"); //for octoprint
} }
SERIAL_ERROR_START;
switch (_fan) { switch (_fan) {
case 0: case 0:
SERIAL_ERRORLNPGM("ERROR: Extruder fan speed is lower then expected"); SERIAL_ECHOLNPGM("Extruder fan speed is lower then expected");
if (get_message_level() == 0) { if (get_message_level() == 0) {
WRITE(BEEPER, HIGH); WRITE(BEEPER, HIGH);
delayMicroseconds(200); delayMicroseconds(200);
@ -515,7 +515,7 @@ void fanSpeedError(unsigned char _fan) {
} }
break; break;
case 1: case 1:
SERIAL_ERRORLNPGM("ERROR: Print fan speed is lower then expected"); SERIAL_ECHOLNPGM("Print fan speed is lower then expected");
if (get_message_level() == 0) { if (get_message_level() == 0) {
WRITE(BEEPER, HIGH); WRITE(BEEPER, HIGH);
delayMicroseconds(200); delayMicroseconds(200);

View File

@ -34,13 +34,13 @@ uint8_t tmc2130_current_r_home[4] = {10, 10, 20, 10};
//pwm_ampl //pwm_ampl
uint8_t tmc2130_pwm_ampl[2] = {TMC2130_PWM_AMPL_X, TMC2130_PWM_AMPL_Y}; uint8_t tmc2130_pwm_ampl[4] = {TMC2130_PWM_AMPL_X, TMC2130_PWM_AMPL_Y, TMC2130_PWM_AMPL_Z, TMC2130_PWM_AMPL_E};
//pwm_grad //pwm_grad
uint8_t tmc2130_pwm_grad[2] = {TMC2130_PWM_GRAD_X, TMC2130_PWM_GRAD_Y}; uint8_t tmc2130_pwm_grad[4] = {TMC2130_PWM_GRAD_X, TMC2130_PWM_GRAD_Y, TMC2130_PWM_GRAD_Z, TMC2130_PWM_GRAD_E};
//pwm_auto //pwm_auto
uint8_t tmc2130_pwm_auto[2] = {TMC2130_PWM_AUTO_X, TMC2130_PWM_AUTO_Y}; uint8_t tmc2130_pwm_auto[4] = {TMC2130_PWM_AUTO_X, TMC2130_PWM_AUTO_Y, TMC2130_PWM_AUTO_Z, TMC2130_PWM_AUTO_E};
//pwm_freq //pwm_freq
uint8_t tmc2130_pwm_freq[2] = {TMC2130_PWM_FREQ_X, TMC2130_PWM_FREQ_Y}; uint8_t tmc2130_pwm_freq[4] = {TMC2130_PWM_FREQ_X, TMC2130_PWM_FREQ_Y, TMC2130_PWM_FREQ_Z, TMC2130_PWM_FREQ_E};
uint8_t tmc2130_mres[4] = {0, 0, 0, 0}; //will be filed at begin of init uint8_t tmc2130_mres[4] = {0, 0, 0, 0}; //will be filed at begin of init
@ -58,7 +58,7 @@ uint32_t tmc2130_sg_meassure_val = 0;
bool tmc2130_sg_stop_on_crash = true; bool tmc2130_sg_stop_on_crash = true;
uint8_t tmc2130_sg_diag_mask = 0x00; uint8_t tmc2130_sg_diag_mask = 0x00;
bool tmc2130_sg_crash = false; uint8_t tmc2130_sg_crash = 0;
uint16_t tmc2130_sg_err[4] = {0, 0, 0, 0}; uint16_t tmc2130_sg_err[4] = {0, 0, 0, 0};
uint16_t tmc2130_sg_cnt[4] = {0, 0, 0, 0}; uint16_t tmc2130_sg_cnt[4] = {0, 0, 0, 0};
bool tmc2130_sg_change = false; bool tmc2130_sg_change = false;
@ -198,7 +198,15 @@ void tmc2130_init()
// tmc2130_wr(tmc2130_cs[axis], TMC2130_REG_IHOLD_IRUN, 0x000f0000 | ((tmc2130_current_r[axis] & 0x1f) << 8) | (tmc2130_current_h[axis] & 0x1f)); // tmc2130_wr(tmc2130_cs[axis], TMC2130_REG_IHOLD_IRUN, 0x000f0000 | ((tmc2130_current_r[axis] & 0x1f) << 8) | (tmc2130_current_h[axis] & 0x1f));
tmc2130_wr(tmc2130_cs[axis], TMC2130_REG_TPOWERDOWN, 0x00000000); tmc2130_wr(tmc2130_cs[axis], TMC2130_REG_TPOWERDOWN, 0x00000000);
#ifndef TMC2130_STEALTH_E
tmc2130_wr(tmc2130_cs[axis], TMC2130_REG_GCONF, TMC2130_GCONF_SGSENS); tmc2130_wr(tmc2130_cs[axis], TMC2130_REG_GCONF, TMC2130_GCONF_SGSENS);
#else //TMC2130_STEALTH_E
tmc2130_wr(tmc2130_cs[axis], TMC2130_REG_COOLCONF, (((uint32_t)tmc2130_sg_thr[axis]) << 16));
tmc2130_wr(tmc2130_cs[axis], TMC2130_REG_TCOOLTHRS, 0);
tmc2130_wr(tmc2130_cs[axis], TMC2130_REG_GCONF, TMC2130_GCONF_SILENT);
tmc2130_wr_PWMCONF(tmc2130_cs[axis], tmc2130_pwm_ampl[axis], tmc2130_pwm_grad[axis], tmc2130_pwm_freq[axis], tmc2130_pwm_auto[axis], 0, 0);
tmc2130_wr_TPWMTHRS(tmc2130_cs[axis], TMC2130_TPWMTHRS);
#endif //TMC2130_STEALTH_E
} }
tmc2130_sg_err[0] = 0; tmc2130_sg_err[0] = 0;
@ -226,7 +234,7 @@ extern bool is_usb_printing;
void tmc2130_st_isr(uint8_t last_step_mask) void tmc2130_st_isr(uint8_t last_step_mask)
{ {
if (tmc2130_mode == TMC2130_MODE_SILENT || tmc2130_sg_stop_on_crash == false) return; if (tmc2130_mode == TMC2130_MODE_SILENT || tmc2130_sg_stop_on_crash == false) return;
bool crash = false; uint8_t crash = 0;
uint8_t diag_mask = tmc2130_sample_diag(); uint8_t diag_mask = tmc2130_sample_diag();
// for (uint8_t axis = X_AXIS; axis <= E_AXIS; axis++) // for (uint8_t axis = X_AXIS; axis <= E_AXIS; axis++)
for (uint8_t axis = X_AXIS; axis <= Z_AXIS; axis++) for (uint8_t axis = X_AXIS; axis <= Z_AXIS; axis++)
@ -239,12 +247,12 @@ void tmc2130_st_isr(uint8_t last_step_mask)
{ {
tmc2130_sg_cnt[axis] = tmc2130_sg_err[axis]; tmc2130_sg_cnt[axis] = tmc2130_sg_err[axis];
tmc2130_sg_change = true; tmc2130_sg_change = true;
uint8_t sg_thr = 48; uint8_t sg_thr = 64;
if (axis == Y_AXIS) sg_thr = 64; // if (axis == Y_AXIS) sg_thr = 64;
if (tmc2130_sg_err[axis] >= sg_thr) if (tmc2130_sg_err[axis] >= sg_thr)
{ {
tmc2130_sg_err[axis] = 0; tmc2130_sg_err[axis] = 0;
crash = true; crash |= mask;
} }
} }
} }
@ -259,7 +267,7 @@ void tmc2130_st_isr(uint8_t last_step_mask)
}*/ }*/
if (/*!is_usb_printing && */tmc2130_sg_stop_on_crash && crash) if (/*!is_usb_printing && */tmc2130_sg_stop_on_crash && crash)
{ {
tmc2130_sg_crash = true; tmc2130_sg_crash = crash;
tmc2130_sg_stop_on_crash = false; tmc2130_sg_stop_on_crash = false;
crashdet_stop_and_save_print(); crashdet_stop_and_save_print();
} }
@ -414,14 +422,33 @@ void tmc2130_setup_chopper(uint8_t axis, uint8_t mres, uint8_t current_h, uint8_
{ {
uint8_t cs = tmc2130_cs[axis]; uint8_t cs = tmc2130_cs[axis];
uint8_t intpol = 1; uint8_t intpol = 1;
uint8_t toff = TMC2130_TOFF_XYZ; // toff = 3 (fchop = 27.778kHz)
uint8_t hstrt = 5; //initial 4, modified to 5
uint8_t hend = 1;
uint8_t fd3 = 0;
uint8_t rndtf = 0; //random off time
uint8_t chm = 0; //spreadCycle
uint8_t tbl = 2; //blanking time
if (axis == E_AXIS)
{
#ifdef TMC2130_CNSTOFF_E
// fd = 0 (slow decay only)
hstrt = 0; //fd0..2
fd3 = 0; //fd3
hend = 0; //sine wave offset
chm = 1; // constant off time mod
#endif //TMC2130_CNSTOFF_E
toff = TMC2130_TOFF_E; // toff = 3-5
// rndtf = 1;
}
if (current_r <= 31) if (current_r <= 31)
{ {
tmc2130_wr_CHOPCONF(cs, 3, 5, 1, 0, 0, 0, 0, 2, 1, 0, 0, 0, mres, intpol, 0, 0); tmc2130_wr_CHOPCONF(cs, toff, hstrt, hend, fd3, 0, rndtf, chm, tbl, 1, 0, 0, 0, mres, intpol, 0, 0);
tmc2130_wr(cs, TMC2130_REG_IHOLD_IRUN, 0x000f0000 | ((current_r & 0x1f) << 8) | (current_h & 0x1f)); tmc2130_wr(cs, TMC2130_REG_IHOLD_IRUN, 0x000f0000 | ((current_r & 0x1f) << 8) | (current_h & 0x1f));
} }
else else
{ {
tmc2130_wr_CHOPCONF(cs, 3, 5, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, mres, intpol, 0, 0); tmc2130_wr_CHOPCONF(cs, toff, hstrt, hend, fd3, 0, 0, 0, tbl, 0, 0, 0, 0, mres, intpol, 0, 0);
tmc2130_wr(cs, TMC2130_REG_IHOLD_IRUN, 0x000f0000 | (((current_r >> 1) & 0x1f) << 8) | ((current_h >> 1) & 0x1f)); tmc2130_wr(cs, TMC2130_REG_IHOLD_IRUN, 0x000f0000 | (((current_r >> 1) & 0x1f) << 8) | ((current_h >> 1) & 0x1f));
} }
} }

View File

@ -13,7 +13,7 @@ extern uint8_t tmc2130_current_r[4];
extern uint8_t tmc2130_sg_thr[4]; extern uint8_t tmc2130_sg_thr[4];
extern bool tmc2130_sg_stop_on_crash; extern bool tmc2130_sg_stop_on_crash;
extern bool tmc2130_sg_crash; extern uint8_t tmc2130_sg_crash; //crash mask
extern uint8_t tmc2130_sg_meassure; extern uint8_t tmc2130_sg_meassure;
extern uint16_t tmc2130_sg_meassure_cnt; extern uint16_t tmc2130_sg_meassure_cnt;

View File

@ -1539,45 +1539,58 @@ static void lcd_menu_extruder_info()
} }
} }
static void lcd_menu_fails_stats() static void lcd_menu_fails_stats_total()
{ {
//01234567890123456789
// Display screen info //Total failures
// Power failures 000
lcd.setCursor(0, 0); // Filam. runouts 000
lcd.print("Failure stats "); // Crash X 000 Y 000
//////////////////////
// Display power failures uint16_t power = eeprom_read_word((uint16_t*)EEPROM_POWER_COUNT_TOT);
uint8_t power_count = eeprom_read_byte((uint8_t*)EEPROM_POWER_COUNT); uint16_t filam = eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT);
lcd.setCursor(0, 1); uint16_t crashX = eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_X_TOT);
lcd.print(" Power failures: "); uint16_t crashY = eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_Y_TOT);
lcd.setCursor(17, 1); fprintf_P(lcdout, PSTR(ESC_H(0,0)"Total failures"ESC_H(1,1)"Power failures %-3d"ESC_H(1,2)"Filam. runouts %-3d"ESC_H(1,3)"Crash X %-3d Y %-3d"), power, filam, crashX, crashY);
lcd.print(itostr3((int)power_count));
// Display Crash detected
uint8_t crash_count = eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT);
lcd.setCursor(0, 2);
lcd.print(" Crash detected: ");
lcd.setCursor(17, 2);
lcd.print(itostr3((int)crash_count));
// Display filament failures
uint8_t ferror_count = eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT);
lcd.setCursor(0, 3);
lcd.print(" Filament fails: ");
lcd.setCursor(17, 3);
lcd.print(itostr3((int)ferror_count));
if (lcd_clicked()) if (lcd_clicked())
{ {
lcd_quick_feedback(); lcd_quick_feedback();
lcd_return_to_status(); //lcd_return_to_status();
lcd_goto_menu(lcd_menu_fails_stats, 4);
} }
} }
static void lcd_menu_fails_stats_print()
{
//01234567890123456789
//Last print failures
// Power failures 000
// Filam. runouts 000
// Crash X 000 Y 000
//////////////////////
uint8_t power = eeprom_read_byte((uint8_t*)EEPROM_POWER_COUNT);
uint8_t filam = eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT);
uint8_t crashX = eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_X);
uint8_t crashY = eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_Y);
fprintf_P(lcdout, PSTR(ESC_H(0,0)"Last print failures"ESC_H(1,1)"Power failures %-3d"ESC_H(1,2)"Filam. runouts %-3d"ESC_H(1,3)"Crash X %-3d Y %-3d"), power, filam, crashX, crashY);
if (lcd_clicked())
{
lcd_quick_feedback();
//lcd_return_to_status();
lcd_goto_menu(lcd_menu_fails_stats, 2);
}
}
static void lcd_menu_fails_stats()
{
START_MENU();
MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
MENU_ITEM(submenu, PSTR("Last print"), lcd_menu_fails_stats_print);
MENU_ITEM(submenu, PSTR("Total"), lcd_menu_fails_stats_total);
END_MENU();
}
#ifdef DEBUG_BUILD #ifdef DEBUG_BUILD
extern uint16_t SP_min; extern uint16_t SP_min;
extern char* __malloc_heap_start; extern char* __malloc_heap_start;
@ -3550,6 +3563,7 @@ void lcd_second_serial_set() {
if(selectedSerialPort == 1) selectedSerialPort = 0; if(selectedSerialPort == 1) selectedSerialPort = 0;
else selectedSerialPort = 1; else selectedSerialPort = 1;
eeprom_update_byte((unsigned char *)EEPROM_SECOND_SERIAL_ACTIVE, selectedSerialPort); eeprom_update_byte((unsigned char *)EEPROM_SECOND_SERIAL_ACTIVE, selectedSerialPort);
MYSERIAL.begin(BAUDRATE);
lcd_goto_menu(lcd_settings_menu, 11); lcd_goto_menu(lcd_settings_menu, 11);
} }

View File

@ -86,7 +86,7 @@ inline bool parse_version(const char *str, uint16_t version[4])
version[3] = FIRMWARE_REVISION_ALPHA; version[3] = FIRMWARE_REVISION_ALPHA;
else if (n == strlen_P(STR_REVISION_BETA) && strncmp_P(p, STR_REVISION_BETA, n) == 0) else if (n == strlen_P(STR_REVISION_BETA) && strncmp_P(p, STR_REVISION_BETA, n) == 0)
version[3] = FIRMWARE_REVISION_BETA; version[3] = FIRMWARE_REVISION_BETA;
else if ((n == 2 || n == 3) && p[0] == 'r' && p[1] == 'c') { else if ((n == 2 || n == 3) && (p[0] == 'r' || p[0] == 'R') && (p[1] == 'c' || p[1] == 'C')) {
if (n == 2) if (n == 2)
version[3] = FIRMWARE_REVISION_RC; version[3] = FIRMWARE_REVISION_RC;
else { else {
@ -116,12 +116,22 @@ inline bool parse_version(const char *str, uint16_t version[4])
inline bool strncmp_PP(const char *p1, const char *p2, uint8_t n) inline bool strncmp_PP(const char *p1, const char *p2, uint8_t n)
{ {
for (; n > 0; -- n, ++ p1, ++ p2) { for (; n > 0; -- n, ++ p1, ++ p2) {
if (pgm_read_byte(p1) < pgm_read_byte(p2)) if (pgm_read_byte(p1) >= 65 && pgm_read_byte(p1) <= 92) //p1 is upper case (p2 is always lowercase)
return -1; {
if (pgm_read_byte(p1) > pgm_read_byte(p2)) if ((pgm_read_byte(p1)+32) < pgm_read_byte(p2))
return 1; return -1;
if (pgm_read_byte(p1) == 0) if ((pgm_read_byte(p1)+32) > pgm_read_byte(p2))
return 0; return 1;
}
else if (pgm_read_byte(p1) == 0) {
return 0;
}
else { //p1 is lowercase
if (pgm_read_byte(p1) < pgm_read_byte(p2))
return -1;
if (pgm_read_byte(p1) > pgm_read_byte(p2))
return 1;
}
} }
return 0; return 0;
} }