Skip to content

Conversation

@skruppy
Copy link
Contributor

@skruppy skruppy commented Oct 27, 2025

Description

The compilation will fail with the following error, if the later described requirements are met:

In file included from Marlin/src/lcd/menu/menu_led.cpp:32:0:
Marlin/src/lcd/menu/menu_led.cpp: In function 'void menu_led()':
Marlin/src/lcd/menu/menu_led.cpp:178:42: error: 'caselight' was not declared in this scope
         EDIT_ITEM(bool, MSG_CASE_LIGHT, &caselight.on, caselight.update_enabled);

I fixed this error by rearranging some feature blocks in menu_led.cpp.

Since this bug was probably caused by a confusing feature block structure, I also cleaned that up in the whole file (which should be only cosmetic changes). The GitHub diff for this looks horrible, but it's mainly only white space changes.

Those two changes are separate commits, so feel free to drop the cleanups if I overlooked some meaning in the old structure.

Requirements

  • Case light is enabled
  • The case light has no brightness control (e.g. by using RGB LED)
  • The LED control menu is enabled
  • The case light menu is enabled

Benefits

  • Fixed compile error
  • (a little bit) cleaner code in menu_led.cpp

Configurations

config patch to reproduce error with otherwise vanilla Marlin on bugfix-2.1.x branch

diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h
index 7947ba65c5..e3954ea066 100644
--- a/Marlin/Configuration.h
+++ b/Marlin/Configuration.h
@@ -2871,7 +2871,7 @@
 //
 // Note: Usually sold with a white PCB.
 //
-//#define REPRAP_DISCOUNT_SMART_CONTROLLER
+#define REPRAP_DISCOUNT_SMART_CONTROLLER
 
 //
 // GT2560 (YHCB2004) LCD Display
@@ -3643,13 +3643,13 @@
  */
 
 // LED Type. Enable only one of the following two options:
-//#define RGB_LED
+#define RGB_LED
 //#define RGBW_LED
 
 #if ANY(RGB_LED, RGBW_LED)
-  //#define RGB_LED_R_PIN 34
-  //#define RGB_LED_G_PIN 43
-  //#define RGB_LED_B_PIN 35
+  #define RGB_LED_R_PIN 34
+  #define RGB_LED_G_PIN 43
+  #define RGB_LED_B_PIN 35
   //#define RGB_LED_W_PIN -1
 #endif
 
diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h
index f1feb94688..63f4a6cf16 100644
--- a/Marlin/Configuration_adv.h
+++ b/Marlin/Configuration_adv.h
@@ -756,7 +756,7 @@
  * @section caselight
  * M355 Case Light on-off / brightness
  */
-//#define CASE_LIGHT_ENABLE
+#define CASE_LIGHT_ENABLE
 #if ENABLED(CASE_LIGHT_ENABLE)
   //#define CASE_LIGHT_PIN 4                  // Override the default pin if needed
   #define INVERT_CASE_LIGHT false             // Set true if Case Light is ON when pin is LOW
@@ -764,12 +764,12 @@
   #define CASE_LIGHT_DEFAULT_BRIGHTNESS 105   // Set default power-up brightness (0-255, requires PWM pin)
   //#define CASE_LIGHT_NO_BRIGHTNESS          // Disable brightness control. Enable for non-PWM lighting.
   //#define CASE_LIGHT_MAX_PWM 128            // Limit PWM duty cycle (0-255)
-  //#define CASE_LIGHT_MENU                   // Add Case Light options to the LCD menu
+  #define CASE_LIGHT_MENU                   // Add Case Light options to the LCD menu
   #if ENABLED(NEOPIXEL_LED)
     //#define CASE_LIGHT_USE_NEOPIXEL         // Use NeoPixel LED as case light
   #endif
   #if ANY(RGB_LED, RGBW_LED)
-    //#define CASE_LIGHT_USE_RGB_LED          // Use RGB / RGBW LED as case light
+    #define CASE_LIGHT_USE_RGB_LED          // Use RGB / RGBW LED as case light
   #endif
   #if ANY(CASE_LIGHT_USE_NEOPIXEL, CASE_LIGHT_USE_RGB_LED)
     #define CASE_LIGHT_DEFAULT_COLOR { 255, 255, 255, 255 } // { Red, Green, Blue, White }
@@ -1689,7 +1689,7 @@
    * LED Control Menu
    * Add LED Control to the LCD menu
    */
-  //#define LED_CONTROL_MENU
+  #define LED_CONTROL_MENU
   #if ENABLED(LED_CONTROL_MENU)
     #define LED_COLOR_PRESETS                 // Enable the Preset Color menu option
     //#define NEO2_COLOR_PRESETS              // Enable a second NeoPixel Preset Color menu option

Related Issues

Found none

@skruppy skruppy changed the title Fix led menu Fix compile error for case light menu w/o brightness Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant