From 1b07d0a5c60766f828f4663478c039da06ff6e6e Mon Sep 17 00:00:00 2001 From: Asbelos Date: Thu, 16 Dec 2021 10:28:41 +0000 Subject: [PATCH] Simplify Withrottle function changes --- DCC.cpp | 38 +++++++------------------------------- DCC.h | 2 +- WiThrottle.cpp | 10 ++++++---- WiThrottle.h | 4 ++-- 4 files changed, 16 insertions(+), 38 deletions(-) diff --git a/DCC.cpp b/DCC.cpp index 67bf676..4469aa1 100644 --- a/DCC.cpp +++ b/DCC.cpp @@ -192,39 +192,15 @@ void DCC::setFn( int cab, int16_t functionNumber, bool on) { } } -// Change function according to how button was pressed, -// typically in WiThrottle. -// Returns new state or -1 if nothing was changed. -int DCC::changeFn( int cab, int16_t functionNumber, bool pressed) { - int funcstate = -1; - if (cab<=0 || functionNumber>28) return funcstate; +// Flip function state +void DCC::changeFn( int cab, int16_t functionNumber) { + if (cab<=0 || functionNumber>28) return; int reg = lookupSpeedTable(cab); - if (reg<0) return funcstate; - uint32_t oldFunctionMap=speedTable[reg].functions; - - // Take care of functions: - // Imitate how many command stations do it: Button press is - // toggle but for F2 where it is momentary + if (reg<0) return; unsigned long funcmask = (1UL<