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
7b84ec1d
Commit
7b84ec1d
authored
Apr 24, 2021
by
Eric Duminil
Browse files
co2_sensor: Eclipse Auto-formatting (K&R)
parent
19efaca1
Changes
1
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/co2_sensor.cpp
View file @
7b84ec1d
...
...
@@ -43,22 +43,22 @@ namespace sensor {
NEEDSCALIBRATION
,
PREPARECALIBRATION_INSTABLE
,
PREPARECALIBRATION_STABLE
,
CALIBRATION
};
const
char
*
state_names
[]
=
{
"INITIAL"
,
"BOOTUP"
,
"READY"
,
"NEEDSCALIBRATION"
,
"PREPARECALIBRATION_INSTABLE"
,
"PREPARECALIBRATION_STABLE"
,
"CALIBRATION"
CALIBRATION
};
const
char
*
state_names
[]
=
{
"INITIAL"
,
"BOOTUP"
,
"READY"
,
"NEEDSCALIBRATION"
,
"PREPARECALIBRATION_INSTABLE"
,
"PREPARECALIBRATION_STABLE"
,
"CALIBRATION"
};
state
current_state
=
INITIAL
;
void
switchState
(
state
);
void
initialize
()
{
#if defined(ESP8266)
Wire
.
begin
(
12
,
14
);
// ESP8266 - D6, D5;
Wire
.
begin
(
12
,
14
);
// ESP8266 - D6, D5;
#endif
#if defined(ESP32)
Wire
.
begin
(
21
,
22
);
// ESP32
...
...
@@ -172,7 +172,9 @@ namespace sensor {
}
void
switchState
(
state
new_state
)
{
if
(
new_state
==
current_state
)
return
;
if
(
new_state
==
current_state
)
{
return
;
}
if
(
config
::
debug_sensor_states
)
{
Serial
.
print
(
F
(
"Changing sensor state: "
));
Serial
.
print
(
state_names
[
current_state
]);
...
...
@@ -198,18 +200,28 @@ namespace sensor {
}
void
showState
()
{
switch
(
current_state
)
{
case
BOOTUP
:
led_effects
::
showWaitingLED
(
color
::
blue
);
break
;
switch
(
current_state
)
{
case
BOOTUP
:
led_effects
::
showWaitingLED
(
color
::
blue
);
break
;
// No special signaling, we want to show the CO2 value
case
READY
:
break
;
case
NEEDSCALIBRATION
:
led_effects
::
showWaitingLED
(
color
::
magenta
);
break
;
case
PREPARECALIBRATION_INSTABLE
:
led_effects
::
showWaitingLED
(
color
::
red
);
break
;
case
PREPARECALIBRATION_STABLE
:
led_effects
::
showWaitingLED
(
color
::
green
);
break
;
case
READY
:
break
;
case
NEEDSCALIBRATION
:
led_effects
::
showWaitingLED
(
color
::
magenta
);
break
;
case
PREPARECALIBRATION_INSTABLE
:
led_effects
::
showWaitingLED
(
color
::
red
);
break
;
case
PREPARECALIBRATION_STABLE
:
led_effects
::
showWaitingLED
(
color
::
green
);
break
;
// No special signaling here, too.
case
CALIBRATION
:
break
;
case
CALIBRATION
:
break
;
// This should not happen.
default:
Serial
.
println
(
F
(
"Encountered unknown sensor state"
));
default:
Serial
.
println
(
F
(
"Encountered unknown sensor state"
));
}
}
...
...
@@ -231,8 +243,7 @@ namespace sensor {
// zero ppm but non-zero temperature and non-zero humidity.
Serial
.
println
(
F
(
"Invalid sensor data - CO2 concentration <= 0 ppm"
));
switchState
(
BOOTUP
);
}
else
if
((
current_state
==
PREPARECALIBRATION_INSTABLE
)
||
(
current_state
==
PREPARECALIBRATION_STABLE
))
{
}
else
if
((
current_state
==
PREPARECALIBRATION_INSTABLE
)
||
(
current_state
==
PREPARECALIBRATION_STABLE
))
{
// Check for pre-calibration states first, because we do not want to
// leave them before calibration is done.
bool
ready_for_calibration
=
countStableMeasurements
();
...
...
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