diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index 45e8a73..f8dd9d4 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -85,6 +85,7 @@ const int16_t HASH_KEYWORD_A='A'; const int16_t HASH_KEYWORD_C='C'; const int16_t HASH_KEYWORD_G='G'; const int16_t HASH_KEYWORD_I='I'; +const int16_t HASH_KEYWORD_O='O'; const int16_t HASH_KEYWORD_R='R'; const int16_t HASH_KEYWORD_T='T'; const int16_t HASH_KEYWORD_X='X'; @@ -691,6 +692,29 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream) } StringFormatter::send(stream, F(">\n")); return; + case HASH_KEYWORD_O: // + for ( Turntable * tto=Turntable::first(); tto; tto=tto->next()) { + if (tto->isHidden()) continue; + StringFormatter::send(stream, F(" %d"),tto->getId()); + } + } else { // + Turntable *tto=Turntable::get(id); + if (!tto || tto->isHidden()) { + StringFormatter::send(stream, F(" %d X"), id); + } else { + uint8_t pos = tto->getPosition(); + const FSH *todesc = NULL; +#ifdef EXRAIL_ACTIVE + // todesc = RMFT2::getTurntableDescription(id); +#endif + if (todesc == NULL) todesc = F(""); + StringFormatter::send(stream, F(" %d %d"), id, pos); + } + } + StringFormatter::send(stream, F(">\n")); + return; default: break; } // switch(p[1]) break; // case J @@ -1075,7 +1099,7 @@ bool DCCEXParser::parseI(Print *stream, int16_t params, int16_t p[]) for (uint8_t i = params - 4; i > 0; i--) { tto->addPosition(p[i + 3]); } - tto->addPosition(0); // Need to add position 0 as 0 so positions start at 1 + tto->addPosition(p[3]); // Allow setting a value for the home angle for throttles to draw it } else if (params > 3 && params < 39 && p[1] == HASH_KEYWORD_DCC) { DIAG(F("Create DCC turntable %d at base address %d with %d positions"), p[0], p[2], params - 2); } else { diff --git a/Turntables.cpp b/Turntables.cpp index ec31a00..5332aa5 100644 --- a/Turntables.cpp +++ b/Turntables.cpp @@ -152,8 +152,8 @@ EXTTTurntable::EXTTTurntable(uint16_t id, VPIN vpin, uint8_t i2caddress) : bool EXTTTurntable::setPositionInternal(uint8_t position, uint8_t activity) { #ifndef IO_NO_HAL DIAG(F("Set EXTT %d to position %d with activity %d"), _exttTurntableData.vpin, position, activity); - // Get position value from position list - int16_t value = getPositionValue(position); + if (position == 0) return false; // Position 0 is just so throttles know where home is + int16_t value = getPositionValue(position); // Get position value from position list if (!value) return false; // Return false if it's not a valid position // Set position via device driver EXTurntable::writeAnalogue(_exttTurntableData.vpin, value, activity);