-
Notifications
You must be signed in to change notification settings - Fork 0
Odometer
Tiogaplanet edited this page Oct 9, 2018
·
2 revisions
The odometer tracks the distance MiP has traveled.
float readDistanceTravelled()
Read the current MiP odometer tally.
None
The distance travelled (in centimeters) since the last reset.
- MiP's odometer is similar to that in a car. It maintains the total tally of the distance travelled, even across power cycles.
- The resetDistanceTravelled() function can be used to reset the odometer.
#include <mip_esp8266.h>
MiP mip;
void setup() {
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("Odometer.ino - Read out current odometer reading and reset."));
float cm = mip.readDistanceTravelled();
Serial.print(F("MiP has travelled "));
Serial.print(cm);
Serial.println(F(" cm since the last reset."));
mip.resetDistanceTravelled();
Serial.println();
Serial.println(F("Sample done."));
}
void loop() {
}
void resetDistanceTravelled()
Reset MiP's odometer. The current odometer distance measurement is available by calling the readDistanceTravelled() function.
None
Nothing
- MiP's odometer doesn't automatically reset during a power cycle.
- You should call this function if you want to manually reset it.
#include <mip_esp8266.h>
MiP mip;
void setup() {
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("Odometer.ino - Read out current odometer reading and reset."));
float cm = mip.readDistanceTravelled();
Serial.print(F("MiP has travelled "));
Serial.print(cm);
Serial.println(F(" cm since the last reset."));
mip.resetDistanceTravelled();
Serial.println();
Serial.println(F("Sample done."));
}
void loop() {
}