More optimization

This commit is contained in:
Alex Voinea 2022-11-17 13:36:00 +01:00 committed by DRracer
parent 8f4ac82273
commit ef83fefce1
6 changed files with 10 additions and 29 deletions

View File

@ -390,12 +390,8 @@ void prusa_statistics_update_from_lcd_update() {
}
void farm_mode_init() {
farm_mode = eeprom_read_byte((uint8_t*)EEPROM_FARM_MODE);
if (farm_mode == 0xFF) {
farm_mode = false; //if farm_mode has not been stored to eeprom yet and farm number is set to zero or EEPROM is fresh, deactivate farm mode
eeprom_update_byte((uint8_t*)EEPROM_FARM_MODE, farm_mode);
}
else if (farm_mode) {
farm_mode = eeprom_init_default_byte((uint8_t*)EEPROM_FARM_MODE, 0);
if (farm_mode) {
no_response = true; //we need confirmation by recieving PRUSA thx
prusa_statistics(8);
#ifdef HAS_SECOND_SERIAL_PORT

View File

@ -153,6 +153,10 @@ void eeprom_update_block_P(const void *__src, void *__dst, size_t __n) {
}
}
void eeprom_toggle(uint8_t *__p) {
eeprom_write_byte(__p, !eeprom_read_byte(__p));
}
void __attribute__((noinline)) eeprom_increment_byte(uint8_t *__p) {
eeprom_write_byte(__p, eeprom_read_byte(__p) + 1);
}

View File

@ -615,6 +615,7 @@ bool eeprom_is_sheet_initialized(uint8_t sheet_num);
bool eeprom_is_initialized_block(const void *__p, size_t __n);
void eeprom_update_block_P(const void *__src, void *__dst, size_t __n);
void eeprom_toggle(uint8_t *__p);
void eeprom_increment_byte(uint8_t *__p);
void eeprom_increment_word(uint16_t *__p);

View File

@ -3125,11 +3125,7 @@ void mbl_settings_init() {
//magnet elimination: use aaproximate Z-coordinate instead of measured values for points which are near magnets
eeprom_init_default_byte((uint8_t*)EEPROM_MBL_MAGNET_ELIMINATION, 1);
eeprom_init_default_byte((uint8_t*)EEPROM_MBL_POINTS_NR, 3);
mbl_z_probe_nr = eeprom_read_byte((uint8_t*)EEPROM_MBL_PROBE_NR);
if (mbl_z_probe_nr == 0xFF) {
mbl_z_probe_nr = 3;
eeprom_update_byte((uint8_t*)EEPROM_MBL_PROBE_NR, mbl_z_probe_nr);
}
mbl_z_probe_nr = eeprom_init_default_byte((uint8_t*)EEPROM_MBL_PROBE_NR, 3);
}
//parameter ix: index of mesh bed leveling point in X-axis (for meas_points == 7 is valid range from 0 to 6; for meas_points == 3 is valid range from 0 to 2 )

View File

@ -4605,12 +4605,7 @@ void lcd_hw_setup_menu(void) // can not be "static"
if (_md->status == 0 || lcd_draw_update)
{
_md->status = 1;
_md->experimental_menu_visibility = eeprom_read_byte((uint8_t *)EEPROM_EXPERIMENTAL_VISIBILITY);
if (_md->experimental_menu_visibility == EEPROM_EMPTY_VALUE)
{
_md->experimental_menu_visibility = 0;
eeprom_update_byte((uint8_t *)EEPROM_EXPERIMENTAL_VISIBILITY, _md->experimental_menu_visibility);
}
_md->experimental_menu_visibility = eeprom_init_default_byte((uint8_t *)EEPROM_EXPERIMENTAL_VISIBILITY, 0);
}
@ -7527,7 +7522,7 @@ void menu_lcd_longpress_func(void)
{
// only toggle the experimental menu visibility flag
lcd_quick_feedback();
lcd_experimental_toggle();
eeprom_toggle((uint8_t *)EEPROM_EXPERIMENTAL_VISIBILITY);
return;
}
@ -7690,16 +7685,6 @@ void lcd_crash_detect_disable()
}
#endif
void lcd_experimental_toggle()
{
uint8_t oldVal = eeprom_read_byte((uint8_t *)EEPROM_EXPERIMENTAL_VISIBILITY);
if (oldVal == EEPROM_EMPTY_VALUE)
oldVal = 0;
else
oldVal = !oldVal;
eeprom_update_byte((uint8_t *)EEPROM_EXPERIMENTAL_VISIBILITY, oldVal);
}
#ifdef TMC2130
void UserECool_toggle(){
// this is only called when the experimental menu is visible, thus the first condition for enabling of the ECool mode is met in this place

View File

@ -244,7 +244,6 @@ enum class WizState : uint8_t
void lcd_wizard(WizState state);
extern void lcd_experimental_toggle();
extern void lcd_experimental_menu();
uint8_t lcdui_print_extruder(void);