Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance status pixel #261

Merged
merged 17 commits into from
May 31, 2022
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -42,4 +42,6 @@ html/*
./vscode/*
src/.vscode/settings.json

.DS_STORE
.DS_STORE

examples/Wippersnapper_demo/build/
5 changes: 1 addition & 4 deletions src/Wippersnapper.cpp
Original file line number Diff line number Diff line change
@@ -1574,7 +1574,6 @@ void Wippersnapper::connect() {

// Register hardware with Wippersnapper
WS_DEBUG_PRINTLN("Registering hardware with WipperSnapper...")
setStatusLEDColor(LED_IO_REGISTER_HW);
if (!registerBoard()) {
haltError("Unable to register with WipperSnapper.");
}
@@ -1593,11 +1592,9 @@ void Wippersnapper::connect() {
runNetFSM();
publishPinConfigComplete();
WS_DEBUG_PRINTLN("Hardware configured successfully!");
statusLEDFade(GREEN, 3);

// Run application
// TODO: Pulse LED green
statusLEDPulse();
// statusLEDBlink(WS_LED_STATUS_CONNECTED);
WS_DEBUG_PRINTLN(
"Registration and configuration complete!\nRunning application...");
}
3 changes: 2 additions & 1 deletion src/Wippersnapper.h
Original file line number Diff line number Diff line change
@@ -182,7 +182,8 @@ class Wippersnapper {
void statusLEDDeinit();
void setStatusLEDColor(uint32_t color);
void statusLEDBlink(ws_led_status_t statusState);
void statusLEDPulse();
void statusLEDFade(uint32_t color, int numFades);

bool lockStatusNeoPixel =
false; ///< True if status LED is using the status neopixel
bool lockStatusDotStar =
33 changes: 28 additions & 5 deletions src/components/statusLED/Wippersnapper_StatusLED.cpp
Original file line number Diff line number Diff line change
@@ -135,22 +135,45 @@ void Wippersnapper::setStatusLEDColor(uint32_t color) {
#endif
}

void Wippersnapper::statusLEDPulse() {
setStatusLEDColor(GREEN);
// pulse 3x
for (int i = 0; i < 3; i++) {
/****************************************************************************/
/*!
@brief Fades the status LED.
@param color
The specific color to fade the status LED.
@param numFades
The amount of time to fade/pulse the status LED.
*/
/****************************************************************************/
void Wippersnapper::statusLEDFade(uint32_t color, int numFades = 3) {
setStatusLEDColor(color);
// pulse numFades times
for (int i = 0; i < numFades; i++) {
for (int i = 50; i <= 200; i += 5) {
#if defined(USE_STATUS_NEOPIXEL)
statusPixel->setBrightness(i);
statusPixel->show();
#elif USE_STATUS_DOTSTAR
statusPixelDotStar->setBrightness(i);
statusPixelDotStar->show();
#else
analogWrite(STATUS_LED_PIN, i);
#endif
delay(10);
}
for (int i = 200; i >= 50; i -= 5) {
#if defined(USE_STATUS_NEOPIXEL)
statusPixel->setBrightness(i);
statusPixel->show();
#elif USE_STATUS_DOTSTAR
statusPixelDotStar->setBrightness(i);
statusPixelDotStar->show();
#else
analogWrite(STATUS_LED_PIN, i);
#endif
delay(10);
}
}

// reset status LED
setStatusLEDColor(BLACK);
}