From 3691cf87d3456765e515ef3362135f1fa17b2636 Mon Sep 17 00:00:00 2001 From: Asbelos Date: Sun, 12 Jul 2020 19:12:25 +0100 Subject: [PATCH] use digitalRead2 --- Hardware.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Hardware.cpp b/Hardware.cpp index 2cfd1c4..e8ee2e7 100644 --- a/Hardware.cpp +++ b/Hardware.cpp @@ -27,8 +27,10 @@ #if defined(ARDUINO_ARCH_AVR) #include // use IDE menu Tools..Manage Libraries to locate and install DIO2 #define WritePin digitalWrite2 + #define ReadPin digitalRead2 #else #define WritePin digitalWrite + #define ReadPin digitalRead #endif void Hardware::init() { @@ -66,7 +68,7 @@ int Hardware::getCurrentRaw(bool isMainTrack) { byte faultpin = isMainTrack ? MAIN_FAULT_PIN : PROG_FAULT_PIN; byte signalpin = isMainTrack ? MAIN_SIGNAL_PIN : PROG_SIGNAL_PIN; - if (faultpin != UNUSED_PIN && digitalRead(faultpin) == LOW && digitalRead(signalpin) == HIGH) + if (faultpin != UNUSED_PIN && ReadPin(faultpin) == LOW && ReadPin(signalpin) == HIGH) return 32767; // MAXINT because we don't know the actual current, return as high as we can // IMPORTANT: This function can be called in Interrupt() time within the 56uS timer // The default analogRead takes ~100uS which is catastrphic