diff options
-rw-r--r-- | app.cpp | 50 |
1 files changed, 19 insertions, 31 deletions
@@ -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(); } |