diff --git a/data/set.device.json b/data/set.device.json index 785f3fe2..ef80ac85 100644 --- a/data/set.device.json +++ b/data/set.device.json @@ -43,7 +43,7 @@ }, { "type": "h4", - "title": "LittleFS version: 256" + "title": "LittleFS version: 257" }, { "type": "hr" @@ -130,6 +130,15 @@ "action": "/set?sceninit", "class": "btn btn-block btn-default" }, + { + "type": "hr" + }, + { + "type": "link", + "title": "Ручная настройка", + "action": "/?set.manual", + "class": "btn btn-block btn-default" + }, { "type": "link", "title": "Инструкция к системе автоматизации", diff --git a/data/set.manual.json b/data/set.manual.json index 26a8832f..bd3b7ba0 100644 --- a/data/set.manual.json +++ b/data/set.manual.json @@ -1,30 +1,38 @@ { - "configs": [ - "/config.setup.json", - "/config.option.json", - "/config.live.json", - "/lang/lang.ru.json" - ], - "class": "col-sm-offset-1 col-sm-10", - "content": [ - { - "type": "h5", - "title": "{{name}}", - "class": "alert-default" - }, - { - "type": "link", - "title": "{{ButMainPage}}", - "action": "/", - "class": "btn btn-block btn-default" - }, - { - "type": "file", - "state": "s.conf.csv", - "style": "width:100%;height:350px", - "title": "Сохранить", - "action": "/set?saveItems", - "class": "btn btn-block btn-default" - } - ] - } \ No newline at end of file + "configs": [ + "/config.setup.json", + "/config.option.json", + "/config.live.json", + "/lang/lang.ru.json" + ], + "class": "col-sm-offset-1 col-sm-10", + "content": [ + { + "type": "h5", + "title": "{{name}}", + "class": "alert-default" + }, + { + "type": "link", + "title": "{{ButMainPage}}", + "action": "/", + "class": "btn btn-block btn-default" + }, + { + "type": "file", + "state": "s.conf.csv", + "style": "width:100%;height:350px", + "title": "Сохранить", + "action": "/set?saveItems", + "class": "btn btn-block btn-default" + }, + { + "type": "file", + "state": "s.scen.txt", + "style": "width:100%;height:350px", + "title": "Сохранить", + "action": "/set?sceninit", + "class": "btn btn-block btn-default" + } + ] +} \ No newline at end of file diff --git a/include/Consts.h b/include/Consts.h index 4b1c5f9d..e023921c 100644 --- a/include/Consts.h +++ b/include/Consts.h @@ -2,7 +2,7 @@ //=================Firmeare================= #define FIRMWARE_NAME "esp8266-iotm" -#define FIRMWARE_VERSION 256 +#define FIRMWARE_VERSION 257 #define FLASH_4MB true //=================System=================== diff --git a/include/items/SensorUltrasonicClass.h b/include/items/SensorUltrasonicClass.h index 40f4061a..06d6a972 100644 --- a/include/items/SensorUltrasonicClass.h +++ b/include/items/SensorUltrasonicClass.h @@ -4,6 +4,9 @@ #include "Class/LineParsing.h" #include "Global.h" #include "items/SensorConvertingClass.h" +#include "GyverFilters.h" + +GMedian<6, int> testFilter; class SensorUltrasonic : public SensorConvertingClass { public: @@ -33,6 +36,8 @@ class SensorUltrasonic : public SensorConvertingClass { long duration_ = pulseIn(echo, HIGH, 30000); // 3000 µs = 50cm // 30000 µs = 5 m value = duration_ / 29 / 2; + value = testFilter.filtered(value); + value = this->mapping(key, value); float valueFl = this->correction(key, value); eventGen(key, ""); diff --git a/lib/GyverFilters/library.properties b/lib/GyverFilters/library.properties index 7c211d3d..2c0c881a 100644 --- a/lib/GyverFilters/library.properties +++ b/lib/GyverFilters/library.properties @@ -1,7 +1,7 @@ name=GyverFilters -version=2.0 -author=AlexGyver -maintainer=AlexGyver +version=2.1 +author=AlexGyver +maintainer=AlexGyver sentence=Library with few filters for data. paragraph=Includes median, running average, AB, simplified Kalman and linear approximation filtering algorithms. category=Data Processing diff --git a/lib/GyverFilters/src/GyverFilters.h b/lib/GyverFilters/src/GyverFilters.h index e03e4bf5..cb35777c 100644 --- a/lib/GyverFilters/src/GyverFilters.h +++ b/lib/GyverFilters/src/GyverFilters.h @@ -7,7 +7,8 @@ #include /* - GyverFilters - библиотека с некоторыми удобными фильтрами: + GyverFilters - библиотека с некоторыми удобными фильтрами. + Документация: https://alexgyver.ru/gyverfilters/ - GFilterRA - компактная альтернатива фильтра экспоненциальное бегущее среднее (Running Average) - GMedian3 - быстрый медианный фильтр 3-го порядка (отсекает выбросы) - GMedian - медианный фильтр N-го порядка. Порядок настраивается в GyverFilters.h - MEDIAN_FILTER_SIZE @@ -23,4 +24,5 @@ - Улучшен и исправлен median и median3 - Улучшен linear - Смотрите примеры! Использование этих фильтров чуть изменилось + - 2.1: Исправлен расчёт дельты в линейном фильтре */ \ No newline at end of file diff --git a/lib/GyverFilters/src/filters/linear.h b/lib/GyverFilters/src/filters/linear.h index 65a134f3..a3f320a2 100644 --- a/lib/GyverFilters/src/filters/linear.h +++ b/lib/GyverFilters/src/filters/linear.h @@ -19,7 +19,7 @@ public: a = a - (long)sumX * sumY; a = (float)a / (arrSize * sumX2 - sumX * sumX); b = (float)(sumY - (float)a * sumX) / arrSize; - delta = a * arrSize; // расчёт изменения + delta = a * (x_array[arrSize-1] - x_array[0]); // расчёт изменения } float getA() {return a;} // получить коэффициент А float getB() {return b;} // получить коэффициент В @@ -27,4 +27,23 @@ public: private: float a, b, delta; -}; \ No newline at end of file +}; + +/* +Сам алгоритм выглядит так: +void loop() { + sumX = 0; + sumY = 0; + sumX2 = 0; + sumXY = 0; + for (int i = 0; i < steps; i++) { + sumX += X[i]; + sumY += Y[i]; + sumX2 += X[i] * X[i]; + sumXY += X[i] * Y[i]; + } + a = (steps * sumXY - sumX * sumY) / (steps * sumX2 - sumX * sumX); + b = (sumY - a * sumX) / steps; + int delta = steps * a; +} +*/ \ No newline at end of file diff --git a/src/Logging.cpp b/src/Logging.cpp index 9c974dad..44b323a4 100644 --- a/src/Logging.cpp +++ b/src/Logging.cpp @@ -1,6 +1,4 @@ #include "Global.h" - -// #include void sendLogData(String file, String topic);