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
9b11a49b
Commit
9b11a49b
authored
Dec 21, 2020
by
Eric Duminil
Browse files
reset() refactor
parent
316d13bc
Changes
7
Hide whitespace changes
Inline
Side-by-side
co2_sensor.cpp
View file @
9b11a49b
...
...
@@ -70,7 +70,7 @@ namespace sensor {
Serial
.
println
(
config
::
auto_calibrate_sensor
?
"ON."
:
"OFF."
);
}
//NOTE: should time offset be used to
rese
t measurement_timestep?
//NOTE: should time offset be used to
adjus
t measurement_timestep?
void
checkTimerDeviation
()
{
static
int32_t
previous_measurement_at
=
0
;
int32_t
now
=
millis
();
...
...
@@ -124,11 +124,7 @@ namespace sensor {
scd30
.
setForcedRecalibrationFactor
(
config
::
co2_calibration_level
);
Serial
.
println
(
F
(
" Done!"
));
Serial
.
println
(
F
(
"Sensor calibrated."
));
Serial
.
println
(
F
(
"Sensor will now restart."
));
LedEffects
::
showKITTWheel
(
color
::
green
,
5
);
//TODO: Add LEDs off and move to util::reset()
FS_LIB
.
end
();
ESP
.
restart
();
resetAmpel
();
}
void
logToSerial
()
{
...
...
co2_sensor.h
View file @
9b11a49b
...
...
@@ -6,6 +6,7 @@
#include
"src/lib/SparkFun_SCD30_Arduino_Library/src/SparkFun_SCD30_Arduino_Library.h"
// From: http://librarymanager/All#SparkFun_SCD30
#include
"config.h"
#include
"led_effects.h"
#include
"util.h"
#include
"csv_writer.h"
// To close filesystem before restart.
#include
<Wire.h>
...
...
led_effects.cpp
View file @
9b11a49b
...
...
@@ -11,7 +11,7 @@ namespace config {
/*****************************************************************
* Configuration (calculated from above values) *
*****************************************************************/
namespace
config
//TODO: Use a class instead. NightMode could then be another state.
namespace
config
//TODO: Use a class instead. NightMode could then be another state.
{
const
float
average_brightness
=
0.5
*
(
config
::
max_brightness
+
config
::
min_brightness
);
const
float
brightness_amplitude
=
0.5
*
(
config
::
max_brightness
-
config
::
min_brightness
);
...
...
@@ -38,7 +38,7 @@ namespace counter {
uint16_t
wheel_offset
=
0
;
uint16_t
kitt_offset
=
0
;
uint16_t
breathing_offset
=
0
;
}
// namespace counter
}
namespace
LedEffects
{
//On-board LED on D4, aka GPIO02
...
...
@@ -56,18 +56,23 @@ namespace LedEffects {
digitalWrite
(
ONBOARD_LED_PIN
,
LOW
);
}
void
LEDsOff
()
{
pixels
.
clear
();
pixels
.
show
();
onBoardLEDOff
();
}
void
setupRing
()
{
pixels
.
begin
();
pixels
.
setBrightness
(
config
::
max_brightness
);
pixels
.
clear
();
LEDsOff
();
}
void
toggleNightMode
()
{
config
::
night_mode
=
!
config
::
night_mode
;
if
(
config
::
night_mode
)
{
Serial
.
println
(
F
(
"NIGHT MODE!"
));
pixels
.
clear
();
pixels
.
show
();
LEDsOff
();
}
else
{
Serial
.
println
(
F
(
"DAY MODE!"
));
}
...
...
@@ -172,7 +177,7 @@ namespace LedEffects {
pixels
.
show
();
counter
::
breathing_offset
+=
1
;
}
delay
(
co2
>
1600
?
50
:
100
);
// faster breathing for higher CO2 values
delay
(
co2
>
1600
?
50
:
100
);
// faster breathing for higher CO2 values
}
/**
...
...
led_effects.h
View file @
9b11a49b
...
...
@@ -22,6 +22,7 @@ namespace LedEffects {
void
onBoardLEDOff
();
void
onBoardLEDOn
();
void
toggleNightMode
();
void
LEDsOff
();
void
setupRing
();
void
redAlert
();
...
...
mqtt.cpp
View file @
9b11a49b
...
...
@@ -162,8 +162,7 @@ namespace mqtt {
}
else
if
(
messageString
==
"local_ip"
)
{
sendInfoAboutLocalNetwork
();
}
else
if
(
messageString
==
"reset"
)
{
FS_LIB
.
end
();
ESP
.
restart
();
resetAmpel
();
}
else
{
LedEffects
::
showKITTWheel
(
color
::
red
,
1
);
Serial
.
println
(
F
(
"Message not supported. Doing nothing."
));
...
...
util.cpp
View file @
9b11a49b
...
...
@@ -38,6 +38,14 @@ namespace ntp {
}
}
void
resetAmpel
()
{
Serial
.
print
(
"Resetting"
);
FS_LIB
.
end
();
LedEffects
::
LEDsOff
();
delay
(
1000
);
ESP
.
restart
();
}
uint32_t
max_loop_duration
=
0
;
//FIXME: Remove every instance of Strings, to avoid heap fragmentation problems. (Start: "Free heap space : 17104 bytes")
...
...
util.h
View file @
9b11a49b
...
...
@@ -3,6 +3,7 @@
#include
<Arduino.h>
#include
"config.h"
#include
"wifi_util.h"
// To get MAC
#include
"csv_writer.h"
// To close filesystem before reset
#include
<WiFiUdp.h>
//required for NTP
#include
"src/lib/NTPClient-master/NTPClient.h"
// NTP
...
...
@@ -27,4 +28,6 @@ namespace ntp {
extern
uint32_t
max_loop_duration
;
const
extern
String
SENSOR_ID
;
void
resetAmpel
();
#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