Added some comments

This commit is contained in:
Sebastian 2020-07-23 12:30:44 +02:00
parent dd2a831ade
commit 68d45f6363
3 changed files with 19 additions and 15 deletions

View File

@ -39,22 +39,22 @@ void setValueNM(int NM) {
// Logic to set color array pointer // Logic to set color array pointer
void getColorBasedOnValueNM(int valueNM) { void getColorBasedOnValueNM(int valueNM) {
if (valueNM <= 420) { //Purple if (valueNM <= 420) { // Purple
colorCounter = 0; colorCounter = 0;
} }
else if (valueNM <= 490) { //Blue else if (valueNM <= 490) { // Blue
colorCounter = 1; colorCounter = 1;
} }
else if (valueNM <= 575) { //Green else if (valueNM <= 575) { // Green
colorCounter = 2; colorCounter = 2;
} }
else if (valueNM <= 585) { //Yellow else if (valueNM <= 585) { // Yellow
colorCounter = 3; colorCounter = 3;
} }
else if (valueNM <= 650) { //Orange else if (valueNM <= 650) { // Orange
colorCounter = 4; colorCounter = 4;
} }
else if (valueNM > 650) { // 650 to 750 is red else if (valueNM > 650) { // 650 to 750 is Red
colorCounter = 5; colorCounter = 5;
} }
Serial.println("New color set based on: "); Serial.println("New color set based on: ");

View File

@ -32,12 +32,12 @@ void setup() {
Serial.println("Setup complete..."); Serial.println("Setup complete...");
Serial.println(); Serial.println();
Serial.println(); Serial.println();
// first read without delay // First read without delay
readSensors(); readSensors();
} }
void loop() { void loop() {
// main loop: read sensors // Main loop: read sensors
if (millis() - sensorReadTimer >= FREQUENCY) { if (millis() - sensorReadTimer >= FREQUENCY) {
readSensors(); readSensors();
sensorReadTimer = millis(); sensorReadTimer = millis();

View File

@ -4,18 +4,18 @@
#include <lightChecker.h> #include <lightChecker.h>
#include <store.h> #include <store.h>
// Feldkapazität des Bodens in Prozent: Standard ist Humus // Fieldcapacity of the Ground in Percentage: Standard is Humus
int fieldCapacity = 44; int fieldCapacity = 44;
// PWP des Bodens in Prozent: Standard ist Humus // PWP of the Ground in Percentage: Standard is Humus
int permanentWiltingPoint = 25; int permanentWiltingPoint = 25;
// Boden vollständig gesättigt bei (Prozent): Standard ist Humus // Ground completely saturated by (Percentage): Standard is Humus
int soilSaturation = 69; int soilSaturation = 69;
// Helligkeitswert der mindestens vorhanden sein muss // Minimum light value before light turns on
int minimumLightValueLX = 50; int minimumLightValueLX = 50;
// switches for automatic light and irrigation control // Switches for automatic light and irrigation control
bool automaticLight = true; bool automaticLight = true;
bool automaticIrrigation = true; bool automaticIrrigation = true;
// make sure device irrigates until fieldcapacity is reached // Make sure device irrigates until fieldcapacity is reached
bool irrigateUntilFC = false; bool irrigateUntilFC = false;
void persistSoilProps(int FC, int PWP, int SAT) { void persistSoilProps(int FC, int PWP, int SAT) {
@ -75,6 +75,7 @@ void setSoilProperties(int FC, int PWP, int SAT) {
Serial.println(soilSaturation); Serial.println(soilSaturation);
} }
// Method to persist save the given lightning properties to NVS
void persistLightProps(int NM, int minLX) { void persistLightProps(int NM, int minLX) {
Serial.println("persistLightProps"); Serial.println("persistLightProps");
bool n = NVS.setInt("nanoMeter", NM); 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() { void restoreLightProps() {
Serial.println("restoreLightProps"); Serial.println("restoreLightProps");
int nm = NVS.getInt("nanoMeter"); int nm = NVS.getInt("nanoMeter");
@ -101,6 +103,7 @@ void restoreLightProps() {
Serial.println(minimumLightValueLX); Serial.println(minimumLightValueLX);
} }
// Method to set given light properties
void setLightProperties(int NM, int minLX) { void setLightProperties(int NM, int minLX) {
setValueNM(NM); setValueNM(NM);
minimumLightValueLX = minLX; minimumLightValueLX = minLX;
@ -111,7 +114,7 @@ void setLightProperties(int NM, int minLX) {
void persistAutoProps(bool light, bool irrigation) { void persistAutoProps(bool light, bool irrigation) {
Serial.println("persistAutoProps"); 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 n = NVS.setInt("automaticLight", (light ? 1 : 2));
bool m = NVS.setInt("automaticIrrigation", (irrigation ? 1 : 2)); bool m = NVS.setInt("automaticIrrigation", (irrigation ? 1 : 2));
if (n && m) { if (n && m) {
@ -158,6 +161,7 @@ void initDeviceID() {
} }
} }
// Returns the device ID
String getDeviceID() { String getDeviceID() {
return DEVICE_ID; return DEVICE_ID;
} }