Skip to content

Instantly share code, notes, and snippets.

@avtolstoy
Created March 31, 2016 20:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avtolstoy/a8fe51b3f874fd0d1cea7339c960b7a1 to your computer and use it in GitHub Desktop.
Save avtolstoy/a8fe51b3f874fd0d1cea7339c960b7a1 to your computer and use it in GitHub Desktop.
#include "application.h"
SYSTEM_MODE(MANUAL);
SYSTEM_THREAD(ENABLED);
uint32_t lastMillis = 0;
void setup()
{
Serial.begin(9600); //Begin USB serial session
Serial.blockOnOverrun(false); //don't let serial block
delay(5000); //start-up delay
#if PLATFORM_ID == 10
Cellular.off();
#else
WiFi.off();
#endif
}
void loop()
{
uint32_t mil1 = millis();
Serial.println("Millis: " + String( mil1 ) );
uint32_t mil2 = millis();
if (mil2 - lastMillis >= 10 && lastMillis != 0) {
Serial.blockOnOverrun(true);
// Consume RX buffer
while(Serial.available())
(void)Serial.read();
while(Serial.available() == 0) {
Serial.println("Diff: " + String(mil2 - lastMillis));
Serial.println("Press any key to continue");
Serial.flush();
delay(1000);
}
while(Serial.available())
(void)Serial.read();
Serial.blockOnOverrun(false);
lastMillis = millis();
} else {
lastMillis = mil1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment