From 3d76b5659844940a5e9a7415cea65893a2010f99 Mon Sep 17 00:00:00 2001 From: CodeCrafter912 Date: Sun, 8 Jul 2018 10:20:54 +0200 Subject: [PATCH 1/2] added connection Indication to the display header --- speedclock.h | 1 + speedclock.ino | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/speedclock.h b/speedclock.h index 791a0ac..f1e75fd 100644 --- a/speedclock.h +++ b/speedclock.h @@ -27,6 +27,7 @@ typedef struct transcv_struct{ #define STOPBUTTON_PRESSED LOW // this the signal level the top button will be at as soon as pressed #define MIN_DELAY_BETWEEN_PRESSED_MS 1000 // this defines the time in milliseconds before the button is expected to be pressed again. We do this to avaoid keybouncing #define MIN_DELAY_BETWEEN_SEND_MS 100 // this defines the time in milliseconds before the next set of data will be send to the base station - except the button was pressed. +#define CONN_TIMEOUT 10000 #define STARTBUTTON_IN 4 // start button #define STARTBUTTON_PRESSED LOW diff --git a/speedclock.ino b/speedclock.ino index 621efe1..6816dd4 100644 --- a/speedclock.ino +++ b/speedclock.ino @@ -30,9 +30,11 @@ unsigned long runner_start_time = 0; // this is the time the runner lef signed long runner_run_time = 0; // this is the time the runner really needed or the time started to early - depending on sign ... unsigned long run_time = 0; // if the timer is running this is that start time ... boolean warn_during_run = false; // will be set to true if there is a warning during the run - usually an offset sync error +unsigned long connection_established = 0; boolean topbuttonwaspressed = false; + timer_state_e timer_state = TIMER_WAIT; // timer needs to be initialized ... timer_state_e timer_new_state = TIMER_INIT; // timer needs to be initialized ... @@ -170,6 +172,7 @@ void loop(void) { // read data from TOP_STATION ... if( radio.available()){ // check if radio data is available - if so read the data + connection_established = millis(); while( radio.available(&pipeNo)){ // Read all available payloads radio.read( &radio_data, sizeof(radio_data) ); // Read the data the TOPSTATION sent } @@ -182,7 +185,6 @@ void loop(void) { Serial.println(current_time_offset); Serial.print(F(" Button was pressed last time on client in millis: ")); Serial.println(radio_data.topbuttonpressedtime); - } // offset calculation ... only needed if the variation is bigger than allowed or not enough values available already ... @@ -475,9 +477,17 @@ void update_screen(timer_state_e state){ display.setLetterSpacing(1); display.setCursor(64 - (display.strWidth(header_to_char) / 2), 0); display.print(header_to_char); + display.setCursor(1,0); + if(millis() - connection_established >= CONN_TIMEOUT || connection_established == 0){ + display.print(" "); + } + else { + display.print("Y"); + } display.setCursor(0,1); display.setLetterSpacing(0); display.print("----------------------------"); + //end of the Header //display.setLetterSpacing(1); display.set2X(); From b99d8f951ba56c6b8f32510757e08e45cf37ab20 Mon Sep 17 00:00:00 2001 From: CodeCrafter912 Date: Sun, 8 Jul 2018 11:29:03 +0200 Subject: [PATCH 2/2] added comments --- speedclock.ino | 3 +++ 1 file changed, 3 insertions(+) diff --git a/speedclock.ino b/speedclock.ino index 6816dd4..5dc6c37 100644 --- a/speedclock.ino +++ b/speedclock.ino @@ -478,10 +478,13 @@ void update_screen(timer_state_e state){ display.setCursor(64 - (display.strWidth(header_to_char) / 2), 0); display.print(header_to_char); display.setCursor(1,0); + //check if there is a connection to the topstation if(millis() - connection_established >= CONN_TIMEOUT || connection_established == 0){ + //if not remove the "Y" display.print(" "); } else { + //if print the "Y" display.print("Y"); } display.setCursor(0,1);