Menu

Adding an onNormalMode Callback

Larz
Joined
2021-03-01 01:25:43
Posts
1

Adding an onNormalMode Callback

I'm using a WS2812 and the Adafruit-NeoPixel library to indicate my program's status.  I'm following the the NeoPixel-Callbacks example and getting good results.

In the example, I see the method used to detect the Normal mode is approached in loop() by polling the mode button and setting the pixel as needed.  Without this, the pixel will remain as it was set in the last button or state callback.

I am looking for an event-driven approach rather than the polling approach from the example.  

This would directly represent the state by explicitly setting it in the code, remove the dependence on the mode button and polling, and keep the related logic out of the loop.

// Somehere in setup()...
IAS.onNormalMode([]() {
  Serial.println(F(" Entering normal mode."));
  Serial.println(F("*------------------------------------------------------------------*"));
  pixels.clear();
  pixels.setPixelColor(0, none);  // send none
  pixels.show();
  delay(100);
});

What do you think about adding an onNormalMode callback to the library?

Thanks!

Christiaan Broeders
Joined
2016-06-04 21:36:48
Posts
19

I shall pass on the request Larz

Onno Dirkzwager
Joined
2016-06-04 21:36:48
Posts
56

In response to Larz (View post):

I'm using a WS2812 and the Adafruit-NeoPixel library to indicate my program's status.  I'm foll...

Will think about it.... Probably won't be in 2.1.0 as we are rounding up for this one.