1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2025-04-21 12:31:19 +02:00

Compare commits

..

No commits in common. "d14aa46d51c546b8eb8d1d393c2be3ccbbd16eb4" and "58b180603ac351727e86fdbdc0d5ff3bac1929d9" have entirely different histories.

7 changed files with 24 additions and 26 deletions

1
.gitignore vendored
View File

@ -15,3 +15,4 @@ my*.h
compile_commands.json
newcode.txt.old
UserAddin.txt
platformio.ini

View File

@ -19,7 +19,7 @@
* along with CommandStation. If not, see <https://www.gnu.org/licenses/>.
*/
//sensorCAM parser.cpp version 3.06 Jan 2025
//sensorCAM parser.cpp version 3.05 Jan 2025
#include "DCCEXParser.h"
#include "CamParser.h"
#include "FSH.h"
@ -32,7 +32,7 @@ const int16_t ve =2899;
// the CamParser::addVpin() function.
// The CAMBaseVpin is the one to be used when commands are given without a vpin.
VPIN CamParser::CAMBaseVpin = 0; // no vpins yet known
VPIN CamParser::CAMVPINS[] = {0,0,0,0}; // determines max # CAM's
VPIN CamParser::CAMVPINS[] = {0,0,0,0}; // no vpins yet known
int CamParser::vpcount=sizeof(CAMVPINS)/sizeof(CAMVPINS[0]);
void CamParser::parse(Print * stream, byte & opcode, byte & paramCount, int16_t p[]) {
@ -42,8 +42,7 @@ void CamParser::parse(Print * stream, byte & opcode, byte & paramCount, int16_t
}
bool CamParser::parseN(Print * stream, byte paramCount, int16_t p[]) {
(void)stream; // probably unused parameter
if (CAMBaseVpin==0) CAMBaseVpin=CAMVPINS[0]; // default to CAM 1.
(void)stream; // probably unused parameter
VPIN vpin=CAMBaseVpin; //use current CAM selection
if (paramCount==0) {
@ -60,22 +59,21 @@ bool CamParser::parseN(Print * stream, byte paramCount, int16_t p[]) {
if(camop=='C'){
if(p[1]>=100) CAMBaseVpin=p[1];
if(p[1]<=vpcount && p[1]>0) CAMBaseVpin=CAMVPINS[p[1]-1];
if(p[1]<vpcount) CAMBaseVpin=CAMVPINS[p[1]];
DIAG(F("CAM base Vpin: %c %d "),p[0],CAMBaseVpin);
return true;
}
if (camop<100) { //switch CAM# if p[1] dictates
if(p[1]>=100 && p[1]<=(vpcount*100+99)) { //limits to CAM# 1 to 4 for now
vpin=CAMVPINS[p[1]/100-1];
if(p[1]>=100 && p[1]<(vpcount*100)) { //limits to CAM# 1 to 3 for now
vpin=CAMVPINS[p[1]/100];
CAMBaseVpin=vpin;
DIAG(F("switching to CAM %d baseVpin:%d"),p[1]/100,vpin);
p[1]=p[1]%100; //strip off CAM #
}
}
if (CAMBaseVpin==0) {DIAG(F("<n Error: Invalid CAM selected, default to CAM1>"));
return false; // cam not defined
}
if (CAMBaseVpin==0) return false; // no cam defined
// send UPPER case to sensorCAM to flag binary data from a DCCEX-CS parser
switch(paramCount) {
case 1: //<N ver> produces '^'
@ -91,13 +89,13 @@ bool CamParser::parseN(Print * stream, byte paramCount, int16_t p[]) {
break;
case 3: //<N vpin rowY colx > or <N cmd p1 p2>
camop=p[0];
if (p[0]>=100) { //vpin - i.e. NOT 'A' through 'Z'
if (p[1]>236 || p[1]<0) return false; //row
if (p[2]>316 || p[2]<0) return false; //column
camop=0x80; // special 'a' case for IO_SensorCAM
vpin = p[0];
}else if (STRCHR_P((const char *)F("IJMNT"),camop) == nullptr) return false;
camop=p[0];
param1 = p[1];
param3 = p[2];
break;

11
DCC.cpp
View File

@ -268,9 +268,14 @@ bool DCC::setFn( int cab, int16_t functionNumber, bool on) {
// Flip function state (used from withrottle protocol)
void DCC::changeFn( int cab, int16_t functionNumber) {
auto currentValue=getFn(cab,functionNumber);
if (currentValue<0) return; // function not valid for change
setFn(cab,functionNumber, currentValue?false:true);
if (cab<=0 || functionNumber>31) return;
auto slot=lookupSpeedTable(cab);
unsigned long funcmask = (1UL<<functionNumber);
slot->functions ^= funcmask;
if (functionNumber <= 28) {
updateGroupflags(slot->groupFlags, functionNumber);
}
CommandDistributor::broadcastLoco(slot);
}
// Report function state (used from withrottle protocol)

View File

@ -408,7 +408,7 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
) break;
// Honour the configuration option (config.h) which allows the <a> command to be reversed
// Because of earlier confusion we need to do the same thing under both defines
#if defined(DCC_ACCESSORY_COMMAND_REVERSE)
#if defined(DCC_ACCESSORY_COMMAND_REVERSE) || defined(DCC_ACCESSORY_RCN_213)
DCC::setAccessory(address, subaddress,p[activep]==0,onoff);
#else
DCC::setAccessory(address, subaddress,p[activep]==1,onoff);

View File

@ -379,7 +379,7 @@
// DCC++ Classic behaviour is that Throw writes a 1 in the packet,
// and Close writes a 0.
// RCN-213 specifies that Throw is 0 and Close is 1.
#ifndef DCC_TURNOUTS_RCN_213
#if defined(DCC_TURNOUTS_RCN_213)
close = !close;
#endif
DCC::setAccessory(_dccTurnoutData.address, _dccTurnoutData.subAddress, close);

View File

@ -269,8 +269,8 @@ The configuration file for DCC-EX Command Station
// over DCC++. This #define likewise inverts the behaviour of the <a> command
// for triggering DCC Accessory Decoders, so that <a addr subaddr 0> generates a
// DCC packet with D=1 (close turnout) and <a addr subaddr 1> generates D=0
// (throw turnout).
//#define DCC_ACCESSORY_COMMAND_REVERSE
// (throw turnout). This is the same as DCC_ACCESSORY_COMMAND_REVERSE
//#define DCC_ACCESSORY_RCN_213
// HANDLING MULTIPLE SERIAL THROTTLES

View File

@ -3,10 +3,7 @@
#include "StringFormatter.h"
#define VERSION "5.5.11"
// 5.5.11 - (5.4.2) accessory command reverse
// 5.5.10 - CamParser fix
// 5.5.9 - (5.4.3) fix changeFn for functions 29..31
#define VERSION "5.5.8"
// 5.5.8 - EXSensorCam clean up to match other filters and
// - avoid need for config.h settings
// - Test: IO_I2CDFPlayer.h inserted 10mS deleay in Init_SC16IS752() just after soft-reset for board with 1.8432 Mhz xtal
@ -26,9 +23,6 @@
// 5.5.2 - DS1307 Real Time clock
// 5.5.1 - Momentum
// 5.5.0 - New version on devel
// 5.4.3 - bugfix changeFn for functions 29..31
// 5.4.2 - Reversed turnout bugfix
// 5.4.1 - ESP32 bugfix packet buffer race
// 5.4.0 - New version on master
// 5.2.96 - EXRAIL additions XFWD() and XREV()
// 5.2.95 - Release candidate for 5.4