Skip to content

Commit

Permalink
fix 23 bit
Browse files Browse the repository at this point in the history
  • Loading branch information
hacknus committed Apr 24, 2024
1 parent 02edf5f commit 86a9923
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,8 +611,8 @@ impl<SPI, CS, EN, E> Tmc5160<SPI, CS, EN>
/// get the current velocity
pub fn get_velocity(&mut self) -> Result<f32, Error<E>> {
self.read_register(Registers::VACTUAL).map(|val| {
if (val.data & 0b1000000000000000000000000) == 0b1000000000000000000000000 {
((8388607 - (val.data & 0b111111111111111111111111) as i32) as f64 / self._step_count as f64) as f32
if (val.data & 0b100000000000000000000000) == 0b100000000000000000000000 {
((8388607 - (val.data & 0b11111111111111111111111) as i32) as f64 / self._step_count as f64) as f32
} else {
((val.data as i32) as f64 / self._step_count as f64) as f32
}
Expand Down

0 comments on commit 86a9923

Please sign in to comment.