Skip to content

Commit 2dca6ef

Browse files
committed
Merge branch 'MK3' into MK3-private_build
Fixed merging
2 parents e3b4015 + 8375e2c commit 2dca6ef

18 files changed

+280
-135
lines changed

Firmware/Configuration.h

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#define STR(x) STR_HELPER(x)
88

99
// Firmware version
10-
#define FW_VERSION "3.1.1-RC5"
11-
#define FW_COMMIT_NR 151
10+
#define FW_VERSION "3.1.1"
11+
#define FW_COMMIT_NR 197
1212
// FW_VERSION_UNKNOWN means this is an unofficial build.
1313
// The firmware should only be checked into github with this symbol.
1414
#define FW_DEV_VERSION FW_VERSION_UNKNOWN
@@ -93,25 +93,28 @@
9393
#define EEPROM_UVLO_FAN_SPEED (EEPROM_UVLO_FEEDRATE - 1)
9494
#define EEPROM_FAN_CHECK_ENABLED (EEPROM_UVLO_FAN_SPEED - 1)
9595
#define EEPROM_UVLO_MESH_BED_LEVELING (EEPROM_FAN_CHECK_ENABLED - 9*2)
96+
9697
#define EEPROM_UVLO_Z_MICROSTEPS (EEPROM_UVLO_MESH_BED_LEVELING - 2)
9798
#define EEPROM_UVLO_E_ABS (EEPROM_UVLO_Z_MICROSTEPS - 1)
98-
#define EEPROM_UVLO_CURRENT_POSITION_E (EEPROM_UVLO_E_ABS - 4) //float for current position in E
99+
#define EEPROM_UVLO_CURRENT_POSITION_E (EEPROM_UVLO_E_ABS - 4) //float for current position in E
99100

100101
// Crash detection mode EEPROM setting
101-
#define EEPROM_CRASH_DET (EEPROM_UVLO_MESH_BED_LEVELING-12)
102+
#define EEPROM_CRASH_DET (EEPROM_UVLO_CURRENT_POSITION_E - 5) // float (orig EEPROM_UVLO_MESH_BED_LEVELING-12)
103+
// Crash detection counter Y (last print)
104+
#define EEPROM_CRASH_COUNT_Y (EEPROM_CRASH_DET - 1) // uint8 (orig EEPROM_UVLO_MESH_BED_LEVELING-15)
102105
// Filament sensor on/off EEPROM setting
103-
#define EEPROM_FSENSOR (EEPROM_UVLO_MESH_BED_LEVELING-14)
104-
// Crash detection counter
105-
#define EEPROM_CRASH_COUNT (EEPROM_UVLO_MESH_BED_LEVELING-15)
106-
// Filament runout/error coutner
107-
#define EEPROM_FERROR_COUNT (EEPROM_UVLO_MESH_BED_LEVELING-16)
108-
// Power loss errors
109-
#define EEPROM_POWER_COUNT (EEPROM_UVLO_MESH_BED_LEVELING-17)
110-
111-
#define EEPROM_XYZ_CAL_SKEW (EEPROM_POWER_COUNT - 4) //float for skew backup
106+
#define EEPROM_FSENSOR (EEPROM_CRASH_COUNT_Y - 1) // uint8 (orig EEPROM_UVLO_MESH_BED_LEVELING-14)
107+
// Crash detection counter X (last print)
108+
#define EEPROM_CRASH_COUNT_X (EEPROM_FSENSOR - 1) // uint8 (orig EEPROM_UVLO_MESH_BED_LEVELING-15)
109+
// Filament runout/error coutner (last print)
110+
#define EEPROM_FERROR_COUNT (EEPROM_CRASH_COUNT_X - 1) // uint8 (orig EEPROM_UVLO_MESH_BED_LEVELING-16)
111+
// Power loss errors (last print)
112+
#define EEPROM_POWER_COUNT (EEPROM_FERROR_COUNT - 1) // uint8 (orig EEPROM_UVLO_MESH_BED_LEVELING-17)
113+
114+
#define EEPROM_XYZ_CAL_SKEW (EEPROM_POWER_COUNT - 4) // float for skew backup
112115
#define EEPROM_WIZARD_ACTIVE (EEPROM_XYZ_CAL_SKEW - 1)
113-
#define EEPROM_BELTSTATUS_X (EEPROM_WIZARD_ACTIVE - 2) //uint16
114-
#define EEPROM_BELTSTATUS_Y (EEPROM_BELTSTATUS_X - 2) //uint16
116+
#define EEPROM_BELTSTATUS_X (EEPROM_WIZARD_ACTIVE - 2) // uint16
117+
#define EEPROM_BELTSTATUS_Y (EEPROM_BELTSTATUS_X - 2) // uint16
115118

116119
#define EEPROM_DIR_DEPTH (EEPROM_BELTSTATUS_Y-1)
117120
#define EEPROM_DIRS (EEPROM_DIR_DEPTH-80) //8 chars for each dir name, max 10 levels
@@ -126,6 +129,15 @@
126129
#define EEPROM_BED_CORRECTION_REAR_RIGHT (EEPROM_BED_CORRECTION_FRONT_RIGHT - 1)
127130
#define EEPROM_BED_CORRECTION_REAR_LEFT (EEPROM_BED_CORRECTION_REAR_RIGHT - 1)
128131
// End Hyperfine Bed Tuning
132+
// Crash detection counter X (total)
133+
#define EEPROM_CRASH_COUNT_X_TOT (EEPROM_FSENS_AUTOLOAD_ENABLED - 2) // uint16
134+
// Crash detection counter Y (total)
135+
#define EEPROM_CRASH_COUNT_Y_TOT (EEPROM_CRASH_COUNT_X_TOT - 2) // uint16
136+
// Filament runout/error coutner (total)
137+
#define EEPROM_FERROR_COUNT_TOT (EEPROM_CRASH_COUNT_Y_TOT - 2) // uint16
138+
// Power loss errors (total)
139+
#define EEPROM_POWER_COUNT_TOT (EEPROM_FERROR_COUNT_TOT - 2) // uint16
140+
129141

130142
//TMC2130 configuration
131143
#define EEPROM_TMC_AXIS_SIZE //axis configuration block size

Firmware/ConfigurationStore.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size)
4747
// wrong data being written to the variables.
4848
// ALSO: always make sure the variables in the Store and retrieve sections are in the same order.
4949

50-
#define EEPROM_VERSION "V1"
50+
#define EEPROM_VERSION "V2"
5151

5252
#ifdef EEPROM_SETTINGS
5353
void Config_StoreSettings(uint16_t offset, uint8_t level)
@@ -285,9 +285,10 @@ void Config_PrintSettings(uint8_t level)
285285

286286

287287
#ifdef EEPROM_SETTINGS
288-
void Config_RetrieveSettings(uint16_t offset, uint8_t level)
288+
bool Config_RetrieveSettings(uint16_t offset, uint8_t level)
289289
{
290290
int i=offset;
291+
bool previous_settings_retrieved = true;
291292
char stored_ver[4];
292293
char ver[4]=EEPROM_VERSION;
293294
EEPROM_READ_VAR(i,stored_ver); //read stored version
@@ -386,10 +387,18 @@ void Config_RetrieveSettings(uint16_t offset, uint8_t level)
386387
else
387388
{
388389
Config_ResetDefault();
390+
//Return false to inform user that eeprom version was changed and firmware is using default hardcoded settings now.
391+
//In case that storing to eeprom was not used yet, do not inform user that hardcoded settings are used.
392+
if (eeprom_read_byte((uint8_t *)offset) != 0xFF ||
393+
eeprom_read_byte((uint8_t *)offset + 1) != 0xFF ||
394+
eeprom_read_byte((uint8_t *)offset + 2) != 0xFF) {
395+
previous_settings_retrieved = false;
396+
}
389397
}
390398
#ifdef EEPROM_CHITCHAT
391399
Config_PrintSettings();
392400
#endif
401+
return previous_settings_retrieved;
393402
}
394403
#endif
395404

Firmware/ConfigurationStore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ FORCE_INLINE void Config_PrintSettings() {}
1414

1515
#ifdef EEPROM_SETTINGS
1616
void Config_StoreSettings(uint16_t offset, uint8_t level = 0);
17-
void Config_RetrieveSettings(uint16_t offset, uint8_t level = 0);
17+
bool Config_RetrieveSettings(uint16_t offset, uint8_t level = 0);
1818
#else
1919
FORCE_INLINE void Config_StoreSettings() {}
2020
FORCE_INLINE void Config_RetrieveSettings() { Config_ResetDefault(); Config_PrintSettings(); }

Firmware/Configuration_prusa.h

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
104104
#define MINTEMP_MINAMBIENT 25
105105
#define MINTEMP_MINAMBIENT_RAW 978
106106

