aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2015-06-21 14:41:07 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2015-06-21 14:41:07 +0200
commit0147b3f0aa69d7c433eb75458c77f04ba666c847 (patch)
tree4ae180a74f1192af038223311dd7b5e0f4753c95
parent3f99167f0c986b2cad9558ab28ec0563ad737eab (diff)
downloadtrygvisio_soil_moisture-0147b3f0aa69d7c433eb75458c77f04ba666c847.tar.gz
trygvisio_soil_moisture-0147b3f0aa69d7c433eb75458c77f04ba666c847.tar.bz2
trygvisio_soil_moisture-0147b3f0aa69d7c433eb75458c77f04ba666c847.tar.xz
trygvisio_soil_moisture-0147b3f0aa69d7c433eb75458c77f04ba666c847.zip
o Use the values from the code instead of generating new default values.
-rw-r--r--app.cpp50
1 files changed, 19 insertions, 31 deletions
diff --git a/app.cpp b/app.cpp
index 5e45c6e..98646bf 100644
--- a/app.cpp
+++ b/app.cpp
@@ -34,13 +34,13 @@ struct sm_sensor {
// A Pin, D1 Pin, D2 Pin, Value, Warning Value, Update Interval, Length of Name, Name
#if SM_BOARD_VERSION == 1
- { 8, 3, 5, 0, 10, 0, 9, "Sensor #1"},
- { 10, 11, 12, 0, 10, 0, 9, "Sensor #2"},
+ { 8, 3, 5, 0, 200, 3000, 9, "Sensor #1"},
+ { 10, 11, 12, 0, 200, 3000, 9, "Sensor #2"},
#elif SM_BOARD_VERSION == 2
- { A0, 1, 2, 0, 10, 0, 3, "wat"},
- { A1, 3, 5, 0, 10, 0, 4, "woot"},
- { A2, 8, 10, 0, 10, 0, 3, "foo"},
- { A3, 11, 12, 0, 10, 0, 3, "bar"},
+ { A0, 1, 2, 0, 200, 3000, 3, "wat"},
+ { A1, 3, 5, 0, 200, 3000, 4, "woot"},
+ { A2, 8, 10, 0, 200, 3000, 3, "foo"},
+ { A3, 11, 12, 0, 200, 3000, 3, "bar"},
#endif
};
@@ -109,21 +109,6 @@ static int load_string(int index, const uint8_t max_length, uint8_t& length, cha
return 1 + len;
}
-static void set_default_settings() {
-#if SENSOR_COUNT > 10
-#error SENSOR_COUNT cannot be bigger than 10
-#endif
-
- for (int i = 0; i < SENSOR_COUNT; i++) {
- sensors[i].warning_value = 700;
-
- int idx = 9;
- strcpy(sensors[i].name, "Sensor #");
- sensors[i].name[idx++] = '0' + i;
- sensors[i].name_length = idx;
- }
-}
-
/**
* Returns true if the settings was successfully read.
*/
@@ -164,26 +149,29 @@ static void store_settings() {
static void setup_settings() {
if (!load_settings()) {
- Serial.println("Setting default settings");
- set_default_settings();
-
- Serial.println("Saving settings");
+ Serial.println("Could not load settings, storing defaults");
store_settings();
} else {
Serial.println("Settings loaded");
}
for (int i = 0; i < SENSOR_COUNT; i++) {
- Serial.print("XX: i=");
+ Serial.print("Sensor #");
Serial.print(i, DEC);
struct sm_sensor& s = sensors[i];
- Serial.print(", name len=");
- Serial.print(s.name_length, DEC);
- Serial.print(": ->");
- Serial.write((const uint8_t*) s.name, s.name_length);
- Serial.print("<-");
+// Serial.print(", name len=");
+// Serial.print(s.name_length, DEC);
+// Serial.print(": ->");
+// Serial.write((const uint8_t*) s.name, s.name_length);
+// Serial.print("<-");
+
+ Serial.print(": update_interval=");
+ Serial.print(s.update_interval, DEC);
+ Serial.print(", warning_value=");
+ Serial.print(s.warning_value, DEC);
+
Serial.println();
}