Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Käppler
ampel-firmware
Commits
8b7f81e4
Commit
8b7f81e4
authored
Dec 28, 2020
by
Eric Duminil
Browse files
Renaming led_effects namespace for consistency
parent
3bfda294
Changes
8
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/ampel-firmware.ino
View file @
8b7f81e4
...
...
@@ -59,14 +59,14 @@
* Setup *
*****************************************************************/
void
setup
()
{
L
ed
E
ffects
::
setupOnBoardLED
();
L
ed
E
ffects
::
onBoardLEDOff
();
l
ed
_e
ffects
::
setupOnBoardLED
();
l
ed
_e
ffects
::
onBoardLEDOff
();
Serial
.
begin
(
BAUDS
);
pinMode
(
0
,
INPUT
);
// Flash button (used for forced calibration)
L
ed
E
ffects
::
setupRing
();
l
ed
_e
ffects
::
setupRing
();
sensor
::
initialize
();
...
...
@@ -165,18 +165,18 @@ void loop() {
*/
void
checkFlashButton
()
{
if
(
!
digitalRead
(
0
))
{
// Button has been pressed
L
ed
E
ffects
::
onBoardLEDOn
();
l
ed
_e
ffects
::
onBoardLEDOn
();
delay
(
300
);
if
(
digitalRead
(
0
))
{
Serial
.
println
(
F
(
"Flash has been pressed for a short time. Should toggle night mode."
));
L
ed
E
ffects
::
toggleNightMode
();
l
ed
_e
ffects
::
toggleNightMode
();
}
else
{
Serial
.
println
(
F
(
"Flash has been pressed for a long time. Keep it pressed for calibration."
));
if
(
L
ed
E
ffects
::
countdownToZero
()
<
0
)
{
if
(
l
ed
_e
ffects
::
countdownToZero
()
<
0
)
{
sensor
::
startCalibrationProcess
();
}
}
L
ed
E
ffects
::
onBoardLEDOff
();
l
ed
_e
ffects
::
onBoardLEDOff
();
}
}
...
...
ampel-firmware/co2_sensor.cpp
View file @
8b7f81e4
...
...
@@ -44,7 +44,7 @@ namespace sensor {
if
(
scd30
.
begin
(
config
::
auto_calibrate_sensor
)
==
false
)
{
Serial
.
println
(
"Air sensor not detected. Please check wiring. Freezing..."
);
while
(
1
)
{
L
ed
E
ffects
::
showWaitingLED
(
color
::
red
);
l
ed
_e
ffects
::
showWaitingLED
(
color
::
red
);
}
}
...
...
@@ -129,7 +129,7 @@ namespace sensor {
void
displayCO2OnLedRing
()
{
if
(
co2
<
250
)
{
// Sensor should be calibrated.
L
ed
E
ffects
::
showWaitingLED
(
color
::
magenta
);
l
ed
_e
ffects
::
showWaitingLED
(
color
::
magenta
);
return
;
}
/**
...
...
@@ -137,11 +137,11 @@ namespace sensor {
* Those effects include a short delay.
*/
if
(
co2
<
2000
)
{
L
ed
E
ffects
::
displayCO2color
(
co2
);
L
ed
E
ffects
::
breathe
(
co2
);
l
ed
_e
ffects
::
displayCO2color
(
co2
);
l
ed
_e
ffects
::
breathe
(
co2
);
}
else
{
// >= 2000: entire ring blinks red
L
ed
E
ffects
::
redAlert
();
l
ed
_e
ffects
::
redAlert
();
}
}
...
...
@@ -162,7 +162,7 @@ namespace sensor {
//NOTE: Data is available, but it's sometimes erroneous: the sensor outputs zero ppm but non-zero temperature and non-zero humidity.
if
(
co2
<=
0
)
{
// No measurement yet. Waiting.
L
ed
E
ffects
::
showWaitingLED
(
color
::
blue
);
l
ed
_e
ffects
::
showWaitingLED
(
color
::
blue
);
return
false
;
}
...
...
@@ -180,7 +180,7 @@ namespace sensor {
if
(
stable_measurements
==
60
)
{
calibrateAndRestart
();
}
L
ed
E
ffects
::
showWaitingLED
(
waiting_color
);
l
ed
_e
ffects
::
showWaitingLED
(
waiting_color
);
return
false
;
}
...
...
ampel-firmware/csv_writer.cpp
View file @
8b7f81e4
...
...
@@ -135,7 +135,7 @@ namespace csv_writer {
}
void
log
(
const
String
&
timeStamp
,
const
int16_t
&
co2
,
const
float
&
temperature
,
const
float
&
humidity
)
{
L
ed
E
ffects
::
onBoardLEDOn
();
l
ed
_e
ffects
::
onBoardLEDOn
();
File
csv_file
=
openOrCreate
();
char
csv_line
[
42
];
snprintf
(
csv_line
,
sizeof
(
csv_line
),
"%s;%d;%.1f;%.1f
\r\n
"
,
timeStamp
.
c_str
(),
co2
,
temperature
,
humidity
);
...
...
@@ -155,7 +155,7 @@ namespace csv_writer {
//NOTE: Can it ever happen that outfile is false?
Serial
.
println
(
F
(
"Problem on create file!"
));
}
L
ed
E
ffects
::
onBoardLEDOff
();
l
ed
_e
ffects
::
onBoardLEDOff
();
}
void
logIfTimeHasCome
(
const
String
&
timeStamp
,
const
int16_t
&
co2
,
const
float
&
temperature
,
const
float
&
humidity
)
{
...
...
ampel-firmware/led_effects.cpp
View file @
8b7f81e4
...
...
@@ -33,7 +33,7 @@ const uint16_t CO2_TICKS[NUMPIXELS + 1] = { 0, 500, 600, 700, 800, 900, 1000, 12
const
uint16_t
LED_HUES
[
NUMPIXELS
]
=
{
21845
,
19114
,
16383
,
13653
,
10922
,
8191
,
5461
,
2730
,
0
,
0
,
0
,
0
};
// [hue angle]
Adafruit_NeoPixel
pixels
(
NUMPIXELS
,
NEOPIXELS_PIN
,
NEO_GRB
+
NEO_KHZ800
);
namespace
L
ed
E
ffects
{
namespace
l
ed
_e
ffects
{
//On-board LED on D4, aka GPIO02
const
int
ONBOARD_LED_PIN
=
2
;
...
...
ampel-firmware/led_effects.h
View file @
8b7f81e4
...
...
@@ -17,7 +17,7 @@ namespace color {
const
uint32_t
magenta
=
0xFF00FF
;
}
namespace
L
ed
E
ffects
{
namespace
l
ed
_e
ffects
{
void
setupOnBoardLED
();
void
onBoardLEDOff
();
void
onBoardLEDOn
();
...
...
ampel-firmware/mqtt.cpp
View file @
8b7f81e4
...
...
@@ -40,7 +40,7 @@ namespace mqtt {
void
publish
(
const
String
&
timestamp
,
int16_t
co2
,
float
temperature
,
float
humidity
)
{
if
(
WiFi
.
status
()
==
WL_CONNECTED
&&
mqttClient
.
connected
())
{
L
ed
E
ffects
::
onBoardLEDOn
();
l
ed
_e
ffects
::
onBoardLEDOn
();
Serial
.
print
(
F
(
"Publishing MQTT message ... "
));
char
payload
[
75
];
// Should be enough for json...
...
...
@@ -52,7 +52,7 @@ namespace mqtt {
}
else
{
Serial
.
println
(
F
(
"Failed."
));
}
L
ed
E
ffects
::
onBoardLEDOff
();
l
ed
_e
ffects
::
onBoardLEDOff
();
}
}
...
...
@@ -65,7 +65,7 @@ namespace mqtt {
Serial
.
println
(
"s."
);
sensor
::
scd30
.
setMeasurementInterval
(
messageString
.
toInt
());
config
::
measurement_timestep
=
messageString
.
toInt
();
L
ed
E
ffects
::
showKITTWheel
(
color
::
green
,
1
);
l
ed
_e
ffects
::
showKITTWheel
(
color
::
green
,
1
);
}
}
...
...
@@ -75,7 +75,7 @@ namespace mqtt {
Serial
.
print
(
F
(
"Setting Sending Interval to : "
));
Serial
.
print
(
config
::
sending_interval
);
Serial
.
println
(
"s."
);
L
ed
E
ffects
::
showKITTWheel
(
color
::
green
,
1
);
l
ed
_e
ffects
::
showKITTWheel
(
color
::
green
,
1
);
}
#ifdef AMPEL_CSV
...
...
@@ -85,7 +85,7 @@ namespace mqtt {
Serial
.
print
(
F
(
"Setting CSV Interval to : "
));
Serial
.
print
(
config
::
csv_interval
);
Serial
.
println
(
"s."
);
L
ed
E
ffects
::
showKITTWheel
(
color
::
green
,
1
);
l
ed
_e
ffects
::
showKITTWheel
(
color
::
green
,
1
);
}
#endif
...
...
@@ -131,7 +131,7 @@ namespace mqtt {
if
(
length
==
0
)
{
return
;
}
L
ed
E
ffects
::
onBoardLEDOn
();
l
ed
_e
ffects
::
onBoardLEDOn
();
Serial
.
print
(
F
(
"Message arrived on topic: "
));
Serial
.
print
(
sub_topic
);
Serial
.
print
(
F
(
". Message: '"
));
...
...
@@ -160,20 +160,20 @@ namespace mqtt {
setCSVinterval
(
messageString
);
}
else
if
(
messageString
==
"format_filesystem"
)
{
FS_LIB
.
format
();
L
ed
E
ffects
::
showKITTWheel
(
color
::
blue
,
2
);
l
ed
_e
ffects
::
showKITTWheel
(
color
::
blue
,
2
);
#endif
}
else
if
(
messageString
==
"night_mode"
)
{
L
ed
E
ffects
::
toggleNightMode
();
l
ed
_e
ffects
::
toggleNightMode
();
}
else
if
(
messageString
==
"local_ip"
)
{
sendInfoAboutLocalNetwork
();
}
else
if
(
messageString
==
"reset"
)
{
resetAmpel
();
}
else
{
L
ed
E
ffects
::
showKITTWheel
(
color
::
red
,
1
);
l
ed
_e
ffects
::
showKITTWheel
(
color
::
red
,
1
);
Serial
.
println
(
F
(
"Message not supported. Doing nothing."
));
}
delay
(
50
);
L
ed
E
ffects
::
onBoardLEDOff
();
l
ed
_e
ffects
::
onBoardLEDOff
();
}
void
reconnect
()
{
...
...
@@ -187,10 +187,10 @@ namespace mqtt {
}
Serial
.
print
(
F
(
"Attempting MQTT connection..."
));
L
ed
E
ffects
::
onBoardLEDOn
();
l
ed
_e
ffects
::
onBoardLEDOn
();
// Wait for connection, at most 15s (default)
mqttClient
.
connect
(
publish_topic
.
c_str
(),
config
::
mqtt_user
,
config
::
mqtt_password
);
L
ed
E
ffects
::
onBoardLEDOff
();
l
ed
_e
ffects
::
onBoardLEDOff
();
connected
=
mqttClient
.
connected
();
...
...
ampel-firmware/util.cpp
View file @
8b7f81e4
...
...
@@ -43,7 +43,7 @@ void resetAmpel() {
#ifdef AMPEL_CSV
FS_LIB
.
end
();
#endif
L
ed
E
ffects
::
LEDsOff
();
l
ed
_e
ffects
::
LEDsOff
();
delay
(
1000
);
ESP
.
restart
();
}
...
...
ampel-firmware/wifi_util.cpp
View file @
8b7f81e4
...
...
@@ -29,16 +29,16 @@ void WiFiConnect(const String &hostname) {
// Wait for connection, at most wifi_timeout seconds
for
(
int
i
=
0
;
i
<=
config
::
wifi_timeout
&&
(
WiFi
.
status
()
!=
WL_CONNECTED
);
i
++
)
{
L
ed
E
ffects
::
showRainbowWheel
();
l
ed
_e
ffects
::
showRainbowWheel
();
Serial
.
print
(
"."
);
}
if
(
WiFi
.
status
()
==
WL_CONNECTED
)
{
L
ed
E
ffects
::
showKITTWheel
(
color
::
green
);
l
ed
_e
ffects
::
showKITTWheel
(
color
::
green
);
Serial
.
println
();
Serial
.
print
(
"
\n
WiFi connected, IP address: "
);
Serial
.
println
(
WiFi
.
localIP
());
}
else
{
L
ed
E
ffects
::
showKITTWheel
(
color
::
red
);
l
ed
_e
ffects
::
showKITTWheel
(
color
::
red
);
Serial
.
println
(
"
\n
Connection to WiFi failed"
);
}
}
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