1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-27 01:56:14 +01:00

3.0.12 Fix Functions >127 (just a bug) (#146)

* Fix Functions >127

* Update version.h

* avoid freds fix

Co-authored-by: Fred <fndecker@gmail.com>
This commit is contained in:
Asbelos 2021-04-27 15:45:26 +01:00 committed by GitHub
parent 87481209ec
commit bded5d3588
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 11 deletions

10
DCC.cpp
View File

@ -142,7 +142,7 @@ bool DCC::getThrottleDirection(int cab) {
} }
// Set function to value on or off // 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 (cab<=0 ) return;
if (functionNumber>28) { if (functionNumber>28) {
@ -159,7 +159,7 @@ void DCC::setFn( int cab, byte functionNumber, bool on) {
else { else {
b[nB++] = 0b11000000; // Binary State Control Instruction long form 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 & 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); DCCWaveform::mainTrack.schedulePacket(b, nB, 4);
return; return;
@ -183,7 +183,7 @@ void DCC::setFn( int cab, byte functionNumber, bool on) {
// Change function according to how button was pressed, // Change function according to how button was pressed,
// typically in WiThrottle. // typically in WiThrottle.
// Returns new state or -1 if nothing was changed. // 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; int funcstate = -1;
if (cab<=0 || functionNumber>28) return funcstate; if (cab<=0 || functionNumber>28) return funcstate;
int reg = lookupSpeedTable(cab); int reg = lookupSpeedTable(cab);
@ -213,7 +213,7 @@ int DCC::changeFn( int cab, byte functionNumber, bool pressed) {
return funcstate; 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 if (cab<=0 || functionNumber>28) return -1; // unknown
int reg = lookupSpeedTable(cab); int reg = lookupSpeedTable(cab);
if (reg<0) return -1; 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. // Set the group flag to say we have touched the particular group.
// A group will be reminded only if it has been touched. // 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; byte groupMask;
if (functionNumber<=4) groupMask=FN_GROUP_1; if (functionNumber<=4) groupMask=FN_GROUP_1;
else if (functionNumber<=8) groupMask=FN_GROUP_2; else if (functionNumber<=8) groupMask=FN_GROUP_2;

8
DCC.h
View File

@ -76,10 +76,10 @@ public:
static void writeCVByteMain(int cab, int cv, byte bValue); static void writeCVByteMain(int cab, int cv, byte bValue);
static void writeCVBitMain(int cab, int cv, byte bNum, bool bValue); static void writeCVBitMain(int cab, int cv, byte bNum, bool bValue);
static void setFunction(int cab, byte fByte, byte eByte); static void setFunction(int cab, byte fByte, byte eByte);
static void setFn(int cab, byte functionNumber, bool on); static void setFn(int cab, int16_t functionNumber, bool on);
static int changeFn(int cab, byte functionNumber, bool pressed); static int changeFn(int cab, int16_t functionNumber, bool pressed);
static int getFn(int cab, byte functionNumber); static int getFn(int cab, int16_t functionNumber);
static void updateGroupflags(byte &flags, int functionNumber); static void updateGroupflags(byte &flags, int16_t functionNumber);
static void setAccessory(int aAdd, byte aNum, bool activate); static void setAccessory(int aAdd, byte aNum, bool activate);
static bool writeTextPacket(byte *b, int nBytes); static bool writeTextPacket(byte *b, int nBytes);
static void setProgTrackSyncMain(bool on); // when true, prog track becomes driveable static void setProgTrackSyncMain(bool on); // when true, prog track becomes driveable

View File

@ -3,8 +3,9 @@
#include "StringFormatter.h" #include "StringFormatter.h"
#define VERSION "3.0.12" #define VERSION "3.0.13"
// 3.0.12 fix esp8266 test for new firmware // 3.0.13 Functions>127 fix
// 3.0.12 Fix HOSTNAME function for STA mode for WiFi
// 3.0.11 ? // 3.0.11 ?
// 3.0.10 Teensy Support // 3.0.10 Teensy Support
// 3.0.9 rearranges serial newlines for the benefit of JMRI. // 3.0.9 rearranges serial newlines for the benefit of JMRI.