From 68d45f636351011427ecaabb22555381faf27521 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 23 Jul 2020 12:30:44 +0200 Subject: [PATCH] Added some comments --- src/lightChecker.cpp | 12 ++++++------ src/main.cpp | 4 ++-- src/store.cpp | 18 +++++++++++------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/lightChecker.cpp b/src/lightChecker.cpp index 1152c90..a191c11 100644 --- a/src/lightChecker.cpp +++ b/src/lightChecker.cpp @@ -39,22 +39,22 @@ void setValueNM(int NM) { // Logic to set color array pointer void getColorBasedOnValueNM(int valueNM) { - if (valueNM <= 420) { //Purple + if (valueNM <= 420) { // Purple colorCounter = 0; } - else if (valueNM <= 490) { //Blue + else if (valueNM <= 490) { // Blue colorCounter = 1; } - else if (valueNM <= 575) { //Green + else if (valueNM <= 575) { // Green colorCounter = 2; } - else if (valueNM <= 585) { //Yellow + else if (valueNM <= 585) { // Yellow colorCounter = 3; } - else if (valueNM <= 650) { //Orange + else if (valueNM <= 650) { // Orange colorCounter = 4; } - else if (valueNM > 650) { // 650 to 750 is red + else if (valueNM > 650) { // 650 to 750 is Red colorCounter = 5; } Serial.println("New color set based on: "); diff --git a/src/main.cpp b/src/main.cpp index c6196c5..f12a32d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -32,12 +32,12 @@ void setup() { Serial.println("Setup complete..."); Serial.println(); Serial.println(); - // first read without delay + // First read without delay readSensors(); } void loop() { - // main loop: read sensors + // Main loop: read sensors if (millis() - sensorReadTimer >= FREQUENCY) { readSensors(); sensorReadTimer = millis(); diff --git a/src/store.cpp b/src/store.cpp index 5aa7ac3..8a814aa 100644 --- a/src/store.cpp +++ b/src/store.cpp @@ -4,18 +4,18 @@ #include #include -// Feldkapazität des Bodens in Prozent: Standard ist Humus +// Fieldcapacity of the Ground in Percentage: Standard is Humus int fieldCapacity = 44; -// PWP des Bodens in Prozent: Standard ist Humus +// PWP of the Ground in Percentage: Standard is Humus int permanentWiltingPoint = 25; -// Boden vollständig gesättigt bei (Prozent): Standard ist Humus +// Ground completely saturated by (Percentage): Standard is Humus int soilSaturation = 69; -// Helligkeitswert der mindestens vorhanden sein muss +// Minimum light value before light turns on int minimumLightValueLX = 50; -// switches for automatic light and irrigation control +// Switches for automatic light and irrigation control bool automaticLight = true; bool automaticIrrigation = true; -// make sure device irrigates until fieldcapacity is reached +// Make sure device irrigates until fieldcapacity is reached bool irrigateUntilFC = false; void persistSoilProps(int FC, int PWP, int SAT) { @@ -75,6 +75,7 @@ void setSoilProperties(int FC, int PWP, int SAT) { Serial.println(soilSaturation); } +// Method to persist save the given lightning properties to NVS void persistLightProps(int NM, int minLX) { Serial.println("persistLightProps"); bool n = NVS.setInt("nanoMeter", NM); @@ -88,6 +89,7 @@ void persistLightProps(int NM, int minLX) { } } +// Method to restore light properties from Non-Volatile Storage (NVS) void restoreLightProps() { Serial.println("restoreLightProps"); int nm = NVS.getInt("nanoMeter"); @@ -101,6 +103,7 @@ void restoreLightProps() { Serial.println(minimumLightValueLX); } +// Method to set given light properties void setLightProperties(int NM, int minLX) { setValueNM(NM); minimumLightValueLX = minLX; @@ -111,7 +114,7 @@ void setLightProperties(int NM, int minLX) { void persistAutoProps(bool light, bool irrigation) { Serial.println("persistAutoProps"); - // saved in NVS as Integer: 1 = true, 2 = false, 0 = not persisted, use standard settings + // Saved in NVS as Integer: 1 = true, 2 = false, 0 = not persisted, use standard settings bool n = NVS.setInt("automaticLight", (light ? 1 : 2)); bool m = NVS.setInt("automaticIrrigation", (irrigation ? 1 : 2)); if (n && m) { @@ -158,6 +161,7 @@ void initDeviceID() { } } +// Returns the device ID String getDeviceID() { return DEVICE_ID; }