mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-24 05:11:24 +01:00
Update add position
This commit is contained in:
parent
152f9850bb
commit
6adff43f4b
@ -1094,7 +1094,7 @@ bool DCCEXParser::parseI(Print *stream, int16_t params, int16_t p[])
|
||||
if (tto) return false;
|
||||
if (!DCCTurntable::create(p[0])) return false;
|
||||
Turntable *tto = Turntable::get(p[0]);
|
||||
tto->addPosition(0);
|
||||
tto->addPosition(0, 0);
|
||||
} else { // Otherwise move a DCC turntable
|
||||
if (tto && !tto->isEXTT()) {
|
||||
if (!tto->setPosition(p[0], p[1])) return false;
|
||||
@ -1105,27 +1105,27 @@ bool DCCEXParser::parseI(Print *stream, int16_t params, int16_t p[])
|
||||
}
|
||||
return true;
|
||||
|
||||
case 3: // <I id ADD value> | <I id position activity>
|
||||
case 3: // <I id position activity> rotate to position for EX-Turntable
|
||||
{
|
||||
Turntable *tto = Turntable::get(p[0]);
|
||||
if (!tto) return false;
|
||||
if (p[1] == HASH_KEYWORD_ADD) { // Add position value to turntable
|
||||
tto->addPosition(p[2]);
|
||||
StringFormatter::send(stream, F("<i>\n"));
|
||||
} else { // <I id position activity> rotate to position for EX-Turntable
|
||||
if (!tto->isEXTT()) return false;
|
||||
if (!tto->setPosition(p[0], p[1], p[2])) return false;
|
||||
}
|
||||
if (!tto->isEXTT()) return false;
|
||||
if (!tto->setPosition(p[0], p[1], p[2])) return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
case 4: // <I id EXTT vpin home> create an EXTT turntable
|
||||
case 4: // <I id EXTT vpin home> | <I id ADD position value> create an EXTT turntable or add position
|
||||
{
|
||||
Turntable *tto = Turntable::get(p[0]);
|
||||
if (p[1] == HASH_KEYWORD_EXTT) {
|
||||
if (Turntable::get(p[0])) return false;
|
||||
if (tto) return false;
|
||||
if (!EXTTTurntable::create(p[0], (VPIN)p[2])) return false;
|
||||
Turntable *tto = Turntable::get(p[0]);
|
||||
tto->addPosition(p[3]);
|
||||
tto->addPosition(0, p[3]);
|
||||
} else if (p[1] == HASH_KEYWORD_ADD) {
|
||||
if (!tto) return false;
|
||||
tto->addPosition(p[2], p[3]);
|
||||
StringFormatter::send(stream, F("<i>\n"));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ LookList* RMFT2::LookListLoader(OPCODE op1, OPCODE op2, OPCODE op3) {
|
||||
VPIN id=operand;
|
||||
setTurntableHiddenState(DCCTurntable::create(id));
|
||||
Turntable *tto=Turntable::get(id);
|
||||
tto->addPosition(0);
|
||||
tto->addPosition(0,0);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -257,15 +257,16 @@ LookList* RMFT2::LookListLoader(OPCODE op1, OPCODE op2, OPCODE op3) {
|
||||
int home=getOperand(progCounter,2);
|
||||
setTurntableHiddenState(EXTTTurntable::create(id,pin));
|
||||
Turntable *tto=Turntable::get(id);
|
||||
tto->addPosition(home);
|
||||
tto->addPosition(0,home);
|
||||
break;
|
||||
}
|
||||
|
||||
case OPCODE_TTADDPOSITION: {
|
||||
VPIN id=operand;
|
||||
int value=getOperand(progCounter,1);
|
||||
int position=getOperand(progCounter,1);
|
||||
int value=getOperand(progCounter,2);
|
||||
Turntable *tto=Turntable::get(id);
|
||||
tto->addPosition(value);
|
||||
tto->addPosition(position,value);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
@ -273,7 +273,7 @@
|
||||
#define START(route)
|
||||
#define STOP
|
||||
#define THROW(id)
|
||||
#define TT_ADDPOSITION(turntable_id,value,description)
|
||||
#define TT_ADDPOSITION(turntable_id,position,value,description)
|
||||
#define TURNOUT(id,addr,subaddr,description...)
|
||||
#define TURNOUTL(id,addr,description...)
|
||||
#define UNJOIN
|
||||
|
@ -406,7 +406,7 @@ const HIGHFLASH int16_t RMFT2::SignalDefinitions[] = {
|
||||
#define STOP OPCODE_SPEED,V(0),
|
||||
#define THROW(id) OPCODE_THROW,V(id),
|
||||
#ifndef IO_NO_HAL
|
||||
#define TT_ADDPOSITION(id,value,description...) OPCODE_TTADDPOSITION,V(id),OPCODE_PAD,V(value),
|
||||
#define TT_ADDPOSITION(id,position,value,description...) OPCODE_TTADDPOSITION,V(id),OPCODE_PAD,V(position),OPCODE_PAD,V(value),
|
||||
#endif
|
||||
#define TURNOUT(id,addr,subaddr,description...) OPCODE_TURNOUT,V(id),OPCODE_PAD,V(addr),OPCODE_PAD,V(subaddr),
|
||||
#define TURNOUTL(id,addr,description...) TURNOUT(id,(addr-1)/4+1,(addr-1)%4, description)
|
||||
|
@ -58,8 +58,8 @@ void Turntable::add(Turntable *tto) {
|
||||
}
|
||||
|
||||
// Add a position
|
||||
void Turntable::addPosition(uint16_t value) {
|
||||
_turntablePositions.insert(value);
|
||||
void Turntable::addPosition(uint8_t idx, uint16_t value) {
|
||||
_turntablePositions.insert(idx, value);
|
||||
}
|
||||
|
||||
// Get value for position
|
||||
|
@ -53,10 +53,10 @@ struct TurntablePosition {
|
||||
|
||||
class TurntablePositionList {
|
||||
public:
|
||||
TurntablePositionList() : head(nullptr), currentIndex(0) {}
|
||||
TurntablePositionList() : head(nullptr) {}
|
||||
|
||||
void insert(uint16_t value) {
|
||||
TurntablePosition* newPosition = new TurntablePosition(currentIndex++, value);
|
||||
void insert(uint8_t idx, uint16_t value) {
|
||||
TurntablePosition* newPosition = new TurntablePosition(idx, value);
|
||||
if(!head) {
|
||||
head = newPosition;
|
||||
} else {
|
||||
@ -71,7 +71,6 @@ public:
|
||||
|
||||
private:
|
||||
TurntablePosition* head;
|
||||
uint8_t currentIndex;
|
||||
|
||||
};
|
||||
|
||||
@ -159,7 +158,7 @@ public:
|
||||
inline uint16_t getId() { return _turntableData.id; }
|
||||
inline Turntable *next() { return _nextTurntable; }
|
||||
void printState(Print *stream);
|
||||
void addPosition(uint16_t value);
|
||||
void addPosition(uint8_t idx, uint16_t value);
|
||||
uint16_t getPositionValue(uint8_t position);
|
||||
uint8_t getPositionCount();
|
||||
bool isMoving() { return _isMoving; }
|
||||
|
Loading…
Reference in New Issue
Block a user