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
f4b28201
Commit
f4b28201
authored
Jun 29, 2021
by
Eric Duminil
Browse files
Merge branch 'develop'
parents
64da8b35
278a1ce7
Pipeline
#4516
passed with stage
in 2 minutes and 39 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
f4b28201
...
...
@@ -85,7 +85,7 @@ In Arduino IDE *Serial Monitor* or PlatformIO *Monitor*, type `help` + <kbd>Ente
*
`lora 300`
(Sets LoRaWAN sending interval, in s).
*
`mqtt 60`
(Sets MQTT sending interval, in s).
*
`night_mode`
(Toggles night mode on/off).
*
`reset`
(Restarts the
sensor
).
*
`reset`
(Restarts the
ESP
).
*
`reset_scd`
(Resets SCD30).
*
`send_local_ip`
(Sends local IP and SSID via MQTT. Can be useful to find sensor).
*
`set_time 1618829570`
(Sets time to the given UNIX time).
...
...
ampel-firmware/ampel-firmware.ino
View file @
f4b28201
...
...
@@ -189,8 +189,10 @@ void checkFlashButton() {
led_effects
::
toggleNightMode
();
}
else
{
Serial
.
println
(
F
(
"Flash has been pressed for a long time. Keep it pressed for calibration."
));
if
(
led_effects
::
countdownToZero
()
<
0
)
{
if
(
led_effects
::
countdownToZero
())
{
Serial
.
println
(
F
(
"You can now release the button."
));
sensor
::
startCalibrationProcess
();
led_effects
::
showKITTWheel
(
color
::
red
,
2
);
}
}
led_effects
::
onBoardLEDOff
();
...
...
ampel-firmware/co2_sensor.cpp
View file @
f4b28201
...
...
@@ -10,6 +10,7 @@ namespace config {
const
int8_t
max_deviation_during_calibration
=
30
;
// [ppm]
const
int16_t
timestep_during_calibration
=
10
;
// [s] WARNING: Measurements can be unreliable for timesteps shorter than 10s.
const
int8_t
stable_measurements_before_calibration
=
120
/
timestep_during_calibration
;
// [-] Stable measurements during at least 2 minutes.
const
uint16_t
co2_alert_threshold
=
2000
;
// [ppm] Display a flashing led ring, if concentration exceeds this value
#ifdef TEMPERATURE_OFFSET
// Residual heat from CO2 sensor seems to be high enough to change the temperature reading. How much should it be offset?
...
...
@@ -227,11 +228,11 @@ namespace sensor {
* A short delay is required in order to let background tasks run on the ESP8266.
* see https://github.com/esp8266/Arduino/issues/3241#issuecomment-301290392
*/
if
(
co2
<
2000
)
{
if
(
co2
<
config
::
co2_alert_threshold
)
{
led_effects
::
displayCO2color
(
co2
);
delay
(
100
);
}
else
{
//
>= 2000: entire ring blinks red
//
Display a flashing led ring, if concentration exceeds a specific value
led_effects
::
redAlert
();
}
}
...
...
ampel-firmware/led_effects.cpp
View file @
f4b28201
...
...
@@ -211,14 +211,17 @@ namespace led_effects {
}
/**
* 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.
* Displays a complete blue circle, and starts removing LEDs one by one.
* Does nothing in night mode and returns false then. Returns true if
* the countdown has finished. Can be used for calibration, e.g. when countdown is 0.
* NOTE: This function is blocking and returns only after the button has
* been released or after every LED has been turned off.
*/
int
countdownToZero
()
{
bool
countdownToZero
()
{
if
(
config
::
night_mode
)
{
Serial
.
println
(
F
(
"Night mode. Not doing anything."
));
delay
(
1000
);
// Wait for a while, to avoid coming back to this function too many times when button is pressed.
return
1
;
return
false
;
}
pixels
.
fill
(
color
::
blue
);
pixels
.
show
();
...
...
@@ -229,6 +232,6 @@ namespace led_effects {
Serial
.
println
(
countdown
);
delay
(
500
);
}
return
countdown
;
return
countdown
<
0
;
}
}
ampel-firmware/led_effects.h
View file @
f4b28201
...
...
@@ -26,7 +26,7 @@ namespace led_effects {
void
setupRing
();
void
redAlert
();
int
countdownToZero
();
bool
countdownToZero
();
void
showWaitingLED
(
uint32_t
color
);
void
showKITTWheel
(
uint32_t
color
,
uint16_t
duration_s
=
2
);
void
showRainbowWheel
(
uint16_t
duration_ms
=
1000
);
...
...
ampel-firmware/util.cpp
View file @
f4b28201
...
...
@@ -85,7 +85,7 @@ Ampel::Ampel() :
sensor_console
::
defineCommand
(
"free"
,
Ampel
::
showFreeSpace
,
F
(
"(Displays available heap space)"
));
sensor_console
::
defineCommand
(
"reset"
,
[]()
{
ESP
.
restart
();
},
F
(
"(Restarts the
sensor
)"
));
},
F
(
"(Restarts the
ESP
)"
));
}
Ampel
ampel
;
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