Skip to content

Commit

Permalink
v2.3.3 bugfix for velocity calcs
Browse files Browse the repository at this point in the history
  • Loading branch information
joshua-8 committed Jun 2, 2024
1 parent e7d1fd5 commit 5524da0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=byte-sized-encoder-decoder
version=2.2.2
version=2.2.3
author=RCM Games <robot.control.modules@gmail.com>
maintainer=RCM Games <robot.control.modules@gmail.com>
sentence=communicate over I2C with an encoder reading module
Expand Down
2 changes: 1 addition & 1 deletion src/byte-sized-encoder-decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class ByteSizedEncoderDecoder {
// calculate velocity
unsigned long mic = micros();
int32_t hundredMicrosSinceLastRead = (mic - lastReadMicros[i]) / 100; // using a time interval of 100 microseconds (won't overflow int32)
if (hundredMicrosSinceLastRead > (int32_t)(encoderSlowestInterval[i] * 10) || abs(encoderCount[i] - lastEncoderCount[i]) > encoderEnoughCounts[i]) {
if (hundredMicrosSinceLastRead > (int32_t)(encoderSlowestInterval[i] * 10) || abs(encoderCount[i] - lastVelocityEncoderCount[i]) > encoderEnoughCounts[i]) {
lastReadMicros[i] = mic;
encoderVelocity[i] = (int32_t)10000 * (encoderCount[i] - lastVelocityEncoderCount[i]) / hundredMicrosSinceLastRead;
lastVelocityEncoderCount[i] = encoderCount[i];
Expand Down

0 comments on commit 5524da0

Please sign in to comment.