Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
co2ampel
ampel-firmware
Commits
33489e7a
Commit
33489e7a
authored
May 09, 2021
by
Eric Duminil
Browse files
One effect while config, one while connect
parent
a350816c
Pipeline
#5897
passed with stage
in 2 minutes and 20 seconds
Changes
5
Pipelines
2
Show whitespace changes
Inline
Side-by-side
ampel-firmware/led_effects.cpp
View file @
33489e7a
...
...
@@ -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.
...
...
ampel-firmware/led_effects.h
View file @
33489e7a
...
...
@@ -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
);
...
...
ampel-firmware/src/lib/WiFiManager/WiFiManager.cpp
View file @
33489e7a
...
...
@@ -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.
...
...
ampel-firmware/src/lib/WiFiManager/WiFiManager.h
View file @
33489e7a
...
...
@@ -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
)
)
{
...
...
ampel-firmware/wifi_util.cpp
View file @
33489e7a
...
...
@@ -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
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment