Skip to content

Commit 8752fbd

Browse files
authored
Store case light brightness in EEPROM (MarlinFirmware#17307)
1 parent bed41af commit 8752fbd

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

Marlin/src/module/configuration_store.cpp

+39
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@
127127
void M710_report(const bool forReplay);
128128
#endif
129129

130+
#define HAS_CASE_LIGHT_BRIGHTNESS (ENABLED(CASE_LIGHT_MENU) && DISABLED(CASE_LIGHT_NO_BRIGHTNESS))
131+
#if HAS_CASE_LIGHT_BRIGHTNESS
132+
#include "../feature/caselight.h"
133+
#endif
134+
130135
#pragma pack(push, 1) // No padding between variables
131136

132137
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 {
376381
uint8_t extui_data[ExtUI::eeprom_data_size];
377382
#endif
378383

384+
//
385+
// HAS_CASE_LIGHT_BRIGHTNESS
386+
//
387+
#if HAS_CASE_LIGHT_BRIGHTNESS
388+
uint8_t case_light_brightness;
389+
#endif
390+
379391
} SettingsData;
380392

381393
//static_assert(sizeof(SettingsData) <= E2END + 1, "EEPROM too small to contain SettingsData!");
@@ -441,6 +453,10 @@ void MarlinSettings::postprocess() {
441453
planner.recalculate_max_e_jerk();
442454
#endif
443455

456+
#if HAS_CASE_LIGHT_BRIGHTNESS
457+
update_case_light();
458+
#endif
459+
444460
// Refresh steps_to_mm with the reciprocal of axis_steps_per_mm
445461
// and init stepper.count[], planner.position[] with current_position
446462
planner.refresh_positioning();
@@ -1309,6 +1325,13 @@ void MarlinSettings::postprocess() {
13091325
}
13101326
#endif
13111327

1328+
//
1329+
// Case Light Brightness
1330+
//
1331+
#if HAS_CASE_LIGHT_BRIGHTNESS
1332+
EEPROM_WRITE(case_light_brightness);
1333+
#endif
1334+
13121335
//
13131336
// Validate CRC and Data Size
13141337
//
@@ -2163,6 +2186,14 @@ void MarlinSettings::postprocess() {
21632186
}
21642187
#endif
21652188

2189+
//
2190+
// Case Light Brightness
2191+
//
2192+
#if HAS_CASE_LIGHT_BRIGHTNESS
2193+
_FIELD_TEST(case_light_brightness);
2194+
EEPROM_READ(case_light_brightness);
2195+
#endif
2196+
21662197
eeprom_error = size_error(eeprom_index - (EEPROM_OFFSET));
21672198
if (eeprom_error) {
21682199
DEBUG_ECHO_START();
@@ -2458,6 +2489,14 @@ void MarlinSettings::reset() {
24582489
ExtUI::onFactoryReset();
24592490
#endif
24602491

2492+
//
2493+
// Case Light Brightness
2494+
//
2495+
2496+
#if HAS_CASE_LIGHT_BRIGHTNESS
2497+
case_light_brightness = CASE_LIGHT_DEFAULT_BRIGHTNESS;
2498+
#endif
2499+
24612500
//
24622501
// Magnetic Parking Extruder
24632502
//

0 commit comments

Comments
 (0)