Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
co2ampel
ampel-firmware
Commits
ade43786
Commit
ade43786
authored
Feb 13, 2022
by
Eric Duminil
Browse files
Cool. Rainbow wheel is back!
parent
ab35a3ff
Pipeline
#5804
passed with stage
in 2 minutes and 48 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/ampel-firmware.h
View file @
ade43786
...
...
@@ -21,4 +21,10 @@
#include
"co2_sensor.h"
#include
"led_effects.h"
void
wifiConnected
();
void
wifiFailed
();
void
keepServicesAlive
();
void
checkFlashButton
();
void
checkSerialInput
();
#endif
ampel-firmware/ampel-firmware.ino
View file @
ade43786
...
...
@@ -56,36 +56,6 @@
* and define your credentials and parameters in 'config.h'.
*/
//void failedConnection() {
// Serial.println("Seriously. What???");
// led_effects::showKITTWheel(color::red);
//}
//
void
wifiConnected
()
{
led_effects
::
showKITTWheel
(
color
::
green
);
Serial
.
println
();
Serial
.
print
(
F
(
"WiFi - Connected! IP address: "
));
IPAddress
address
=
WiFi
.
localIP
();
snprintf
(
wifi
::
local_ip
,
sizeof
(
wifi
::
local_ip
),
"%d.%d.%d.%d"
,
address
[
0
],
address
[
1
],
address
[
2
],
address
[
3
]);
Serial
.
println
(
wifi
::
local_ip
);
ntp
::
initialize
();
if
(
config
::
mqtt_active
())
{
mqtt
::
initialize
(
ampel
.
sensorId
);
}
Serial
.
print
(
F
(
"You can access this sensor via http://"
));
Serial
.
print
(
ampel
.
sensorId
);
Serial
.
print
(
F
(
".local (might be unstable) or http://"
));
Serial
.
println
(
WiFi
.
localIP
());
}
void
wifiFailed
()
{
Serial
.
print
(
F
(
"WiFi - Could not connect to "
));
Serial
.
println
(
config
::
selected_ssid
());
//TODO: Rename
led_effects
::
showKITTWheel
(
color
::
red
);
}
/*****************************************************************
* Setup *
*****************************************************************/
...
...
@@ -122,6 +92,7 @@ void setup() {
if
(
config
::
wifi_active
)
{
wifi
::
defineCommands
();
web_server
::
definePages
();
wifi
::
tryConnection
();
}
#if defined(ESP32)
...
...
@@ -131,13 +102,6 @@ void setup() {
#endif
}
/*****************************************************************
* Helper functions *
*****************************************************************/
void
keepServicesAlive
();
void
checkFlashButton
();
void
checkSerialInput
();
/*****************************************************************
* Main loop *
*****************************************************************/
...
...
@@ -189,6 +153,39 @@ void loop() {
}
}
/*****************************************************************
* Callbacks *
*****************************************************************/
void
wifiConnected
()
{
led_effects
::
showKITTWheel
(
color
::
green
);
Serial
.
println
();
Serial
.
print
(
F
(
"WiFi - Connected! IP address: "
));
IPAddress
address
=
WiFi
.
localIP
();
snprintf
(
wifi
::
local_ip
,
sizeof
(
wifi
::
local_ip
),
"%d.%d.%d.%d"
,
address
[
0
],
address
[
1
],
address
[
2
],
address
[
3
]);
Serial
.
println
(
wifi
::
local_ip
);
ntp
::
initialize
();
if
(
config
::
mqtt_active
())
{
mqtt
::
initialize
(
ampel
.
sensorId
);
}
Serial
.
print
(
F
(
"You can access this sensor via http://"
));
Serial
.
print
(
ampel
.
sensorId
);
Serial
.
print
(
F
(
".local (might be unstable) or http://"
));
Serial
.
println
(
WiFi
.
localIP
());
}
void
wifiFailed
()
{
Serial
.
print
(
F
(
"WiFi - Could not connect to "
));
Serial
.
println
(
config
::
selected_ssid
());
//TODO: Rename
led_effects
::
showKITTWheel
(
color
::
red
);
}
/*****************************************************************
* Helper functions *
*****************************************************************/
void
checkSerialInput
()
{
while
(
Serial
.
available
()
>
0
)
{
sensor_console
::
processSerialInput
(
Serial
.
read
());
...
...
ampel-firmware/wifi_util.cpp
View file @
ade43786
...
...
@@ -19,6 +19,14 @@ namespace wifi {
return
WiFi
.
status
()
==
WL_CONNECTED
;
}
void
tryConnection
()
{
for
(
int
i
=
0
;
i
<=
30
&&
!
connected
();
i
++
)
{
led_effects
::
showRainbowWheel
();
web_config
::
update
();
Serial
.
print
(
"."
);
}
}
void
scanNetworks
()
{
Serial
.
println
();
Serial
.
println
(
F
(
"WiFi - Scanning..."
));
...
...
ampel-firmware/wifi_util.h
View file @
ade43786
...
...
@@ -5,6 +5,7 @@ namespace wifi {
extern
char
local_ip
[
16
];
void
defineCommands
();
bool
connected
();
void
tryConnection
();
}
#endif
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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