From a757da736e21a49f77306172379c69103dbbf59a Mon Sep 17 00:00:00 2001 From: Defend Date: Mon, 27 Nov 2017 10:04:28 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=81=D0=BD=D0=BE=D0=B2=D0=BD=D0=BE?= =?UTF-8?q?=D0=B9=20=D0=BA=D0=BE=D0=B4=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BF?= =?UTF-8?q?=D0=B8=D1=81=D0=B0=D0=BD=20=D0=BF=D0=BE=D0=B4=20Sensor.h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 198e6dc..2114726 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -13,8 +13,6 @@ ESP8266WebServer server(80); Sensor accelerometer = Sensor(); -long int lastUpdate = 0; -int acc = 0; Graph graphAcc = Graph(200, 50); @@ -42,19 +40,19 @@ void handleAccelerometer() void updateAccelerometer() { - if ((millis() - lastUpdate) > (1000 / graphAcc.graphUpdateRate)) + if ((millis() - accelerometer.lastUpdate) > (1000 / graphAcc.graphUpdateRate)) { - acc = map(analogRead(A0), 512, 768, 200, 0); + accelerometer.lastValue = map(analogRead(A0), 512, 768, 200, 0); if (graphAcc.graphCounter < graphAcc.graphSize - 1) { - graphAcc.graphArray[graphAcc.graphCounter] = acc; + graphAcc.graphArray[graphAcc.graphCounter] = accelerometer.lastValue; graphAcc.graphCounter++; } else { for(int i = 0; i != graphAcc.graphCounter; i++) { graphAcc.graphArray[i] = graphAcc.graphArray[i + 1]; } - graphAcc.graphArray[graphAcc.graphCounter] = acc; + graphAcc.graphArray[graphAcc.graphCounter] = accelerometer.lastValue; } - lastUpdate = millis(); + accelerometer.lastUpdate = millis(); } }