Commit 903ec7a9 authored by Eric Duminil's avatar Eric Duminil
Browse files

Slight refactor

parent 110a1a8a
Pipeline #5801 passed with stage
in 2 minutes and 31 seconds
......@@ -5,17 +5,13 @@
*****************************************************************/
//NOTE: Too many headers. Move them to include/ folder?
// Needed for offline config too.
#include "config.h" //TODO: Replace with just web_config
#include "web_config.h"
#include "web_config.h" // Needed for offline config too.
#include "csv_writer.h"
#include "wifi_util.h"
#include "mqtt.h"
#if (AMPEL_HTTP==1) //TODO: Is it still needed?
# include "web_server.h"
#endif
#include "web_server.h"
#include "lorawan.h"
......
......@@ -94,7 +94,7 @@ void setup() {
led_effects::setupOnBoardLED();
led_effects::onBoardLEDOff();
Serial.begin(BAUDS);
Serial.begin(config::bauds);
web_config::initialize();
......@@ -122,9 +122,7 @@ void setup() {
if (config::wifi_active) {
wifi::defineCommands();
# if (AMPEL_HTTP==1)
web_server::definePages();
# endif
}
#if defined(ESP32)
......@@ -211,6 +209,7 @@ void checkFlashButton() {
if (digitalRead(0)) {
Serial.println(F("Flash has been pressed for a short time. Should toggle night mode."));
led_effects::toggleNightMode();
//NOTE: Start Access Point instead?
} else {
Serial.println(F("Flash has been pressed for a long time. Keep it pressed for calibration."));
if (led_effects::countdownToZero()) {
......
......@@ -9,7 +9,6 @@
// Define the default for corresponding services. They can be enabled/disabled later in the web-config.
# define AMPEL_WIFI true // Should ESP connect to WiFi? It allows the Ampel to get time from an NTP server.
# define AMPEL_HTTP true // Should HTTP web server be started? (AMPEL_WIFI should be enabled too)
# define AMPEL_MQTT true // Should data be sent over MQTT? (AMPEL_WIFI should be enabled too)
# define AMPEL_CSV true // Should data be logged as CSV, on the ESP flash memory?
# define AMPEL_LORAWAN false // Should data be sent over LoRaWAN? (Requires ESP32 + LoRa modem, and "MCCI LoRaWAN LMIC library")
......@@ -148,9 +147,4 @@
# define NTP_SERVER "pool.ntp.org"
# define UTC_OFFSET_IN_SECONDS 7200 // [s] 3600 for UTC+1, 7200 for UTC+1 and daylight saving time
/**
* Others
*/
# define BAUDS 115200 // Transmission rate
#endif
......@@ -10,7 +10,12 @@
#endif
namespace config {
void save(); // Save config to EEPROM
// WiFi
char* selected_ssid();
extern bool &wifi_active; // [true / false]
// Sensor
extern uint16_t &measurement_timestep; // [s] Value between 2 and 1800 (range for SCD30 sensor).
extern uint16_t &altitude_above_sea_level; // [m]
......@@ -18,9 +23,6 @@ namespace config {
extern bool &auto_calibrate_sensor; // [true / false]
extern float &temperature_offset; // [K] Sign isn't relevant.
extern bool &wifi_active; // [true / false]
void save(); // Save config to EEPROM
// LED
extern uint8_t &max_brightness;
extern uint8_t &min_brightness;
......@@ -49,6 +51,9 @@ namespace config {
#if defined(ESP32)
bool lorawan_active(); // also defined for ESP8266, and set to false
#endif
// Transmission rate
constexpr uint32_t bauds = 115200;
}
namespace web_config {
......
Markdown is supported
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