Skip to content

Commit

Permalink
Add support for forcing a function
Browse files Browse the repository at this point in the history
  • Loading branch information
flash62au committed Sep 19, 2024
1 parent 63f9a70 commit 002e01f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=WiThrottleProtocol
version=1.1.23
version=1.1.24
author=Peter Akers <[email protected]>, David Zuhn <[email protected]>, Luca Dentella <[email protected]>
maintainer=Peter Akers <[email protected]>
sentence=JMRI WiThrottle Protocol implementation for ESP32
Expand Down
14 changes: 11 additions & 3 deletions src/WiThrottleProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1533,14 +1533,18 @@ void WiThrottleProtocol::emergencyStop(char multiThrottle, String address) {
// ******************************************************************************************************

void WiThrottleProtocol::setFunction(int funcNum, bool pressed) {
setFunction(DEFAULT_MULTITHROTTLE, funcNum, pressed);
setFunction(DEFAULT_MULTITHROTTLE, "", funcNum, pressed, false);
}

void WiThrottleProtocol::setFunction(char multiThrottle, int funcNum, bool pressed) {
setFunction(multiThrottle, "", funcNum, pressed) ;
setFunction(multiThrottle, "", funcNum, pressed, false) ;
}

void WiThrottleProtocol::setFunction(char multiThrottle, String address, int funcNum, bool pressed) {
setFunction(multiThrottle, address, funcNum, pressed, false) ;
}

void WiThrottleProtocol::setFunction(char multiThrottle, String address, int funcNum, bool pressed, bool force) {
if (logLevel>0) { console->print("WiT:: setFunction(): "); console->print(multiThrottle); console->print(" : "); console->println(funcNum); }

int multiThrottleIndex = getMultiThrottleIndex(multiThrottle);
Expand All @@ -1561,7 +1565,11 @@ void WiThrottleProtocol::setFunction(char multiThrottle, String address, int fun
}

cmd.concat(PROPERTY_SEPARATOR);
cmd.concat("F");
if (!force) {
cmd.concat("F");
} else {
cmd.concat("f");
}

if (pressed) {
cmd += "1";
Expand Down
9 changes: 9 additions & 0 deletions src/WiThrottleProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
/*
Version information:
1.1.24 - Add support for forcing a function
1.1.23 - Fix for individual loco direction (facing) changes in a consist
1.1.22 - Fix for the original 'steal' code
1.1.21 - Add support for setting the Speed Step mode 28/128/14 etc. setSpeedSteps(), getSpeedSteps()
Expand Down Expand Up @@ -486,6 +487,14 @@ class WiThrottleProtocol
/// @param pressed TBA
void setFunction(char multiThrottle, String address, int funcnum, bool pressed);

/// @brief Set a Function on a specified Loco only, on a specified Throttle
/// @param multiThrottle Which Throttle. Supported multiThrottle codes are 'T' '0' '1' '2' '3' '4' '5' only.
/// @param address DCC Address of the loco to set
/// @param funcnum Function Number
/// @param pressed TBA
/// @param force TBA
void setFunction(char multiThrottle, String address, int funcnum, bool pressed, bool force);

/// @brief Set the speed of the default (first) Throttle
/// @param speed Speed 0-126
bool setSpeed(int speed);
Expand Down

0 comments on commit 002e01f

Please sign in to comment.