From 19efaca1d5f4ff2d5ab36ca83a430eca30891f47 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20K=C3=A4ppler?= <michael_kaeppler@web.de>
Date: Thu, 22 Apr 2021 22:47:38 +0200
Subject: [PATCH] co2_sensor: Disable state logging by default

---
 ampel-firmware/co2_sensor.cpp | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/ampel-firmware/co2_sensor.cpp b/ampel-firmware/co2_sensor.cpp
index 946e09b..51e5fcc 100644
--- a/ampel-firmware/co2_sensor.cpp
+++ b/ampel-firmware/co2_sensor.cpp
@@ -15,6 +15,7 @@ namespace config {
   const float temperature_offset = -3.0;  // [K] Temperature measured by sensor is usually at least 3K too high.
 #endif
   bool auto_calibrate_sensor = AUTO_CALIBRATE_SENSOR; // [true / false]
+  const bool debug_sensor_states = false; // If true, log state transitions over serial console
 }
 
 namespace sensor {
@@ -172,10 +173,12 @@ namespace sensor {
 
   void switchState(state new_state) {
     if (new_state == current_state) return;
-    Serial.print(F("Changing sensor state: "));
-    Serial.print(state_names[current_state]);
-    Serial.print(" -> ");
-    Serial.println(state_names[new_state]);
+    if (config::debug_sensor_states) {
+      Serial.print(F("Changing sensor state: "));
+      Serial.print(state_names[current_state]);
+      Serial.print(" -> ");
+      Serial.println(state_names[new_state]);
+    }
     current_state = new_state;
   }
 
-- 
GitLab