Fixed FRCSim artf2609 - double ports handled wrong.

Change-Id: I2dc59c8d3113f3024d237763eb4e2f94bb85ff1a
This commit is contained in:
Colby Skeggs
2014-07-03 11:56:19 -07:00
parent 65c3c0ba09
commit 55fde6b616
4 changed files with 24 additions and 8 deletions

View File

@@ -24,7 +24,6 @@ void Encoder::InitEncoder(int channelA, int channelB, bool reverseDirection, Enc
m_table = NULL;
this->channelA = channelA;
this->channelB = channelB;
reversed = reverseDirection;
m_encodingType = encodingType;
int32_t index = 0;
@@ -37,6 +36,9 @@ void Encoder::InitEncoder(int channelA, int channelB, bool reverseDirection, Enc
int channel = channelB;
channelB = channelA;
channelA = channel;
m_reverseDirection = !reverseDirection;
} else {
m_reverseDirection = reverseDirection;
}
char buffer[50];
int n = sprintf(buffer, "dio/1/%d/1/%d", channelA, channelB);
@@ -288,7 +290,11 @@ void Encoder::SetMinRate(double minRate)
*/
void Encoder::SetDistancePerPulse(double distancePerPulse)
{
m_distancePerPulse = distancePerPulse;
if (m_reverseDirection) {
m_distancePerPulse = -distancePerPulse;
} else {
m_distancePerPulse = distancePerPulse;
}
}
/**
@@ -334,7 +340,7 @@ void Encoder::UpdateTable() {
if (m_table != NULL) {
m_table->PutNumber("Speed", GetRate());
m_table->PutNumber("Distance", GetDistance());
m_table->PutNumber("Distance per Tick", m_distancePerPulse);
m_table->PutNumber("Distance per Tick", m_reverseDirection ? -m_distancePerPulse : m_distancePerPulse);
}
}