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

Renaming led_effects namespace for consistency

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