From 3ea77891f12c75400de5219d5d41041c81d05ca8 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Fri, 27 Apr 2018 23:05:44 +0200 Subject: [PATCH] TX module LED indication --- .vscode/c_cpp_properties.json | 3 ++- crossbow/crossbow.ino | 18 +++++++++++++++++- crossbow/variables.h | 1 + 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index c6842ff..0b27556 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -16,7 +16,8 @@ "cppStandard": "c++17", "compilerPath": "/usr/bin/clang", "defines": [ - "FEATURE_TX_INPUT_SBUS" + "FEATURE_TX_INPUT_SBUS", + "ARDUINO_AVR_FEATHER32U4" ] }, { diff --git a/crossbow/crossbow.ino b/crossbow/crossbow.ino index faaacd0..a6067b4 100644 --- a/crossbow/crossbow.ino +++ b/crossbow/crossbow.ino @@ -648,8 +648,24 @@ void loop(void) } #endif -#endif + /* + * Handle LED updates + */ + if (txDeviceState.nextLedUpdate < currentMillis) { + if (txDeviceState.isReceiving) { + digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); + txDeviceState.nextLedUpdate = currentMillis + 300; + } else if (txInput.isReceiving()) { + digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); + txDeviceState.nextLedUpdate = currentMillis + 100; + } else { + digitalWrite(LED_BUILTIN, HIGH); + txDeviceState.nextLedUpdate = currentMillis + 200; + } + } + +#endif } diff --git a/crossbow/variables.h b/crossbow/variables.h index f0dcb7e..fd75559 100644 --- a/crossbow/variables.h +++ b/crossbow/variables.h @@ -115,6 +115,7 @@ struct TxDeviceState_t { uint8_t flags = 0; uint32_t roundtrip = 0; bool isReceiving = false; //Indicates that TX module is receiving frames from RX module + uint32_t nextLedUpdate = 0; }; struct RxDeviceState_t {