Browse Source

some optimisation

master
parent
commit
a907798c86
  1. 1
      .gitignore
  2. 11
      src/main.cpp

1
.gitignore

@ -6,3 +6,4 @@
.vscode/launch.json
.vscode
.vscode/.browse.c_cpp.db*
.lib/readme.txt

11
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);

Loading…
Cancel
Save