@@ -84,11 +84,29 @@ void initStatusLED() {
8484 analogWrite (STATUS_LED_PIN, 255 );
8585#elif defined(ARDUINO_ARCH_ESP32)
8686 WS._pwmComponent ->attach (STATUS_LED_PIN, LEDC_BASE_FREQ, LEDC_TIMER_12_BIT);
87- WS._pwmComponent ->writeDutyCycle (STATUS_LED_PIN, 0 ); // turn OFF
87+ WS._pwmComponent ->writeDutyCycle (STATUS_LED_PIN,
88+ #if defined(STATUS_LED_INVERTED)
89+ 255
90+ #else
91+ 0
92+ #endif
93+ ); // turn OFF
8894#elif defined(ARDUINO_ARCH_RP2040)
89- digitalWrite (STATUS_LED_PIN, 0 );
95+ digitalWrite (STATUS_LED_PIN,
96+ #if defined(STATUS_LED_INVERTED)
97+ 255
98+ #else
99+ 0
100+ #endif
101+ ); // turn OFF
102+ #else
103+ analogWrite (STATUS_LED_PIN,
104+ #if defined(STATUS_LED_INVERTED)
105+ 255
90106#else
91- analogWrite (STATUS_LED_PIN, 0 );
107+ 0
108+ #endif
109+ ); // turn OFF
92110#endif
93111
94112 WS.lockStatusLED = true ; // set global pin "lock" flag
@@ -116,7 +134,13 @@ void releaseStatusLED() {
116134#endif
117135
118136#ifdef USE_STATUS_LED
119- digitalWrite (STATUS_LED_PIN, 0 ); // turn off
137+ digitalWrite (STATUS_LED_PIN,
138+ #if defined(STATUS_LED_INVERTED)
139+ 255
140+ #else
141+ 0
142+ #endif
143+ ); // turn OFF
120144 pinMode (STATUS_LED_PIN,
121145 INPUT); // "release" for use by setting to input (hi-z)
122146 WS.lockStatusLED = false ; // un-set global pin "lock" flag
@@ -182,13 +206,31 @@ void setStatusLEDColor(uint32_t color) {
182206 if (!WS.lockStatusLED )
183207 return ; // status pixel is in-use elsewhere
184208#ifdef ARDUINO_ARCH_RP2040
185- digitalWrite (STATUS_LED_PIN, color > 0 );
209+ digitalWrite (STATUS_LED_PIN,
210+ #if defined(STATUS_LED_INVERTED)
211+ !(color > 0 )
212+ #else
213+ color > 0
214+ #endif
215+ );
186216#else
187217 if (color != BLACK)
188218 WS._pwmComponent ->writeDutyCycle (
189- STATUS_LED_PIN, map (WS.status_pixel_brightness , 0.0 , 1.0 , 0 , 1023 ));
219+ STATUS_LED_PIN, map (WS.status_pixel_brightness , 0.0 , 1.0 ,
220+ #if defined(STATUS_LED_INVERTED)
221+ 1023 , 0
222+ #else
223+ 0 , 1023
224+ #endif
225+ ));
190226 else
191- WS._pwmComponent ->writeDutyCycle (STATUS_LED_PIN, 0 );
227+ WS._pwmComponent ->writeDutyCycle (STATUS_LED_PIN,
228+ #if defined(STATUS_LED_INVERTED)
229+ 1023
230+ #else
231+ 0
232+ #endif
233+ );
192234#endif
193235#endif
194236}
@@ -241,14 +283,32 @@ void setStatusLEDColor(uint32_t color, int brightness) {
241283 return ;
242284
243285#ifdef ARDUINO_ARCH_RP2040
244- digitalWrite (STATUS_LED_PIN, color > 0 );
286+ digitalWrite (STATUS_LED_PIN,
287+ #if defined(STATUS_LED_INVERTED)
288+ !(color > 0 )
289+ #else
290+ color > 0
291+ #endif
292+ );
245293#else
246294 if (color != BLACK) {
247295 // re-map for pixel as a LED
248- int pulseWidth = map (brightness, 0 , 255 , 0 , 1023 );
296+ int pulseWidth = map (brightness, 0 , 255 ,
297+ #if defined(STATUS_LED_INVERTED)
298+ 1023 , 0
299+ #else
300+ 0 , 1023
301+ #endif
302+ );
249303 WS._pwmComponent ->writeDutyCycle (STATUS_LED_PIN, pulseWidth);
250304 } else {
251- WS._pwmComponent ->writeDutyCycle (STATUS_LED_PIN, 0 );
305+ WS._pwmComponent ->writeDutyCycle (STATUS_LED_PIN,
306+ #if defined(STATUS_LED_INVERTED)
307+ 1023
308+ #else
309+ 0
310+ #endif
311+ );
252312 }
253313#endif
254314#endif
0 commit comments