From 27ec4027bf89ff560ef65f58268bb758d96b44a7 Mon Sep 17 00:00:00 2001 From: Defend Date: Mon, 27 Nov 2017 09:56:43 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=81=D0=BF=D0=BE=D0=BC=D0=BE=D0=B3?= =?UTF-8?q?=D0=B0=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B=D0=B9=20=D0=BA=D0=BB?= =?UTF-8?q?=D0=B0=D1=81=D1=81=20=D0=BE=D1=82=D1=80=D0=B8=D1=81=D0=BE=D0=B2?= =?UTF-8?q?=D0=BA=D0=B8=20=D0=B3=D1=80=D0=B0=D1=84=D0=B8=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=B2=D1=8B=D0=BD=D0=B5=D1=81=D0=B5=D0=BD=20=D0=B2=20=D0=BE?= =?UTF-8?q?=D1=82=D0=B4=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B=D0=B9=20=D1=84=D0=B0?= =?UTF-8?q?=D0=B9=D0=BB.=20=D0=A2=D0=B0=D0=BA=D0=B6=D0=B5=20=D1=81=D0=BE?= =?UTF-8?q?=D0=B7=D0=B4=D0=B0=D0=BD=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81,=20?= =?UTF-8?q?=D1=85=D1=80=D0=B0=D0=BD=D1=8F=D1=89=D0=B8=D0=B9=20=D0=BF=D0=BE?= =?UTF-8?q?=D1=81=D0=BB=D0=B5=D0=B4=D0=BD=D0=B5=D0=B5=20=D0=B2=D1=80=D0=B5?= =?UTF-8?q?=D0=BC=D1=8F=20=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D1=81=D0=B5=D0=BD=D1=81=D0=BE=D1=80=D0=B0,=20?= =?UTF-8?q?=D0=B0=20=D1=82=D0=B0=D0=BA=D0=B6=D0=B5=20=D0=B5=D0=B3=D0=BE=20?= =?UTF-8?q?=D0=BF=D0=BE=D1=81=D0=BB=D0=B5=D0=B4=D0=BD=D0=B5=D0=B5=20=D0=B7?= =?UTF-8?q?=D0=BD=D0=B0=D1=87=D0=B5=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Graph.cpp | 8 ++++++++ src/Graph.h | 9 +++++++++ src/Sensor.cpp | 6 ++++++ src/Sensor.h | 7 +++++++ src/main.cpp | 22 +++++----------------- 5 files changed, 35 insertions(+), 17 deletions(-) create mode 100644 src/Graph.cpp create mode 100644 src/Graph.h create mode 100644 src/Sensor.cpp create mode 100644 src/Sensor.h diff --git a/src/Graph.cpp b/src/Graph.cpp new file mode 100644 index 0000000..ed1c842 --- /dev/null +++ b/src/Graph.cpp @@ -0,0 +1,8 @@ +#include "Graph.h" + +Graph::Graph (int graphSize, int graphUpdateRate) { + this->graphSize = graphSize; + this->graphUpdateRate = graphUpdateRate; // Раз в секунду + graphArray = new int[graphSize]; + graphCounter = 0; +} \ No newline at end of file diff --git a/src/Graph.h b/src/Graph.h new file mode 100644 index 0000000..e6349c6 --- /dev/null +++ b/src/Graph.h @@ -0,0 +1,9 @@ +class Graph { + public: + int graphSize; + int graphUpdateRate; + int * graphArray; + int graphCounter; + + Graph (int graphSize, int graphUpdateRate); +}; \ No newline at end of file diff --git a/src/Sensor.cpp b/src/Sensor.cpp new file mode 100644 index 0000000..aff5d50 --- /dev/null +++ b/src/Sensor.cpp @@ -0,0 +1,6 @@ +#include + +Sensor::Sensor() { + lastUpdate = 0; + lastValue = 0; +} \ No newline at end of file diff --git a/src/Sensor.h b/src/Sensor.h new file mode 100644 index 0000000..8c1e220 --- /dev/null +++ b/src/Sensor.h @@ -0,0 +1,7 @@ +class Sensor { + public: + int lastValue; + long int lastUpdate; + + Sensor(); +}; \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 876ab3f..198e6dc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,30 +4,19 @@ #include #include #include +#include +#include const char *ssid = "NodeMCU"; ESP8266WebServer server(80); + +Sensor accelerometer = Sensor(); long int lastUpdate = 0; int acc = 0; -class Graph { - public: - int graphSize; - int graphUpdateRate; - int * graphArray; - int graphCounter; - - Graph (int graphSize, int graphUpdateRate) { - this->graphSize = graphSize; - this->graphUpdateRate = graphUpdateRate; // Раз в секунду - graphArray = new int[graphSize]; - graphCounter = 0; - } -}; // Раз в секунду - -Graph graphAcc; +Graph graphAcc = Graph(200, 50); void handleAccelerometer() { @@ -88,7 +77,6 @@ void handleNotFound() void setup(void) { - graphAcc = Graph(200, 50); // Класс графики для акселерометра pinMode(A0, INPUT); Serial.begin(115200); WiFi.softAP(ssid);