Browse Source

fix commit: added important vars, fixed board perfomance

master
Никита 7 years ago
parent
commit
fc8c0b468a
  1. 19
      src/main.cpp

19
src/main.cpp

@ -18,6 +18,8 @@ const char *ssid = "LabWork_1";
ESP8266WebServer server(80); ESP8266WebServer server(80);
Sensor accelerometer = Sensor(); Sensor accelerometer = Sensor();
Graph graphAcc = Graph(256, 50); Graph graphAcc = Graph(256, 50);
Ticker sensorTicker, stepTicker;
double vReal[256]; double vReal[256];
double vImag[256]; double vImag[256];
@ -30,12 +32,16 @@ int accCalRemains = 0;
int accMax1 = 0; int accMax1 = 0;
int accMax2 = 0; int accMax2 = 0;
double peakFreq = 0;
int steps = 0;
WebSocketsServer webSocket = WebSocketsServer(81); WebSocketsServer webSocket = WebSocketsServer(81);
void handleAccelerometer() void handleAccelerometer()
{ {
int16_t bias = 0; int16_t bias = 0;
const int arr_size = 5000; const int arr_size = 7000;
char *html_code = new char[arr_size]; char *html_code = new char[arr_size];
memset(html_code, '\0', sizeof(char) * arr_size); memset(html_code, '\0', sizeof(char) * arr_size);
@ -189,17 +195,14 @@ void setup(void)
webSocket.onEvent(webSocketEvent); webSocket.onEvent(webSocketEvent);
pinMode(A0, INPUT); pinMode(A0, INPUT);
sensorTicker.attach_ms(33, updateAccelerometer);
stepTicker.attach_ms(8500, stepUpdater);
} }
void loop(void) void loop(void)
{ {
updateCpuTime(0);
server.handleClient(); server.handleClient();
webSocket.loop(); delay(10);
updateAccelerometer();
sendAccelerometerData(); sendAccelerometerData();
delay(10);
updateCpuTime(1);
printCpuLoad();
} }
Loading…
Cancel
Save