Skip to content

Commit

Permalink
Whitespace and Tab corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulZC committed May 1, 2020
1 parent 80c05ea commit ec528f1
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/SparkFun_BNO080_Arduino_Library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ bool BNO080::dataAvailable(void)
if (digitalRead(_int) == HIGH)
return (false);
}

if (receivePacket() == true)
{
//Check to see if this packet is a sensor reporting its data to us
Expand All @@ -163,11 +163,11 @@ bool BNO080::dataAvailable(void)
parseCommandReport(); //This will update responses to commands, calibrationStatus, etc.
return (true);
}
else if(shtpHeader[2] == CHANNEL_GYRO)
{
parseInputReport(); //This will update the rawAccelX, etc variables depending on which feature report is found
return (true);
}
else if(shtpHeader[2] == CHANNEL_GYRO)
{
parseInputReport(); //This will update the rawAccelX, etc variables depending on which feature report is found
return (true);
}
}
return (false);
}
Expand Down Expand Up @@ -232,12 +232,12 @@ void BNO080::parseInputReport(void)
int16_t dataLength = ((uint16_t)shtpHeader[1] << 8 | shtpHeader[0]);
dataLength &= ~(1 << 15); //Clear the MSbit. This bit indicates if this package is a continuation of the last.
//Ignore it for now. TODO catch this as an error and exit

dataLength -= 4; //Remove the header bytes from the data count

timeStamp = ((uint32_t)shtpData[4] << (8 * 3)) | ((uint32_t)shtpData[3] << (8 * 2)) | ((uint32_t)shtpData[2] << (8 * 1)) | ((uint32_t)shtpData[1] << (8 * 0));

// The gyro-integrated input reports are sent via the special gyro channel and do no include the usual ID, sequence, and status fields
// The gyro-integrated input reports are sent via the special gyro channel and do no include the usual ID, sequence, and status fields
if(shtpHeader[2] == CHANNEL_GYRO) {
rawQuatI = (uint16_t)shtpData[1] << 8 | shtpData[0];
rawQuatJ = (uint16_t)shtpData[3] << 8 | shtpData[2];
Expand All @@ -246,7 +246,7 @@ void BNO080::parseInputReport(void)
rawFastGyroX = (uint16_t)shtpData[9] << 8 | shtpData[8];
rawFastGyroY = (uint16_t)shtpData[11] << 8 | shtpData[10];
rawFastGyroZ = (uint16_t)shtpData[13] << 8 | shtpData[12];

return;
}

Expand Down Expand Up @@ -295,8 +295,10 @@ void BNO080::parseInputReport(void)
rawMagY = data2;
rawMagZ = data3;
}
else if (shtpData[5] == SENSOR_REPORTID_ROTATION_VECTOR || shtpData[5] == SENSOR_REPORTID_GAME_ROTATION_VECTOR ||
shtpData[5] == SENSOR_REPORTID_AR_VR_STABILIZED_ROTATION_VECTOR || shtpData[5] == SENSOR_REPORTID_AR_VR_STABILIZED_GAME_ROTATION_VECTOR)
else if (shtpData[5] == SENSOR_REPORTID_ROTATION_VECTOR ||
shtpData[5] == SENSOR_REPORTID_GAME_ROTATION_VECTOR ||
shtpData[5] == SENSOR_REPORTID_AR_VR_STABILIZED_ROTATION_VECTOR ||
shtpData[5] == SENSOR_REPORTID_AR_VR_STABILIZED_GAME_ROTATION_VECTOR)
{
quatAccuracy = status;
rawQuatI = data1;
Expand All @@ -305,7 +307,7 @@ void BNO080::parseInputReport(void)
rawQuatReal = data4;

//Only available on rotation vector and ar/vr stabilized rotation vector,
// not game rot vector and not ar/vr stabilized rotation vector
// not game rot vector and not ar/vr stabilized rotation vector
rawQuatRadianAccuracy = data5;
}
else if (shtpData[5] == SENSOR_REPORTID_STEP_COUNTER)
Expand Down Expand Up @@ -1214,13 +1216,13 @@ boolean BNO080::receivePacket(void)
uint8_t packetMSB = _spiPort->transfer(0);
uint8_t channelNumber = _spiPort->transfer(0);
uint8_t sequenceNumber = _spiPort->transfer(0); //Not sure if we need to store this or not

//Store the header info
shtpHeader[0] = packetLSB;
shtpHeader[1] = packetMSB;
shtpHeader[2] = channelNumber;
shtpHeader[3] = sequenceNumber;

//Calculate the number of data bytes in this packet
uint16_t dataLength = ((uint16_t)packetMSB << 8 | packetLSB);
dataLength &= ~(1 << 15); //Clear the MSbit.
Expand All @@ -1242,7 +1244,7 @@ boolean BNO080::receivePacket(void)
}

digitalWrite(_cs, HIGH); //Release BNO080

_spiPort->endTransaction();
//printPacket();
}
Expand Down

0 comments on commit ec528f1

Please sign in to comment.