Commit 33489e7a authored by Eric Duminil's avatar Eric Duminil
Browse files

One effect while config, one while connect

parent a350816c
Pipeline #5897 passed with stage
in 2 minutes and 20 seconds
......@@ -210,6 +210,15 @@ namespace led_effects {
}
}
void greenAlert() {
static uint8_t i;
i = (i + 1) % 10;
pixels.setBrightness(static_cast<int>(config::max_brightness * (1 - i * 0.1)));
delay(50);
pixels.fill(color::green);
pixels.show();
}
/**
* Displays a complete blue circle, and starts removing LEDs one by one. Returns the number of remaining LEDs.
* Can be used for calibration, e.g. when countdown is 0. Does not work in night mode.
......
......@@ -26,6 +26,7 @@ namespace led_effects {
void setupRing();
void redAlert();
void greenAlert();
int countdownToZero();
void showWaitingLED(uint32_t color);
void showKITTWheel(uint32_t color, uint16_t duration_s = 2);
......
......@@ -785,7 +785,7 @@ uint8_t WiFiManager::connectWifi(String ssid, String pass) {
// connect using saved ssid if there is one
if (WiFi_hasAutoConnect()) {
wifiConnectDefault();
connRes = waitForConnectResult();
connRes = waitForConnectResult(_saveTimeout);
}
else {
DEBUG_WM(F("No wifi save required, skipping"));
......@@ -927,7 +927,11 @@ uint8_t WiFiManager::waitForConnectResult(uint16_t timeout) {
return status;
}
DEBUG_WM (DEBUG_VERBOSE,F("."));
if ( _waiting_for_connection_callback == NULL){
delay(100);
} else {
_waiting_for_connection_callback();
}
}
return status;
}
......@@ -2207,6 +2211,11 @@ void WiFiManager::setWaitingForClientCallback( std::function<void()> func ) {
_waiting_for_client_callback = func;
}
// CUSTOM for Ampel
void WiFiManager::setWaitingForConnectionCallback( std::function<void()> func ) {
_waiting_for_connection_callback = func;
}
/**
* set custom head html
* custom element will be added to head, eg. new style tag etc.
......
......@@ -219,6 +219,9 @@ class WiFiManager
//called while waiting for client to connect to config. Used for LEDs
void setWaitingForClientCallback( std::function<void()> func );
//called while waiting for ESP to connect. Used for LEDs
void setWaitingForConnectionCallback( std::function<void()> func );
//sets timeout before AP,webserver loop ends and exits even if there has been no setup.
//useful for devices that failed to connect at some point and got stuck in a webserver loop
......@@ -604,6 +607,7 @@ class WiFiManager
std::function<void()> _saveparamscallback;
std::function<void()> _resetcallback;
std::function<void()> _waiting_for_client_callback;
std::function<void()> _waiting_for_connection_callback;
template <class T>
auto optionalIPFromString(T *obj, const char *s) -> decltype( obj->fromString(s) ) {
......
......@@ -55,7 +55,7 @@ namespace wifi {
// });
//
wifiManager.setWaitingForClientCallback([](){
led_effects::showRainbowWheel(50); // Shouldn't last too long, web server needs to be able to answer.
led_effects::greenAlert();
});
//
// wifiManager.setWebServerCallback([]() {
......@@ -69,7 +69,12 @@ namespace wifi {
// wifiManager.setSaveConfigCallback([]() {
// led_effects::showKITTWheel(color::magenta);
// });
wifiManager.setWaitingForConnectionCallback([](){
led_effects::showRainbowWheel(100);
});
//
wifiManager.setSaveConnectTimeout(WIFI_TIMEOUT);
wifiManager.autoConnect(hostname);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment