Bladeren bron

Minor cleanup w/r/t LEDs

Scott Lahteine 3 jaren geleden
bovenliggende
commit
c488070859

+ 1
- 1
Marlin/Configuration.h Bestand weergeven

@@ -2363,7 +2363,7 @@
2363 2363
   //#define NEOPIXEL2_TYPE NEOPIXEL_TYPE
2364 2364
   //#define NEOPIXEL2_PIN    5
2365 2365
   //#define NEOPIXEL2_INSERIES     // Default behavior is NeoPixel 2 in parallel
2366
-  #define NEOPIXEL_PIXELS 30       // Number of LEDs in the strip, larger of 2 strips if 2 neopixel strips are used
2366
+  #define NEOPIXEL_PIXELS 30       // Number of LEDs in the strip, larger of 2 strips if 2 NeoPixel strips are used
2367 2367
   #define NEOPIXEL_IS_SEQUENTIAL   // Sequential display for temperature change - LED by LED. Disable to change all LEDs at once.
2368 2368
   #define NEOPIXEL_BRIGHTNESS 127  // Initial brightness (0-255)
2369 2369
   //#define NEOPIXEL_STARTUP_TEST  // Cycle through colors at startup

+ 3
- 6
Marlin/src/feature/leds/leds.cpp Bestand weergeven

@@ -129,12 +129,9 @@ void LEDLights::set_color(const LEDColor &incol
129 129
 
130 130
   #endif
131 131
 
132
-  #if ENABLED(PCA9632)
133
-    // Update I2C LED driver
134
-    pca9632_set_led_color(incol);
135
-  #endif
136
-
137
-  TERN_(PCA9533, PCA9533_setColor(incol.r, incol.g, incol.b));
132
+  // Update I2C LED driver
133
+  TERN_(PCA9632, PCA9632_set_led_color(incol));
134
+  TERN_(PCA9533, PCA9533_set_rgb(incol.r, incol.g, incol.b));
138 135
 
139 136
   #if EITHER(LED_CONTROL_MENU, PRINTER_EVENT_LEDS)
140 137
     // Don't update the color when OFF

+ 2
- 6
Marlin/src/feature/leds/leds.h Bestand weergeven

@@ -104,11 +104,7 @@ typedef struct LEDColor {
104 104
   bool operator!=(const LEDColor &right) { return !operator==(right); }
105 105
 
106 106
   bool is_off() const {
107
-    return 3 > r + g + b
108
-      #if HAS_WHITE_LED
109
-        + w
110
-      #endif
111
-    ;
107
+    return 3 > r + g + b + TERN0(HAS_WHITE_LED, w);
112 108
   }
113 109
 } LEDColor;
114 110
 
@@ -156,7 +152,7 @@ public:
156 152
     #endif
157 153
   );
158 154
 
