Store case light brightness in EEPROM (#17307)

This commit is contained in:
Mathias Rasmussen 2020-03-27 23:38:28 +01:00 committed by GitHub
parent bed41af868
commit 8752fbd92c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -127,6 +127,11 @@
void M710_report(const bool forReplay); void M710_report(const bool forReplay);
#endif #endif
#define HAS_CASE_LIGHT_BRIGHTNESS (ENABLED(CASE_LIGHT_MENU) && DISABLED(CASE_LIGHT_NO_BRIGHTNESS))
#if HAS_CASE_LIGHT_BRIGHTNESS
#include "../feature/caselight.h"
#endif
#pragma pack(push, 1) // No padding between variables #pragma pack(push, 1) // No padding between variables
typedef struct { uint16_t X, Y, Z, X2, Y2, Z2, Z3, Z4, E0, E1, E2, E3, E4, E5; } tmc_stepper_current_t; typedef struct { uint16_t X, Y, Z, X2, Y2, Z2, Z3, Z4, E0, E1, E2, E3, E4, E5; } tmc_stepper_current_t;
@ -376,6 +381,13 @@ typedef struct SettingsDataStruct {
uint8_t extui_data[ExtUI::eeprom_data_size]; uint8_t extui_data[ExtUI::eeprom_data_size];
#endif #endif
//
// HAS_CASE_LIGHT_BRIGHTNESS
//
#if HAS_CASE_LIGHT_BRIGHTNESS
uint8_t case_light_brightness;
#endif
} SettingsData; } SettingsData;
//static_assert(sizeof(SettingsData) <= E2END + 1, "EEPROM too small to contain SettingsData!"); //static_assert(sizeof(SettingsData) <= E2END + 1, "EEPROM too small to contain SettingsData!");
@ -441,6 +453,10 @@ void MarlinSettings::postprocess() {
planner.recalculate_max_e_jerk(); planner.recalculate_max_e_jerk();
#endif #endif
#if HAS_CASE_LIGHT_BRIGHTNESS
update_case_light();
#endif
// Refresh steps_to_mm with the reciprocal of axis_steps_per_mm // Refresh steps_to_mm with the reciprocal of axis_steps_per_mm
// and init stepper.count[], planner.position[] with current_position // and init stepper.count[], planner.position[] with current_position
planner.refresh_positioning(); planner.refresh_positioning();
@ -1309,6 +1325,13 @@ void MarlinSettings::postprocess() {
} }
#endif #endif
//
// Case Light Brightness
//
#if HAS_CASE_LIGHT_BRIGHTNESS
EEPROM_WRITE(case_light_brightness);
#endif
// //
// Validate CRC and Data Size // Validate CRC and Data Size
// //
@ -2163,6 +2186,14 @@ void MarlinSettings::postprocess() {
} }
#endif #endif
//
// Case Light Brightness
//
#if HAS_CASE_LIGHT_BRIGHTNESS
_FIELD_TEST(case_light_brightness);
EEPROM_READ(case_light_brightness);
#endif
eeprom_error = size_error(eeprom_index - (EEPROM_OFFSET)); eeprom_error = size_error(eeprom_index - (EEPROM_OFFSET));
if (eeprom_error) { if (eeprom_error) {
DEBUG_ECHO_START(); DEBUG_ECHO_START();
@ -2458,6 +2489,14 @@ void MarlinSettings::reset() {
ExtUI::onFactoryReset(); ExtUI::onFactoryReset();
#endif #endif
//
// Case Light Brightness
//
#if HAS_CASE_LIGHT_BRIGHTNESS
case_light_brightness = CASE_LIGHT_DEFAULT_BRIGHTNESS;
#endif
// //
// Magnetic Parking Extruder // Magnetic Parking Extruder
// //