mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-24 05:11:24 +01:00
Capture progress
This commit is contained in:
parent
004d10ee58
commit
1e48c59cd8
@ -71,14 +71,11 @@ void EXTurntable::_loop(unsigned long currentMicros) {
|
||||
uint8_t readBuffer[1];
|
||||
I2CManager.read(_I2CAddress, readBuffer, 1);
|
||||
_stepperStatus = readBuffer[0];
|
||||
if (_stepperStatus < 2) {
|
||||
if (_stepperStatus != _previousStatus) {
|
||||
_broadcastStatus(_firstVpin, _stepperStatus);
|
||||
_previousStatus = _stepperStatus;
|
||||
}
|
||||
if (_stepperStatus != _previousStatus && _stepperStatus == 0) { // Broadcast when a rotation finishes
|
||||
_broadcastStatus(_firstVpin, _stepperStatus);
|
||||
_previousStatus = _stepperStatus;
|
||||
}
|
||||
// DIAG(F("Turntable-EX returned status: %d"), _stepperStatus);
|
||||
delayUntil(currentMicros + 500000); // Wait 500ms before checking again, turntables turn slowly
|
||||
delayUntil(currentMicros + 100000); // Wait 100ms before checking again
|
||||
}
|
||||
|
||||
// Read returns status as obtained in our loop.
|
||||
@ -128,6 +125,7 @@ void EXTurntable::_writeAnalogue(VPIN vpin, int value, uint8_t activity, uint16_
|
||||
_I2CAddress.toString(), stepsMSB, stepsLSB, activity);
|
||||
#endif
|
||||
_stepperStatus = 1; // Tell the device driver Turntable-EX is busy
|
||||
_broadcastStatus(vpin, _stepperStatus); // Broadcast when the rotation starts
|
||||
I2CManager.write(_I2CAddress, 3, stepsMSB, stepsLSB, activity);
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,9 @@ bool Turntable::setPositionStateOnly(uint16_t id, uint8_t position, bool moving)
|
||||
// Only need to broadcast from here if it's a DCC type, device driver broadcasts EXTT
|
||||
if (!tto->isEXTT()) { CommandDistributor::broadcastTurntable(id, position, moving); }
|
||||
#if defined(EXRAIL_ACTIVE)
|
||||
// RMFT2::turntableEvent(id, position);
|
||||
bool rotated = false;
|
||||
if (position != tto->_previousPosition) rotated = true;
|
||||
if (!tto->isEXTT()) { RMFT2::rotateEvent(id, rotated); }
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
@ -138,6 +140,7 @@ 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->_turntableData.position = position;
|
||||
if (tto->isEXTT()) {
|
||||
|
@ -105,6 +105,9 @@ protected:
|
||||
|
||||
// Linked list for positions
|
||||
TurntablePositionList _turntablePositions;
|
||||
|
||||
// Store the previous position to allow checking for changes
|
||||
uint8_t _previousPosition = 0;
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
|
Loading…
Reference in New Issue
Block a user