|
|
@ -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(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|