mirror of https://github.com/EspoTek/Labrador.git
Changed jitter compensation to occur every character. Smooth as butter, even at 115200. :)
This commit is contained in:
parent
9908cd2c43
commit
5320d6abf7
Binary file not shown.
|
@ -237,6 +237,7 @@ void isoBuffer::serialDecode(double baudRate)
|
||||||
//qDebug() << "uart_bit = " << uart_bit;
|
//qDebug() << "uart_bit = " << uart_bit;
|
||||||
} else{
|
} else{
|
||||||
uartTransmitting = (uart_bit==1) ? false : true;
|
uartTransmitting = (uart_bit==1) ? false : true;
|
||||||
|
jitterCompensationNeeded = true;
|
||||||
//if(uartTransmitting) qDebug() << "Decoding symbol!";
|
//if(uartTransmitting) qDebug() << "Decoding symbol!";
|
||||||
}
|
}
|
||||||
//Update the pointer, accounting for jitter
|
//Update the pointer, accounting for jitter
|
||||||
|
@ -244,7 +245,6 @@ void isoBuffer::serialDecode(double baudRate)
|
||||||
//Calculate stopping condition
|
//Calculate stopping condition
|
||||||
dist_seconds = (double)serialDistance()/sampleRate_bit;
|
dist_seconds = (double)serialDistance()/sampleRate_bit;
|
||||||
}
|
}
|
||||||
jitterCompensationNeeded = true;
|
|
||||||
//qDebug() << "\n\n\n\n\n";
|
//qDebug() << "\n\n\n\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,13 +261,13 @@ void isoBuffer::updateSerialPtr(double baudRate, unsigned char current_bit)
|
||||||
{
|
{
|
||||||
if(jitterCompensationNeeded && uartTransmitting){
|
if(jitterCompensationNeeded && uartTransmitting){
|
||||||
jitterCompensationNeeded = jitterCompensationProcedure(baudRate, current_bit);
|
jitterCompensationNeeded = jitterCompensationProcedure(baudRate, current_bit);
|
||||||
qDebug() << "JitterCompensation Needed?" << jitterCompensationNeeded;
|
//qDebug() << "JitterCompensation Needed?" << jitterCompensationNeeded;
|
||||||
}
|
}
|
||||||
|
|
||||||
int distance_between_bits = sampleRate_bit/baudRate;
|
int distance_between_bits = sampleRate_bit/baudRate;
|
||||||
if(uartTransmitting){
|
if(uartTransmitting){
|
||||||
serialPtr_bit += distance_between_bits;
|
serialPtr_bit += distance_between_bits;
|
||||||
} else serialPtr_bit += distance_between_bits - 1; //Less than one baud period so that it will always see that start bit.
|
} else serialPtr_bit += distance_between_bits; //Less than one baud period so that it will always see that start bit.
|
||||||
|
|
||||||
if (serialPtr_bit > (bufferEnd * 8)){
|
if (serialPtr_bit > (bufferEnd * 8)){
|
||||||
serialPtr_bit -= (bufferEnd * 8);
|
serialPtr_bit -= (bufferEnd * 8);
|
||||||
|
@ -301,7 +301,7 @@ void isoBuffer::decodeNextUartBit(unsigned char bitValue)
|
||||||
bool isoBuffer::jitterCompensationProcedure(double baudRate, unsigned char current_bit){
|
bool isoBuffer::jitterCompensationProcedure(double baudRate, unsigned char current_bit){
|
||||||
|
|
||||||
if(current_bit !=0){
|
if(current_bit !=0){
|
||||||
qDebug() << "Current bit not zero!!";
|
//qDebug() << "Current bit not zero!!";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,13 +311,13 @@ bool isoBuffer::jitterCompensationProcedure(double baudRate, unsigned char curre
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char left_byte = (buffer[left_coord/8] & 0xff);
|
unsigned char left_byte = (buffer[left_coord/8] & 0xff);
|
||||||
qDebug() << "current_bit" << current_bit;
|
//qDebug() << "current_bit" << current_bit;
|
||||||
qDebug() << "left_byte" << left_byte;
|
//qDebug() << "left_byte" << left_byte;
|
||||||
|
|
||||||
if(left_byte > 0){
|
if(left_byte > 0){
|
||||||
qDebug() << "Recalibration Opportunity";
|
//qDebug() << "Recalibration Opportunity";
|
||||||
unsigned char temp_bit = 0;
|
unsigned char temp_bit = 0;
|
||||||
//Go back to transition point
|
//Go back to 1-0 transition point
|
||||||
while(!temp_bit){
|
while(!temp_bit){
|
||||||
temp_bit = getNextUartBit();
|
temp_bit = getNextUartBit();
|
||||||
serialPtr_bit--;
|
serialPtr_bit--;
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue