diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index 7473c26..2014762 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -1087,7 +1087,7 @@ bool DCCEXParser::parseI(Print *stream, int16_t params, int16_t p[]) } return true; - case 2: // - rotate to position for DCC turntables + case 2: // | - rotate or create DCC turntable { Turntable *tto = Turntable::get(p[0]); if (p[1] == HASH_KEYWORD_DCC) { // Create a DCC turntable @@ -1096,7 +1096,7 @@ bool DCCEXParser::parseI(Print *stream, int16_t params, int16_t p[]) Turntable *tto = Turntable::get(p[0]); tto->addPosition(0); } else { // Otherwise move a DCC turntable - if (tto) { + if (tto && !tto->isEXTT()) { if (!tto->setPosition(p[0], p[1])) return false; } else { return false; @@ -1105,14 +1105,15 @@ bool DCCEXParser::parseI(Print *stream, int16_t params, int16_t p[]) } return true; - case 3: + case 3: // | { Turntable *tto = Turntable::get(p[0]); if (!tto) return false; - if (p[1] == HASH_KEYWORD_ADD) { // add position value to turntable + if (p[1] == HASH_KEYWORD_ADD) { // Add position value to turntable tto->addPosition(p[2]); StringFormatter::send(stream, F("\n")); } else { // rotate to position for EX-Turntable + if (!tto->isEXTT()) return false; if (!tto->setPosition(p[0], p[1], p[2])) return false; } } diff --git a/Turntables.cpp b/Turntables.cpp index f7b2a46..f96a3a8 100644 --- a/Turntables.cpp +++ b/Turntables.cpp @@ -140,8 +140,8 @@ bool Turntable::setPosition(uint16_t id, uint8_t position, uint8_t activity) { if (ok) { // Broadcast a position change only if non zero has been set, or home/calibration sent - tto->_previousPosition = tto->getPosition(); if (position > 0 || (position == 0 && (activity == 2 || activity == 3))) { + tto->_previousPosition = tto->getPosition(); tto->_turntableData.position = position; if (tto->isEXTT()) { tto->setPositionStateOnly(id, position, 1); @@ -179,6 +179,7 @@ using DevState = IODevice::DeviceStateEnum; } if (!IODevice::exists(vpin)) return nullptr; if (IODevice::getStatus(vpin) == DevState::DEVSTATE_FAILED) return nullptr; + if (Turntable::getByVpin(vpin)) return nullptr; tto = (Turntable *)new EXTTTurntable(id, vpin); DIAG(F("Turntable 0x%x size %d size %d"), tto, sizeof(Turntable), sizeof(struct TurntableData)); return tto;