From 74bbe595fc1ccb7493c27203f880172968abd247 Mon Sep 17 00:00:00 2001 From: Asbelos Date: Wed, 23 Feb 2022 16:21:45 +0000 Subject: [PATCH] DC hooks still requires pin jiggling --- DCC.cpp | 2 ++ MotorDriver.cpp | 5 +++++ MotorDriver.h | 1 + TrackManager.cpp | 2 +- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/DCC.cpp b/DCC.cpp index 7790936..6d19a26 100644 --- a/DCC.cpp +++ b/DCC.cpp @@ -35,6 +35,7 @@ #include "IODevice.h" #include "EXRAIL2.h" #include "CommandDistributor.h" +#include "TrackManager.h" // This module is responsible for converting API calls into // messages to be sent to the waveform generator. @@ -78,6 +79,7 @@ void DCC::begin(const FSH * motorShieldName) { void DCC::setThrottle( uint16_t cab, uint8_t tSpeed, bool tDirection) { byte speedCode = (tSpeed & 0x7F) + tDirection * 128; setThrottle2(cab, speedCode); + TrackManager::setDCSignal(cab,speedCode); // in case this is a dcc track on this addr // retain speed for loco reminders updateLocoReminder(cab, speedCode ); } diff --git a/MotorDriver.cpp b/MotorDriver.cpp index c441f8a..7f2d3e1 100644 --- a/MotorDriver.cpp +++ b/MotorDriver.cpp @@ -169,6 +169,11 @@ int MotorDriver::getCurrentRaw() { } +void MotorDriver::setDCSignal(byte speedcode) { + // spedcxode is a dcc speed /direction + // TODO jiggle the DC speed pin PWMs + +} int MotorDriver::getCurrentRawInInterrupt() { // IMPORTANT: This function must be called in Interrupt() time within the 56uS timer diff --git a/MotorDriver.h b/MotorDriver.h index 80453ea..ca30706 100644 --- a/MotorDriver.h +++ b/MotorDriver.h @@ -54,6 +54,7 @@ class MotorDriver { virtual POWERMODE getPower() { return powerMode;} virtual void setSignal( bool high); virtual void setBrake( bool on); + virtual void setDCSignal(byte speedByte); virtual int getCurrentRaw(); virtual int getCurrentRawInInterrupt(); virtual unsigned int raw2mA( int raw); diff --git a/TrackManager.cpp b/TrackManager.cpp index 10b61c2..8235984 100644 --- a/TrackManager.cpp +++ b/TrackManager.cpp @@ -82,7 +82,7 @@ void TrackManager::setPROGSignal( bool on) { } void TrackManager::setDCSignal(int16_t cab, byte speedbyte) { - // TODO LOOPMODE(cab,setDC(speedbyte)); + LOOPMODE(cab,setDCSignal(speedbyte)); } bool TrackManager::setTrackMode(byte trackToSet, int16_t modeOrAddr) {