From 8decd7db0a96cdb83658a378b68d3de82ee0add1 Mon Sep 17 00:00:00 2001 From: Asbelos Date: Mon, 22 Jun 2020 10:47:25 +0100 Subject: [PATCH] Change to TimerOne and drop Railcom code for now. --- Hardware.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Hardware.cpp b/Hardware.cpp index 5111679..230177c 100644 --- a/Hardware.cpp +++ b/Hardware.cpp @@ -1,13 +1,11 @@ #include -#include -#include - +#include // use IDE menu Tools..Manage Libraries to locate and install TimerOne #include "Hardware.h" #include "Config.h" #include "DIAG.h" #if defined(ARDUINO_ARCH_AVR) - #include + #include // use IDE menu Tools..Manage Libraries to locate and install DIO2 #define WritePin digitalWrite2 #else #define WritePin digitalWrite @@ -47,20 +45,22 @@ int Hardware::getCurrentMilliamps(bool isMainTrack) { } void Hardware::setCallback(int duration, void (*isr)()) { - Timer3.initialize(duration); - Timer3.disablePwm(TIMER3_A_PIN); - Timer3.disablePwm(TIMER3_B_PIN); - Timer3.attachInterrupt(isr); -} - -void Hardware::setSingleCallback(int duration, void (*isr)()) { Timer1.initialize(duration); + // We don't want the timer to set pins because these often clash with motor shields etc. Timer1.disablePwm(TIMER1_A_PIN); Timer1.disablePwm(TIMER1_B_PIN); Timer1.attachInterrupt(isr); } -void Hardware::resetSingleCallback(int duration) { - if (duration==0) Timer1.stop(); - else Timer1.initialize(duration); +// Railcom support functions, not yet implemented +void Hardware::setSingleCallback(int duration, void (*isr)()) { +// Timer2.initialize(duration); +// Timer2.disablePwm(TIMER1_A_PIN); +// Timer2.disablePwm(TIMER1_B_PIN); +// Timer2.attachInterrupt(isr); +} + +void Hardware::resetSingleCallback(int duration) { +// if (duration==0) Timer2.stop(); +// else Timer2.initialize(duration); }