Commit 8b7f81e4 authored by Eric Duminil's avatar Eric Duminil
Browse files

Renaming led_effects namespace for consistency

parent 3bfda294
...@@ -59,14 +59,14 @@ ...@@ -59,14 +59,14 @@
* Setup * * Setup *
*****************************************************************/ *****************************************************************/
void setup() { void setup() {
LedEffects::setupOnBoardLED(); led_effects::setupOnBoardLED();
LedEffects::onBoardLEDOff(); led_effects::onBoardLEDOff();
Serial.begin(BAUDS); Serial.begin(BAUDS);
pinMode(0, INPUT); // Flash button (used for forced calibration) pinMode(0, INPUT); // Flash button (used for forced calibration)
LedEffects::setupRing(); led_effects::setupRing();
sensor::initialize(); sensor::initialize();
...@@ -165,18 +165,18 @@ void loop() { ...@@ -165,18 +165,18 @@ void loop() {
*/ */
void checkFlashButton() { void checkFlashButton() {
if (!digitalRead(0)) { // Button has been pressed if (!digitalRead(0)) { // Button has been pressed
LedEffects::onBoardLEDOn(); led_effects::onBoardLEDOn();
delay(300); delay(300);
if (digitalRead(0)) { if (digitalRead(0)) {
Serial.println(F("Flash has been pressed for a short time. Should toggle night mode.")); Serial.println(F("Flash has been pressed for a short time. Should toggle night mode."));
LedEffects::toggleNightMode(); led_effects::toggleNightMode();
} else { } else {
Serial.println(F("Flash has been pressed for a long time. Keep it pressed for calibration.")); Serial.println(F("Flash has been pressed for a long time. Keep it pressed for calibration."));
if (LedEffects::countdownToZero() < 0) { if (led_effects::countdownToZero() < 0) {
sensor::startCalibrationProcess(); sensor::startCalibrationProcess();
} }
} }
LedEffects::onBoardLEDOff(); led_effects::onBoardLEDOff();
} }
} }
......
...@@ -44,7 +44,7 @@ namespace sensor { ...@@ -44,7 +44,7 @@ namespace sensor {
if (scd30.begin(config::auto_calibrate_sensor) == false) { if (scd30.begin(config::auto_calibrate_sensor) == false) {
Serial.println("Air sensor not detected. Please check wiring. Freezing..."); Serial.println("Air sensor not detected. Please check wiring. Freezing...");
while (1) { while (1) {
LedEffects::showWaitingLED(color::red); led_effects::showWaitingLED(color::red);
} }
} }
...@@ -129,7 +129,7 @@ namespace sensor { ...@@ -129,7 +129,7 @@ namespace sensor {
void displayCO2OnLedRing() { void displayCO2OnLedRing() {
if (co2 < 250) { if (co2 < 250) {
// Sensor should be calibrated. // Sensor should be calibrated.
LedEffects::showWaitingLED(color::magenta); led_effects::showWaitingLED(color::magenta);
return; return;
} }
/** /**
...@@ -137,11 +137,11 @@ namespace sensor { ...@@ -137,11 +137,11 @@ namespace sensor {
* Those effects include a short delay. * Those effects include a short delay.
*/ */
if (co2 < 2000) { if (co2 < 2000) {
LedEffects::displayCO2color(co2); led_effects::displayCO2color(co2);
LedEffects::breathe(co2); led_effects::breathe(co2);
} else { } else {
// >= 2000: entire ring blinks red // >= 2000: entire ring blinks red
LedEffects::redAlert(); led_effects::redAlert();
} }
} }
...@@ -162,7 +162,7 @@ namespace sensor { ...@@ -162,7 +162,7 @@ namespace sensor {
//NOTE: Data is available, but it's sometimes erroneous: the sensor outputs zero ppm but non-zero temperature and non-zero humidity. //NOTE: Data is available, but it's sometimes erroneous: the sensor outputs zero ppm but non-zero temperature and non-zero humidity.
if (co2 <= 0) { if (co2 <= 0) {
// No measurement yet. Waiting. // No measurement yet. Waiting.
LedEffects::showWaitingLED(color::blue); led_effects::showWaitingLED(color::blue);
return false; return false;
} }
...@@ -180,7 +180,7 @@ namespace sensor { ...@@ -180,7 +180,7 @@ namespace sensor {
if (stable_measurements == 60) { if (stable_measurements == 60) {
calibrateAndRestart(); calibrateAndRestart();
} }
LedEffects::showWaitingLED(waiting_color); led_effects::showWaitingLED(waiting_color);
return false; return false;
} }
......
...@@ -135,7 +135,7 @@ namespace csv_writer { ...@@ -135,7 +135,7 @@ namespace csv_writer {
} }
void log(const String &timeStamp, const int16_t &co2, const float &temperature, const float &humidity) { void log(const String &timeStamp, const int16_t &co2, const float &temperature, const float &humidity) {
LedEffects::onBoardLEDOn(); led_effects::onBoardLEDOn();
File csv_file = openOrCreate(); File csv_file = openOrCreate();
char csv_line[42]; char csv_line[42];
snprintf(csv_line, sizeof(csv_line), "%s;%d;%.1f;%.1f\r\n", timeStamp.c_str(), co2, temperature, humidity); snprintf(csv_line, sizeof(csv_line), "%s;%d;%.1f;%.1f\r\n", timeStamp.c_str(), co2, temperature, humidity);
...@@ -155,7 +155,7 @@ namespace csv_writer { ...@@ -155,7 +155,7 @@ namespace csv_writer {
//NOTE: Can it ever happen that outfile is false? //NOTE: Can it ever happen that outfile is false?
Serial.println(F("Problem on create file!")); Serial.println(F("Problem on create file!"));
} }
LedEffects::onBoardLEDOff(); led_effects::onBoardLEDOff();
} }
void logIfTimeHasCome(const String &timeStamp, const int16_t &co2, const float &temperature, const float &humidity) { void logIfTimeHasCome(const String &timeStamp, const int16_t &co2, const float &temperature, const float &humidity) {
......
...@@ -33,7 +33,7 @@ const uint16_t CO2_TICKS[NUMPIXELS + 1] = { 0, 500, 600, 700, 800, 900, 1000, 12 ...@@ -33,7 +33,7 @@ const uint16_t CO2_TICKS[NUMPIXELS + 1] = { 0, 500, 600, 700, 800, 900, 1000, 12
const uint16_t LED_HUES[NUMPIXELS] = { 21845, 19114, 16383, 13653, 10922, 8191, 5461, 2730, 0, 0, 0, 0 }; // [hue angle] const uint16_t LED_HUES[NUMPIXELS] = { 21845, 19114, 16383, 13653, 10922, 8191, 5461, 2730, 0, 0, 0, 0 }; // [hue angle]
Adafruit_NeoPixel pixels(NUMPIXELS, NEOPIXELS_PIN, NEO_GRB + NEO_KHZ800); Adafruit_NeoPixel pixels(NUMPIXELS, NEOPIXELS_PIN, NEO_GRB + NEO_KHZ800);
namespace LedEffects { namespace led_effects {
//On-board LED on D4, aka GPIO02 //On-board LED on D4, aka GPIO02
const int ONBOARD_LED_PIN = 2; const int ONBOARD_LED_PIN = 2;
......
...@@ -17,7 +17,7 @@ namespace color { ...@@ -17,7 +17,7 @@ namespace color {
const uint32_t magenta = 0xFF00FF; const uint32_t magenta = 0xFF00FF;
} }
namespace LedEffects { namespace led_effects {
void setupOnBoardLED(); void setupOnBoardLED();
void onBoardLEDOff(); void onBoardLEDOff();
void onBoardLEDOn(); void onBoardLEDOn();
......
...@@ -40,7 +40,7 @@ namespace mqtt { ...@@ -40,7 +40,7 @@ namespace mqtt {
void publish(const String &timestamp, int16_t co2, float temperature, float humidity) { void publish(const String &timestamp, int16_t co2, float temperature, float humidity) {
if (WiFi.status() == WL_CONNECTED && mqttClient.connected()) { if (WiFi.status() == WL_CONNECTED && mqttClient.connected()) {
LedEffects::onBoardLEDOn(); led_effects::onBoardLEDOn();
Serial.print(F("Publishing MQTT message ... ")); Serial.print(F("Publishing MQTT message ... "));
char payload[75]; // Should be enough for json... char payload[75]; // Should be enough for json...
...@@ -52,7 +52,7 @@ namespace mqtt { ...@@ -52,7 +52,7 @@ namespace mqtt {
} else { } else {
Serial.println(F("Failed.")); Serial.println(F("Failed."));
} }
LedEffects::onBoardLEDOff(); led_effects::onBoardLEDOff();
} }
} }
...@@ -65,7 +65,7 @@ namespace mqtt { ...@@ -65,7 +65,7 @@ namespace mqtt {
Serial.println("s."); Serial.println("s.");
sensor::scd30.setMeasurementInterval(messageString.toInt()); sensor::scd30.setMeasurementInterval(messageString.toInt());
config::measurement_timestep = messageString.toInt(); config::measurement_timestep = messageString.toInt();
LedEffects::showKITTWheel(color::green, 1); led_effects::showKITTWheel(color::green, 1);
} }
} }
...@@ -75,7 +75,7 @@ namespace mqtt { ...@@ -75,7 +75,7 @@ namespace mqtt {
Serial.print(F("Setting Sending Interval to : ")); Serial.print(F("Setting Sending Interval to : "));
Serial.print(config::sending_interval); Serial.print(config::sending_interval);
Serial.println("s."); Serial.println("s.");
LedEffects::showKITTWheel(color::green, 1); led_effects::showKITTWheel(color::green, 1);
} }
#ifdef AMPEL_CSV #ifdef AMPEL_CSV
...@@ -85,7 +85,7 @@ namespace mqtt { ...@@ -85,7 +85,7 @@ namespace mqtt {
Serial.print(F("Setting CSV Interval to : ")); Serial.print(F("Setting CSV Interval to : "));
Serial.print(config::csv_interval); Serial.print(config::csv_interval);
Serial.println("s."); Serial.println("s.");
LedEffects::showKITTWheel(color::green, 1); led_effects::showKITTWheel(color::green, 1);
} }
#endif #endif
...@@ -131,7 +131,7 @@ namespace mqtt { ...@@ -131,7 +131,7 @@ namespace mqtt {
if (length == 0) { if (length == 0) {
return; return;
} }
LedEffects::onBoardLEDOn(); led_effects::onBoardLEDOn();
Serial.print(F("Message arrived on topic: ")); Serial.print(F("Message arrived on topic: "));
Serial.print(sub_topic); Serial.print(sub_topic);
Serial.print(F(". Message: '")); Serial.print(F(". Message: '"));
...@@ -160,20 +160,20 @@ namespace mqtt { ...@@ -160,20 +160,20 @@ namespace mqtt {
setCSVinterval(messageString); setCSVinterval(messageString);
} else if (messageString == "format_filesystem") { } else if (messageString == "format_filesystem") {
FS_LIB.format(); FS_LIB.format();
LedEffects::showKITTWheel(color::blue, 2); led_effects::showKITTWheel(color::blue, 2);
#endif #endif
} else if (messageString == "night_mode") { } else if (messageString == "night_mode") {
LedEffects::toggleNightMode(); led_effects::toggleNightMode();
} else if (messageString == "local_ip") { } else if (messageString == "local_ip") {
sendInfoAboutLocalNetwork(); sendInfoAboutLocalNetwork();
} else if (messageString == "reset") { } else if (messageString == "reset") {
resetAmpel(); resetAmpel();
} else { } else {
LedEffects::showKITTWheel(color::red, 1); led_effects::showKITTWheel(color::red, 1);
Serial.println(F("Message not supported. Doing nothing.")); Serial.println(F("Message not supported. Doing nothing."));
} }
delay(50); delay(50);
LedEffects::onBoardLEDOff(); led_effects::onBoardLEDOff();
} }
void reconnect() { void reconnect() {
...@@ -187,10 +187,10 @@ namespace mqtt { ...@@ -187,10 +187,10 @@ namespace mqtt {
} }
Serial.print(F("Attempting MQTT connection...")); Serial.print(F("Attempting MQTT connection..."));
LedEffects::onBoardLEDOn(); led_effects::onBoardLEDOn();
// Wait for connection, at most 15s (default) // Wait for connection, at most 15s (default)
mqttClient.connect(publish_topic.c_str(), config::mqtt_user, config::mqtt_password); mqttClient.connect(publish_topic.c_str(), config::mqtt_user, config::mqtt_password);
LedEffects::onBoardLEDOff(); led_effects::onBoardLEDOff();
connected = mqttClient.connected(); connected = mqttClient.connected();
......
...@@ -43,7 +43,7 @@ void resetAmpel() { ...@@ -43,7 +43,7 @@ void resetAmpel() {
#ifdef AMPEL_CSV #ifdef AMPEL_CSV
FS_LIB.end(); FS_LIB.end();
#endif #endif
LedEffects::LEDsOff(); led_effects::LEDsOff();
delay(1000); delay(1000);
ESP.restart(); ESP.restart();
} }
......
...@@ -29,16 +29,16 @@ void WiFiConnect(const String &hostname) { ...@@ -29,16 +29,16 @@ void WiFiConnect(const String &hostname) {
// Wait for connection, at most wifi_timeout seconds // Wait for connection, at most wifi_timeout seconds
for (int i = 0; i <= config::wifi_timeout && (WiFi.status() != WL_CONNECTED); i++) { for (int i = 0; i <= config::wifi_timeout && (WiFi.status() != WL_CONNECTED); i++) {
LedEffects::showRainbowWheel(); led_effects::showRainbowWheel();
Serial.print("."); Serial.print(".");
} }
if (WiFi.status() == WL_CONNECTED) { if (WiFi.status() == WL_CONNECTED) {
LedEffects::showKITTWheel(color::green); led_effects::showKITTWheel(color::green);
Serial.println(); Serial.println();
Serial.print("\nWiFi connected, IP address: "); Serial.print("\nWiFi connected, IP address: ");
Serial.println(WiFi.localIP()); Serial.println(WiFi.localIP());
} else { } else {
LedEffects::showKITTWheel(color::red); led_effects::showKITTWheel(color::red);
Serial.println("\nConnection to WiFi failed"); Serial.println("\nConnection to WiFi failed");
} }
} }
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