Skip to content

Commit 3d03f96

Browse files
studiodynethinkyhead
authored andcommitted
✨ RGB_STARTUP_TEST
1 parent c996bfd commit 3d03f96

File tree

2 files changed

+48
-3
lines changed

2 files changed

+48
-3
lines changed

Marlin/Configuration.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3251,16 +3251,19 @@
32513251
* luminance values can be set from 0 to 255.
32523252
* For NeoPixel LED an overall brightness parameter is also available.
32533253
*
3254-
* *** CAUTION ***
3254+
* === CAUTION ===
32553255
* LED Strips require a MOSFET Chip between PWM lines and LEDs,
32563256
* as the Arduino cannot handle the current the LEDs will require.
32573257
* Failure to follow this precaution can destroy your Arduino!
3258+
*
32583259
* NOTE: A separate 5V power supply is required! The NeoPixel LED needs
32593260
* more current than the Arduino 5V linear regulator can produce.
3260-
* *** CAUTION ***
32613261
*
3262-
* LED Type. Enable only one of the following two options.
3262+
* Requires PWM frequency between 50 <> 100Hz (Check HAL or variant)
3263+
* Use FAST_PWM_FAN, if possible, to reduce fan noise.
32633264
*/
3265+
3266+
// LED Type. Enable only one of the following two options:
32643267
//#define RGB_LED
32653268
//#define RGBW_LED
32663269

@@ -3269,6 +3272,10 @@
32693272
//#define RGB_LED_G_PIN 43
32703273
//#define RGB_LED_B_PIN 35
32713274
//#define RGB_LED_W_PIN -1
3275+
//#define RGB_STARTUP_TEST // For PWM pins, fade between all colors
3276+
#if ENABLED(RGB_STARTUP_TEST)
3277+
#define RGB_STARTUP_TEST_INNER_MS 10 // (ms) Reduce or increase fading speed
3278+
#endif
32723279
#endif
32733280

32743281
// Support for Adafruit NeoPixel LED driver

Marlin/src/feature/leds/leds.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,44 @@ void LEDLights::setup() {
6969
#if ENABLED(RGBW_LED)
7070
if (PWM_PIN(RGB_LED_W_PIN)) SET_PWM(RGB_LED_W_PIN); else SET_OUTPUT(RGB_LED_W_PIN);
7171
#endif
72+
73+
#if ENABLED(RGB_STARTUP_TEST)
74+
int8_t led_pin_count = 0;
75+
if (PWM_PIN(RGB_LED_R_PIN) && PWM_PIN(RGB_LED_G_PIN) && PWM_PIN(RGB_LED_B_PIN)) led_pin_count = 3;
76+
#if ENABLED(RGBW_LED)
77+
if (PWM_PIN(RGB_LED_W_PIN) && led_pin_count) led_pin_count++;
78+
#endif
79+
// Startup animation
80+
if (led_pin_count) {
81+
// blackout
82+
if (PWM_PIN(RGB_LED_R_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_R_PIN), 0); else WRITE(RGB_LED_R_PIN, LOW);
83+
if (PWM_PIN(RGB_LED_G_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_G_PIN), 0); else WRITE(RGB_LED_G_PIN, LOW);
84+
if (PWM_PIN(RGB_LED_B_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_B_PIN), 0); else WRITE(RGB_LED_B_PIN, LOW);
85+
#if ENABLED(RGBW_LED)
86+
if (PWM_PIN(RGB_LED_W_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_W_PIN), 0);
87+
else WRITE(RGB_LED_W_PIN, LOW);
88+
#endif
89+
delay(200);
90+
91+
LOOP_L_N(i, led_pin_count) {
92+
LOOP_LE_N(b, 200) {
93+
const uint16_t led_pwm = b <= 100 ? b : 200 - b;
94+
if (i == 0 && PWM_PIN(RGB_LED_R_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_R_PIN), led_pwm); else WRITE(RGB_LED_R_PIN, b < 100 ? HIGH : LOW);
95+
if (i == 1 && PWM_PIN(RGB_LED_G_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_G_PIN), led_pwm); else WRITE(RGB_LED_G_PIN, b < 100 ? HIGH : LOW);
96+
if (i == 2 && PWM_PIN(RGB_LED_B_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_B_PIN), led_pwm); else WRITE(RGB_LED_B_PIN, b < 100 ? HIGH : LOW);
97+
#if ENABLED(RGBW_LED)
98+
if (i == 3){
99+
if (PWM_PIN(RGB_LED_W_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_W_PIN), led_pwm);
100+
else WRITE(RGB_LED_W_PIN, b < 100 ? HIGH : LOW);
101+
delay(RGB_STARTUP_TEST_INNER_MS);//More slowing for ending
102+
}
103+
#endif
104+
delay(RGB_STARTUP_TEST_INNER_MS);
105+
}
106+
}
107+
delay(500);
108+
}
109+
#endif // RGB_STARTUP_TEST
72110
#endif
73111
TERN_(NEOPIXEL_LED, neo.init());
74112
TERN_(PCA9533, PCA9533_init());

0 commit comments

Comments
 (0)