Commit 2e99fa40 authored by Eric Duminil's avatar Eric Duminil
Browse files

Pass by reference

parent 0d9e1e2b
......@@ -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, temperature, 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);
}
}
}
......@@ -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 &temperature, const float &humidity);
int getAvailableSpace();
extern const String filename;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment