1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-30 03:26:13 +01:00

Correct order

This commit is contained in:
peteGSX 2023-08-26 19:41:17 +10:00
parent b823a647ac
commit 1425da20b5
4 changed files with 13 additions and 11 deletions

View File

@ -1060,11 +1060,12 @@ bool DCCEXParser::parseI(Print *stream, int16_t params, int16_t p[])
default: // If we're here, it must be creating a turntable object default: // If we're here, it must be creating a turntable object
{ {
DIAG(F("Params: %d"), params);
if (params > 5 && params < 41 && p[1] == HASH_KEYWORD_EXTT) { if (params > 5 && params < 41 && p[1] == HASH_KEYWORD_EXTT) {
DIAG(F("Create EXTT turntable %d on vpin %d and address %d with %d positions"), p[0], p[2], p[3], params - 4); DIAG(F("Create EXTT turntable %d on vpin %d and address %d with %d positions"), p[0], p[2], p[3], params - 4);
if (!EXTTTurntable::create(p[0], (uint8_t)p[1], (VPIN)p[2])) return false; if (!EXTTTurntable::create(p[0], (VPIN)p[2], (uint8_t)p[3])) return false;
Turntable *tto = Turntable::get(p[0]); Turntable *tto = Turntable::get(p[0]);
for ( uint8_t i = 0; i < params - 4; i++) { for ( uint8_t i = params - 4; i > 0; i--) {
tto->addPosition(p[i + 3]); tto->addPosition(p[i + 3]);
DIAG(F("Add position %d"), p[i + 3]); DIAG(F("Add position %d"), p[i + 3]);
} }

View File

@ -100,6 +100,7 @@ int EXTurntable::_read(VPIN vpin) {
// Acc_Off = 9 // Turn accessory pin off // Acc_Off = 9 // Turn accessory pin off
void EXTurntable::_writeAnalogue(VPIN vpin, int value, uint8_t activity, uint16_t duration) { void EXTurntable::_writeAnalogue(VPIN vpin, int value, uint8_t activity, uint16_t duration) {
if (_deviceState == DEVSTATE_FAILED) return; if (_deviceState == DEVSTATE_FAILED) return;
if (value < 0) return;
uint8_t stepsMSB = value >> 8; uint8_t stepsMSB = value >> 8;
uint8_t stepsLSB = value & 0xFF; uint8_t stepsLSB = value & 0xFF;
#ifdef DIAG_IO #ifdef DIAG_IO

View File

@ -126,26 +126,26 @@ bool Turntable::setPosition(uint16_t id, uint8_t position, uint8_t activity) {
* *
*************************************************************************************/ *************************************************************************************/
// Private constructor // Private constructor
EXTTTurntable::EXTTTurntable(uint16_t id, uint8_t i2caddress, VPIN vpin) : EXTTTurntable::EXTTTurntable(uint16_t id, VPIN vpin, uint8_t i2caddress) :
Turntable(id, TURNTABLE_EXTT) Turntable(id, TURNTABLE_EXTT)
{ {
_exttTurntableData.i2caddress = i2caddress;
_exttTurntableData.vpin = vpin; _exttTurntableData.vpin = vpin;
_exttTurntableData.i2caddress = i2caddress;
} }
// Create function // Create function
Turntable *EXTTTurntable::create(uint16_t id, uint8_t i2caddress, VPIN vpin) { Turntable *EXTTTurntable::create(uint16_t id, VPIN vpin, uint8_t i2caddress) {
#ifndef IO_NO_HAL #ifndef IO_NO_HAL
Turntable *tto = get(id); Turntable *tto = get(id);
if (tto) { if (tto) {
if (tto->isType(TURNTABLE_EXTT)) { if (tto->isType(TURNTABLE_EXTT)) {
EXTTTurntable *extt = (EXTTTurntable *)tto; EXTTTurntable *extt = (EXTTTurntable *)tto;
extt->_exttTurntableData.i2caddress = i2caddress;
extt->_exttTurntableData.vpin = vpin; extt->_exttTurntableData.vpin = vpin;
extt->_exttTurntableData.i2caddress = i2caddress;
return tto; return tto;
} }
} }
tto = (Turntable *)new EXTTTurntable(id, i2caddress, vpin); tto = (Turntable *)new EXTTTurntable(id, vpin, i2caddress);
DIAG(F("Turntable 0x%x"), tto); DIAG(F("Turntable 0x%x"), tto);
return tto; return tto;
#else #else
@ -157,7 +157,7 @@ EXTTTurntable::EXTTTurntable(uint16_t id, uint8_t i2caddress, VPIN vpin) :
} }
void EXTTTurntable::print(Print *stream) { void EXTTTurntable::print(Print *stream) {
StringFormatter::send(stream, F("<i %d EXTURNTABLE %d %d>\n"), _turntableData.id, _exttTurntableData.i2caddress, _exttTurntableData.vpin); StringFormatter::send(stream, F("<i %d EXTURNTABLE %d %d>\n"), _turntableData.id, _exttTurntableData.vpin, _exttTurntableData.i2caddress);
} }
// EX-Turntable specific code for moving to the specified position // EX-Turntable specific code for moving to the specified position

View File

@ -183,16 +183,16 @@ class EXTTTurntable : public Turntable {
private: private:
// EXTTTurntableData contains device specific data // EXTTTurntableData contains device specific data
struct EXTTTurntableData { struct EXTTTurntableData {
uint8_t i2caddress;
VPIN vpin; VPIN vpin;
uint8_t i2caddress;
} _exttTurntableData; } _exttTurntableData;
// Constructor // Constructor
EXTTTurntable(uint16_t id, uint8_t i2caddress, VPIN vpin); EXTTTurntable(uint16_t id, VPIN vpin, uint8_t i2caddress);
public: public:
// Create function // Create function
static Turntable *create(uint16_t id, uint8_t i2caddress, VPIN vpin); static Turntable *create(uint16_t id, VPIN vpin, uint8_t i2caddress);
void print(Print *stream) override; void print(Print *stream) override;
protected: protected: