Browse Source

✨ RGB_STARTUP_TEST

studiodyne 2 years ago
parent
commit
0765dfd43f
2 changed files with 48 additions and 3 deletions
  1. 10
    3
      Marlin/Configuration.h
  2. 38
    0
      Marlin/src/feature/leds/leds.cpp

+ 10
- 3
Marlin/Configuration.h View File

@@ -3251,16 +3251,19 @@
3251 3251
  * luminance values can be set from 0 to 255.
3252 3252
  * For NeoPixel LED an overall brightness parameter is also available.
3253 3253
  *
3254
- * *** CAUTION ***
3254
+ *  === CAUTION ===
3255 3255
  *  LED Strips require a MOSFET Chip between PWM lines and LEDs,
3256 3256
  *  as the Arduino cannot handle the current the LEDs will require.
3257 3257
  *  Failure to follow this precaution can destroy your Arduino!
3258
+ *
3258 3259
  *  NOTE: A separate 5V power supply is required! The NeoPixel LED needs
3259 3260
  *  more current than the Arduino 5V linear regulator can produce.
3260
- * *** CAUTION ***
3261 3261
  *
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.
3263 3264
  */
3265
+
3266
+// LED Type. Enable only one of the following two options:
3264 3267
 //#define RGB_LED
3265 3268
 //#define RGBW_LED
3266 3269
 
@@ -3269,6 +3272,10 @@
3269 3272
   //#define RGB_LED_G_PIN 43
3270 3273
   //#define RGB_LED_B_PIN 35
3271 3274
   //#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
3272 3279
 #endif
3273 3280
 
3274 3281
 // Support for Adafruit NeoPixel LED driver

+ 38
- 0
Marlin/src/feature/leds/leds.cpp View File

@@ -69,6 +69,44 @@ void LEDLights::setup() {
69 69
     #if ENABLED(RGBW_LED)
70 70
       if (PWM_PIN(RGB_LED_W_PIN)) SET_PWM(RGB_LED_W_PIN); else SET_OUTPUT(RGB_LED_W_PIN);
71 71
     #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
72 110
   #endif
73 111
   TERN_(NEOPIXEL_LED, neo.init());
74 112
   TERN_(PCA9533, PCA9533_init());

Loading…
Cancel
Save