From fc8c0b468adb1c15116bd34ff7fae0471d36dded Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0?= Date: Wed, 30 May 2018 12:44:12 +0300 Subject: [PATCH] fix commit: added important vars, fixed board perfomance --- src/main.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index a197073..5f074c1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,6 +18,8 @@ const char *ssid = "LabWork_1"; ESP8266WebServer server(80); Sensor accelerometer = Sensor(); Graph graphAcc = Graph(256, 50); +Ticker sensorTicker, stepTicker; + double vReal[256]; double vImag[256]; @@ -30,12 +32,16 @@ int accCalRemains = 0; int accMax1 = 0; int accMax2 = 0; + +double peakFreq = 0; +int steps = 0; + WebSocketsServer webSocket = WebSocketsServer(81); void handleAccelerometer() { int16_t bias = 0; - const int arr_size = 5000; + const int arr_size = 7000; char *html_code = new char[arr_size]; memset(html_code, '\0', sizeof(char) * arr_size); @@ -189,17 +195,14 @@ void setup(void) webSocket.onEvent(webSocketEvent); pinMode(A0, INPUT); + sensorTicker.attach_ms(33, updateAccelerometer); + stepTicker.attach_ms(8500, stepUpdater); } void loop(void) { - updateCpuTime(0); - server.handleClient(); - webSocket.loop(); - updateAccelerometer(); + delay(10); sendAccelerometerData(); - - updateCpuTime(1); - printCpuLoad(); + delay(10); } \ No newline at end of file