Limit Case Light PWM (#15459)
This commit is contained in:
		
				
					committed by
					
						 Scott Lahteine
						Scott Lahteine
					
				
			
			
				
	
			
			
			
						parent
						
							f8498d8a52
						
					
				
				
					commit
					a1ad01e4ab
				
			| @@ -379,6 +379,7 @@ | ||||
|   #define INVERT_CASE_LIGHT false             // Set true if Case Light is ON when pin is LOW | ||||
|   #define CASE_LIGHT_DEFAULT_ON true          // Set default power-up state on | ||||
|   #define CASE_LIGHT_DEFAULT_BRIGHTNESS 105   // Set default power-up brightness (0-255, requires PWM pin) | ||||
|   //#define CASE_LIGHT_MAX_PWM 128            // Limit pwm | ||||
|   //#define CASE_LIGHT_MENU                   // Add Case Light options to the LCD menu | ||||
|   //#define CASE_LIGHT_NO_BRIGHTNESS          // Disable brightness control. Enable for non-PWM lighting. | ||||
|   //#define CASE_LIGHT_USE_NEOPIXEL           // Use Neopixel LED as case light, requires NEOPIXEL_LED. | ||||
|   | ||||
| @@ -71,7 +71,13 @@ void update_case_light() { | ||||
|  | ||||
|     #if DISABLED(CASE_LIGHT_NO_BRIGHTNESS) | ||||
|       if (PWM_PIN(CASE_LIGHT_PIN)) | ||||
|         analogWrite(pin_t(CASE_LIGHT_PIN), n10ct); | ||||
|         analogWrite(pin_t(CASE_LIGHT_PIN), | ||||
|           #if CASE_LIGHT_MAX_PWM == 255 | ||||
|             n10ct | ||||
|           #else | ||||
|             map(n10ct, 0, 255, 0, CASE_LIGHT_MAX_PWM) | ||||
|           #endif | ||||
|         ); | ||||
|       else | ||||
|     #endif | ||||
|       { | ||||
|   | ||||
| @@ -1334,6 +1334,17 @@ | ||||
|   #define FAST_PWM_FAN_FREQUENCY ((F_CPU) / (2 * 255 * 1)) // Fan frequency default | ||||
| #endif | ||||
|  | ||||
| /** | ||||
|  * MIN/MAX case light PWM scaling | ||||
|  */ | ||||
| #if HAS_CASE_LIGHT | ||||
|   #ifndef CASE_LIGHT_MAX_PWM | ||||
|     #define CASE_LIGHT_MAX_PWM 255 | ||||
|   #elif !WITHIN(CASE_LIGHT_MAX_PWM, 1, 255) | ||||
|     #error "CASE_LIGHT_MAX_PWM must be a value from 1 to 255." | ||||
|   #endif | ||||
| #endif | ||||
|  | ||||
| /** | ||||
|  * Bed Probe dependencies | ||||
|  */ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user