|
@@ -1045,9 +1045,7 @@ void setup()
|
|
|
lcd_splash();
|
|
|
Sound_Init(); // also guarantee "SET_OUTPUT(BEEPER)"
|
|
|
|
|
|
- selectedSerialPort = eeprom_read_byte((uint8_t *)EEPROM_SECOND_SERIAL_ACTIVE);
|
|
|
- if (selectedSerialPort == 0xFF) selectedSerialPort = 0;
|
|
|
- eeprom_update_byte((uint8_t *)EEPROM_SECOND_SERIAL_ACTIVE, selectedSerialPort);
|
|
|
+ selectedSerialPort = eeprom_init_default_byte((uint8_t *)EEPROM_SECOND_SERIAL_ACTIVE, 0);
|
|
|
MYSERIAL.begin(BAUDRATE);
|
|
|
fdev_setup_stream(uartout, uart_putchar, NULL, _FDEV_SETUP_WRITE); //setup uart out stream
|
|
|
stdout = uartout;
|
|
@@ -1253,22 +1251,11 @@ void setup()
|
|
|
plan_init(); // Initialize planner;
|
|
|
|
|
|
factory_reset();
|
|
|
- if (eeprom_read_dword((uint32_t*)(EEPROM_TOP - 4)) == 0x0ffffffff &&
|
|
|
- eeprom_read_dword((uint32_t*)(EEPROM_TOP - 8)) == 0x0ffffffff)
|
|
|
- {
|
|
|
- // Maiden startup. The firmware has been loaded and first started on a virgin RAMBo board,
|
|
|
- // where all the EEPROM entries are set to 0x0ff.
|
|
|
- // Once a firmware boots up, it forces at least a language selection, which changes
|
|
|
- // EEPROM_LANG to number lower than 0x0ff.
|
|
|
- // 1) Set a high power mode.
|
|
|
- eeprom_update_byte((uint8_t*)EEPROM_SILENT, SILENT_MODE_OFF);
|
|
|
-#ifdef TMC2130
|
|
|
- tmc2130_mode = TMC2130_MODE_NORMAL;
|
|
|
-#endif //TMC2130
|
|
|
- eeprom_write_byte((uint8_t*)EEPROM_WIZARD_ACTIVE, 1); //run wizard
|
|
|
- }
|
|
|
|
|
|
- lcd_encoder_diff=0;
|
|
|
+ eeprom_init_default_byte((uint8_t*)EEPROM_SILENT, SILENT_MODE_OFF);
|
|
|
+ eeprom_init_default_byte((uint8_t*)EEPROM_WIZARD_ACTIVE, 1); //run wizard if uninitialized
|
|
|
+
|
|
|
+ lcd_encoder_diff=0;
|
|
|
|
|
|
#ifdef TMC2130
|
|
|
uint8_t silentMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT);
|
|
@@ -1550,22 +1537,15 @@ void setup()
|
|
|
update_current_firmware_version_to_eeprom();
|
|
|
|
|
|
#ifdef TMC2130
|
|
|
- tmc2130_home_origin[X_AXIS] = eeprom_read_byte((uint8_t*)EEPROM_TMC2130_HOME_X_ORIGIN);
|
|
|
- tmc2130_home_bsteps[X_AXIS] = eeprom_read_byte((uint8_t*)EEPROM_TMC2130_HOME_X_BSTEPS);
|
|
|
- tmc2130_home_fsteps[X_AXIS] = eeprom_read_byte((uint8_t*)EEPROM_TMC2130_HOME_X_FSTEPS);
|
|
|
- if (tmc2130_home_origin[X_AXIS] == 0xff) tmc2130_home_origin[X_AXIS] = 0;
|
|
|
- if (tmc2130_home_bsteps[X_AXIS] == 0xff) tmc2130_home_bsteps[X_AXIS] = 48;
|
|
|
- if (tmc2130_home_fsteps[X_AXIS] == 0xff) tmc2130_home_fsteps[X_AXIS] = 48;
|
|
|
-
|
|
|
- tmc2130_home_origin[Y_AXIS] = eeprom_read_byte((uint8_t*)EEPROM_TMC2130_HOME_Y_ORIGIN);
|
|
|
- tmc2130_home_bsteps[Y_AXIS] = eeprom_read_byte((uint8_t*)EEPROM_TMC2130_HOME_Y_BSTEPS);
|
|
|
- tmc2130_home_fsteps[Y_AXIS] = eeprom_read_byte((uint8_t*)EEPROM_TMC2130_HOME_Y_FSTEPS);
|
|
|
- if (tmc2130_home_origin[Y_AXIS] == 0xff) tmc2130_home_origin[Y_AXIS] = 0;
|
|
|
- if (tmc2130_home_bsteps[Y_AXIS] == 0xff) tmc2130_home_bsteps[Y_AXIS] = 48;
|
|
|
- if (tmc2130_home_fsteps[Y_AXIS] == 0xff) tmc2130_home_fsteps[Y_AXIS] = 48;
|
|
|
-
|
|
|
- tmc2130_home_enabled = eeprom_read_byte((uint8_t*)EEPROM_TMC2130_HOME_ENABLED);
|
|
|
- if (tmc2130_home_enabled == 0xff) tmc2130_home_enabled = 0;
|
|
|
+ tmc2130_home_origin[X_AXIS] = eeprom_init_default_byte((uint8_t*)EEPROM_TMC2130_HOME_X_ORIGIN, 0);
|
|
|
+ tmc2130_home_bsteps[X_AXIS] = eeprom_init_default_byte((uint8_t*)EEPROM_TMC2130_HOME_X_BSTEPS, 48);
|
|
|
+ tmc2130_home_fsteps[X_AXIS] = eeprom_init_default_byte((uint8_t*)EEPROM_TMC2130_HOME_X_FSTEPS, 48);
|
|
|
+
|
|
|
+ tmc2130_home_origin[Y_AXIS] = eeprom_init_default_byte((uint8_t*)EEPROM_TMC2130_HOME_Y_ORIGIN, 0);
|
|
|
+ tmc2130_home_bsteps[Y_AXIS] = eeprom_init_default_byte((uint8_t*)EEPROM_TMC2130_HOME_Y_BSTEPS, 48);
|
|
|
+ tmc2130_home_fsteps[Y_AXIS] = eeprom_init_default_byte((uint8_t*)EEPROM_TMC2130_HOME_Y_FSTEPS, 48);
|
|
|
+
|
|
|
+ tmc2130_home_enabled = eeprom_init_default_byte((uint8_t*)EEPROM_TMC2130_HOME_ENABLED, 0);
|
|
|
#endif //TMC2130
|
|
|
|
|
|
// report crash failures
|
|
@@ -9776,14 +9756,8 @@ bool setTargetedHotend(int code, uint8_t &extruder)
|
|
|
|
|
|
void save_statistics(unsigned long _total_filament_used, unsigned long _total_print_time) //_total_filament_used unit: mm/100; print time in s
|
|
|
{
|
|
|
- if (eeprom_read_byte((uint8_t *)EEPROM_TOTALTIME) == 255 && eeprom_read_byte((uint8_t *)EEPROM_TOTALTIME + 1) == 255 && eeprom_read_byte((uint8_t *)EEPROM_TOTALTIME + 2) == 255 && eeprom_read_byte((uint8_t *)EEPROM_TOTALTIME + 3) == 255)
|
|
|
- {
|
|
|
- eeprom_update_dword((uint32_t *)EEPROM_TOTALTIME, 0);
|
|
|
- eeprom_update_dword((uint32_t *)EEPROM_FILAMENTUSED, 0);
|
|
|
- }
|
|
|
-
|
|
|
- unsigned long _previous_filament = eeprom_read_dword((uint32_t *)EEPROM_FILAMENTUSED); //_previous_filament unit: cm
|
|
|
- unsigned long _previous_time = eeprom_read_dword((uint32_t *)EEPROM_TOTALTIME); //_previous_time unit: min
|
|
|
+ unsigned long _previous_filament = eeprom_init_default_dword((uint32_t *)EEPROM_FILAMENTUSED, 0); //_previous_filament unit: cm
|
|
|
+ unsigned long _previous_time = eeprom_init_default_dword((uint32_t *)EEPROM_TOTALTIME, 0); //_previous_time unit: min
|
|
|
|
|
|
eeprom_update_dword((uint32_t *)EEPROM_TOTALTIME, _previous_time + (_total_print_time/60)); //EEPROM_TOTALTIME unit: min
|
|
|
eeprom_update_dword((uint32_t *)EEPROM_FILAMENTUSED, _previous_filament + (_total_filament_used / 1000));
|