From a907798c86dc1d7a7815c8cad03c9d6d1d0516e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Sun, 29 Apr 2018 11:15:26 +0300 Subject: [PATCH] some optimisation --- .gitignore | 1 + src/main.cpp | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 790b585..65a8df0 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ .vscode/launch.json .vscode .vscode/.browse.c_cpp.db* +.lib/readme.txt diff --git a/src/main.cpp b/src/main.cpp index fec68b8..45840d6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -19,6 +19,8 @@ Sensor accelerometer = Sensor(); Graph graphAcc = Graph(200, 200); long int lastDataSend = 0; +long int lastTest = 0; +bool testState = false; int timeOfCal = 0; bool accCalibrated = false; @@ -54,6 +56,10 @@ void cookDataToJson(String &in, int *in_array, int array_size) { root.printTo(*output); } +void eatDataFromJson() { + +} + int lowFreqFilter(int inputValue, int lastFilteredValue, int alpha) { return (lastFilteredValue + alpha * (inputValue - lastFilteredValue)+100); } @@ -74,7 +80,6 @@ void updateSensors() if (graphAcc.counter < graphAcc.size - 1) { graphAcc.array[graphAcc.counter] = filteredSignal; - graphAcc.source[graphAcc.counter] = sourceSignal; graphAcc.counter++; } else @@ -82,10 +87,8 @@ void updateSensors() for (int i = 0; i != graphAcc.counter; i++) { graphAcc.array[i] = graphAcc.array[i + 1]; - graphAcc.source[i] = graphAcc.source[i + 1]; } graphAcc.array[graphAcc.counter] = filteredSignal; - graphAcc.source[graphAcc.counter] = sourceSignal; } accelerometer.lastUpdate = millis(); @@ -181,7 +184,7 @@ void loop(void) webSocket.loop(); updateSensors(); sendDataToSocket(); - + selfTest(); updateCpuTime(1);