Browse Source

Store case light brightness in EEPROM (#17307)

Mathias Rasmussen 5 years ago
parent
commit
8752fbd92c
No account linked to committer's email address
1 changed files with 39 additions and 0 deletions
  1. 39
    0
      Marlin/src/module/configuration_store.cpp

+ 39
- 0
Marlin/src/module/configuration_store.cpp View File

@@ -127,6 +127,11 @@
127 127
   void M710_report(const bool forReplay);
128 128
 #endif
129 129
 
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
+
130 135
 #pragma pack(push, 1) // No padding between variables
131 136
 
132 137
 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 {
376 381
     uint8_t extui_data[ExtUI::eeprom_data_size];
377 382
   #endif
378 383
 
384
+  //
385
+  // HAS_CASE_LIGHT_BRIGHTNESS
386
+  //
387
+  #if HAS_CASE_LIGHT_BRIGHTNESS
388
+    uint8_t case_light_brightness;
389
+  #endif
390
+
379 391
 } SettingsData;
380 392
 
381 393
 //static_assert(sizeof(SettingsData) <= E2END + 1, "EEPROM too small to contain SettingsData!");
@@ -441,6 +453,10 @@ void MarlinSettings::postprocess() {
441 453
     planner.recalculate_max_e_jerk();
442 454
   #endif
443 455
 
456
+  #if HAS_CASE_LIGHT_BRIGHTNESS
457
+    update_case_light();
458
+  #endif
459
+
444 460
   // Refresh steps_to_mm with the reciprocal of axis_steps_per_mm
445 461
   // and init stepper.count[], planner.position[] with current_position
446 462
   planner.refresh_positioning();
@@ -1310,6 +1326,13 @@ void MarlinSettings::postprocess() {
1310 1326
     #endif
1311 1327
 
1312 1328
     //
1329
+    // Case Light Brightness
1330
+    //
1331
+    #if HAS_CASE_LIGHT_BRIGHTNESS
1332
+      EEPROM_WRITE(case_light_brightness);
1333
+    #endif
1334
+
1335
+    //
1313 1336
     // Validate CRC and Data Size
1314 1337
     //
1315 1338
     if (!eeprom_error) {
@@ -2163,6 +2186,14 @@ void MarlinSettings::postprocess() {
2163 2186
         }
2164 2187
       #endif
2165 2188
 
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
+
2166 2197
       eeprom_error = size_error(eeprom_index - (EEPROM_OFFSET));
2167 2198
       if (eeprom_error) {
2168 2199
         DEBUG_ECHO_START();
@@ -2459,6 +2490,14 @@ void MarlinSettings::reset() {
2459 2490
   #endif
2460 2491
 
2461 2492
   //
2493
+  // Case Light Brightness
2494
+  //
2495
+
2496
+  #if HAS_CASE_LIGHT_BRIGHTNESS
2497
+    case_light_brightness = CASE_LIGHT_DEFAULT_BRIGHTNESS;
2498
+  #endif
2499
+
2500
+  //
2462 2501
   // Magnetic Parking Extruder
2463 2502
   //
2464 2503
 

Loading…
Cancel
Save