159
-  inline void set_color(uint8_t r, uint8_t g, uint8_t b
155
+  static inline void set_color(uint8_t r, uint8_t g, uint8_t b
160 156
     #if HAS_WHITE_LED
161 157
       , uint8_t w=0
162 158
       #if ENABLED(NEOPIXEL_LED)

+ 6
- 7
Marlin/src/feature/leds/neopixel.cpp Bestand weergeven

@@ -53,9 +53,9 @@ Adafruit_NeoPixel Marlin_NeoPixel::adaneo1(NEOPIXEL_PIXELS, NEOPIXEL_PIN, NEOPIX
53 53
 #endif
54 54
 
55 55
 void Marlin_NeoPixel::set_color(const uint32_t color) {
56
-  if (get_neo_index() >= 0) {
57
-    set_pixel_color(get_neo_index(), color);
58
-    set_neo_index(-1);
56
+  if (neoindex >= 0) {
57
+    set_pixel_color(neoindex, color);
58
+    neoindex = -1;
59 59
   }
60 60
   else {
61 61
     for (uint16_t i = 0; i < pixels(); ++i) {
@@ -78,18 +78,17 @@ void Marlin_NeoPixel::set_color_startup(const uint32_t color) {
78 78
 }
79 79
 
80 80
 void Marlin_NeoPixel::init() {
81
-  set_neo_index(-1);                   // -1 .. NEOPIXEL_PIXELS-1 range
81
+  neoindex = -1;                       // -1 .. NEOPIXEL_PIXELS-1 range
82 82
   set_brightness(NEOPIXEL_BRIGHTNESS); //  0 .. 255 range
83 83
   begin();
84 84
   show();  // initialize to all off
85 85
 
86 86
   #if ENABLED(NEOPIXEL_STARTUP_TEST)
87 87
     set_color_startup(adaneo1.Color(255, 0, 0, 0));  // red
88
-    safe_delay(1000);
88
+    safe_delay(500);
89 89
     set_color_startup(adaneo1.Color(0, 255, 0, 0));  // green
90
-    safe_delay(1000);
90
+    safe_delay(500);
91 91
     set_color_startup(adaneo1.Color(0, 0, 255, 0));  // blue
92
-    safe_delay(1000);
93 92
   #endif
94 93
 
95 94
   #ifdef NEOPIXEL_BKGD_LED_INDEX

+ 2
- 4
Marlin/src/feature/leds/neopixel.h Bestand weergeven

@@ -65,17 +65,15 @@ private:
65 65
       , adaneo2
66 66
     #endif
67 67
   ;
68
-  static int8_t neoindex;
69 68
 
70 69
 public:
70
+  static int8_t neoindex;
71
+
71 72
   static void init();
72 73
   static void set_color_startup(const uint32_t c);
73 74
 
74 75
   static void set_color(const uint32_t c);
75 76
 
76
-  FORCE_INLINE static void set_neo_index(const int8_t neoIndex) { neoindex = neoIndex; }
77
-  FORCE_INLINE static int8_t get_neo_index() { return neoindex; }
78
-
79 77
   #ifdef NEOPIXEL_BKGD_LED_INDEX
80 78
     static void set_color_background();
81 79
   #endif

+ 1
- 1
Marlin/src/feature/leds/pca9533.cpp Bestand weergeven

@@ -62,7 +62,7 @@ void PCA9533_setOff() {
62 62
   PCA9533_writeRegister(PCA9533_REG_SEL, 0);
63 63
 }
64 64
 
65
-void PCA9533_setColor(uint8_t red, uint8_t green, uint8_t blue) {
65
+void PCA9533_set_rgb(uint8_t red, uint8_t green, uint8_t blue) {
66 66
   uint8_t r_pwm0 = 0; // Register data - PWM value
67 67
   uint8_t r_pwm1 = 0; // Register data - PWM value
68 68
 

+ 1
- 1
Marlin/src/feature/leds/pca9533.h Bestand weergeven

@@ -55,5 +55,5 @@
55 55
 
56 56
 void PCA9533_init();
57 57
 void PCA9533_reset();
58
-void PCA9533_setColor(uint8_t red, uint8_t green, uint8_t blue);
58
+void PCA9533_set_rgb(uint8_t red, uint8_t green, uint8_t blue);
59 59
 void PCA9533_setOff();

+ 2
- 2
Marlin/src/feature/leds/pca9632.cpp Bestand weergeven

@@ -120,7 +120,7 @@ static void PCA9632_WriteAllRegisters(const byte addr, const byte regadd, const
120 120
   }
121 121
 #endif
122 122
 
123
-void pca9632_set_led_color(const LEDColor &color) {
123
+void PCA9632_set_led_color(const LEDColor &color) {
124 124
   Wire.begin();
125 125
   if (!PCA_init) {
126 126
     PCA_init = 1;
@@ -138,7 +138,7 @@ void pca9632_set_led_color(const LEDColor &color) {
138 138
 
139 139
 #if ENABLED(PCA9632_BUZZER)
140 140
 
141
-  void pca9632_buzz(const long, const uint16_t) {
141
+  void PCA9632_buzz(const long, const uint16_t) {
142 142
     uint8_t data[] = PCA9632_BUZZER_DATA;
143 143
     Wire.beginTransmission(I2C_ADDRESS(PCA9632_ADDRESS));
144 144
     Wire.write(data, sizeof(data));

+ 2
- 2
Marlin/src/feature/leds/pca9632.h Bestand weergeven

@@ -29,9 +29,9 @@
29 29
 struct LEDColor;
30 30
 typedef LEDColor LEDColor;
31 31
 
32
-void pca9632_set_led_color(const LEDColor &color);
32
+void PCA9632_set_led_color(const LEDColor &color);
33 33
 
34 34
 #if ENABLED(PCA9632_BUZZER)
35 35
   #include <stdint.h>
36
-  void pca9632_buzz(const long, const uint16_t);
36
+  void PCA9632_buzz(const long, const uint16_t);
37 37
 #endif

+ 1
- 1
Marlin/src/feature/password/password.cpp Bestand weergeven

@@ -16,7 +16,7 @@
16 16
  * GNU General Public License for more details.
17 17
  *
18 18
  * You should have received a copy of the GNU General Public License
19
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20 20
  *
21 21
  */
22 22
 

+ 1
- 1
Marlin/src/feature/password/password.h Bestand weergeven

@@ -16,7 +16,7 @@
16 16
  * GNU General Public License for more details.
17 17
  *
18 18
  * You should have received a copy of the GNU General Public License
19
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20 20
  *
21 21
  */
22 22
 #pragma once

+ 1
- 1
Marlin/src/gcode/feature/password/M510-M512.cpp Bestand weergeven

@@ -16,7 +16,7 @@
16 16
  * GNU General Public License for more details.
17 17
  *
18 18
  * You should have received a copy of the GNU General Public License
19
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20 20
  *
21 21
  */
22 22
 

+ 1
- 1
Marlin/src/gcode/gcode.h Bestand weergeven

@@ -155,7 +155,7 @@
155 155
  * M141 - Set heated chamber target temp. S<temp> (Requires a chamber heater)
156 156
  * M145 - Set heatup values for materials on the LCD. H<hotend> B<bed> F<fan speed> for S<material> (0=PLA, 1=ABS)
157 157
  * M149 - Set temperature units. (Requires TEMPERATURE_UNITS_SUPPORT)
158
- * M150 - Set Status LED Color as R<red> U<green> B<blue> P<bright>. Values 0-255. (Requires BLINKM, RGB_LED, RGBW_LED, NEOPIXEL_LED, PCA9533, or PCA9632).
158
+ * M150 - Set Status LED Color as R<red> U<green> B<blue> W<white> P<bright>. Values 0-255. (Requires BLINKM, RGB_LED, RGBW_LED, NEOPIXEL_LED, PCA9533, or PCA9632).
159 159
  * M155 - Auto-report temperatures with interval of S<seconds>. (Requires AUTO_REPORT_TEMPERATURES)
160 160
  * M163 - Set a single proportion for a mixing extruder. (Requires MIXING_EXTRUDER)
161 161
  * M164 - Commit the mix and save to a virtual tool (current, or as specified by 'S'). (Requires MIXING_EXTRUDER)

+ 8
- 7
Marlin/src/lcd/menu/menu_led.cpp Bestand weergeven

@@ -34,18 +34,19 @@
34 34
   #include "../../feature/leds/leds.h"
35 35
 
36 36
   #if ENABLED(LED_COLOR_PRESETS)
37
+
37 38
     void menu_led_presets() {
38 39
       START_MENU();
39 40
       #if LCD_HEIGHT > 2
40 41
         STATIC_ITEM(MSG_LED_PRESETS, SS_DEFAULT|SS_INVERT);
41 42
       #endif
42 43
       BACK_ITEM(MSG_LED_CONTROL);
43
-      ACTION_ITEM(MSG_SET_LEDS_WHITE, leds.set_white);
44
-      ACTION_ITEM(MSG_SET_LEDS_RED, leds.set_red);
44
+      ACTION_ITEM(MSG_SET_LEDS_WHITE,  leds.set_white);
45
+      ACTION_ITEM(MSG_SET_LEDS_RED,    leds.set_red);
45 46
       ACTION_ITEM(MSG_SET_LEDS_ORANGE, leds.set_orange);
46
-      ACTION_ITEM(MSG_SET_LEDS_YELLOW,leds.set_yellow);
47
-      ACTION_ITEM(MSG_SET_LEDS_GREEN, leds.set_green);
48
-      ACTION_ITEM(MSG_SET_LEDS_BLUE, leds.set_blue);
47
+      ACTION_ITEM(MSG_SET_LEDS_YELLOW, leds.set_yellow);
48
+      ACTION_ITEM(MSG_SET_LEDS_GREEN,  leds.set_green);
49
+      ACTION_ITEM(MSG_SET_LEDS_BLUE,   leds.set_blue);
49 50
       ACTION_ITEM(MSG_SET_LEDS_INDIGO, leds.set_indigo);
50 51
       ACTION_ITEM(MSG_SET_LEDS_VIOLET, leds.set_violet);
51 52
       END_MENU();
@@ -83,11 +84,10 @@
83 84
   #endif
84 85
 #endif
85 86
 
86
-
87
-
88 87
 void menu_led() {
89 88
   START_MENU();
90 89
   BACK_ITEM(MSG_MAIN);
90
+
91 91
   #if ENABLED(LED_CONTROL_MENU)
92 92
     bool led_on = leds.lights_on;
93 93
     EDIT_ITEM(bool, MSG_LEDS, &led_on, leds.toggle);
@@ -97,6 +97,7 @@ void menu_led() {
97 97
     #endif
98 98
     SUBMENU(MSG_CUSTOM_LEDS, menu_led_custom);
99 99
   #endif
100
+
100 101
   //
101 102
   // Set Case light on/off/brightness
102 103
   //

+ 1
- 1
Marlin/src/lcd/ultralcd.cpp Bestand weergeven

@@ -81,7 +81,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
81 81
   #endif
82 82
   void MarlinUI::buzz(const long duration, const uint16_t freq) {
83 83
     #if ENABLED(PCA9632_BUZZER)
84
-      pca9632_buzz(duration, freq);
84
+      PCA9632_buzz(duration, freq);
85 85
     #elif USE_BEEPER
86 86
       buzzer.tone(duration, freq);
87 87
     #endif

+ 1
- 1
Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h Bestand weergeven

@@ -113,7 +113,7 @@
113 113
 #define FAN1_PIN                            PA8   // FAN  (fan0 on board) e0 cool fan
114 114
 #define FAN2_PIN                            PB9   // FAN  (fan1 on board) controller cool fan
115 115
 
116
-// One neopixel onboard and a connector for other neopixels
116
+// One NeoPixel onboard and a connector for other NeoPixels
117 117
 #define NEOPIXEL_PIN                        PC7   // The NEOPIXEL LED driving pin
118 118
 
119 119
 /**

Laden…
Annuleren
Opslaan