From c6c7ec4ad57c609c24d84384732059649715700b Mon Sep 17 00:00:00 2001 From: Mike C Date: Thu, 25 Apr 2013 19:53:40 -0400 Subject: [PATCH] Added TX/RX status via blinking button LED's when UI is timed out/off --- Universal_Serial_Adapter/Config.cpp | 21 +++++++++++++++++++ Universal_Serial_Adapter/UI.cpp | 14 +++++++++++++ Universal_Serial_Adapter/UI.h | 3 +++ Universal_Serial_Adapter/UILCD.cpp | 2 +- .../Universal_Serial_Adapter.ino | 16 -------------- 5 files changed, 39 insertions(+), 17 deletions(-) diff --git a/Universal_Serial_Adapter/Config.cpp b/Universal_Serial_Adapter/Config.cpp index b35d46d..7d6cff5 100644 --- a/Universal_Serial_Adapter/Config.cpp +++ b/Universal_Serial_Adapter/Config.cpp @@ -217,35 +217,56 @@ void Config::processSerialData() { //if (DEBUG) { // Serial.println("Config::processSerialData()"); //} + //#if DEBUG == 2 + //DateTime now = rtc.now(); + //Serial.print(now.year(), DEC); + //Serial.print('/'); + //Serial.print(now.month(), DEC); + //Serial.print('/'); + //Serial.print(now.day(), DEC); + //Serial.print(' '); + //Serial.print(now.hour(), DEC); + //Serial.print(':'); + //Serial.print(now.minute(), DEC); + //Serial.print(':'); + //Serial.print(now.second(), DEC); + //Serial.println(); + //#endif switch (currentMode) { case 0: // ttl if (Serial3.available()) { int inByte = Serial3.read(); Serial.write(inByte); + ui->blinkCancelButton(); } if (Serial.available()) { int inByte = Serial.read(); Serial3.write(inByte); + ui->blinkOKButton(); } break; case 1: // db9_null if (Serial2.available()) { int inByte = Serial2.read(); Serial.write(inByte); + ui->blinkCancelButton(); } if (Serial.available()) { int inByte = Serial.read(); Serial2.write(inByte); + ui->blinkOKButton(); } break; case 2: // cisco if (Serial1.available()) { int inByte = Serial1.read(); Serial.write(inByte); + ui->blinkCancelButton(); } if (Serial.available()) { int inByte = Serial.read(); Serial1.write(inByte); + ui->blinkOKButton(); } break; } diff --git a/Universal_Serial_Adapter/UI.cpp b/Universal_Serial_Adapter/UI.cpp index 3ac1bf7..63a9b05 100644 --- a/Universal_Serial_Adapter/UI.cpp +++ b/Universal_Serial_Adapter/UI.cpp @@ -29,6 +29,20 @@ UI::UI() { startUI(); } +void UI::blinkOKButton() { + if (!config->isUIEnabled()) { + okButton->turnOnLed(); + okButton->turnOffLed(); + } +} + +void UI::blinkCancelButton() { + if (!config->isUIEnabled()) { + cancelButton->turnOnLed(); + cancelButton->turnOffLed(); + } +} + void UI::setLCDTimeout() { uiTimeout->interval(config->getTimeoutMilis()); } diff --git a/Universal_Serial_Adapter/UI.h b/Universal_Serial_Adapter/UI.h index 32c87ae..bf3f640 100644 --- a/Universal_Serial_Adapter/UI.h +++ b/Universal_Serial_Adapter/UI.h @@ -50,6 +50,9 @@ public: void setLCDTimeout(); void resetTimeout(); + + void blinkOKButton(); + void blinkCancelButton(); }; #endif diff --git a/Universal_Serial_Adapter/UILCD.cpp b/Universal_Serial_Adapter/UILCD.cpp index f60835a..b2a1a49 100644 --- a/Universal_Serial_Adapter/UILCD.cpp +++ b/Universal_Serial_Adapter/UILCD.cpp @@ -610,7 +610,7 @@ void UILCD::bmpDraw(char *filename, uint8_t x, uint8_t y) { } bmpFile.close(); - if(!goodBmp && DEBUG) Serial.println("BMP format not recognized."); + if(!goodBmp && DEBUG == 2) Serial.println("BMP format not recognized."); } // These read 16- and 32-bit types from the SD card file. diff --git a/Universal_Serial_Adapter/Universal_Serial_Adapter.ino b/Universal_Serial_Adapter/Universal_Serial_Adapter.ino index 6f7ac9b..92c2d73 100644 --- a/Universal_Serial_Adapter/Universal_Serial_Adapter.ino +++ b/Universal_Serial_Adapter/Universal_Serial_Adapter.ino @@ -66,22 +66,6 @@ void setup() { } void loop() { - if (DEBUG) { - DateTime now = rtc.now(); - Serial.print(now.year(), DEC); - Serial.print('/'); - Serial.print(now.month(), DEC); - Serial.print('/'); - Serial.print(now.day(), DEC); - Serial.print(' '); - Serial.print(now.hour(), DEC); - Serial.print(':'); - Serial.print(now.minute(), DEC); - Serial.print(':'); - Serial.print(now.second(), DEC); - Serial.println(); - } - // Serial data is processed via an interrupt so isn't needed in the main loop ui->processInputEvents(); ui->processTimeoutEvents();