107-
107+
//#define DEBUG_BUILD
108108
#ifdef DEBUG_BUILD
109109
//#define _NO_ASM
110110
#define DEBUG_DCODES //D codes
@@ -119,7 +119,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
119119
//#define DEBUG_DISABLE_YMAXLIMIT //y max limit ignored
120120
//#define DEBUG_DISABLE_ZMINLIMIT //z min limit ignored
121121
//#define DEBUG_DISABLE_ZMAXLIMIT //z max limit ignored
122-
//#define DEBUG_DISABLE_STARTMSGS //no startup messages
122+
#define DEBUG_DISABLE_STARTMSGS //no startup messages
123123
//#define DEBUG_DISABLE_MINTEMP //mintemp error ignored
124124
//#define DEBUG_DISABLE_SWLIMITS //sw limits ignored
125125
//#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
159159
#define TMC2130_PWM_AUTO_Y 1 // PWMCONF
160160
#define TMC2130_PWM_FREQ_Y 2 // PWMCONF
161161

162-
/* //not used
162+
#define TMC2130_PWM_GRAD_E 2 // PWMCONF
163+
#define TMC2130_PWM_AMPL_E 235 // PWMCONF
164+
#define TMC2130_PWM_AUTO_E 1 // PWMCONF
165+
#define TMC2130_PWM_FREQ_E 2 // PWMCONF
166+
163167
#define TMC2130_PWM_GRAD_Z 4 // PWMCONF
164168
#define TMC2130_PWM_AMPL_Z 200 // PWMCONF
165169
#define TMC2130_PWM_AUTO_Z 1 // PWMCONF
166170
#define TMC2130_PWM_FREQ_Z 2 // PWMCONF
171+
167172
#define TMC2130_PWM_GRAD_E 4 // PWMCONF
168-
#define TMC2130_PWM_AMPL_E 200 // PWMCONF
173+
#define TMC2130_PWM_AMPL_E 240 // PWMCONF
169174
#define TMC2130_PWM_AUTO_E 1 // PWMCONF
170175
#define TMC2130_PWM_FREQ_E 2 // PWMCONF
171-
*/
176+
177+
#define TMC2130_TOFF_XYZ 3 // CHOPCONF // fchop = 27.778kHz
178+
#define TMC2130_TOFF_E 3 // CHOPCONF // fchop = 27.778kHz
179+
//#define TMC2130_TOFF_E 4 // CHOPCONF // fchop = 21.429kHz
180+
//#define TMC2130_TOFF_E 5 // CHOPCONF // fchop = 17.442kHz
181+
182+
//#define TMC2130_STEALTH_E // Extruder stealthChop mode
183+
//#define TMC2130_CNSTOFF_E // Extruder constant-off-time mode (similar to MK2)
172184

173185
//#define TMC2130_PWM_DIV 683 // PWM frequency divider (1024, 683, 512, 410)
174186
#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
193205
//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)
194206
#define TMC2130_CURRENTS_H {13, 20, 25, 35} // default holding currents for all axes
195207
#define TMC2130_CURRENTS_R {13, 20, 25, 35} // default running currents for all axes
208+
#define TMC2130_UNLOAD_CURRENT_R 12 // lowe current for M600 to protect filament sensor
196209

197210
//#define TMC2130_DEBUG
198211
//#define TMC2130_DEBUG_WR

Firmware/Dcodes.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ void dcode_10()
449449
void dcode_12()
450450
{//Reset Filament error, Power loss and crash counter ( Do it before every print and you can get stats for the print )
451451
LOG("D12 - Reset failstat counters\n");
452-
eeprom_update_byte((uint8_t*)EEPROM_CRASH_COUNT, 0x00);
452+
eeprom_update_byte((uint8_t*)EEPROM_CRASH_COUNT_X, 0x00);
453453
eeprom_update_byte((uint8_t*)EEPROM_FERROR_COUNT, 0x00);
454454
eeprom_update_byte((uint8_t*)EEPROM_POWER_COUNT, 0x00);
455455
}
@@ -491,7 +491,8 @@ void dcode_9125()
491491
LOG("D9125 - PAT9125\n");
492492
if ((strchr_pointer[1+4] == '?') || (strchr_pointer[1+4] == 0))
493493
{
494-
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);
494+
// 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);
495+
printf("x=%d y=%d b=%d s=%d\n", pat9125_x, pat9125_y, pat9125_b, pat9125_s);
495496
return;
496497
}
497498
if (strchr_pointer[1+4] == '!')

0 commit comments

Comments
 (0)