From 9f6604b190ca5b5fb7745cb291c345b98359f151 Mon Sep 17 00:00:00 2001
From: Eric Duminil <eric.duminil@gmail.com>
Date: Wed, 21 Apr 2021 12:07:58 +0200
Subject: [PATCH] Headers refactor.

---
 ampel-firmware/ampel-firmware.h   | 4 ----
 ampel-firmware/ampel-firmware.ino | 7 +++++++
 ampel-firmware/mqtt.h             | 2 ++
 ampel-firmware/sensor_console.h   | 5 +++--
 ampel-firmware/util.h             | 3 ++-
 5 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/ampel-firmware/ampel-firmware.h b/ampel-firmware/ampel-firmware.h
index 629e180..41fe46b 100644
--- a/ampel-firmware/ampel-firmware.h
+++ b/ampel-firmware/ampel-firmware.h
@@ -37,8 +37,4 @@
 #include "co2_sensor.h"
 #include "led_effects.h"
 
-void keepServicesAlive();
-void checkFlashButton();
-void checkSerialInput();
-
 #endif
diff --git a/ampel-firmware/ampel-firmware.ino b/ampel-firmware/ampel-firmware.ino
index df16f22..8d04504 100644
--- a/ampel-firmware/ampel-firmware.ino
+++ b/ampel-firmware/ampel-firmware.ino
@@ -122,6 +122,13 @@ void setup() {
 #endif
 }
 
+/*****************************************************************
+ * Helper functions                                              *
+ *****************************************************************/
+void keepServicesAlive();
+void checkFlashButton();
+void checkSerialInput();
+
 /*****************************************************************
  * Main loop                                                     *
  *****************************************************************/
diff --git a/ampel-firmware/mqtt.h b/ampel-firmware/mqtt.h
index fb769d6..4d10883 100644
--- a/ampel-firmware/mqtt.h
+++ b/ampel-firmware/mqtt.h
@@ -7,9 +7,11 @@
 #include "sensor_console.h"
 #include "src/lib/PubSubClient/src/PubSubClient.h"
 #include "wifi_util.h"
+
 namespace config {
   extern uint16_t mqtt_sending_interval; // [s]
 }
+
 namespace mqtt {
   extern char last_successful_publish[];
   extern bool connected;
diff --git a/ampel-firmware/sensor_console.h b/ampel-firmware/sensor_console.h
index e152414..b46e212 100644
--- a/ampel-firmware/sensor_console.h
+++ b/ampel-firmware/sensor_console.h
@@ -8,10 +8,11 @@
  */
 
 namespace sensor_console {
+  void defineCommand(const char *command, void (*function)(void), const __FlashStringHelper *ifsh);
+  void defineIntCommand(const char *command, void (*function)(int32_t), const __FlashStringHelper *ifsh);
+
   void processSerialInput(const byte in_byte);
   void runCommand(const char *command);
-  void defineIntCommand(const char *command, void (*function)(int32_t), const __FlashStringHelper *ifsh);
-  void defineCommand(const char *command, void (*function)(void), const __FlashStringHelper *ifsh);
 }
 
 #endif
diff --git a/ampel-firmware/util.h b/ampel-firmware/util.h
index a267333..093cf28 100644
--- a/ampel-firmware/util.h
+++ b/ampel-firmware/util.h
@@ -42,8 +42,9 @@ public:
   Ampel();
 };
 
+extern Ampel ampel;
+
 //NOTE: Only use seconds() for duration comparison, not timestamps comparison. Otherwise, problems happen when millis roll over.
 #define seconds() (millis() / 1000UL)
-extern Ampel ampel;
 
 #endif
-- 
GitLab