From fd3fa6349b8d04096355536125f76d9bb9ae4bef Mon Sep 17 00:00:00 2001 From: Lexa Date: Thu, 21 Aug 2025 11:14:26 +0300 Subject: [PATCH] Deleted old projects --- KorMYS/.pio/build/project.checksum | 1 - KorMYS/.pio/build/uno/idedata.json | 1 - .../libdeps/uno/RunningMedian/.arduino-ci.yml | 7 - .../.github/workflows/arduino_test_runner.yml | 13 - KorMYS/.pio/libdeps/uno/RunningMedian/.piopm | 1 - KorMYS/.pio/libdeps/uno/RunningMedian/LICENSE | 21 - .../.pio/libdeps/uno/RunningMedian/README.md | 79 -- .../uno/RunningMedian/RunningMedian.cpp | 205 ----- .../libdeps/uno/RunningMedian/RunningMedian.h | 94 --- .../examples/RunningMedian/RunningMedian.ino | 50 -- .../RunningMedian2/RunningMedian2.ino | 78 -- .../RunningMedianQuantileTest.ino | 40 - .../RunningMedianTest1/RunningMedianTest1.ino | 163 ---- .../RunningMedian_large.ino | 66 -- .../libdeps/uno/RunningMedian/keywords.txt | 23 - .../libdeps/uno/RunningMedian/library.json | 21 - .../uno/RunningMedian/library.properties | 11 - .../uno/RunningMedian/test/unit_test_001.cpp | 123 --- KorMYS/.pio/libdeps/uno/SoftwareSerial/.piopm | 1 - .../uno/SoftwareSerial/SoftwareSerial.cpp | 677 --------------- .../uno/SoftwareSerial/SoftwareSerial.h | 150 ---- .../SoftwareSerialExample.ino | 55 -- .../TwoPortReceive/TwoPortReceive.ino | 93 --- .../libdeps/uno/SoftwareSerial/keywords.txt | 30 - .../libdeps/uno/SoftwareSerial/library.json | 31 - .../uno/SoftwareSerial/library.properties | 10 - .../libdeps/uno/SoftwareSerial/libray.json | 31 - KorMYS/.pio/libdeps/uno/integrity.dat | 2 - KorMYS/.vscode/c_cpp_properties.json | 128 --- KorMYS/.vscode/launch.json | 44 - esp8266-KUH/.gitignore | 5 - esp8266-KUH/.travis.yml | 67 -- esp8266-KUH/.vscode/extensions.json | 10 - esp8266-KUH/include/README | 39 - esp8266-KUH/include/main.h | 45 - esp8266-KUH/lib/README | 46 -- esp8266-KUH/platformio.ini | 24 - esp8266-KUH/src/main.cpp | 780 ------------------ esp8266-KUH/test/README | 11 - 39 files changed, 3276 deletions(-) delete mode 100644 KorMYS/.pio/build/project.checksum delete mode 100644 KorMYS/.pio/build/uno/idedata.json delete mode 100644 KorMYS/.pio/libdeps/uno/RunningMedian/.arduino-ci.yml delete mode 100644 KorMYS/.pio/libdeps/uno/RunningMedian/.github/workflows/arduino_test_runner.yml delete mode 100644 KorMYS/.pio/libdeps/uno/RunningMedian/.piopm delete mode 100644 KorMYS/.pio/libdeps/uno/RunningMedian/LICENSE delete mode 100644 KorMYS/.pio/libdeps/uno/RunningMedian/README.md delete mode 100644 KorMYS/.pio/libdeps/uno/RunningMedian/RunningMedian.cpp delete mode 100644 KorMYS/.pio/libdeps/uno/RunningMedian/RunningMedian.h delete mode 100644 KorMYS/.pio/libdeps/uno/RunningMedian/examples/RunningMedian/RunningMedian.ino delete mode 100644 KorMYS/.pio/libdeps/uno/RunningMedian/examples/RunningMedian2/RunningMedian2.ino delete mode 100644 KorMYS/.pio/libdeps/uno/RunningMedian/examples/RunningMedianQuantileTest/RunningMedianQuantileTest.ino delete mode 100644 KorMYS/.pio/libdeps/uno/RunningMedian/examples/RunningMedianTest1/RunningMedianTest1.ino delete mode 100644 KorMYS/.pio/libdeps/uno/RunningMedian/examples/RunningMedian_large/RunningMedian_large.ino delete mode 100644 KorMYS/.pio/libdeps/uno/RunningMedian/keywords.txt delete mode 100644 KorMYS/.pio/libdeps/uno/RunningMedian/library.json delete mode 100644 KorMYS/.pio/libdeps/uno/RunningMedian/library.properties delete mode 100644 KorMYS/.pio/libdeps/uno/RunningMedian/test/unit_test_001.cpp delete mode 100644 KorMYS/.pio/libdeps/uno/SoftwareSerial/.piopm delete mode 100644 KorMYS/.pio/libdeps/uno/SoftwareSerial/SoftwareSerial.cpp delete mode 100644 KorMYS/.pio/libdeps/uno/SoftwareSerial/SoftwareSerial.h delete mode 100644 KorMYS/.pio/libdeps/uno/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino delete mode 100644 KorMYS/.pio/libdeps/uno/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino delete mode 100644 KorMYS/.pio/libdeps/uno/SoftwareSerial/keywords.txt delete mode 100644 KorMYS/.pio/libdeps/uno/SoftwareSerial/library.json delete mode 100644 KorMYS/.pio/libdeps/uno/SoftwareSerial/library.properties delete mode 100644 KorMYS/.pio/libdeps/uno/SoftwareSerial/libray.json delete mode 100644 KorMYS/.pio/libdeps/uno/integrity.dat delete mode 100644 KorMYS/.vscode/c_cpp_properties.json delete mode 100644 KorMYS/.vscode/launch.json delete mode 100644 esp8266-KUH/.gitignore delete mode 100644 esp8266-KUH/.travis.yml delete mode 100644 esp8266-KUH/.vscode/extensions.json delete mode 100644 esp8266-KUH/include/README delete mode 100644 esp8266-KUH/include/main.h delete mode 100644 esp8266-KUH/lib/README delete mode 100644 esp8266-KUH/platformio.ini delete mode 100644 esp8266-KUH/src/main.cpp delete mode 100644 esp8266-KUH/test/README diff --git a/KorMYS/.pio/build/project.checksum b/KorMYS/.pio/build/project.checksum deleted file mode 100644 index 41d5a3d..0000000 --- a/KorMYS/.pio/build/project.checksum +++ /dev/null @@ -1 +0,0 @@ -b58b282bd85d9a4528491da8b76afbc5f6cf573c \ No newline at end of file diff --git a/KorMYS/.pio/build/uno/idedata.json b/KorMYS/.pio/build/uno/idedata.json deleted file mode 100644 index 7067060..0000000 --- a/KorMYS/.pio/build/uno/idedata.json +++ /dev/null @@ -1 +0,0 @@ -{"build_type": "release", "env_name": "uno", "libsource_dirs": ["d:\\Projects\\Arduino\\AHome\\KorMYS\\lib", "d:\\Projects\\Arduino\\AHome\\KorMYS\\.pio\\libdeps\\uno", "C:\\Users\\lexa-\\.platformio\\lib", "C:\\Users\\lexa-\\.platformio\\packages\\framework-arduino-avr\\libraries"], "defines": ["PLATFORMIO=60105", "ARDUINO_AVR_UNO", "F_CPU=16000000L", "ARDUINO_ARCH_AVR", "ARDUINO=10808", "__AVR_ATmega328P__"], "includes": {"build": ["d:\\Projects\\Arduino\\AHome\\KorMYS\\include", "d:\\Projects\\Arduino\\AHome\\KorMYS\\src", "d:\\Projects\\Arduino\\AHome\\KorMYS\\include", "d:\\Projects\\Arduino\\AHome\\KorMYS\\src", "C:\\Users\\lexa-\\.platformio\\lib\\SDS011 sensor Library", "C:\\Users\\lexa-\\.platformio\\lib\\MySensors_ID548", "C:\\Users\\lexa-\\.platformio\\packages\\framework-arduino-avr\\libraries\\EEPROM\\src", "C:\\Users\\lexa-\\.platformio\\packages\\framework-arduino-avr\\libraries\\SPI\\src", "C:\\Users\\lexa-\\.platformio\\packages\\framework-arduino-avr\\libraries\\Wire\\src", "d:\\Projects\\Arduino\\AHome\\KorMYS\\.pio\\libdeps\\uno\\RunningMedian", "d:\\Projects\\Arduino\\AHome\\KorMYS\\.pio\\libdeps\\uno\\SoftwareSerial", "C:\\Users\\lexa-\\.platformio\\packages\\framework-arduino-avr\\cores\\arduino", "C:\\Users\\lexa-\\.platformio\\packages\\framework-arduino-avr\\variants\\standard"], "compatlib": ["d:\\Projects\\Arduino\\AHome\\KorMYS\\.pio\\libdeps\\uno\\RunningMedian", "d:\\Projects\\Arduino\\AHome\\KorMYS\\.pio\\libdeps\\uno\\RunningMedian", "d:\\Projects\\Arduino\\AHome\\KorMYS\\.pio\\libdeps\\uno\\SoftwareSerial", "d:\\Projects\\Arduino\\AHome\\KorMYS\\.pio\\libdeps\\uno\\SoftwareSerial", "C:\\Users\\lexa-\\.platformio\\lib\\MySensors_ID548", "C:\\Users\\lexa-\\.platformio\\lib\\MySensors_ID548", "C:\\Users\\lexa-\\.platformio\\packages\\framework-arduino-avr\\libraries\\EEPROM\\src", "C:\\Users\\lexa-\\.platformio\\packages\\framework-arduino-avr\\libraries\\SPI\\src", "C:\\Users\\lexa-\\.platformio\\packages\\framework-arduino-avr\\libraries\\Wire\\src", "C:\\Users\\lexa-\\.platformio\\lib\\SDS011 sensor Library", "C:\\Users\\lexa-\\.platformio\\packages\\framework-arduino-avr\\libraries\\EEPROM\\src", "C:\\Users\\lexa-\\.platformio\\packages\\framework-arduino-avr\\libraries\\SPI\\src", "C:\\Users\\lexa-\\.platformio\\packages\\framework-arduino-avr\\libraries\\Wire\\src", "C:\\Users\\lexa-\\.platformio\\lib\\Adafruit ADXL343", "C:\\Users\\lexa-\\.platformio\\lib\\Adafruit AHTX0", "C:\\Users\\lexa-\\.platformio\\lib\\Adafruit BME280 Library", "C:\\Users\\lexa-\\.platformio\\lib\\Adafruit BusIO", "C:\\Users\\lexa-\\.platformio\\lib\\Adafruit DHT Unified_ID18", "C:\\Users\\lexa-\\.platformio\\lib\\Adafruit GFX Library", "C:\\Users\\lexa-\\.platformio\\lib\\Adafruit HTU21DF Library_ID566", "C:\\Users\\lexa-\\.platformio\\lib\\Adafruit SH110X", "C:\\Users\\lexa-\\.platformio\\lib\\Adafruit Unified Sensor", "C:\\Users\\lexa-\\.platformio\\lib\\AsyncMqttClient\\src", "C:\\Users\\lexa-\\.platformio\\lib\\BME280_ID901\\src", "C:\\Users\\lexa-\\.platformio\\lib\\Bounce2\\src", "C:\\Users\\lexa-\\.platformio\\lib\\ClosedCube HDC1080_ID805\\src", "C:\\Users\\lexa-\\.platformio\\lib\\DHT sensor library", "C:\\Users\\lexa-\\.platformio\\lib\\DallasTemperature", "C:\\Users\\lexa-\\.platformio\\lib\\EEPROMEx", "C:\\Users\\lexa-\\.platformio\\lib\\ESP_EEPROM\\src", "C:\\Users\\lexa-\\.platformio\\lib\\EmonLib_ID116", "C:\\Users\\lexa-\\.platformio\\lib\\Encoder", "C:\\Users\\lexa-\\.platformio\\lib\\Encoder\\utility", "C:\\Users\\lexa-\\.platformio\\lib\\I2C_EEPROM", "C:\\Users\\lexa-\\.platformio\\lib\\LiquidCrystal_PCF8574\\src", "C:\\Users\\lexa-\\.platformio\\lib\\MH-Z19\\src", "C:\\Users\\lexa-\\.platformio\\lib\\MsTimer2_ID137", "C:\\Users\\lexa-\\.platformio\\lib\\Nova Fitness Sds dust sensors library\\src", "C:\\Users\\lexa-\\.platformio\\lib\\OneButton\\src", "C:\\Users\\lexa-\\.platformio\\lib\\OneWire", "C:\\Users\\lexa-\\.platformio\\lib\\PCF8574", "C:\\Users\\lexa-\\.platformio\\lib\\PCF8574_ESP", "C:\\Users\\lexa-\\.platformio\\lib\\PubSubClient_ID89\\src", "C:\\Users\\lexa-\\.platformio\\lib\\RotaryEncoder\\src", "C:\\Users\\lexa-\\.platformio\\lib\\TimerOne", "C:\\Users\\lexa-\\.platformio\\packages\\framework-arduino-avr\\libraries\\HID\\src", "C:\\Users\\lexa-\\.platformio\\packages\\framework-arduino-avr\\libraries\\SoftwareSerial\\src"], "toolchain": ["C:\\Users\\lexa-\\.platformio\\packages\\toolchain-atmelavr@1.70300.191015\\lib\\gcc\\avr\\7.3.0\\include", "C:\\Users\\lexa-\\.platformio\\packages\\toolchain-atmelavr@1.70300.191015\\lib\\gcc\\avr\\7.3.0\\include-fixed", "C:\\Users\\lexa-\\.platformio\\packages\\toolchain-atmelavr@1.70300.191015\\avr\\include"]}, "cc_flags": "-std=gnu11 -fno-fat-lto-objects -mmcu=atmega328p -Os -Wall -ffunction-sections -fdata-sections -flto", "cxx_flags": "-fno-exceptions -fno-threadsafe-statics -fpermissive -std=gnu++11 -mmcu=atmega328p -Os -Wall -ffunction-sections -fdata-sections -flto", "cc_path": "C:\\Users\\lexa-\\.platformio\\packages\\toolchain-atmelavr@1.70300.191015\\bin\\avr-gcc.exe", "cxx_path": "C:\\Users\\lexa-\\.platformio\\packages\\toolchain-atmelavr@1.70300.191015\\bin\\avr-g++.exe", "gdb_path": "C:\\Users\\lexa-\\.platformio\\packages\\toolchain-atmelavr@1.70300.191015\\bin\\avr-gdb.exe", "prog_path": "d:\\Projects\\Arduino\\AHome\\KorMYS\\.pio\\build\\uno\\firmware.elf", "svd_path": null, "compiler_type": "gcc", "targets": [{"name": "size", "title": "Program Size", "description": "Calculate program size", "group": "Platform"}, {"name": "upload", "title": "Upload", "description": null, "group": "Platform"}, {"name": "uploadeep", "title": "Upload EEPROM", "description": null, "group": "Platform"}, {"name": "fuses", "title": "Set Fuses", "description": null, "group": "Platform"}, {"name": "bootloader", "title": "Burn Bootloader", "description": null, "group": "Platform"}], "extra": {"flash_images": []}} \ No newline at end of file diff --git a/KorMYS/.pio/libdeps/uno/RunningMedian/.arduino-ci.yml b/KorMYS/.pio/libdeps/uno/RunningMedian/.arduino-ci.yml deleted file mode 100644 index ff5659b..0000000 --- a/KorMYS/.pio/libdeps/uno/RunningMedian/.arduino-ci.yml +++ /dev/null @@ -1,7 +0,0 @@ -compile: - # Choosing to run compilation tests on 2 different Arduino platforms - platforms: - - uno - - leonardo - - due - - zero diff --git a/KorMYS/.pio/libdeps/uno/RunningMedian/.github/workflows/arduino_test_runner.yml b/KorMYS/.pio/libdeps/uno/RunningMedian/.github/workflows/arduino_test_runner.yml deleted file mode 100644 index 476456b..0000000 --- a/KorMYS/.pio/libdeps/uno/RunningMedian/.github/workflows/arduino_test_runner.yml +++ /dev/null @@ -1,13 +0,0 @@ ---- -name: Arduino CI - -on: [push, pull_request] - -jobs: - arduino_ci: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - uses: Arduino-CI/action@master - # Arduino-CI/action@v0.1.1 diff --git a/KorMYS/.pio/libdeps/uno/RunningMedian/.piopm b/KorMYS/.pio/libdeps/uno/RunningMedian/.piopm deleted file mode 100644 index 73d23ff..0000000 --- a/KorMYS/.pio/libdeps/uno/RunningMedian/.piopm +++ /dev/null @@ -1 +0,0 @@ -{"type": "library", "name": "RunningMedian", "version": "0.3.3", "spec": {"owner": "robtillaart", "id": 1361, "name": "RunningMedian", "requirements": null, "url": null}} \ No newline at end of file diff --git a/KorMYS/.pio/libdeps/uno/RunningMedian/LICENSE b/KorMYS/.pio/libdeps/uno/RunningMedian/LICENSE deleted file mode 100644 index cfc58f9..0000000 --- a/KorMYS/.pio/libdeps/uno/RunningMedian/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2011-2021 Rob Tillaart - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/KorMYS/.pio/libdeps/uno/RunningMedian/README.md b/KorMYS/.pio/libdeps/uno/RunningMedian/README.md deleted file mode 100644 index 424b829..0000000 --- a/KorMYS/.pio/libdeps/uno/RunningMedian/README.md +++ /dev/null @@ -1,79 +0,0 @@ - -[![Arduino CI](https://github.com/RobTillaart/RunningMedian/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci) -[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/RunningMedian/blob/master/LICENSE) -[![GitHub release](https://img.shields.io/github/release/RobTillaart/RunningMedian.svg?maxAge=3600)](https://github.com/RobTillaart/RunningMedian/releases) - - -# RunningMedian - -Arduino library to determine the running median by means of a circular buffer. - - -## Description - -Running Median looks like a running average with a small but important twist. -Running average averages the last N samples while the running median takes -the last N samples, sort them and take the middle one, or the average of the -middle two in case the internal buffer size is even. - -Important differences between running average and running median: -- Running median will return real data (e.g. a real sample from a sensor) -if one uses an odd size of the buffer (therefor preferred). -Running average may return a value that is never sampled. -- Running median will give zero weight to outliers, and 100% to the middle sample, -whereas running average gives the same weight to all samples. -- Running median will give often constant values for some time. -- As one knows the values in the buffer one can predict the maximum change of -the running median in the next steps in advance. -- Running median is slower as one needs to keep the values in timed order -to remove the oldest and keep them sorted to be able to select the median. - - -#### Note MEDIAN_MAX_SIZE - -The maximum size of the internal buffer is defined by **MEDIAN_MAX_SIZE** and is -set to 255 (since version 0.3.1). The memory allocated currently is in the order -of 5 bytes per element plus some overhead, so 255 elements take ~1300 bytes. -For an UNO this is quite a bit. - -With larger sizes the performance penalty to keep the internal array sorted -is large. For most applications a value much lower e.g. 19 is working well, and -is performance wise O(100x) faster in sorting than 255 elements. - - -## Interface - - -### Constructor - -- **RunningMedian(const uint8_t size)** Constructor, dynamically allocates memory. -- **~RunningMedian()** Destructor -- **uint8_t getSize()** returns size of internal array -- **uint8_t getCount()** returns current used elements, getCount() <= getSize() -- **bool isFull()** returns true if the internal buffer is 100% filled. - - -### Base functions - -- **clear()** resets internal buffer and variables, effectively emptird thr buffer. -- **add(const float value) ** adds a new value to internal buffer, optionally replacing the oldest element if the buffer is full -- **float getMedian()** returns the median == middle element -- **float getAverage()** returns average of **all** the values in the internal buffer -- **float getAverage(uint8_t nMedian)** returns average of **the middle n** values. -This effectively removes noise from the outliers in the samples. -- **float getHighest()** get the largest values in the buffer. -- **float getLowest()** get the smallest value in the buffer. -- **float getQuantile(const float q)** returns the Quantile value from the buffer. -This value is often interpolated. - - -### Less used functions - -- **float getElement(const uint8_t n)** returns the n'th element from the values in time order. -- **float getSortedElement(const uint8_t n)** returns the n'th element from the values in size order (sorted ascending) -- **float predict(const uint8_t n)** predict the max change of median after n additions, n should be smaller than **getSize()/2** - - -## Operation - -See examples diff --git a/KorMYS/.pio/libdeps/uno/RunningMedian/RunningMedian.cpp b/KorMYS/.pio/libdeps/uno/RunningMedian/RunningMedian.cpp deleted file mode 100644 index e21e0f4..0000000 --- a/KorMYS/.pio/libdeps/uno/RunningMedian/RunningMedian.cpp +++ /dev/null @@ -1,205 +0,0 @@ -// -// FILE: RunningMedian.cpp -// AUTHOR: Rob Tillaart -// VERSION: 0.3.3 -// PURPOSE: RunningMedian library for Arduino -// -// HISTORY: -// 0.1.00 2011-02-16 initial version -// 0.1.01 2011-02-22 added remarks from CodingBadly -// 0.1.02 2012-03-15 added -// 0.1.03 2013-09-30 added _sorted flag, minor refactor -// 0.1.04 2013-10-17 added getAverage(uint8_t) - kudo's to Sembazuru -// 0.1.05 2013-10-18 fixed bug in sort; removes default constructor; dynamic memory -// 0.1.06 2013-10-19 faster sort, dynamic arrays, replaced sorted float array with indirection array -// 0.1.07 2013-10-19 add correct median if _count is even. -// 0.1.08 2013-10-20 add getElement(), add getSottedElement() add predict() -// 0.1.09 2014-11-25 float to double (support ARM) -// 0.1.10 2015-03-07 fix clear -// 0.1.11 2015-03-29 undo 0.1.10 fix clear -// 0.1.12 2015-07-12 refactor constructor + const -// 0.1.13 2015-10-30 fix getElement(n) - kudos to Gdunge -// 0.1.14 2017-07-26 revert double to float - issue #33 -// 0.1.15 2018-08-24 make runningMedian Configurable #110 -// 0.2.0 2020-04-16 refactor. -// 0.2.1 2020-06-19 fix library.json -// 0.2.2 2021-01-03 add Arduino-CI + unit tests -// 0.3.0 2021-01-04 malloc memory as default storage -// 0.3.1 2021-01-16 Changed size parameter to 255 max -// 0.3.2 2021-01-21 replaced bubbleSort by insertionSort -// --> better performance for large arrays. -// 0.3.3 2021-01-22 better insertionSort (+ cleanup test code) - - -#include "RunningMedian.h" - - -RunningMedian::RunningMedian(const uint8_t size) -{ - _size = size; - if (_size < MEDIAN_MIN_SIZE) _size = MEDIAN_MIN_SIZE; - // if (_size > MEDIAN_MAX_SIZE) _size = MEDIAN_MAX_SIZE; - -#ifdef RUNNING_MEDIAN_USE_MALLOC - _values = (float *) malloc(_size * sizeof(float)); - _sortIdx = (uint8_t *) malloc(_size * sizeof(uint8_t)); -#endif - clear(); -} - - -RunningMedian::~RunningMedian() -{ - #ifdef RUNNING_MEDIAN_USE_MALLOC - free(_values); - free(_sortIdx); - #endif -} - - -// resets all internal counters -void RunningMedian::clear() -{ - _count = 0; - _index = 0; - _sorted = false; - for (uint8_t i = 0; i < _size; i++) - { - _sortIdx[i] = i; - } -} - - -// adds a new value to the data-set -// or overwrites the oldest if full. -void RunningMedian::add(float value) -{ - _values[_index++] = value; - if (_index >= _size) _index = 0; // wrap around - if (_count < _size) _count++; - _sorted = false; -} - - -float RunningMedian::getMedian() -{ - if (_count == 0) return NAN; - - if (_sorted == false) sort(); - - if (_count & 0x01) // is it odd sized? - { - return _values[_sortIdx[_count / 2]]; - } - return (_values[_sortIdx[_count / 2]] + _values[_sortIdx[_count / 2 - 1]]) / 2; -} - - -float RunningMedian::getQuantile(float q) -{ - if (_count == 0) return NAN; - - if ((q < 0) || (q > 1)) return NAN; - - if (_sorted == false) sort(); - - const float id = (_count - 1) * q; - const uint8_t lo = floor(id); - const uint8_t hi = ceil(id); - const float qs = _values[_sortIdx[lo]]; - const float h = (id - lo); - - return (1.0 - h) * qs + h * _values[_sortIdx[hi]]; -} - - -float RunningMedian::getAverage() -{ - if (_count == 0) return NAN; - - float sum = 0; - for (uint8_t i = 0; i < _count; i++) - { - sum += _values[i]; - } - return sum / _count; -} - - -float RunningMedian::getAverage(uint8_t nMedians) -{ - if ((_count == 0) || (nMedians == 0)) return NAN; - - if (_count < nMedians) nMedians = _count; // when filling the array for first time - uint8_t start = ((_count - nMedians) / 2); - uint8_t stop = start + nMedians; - - if (_sorted == false) sort(); - - float sum = 0; - for (uint8_t i = start; i < stop; i++) - { - sum += _values[_sortIdx[i]]; - } - return sum / nMedians; -} - - -float RunningMedian::getElement(const uint8_t n) -{ - if ((_count == 0) || (n >= _count)) return NAN; - - uint8_t pos = _index + n; - if (pos >= _count) // faster than % - { - pos -= _count; - } - return _values[pos]; -} - - -float RunningMedian::getSortedElement(const uint8_t n) -{ - if ((_count == 0) || (n >= _count)) return NAN; - - if (_sorted == false) sort(); - return _values[_sortIdx[n]]; -} - - -// n can be max <= half the (filled) size -float RunningMedian::predict(const uint8_t n) -{ - uint8_t mid = _count / 2; - if ((_count == 0) || (n >= mid)) return NAN; - - float med = getMedian(); // takes care of sorting ! - if (_count & 0x01) // odd # elements - { - return max(med - _values[_sortIdx[mid - n]], _values[_sortIdx[mid + n]] - med); - } - // even # elements - float f1 = (_values[_sortIdx[mid - n]] + _values[_sortIdx[mid - n - 1]]) / 2; - float f2 = (_values[_sortIdx[mid + n]] + _values[_sortIdx[mid + n - 1]]) / 2; - return max(med - f1, f2 - med) / 2; -} - - -void RunningMedian::sort() -{ - // insertSort - for (uint16_t i = 1; i < _count; i++) - { - uint16_t z = i; - uint16_t temp = _sortIdx[z]; - while ((z > 0) && (_values[temp] < _values[_sortIdx[z - 1]])) - { - _sortIdx[z] = _sortIdx[z - 1]; - z--; - } - _sortIdx[z] = temp; - } - _sorted = true; -} - -// -- END OF FILE -- diff --git a/KorMYS/.pio/libdeps/uno/RunningMedian/RunningMedian.h b/KorMYS/.pio/libdeps/uno/RunningMedian/RunningMedian.h deleted file mode 100644 index 32be4da..0000000 --- a/KorMYS/.pio/libdeps/uno/RunningMedian/RunningMedian.h +++ /dev/null @@ -1,94 +0,0 @@ -#pragma once -// -// FILE: RunningMedian.h -// AUTHOR: Rob Tillaart -// PURPOSE: RunningMedian library for Arduino -// VERSION: 0.3.3 -// URL: https://github.com/RobTillaart/RunningMedian -// URL: http://arduino.cc/playground/Main/RunningMedian -// HISTORY: See RunningMedian.cpp -// - - -#include "Arduino.h" - -#define RUNNING_MEDIAN_VERSION (F("0.3.3")) - - -// fall back to fixed storage for dynamic version => remove true -#define RUNNING_MEDIAN_USE_MALLOC true - - -// MEDIAN_MIN_SIZE should at least be 3 to be practical, -#define MEDIAN_MIN_SIZE 3 - - -#ifdef RUNNING_MEDIAN_USE_MALLOC -// max 250 to not overflow uint8_t internal vars -#define MEDIAN_MAX_SIZE 255 -#else -// using fixed memory will be limited to 19 elements. -#define MEDIAN_MAX_SIZE 19 -#endif - - -class RunningMedian -{ -public: - // # elements in the internal buffer - // odd sizes results in a 'real' middle element and will be a bit faster. - // even sizes takes the average of the two middle elements as median - explicit RunningMedian(const uint8_t size); - ~RunningMedian(); - - // resets internal buffer and var - void clear(); - // adds a new value to internal buffer, optionally replacing the oldest element. - void add(const float value); - // returns the median == middle element - float getMedian(); - - // returns the Quantile - float getQuantile(const float q); - - // returns average of the values in the internal buffer - float getAverage(); - // returns average of the middle nMedian values, removes noise from outliers - float getAverage(uint8_t nMedian); - - float getHighest() { return getSortedElement(_count - 1); }; - float getLowest() { return getSortedElement(0); }; - - // get n'th element from the values in time order - float getElement(const uint8_t n); - // get n'th element from the values in size order - float getSortedElement(const uint8_t n); - // predict the max change of median after n additions - float predict(const uint8_t n); - - uint8_t getSize() { return _size; }; - // returns current used elements, getCount() <= getSize() - uint8_t getCount() { return _count; }; - bool isFull() { return (_count == _size); } - - -protected: - boolean _sorted; // _sortIdx{} is up to date - uint8_t _size; // max number of values - uint8_t _count; // current number of values - uint8_t _index; // next index to add. - - - // _values holds the elements themself - // _p holds the index for sorted -#ifdef RUNNING_MEDIAN_USE_MALLOC - float * _values; - uint8_t * _sortIdx; -#else - float _values[MEDIAN_MAX_SIZE]; - uint8_t _p[MEDIAN_MAX_SIZE]; -#endif - void sort(); -}; - -// END OF FILE \ No newline at end of file diff --git a/KorMYS/.pio/libdeps/uno/RunningMedian/examples/RunningMedian/RunningMedian.ino b/KorMYS/.pio/libdeps/uno/RunningMedian/examples/RunningMedian/RunningMedian.ino deleted file mode 100644 index ce888fc..0000000 --- a/KorMYS/.pio/libdeps/uno/RunningMedian/examples/RunningMedian/RunningMedian.ino +++ /dev/null @@ -1,50 +0,0 @@ -// -// FILE: RunningMedian.ino -// AUTHOR: Rob Tillaart ( kudos to Sembazuru) -// VERSION: 0.1.2 -// PURPOSE: demo basic usage -// DATE: 2013-10-17 -// URL: https://github.com/RobTillaart/RunningMedian -// - -#include - -RunningMedian samples = RunningMedian(5); - -void setup() -{ - Serial.begin(115200); - Serial.print("Running Median Version: "); - Serial.println(RUNNING_MEDIAN_VERSION); -} - -void loop() -{ - test1(); -} - -void test1() -{ - int x = analogRead(A0); - - samples.add(x); - long l = samples.getLowest(); - long m = samples.getMedian(); - long a = samples.getAverage(); - long h = samples.getHighest(); - - Serial.print(millis()); - Serial.print("\t"); - Serial.print(x); - Serial.print("\t"); - Serial.print(l); - Serial.print("\t"); - Serial.print(a); - Serial.print("\t"); - Serial.print(m); - Serial.print("\t"); - Serial.println(h); - delay(100); -} - -// -- END OF FILE -- diff --git a/KorMYS/.pio/libdeps/uno/RunningMedian/examples/RunningMedian2/RunningMedian2.ino b/KorMYS/.pio/libdeps/uno/RunningMedian/examples/RunningMedian2/RunningMedian2.ino deleted file mode 100644 index adac125..0000000 --- a/KorMYS/.pio/libdeps/uno/RunningMedian/examples/RunningMedian2/RunningMedian2.ino +++ /dev/null @@ -1,78 +0,0 @@ -// -// FILE: RunningMedian2.ino -// AUTHOR: Rob Tillaart ( kudos to Sembazuru) -// VERSION: 0.1.2 -// PURPOSE: demo most functions -// DATE: 2013-10-17 -// URL: https://github.com/RobTillaart/RunningMedian -// - -#include "RunningMedian.h" - -RunningMedian samples = RunningMedian(100); - -long count = 0; - -void setup() -{ - Serial.begin(115200); - Serial.print(F("Running Median Version: ")); - Serial.println(RUNNING_MEDIAN_VERSION); -} - -void loop() -{ - test1(); -} - -void test1() -{ - if (count % 20 == 0) - { - Serial.println(F("\nmsec \tAnR \tSize \tCnt \tLow \tAvg \tAvg(7) \tAvg(3) \tMed \tHigh \tPre(1) \tPre(2)")); - } - count++; - - long x = analogRead(A0); - - samples.add(x); - - float l = samples.getLowest(); - float m = samples.getMedian(); - float a = samples.getAverage(); - float a7 = samples.getAverage(7); - float a3 = samples.getAverage(3); - float h = samples.getHighest(); - int s = samples.getSize(); - int c = samples.getCount(); - float p1 = samples.predict(1); - float p2 = samples.predict(2); - - Serial.print(millis()); - Serial.print('\t'); - Serial.print(x); - Serial.print('\t'); - Serial.print(s); - Serial.print('\t'); - Serial.print(c); - Serial.print('\t'); - Serial.print(l); - Serial.print('\t'); - Serial.print(a, 2); - Serial.print('\t'); - Serial.print(a7, 2); - Serial.print('\t'); - Serial.print(a3, 2); - Serial.print('\t'); - Serial.print(m); - Serial.print('\t'); - Serial.print(h); - Serial.print('\t'); - Serial.print(p1, 2); - Serial.print('\t'); - Serial.println(p2, 2); - - delay(100); -} - - diff --git a/KorMYS/.pio/libdeps/uno/RunningMedian/examples/RunningMedianQuantileTest/RunningMedianQuantileTest.ino b/KorMYS/.pio/libdeps/uno/RunningMedian/examples/RunningMedianQuantileTest/RunningMedianQuantileTest.ino deleted file mode 100644 index b56972d..0000000 --- a/KorMYS/.pio/libdeps/uno/RunningMedian/examples/RunningMedianQuantileTest/RunningMedianQuantileTest.ino +++ /dev/null @@ -1,40 +0,0 @@ -// -// FILE: RunningMedianQuantileTest.ino -// AUTHOR: f-s ( derived from Rob Tillaart ) -// VERSION: 0.1.2 -// PURPOSE: demo basic quantile usage -// DATE: 2020-09-02 -// URL: https://github.com/RobTillaart/RunningMedian -// - -#include - -RunningMedian samples = RunningMedian(5); - -void setup() -{ - Serial.begin(115200); - Serial.print("Running Median Version: "); - Serial.println(RUNNING_MEDIAN_VERSION); -} - -void loop() -{ - test1(); -} - -void test1() -{ - int x = analogRead(A0); - - samples.add(x); - // calculate the 5% quantile => 0.05 - long q = samples.getQuantile(0.05); - - Serial.print(millis()); - Serial.print("\t"); - Serial.println(q); - delay(100); -} - -// -- END OF FILE -- diff --git a/KorMYS/.pio/libdeps/uno/RunningMedian/examples/RunningMedianTest1/RunningMedianTest1.ino b/KorMYS/.pio/libdeps/uno/RunningMedian/examples/RunningMedianTest1/RunningMedianTest1.ino deleted file mode 100644 index d4c7e76..0000000 --- a/KorMYS/.pio/libdeps/uno/RunningMedian/examples/RunningMedianTest1/RunningMedianTest1.ino +++ /dev/null @@ -1,163 +0,0 @@ -// -// FILE: runningMedianTest1.ino -// AUTHOR: Rob Tillaart -// VERSION: 0.1.1 -// PURPOSE: test functionality -// DATE: 2013-10-28 -// URL: https://github.com/RobTillaart/RunningMedian -// - -#include - -const int sourceData[] = -{ // 50 consecutive samples from Sharp distance sensor model GP2Y0A710K0F while stationary. - 300, 299, 296, 343, 307, 304, 303, 305, 300, 340, - 308, 305, 300, 304, 311, 304, 300, 300, 304, 304, - 284, 319, 306, 304, 300, 302, 305, 310, 306, 304, - 308, 300, 299, 304, 300, 305, 307, 303, 326, 311, - 306, 304, 305, 300, 300, 307, 302, 305, 296, 300 -}; -const int sourceSize = (sizeof(sourceData)/sizeof(sourceData[0])); - -RunningMedian samples = RunningMedian(sourceSize); - -void setup() -{ - Serial.begin(115200); - while (!Serial); // Wait for serial port to connect. Needed for Leonardo only. - delay(1000); // Simply to allow time for the ERW versions of the IDE time to automagically open the Serial Monitor. 1 second chosen arbitrarily. - Serial.print(F("Running Median Version: ")); - Serial.println(RUNNING_MEDIAN_VERSION); - - -#ifdef RUNNING_MEDIAN_USE_MALLOC - Serial.println(F("Dynamic version using malloc() enabled")); -#else - Serial.print(F("Static version, will always allocate an array of ")); - Serial.print(MEDIAN_MAX_SIZE, DEC); - Serial.println(F(" floats.")); -#endif - - test1(); - - Serial.println("\ndone..\n"); -} - -void loop() -{ -} - -void test1() -{ - uint32_t start = 0; - uint32_t stop = 0; - float result = 0; - - Serial.print(F("Requested median array size = ")); - Serial.println(sourceSize); - Serial.print(F(" Actual allocated size = ")); - Serial.println(samples.getSize()); - Serial.println(); - - // 50 iterations !! - for (uint8_t i = 0; i <= (sourceSize - 1); i++) - { - Serial.print(F("Loop number : ")); - Serial.println(i + 1); - - start = micros(); - samples.add(sourceData[i]); - stop = micros(); - Serial.print(F("Time to add the next element to the array = ")); - Serial.println(stop - start); - - - Serial.println(F("Cumulative source data added:")); - Serial.print(F(" ")); - for (uint8_t j = 0; j <= i; j++) - { - Serial.print(sourceData[j]); - Serial.print(F(" ")); - } - Serial.println(); - - - Serial.println(F("Unsorted accumulated array:")); - Serial.print(F(" ")); - for (uint8_t j = 0; j < samples.getCount(); j++) - { - Serial.print(samples.getElement(j)); - Serial.print(F(" ")); - } - Serial.println(); - - - start = micros(); - result = samples.getSortedElement(0); - stop = micros(); - Serial.print(F("Time to sort array and return element number zero = ")); - Serial.println(stop - start); - - - Serial.println(F("Sorted accumulated array:")); - Serial.print(F(" ")); - for (uint8_t j = 0; j < samples.getCount(); j++) - { - Serial.print(samples.getSortedElement(j)); - Serial.print(F(" ")); - } - Serial.println(); - - - start = micros(); - result = samples.getMedian(); - stop = micros(); - Serial.print(F("getMedian() result = ")); - Serial.println(result); - Serial.print(F("Time to execute getMedian() = ")); - Serial.println(stop - start); - - - start = micros(); - result = samples.getAverage(); - stop = micros(); - Serial.print(F("getAverage() result = ")); - Serial.println(result); - Serial.print(F("Time to execute getAverage() = ")); - Serial.println(stop - start); - - - Serial.println(F("getAverage(x) results where:")); - for (uint8_t j = 1; j <= samples.getCount(); j++) - { - start = micros(); - result = samples.getAverage(j); - stop = micros(); - Serial.print(F(" x = ")); - Serial.print(j); - Serial.print(F(" => ")); - Serial.print(result); - Serial.print(F(" Time to execute = ")); - Serial.println(stop - start); - } - - Serial.println(F("predict(x) results where:")); - for (uint8_t j = 1; j <= (samples.getCount() / 2); j++) - { - start = micros(); - result = samples.predict(j); - stop = micros(); - Serial.print(F(" x = ")); - Serial.print(j); - Serial.print(F(" => ")); - Serial.print(result); - Serial.print(F(" Time to execute = ")); - Serial.println(stop - start); - } - - Serial.println(); - Serial.println(); - } -} - -// -- END OF FILE -- \ No newline at end of file diff --git a/KorMYS/.pio/libdeps/uno/RunningMedian/examples/RunningMedian_large/RunningMedian_large.ino b/KorMYS/.pio/libdeps/uno/RunningMedian/examples/RunningMedian_large/RunningMedian_large.ino deleted file mode 100644 index fe0ebe9..0000000 --- a/KorMYS/.pio/libdeps/uno/RunningMedian/examples/RunningMedian_large/RunningMedian_large.ino +++ /dev/null @@ -1,66 +0,0 @@ -// -// FILE: RunningMedian_large.ino -// AUTHOR: Rob Tillaart -// VERSION: 0.1.3 -// PURPOSE: demo most functions -// DATE: 2013-10-17 -// URL: https://github.com/RobTillaart/RunningMedian -// - -#include "RunningMedian.h" - - -RunningMedian samples = RunningMedian(255); - - -long count = 0; - -uint32_t start, dur1, dur2, dur3; - - -void setup() -{ - Serial.begin(115200); - Serial.print(F("Running Median Version: ")); - Serial.println(RUNNING_MEDIAN_VERSION); - - Serial.println(samples.getSize()); -} - - -void loop() -{ - if (count < 255) - { - start = micros(); - samples.add(256 - count); - dur1 = micros() - start; - start = micros(); - count = samples.getCount(); - dur2 = micros() - start; - start = micros(); - float value = samples.getMedian(); - dur3 = micros() - start; - - Serial.print(count); - Serial.print('\t'); - Serial.print(dur1); - Serial.print('\t'); - Serial.print(dur2); - Serial.print('\t'); - Serial.print(dur3); - Serial.print('\t'); - Serial.println(); - } - - if (count == 255) - { - for (int i = 0; i < 255; i++) - { - Serial.println(samples.getSortedElement(i)); - } - } - count++; -} - -// -- END OF FILE -- diff --git a/KorMYS/.pio/libdeps/uno/RunningMedian/keywords.txt b/KorMYS/.pio/libdeps/uno/RunningMedian/keywords.txt deleted file mode 100644 index d7f2058..0000000 --- a/KorMYS/.pio/libdeps/uno/RunningMedian/keywords.txt +++ /dev/null @@ -1,23 +0,0 @@ -# Syntax Coloring Map for RunningMedian - -# Datatypes (KEYWORD1) -RunningMedian KEYWORD1 - -# Methods and Functions (KEYWORD2) -add KEYWORD2 -clear KEYWORD2 -getMedian KEYWORD2 -getQuantile KEYWORD2 -getAverage KEYWORD2 -getHighest KEYWORD2 -getLowest KEYWORD2 -getSize KEYWORD2 -getCount KEYWORD2 -getElement KEYWORD2 -getSortedElement KEYWORD2 -predict KEYWORD2 -getStatus KEYWORD2 - -# Constants (LITERAL1) -OK LITERAL1 -NOK LITERAL1 \ No newline at end of file diff --git a/KorMYS/.pio/libdeps/uno/RunningMedian/library.json b/KorMYS/.pio/libdeps/uno/RunningMedian/library.json deleted file mode 100644 index 29fc786..0000000 --- a/KorMYS/.pio/libdeps/uno/RunningMedian/library.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "RunningMedian", - "keywords": "running, moving, median, average, outliers", - "description": "The library stores the last N individual values in a buffer to select the median. It filters outliers.", - "authors": - [ - { - "name": "Rob Tillaart", - "email": "Rob.Tillaart@gmail.com", - "maintainer": true - } - ], - "repository": - { - "type": "git", - "url": "https://github.com/RobTillaart/RunningMedian.git" - }, - "version":"0.3.3", - "frameworks": "arduino", - "platforms": "*" -} diff --git a/KorMYS/.pio/libdeps/uno/RunningMedian/library.properties b/KorMYS/.pio/libdeps/uno/RunningMedian/library.properties deleted file mode 100644 index c295e0b..0000000 --- a/KorMYS/.pio/libdeps/uno/RunningMedian/library.properties +++ /dev/null @@ -1,11 +0,0 @@ -name=RunningMedian -version=0.3.3 -author=Rob Tillaart -maintainer=Rob Tillaart -sentence=The library stores the last N individual values in a buffer to select the median. -paragraph=This will filter outliers in a chain of samples very well. -category=Data Processing -url=https://github.com/RobTillaart/RunningMedian -architectures=* -includes=RunningMedian.h -depends= diff --git a/KorMYS/.pio/libdeps/uno/RunningMedian/test/unit_test_001.cpp b/KorMYS/.pio/libdeps/uno/RunningMedian/test/unit_test_001.cpp deleted file mode 100644 index 3881aed..0000000 --- a/KorMYS/.pio/libdeps/uno/RunningMedian/test/unit_test_001.cpp +++ /dev/null @@ -1,123 +0,0 @@ -// -// FILE: unit_test_001.cpp -// AUTHOR: Rob Tillaart -// DATE: 2021-01-03 -// PURPOSE: unit tests for the RunningMedian -// https://github.com/RobTillaart/RunningMedian -// https://github.com/Arduino-CI/arduino_ci/blob/master/REFERENCE.md -// - -// supported assertions -// ---------------------------- -// assertEqual(expected, actual); // a == b -// assertNotEqual(unwanted, actual); // a != b -// assertComparativeEquivalent(expected, actual); // abs(a - b) == 0 or (!(a > b) && !(a < b)) -// assertComparativeNotEquivalent(unwanted, actual); // abs(a - b) > 0 or ((a > b) || (a < b)) -// assertLess(upperBound, actual); // a < b -// assertMore(lowerBound, actual); // a > b -// assertLessOrEqual(upperBound, actual); // a <= b -// assertMoreOrEqual(lowerBound, actual); // a >= b -// assertTrue(actual); -// assertFalse(actual); -// assertNull(actual); - -// // special cases for floats -// assertEqualFloat(expected, actual, epsilon); // fabs(a - b) <= epsilon -// assertNotEqualFloat(unwanted, actual, epsilon); // fabs(a - b) >= epsilon -// assertInfinity(actual); // isinf(a) -// assertNotInfinity(actual); // !isinf(a) -// assertNAN(arg); // isnan(a) -// assertNotNAN(arg); // !isnan(a) - -#include - - -#include "Arduino.h" -#include "RunningMedian.h" - - - -unittest_setup() -{ -} - -unittest_teardown() -{ -} - - -unittest(test_constructor) -{ - fprintf(stderr, "VERSION: %s\n", RUNNING_MEDIAN_VERSION); - - RunningMedian samples = RunningMedian(5); - assertEqual(5, samples.getSize()); - assertEqual(0, samples.getCount()); - - // TODO default values? -} - - -unittest(test_basic_add) -{ - fprintf(stderr, "VERSION: %s\n", RUNNING_MEDIAN_VERSION); - - RunningMedian samples = RunningMedian(5); - - int cnt = 0; - for (int i = 0, cnt = 0; i < 50; i+=10) - { - samples.add(i); - cnt++; - assertEqual(cnt, samples.getCount()); - } - assertEqual(5, samples.getSize()); - assertEqualFloat(20, samples.getMedian(), 0.0001); - assertEqualFloat(20, samples.getAverage(), 0.0001); - assertEqualFloat(00, samples.getLowest(), 0.0001); - assertEqualFloat(40, samples.getHighest(), 0.0001); - - samples.add(100); // 6th element - assertEqual(5, samples.getSize()); - assertEqual(5, samples.getCount()); - - assertEqualFloat(30, samples.getMedian(), 0.0001); - assertEqualFloat(40, samples.getAverage(), 0.0001); - assertEqualFloat(10, samples.getLowest(), 0.0001); - assertEqualFloat(100, samples.getHighest(), 0.0001); - - samples.clear(); - assertEqual(5, samples.getSize()); - assertEqual(0, samples.getCount()); -} - - -unittest(test_big) -{ - fprintf(stderr, "VERSION: %s\n", RUNNING_MEDIAN_VERSION); - - RunningMedian samples = RunningMedian(100); - assertEqual(100, samples.getSize()); - assertEqual(0, samples.getCount()); - - for (int i = 0; i < 110; i++) - { - samples.add(i); - } - assertEqual(100, samples.getSize()); - assertEqual(100, samples.getCount()); - - assertEqualFloat(59.5, samples.getMedian(), 0.0001); - assertEqualFloat(59.5, samples.getAverage(), 0.0001); - assertEqualFloat(10, samples.getLowest(), 0.0001); - assertEqualFloat(109, samples.getHighest(), 0.0001); - - samples.clear(); - assertEqual(100, samples.getSize()); - assertEqual(0, samples.getCount()); -} - - -unittest_main() - -// -------- diff --git a/KorMYS/.pio/libdeps/uno/SoftwareSerial/.piopm b/KorMYS/.pio/libdeps/uno/SoftwareSerial/.piopm deleted file mode 100644 index 1e3b9a2..0000000 --- a/KorMYS/.pio/libdeps/uno/SoftwareSerial/.piopm +++ /dev/null @@ -1 +0,0 @@ -{"type": "library", "name": "SoftwareSerial", "version": "1.0.0", "spec": {"owner": "featherfly", "id": 7212, "name": "SoftwareSerial", "requirements": null, "url": null}} \ No newline at end of file diff --git a/KorMYS/.pio/libdeps/uno/SoftwareSerial/SoftwareSerial.cpp b/KorMYS/.pio/libdeps/uno/SoftwareSerial/SoftwareSerial.cpp deleted file mode 100644 index 8dd8bd6..0000000 --- a/KorMYS/.pio/libdeps/uno/SoftwareSerial/SoftwareSerial.cpp +++ /dev/null @@ -1,677 +0,0 @@ -/* -SoftwareSerial.cpp (formerly NewSoftSerial.cpp) - -Multi-instance software serial library for Arduino/Wiring --- Interrupt-driven receive and other improvements by ladyada - (http://ladyada.net) --- Tuning, circular buffer, derivation from class Print/Stream, - multi-instance support, porting to 8MHz processors, - various optimizations, PROGMEM delay tables, inverse logic and - direct port writing by Mikal Hart (http://www.arduiniana.org) --- Pin change interrupt macros by Paul Stoffregen (http://www.pjrc.com) --- 20MHz processor support by Garrett Mace (http://www.macetech.com) --- ATmega1280/2560 support by Brett Hagman (http://www.roguerobotics.com/) - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -The latest version of this library can always be found at -http://arduiniana.org. -*/ - -// When set, _DEBUG co-opts pins 11 and 13 for debugging with an -// oscilloscope or logic analyzer. Beware: it also slightly modifies -// the bit times, so don't rely on it too much at high baud rates -#define _DEBUG 0 -#define _DEBUG_PIN1 11 -#define _DEBUG_PIN2 13 -// -// Includes -// -#include -#include -#include -#include - - -#if defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MKL26Z64__) || defined(__MK64FX512__) || defined(__MK66FX1M0__) || defined(__IMXRT1052__) || defined(__IMXRT1062__) - -SoftwareSerial::SoftwareSerial(uint8_t rxPin, uint8_t txPin, bool inverse_logic /* = false */) -{ - buffer_overflow = false; - #if defined(__IMXRT1052__) || defined(__IMXRT1062__) - if (rxPin == 0 && txPin == 1) { - port = &Serial1; - return; - } else if (rxPin == 6 && txPin == 7) { - port = &Serial2; - return; - } else if (rxPin == 14 && txPin == 15) { - port = &Serial3; - return; - } else if (rxPin == 16 && txPin == 17) { - port = &Serial4; - return; - } else if (rxPin == 21 && txPin == 20) { - port = &Serial5; - return; - } else if (rxPin == 25 && txPin == 24) { - port = &Serial6; - return; - } else if (rxPin == 28 && txPin == 29) { - port = &Serial7; - return; - } - #else - if (rxPin == 0 && txPin == 1) { - port = &Serial1; - return; - } else if (rxPin == 9 && txPin == 10) { - port = &Serial2; - return; - } else if (rxPin == 7 && txPin == 8) { - port = &Serial3; - return; - } - #endif - port = NULL; - pinMode(txPin, OUTPUT); - pinMode(rxPin, INPUT_PULLUP); - txpin = txPin; - rxpin = rxPin; - txreg = portOutputRegister(digitalPinToPort(txPin)); - rxreg = portInputRegister(digitalPinToPort(rxPin)); - cycles_per_bit = 0; -} - -void SoftwareSerial::begin(unsigned long speed) -{ - if (port) { - port->begin(speed); - } else { - cycles_per_bit = (uint32_t)(F_CPU + speed / 2) / speed; - ARM_DEMCR |= ARM_DEMCR_TRCENA; - ARM_DWT_CTRL |= ARM_DWT_CTRL_CYCCNTENA; - } -} - -void SoftwareSerial::end() -{ - if (port) { - port->end(); - port = NULL; - } else { - pinMode(txpin, INPUT); - pinMode(rxpin, INPUT); - } - cycles_per_bit = 0; -} - -// The worst case expected length of any interrupt routines. If an -// interrupt runs longer than this number of cycles, it can disrupt -// the transmit waveform. Increasing this number causes SoftwareSerial -// to hog the CPU longer, delaying all interrupt response for other -// libraries, so this should be made as small as possible but still -// ensure accurate transmit waveforms. -#define WORST_INTERRUPT_CYCLES 360 - -static void wait_for_target(uint32_t begin, uint32_t target) -{ - if (target - (ARM_DWT_CYCCNT - begin) > WORST_INTERRUPT_CYCLES+20) { - uint32_t pretarget = target - WORST_INTERRUPT_CYCLES; - //digitalWriteFast(12, HIGH); - interrupts(); - while (ARM_DWT_CYCCNT - begin < pretarget) ; // wait - noInterrupts(); - //digitalWriteFast(12, LOW); - } - while (ARM_DWT_CYCCNT - begin < target) ; // wait -} - -size_t SoftwareSerial::write(uint8_t b) -{ - elapsedMicros elapsed; - uint32_t target; - uint8_t mask; - uint32_t begin_cycle; - - // use hardware serial, if possible - if (port) return port->write(b); - if (cycles_per_bit == 0) return 0; - ARM_DEMCR |= ARM_DEMCR_TRCENA; - ARM_DWT_CTRL |= ARM_DWT_CTRL_CYCCNTENA; - // start bit - target = cycles_per_bit; - noInterrupts(); - begin_cycle = ARM_DWT_CYCCNT; - *txreg = 0; - wait_for_target(begin_cycle, target); - // 8 data bits - for (mask = 1; mask; mask <<= 1) { - *txreg = (b & mask) ? 1 : 0; - target += cycles_per_bit; - wait_for_target(begin_cycle, target); - } - // stop bit - *txreg = 1; - interrupts(); - target += cycles_per_bit; - while (ARM_DWT_CYCCNT - begin_cycle < target) ; // wait - return 1; -} - -void SoftwareSerial::flush() -{ - if (port) port->flush(); -} - -// TODO implement reception using pin change DMA capturing -// ARM_DWT_CYCCNT and the bitband mapped GPIO_PDIR register -// to a circular buffer (8 bytes per event... memory intensive) - -int SoftwareSerial::available() -{ - if (port) return port->available(); - return 0; -} - -int SoftwareSerial::peek() -{ - if (port) return port->peek(); - return -1; -} - -int SoftwareSerial::read() -{ - if (port) return port->read(); - return -1; -} - -#else - -// -// Lookup table -// -typedef struct _DELAY_TABLE -{ - long baud; - unsigned short rx_delay_centering; - unsigned short rx_delay_intrabit; - unsigned short rx_delay_stopbit; - unsigned short tx_delay; -} DELAY_TABLE; - -#if F_CPU == 16000000 - -static const DELAY_TABLE PROGMEM table[] = -{ - // baud rxcenter rxintra rxstop tx - { 115200, 1, 17, 17, 12, }, - { 57600, 10, 37, 37, 33, }, - { 38400, 25, 57, 57, 54, }, - { 31250, 31, 70, 70, 68, }, - { 28800, 34, 77, 77, 74, }, - { 19200, 54, 117, 117, 114, }, - { 14400, 74, 156, 156, 153, }, - { 9600, 114, 236, 236, 233, }, - { 4800, 233, 474, 474, 471, }, - { 2400, 471, 950, 950, 947, }, - { 1200, 947, 1902, 1902, 1899, }, - { 600, 1902, 3804, 3804, 3800, }, - { 300, 3804, 7617, 7617, 7614, }, -}; - -const int XMIT_START_ADJUSTMENT = 5; - -#elif F_CPU == 8000000 - -static const DELAY_TABLE table[] PROGMEM = -{ - // baud rxcenter rxintra rxstop tx - { 115200, 1, 5, 5, 3, }, - { 57600, 1, 15, 15, 13, }, - { 38400, 2, 25, 26, 23, }, - { 31250, 7, 32, 33, 29, }, - { 28800, 11, 35, 35, 32, }, - { 19200, 20, 55, 55, 52, }, - { 14400, 30, 75, 75, 72, }, - { 9600, 50, 114, 114, 112, }, - { 4800, 110, 233, 233, 230, }, - { 2400, 229, 472, 472, 469, }, - { 1200, 467, 948, 948, 945, }, - { 600, 948, 1895, 1895, 1890, }, - { 300, 1895, 3805, 3805, 3802, }, -}; - -const int XMIT_START_ADJUSTMENT = 4; - -#elif F_CPU == 20000000 - -// 20MHz support courtesy of the good people at macegr.com. -// Thanks, Garrett! - -static const DELAY_TABLE PROGMEM table[] = -{ - // baud rxcenter rxintra rxstop tx - { 115200, 3, 21, 21, 18, }, - { 57600, 20, 43, 43, 41, }, - { 38400, 37, 73, 73, 70, }, - { 31250, 45, 89, 89, 88, }, - { 28800, 46, 98, 98, 95, }, - { 19200, 71, 148, 148, 145, }, - { 14400, 96, 197, 197, 194, }, - { 9600, 146, 297, 297, 294, }, - { 4800, 296, 595, 595, 592, }, - { 2400, 592, 1189, 1189, 1186, }, - { 1200, 1187, 2379, 2379, 2376, }, - { 600, 2379, 4759, 4759, 4755, }, - { 300, 4759, 9523, 9523, 9520, }, -}; - -const int XMIT_START_ADJUSTMENT = 6; - -#else - -#error This version of SoftwareSerial supports only 20, 16 and 8MHz processors - -#endif - -// -// Statics -// -SoftwareSerial *SoftwareSerial::active_object = 0; -char SoftwareSerial::_receive_buffer[_SS_MAX_RX_BUFF]; -volatile uint8_t SoftwareSerial::_receive_buffer_tail = 0; -volatile uint8_t SoftwareSerial::_receive_buffer_head = 0; - -// -// Debugging -// -// This function generates a brief pulse -// for debugging or measuring on an oscilloscope. -inline void DebugPulse(uint8_t pin, uint8_t count) -{ -#if _DEBUG - volatile uint8_t *pport = portOutputRegister(digitalPinToPort(pin)); - - uint8_t val = *pport; - while (count--) - { - *pport = val | digitalPinToBitMask(pin); - *pport = val; - } -#endif -} - -// -// Private methods -// - -/* static */ -inline void SoftwareSerial::tunedDelay(uint16_t delay) { - uint8_t tmp=0; - - asm volatile("sbiw %0, 0x01 \n\t" - "ldi %1, 0xFF \n\t" - "cpi %A0, 0xFF \n\t" - "cpc %B0, %1 \n\t" - "brne .-10 \n\t" - : "+r" (delay), "+a" (tmp) - : "0" (delay) - ); -} - -// This function sets the current object as the "listening" -// one and returns true if it replaces another -bool SoftwareSerial::listen() -{ - if (active_object != this) - { - _buffer_overflow = false; - uint8_t oldSREG = SREG; - cli(); - _receive_buffer_head = _receive_buffer_tail = 0; - active_object = this; - SREG = oldSREG; - return true; - } - - return false; -} - -// -// The receive routine called by the interrupt handler -// -void SoftwareSerial::recv() -{ - -#if GCC_VERSION < 40302 -// Work-around for avr-gcc 4.3.0 OSX version bug -// Preserve the registers that the compiler misses -// (courtesy of Arduino forum user *etracer*) - asm volatile( - "push r18 \n\t" - "push r19 \n\t" - "push r20 \n\t" - "push r21 \n\t" - "push r22 \n\t" - "push r23 \n\t" - "push r26 \n\t" - "push r27 \n\t" - ::); -#endif - - uint8_t d = 0; - - // If RX line is high, then we don't see any start bit - // so interrupt is probably not for us - if (_inverse_logic ? rx_pin_read() : !rx_pin_read()) - { - // Wait approximately 1/2 of a bit width to "center" the sample - tunedDelay(_rx_delay_centering); - DebugPulse(_DEBUG_PIN2, 1); - - // Read each of the 8 bits - for (uint8_t i=0x1; i; i <<= 1) - { - tunedDelay(_rx_delay_intrabit); - DebugPulse(_DEBUG_PIN2, 1); - uint8_t noti = ~i; - if (rx_pin_read()) - d |= i; - else // else clause added to ensure function timing is ~balanced - d &= noti; - } - - // skip the stop bit - tunedDelay(_rx_delay_stopbit); - DebugPulse(_DEBUG_PIN2, 1); - - if (_inverse_logic) - d = ~d; - - // if buffer full, set the overflow flag and return - if ((_receive_buffer_tail + 1) % _SS_MAX_RX_BUFF != _receive_buffer_head) - { - // save new data in buffer: tail points to where byte goes - _receive_buffer[_receive_buffer_tail] = d; // save new byte - _receive_buffer_tail = (_receive_buffer_tail + 1) % _SS_MAX_RX_BUFF; - } - else - { -#if _DEBUG // for scope: pulse pin as overflow indictator - DebugPulse(_DEBUG_PIN1, 1); -#endif - _buffer_overflow = true; - } - } - -#if GCC_VERSION < 40302 -// Work-around for avr-gcc 4.3.0 OSX version bug -// Restore the registers that the compiler misses - asm volatile( - "pop r27 \n\t" - "pop r26 \n\t" - "pop r23 \n\t" - "pop r22 \n\t" - "pop r21 \n\t" - "pop r20 \n\t" - "pop r19 \n\t" - "pop r18 \n\t" - ::); -#endif -} - -void SoftwareSerial::tx_pin_write(uint8_t pin_state) -{ - if (pin_state == LOW) - *_transmitPortRegister &= ~_transmitBitMask; - else - *_transmitPortRegister |= _transmitBitMask; -} - -uint8_t SoftwareSerial::rx_pin_read() -{ - return *_receivePortRegister & _receiveBitMask; -} - -// -// Interrupt handling -// - -/* static */ -inline void SoftwareSerial::handle_interrupt() -{ - if (active_object) - { - active_object->recv(); - } -} - -#if defined(PCINT0_vect) -ISR(PCINT0_vect) -{ - SoftwareSerial::handle_interrupt(); -} -#endif - -#if defined(PCINT1_vect) -ISR(PCINT1_vect) -{ - SoftwareSerial::handle_interrupt(); -} -#endif - -#if defined(PCINT2_vect) -ISR(PCINT2_vect) -{ - SoftwareSerial::handle_interrupt(); -} -#endif - -#if defined(PCINT3_vect) -ISR(PCINT3_vect) -{ - SoftwareSerial::handle_interrupt(); -} -#endif - -// -// Constructor -// -SoftwareSerial::SoftwareSerial(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic /* = false */) : - _rx_delay_centering(0), - _rx_delay_intrabit(0), - _rx_delay_stopbit(0), - _tx_delay(0), - _buffer_overflow(false), - _inverse_logic(inverse_logic) -{ - setTX(transmitPin); - setRX(receivePin); -} - -// -// Destructor -// -SoftwareSerial::~SoftwareSerial() -{ - end(); -} - -void SoftwareSerial::setTX(uint8_t tx) -{ - pinMode(tx, OUTPUT); - digitalWrite(tx, HIGH); - _transmitBitMask = digitalPinToBitMask(tx); - uint8_t port = digitalPinToPort(tx); - _transmitPortRegister = portOutputRegister(port); -} - -void SoftwareSerial::setRX(uint8_t rx) -{ - pinMode(rx, INPUT); - if (!_inverse_logic) - digitalWrite(rx, HIGH); // pullup for normal logic! - _receivePin = rx; - _receiveBitMask = digitalPinToBitMask(rx); - uint8_t port = digitalPinToPort(rx); - _receivePortRegister = portInputRegister(port); -} - -// -// Public methods -// - -void SoftwareSerial::begin(long speed) -{ - _rx_delay_centering = _rx_delay_intrabit = _rx_delay_stopbit = _tx_delay = 0; - - for (unsigned i=0; i -#include -#include - -/****************************************************************************** -* Definitions -******************************************************************************/ - -#define _SS_MAX_RX_BUFF 64 // RX buffer size -#ifndef GCC_VERSION -#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) -#endif - -#if defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MKL26Z64__) || defined(__MK64FX512__) || defined(__MK66FX1M0__) || defined(__IMXRT1052__) || defined(__IMXRT1062__) - -class SoftwareSerial : public Stream -{ -public: - SoftwareSerial(uint8_t rxPin, uint8_t txPin, bool inverse_logic = false); - ~SoftwareSerial() { end(); } - void begin(unsigned long speed); - void end(); - bool listen() { return true; } - bool isListening() { return true; } - bool overflow() { bool ret = buffer_overflow; buffer_overflow = false; return ret; } - virtual int available(); - virtual int read(); - int peek(); - virtual void flush(); - virtual size_t write(uint8_t byte); - using Print::write; -private: - HardwareSerial *port; - uint32_t cycles_per_bit; - #if defined(__IMXRT1052__) || defined(__IMXRT1062__) - volatile uint32_t *txreg; - volatile uint32_t *rxreg; - #else - volatile uint8_t *txreg; - volatile uint8_t *rxreg; - #endif - bool buffer_overflow; - uint8_t txpin; - uint8_t rxpin; -}; - -#else -class SoftwareSerial : public Stream -{ -private: - // per object data - uint8_t _receivePin; - uint8_t _receiveBitMask; - volatile uint8_t *_receivePortRegister; - uint8_t _transmitBitMask; - volatile uint8_t *_transmitPortRegister; - - uint16_t _rx_delay_centering; - uint16_t _rx_delay_intrabit; - uint16_t _rx_delay_stopbit; - uint16_t _tx_delay; - - uint16_t _buffer_overflow:1; - uint16_t _inverse_logic:1; - - // static data - static char _receive_buffer[_SS_MAX_RX_BUFF]; - static volatile uint8_t _receive_buffer_tail; - static volatile uint8_t _receive_buffer_head; - static SoftwareSerial *active_object; - - // private methods - void recv(); - uint8_t rx_pin_read(); - void tx_pin_write(uint8_t pin_state); - void setTX(uint8_t transmitPin); - void setRX(uint8_t receivePin); - - // private static method for timing - static inline void tunedDelay(uint16_t delay); - - -public: - // public methods - SoftwareSerial(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic = false); - ~SoftwareSerial(); - void begin(long speed); - bool listen(); - void end(); - bool isListening() { return this == active_object; } - bool overflow() { bool ret = _buffer_overflow; _buffer_overflow = false; return ret; } - int peek(); - - virtual size_t write(uint8_t byte); - virtual int read(); - virtual int available(); - virtual void flush(); - - using Print::write; - - // public only for easy access by interrupt handlers - static inline void handle_interrupt(); -}; - -// Arduino 0012 workaround -#undef int -#undef char -#undef long -#undef byte -#undef float -#undef abs -#undef round - -#endif - -#endif diff --git a/KorMYS/.pio/libdeps/uno/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino b/KorMYS/.pio/libdeps/uno/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino deleted file mode 100644 index 6101bb1..0000000 --- a/KorMYS/.pio/libdeps/uno/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino +++ /dev/null @@ -1,55 +0,0 @@ -/* - Software serial multple serial test - - Receives from the hardware serial, sends to software serial. - Receives from software serial, sends to hardware serial. - - The circuit: - * RX is digital pin 10 (connect to TX of other device) - * TX is digital pin 11 (connect to RX of other device) - - Note: - Not all pins on the Mega and Mega 2560 support change interrupts, - so only the following can be used for RX: - 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69 - - Not all pins on the Leonardo support change interrupts, - so only the following can be used for RX: - 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI). - - created back in the mists of time - modified 25 May 2012 - by Tom Igoe - based on Mikal Hart's example - - This example code is in the public domain. - - */ -#include - -SoftwareSerial mySerial(10, 11); // RX, TX - -void setup() -{ - // Open serial communications and wait for port to open: - Serial.begin(57600); - while (!Serial) { - ; // wait for serial port to connect. Needed for Leonardo only - } - - - Serial.println("Goodnight moon!"); - - // set the data rate for the SoftwareSerial port - mySerial.begin(4800); - mySerial.println("Hello, world?"); -} - -void loop() // run over and over -{ - if (mySerial.available()) - Serial.write(mySerial.read()); - if (Serial.available()) - mySerial.write(Serial.read()); -} - diff --git a/KorMYS/.pio/libdeps/uno/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino b/KorMYS/.pio/libdeps/uno/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino deleted file mode 100644 index d607ee6..0000000 --- a/KorMYS/.pio/libdeps/uno/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino +++ /dev/null @@ -1,93 +0,0 @@ -/* - Software serial multple serial test - - Receives from the two software serial ports, - sends to the hardware serial port. - - In order to listen on a software port, you call port.listen(). - When using two software serial ports, you have to switch ports - by listen()ing on each one in turn. Pick a logical time to switch - ports, like the end of an expected transmission, or when the - buffer is empty. This example switches ports when there is nothing - more to read from a port - - The circuit: - Two devices which communicate serially are needed. - * First serial device's TX attached to digital pin 2, RX to pin 3 - * Second serial device's TX attached to digital pin 4, RX to pin 5 - - Note: - Not all pins on the Mega and Mega 2560 support change interrupts, - so only the following can be used for RX: - 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69 - - Not all pins on the Leonardo support change interrupts, - so only the following can be used for RX: - 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI). - - created 18 Apr. 2011 - modified 25 May 2012 - by Tom Igoe - based on Mikal Hart's twoPortRXExample - - This example code is in the public domain. - - */ - -#include -// software serial #1: TX = digital pin 10, RX = digital pin 11 -SoftwareSerial portOne(10,11); - -// software serial #2: TX = digital pin 8, RX = digital pin 9 -// on the Mega, use other pins instead, since 8 and 9 don't work on the Mega -SoftwareSerial portTwo(8,9); - -void setup() -{ - // Open serial communications and wait for port to open: - Serial.begin(9600); - while (!Serial) { - ; // wait for serial port to connect. Needed for Leonardo only - } - - - // Start each software serial port - portOne.begin(9600); - portTwo.begin(9600); -} - -void loop() -{ - // By default, the last intialized port is listening. - // when you want to listen on a port, explicitly select it: - portOne.listen(); - Serial.println("Data from port one:"); - // while there is data coming in, read it - // and send to the hardware serial port: - while (portOne.available() > 0) { - char inByte = portOne.read(); - Serial.write(inByte); - } - - // blank line to separate data from the two ports: - Serial.println(); - - // Now listen on the second port - portTwo.listen(); - // while there is data coming in, read it - // and send to the hardware serial port: - Serial.println("Data from port two:"); - while (portTwo.available() > 0) { - char inByte = portTwo.read(); - Serial.write(inByte); - } - - // blank line to separate data from the two ports: - Serial.println(); -} - - - - - - diff --git a/KorMYS/.pio/libdeps/uno/SoftwareSerial/keywords.txt b/KorMYS/.pio/libdeps/uno/SoftwareSerial/keywords.txt deleted file mode 100644 index aaea17c..0000000 --- a/KorMYS/.pio/libdeps/uno/SoftwareSerial/keywords.txt +++ /dev/null @@ -1,30 +0,0 @@ -####################################### -# Syntax Coloring Map for SoftwareSerial -# (formerly NewSoftSerial) -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### - -SoftwareSerial KEYWORD1 - -####################################### -# Methods and Functions (KEYWORD2) -####################################### - -begin KEYWORD2 -end KEYWORD2 -read KEYWORD2 -write KEYWORD2 -available KEYWORD2 -isListening KEYWORD2 -overflow KEYWORD2 -flush KEYWORD2 -listen KEYWORD2 -peek KEYWORD2 - -####################################### -# Constants (LITERAL1) -####################################### - diff --git a/KorMYS/.pio/libdeps/uno/SoftwareSerial/library.json b/KorMYS/.pio/libdeps/uno/SoftwareSerial/library.json deleted file mode 100644 index 6373d23..0000000 --- a/KorMYS/.pio/libdeps/uno/SoftwareSerial/library.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "SoftwareSerial", - "keywords": "SoftwareSerial", - "description": "The SoftwareSerial library has been developed to allow serial communication, using software to replicate the functionality of the hardware UART. It is possible to have multiple software serial ports with speeds up to 115200 bps. On 32 bit Teensy boards, SoftwareSerial uses the real hardware serial ports (and is restricted to only those pins), but allows compatibility with programs that depend on SoftwareSerial.", - "repository": - { - "type": "git", - "url": "https://github.com/featherfly/SoftwareSerial.git" - }, - "authors": - [ - { - "name": "Arduino", - "maintainer": true, - "url": "https://www.arduino.cc" - }, - { - "name": "Paul Stoffregen", - "maintainer": true - }, - { - "name": "yufei", - "email": "featherfly@foxmail.com" - } - ], - "dependencies": [ - ], - "version": "1.0", - "frameworks": "arduino", - "platforms": "*" - } \ No newline at end of file diff --git a/KorMYS/.pio/libdeps/uno/SoftwareSerial/library.properties b/KorMYS/.pio/libdeps/uno/SoftwareSerial/library.properties deleted file mode 100644 index d96fa4f..0000000 --- a/KorMYS/.pio/libdeps/uno/SoftwareSerial/library.properties +++ /dev/null @@ -1,10 +0,0 @@ -name=SoftwareSerial -version=1.0 -author=Arduino -maintainer=Paul Stoffregen -sentence=Enables serial communication on any digital pin. -paragraph=The SoftwareSerial library has been developed to allow serial communication, using software to replicate the functionality of the hardware UART. It is possible to have multiple software serial ports with speeds up to 115200 bps. On 32 bit Teensy boards, SoftwareSerial uses the real hardware serial ports (and is restricted to only those pins), but allows compatibility with programs that depend on SoftwareSerial. -category=Communication -url=http://www.arduino.cc/en/Reference/SoftwareSerial -architectures=* - diff --git a/KorMYS/.pio/libdeps/uno/SoftwareSerial/libray.json b/KorMYS/.pio/libdeps/uno/SoftwareSerial/libray.json deleted file mode 100644 index 6373d23..0000000 --- a/KorMYS/.pio/libdeps/uno/SoftwareSerial/libray.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "SoftwareSerial", - "keywords": "SoftwareSerial", - "description": "The SoftwareSerial library has been developed to allow serial communication, using software to replicate the functionality of the hardware UART. It is possible to have multiple software serial ports with speeds up to 115200 bps. On 32 bit Teensy boards, SoftwareSerial uses the real hardware serial ports (and is restricted to only those pins), but allows compatibility with programs that depend on SoftwareSerial.", - "repository": - { - "type": "git", - "url": "https://github.com/featherfly/SoftwareSerial.git" - }, - "authors": - [ - { - "name": "Arduino", - "maintainer": true, - "url": "https://www.arduino.cc" - }, - { - "name": "Paul Stoffregen", - "maintainer": true - }, - { - "name": "yufei", - "email": "featherfly@foxmail.com" - } - ], - "dependencies": [ - ], - "version": "1.0", - "frameworks": "arduino", - "platforms": "*" - } \ No newline at end of file diff --git a/KorMYS/.pio/libdeps/uno/integrity.dat b/KorMYS/.pio/libdeps/uno/integrity.dat deleted file mode 100644 index 8a3f18a..0000000 --- a/KorMYS/.pio/libdeps/uno/integrity.dat +++ /dev/null @@ -1,2 +0,0 @@ -robtillaart/RunningMedian @ ^0.3.3 -featherfly/SoftwareSerial @ ^1.0 \ No newline at end of file diff --git a/KorMYS/.vscode/c_cpp_properties.json b/KorMYS/.vscode/c_cpp_properties.json deleted file mode 100644 index 9841421..0000000 --- a/KorMYS/.vscode/c_cpp_properties.json +++ /dev/null @@ -1,128 +0,0 @@ -// -// !!! WARNING !!! AUTO-GENERATED FILE! -// PLEASE DO NOT MODIFY IT AND USE "platformio.ini": -// https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags -// -{ - "configurations": [ - { - "name": "PlatformIO", - "includePath": [ - "d:/Projects/Arduino/AHome/KorMYS/include", - "d:/Projects/Arduino/AHome/KorMYS/src", - "C:/Users/lexa-/.platformio/lib/SDS011 sensor Library", - "C:/Users/lexa-/.platformio/lib/MySensors_ID548", - "C:/Users/lexa-/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src", - "C:/Users/lexa-/.platformio/packages/framework-arduino-avr/libraries/SPI/src", - "C:/Users/lexa-/.platformio/packages/framework-arduino-avr/libraries/Wire/src", - "d:/Projects/Arduino/AHome/KorMYS/.pio/libdeps/uno/RunningMedian", - "d:/Projects/Arduino/AHome/KorMYS/.pio/libdeps/uno/SoftwareSerial", - "C:/Users/lexa-/.platformio/packages/framework-arduino-avr/cores/arduino", - "C:/Users/lexa-/.platformio/packages/framework-arduino-avr/variants/standard", - "C:/Users/lexa-/.platformio/lib/Adafruit ADXL343", - "C:/Users/lexa-/.platformio/lib/Adafruit AHTX0", - "C:/Users/lexa-/.platformio/lib/Adafruit BME280 Library", - "C:/Users/lexa-/.platformio/lib/Adafruit BusIO", - "C:/Users/lexa-/.platformio/lib/Adafruit DHT Unified_ID18", - "C:/Users/lexa-/.platformio/lib/Adafruit GFX Library", - "C:/Users/lexa-/.platformio/lib/Adafruit HTU21DF Library_ID566", - "C:/Users/lexa-/.platformio/lib/Adafruit SH110X", - "C:/Users/lexa-/.platformio/lib/Adafruit Unified Sensor", - "C:/Users/lexa-/.platformio/lib/AsyncMqttClient/src", - "C:/Users/lexa-/.platformio/lib/BME280_ID901/src", - "C:/Users/lexa-/.platformio/lib/Bounce2/src", - "C:/Users/lexa-/.platformio/lib/ClosedCube HDC1080_ID805/src", - "C:/Users/lexa-/.platformio/lib/DHT sensor library", - "C:/Users/lexa-/.platformio/lib/DallasTemperature", - "C:/Users/lexa-/.platformio/lib/EEPROMEx", - "C:/Users/lexa-/.platformio/lib/ESP_EEPROM/src", - "C:/Users/lexa-/.platformio/lib/EmonLib_ID116", - "C:/Users/lexa-/.platformio/lib/Encoder", - "C:/Users/lexa-/.platformio/lib/Encoder/utility", - "C:/Users/lexa-/.platformio/lib/I2C_EEPROM", - "C:/Users/lexa-/.platformio/lib/LiquidCrystal_PCF8574/src", - "C:/Users/lexa-/.platformio/lib/MH-Z19/src", - "C:/Users/lexa-/.platformio/lib/MsTimer2_ID137", - "C:/Users/lexa-/.platformio/lib/Nova Fitness Sds dust sensors library/src", - "C:/Users/lexa-/.platformio/lib/OneButton/src", - "C:/Users/lexa-/.platformio/lib/OneWire", - "C:/Users/lexa-/.platformio/lib/PCF8574", - "C:/Users/lexa-/.platformio/lib/PCF8574_ESP", - "C:/Users/lexa-/.platformio/lib/PubSubClient_ID89/src", - "C:/Users/lexa-/.platformio/lib/RotaryEncoder/src", - "C:/Users/lexa-/.platformio/lib/TimerOne", - "C:/Users/lexa-/.platformio/packages/framework-arduino-avr/libraries/HID/src", - "C:/Users/lexa-/.platformio/packages/framework-arduino-avr/libraries/SoftwareSerial/src", - "" - ], - "browse": { - "limitSymbolsToIncludedHeaders": true, - "path": [ - "d:/Projects/Arduino/AHome/KorMYS/include", - "d:/Projects/Arduino/AHome/KorMYS/src", - "C:/Users/lexa-/.platformio/lib/SDS011 sensor Library", - "C:/Users/lexa-/.platformio/lib/MySensors_ID548", - "C:/Users/lexa-/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src", - "C:/Users/lexa-/.platformio/packages/framework-arduino-avr/libraries/SPI/src", - "C:/Users/lexa-/.platformio/packages/framework-arduino-avr/libraries/Wire/src", - "d:/Projects/Arduino/AHome/KorMYS/.pio/libdeps/uno/RunningMedian", - "d:/Projects/Arduino/AHome/KorMYS/.pio/libdeps/uno/SoftwareSerial", - "C:/Users/lexa-/.platformio/packages/framework-arduino-avr/cores/arduino", - "C:/Users/lexa-/.platformio/packages/framework-arduino-avr/variants/standard", - "C:/Users/lexa-/.platformio/lib/Adafruit ADXL343", - "C:/Users/lexa-/.platformio/lib/Adafruit AHTX0", - "C:/Users/lexa-/.platformio/lib/Adafruit BME280 Library", - "C:/Users/lexa-/.platformio/lib/Adafruit BusIO", - "C:/Users/lexa-/.platformio/lib/Adafruit DHT Unified_ID18", - "C:/Users/lexa-/.platformio/lib/Adafruit GFX Library", - "C:/Users/lexa-/.platformio/lib/Adafruit HTU21DF Library_ID566", - "C:/Users/lexa-/.platformio/lib/Adafruit SH110X", - "C:/Users/lexa-/.platformio/lib/Adafruit Unified Sensor", - "C:/Users/lexa-/.platformio/lib/AsyncMqttClient/src", - "C:/Users/lexa-/.platformio/lib/BME280_ID901/src", - "C:/Users/lexa-/.platformio/lib/Bounce2/src", - "C:/Users/lexa-/.platformio/lib/ClosedCube HDC1080_ID805/src", - "C:/Users/lexa-/.platformio/lib/DHT sensor library", - "C:/Users/lexa-/.platformio/lib/DallasTemperature", - "C:/Users/lexa-/.platformio/lib/EEPROMEx", - "C:/Users/lexa-/.platformio/lib/ESP_EEPROM/src", - "C:/Users/lexa-/.platformio/lib/EmonLib_ID116", - "C:/Users/lexa-/.platformio/lib/Encoder", - "C:/Users/lexa-/.platformio/lib/Encoder/utility", - "C:/Users/lexa-/.platformio/lib/I2C_EEPROM", - "C:/Users/lexa-/.platformio/lib/LiquidCrystal_PCF8574/src", - "C:/Users/lexa-/.platformio/lib/MH-Z19/src", - "C:/Users/lexa-/.platformio/lib/MsTimer2_ID137", - "C:/Users/lexa-/.platformio/lib/Nova Fitness Sds dust sensors library/src", - "C:/Users/lexa-/.platformio/lib/OneButton/src", - "C:/Users/lexa-/.platformio/lib/OneWire", - "C:/Users/lexa-/.platformio/lib/PCF8574", - "C:/Users/lexa-/.platformio/lib/PCF8574_ESP", - "C:/Users/lexa-/.platformio/lib/PubSubClient_ID89/src", - "C:/Users/lexa-/.platformio/lib/RotaryEncoder/src", - "C:/Users/lexa-/.platformio/lib/TimerOne", - "C:/Users/lexa-/.platformio/packages/framework-arduino-avr/libraries/HID/src", - "C:/Users/lexa-/.platformio/packages/framework-arduino-avr/libraries/SoftwareSerial/src", - "" - ] - }, - "defines": [ - "PLATFORMIO=60105", - "ARDUINO_AVR_UNO", - "F_CPU=16000000L", - "ARDUINO_ARCH_AVR", - "ARDUINO=10808", - "__AVR_ATmega328P__", - "" - ], - "cStandard": "c11", - "cppStandard": "c++11", - "compilerPath": "C:/Users/lexa-/.platformio/packages/toolchain-atmelavr@1.70300.191015/bin/avr-gcc.exe", - "compilerArgs": [ - "-mmcu=atmega328p", - "" - ] - } - ], - "version": 4 -} diff --git a/KorMYS/.vscode/launch.json b/KorMYS/.vscode/launch.json deleted file mode 100644 index fd764e2..0000000 --- a/KorMYS/.vscode/launch.json +++ /dev/null @@ -1,44 +0,0 @@ -// AUTOMATICALLY GENERATED FILE. PLEASE DO NOT MODIFY IT MANUALLY -// -// PIO Unified Debugger -// -// Documentation: https://docs.platformio.org/page/plus/debugging.html -// Configuration: https://docs.platformio.org/page/projectconf/section_env_debug.html - -{ - "version": "0.2.0", - "configurations": [ - { - "type": "platformio-debug", - "request": "launch", - "name": "PIO Debug", - "executable": "d:/Projects/Arduino/AHome/KorMYS/.pio/build/uno/firmware.elf", - "projectEnvName": "uno", - "toolchainBinDir": "C:/Users/lexa-/.platformio/packages/toolchain-atmelavr@1.70300.191015/bin", - "internalConsoleOptions": "openOnSessionStart", - "preLaunchTask": { - "type": "PlatformIO", - "task": "Pre-Debug" - } - }, - { - "type": "platformio-debug", - "request": "launch", - "name": "PIO Debug (skip Pre-Debug)", - "executable": "d:/Projects/Arduino/AHome/KorMYS/.pio/build/uno/firmware.elf", - "projectEnvName": "uno", - "toolchainBinDir": "C:/Users/lexa-/.platformio/packages/toolchain-atmelavr@1.70300.191015/bin", - "internalConsoleOptions": "openOnSessionStart" - }, - { - "type": "platformio-debug", - "request": "launch", - "name": "PIO Debug (without uploading)", - "executable": "d:/Projects/Arduino/AHome/KorMYS/.pio/build/uno/firmware.elf", - "projectEnvName": "uno", - "toolchainBinDir": "C:/Users/lexa-/.platformio/packages/toolchain-atmelavr@1.70300.191015/bin", - "internalConsoleOptions": "openOnSessionStart", - "loadMode": "manual" - } - ] -} diff --git a/esp8266-KUH/.gitignore b/esp8266-KUH/.gitignore deleted file mode 100644 index 89cc49c..0000000 --- a/esp8266-KUH/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -.pio -.vscode/.browse.c_cpp.db* -.vscode/c_cpp_properties.json -.vscode/launch.json -.vscode/ipch diff --git a/esp8266-KUH/.travis.yml b/esp8266-KUH/.travis.yml deleted file mode 100644 index a8bbc57..0000000 --- a/esp8266-KUH/.travis.yml +++ /dev/null @@ -1,67 +0,0 @@ -# Continuous Integration (CI) is the practice, in software -# engineering, of merging all developer working copies with a shared mainline -# several times a day < https://docs.platformio.org/page/ci/index.html > -# -# Documentation: -# -# * Travis CI Embedded Builds with PlatformIO -# < https://docs.travis-ci.com/user/integration/platformio/ > -# -# * PlatformIO integration with Travis CI -# < https://docs.platformio.org/page/ci/travis.html > -# -# * User Guide for `platformio ci` command -# < https://docs.platformio.org/page/userguide/cmd_ci.html > -# -# -# Please choose one of the following templates (proposed below) and uncomment -# it (remove "# " before each line) or use own configuration according to the -# Travis CI documentation (see above). -# - - -# -# Template #1: General project. Test it using existing `platformio.ini`. -# - -# language: python -# python: -# - "2.7" -# -# sudo: false -# cache: -# directories: -# - "~/.platformio" -# -# install: -# - pip install -U platformio -# - platformio update -# -# script: -# - platformio run - - -# -# Template #2: The project is intended to be used as a library with examples. -# - -# language: python -# python: -# - "2.7" -# -# sudo: false -# cache: -# directories: -# - "~/.platformio" -# -# env: -# - PLATFORMIO_CI_SRC=path/to/test/file.c -# - PLATFORMIO_CI_SRC=examples/file.ino -# - PLATFORMIO_CI_SRC=path/to/test/directory -# -# install: -# - pip install -U platformio -# - platformio update -# -# script: -# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/esp8266-KUH/.vscode/extensions.json b/esp8266-KUH/.vscode/extensions.json deleted file mode 100644 index 080e70d..0000000 --- a/esp8266-KUH/.vscode/extensions.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - // See http://go.microsoft.com/fwlink/?LinkId=827846 - // for the documentation about the extensions.json format - "recommendations": [ - "platformio.platformio-ide" - ], - "unwantedRecommendations": [ - "ms-vscode.cpptools-extension-pack" - ] -} diff --git a/esp8266-KUH/include/README b/esp8266-KUH/include/README deleted file mode 100644 index 45496b1..0000000 --- a/esp8266-KUH/include/README +++ /dev/null @@ -1,39 +0,0 @@ - -This directory is intended for project header files. - -A header file is a file containing C declarations and macro definitions -to be shared between several project source files. You request the use of a -header file in your project source file (C, C++, etc) located in `src` folder -by including it, with the C preprocessing directive `#include'. - -```src/main.c - -#include "header.h" - -int main (void) -{ - ... -} -``` - -Including a header file produces the same results as copying the header file -into each source file that needs it. Such copying would be time-consuming -and error-prone. With a header file, the related declarations appear -in only one place. If they need to be changed, they can be changed in one -place, and programs that include the header file will automatically use the -new version when next recompiled. The header file eliminates the labor of -finding and changing all the copies as well as the risk that a failure to -find one copy will result in inconsistencies within a program. - -In C, the usual convention is to give header files names that end with `.h'. -It is most portable to use only letters, digits, dashes, and underscores in -header file names, and at most one dot. - -Read more about using header files in official GCC documentation: - -* Include Syntax -* Include Operation -* Once-Only Headers -* Computed Includes - -https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/esp8266-KUH/include/main.h b/esp8266-KUH/include/main.h deleted file mode 100644 index 761298c..0000000 --- a/esp8266-KUH/include/main.h +++ /dev/null @@ -1,45 +0,0 @@ -#include -#include -#include -#include -//#include -#include -#include -#include -#include -#include -//#include - -#include - -#include -#include -#include - -#include - -#include - -#define ONE_WIRE_BUS D4 - -union uFloat { - byte b[4]; - float f; - int i; -} wcH, wcC, ls, ld; - -void wCycle(); -void showLCD(); -void getTemp(); -void initLCD(); -void initWiFi(); -void initTemp(); -//void readEEPROM(); -void readDI(); -void movSens(); -void callback(String topic, byte* message, unsigned int length); -void reconnect(); -void handleData(); -//void writeEEPROM(const char tip[2], uFloat val); -void publishSec(); -void publishMin(); diff --git a/esp8266-KUH/lib/README b/esp8266-KUH/lib/README deleted file mode 100644 index 8c9c29c..0000000 --- a/esp8266-KUH/lib/README +++ /dev/null @@ -1,46 +0,0 @@ - -This directory is intended for project specific (private) libraries. -PlatformIO will compile them to static libraries and link into executable file. - -The source code of each library should be placed in a an own separate directory -("lib/your_library_name/[here are source files]"). - -For example, see a structure of the following two libraries `Foo` and `Bar`: - -|--lib -| | -| |--Bar -| | |--docs -| | |--examples -| | |--src -| | |- Bar.c -| | |- Bar.h -| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html -| | -| |--Foo -| | |- Foo.c -| | |- Foo.h -| | -| |- README --> THIS FILE -| -|- platformio.ini -|--src - |- main.c - -and a contents of `src/main.c`: -``` -#include -#include - -int main (void) -{ - ... -} - -``` - -PlatformIO Library Dependency Finder will find automatically dependent -libraries scanning project source files. - -More information about PlatformIO Library Dependency Finder -- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/esp8266-KUH/platformio.ini b/esp8266-KUH/platformio.ini deleted file mode 100644 index 86bc93e..0000000 --- a/esp8266-KUH/platformio.ini +++ /dev/null @@ -1,24 +0,0 @@ -;PlatformIO Project Configuration File -; -; Build options: build flags, source filter -; Upload options: custom upload port, speed and extra flags -; Library options: dependencies, extra library storages -; Advanced options: extra scripting -; -; Please visit documentation for the other options and examples -; https://docs.platformio.org/page/projectconf.html - -[env:nodemcuv2] -platform = espressif8266 -board = nodemcuv2 -framework = arduino -upload_protocol = espota -upload_port = 192.168.1.6 - -lib_deps = - thomasfredericks/Bounce2 @ ^2.72 - mathertel/LiquidCrystal_PCF8574 @ ^2.2.0 - milesburton/DallasTemperature @ ^4.0.4 - werecatf/PCF8574_ESP @ ^1.0.10 - finitespace/BME280 @ ^3.0.0 - knolleary/PubSubClient @ ^2.8 \ No newline at end of file diff --git a/esp8266-KUH/src/main.cpp b/esp8266-KUH/src/main.cpp deleted file mode 100644 index c41a135..0000000 --- a/esp8266-KUH/src/main.cpp +++ /dev/null @@ -1,780 +0,0 @@ -#include "main.h" - -const char* host = "esp8266"; -const char* ssid = "wf-home"; -const char* password = "0ndthnrf"; - -const char* mqtt_server = "192.168.1.250"; - -//ESP8266WebServer server(80); - -// инициализируем espClient: -WiFiClient espClient; -PubSubClient client(espClient); - -LiquidCrystal_PCF8574 lcd(0x27); // set the LCD address to 0x27 for a 16 chars and 2 line display - -int nDevs; -DeviceAddress da[4] = { - {0x28, 0xFF, 0x75, 0x3f, 0x93, 0x16, 0x04, 0xce}, - {0x28, 0x85, 0xcd, 0x1b, 0x05, 0x00, 0x00, 0x48}, - {0x28, 0xff, 0x79, 0x41, 0x88, 0x16, 0x03, 0x5a}, - {0x28, 0x20, 0xbe, 0x1b, 0x05, 0x00, 0x00, 0xdc} -}; - -// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) -OneWire oneWire(ONE_WIRE_BUS); - -// Pass our oneWire reference to Dallas Temperature. -DallasTemperature sensors(&oneWire); - -float temp1, tHolTop, tHolDown, tMoroz; -//float hum; -float hic; -//float temp2; -//float pres, bmpTemp; - -int old_wcC, old_wcH; -int adc; -float temp[4]; - - -const int led = LED_BUILTIN; -const int HOT_SENS = D5; -const int COLD_SENS = D6; -const int LED_STRIPE = D7; -const int LCD_MODE = D8; -const int RSET_FLOOD = D4; - -unsigned long oldRun = millis(); - -bool Flood = false; - -TwoWire testWire; -PCF857x pcf8574(0x38, &testWire); - -/*const int MB_LED = 0; -const int VLZEM_LED = 1; -const int BOX_LED = 2; -const int FLOOD_LED = 3; */ - - -//Bounce modeLCD_dbnc = Bounce(); -//Bounce hot_dbnc = Bounce(); -//Bounce cold_dbnc = Bounce(); -//Bounce rset_dbnc = Bounce(); - -bool bMLCD; -short sLCDPage; - -BME280I2C::Settings settings( - BME280::OSR_X1, - BME280::OSR_X2, - BME280::OSR_X16, - BME280::Mode_Normal, - BME280::StandbyTime_1000ms, - BME280::Filter_16, - BME280::SpiEnable_False, - BME280I2C::I2CAddr_0x76 // I2C address. I2C specific. -); -BME280I2C bme(settings); // Default : forced mode, standby time = 1000 ms -// Oversampling = pressure ×1, temperature ×1, humidity ×1, filter off, -float temp2(NAN), hum(NAN), pres(NAN); - -bool movSensor = 0; -bool MS = 0; - -void setup() -{ - Serial.begin(115200); - Serial.println("Init LCD"); - initLCD(); - delay(500); - Serial.println("Init BME280"); - int nt = 0; - while (!bme.begin()) { - Serial.println("Could not find a valid BMe280 sensor, check wiring!"); - delay(1000); - nt++; - if (nt > 10) break; - } - delay(500); - Serial.println("Init Temperature"); - initTemp(); - bme.read(pres, temp2, hum, BME280::TempUnit_Celsius, BME280::PresUnit_torr); - - pinMode(led, OUTPUT); - digitalWrite(led, 1); - pinMode(HOT_SENS, INPUT_PULLUP); - pinMode(COLD_SENS, INPUT_PULLUP); - pinMode(LED_STRIPE, OUTPUT); - pinMode(LCD_MODE, INPUT_PULLUP); - pinMode(D4, INPUT_PULLUP); - - //hot_dbnc.attach(HOT_SENS); - //hot_dbnc.interval(5); // interval in ms - //cold_dbnc.attach(COLD_SENS); - //cold_dbnc.interval(5); // interval in ms - /*modeLCD_dbnc.attach(LCD_MODE); - modeLCD_dbnc.interval(5); // interval in ms - rset_dbnc.attach(RSET_FLOOD); - rset_dbnc.interval(5); // interval in ms*/ - - - EEPROM.begin(16); - //readEEPROM(); - //Serial.print("Hot water: "); - //Serial.print(float(wcH.i) / 100.0); - //Serial.print("Cold water: "); - //Serial.println(float(wcC.i) / 100.0); - //Serial.print("LS Set: "); - //Serial.println(ls.i); - //Serial.print("LS DB: "); - //Serial.println(ld.i); - ls.i = 250; - ld.i = 50; - //old_wcC = wcC.i; - //old_wcH = wcH.i; - - testWire.begin();//5, 4); - testWire.setClock(100000L); - pcf8574.begin(); - bMLCD = false; - readDI(); - sLCDPage = 0; - initWiFi(); - client.setServer(mqtt_server, 1883); - client.setCallback(callback); - - ArduinoOTA.onStart([]() { - Serial.println("Start"); // "Начало OTA-апдейта" - }); - ArduinoOTA.onEnd([]() { - Serial.println("\nEnd"); // "Завершение OTA-апдейта" - }); - ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) { - Serial.printf("Progress: %u%%\r", (progress / (total / 100))); - }); - ArduinoOTA.onError([](ota_error_t error) { - Serial.printf("Error[%u]: ", error); - if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed"); - // "Ошибка при аутентификации" - else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed"); - // "Ошибка при начале OTA-апдейта" - else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed"); - // "Ошибка при подключении" - else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed"); - // "Ошибка при получении данных" - else if (error == OTA_END_ERROR) Serial.println("End Failed"); - // "Ошибка при завершении OTA-апдейта" - }); - ArduinoOTA.begin(); -} // setup() - -void loop() -{ - unsigned long curTime = millis(); - if ((curTime - oldRun) >= 10){ - wCycle(); - oldRun = curTime; - } - //server.handleClient(); - ArduinoOTA.handle(); - //movSens(); -} - -char strFVal[10]; - -void wCycle() -{ - static int sec = 0; - static short stp = 100; - if(stp == 100){ - stp = 0; - sec++; - if (sec == 59){ - sec = 0; - publishMin(); - } - getTemp(); - publishSec(); - } - if((stp % 20) == 0){ - showLCD(); - } - if((stp) == 60){ - float p, t, h; - bme.read(p, t, h, BME280::TempUnit_Celsius, BME280::PresUnit_torr); - //if (isnan(pres)) - pres = p; - //else pres += (p - pres) * 0.05; - //if (isnan(temp2)) - temp2 = t; - //else temp2 += (t - temp2) * 0.05; - //if (isnan(hum)) - hum = h; - //else hum += (h - hum) * 0.05; - } - readDI(); - movSens(); -/* if (Flood == true) - pcf8574.write(2, LOW); - else - pcf8574.write(2, HIGH);*/ - stp++; -} // loop() - - -void movSens() -{ - adc = analogRead(A0); - if (MS != pcf8574.read(4)){ - MS = pcf8574.read(4); - client.publish("/esp8266/move", String(MS).c_str()); - } - //Dark - if ((adc < (ls.i - ld.i)) && MS){ - pcf8574.write(5, LOW); //digitalWrite(LED_STRIPE, LOW); - } - //Light - if ((adc > (ls.i + ld.i)) || !MS){ - pcf8574.write(5, HIGH); //digitalWrite(LED_STRIPE, HIGH); - } - if (MS == true) - lcd.setBacklight(255); - else - lcd.setBacklight(0); -} - - -void getTemp() -{ - static bool readTemp = false; - static byte nSens = 0; - if (readTemp){ - sensors.setWaitForConversion(false); - sensors.requestTemperatures(); - readTemp = !readTemp; - } - else{ - //float t = sensors.getTempC(outTemp); - float t = sensors.getTempC(da[nSens]);//ByIndex(nSens); - Serial.print(nSens); - Serial.print(" Temp readed="); - Serial.println(t); - //to[0] = t; - if ((t > -127) && (t < 85)){ - switch(nSens){ - case 0: - temp1 += (t - temp1) * 0.05; - break; - case 1: - tHolTop += (t - tHolTop) * 0.05; - break; - case 2: - tHolDown += (t - tHolDown) * 0.05; - break; - case 3: - tMoroz += (t - tMoroz) * 0.05; - break; - } - } - if (++nSens > 3){ - nSens = 0; - readTemp = !readTemp; - } - } - //n++; -} - -void showLCD() -{ - char outS[16]; - String s1, s2; - //lcd.clear(); - switch (sLCDPage){ - case 0: - s1 = String(temp1, 1); - s2 = String(temp2, 1); - snprintf(outS, 17, "O:%5sC I:%4sC ", s1.c_str(), s2.c_str()); - lcd.setCursor(0, 0); - lcd.print(outS); - lcd.setCursor(0, 1); - s1 = String(hum, 1); - s2 = String(pres, 0); - snprintf(outS, 17, "H:%4s%% Pr:%2smm", s1.c_str(), s2.c_str()); - lcd.print(outS); - break; - case 1: - snprintf(outS, 17, "L:%04d SP:%03d %d ", adc, ls.i, ld.i); - lcd.setCursor(0, 0); - lcd.print(outS); - lcd.setCursor(0, 1); - s1 = String(hum, 1); - s2 = String(hic, 1); - snprintf(outS, 17, "H:%4s%% HI:%4sC ", s1.c_str(), s2.c_str()); - lcd.print(outS); - break; - case 2: - snprintf(outS, 17, "L:%04d SP:%03d %d", adc, ls.i, ld.i); - lcd.setCursor(0, 0); - lcd.print(outS); - lcd.setCursor(0, 1); - snprintf(outS, 17, "C:%03.2fH:%03.2f", float(wcC.i) / 100.0, float(wcH.i) / 100.0); - lcd.print(outS); - break; - case 3: - s1 = String(temp1, 1); - s2 = String(tMoroz, 1); - snprintf(outS, 17, "O:%4sC M:%4sC ", s1.c_str(), s2.c_str()); - lcd.setCursor(0, 0); - lcd.print(outS); - lcd.setCursor(0, 1); - s1 = String(tHolTop, 1); - s2 = String(tHolDown, 1); - snprintf(outS, 17, "H:%4sC HM:%4sC", s1.c_str(), s2.c_str()); - lcd.print(outS); - break; - } -} - -void initLCD(){ - int error; - Serial.println("LCD..."); - Serial.println("Dose: check for LCD"); - - // See http://playground.arduino.cc/Main/I2cScanner - Wire.begin(); - Wire.beginTransmission(0x38); - error = Wire.endTransmission(); - Serial.print("Error: "); - Serial.print(error); - - if (error == 0) { - Serial.println(": LCD found."); - - } else { - Serial.println(": LCD not found."); - } // if - lcd.begin(16, 2); // initialize the lcd - lcd.setBacklight(255); - lcd.clear(); -} - -/*void handleRoot() { - digitalWrite ( led, 0 ); - char temp[400]; - int sec = millis() / 1000; - int min = sec / 60; - int hr = min / 60; - - snprintf ( temp, 400, - - "\ - \ - \ - ESP8266 Demo\ - \ - \ - \ -

