From bded5d3588d41bb1727c0ec671c3c1f001de965f Mon Sep 17 00:00:00 2001 From: Asbelos Date: Tue, 27 Apr 2021 15:45:26 +0100 Subject: [PATCH] 3.0.12 Fix Functions >127 (just a bug) (#146) * Fix Functions >127 * Update version.h * avoid freds fix Co-authored-by: Fred --- DCC.cpp | 10 +++++----- DCC.h | 8 ++++---- version.h | 5 +++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/DCC.cpp b/DCC.cpp index 0185ce9..b31d8c9 100644 --- a/DCC.cpp +++ b/DCC.cpp @@ -142,7 +142,7 @@ bool DCC::getThrottleDirection(int cab) { } // Set function to value on or off -void DCC::setFn( int cab, byte functionNumber, bool on) { +void DCC::setFn( int cab, int16_t functionNumber, bool on) { if (cab<=0 ) return; if (functionNumber>28) { @@ -159,7 +159,7 @@ void DCC::setFn( int cab, byte functionNumber, bool on) { else { b[nB++] = 0b11000000; // Binary State Control Instruction long form b[nB++] = (functionNumber & 0x7F) | (on ? 0x80 : 0); // low order bits and state flag - b[nB++] = functionNumber >>8 ; // high order bits + b[nB++] = functionNumber >>7 ; // high order bits } DCCWaveform::mainTrack.schedulePacket(b, nB, 4); return; @@ -183,7 +183,7 @@ void DCC::setFn( int cab, byte 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, byte functionNumber, bool pressed) { +int DCC::changeFn( int cab, int16_t functionNumber, bool pressed) { int funcstate = -1; if (cab<=0 || functionNumber>28) return funcstate; int reg = lookupSpeedTable(cab); @@ -213,7 +213,7 @@ int DCC::changeFn( int cab, byte functionNumber, bool pressed) { return funcstate; } -int DCC::getFn( int cab, byte functionNumber) { +int DCC::getFn( int cab, int16_t functionNumber) { if (cab<=0 || functionNumber>28) return -1; // unknown int reg = lookupSpeedTable(cab); if (reg<0) return -1; @@ -224,7 +224,7 @@ int DCC::getFn( int cab, byte functionNumber) { // Set the group flag to say we have touched the particular group. // A group will be reminded only if it has been touched. -void DCC::updateGroupflags(byte & flags, int functionNumber) { +void DCC::updateGroupflags(byte & flags, int16_t functionNumber) { byte groupMask; if (functionNumber<=4) groupMask=FN_GROUP_1; else if (functionNumber<=8) groupMask=FN_GROUP_2; diff --git a/DCC.h b/DCC.h index 0f5c489..3473d6f 100644 --- a/DCC.h +++ b/DCC.h @@ -76,10 +76,10 @@ public: static void writeCVByteMain(int cab, int cv, byte bValue); static void writeCVBitMain(int cab, int cv, byte bNum, bool bValue); static void setFunction(int cab, byte fByte, byte eByte); - static void setFn(int cab, byte functionNumber, bool on); - static int changeFn(int cab, byte functionNumber, bool pressed); - static int getFn(int cab, byte functionNumber); - static void updateGroupflags(byte &flags, int functionNumber); + static void setFn(int cab, int16_t functionNumber, bool on); + static int changeFn(int cab, int16_t functionNumber, bool pressed); + static int getFn(int cab, int16_t functionNumber); + static void updateGroupflags(byte &flags, int16_t functionNumber); static void setAccessory(int aAdd, byte aNum, bool activate); static bool writeTextPacket(byte *b, int nBytes); static void setProgTrackSyncMain(bool on); // when true, prog track becomes driveable diff --git a/version.h b/version.h index 00acfd2..a2388ca 100644 --- a/version.h +++ b/version.h @@ -3,8 +3,9 @@ #include "StringFormatter.h" -#define VERSION "3.0.12" -// 3.0.12 fix esp8266 test for new firmware +#define VERSION "3.0.13" +// 3.0.13 Functions>127 fix +// 3.0.12 Fix HOSTNAME function for STA mode for WiFi // 3.0.11 ? // 3.0.10 Teensy Support // 3.0.9 rearranges serial newlines for the benefit of JMRI.