Created
March 31, 2016 20:08
-
-
Save avtolstoy/a8fe51b3f874fd0d1cea7339c960b7a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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