1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-24 16:46:13 +01:00

Compare commits

...

2 Commits

Author SHA1 Message Date
peteGSX
7a305e179c
Merge pull request #353 from DCC-EX:turntable-fix
Updated broadcasts
2023-09-15 06:32:30 +10:00
peteGSX
8437b0e7aa Updated broadcasts 2023-09-15 06:26:29 +10:00
4 changed files with 16 additions and 10 deletions

View File

@ -812,13 +812,12 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
const FSH *tpdesc = NULL; const FSH *tpdesc = NULL;
for (uint8_t p = 0; p < posCount; p++) { for (uint8_t p = 0; p < posCount; p++) {
StringFormatter::send(stream, F("<jP")); StringFormatter::send(stream, F("<jP"));
int16_t value = tto->getPositionValue(p);
int16_t angle = tto->getPositionAngle(p); int16_t angle = tto->getPositionAngle(p);
#ifdef EXRAIL_ACTIVE #ifdef EXRAIL_ACTIVE
tpdesc = RMFT2::getTurntablePositionDescription(id, p); tpdesc = RMFT2::getTurntablePositionDescription(id, p);
#endif #endif
if (tpdesc == NULL) tpdesc = F(""); if (tpdesc == NULL) tpdesc = F("");
StringFormatter::send(stream, F(" %d %d %d %d \"%S\""), id, p, value, angle, tpdesc); StringFormatter::send(stream, F(" %d %d %d \"%S\""), id, p, angle, tpdesc);
StringFormatter::send(stream, F(">\n")); StringFormatter::send(stream, F(">\n"));
} }
} }

View File

@ -409,11 +409,12 @@ private:
void _begin() override; void _begin() override;
void _loop(unsigned long currentMicros) override; void _loop(unsigned long currentMicros) override;
int _read(VPIN vpin) override; int _read(VPIN vpin) override;
void _broadcastStatus (VPIN vpin, uint8_t status); void _broadcastStatus (VPIN vpin, uint8_t status, uint8_t activity);
void _writeAnalogue(VPIN vpin, int value, uint8_t activity, uint16_t duration) override; void _writeAnalogue(VPIN vpin, int value, uint8_t activity, uint16_t duration) override;
void _display() override; void _display() override;
uint8_t _stepperStatus; uint8_t _stepperStatus;
uint8_t _previousStatus; uint8_t _previousStatus;
uint8_t _currentActivity;
}; };
#endif #endif

View File

@ -72,7 +72,9 @@ void EXTurntable::_loop(unsigned long currentMicros) {
I2CManager.read(_I2CAddress, readBuffer, 1); I2CManager.read(_I2CAddress, readBuffer, 1);
_stepperStatus = readBuffer[0]; _stepperStatus = readBuffer[0];
if (_stepperStatus != _previousStatus && _stepperStatus == 0) { // Broadcast when a rotation finishes if (_stepperStatus != _previousStatus && _stepperStatus == 0) { // Broadcast when a rotation finishes
_broadcastStatus(_firstVpin, _stepperStatus); if ( _currentActivity < 4) {
_broadcastStatus(_firstVpin, _stepperStatus, _currentActivity);
}
_previousStatus = _stepperStatus; _previousStatus = _stepperStatus;
} }
delayUntil(currentMicros + 100000); // Wait 100ms before checking again delayUntil(currentMicros + 100000); // Wait 100ms before checking again
@ -90,11 +92,13 @@ int EXTurntable::_read(VPIN vpin) {
} }
// If a status change has occurred for a turntable object, broadcast it // If a status change has occurred for a turntable object, broadcast it
void EXTurntable::_broadcastStatus (VPIN vpin, uint8_t status) { void EXTurntable::_broadcastStatus (VPIN vpin, uint8_t status, uint8_t activity) {
Turntable *tto = Turntable::getByVpin(vpin); Turntable *tto = Turntable::getByVpin(vpin);
if (tto) { if (tto) {
tto->setMoving(status); if (activity < 4) {
CommandDistributor::broadcastTurntable(tto->getId(), tto->getPosition(), status); tto->setMoving(status);
CommandDistributor::broadcastTurntable(tto->getId(), tto->getPosition(), status);
}
} }
} }
@ -124,9 +128,10 @@ void EXTurntable::_writeAnalogue(VPIN vpin, int value, uint8_t activity, uint16_
DIAG(F("I2CManager write I2C Address:%d stepsMSB:%d stepsLSB:%d activity:%d"), DIAG(F("I2CManager write I2C Address:%d stepsMSB:%d stepsLSB:%d activity:%d"),
_I2CAddress.toString(), stepsMSB, stepsLSB, activity); _I2CAddress.toString(), stepsMSB, stepsLSB, activity);
#endif #endif
_stepperStatus = 1; // Tell the device driver Turntable-EX is busy if (activity < 4) _stepperStatus = 1; // Tell the device driver Turntable-EX is busy
_previousStatus = _stepperStatus; _previousStatus = _stepperStatus;
_broadcastStatus(vpin, _stepperStatus); // Broadcast when the rotation starts _currentActivity = activity;
_broadcastStatus(vpin, _stepperStatus, activity); // Broadcast when the rotation starts
I2CManager.write(_I2CAddress, 3, stepsMSB, stepsLSB, activity); I2CManager.write(_I2CAddress, 3, stepsMSB, stepsLSB, activity);
} }

View File

@ -3,7 +3,8 @@
#include "StringFormatter.h" #include "StringFormatter.h"
#define VERSION "5.1.6" #define VERSION "5.1.7"
// 5.1.7 - Fix turntable broadcasts for non-movement activities and <JP> result
// 5.1.6 - STM32F4xx native I2C driver added // 5.1.6 - STM32F4xx native I2C driver added
// 5.1.5 - Added turntable object and EXRAIL commands // 5.1.5 - Added turntable object and EXRAIL commands
// - <I ...>, <JO ...>, <JP ...> - turntable commands // - <I ...>, <JO ...>, <JP ...> - turntable commands