1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2025-07-28 18:03:45 +02:00

clean up getThrottleSpeed functions

This commit is contained in:
Harald Barth
2022-06-05 23:07:03 +02:00
parent 06e7ad5c53
commit 016bc37b53
5 changed files with 25 additions and 15 deletions

15
DCC.cpp
View File

@@ -137,12 +137,25 @@ void DCC::setFunctionInternal(int cab, byte byte1, byte byte2) {
DCCWaveform::mainTrack.schedulePacket(b, nB, 0);
}
uint8_t DCC::getThrottleSpeed(int cab) {
// returns speed steps 0 to 127 (1 == emergency stop)
// or -1 on "loco not found"
int8_t DCC::getThrottleSpeed(int cab) {
int reg=lookupSpeedTable(cab);
if (reg<0) return -1;
return speedTable[reg].speedCode & 0x7F;
}
// returns speed code byte
// or 128 (speed 0, dir forward) on "loco not found".
uint8_t DCC::getThrottleSpeedByte(int cab) {
int reg=lookupSpeedTable(cab);
if (reg<0)
return 128;
return speedTable[reg].speedCode;
}
// returns direction on loco
// or true/forward on "loco not found"
bool DCC::getThrottleDirection(int cab) {
int reg=lookupSpeedTable(cab);
if (reg<0) return true;