RGB_STARTUP_TEST

This commit is contained in:
studiodyne 2022-08-28 00:43:32 +02:00 committed by Scott Lahteine
parent c996bfddb7
commit 3d03f96205
2 changed files with 48 additions and 3 deletions

View File

@ -3251,16 +3251,19 @@
* luminance values can be set from 0 to 255.
* For NeoPixel LED an overall brightness parameter is also available.
*
* *** CAUTION ***
* === CAUTION ===
* LED Strips require a MOSFET Chip between PWM lines and LEDs,
* as the Arduino cannot handle the current the LEDs will require.
* Failure to follow this precaution can destroy your Arduino!
*
* NOTE: A separate 5V power supply is required! The NeoPixel LED needs
* more current than the Arduino 5V linear regulator can produce.
* *** CAUTION ***
*
* LED Type. Enable only one of the following two options.
* Requires PWM frequency between 50 <> 100Hz (Check HAL or variant)
* Use FAST_PWM_FAN, if possible, to reduce fan noise.
*/
// LED Type. Enable only one of the following two options:
//#define RGB_LED
//#define RGBW_LED
@ -3269,6 +3272,10 @@
//#define RGB_LED_G_PIN 43
//#define RGB_LED_B_PIN 35
//#define RGB_LED_W_PIN -1
//#define RGB_STARTUP_TEST // For PWM pins, fade between all colors
#if ENABLED(RGB_STARTUP_TEST)
#define RGB_STARTUP_TEST_INNER_MS 10 // (ms) Reduce or increase fading speed
#endif
#endif
// Support for Adafruit NeoPixel LED driver

View File

@ -69,6 +69,44 @@ void LEDLights::setup() {
#if ENABLED(RGBW_LED)
if (PWM_PIN(RGB_LED_W_PIN)) SET_PWM(RGB_LED_W_PIN); else SET_OUTPUT(RGB_LED_W_PIN);
#endif
#if ENABLED(RGB_STARTUP_TEST)
int8_t led_pin_count = 0;
if (PWM_PIN(RGB_LED_R_PIN) && PWM_PIN(RGB_LED_G_PIN) && PWM_PIN(RGB_LED_B_PIN)) led_pin_count = 3;
#if ENABLED(RGBW_LED)
if (PWM_PIN(RGB_LED_W_PIN) && led_pin_count) led_pin_count++;
#endif
// Startup animation
if (led_pin_count) {
// blackout
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);
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);
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);
#if ENABLED(RGBW_LED)
if (PWM_PIN(RGB_LED_W_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_W_PIN), 0);
else WRITE(RGB_LED_W_PIN, LOW);
#endif
delay(200);
LOOP_L_N(i, led_pin_count) {
LOOP_LE_N(b, 200) {
const uint16_t led_pwm = b <= 100 ? b : 200 - b;
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);
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);
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);
#if ENABLED(RGBW_LED)
if (i == 3){
if (PWM_PIN(RGB_LED_W_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_W_PIN), led_pwm);
else WRITE(RGB_LED_W_PIN, b < 100 ? HIGH : LOW);
delay(RGB_STARTUP_TEST_INNER_MS);//More slowing for ending
}
#endif
delay(RGB_STARTUP_TEST_INNER_MS);
}
}
delay(500);
}
#endif // RGB_STARTUP_TEST
#endif
TERN_(NEOPIXEL_LED, neo.init());
TERN_(PCA9533, PCA9533_init());