Bodenkontaktzeiten auf der Webseite darstellen
* Zeiten ausrechnen * Die letzten 20 Zeiten in einer Liste darstellen
This commit is contained in:
parent
7076dddda3
commit
1c8df52823
59
src/main.cpp
59
src/main.cpp
|
@ -10,6 +10,7 @@
|
|||
|
||||
int sensorValue = 0;
|
||||
int letzteWerte[100];
|
||||
int niedrigsterWert = 1024;
|
||||
int idWert = 0;
|
||||
|
||||
|
||||
|
@ -36,7 +37,7 @@ int kontaktzeiten[20];
|
|||
int idx = 0;
|
||||
|
||||
String websiteA = "<!doctype html><html lang=en><head><meta charset=utf-8><title>Sensor</title></head><body style='background:#2d2d2d'>"
|
||||
"<div style='position:fixed;top:10%;left:10%;width:80%;height:80%;color:#ffffff;text-align:left;vertical-align:left;line-height:400%;font-size:400%;font-family:Arial,Helvetica,sans-serif;''> <ul style='list-style-type:none;'> ";
|
||||
"<div style='position:fixed;top:10%;left:10%;width:80%;height:80%;color:#ffffff;text-align:left;vertical-align:left;line-height:100%;font-size:300%;font-family:Arial,Helvetica,sans-serif;''> <ul style='list-style-type:none;'> ";
|
||||
String websiteB = "</ul></div><div style='position:fixed;bottom:0;left:0;width:100%;height:20%;background:#9ade00;color:#00252c;text-align:center;vertical-align:middle;line-height:400%;font-size:400%'> <p><b>Start</b></p> </div> </body></html>";
|
||||
|
||||
|
||||
|
@ -48,9 +49,16 @@ const int led = 13;
|
|||
|
||||
void handleRoot() {
|
||||
String liste;
|
||||
for(int i = idWert; i < idWert + 100; i++) {
|
||||
liste = liste + letzteWerte[i % 100] + "\r\n";
|
||||
|
||||
int vorherig = 1024;
|
||||
int aktuell = 1024;
|
||||
|
||||
liste = liste + "niedrigster: " + niedrigsterWert;
|
||||
liste = liste + "<li>";
|
||||
for(int i = 0; i < 20; i++) {
|
||||
liste = liste + "<ul>" + i + ". Kontakt:" + kontaktzeiten[i] + " ms </ul>";
|
||||
}
|
||||
liste = liste + "</li>";
|
||||
server.send(200, "text/html", websiteA + liste + websiteB);
|
||||
}
|
||||
|
||||
|
@ -86,44 +94,47 @@ void setup(void) {
|
|||
}
|
||||
|
||||
|
||||
int letzterWert = 1024;
|
||||
|
||||
void loop(void) {
|
||||
|
||||
|
||||
sensorValue = analogRead(ANALOG_READ_PIN);
|
||||
Serial.println(sensorValue);
|
||||
// Serial.println(sensorValue);
|
||||
|
||||
letzteWerte[idWert] = sensorValue;
|
||||
idWert = (idWert + 1) % 100;
|
||||
niedrigsterWert = std::min(sensorValue, niedrigsterWert);
|
||||
|
||||
// Hier Logik ändern
|
||||
/*
|
||||
// read the input pin:
|
||||
int buttonState = digitalRead(pushButton);
|
||||
// print out the state of the button:
|
||||
//Serial.println(buttonState);
|
||||
//Serial.println(millis());
|
||||
if(lastbuttonstate == 0 && buttonState == 1)
|
||||
if(letzterWert >= 300 && sensorValue < 300 )
|
||||
{
|
||||
auftrittmillis = millis();
|
||||
Serial.print("Auftritt: ");
|
||||
Serial.println(auftrittmillis);
|
||||
|
||||
// nur wenn mehr als 30ms, dann Ausgeben
|
||||
if((auftrittmillis - abtrittmillis) > 30) {
|
||||
Serial.print("Flugphase: ");
|
||||
Serial.println(auftrittmillis - abtrittmillis);
|
||||
}
|
||||
if(lastbuttonstate == 1 && buttonState == 0)
|
||||
}
|
||||
if(letzterWert < 300 && sensorValue >= 300)
|
||||
{
|
||||
abtrittmillis = millis();
|
||||
Serial.print("Abgehoben: ");
|
||||
Serial.println(abtrittmillis);
|
||||
Serial.print("Bodenkontakt: ");
|
||||
Serial.println(abtrittmillis - auftrittmillis);
|
||||
|
||||
|
||||
if ((abtrittmillis - auftrittmillis)> 30 ) {
|
||||
auftrittzeiten[idx] = auftrittmillis;
|
||||
kontaktzeiten[idx] = abtrittmillis - auftrittmillis;
|
||||
idx = (idx + 1)%20;
|
||||
}
|
||||
lastbuttonstate = buttonState;
|
||||
*/
|
||||
|
||||
delay(10); // delay in between reads for stability
|
||||
Serial.print(idx);
|
||||
Serial.print(". Bodenkontakt: ");
|
||||
Serial.println(abtrittmillis - auftrittmillis);
|
||||
}
|
||||
}
|
||||
|
||||
letzterWert = sensorValue;
|
||||
|
||||
|
||||
delay(20); // delay in between reads for stability
|
||||
server.handleClient();
|
||||
MDNS.update();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue