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
2e99fa40
Commit
2e99fa40
authored
Dec 26, 2020
by
Eric Duminil
Browse files
Pass by reference
parent
0d9e1e2b
Changes
2
Show whitespace changes
Inline
Side-by-side
csv_writer.cpp
View file @
2e99fa40
...
...
@@ -134,15 +134,11 @@ namespace csv_writer {
return
csv_file
;
}
void
logIfTimeHasCome
(
const
String
&
timeStamp
,
int16_t
co2
,
float
temp
,
float
hum
)
{
unsigned
long
now
=
seconds
();
//TODO: Write average since last CSV write?
if
(
now
-
last_written_at
>
config
::
csv_interval
)
{
last_written_at
=
now
;
void
log
(
const
String
&
timeStamp
,
const
int16_t
&
co2
,
const
float
&
temperature
,
const
float
&
humidity
)
{
LedEffects
::
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
,
temp
,
hum
);
snprintf
(
csv_line
,
sizeof
(
csv_line
),
"%s;%d;%.1f;%.1f
\r\n
"
,
timeStamp
.
c_str
(),
co2
,
temp
erature
,
humidity
);
if
(
csv_file
)
{
size_t
written_bytes
=
csv_file
.
print
(
csv_line
);
csv_file
.
close
();
...
...
@@ -161,5 +157,13 @@ namespace csv_writer {
}
LedEffects
::
onBoardLEDOff
();
}
void
logIfTimeHasCome
(
const
String
&
timeStamp
,
const
int16_t
&
co2
,
const
float
&
temperature
,
const
float
&
humidity
)
{
unsigned
long
now
=
seconds
();
//TODO: Write average since last CSV write?
if
(
now
-
last_written_at
>
config
::
csv_interval
)
{
last_written_at
=
now
;
log
(
timeStamp
,
co2
,
temperature
,
humidity
);
}
}
}
csv_writer.h
View file @
2e99fa40
...
...
@@ -19,7 +19,7 @@ namespace config {
namespace
csv_writer
{
extern
String
last_successful_write
;
void
initialize
();
void
logIfTimeHasCome
(
const
String
&
timeStamp
,
int16_t
co2
,
float
temp
,
float
hum
);
void
logIfTimeHasCome
(
const
String
&
timeStamp
,
const
int16_t
&
co2
,
const
float
&
temp
erature
,
const
float
&
hum
idity
);
int
getAvailableSpace
();
extern
const
String
filename
;
}
...
...
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