From 7503421eb6bea5f7c3758cb0604c54829df826c3 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Mon, 26 Feb 2024 09:11:21 +0100 Subject: [PATCH] Compile time optimization for booster mode --- MotorDriver.h | 12 +++++++++--- TrackManager.cpp | 9 +++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/MotorDriver.h b/MotorDriver.h index b678a84..4491164 100644 --- a/MotorDriver.h +++ b/MotorDriver.h @@ -34,9 +34,15 @@ template inline T operator| (T a, T b) { return (T)((int)a | (int)b); } template inline T operator& (T a, T b) { return (T)((int)a & (int)b); } template inline T operator^ (T a, T b) { return (T)((int)a ^ (int)b); } enum TRACK_MODE : byte {TRACK_MODE_NONE = 1, TRACK_MODE_MAIN = 2, TRACK_MODE_PROG = 4, - TRACK_MODE_DC = 8, TRACK_MODE_EXT = 16, TRACK_MODE_BOOST = 32, - TRACK_MODE_ALL = 62, // only to operate all tracks - TRACK_MODE_INV = 64, TRACK_MODE_DCX = 72 /*DC + INV*/, TRACK_MODE_AUTOINV = 128}; + TRACK_MODE_DC = 8, TRACK_MODE_EXT = 16, +#ifdef ARDUINO_ARCH_ESP32 + TRACK_MODE_BOOST = 32, +#else + TRACK_MODE_BOOST = 0, +#endif + TRACK_MODE_ALL = TRACK_MODE_MAIN|TRACK_MODE_PROG|TRACK_MODE_DC|TRACK_MODE_EXT|TRACK_MODE_BOOST, + TRACK_MODE_INV = 64, + TRACK_MODE_DCX = TRACK_MODE_DC|TRACK_MODE_INV, TRACK_MODE_AUTOINV = 128}; #define setHIGH(fastpin) *fastpin.inout |= fastpin.maskHIGH #define setLOW(fastpin) *fastpin.inout &= fastpin.maskLOW diff --git a/TrackManager.cpp b/TrackManager.cpp index 5aba978..e357e7f 100644 --- a/TrackManager.cpp +++ b/TrackManager.cpp @@ -362,7 +362,8 @@ bool TrackManager::parseEqualSign(Print *stream, int16_t params, int16_t p[]) if (params==2 && p[1]=="EXT"_hk) // <= id EXT> return setTrackMode(p[0],TRACK_MODE_EXT); #ifdef BOOSTER_INPUT - if (params==2 && p[1]=="BOOST"_hk) // <= id BOOST> + if (TRACK_MODE_BOOST != 0 && // compile time optimization + params==2 && p[1]=="BOOST"_hk) // <= id BOOST> return setTrackMode(p[0],TRACK_MODE_BOOST); #endif if (params==2 && p[1]=="AUTO"_hk) // <= id AUTO> @@ -401,11 +402,11 @@ const FSH* TrackManager::getModeName(TRACK_MODE tm) { modename=F("EXT"); else if(tm & TRACK_MODE_BOOST) { if(tm & TRACK_MODE_AUTOINV) - modename=F("B A"); + modename=F("BOOST A"); else if (tm & TRACK_MODE_INV) - modename=F("B I"); + modename=F("BOOST I"); else - modename=F("B"); + modename=F("BOOST"); } else if (tm & TRACK_MODE_DC) { if (tm & TRACK_MODE_INV)