arduino dev
This commit is contained in:
parent
9b2bf554b1
commit
c1fcd3a47d
1 changed files with 7 additions and 12 deletions
|
@ -22,7 +22,6 @@ String vfd_line_bottom = "Waiting for stream. ";
|
|||
unsigned int vfd_line_position = 0;
|
||||
bool vfd_line_print = false;
|
||||
unsigned long millis_last_incoming_ping = 0;
|
||||
unsigned long millis_last_outgoing_ping = 0;
|
||||
|
||||
// the setup function runs once when you press reset or power the board
|
||||
void setup() {
|
||||
|
@ -49,6 +48,9 @@ void check_serial() {
|
|||
millis_last_incoming_ping = millis();
|
||||
int incomingByte = Serial.read();
|
||||
if (incomingByte == 0 || incomingByte == '^') {
|
||||
if (Serial.availableForWrite()) {
|
||||
Serial.write("pong^");
|
||||
}
|
||||
incomingByte = vfd_line_position = 0;
|
||||
}
|
||||
if (incomingByte < 32) {
|
||||
|
@ -71,28 +73,21 @@ void check_serial() {
|
|||
// the loop function runs over and over again forever
|
||||
void loop() {
|
||||
// We've been running for over 50 days and wrapped to zero. Reset all our timers
|
||||
if (millis() < 10000 && (millis_last_outgoing_ping > 10000 || millis_last_incoming_ping > 10000)) {
|
||||
millis_last_outgoing_ping = 0;
|
||||
if (millis() < 10000 && millis_last_incoming_ping > 10000) {
|
||||
millis_last_incoming_ping = 0;
|
||||
}
|
||||
|
||||
check_serial();
|
||||
|
||||
// If it's been 10 seconds since last incoming data
|
||||
// If it's been 30 seconds since last incoming data
|
||||
if (millis() - millis_last_incoming_ping > 30000) {
|
||||
// |12345678901234567890|
|
||||
vfd_line_top = "Error stream is down";
|
||||
vfd_line_bottom = "Verify or restart...";
|
||||
vfd_line_top = "Stream is down! Try ";
|
||||
vfd_line_bottom = "restarting computer.";
|
||||
vfd_line_print = true;
|
||||
millis_last_incoming_ping = millis();
|
||||
}
|
||||
|
||||
// Send outgoing ping every 5 seconds if we can.
|
||||
if (millis() - millis_last_outgoing_ping > 30000 && Serial.availableForWrite()) {
|
||||
Serial.write('^');
|
||||
millis_last_outgoing_ping = millis();
|
||||
}
|
||||
|
||||
// If we have something to print, print it
|
||||
if (vfd_line_print) {
|
||||
vfd_line_print = false;
|
||||
|
|
Loading…
Reference in a new issue