Hello from ESP8266!

\ -

Uptime: %02d:%02d:%02d

\ - \ - ", - - hr, min % 60, sec % 60 - ); - server.send ( 200, "text/html", temp ); - //digitalWrite ( led, 1 ); -}*/ - -/*void handleNotFound() { -// digitalWrite ( led, 0 ); - String message = "File Not Found\n\n"; - message += "URI: "; - message += server.uri(); - message += "\nMethod: "; - message += ( server.method() == HTTP_GET ) ? "GET" : "POST"; - message += "\nArguments: "; - message += server.args(); - message += "\n"; - // message += test().c_str(); - - for ( uint8_t i = 0; i < server.args(); i++ ) { - message += " " + server.argName ( i ) + ": " + server.arg ( i ) + "\n"; - } - - server.send ( 404, "text/plain", message ); - //digitalWrite ( led, 1 ); -}*/ - -/*void handleJSON() -{ - //digitalWrite ( led, 0 ); - pcf8574.write(7, LOW); - - // Allocate JsonBuffer - // Use arduinojson.org/assistant to compute the capacity. - - StaticJsonBuffer<500> jsonBuffer; - - // Create the root object - JsonObject& root = jsonBuffer.createObject(); - - root.set("temp1", temp1); - root.set("temp2", temp2); - root.set("press", pres); - root.set("hum", hum); - root.set("vlzem", 0.0); - root.set("qc", float(wcC.i) / 100.0); - root.set("qh", float(wcH.i) / 100.0); - root.set("sp", ls.i); - root.set("db", ld.i); - root.set("vlsp", adc); - root.set("flood", Flood); - // Create the "analog" array - - String s; - root.printTo(s); - server.send(200, "application/json", s); - pcf8574.write(7, HIGH); - //digitalWrite ( led, 0 ); -}*/ - -/*void handleData() -{ - //String inArgs = ""; - char temp[100]; - char tm[3]; - String html; - - pcf8574.write(7, LOW); - int sec = millis() / 1000; - int min = sec / 60; - int hr = min / 60; - - if (server.args() > 0){ - for (int i = 0; i < server.args(); i++) { - if (server.argName(i).equals("wcc")){ - wcC.i = int(server.arg(i).toFloat() * 100.0f); - writeEEPROM("cc", wcC); - //inArgs += "

Write to wcc value: " + server.arg(i) + "

"; - } - if (server.argName(i).equals("wch")){ - wcH.i = int(server.arg(i).toFloat() * 100.0f) ; - writeEEPROM("ch", wcH); - //inArgs += "

Write to wcc value: " + server.arg(i) + "

"; - } - if (server.argName(i).equals("ls_set")){ - ls.i = server.arg(i).toInt(); - writeEEPROM("ls", ls); - } - if (server.argName(i).equals("ls_db")){ - ld.i = server.arg(i).toInt(); - writeEEPROM("ld", ld); - } - } - } - - html = ""; - html += ""; - html += ""; - html += "ESP8266 Demo"; - html += ""; - html += ""; - html += ""; - html += "

Hello from ESP8266!

"; - snprintf(tm, 3, "%02d", hr); - html += "

Uptime: " + String(tm); - snprintf(tm, 3, "%02d", min % 60); - html += ":" + String(tm); - snprintf(tm, 3, "%02d", sec % 60); - html += ":" + String(tm) + String("

"); - sprintf(temp, "

Cold Water: %6.2f m3

Hot Water: %6.2f m3

Temp: %3.3fC

LSet: %d, LDB: %d

", float(wcC.i) / 100.0, float(wcH.i) / 100.0, temp1, ls.i, ld.i); - html += String(temp); - html += ""; - - server.send ( 200, "text/html", html ); - pcf8574.write(7, HIGH); -}*/ - - -void initWiFi() -{ - //WiFi.mode(WIFI_STA); - WiFi.begin(ssid, password); - if(WiFi.waitForConnectResult() == WL_CONNECTED){ - delay(500); - Serial.print("."); - } - Serial.println(""); - Serial.print("Connected to "); - Serial.println(ssid); - Serial.print("IP address: "); - Serial.println(WiFi.localIP()); - - if (MDNS.begin(host)) { - Serial.println("MDNS responder started"); - } - - /*server.on ("/", handleData); - server.on("/data", handleData); - server.on("/json", handleJSON); - server.on ("/inline", []() { - server.send ( 200, "text/plain", "this works as well" ); - } ); - server.onNotFound ( handleNotFound ); - server.begin(); - Serial.println ( "HTTP server started" );*/ - - Serial.println("Ready"); - Serial.print("IP address: "); - Serial.println(WiFi.localIP()); -} - -void initTemp() -{ - //DeviceAddress da[4]; - sensors.begin(); - Serial.println("InitTemp"); - //oneWire.reset_search(); - for (int i = 0; i < 4; i++){ - //sensors.getAddress(da[i], i); - sensors.setResolution(da[i], 12); - //printAddress(da[i]); - } - //sensors.getAddress(outTemp, 0); - //sensors.setResolution(outTemp, 12); - sensors.setWaitForConversion(true); - sensors.requestTemperatures(); - Serial.println("Request Temp"); - /*printAddress(outTemp); - printAddress(holTop); - printAddress(holDown); - printAddress(moroz);*/ - temp1 = sensors.getTempC(da[0]); - Serial.println(temp1); - tHolTop = sensors.getTempC(da[1]); - Serial.println(tHolTop); - tHolDown = sensors.getTempC(da[2]); - Serial.println(tHolDown); - tMoroz = sensors.getTempC(da[3]); - Serial.println(tMoroz); - /*delay(100); - tHolTop = sensors.getTempCByIndex(1); - delay(100); - tHolDown = sensors.getTempCByIndex(2); - delay(100); - tMoroz = sensors.getTempCByIndex(0);*/ -} - -/*void readEEPROM() -{ - wcC.b[0] = EEPROM.read(0); - wcC.b[1] = EEPROM.read(1); - wcC.b[2] = EEPROM.read(2); - wcC.b[3] = EEPROM.read(3); - - wcH.b[0] = EEPROM.read(4); - wcH.b[1] = EEPROM.read(5); - wcH.b[2] = EEPROM.read(6); - wcH.b[3] = EEPROM.read(7); - - ls.b[0] = EEPROM.read(8); - ls.b[1] = EEPROM.read(9); - ls.b[2] = EEPROM.read(10); - ls.b[3] = EEPROM.read(11); - - ld.b[0] = EEPROM.read(12); - ld.b[1] = EEPROM.read(13); - ld.b[2] = EEPROM.read(14); - ld.b[3] = EEPROM.read(15); -}*/ - -/*void writeEEPROM(const char tip[2], uFloat val) -{ - short shft = -1; - if (strcmp(tip, "cc") == 0) { - shft = 0; - //Serial.print("Write cold counter: "); - //Serial.println(val.f); - } - if (strcmp(tip, "ch") == 0) { - shft = 4; - //Serial.print("Write Hot counter: "); - //Serial.println(val.f); - } - if (strcmp(tip, "ls") == 0) { - shft = 8; - //Serial.print("Light Sensor Set: "); - //Serial.println(val.i); - } - if (strcmp(tip, "ld") == 0) { - shft = 12; - //Serial.print("Light Sensor DB: "); - //Serial.println(val.i); - } - if (shft == -1) return; - - EEPROM.write(shft, val.b[0]); - EEPROM.write(shft + 1, val.b[1]); - EEPROM.write(shft + 2, val.b[2]); - EEPROM.write(shft + 3, val.b[3]); - EEPROM.commit(); -}*/ - -void readDI() -{ - /*if (hot_dbnc.update()){ - if (hot_dbnc.read() == 1){ - wcH.i += 1; - //wcH.f += 0.01; - if (fabs(old_wcH - wcH.i) >= 5){ - writeEEPROM("ch", wcH); - old_wcH = wcH.i; - } - } - } - if (cold_dbnc.update()){ - if (cold_dbnc.read() == 1) - wcC.i += 1; - if (fabs(old_wcC - wcC.i) >= 5){ - writeEEPROM("cc", wcC); - old_wcC = wcC.i; - } - } - if (!pcf8574.read(6)) - Flood = true; - if (!pcf8574.read(0)) Flood = false;*/ - if (pcf8574.read(1) != bMLCD){ - if (bMLCD == false){ - sLCDPage++; - if (sLCDPage > 3) sLCDPage = 0; - } - bMLCD = !bMLCD; - } -} - -void callback(String topic, byte* message, unsigned int length) { - Serial.print("Message arrived on topic: "); - // "Сообщение прибыло в топик: " - Serial.print(topic); - Serial.print(". Message: "); // ". Сообщение: " - String messageTemp; - - for (unsigned int i = 0; i < length; i++) { - Serial.print((char)message[i]); - messageTemp += (char)message[i]; - } - Serial.println(); -} - -void reconnect() { - // заново запускаем цикл, пока не подключимся: - //while (!client.connected()) { - Serial.print("Attempting MQTT connection..."); - // "Попытка подключиться к MQTT-брокеру... " - - // Пытаемся подключиться: - if (client.connect("ESP8266Client")) { - Serial.println("connected"); // "подключен" - // подписываемся или переподписываемся на топик; - // можно подписаться не только на один, а на несколько топиков - // (что касается конкретно этого примера, то это позволит - // управлять большим количеством светодиодов): - //client.subscribe("esp8266/qc"); - //client.subscribe("esp8266/qh"); - } else { - Serial.print("failed, rc="); // "подключение не удалось" - Serial.print(client.state()); - Serial.println(" try again in 5 seconds"); - // "5 секунд до следующей попытки" - // ждем 5 секунд перед тем, как попробовать снова: - //delay(5000); - } - //} -} - -void printAddress(DeviceAddress deviceAddress) -{ - for (uint8_t i = 0; i < 8; i++) - { - // zero pad the address if necessary - if (deviceAddress[i] < 16) Serial.print("0"); - Serial.print(deviceAddress[i], HEX); - } - Serial.println(); -} - -void publishSec() -{ - if (!client.connected()) { - reconnect(); - } - if(!client.loop()) - client.connect("ESP8266Client"); - if (client.connected()) { - pcf8574.write(3, LOW); - dtostrf(temp1, 6, 2, strFVal); - client.publish("/esp8266/temp_out", strFVal); - dtostrf(temp2, 6, 2, strFVal); - client.publish("/esp8266/temp_in", strFVal); - dtostrf(hum, 6, 2, strFVal); - client.publish("/esp8266/humidity", strFVal); - dtostrf(pres, 6, 2, strFVal); - client.publish("/esp8266/pressure", strFVal); - dtostrf(float(wcC.i) / 100.0, 6, 2, strFVal); - /*client.publish("/esp8266/qCold", strFVal); - dtostrf(float(wcH.i) / 100.0, 6, 2, strFVal); - client.publish("/esp8266/qHot", strFVal); - itoa(ls.i, strFVal, 10);*/ - client.publish("/esp8266/light_sp", strFVal); - itoa(ld.i, strFVal, 10); - client.publish("/esp8266/light_db", strFVal); - itoa(adc, strFVal, 10); - client.publish("/esp8266/light_cur", strFVal); - //client.publish("/esp8266/flood", String(Flood).c_str()); - dtostrf(tHolTop, 6, 2, strFVal); - client.publish("/esp8266/hol_top", strFVal); - dtostrf(tHolDown, 6, 2, strFVal); - client.publish("/esp8266/hol_down", strFVal); - dtostrf(tMoroz, 6, 2, strFVal); - client.publish("/esp8266/moroz", strFVal); - pcf8574.write(3, HIGH); - } -} - -void publishMin() -{ - if (!client.connected()) { - reconnect(); - } - if(!client.loop()) - client.connect("ESP8266Client"); - if (client.connected()) { - pcf8574.write(7, LOW); - dtostrf(temp1, 6, 1, strFVal); - client.publish("/home/kuh/temp_out", strFVal); - dtostrf(temp2, 6, 1, strFVal); - client.publish("/home/kuh/temp_in", strFVal); - dtostrf(hum, 6, 1, strFVal); - client.publish("/home/kuh/humidity", strFVal); - dtostrf(pres, 6, 1, strFVal); - client.publish("/home/kuh/pressure", strFVal); - itoa(ls.i, strFVal, 10); - client.publish("/home/kuh/light_sp", strFVal); - itoa(ld.i, strFVal, 10); - client.publish("/home/kuh/light_db", strFVal); - itoa(adc, strFVal, 10); - client.publish("/home/kuh/light_cur", strFVal); - dtostrf(tHolTop, 6, 1, strFVal); - client.publish("/home/kuh/hol_top", strFVal); - dtostrf(tHolDown, 6, 1, strFVal); - client.publish("/home/kuh/hol_down", strFVal); - dtostrf(tMoroz, 6, 1, strFVal); - client.publish("/home/kuh/moroz", strFVal); - pcf8574.write(7, HIGH); - } -} diff --git a/esp8266-KUH/test/README b/esp8266-KUH/test/README deleted file mode 100644 index c3b0ed6..0000000 --- a/esp8266-KUH/test/README +++ /dev/null @@ -1,11 +0,0 @@ - -This directory is intended for PIO Unit Testing and project tests. - -Unit Testing is a software testing method by which individual units of -source code, sets of one or more MCU program modules together with associated -control data, usage procedures, and operating procedures, are tested to -determine whether they are fit for use. Unit testing finds problems early -in the development cycle. - -More information about PIO Unit Testing: -- https://docs.platformio.org/page/plus/unit-testing.html