eeprom_init_default also returns the read/default value
This commit is contained in:
parent
b317786110
commit
8f4ac82273
|
|
@ -481,8 +481,8 @@ void PAT9125_sensor::filJam() {
|
||||||
jamDetection = false;
|
jamDetection = false;
|
||||||
stop_and_save_print_to_ram(0, 0);
|
stop_and_save_print_to_ram(0, 0);
|
||||||
restore_print_from_ram_and_continue(0);
|
restore_print_from_ram_and_continue(0);
|
||||||
eeprom_update_byte((uint8_t *)EEPROM_FERROR_COUNT, eeprom_read_byte((uint8_t *)EEPROM_FERROR_COUNT) + 1);
|
eeprom_increment_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);
|
eeprom_increment_word((uint16_t *)EEPROM_FERROR_COUNT_TOT);
|
||||||
enquecommand_front_P((PSTR("M600")));
|
enquecommand_front_P((PSTR("M600")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1045,9 +1045,7 @@ void setup()
|
||||||
lcd_splash();
|
lcd_splash();
|
||||||
Sound_Init(); // also guarantee "SET_OUTPUT(BEEPER)"
|
Sound_Init(); // also guarantee "SET_OUTPUT(BEEPER)"
|
||||||
|
|
||||||
selectedSerialPort = eeprom_read_byte((uint8_t *)EEPROM_SECOND_SERIAL_ACTIVE);
|
selectedSerialPort = eeprom_init_default_byte((uint8_t *)EEPROM_SECOND_SERIAL_ACTIVE, 0);
|
||||||
if (selectedSerialPort == 0xFF) selectedSerialPort = 0;
|
|
||||||
eeprom_update_byte((uint8_t *)EEPROM_SECOND_SERIAL_ACTIVE, selectedSerialPort);
|
|
||||||
MYSERIAL.begin(BAUDRATE);
|
MYSERIAL.begin(BAUDRATE);
|
||||||
fdev_setup_stream(uartout, uart_putchar, NULL, _FDEV_SETUP_WRITE); //setup uart out stream
|
fdev_setup_stream(uartout, uart_putchar, NULL, _FDEV_SETUP_WRITE); //setup uart out stream
|
||||||
stdout = uartout;
|
stdout = uartout;
|
||||||
|
|
@ -1253,22 +1251,11 @@ void setup()
|
||||||
plan_init(); // Initialize planner;
|
plan_init(); // Initialize planner;
|
||||||
|
|
||||||
factory_reset();
|
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
|
#ifdef TMC2130
|
||||||
uint8_t silentMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT);
|
uint8_t silentMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT);
|
||||||
|
|
@ -1550,22 +1537,15 @@ void setup()
|
||||||
update_current_firmware_version_to_eeprom();
|
update_current_firmware_version_to_eeprom();
|
||||||
|
|
||||||
#ifdef TMC2130
|
#ifdef TMC2130
|
||||||
tmc2130_home_origin[X_AXIS] = eeprom_read_byte((uint8_t*)EEPROM_TMC2130_HOME_X_ORIGIN);
|
tmc2130_home_origin[X_AXIS] = eeprom_init_default_byte((uint8_t*)EEPROM_TMC2130_HOME_X_ORIGIN, 0);
|
||||||
tmc2130_home_bsteps[X_AXIS] = eeprom_read_byte((uint8_t*)EEPROM_TMC2130_HOME_X_BSTEPS);
|
tmc2130_home_bsteps[X_AXIS] = eeprom_init_default_byte((uint8_t*)EEPROM_TMC2130_HOME_X_BSTEPS, 48);
|
||||||
tmc2130_home_fsteps[X_AXIS] = eeprom_read_byte((uint8_t*)EEPROM_TMC2130_HOME_X_FSTEPS);
|
tmc2130_home_fsteps[X_AXIS] = eeprom_init_default_byte((uint8_t*)EEPROM_TMC2130_HOME_X_FSTEPS, 48);
|
||||||
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_origin[Y_AXIS] = eeprom_init_default_byte((uint8_t*)EEPROM_TMC2130_HOME_Y_ORIGIN, 0);
|
||||||
tmc2130_home_bsteps[Y_AXIS] = eeprom_read_byte((uint8_t*)EEPROM_TMC2130_HOME_Y_BSTEPS);
|
tmc2130_home_bsteps[Y_AXIS] = eeprom_init_default_byte((uint8_t*)EEPROM_TMC2130_HOME_Y_BSTEPS, 48);
|
||||||
tmc2130_home_fsteps[Y_AXIS] = eeprom_read_byte((uint8_t*)EEPROM_TMC2130_HOME_Y_FSTEPS);
|
tmc2130_home_fsteps[Y_AXIS] = eeprom_init_default_byte((uint8_t*)EEPROM_TMC2130_HOME_Y_FSTEPS, 48);
|
||||||
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);
|
tmc2130_home_enabled = eeprom_init_default_byte((uint8_t*)EEPROM_TMC2130_HOME_ENABLED, 0);
|
||||||
if (tmc2130_home_enabled == 0xff) tmc2130_home_enabled = 0;
|
|
||||||
#endif //TMC2130
|
#endif //TMC2130
|
||||||
|
|
||||||
// report crash failures
|
// 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
|
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)
|
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, 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
|
|
||||||
|
|
||||||
eeprom_update_dword((uint32_t *)EEPROM_TOTALTIME, _previous_time + (_total_print_time/60)); //EEPROM_TOTALTIME 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));
|
eeprom_update_dword((uint32_t *)EEPROM_FILAMENTUSED, _previous_filament + (_total_filament_used / 1000));
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ void eeprom_init()
|
||||||
eeprom_init_default_word((uint16_t*)EEPROM_MMU_LOAD_FAIL_TOT, 0);
|
eeprom_init_default_word((uint16_t*)EEPROM_MMU_LOAD_FAIL_TOT, 0);
|
||||||
eeprom_init_default_byte((uint8_t*)EEPROM_MMU_FAIL, 0);
|
eeprom_init_default_byte((uint8_t*)EEPROM_MMU_FAIL, 0);
|
||||||
eeprom_init_default_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL, 0);
|
eeprom_init_default_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL, 0);
|
||||||
if (eeprom_read_dword((uint32_t*)EEPROM_TOTAL_TOOLCHANGE_COUNT) == 0xffffffff) eeprom_update_dword((uint32_t *)EEPROM_TOTAL_TOOLCHANGE_COUNT, 0);
|
eeprom_init_default_dword((uint32_t*)EEPROM_TOTAL_TOOLCHANGE_COUNT, 0);
|
||||||
if (eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)) == EEPROM_EMPTY_VALUE)
|
if (eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)) == EEPROM_EMPTY_VALUE)
|
||||||
{
|
{
|
||||||
eeprom_update_byte(&(EEPROM_Sheets_base->active_sheet), 0);
|
eeprom_update_byte(&(EEPROM_Sheets_base->active_sheet), 0);
|
||||||
|
|
@ -50,17 +50,12 @@ void eeprom_init()
|
||||||
check_babystep();
|
check_babystep();
|
||||||
|
|
||||||
#ifdef PINDA_TEMP_COMP
|
#ifdef PINDA_TEMP_COMP
|
||||||
if (eeprom_read_byte((uint8_t*)EEPROM_PINDA_TEMP_COMPENSATION) == 0xff) eeprom_update_byte((uint8_t *)EEPROM_PINDA_TEMP_COMPENSATION, 0);
|
eeprom_init_default_byte((uint8_t*)EEPROM_PINDA_TEMP_COMPENSATION, 0);
|
||||||
#endif //PINDA_TEMP_COMP
|
#endif //PINDA_TEMP_COMP
|
||||||
|
|
||||||
if (eeprom_read_dword((uint32_t*)EEPROM_JOB_ID) == EEPROM_EMPTY_VALUE32)
|
eeprom_init_default_dword((uint32_t*)EEPROM_JOB_ID, 0);
|
||||||
eeprom_update_dword((uint32_t*)EEPROM_JOB_ID, 0);
|
eeprom_init_default_dword((uint32_t*)EEPROM_TOTALTIME, 0);
|
||||||
|
eeprom_init_default_dword((uint32_t*)EEPROM_FILAMENTUSED, 0);
|
||||||
if (eeprom_read_dword((uint32_t *)EEPROM_TOTALTIME) == 0xffffffff) {
|
|
||||||
eeprom_update_dword((uint32_t *)EEPROM_TOTALTIME, 0);
|
|
||||||
eeprom_update_dword((uint32_t *)EEPROM_FILAMENTUSED, 0);
|
|
||||||
}
|
|
||||||
//Set Cutter OFF if 0xff
|
|
||||||
eeprom_init_default_byte((uint8_t*)EEPROM_MMU_CUTTER_ENABLED, 0);
|
eeprom_init_default_byte((uint8_t*)EEPROM_MMU_CUTTER_ENABLED, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -184,19 +179,31 @@ void __attribute__((noinline)) eeprom_add_dword(uint32_t *__p, uint32_t add) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void __attribute__((noinline)) eeprom_init_default_byte(uint8_t *__p, uint8_t def) {
|
uint8_t __attribute__((noinline)) eeprom_init_default_byte(uint8_t *__p, uint8_t def) {
|
||||||
if (eeprom_read_byte(__p) == EEPROM_EMPTY_VALUE)
|
uint8_t val = eeprom_read_byte(__p);
|
||||||
|
if (val == EEPROM_EMPTY_VALUE) {
|
||||||
eeprom_write_byte(__p, def);
|
eeprom_write_byte(__p, def);
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __attribute__((noinline)) eeprom_init_default_word(uint16_t *__p, uint16_t def) {
|
uint16_t __attribute__((noinline)) eeprom_init_default_word(uint16_t *__p, uint16_t def) {
|
||||||
if (eeprom_read_word(__p) == EEPROM_EMPTY_VALUE16)
|
uint16_t val = eeprom_read_word(__p);
|
||||||
|
if (val == EEPROM_EMPTY_VALUE16) {
|
||||||
eeprom_write_word(__p, def);
|
eeprom_write_word(__p, def);
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __attribute__((noinline)) eeprom_init_default_dword(uint32_t *__p, uint32_t def) {
|
uint32_t __attribute__((noinline)) eeprom_init_default_dword(uint32_t *__p, uint32_t def) {
|
||||||
if (eeprom_read_dword(__p) == EEPROM_EMPTY_VALUE32)
|
uint32_t val = eeprom_read_dword(__p);
|
||||||
|
if (val == EEPROM_EMPTY_VALUE32) {
|
||||||
eeprom_write_dword(__p, def);
|
eeprom_write_dword(__p, def);
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __attribute__((noinline)) eeprom_init_default_float(float *__p, float def) {
|
void __attribute__((noinline)) eeprom_init_default_float(float *__p, float def) {
|
||||||
|
|
|
||||||
|
|
@ -624,9 +624,9 @@ void eeprom_add_byte(uint8_t *__p, uint8_t add);
|
||||||
void eeprom_add_word(uint16_t *__p, uint16_t add);
|
void eeprom_add_word(uint16_t *__p, uint16_t add);
|
||||||
void eeprom_add_dword(uint32_t *__p, uint32_t add);
|
void eeprom_add_dword(uint32_t *__p, uint32_t add);
|
||||||
|
|
||||||
void eeprom_init_default_byte(uint8_t *__p, uint8_t def);
|
uint8_t eeprom_init_default_byte(uint8_t *__p, uint8_t def);
|
||||||
void eeprom_init_default_word(uint16_t *__p, uint16_t def);
|
uint16_t eeprom_init_default_word(uint16_t *__p, uint16_t def);
|
||||||
void eeprom_init_default_dword(uint32_t *__p, uint32_t def);
|
uint32_t eeprom_init_default_dword(uint32_t *__p, uint32_t def);
|
||||||
void eeprom_init_default_float(float *__p, float def);
|
void eeprom_init_default_float(float *__p, float def);
|
||||||
void eeprom_init_default_block(void *__p, size_t __n, const void *def);
|
void eeprom_init_default_block(void *__p, size_t __n, const void *def);
|
||||||
void eeprom_init_default_block_P(void *__p, size_t __n, const void *def);
|
void eeprom_init_default_block_P(void *__p, size_t __n, const void *def);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue