From 01a6d1c8f4e665239be0257f1f65426272ee094e Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sun, 29 Nov 2020 10:48:39 +0100 Subject: [PATCH 1/6] Ethernet should need a #define in config(.example).h --- DCCEX.h | 2 ++ EthernetInterface.cpp | 9 +++++---- LCD_Implementation.h | 5 +++-- config.example.h | 8 ++++++++ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/DCCEX.h b/DCCEX.h index fb4baef..d89d581 100644 --- a/DCCEX.h +++ b/DCCEX.h @@ -10,7 +10,9 @@ #include "DCCEXParser.h" #include "version.h" #include "WifiInterface.h" +#if ETHERNET_ON == true #include "EthernetInterface.h" +#endif #include "LCD_Implementation.h" #include "freeMemory.h" #include diff --git a/EthernetInterface.cpp b/EthernetInterface.cpp index 6251bac..1cc41b8 100644 --- a/EthernetInterface.cpp +++ b/EthernetInterface.cpp @@ -18,6 +18,9 @@ * */ +#include "config.h" +#include "defines.h" // This should be changed to DCCEX.h when possible +#if ETHERNET_ON == true #include "EthernetInterface.h" #include "DIAG.h" #include "CommandDistributor.h" @@ -166,8 +169,6 @@ void EthernetInterface::loop() if (Diag::ETHERNET) DIAG(F("Ethernet reply socket=%d, count=:%d\n"), socketOut,count); for(;count>0;count--) clients[socketOut].write(outboundRing->read()); clients[socketOut].flush(); //maybe - } - } - - +} +#endif diff --git a/LCD_Implementation.h b/LCD_Implementation.h index 1da344e..45e0429 100644 --- a/LCD_Implementation.h +++ b/LCD_Implementation.h @@ -25,6 +25,8 @@ // which libraray is involved. //////////////////////////////////////////////////////////////////////////////////// +#ifndef LCD_Implementation_h +#define LCD_Implementation_h #include "config.h" #include #include "LCDDisplay.h" @@ -50,6 +52,5 @@ LCDDisplay * LCDDisplay::lcdDisplay=0; #include "LCD_NONE.h" #define CONDITIONAL_LCD_START if (false) /* NO LCD CONFIG */ #endif - - +#endif // LCD_Implementation_h diff --git a/config.example.h b/config.example.h index 174e590..0c2d137 100644 --- a/config.example.h +++ b/config.example.h @@ -76,6 +76,14 @@ The configuration file for DCC++ EX Command Station // //#define WIFI_CONNECT_TIMEOUT 14000 +///////////////////////////////////////////////////////////////////////////////////// +// +// ENABLE_ETHERNET: Set to true if you have an Arduino Ethernet card (wired). This +// is not for Wifi. You will then need the Arduino Ethernet library as well +// +//#define ENABLE_ETHERNET true + + ///////////////////////////////////////////////////////////////////////////////////// // // DEFINE STATIC IP ADDRESS *OR* COMMENT OUT TO USE DHCP From a1f7d06508bbc1337356e6c79314dbd2650bb618 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sun, 6 Dec 2020 21:43:37 +0100 Subject: [PATCH 2/6] Report current as 1/1024 as expected by JMRI --- DCCEXParser.cpp | 2 +- DCCWaveform.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index 3d3bed6..f073f70 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -434,7 +434,7 @@ void DCCEXParser::parse(Print *stream, byte *com, bool blocking) return; case 'c': // READ CURRENT - StringFormatter::send(stream, F(""), DCCWaveform::mainTrack.getLastCurrent()); + StringFormatter::send(stream, F(""), DCCWaveform::mainTrack.get1024Current()); return; case 'Q': // SENSORS diff --git a/DCCWaveform.h b/DCCWaveform.h index c658577..b51e79f 100644 --- a/DCCWaveform.h +++ b/DCCWaveform.h @@ -57,6 +57,11 @@ class DCCWaveform { POWERMODE getPowerMode(); void checkPowerOverload(); int getLastCurrent(); + inline int get1024Current() { + if (powerMode == POWERMODE::ON) + return (int)(lastCurrent*(long int)1024/motorDriver->getRawCurrentTripValue()); + return 0; + } void schedulePacket(const byte buffer[], byte byteCount, byte repeats); volatile bool packetPending; volatile byte sentResetsSincePacket; From 73b532508587a6b1d10ba65c448ba2b6ab85b0a7 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Fri, 11 Dec 2020 19:03:05 +0100 Subject: [PATCH 3/6] better speed step comment --- DCCEXParser.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index 3d3bed6..176e09c 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -272,7 +272,8 @@ void DCCEXParser::parse(Print *stream, byte *com, bool blocking) else break; - // Convert JMRI bizarre -1=emergency stop, 0-126 as speeds + // Convert DCC-EX protocol speed steps where + // -1=emergency stop, 0-126 as speeds // to DCC 0=stop, 1= emergency stop, 2-127 speeds if (tspeed > 126 || tspeed < -1) break; // invalid JMRI speed code From 89073bd3115e5cd2f4d7b4284f4fe189cd1b70a1 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Fri, 11 Dec 2020 19:11:17 +0100 Subject: [PATCH 4/6] give back witspeed not converted (DCC) locospeed --- WiThrottle.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/WiThrottle.cpp b/WiThrottle.cpp index 61f7f92..d9b9ec7 100644 --- a/WiThrottle.cpp +++ b/WiThrottle.cpp @@ -262,10 +262,10 @@ void WiThrottle::locoAction(RingStream * stream, byte* aval, char throttleChar, switch (aval[0]) { case 'V': // Vspeed { - byte locospeed=WiTToDCCSpeed(getInt(aval+1)); + int witSpeed=getInt(aval+1); LOOPLOCOS(throttleChar, cab) { - DCC::setThrottle(myLocos[loco].cab, locospeed, DCC::getThrottleDirection(myLocos[loco].cab)); - StringFormatter::send(stream,F("M%cA%c%d<;>V%d\n"), throttleChar, LorS(myLocos[loco].cab), myLocos[loco].cab, locospeed); + DCC::setThrottle(myLocos[loco].cab, WiTToDCCSpeed(witSpeed), DCC::getThrottleDirection(myLocos[loco].cab)); + StringFormatter::send(stream,F("M%cA%c%d<;>V%d\n"), throttleChar, LorS(myLocos[loco].cab), myLocos[loco].cab, witSpeed); } } break; From b9fdfdd71c516858fc2914452f0b3c02f10b31df Mon Sep 17 00:00:00 2001 From: mstevetodd Date: Fri, 11 Dec 2020 14:20:13 -0500 Subject: [PATCH 5/6] FIX: return WiThrottle speedstep, not DCC speedstep, in response to speed change request (#105) * FIX: return WiThrottle speedstep, not DCC speedstep, in response to speed change request. Should close #104 * use int, not byte for witSpeed --- WiThrottle.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/WiThrottle.cpp b/WiThrottle.cpp index 61f7f92..d9b9ec7 100644 --- a/WiThrottle.cpp +++ b/WiThrottle.cpp @@ -262,10 +262,10 @@ void WiThrottle::locoAction(RingStream * stream, byte* aval, char throttleChar, switch (aval[0]) { case 'V': // Vspeed { - byte locospeed=WiTToDCCSpeed(getInt(aval+1)); + int witSpeed=getInt(aval+1); LOOPLOCOS(throttleChar, cab) { - DCC::setThrottle(myLocos[loco].cab, locospeed, DCC::getThrottleDirection(myLocos[loco].cab)); - StringFormatter::send(stream,F("M%cA%c%d<;>V%d\n"), throttleChar, LorS(myLocos[loco].cab), myLocos[loco].cab, locospeed); + DCC::setThrottle(myLocos[loco].cab, WiTToDCCSpeed(witSpeed), DCC::getThrottleDirection(myLocos[loco].cab)); + StringFormatter::send(stream,F("M%cA%c%d<;>V%d\n"), throttleChar, LorS(myLocos[loco].cab), myLocos[loco].cab, witSpeed); } } break; From 5333b7889f9dd4e50ca1b632e207fc8d39162605 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Fri, 11 Dec 2020 22:02:11 +0100 Subject: [PATCH 6/6] bugfix patches go in now --- version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.h b/version.h index d0c09b9..e60dd91 100644 --- a/version.h +++ b/version.h @@ -4,7 +4,7 @@ #include "StringFormatter.h" // const char VERSION[] PROGMEM ="0.2.0"; -#define VERSION "3.0.0" +#define VERSION "3.0.1" #endif