Skip to content

Commit

Permalink
Fix read of command byte for data decode
Browse files Browse the repository at this point in the history
  • Loading branch information
sunsided committed Jul 5, 2024
1 parent 3a24e21 commit 4f64107
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,13 @@ where
let mut buffer = [command, 0, 0, 0, 0, 0, 0];
self.spi.transfer(&mut buffer)?;

let xlo = OutXLow::from_bits(buffer[0]);
let xhi = OutXHigh::from_bits(buffer[1]);
let ylo = OutYLow::from_bits(buffer[2]);
let yhi = OutYHigh::from_bits(buffer[3]);
let zlo = OutZLow::from_bits(buffer[4]);
let zhi = OutZHigh::from_bits(buffer[5]);
// skip the command byte [0].
let xlo = OutXLow::from_bits(buffer[1]);
let xhi = OutXHigh::from_bits(buffer[2]);
let ylo = OutYLow::from_bits(buffer[3]);
let yhi = OutYHigh::from_bits(buffer[4]);
let zlo = OutZLow::from_bits(buffer[5]);
let zhi = OutZHigh::from_bits(buffer[6]);

let x = xhi + xlo;
let y = yhi + ylo;
Expand All @@ -319,6 +320,7 @@ where
let mut buffer = [command, 0, 0, 0, 0, 0, 0, 0, 0];
self.spi.transfer(&mut buffer)?;

// skip the command byte at [0].
let temp = TemperatureRegister::from_bits(buffer[1]);
let status = StatusRegister::from_bits(buffer[2]);
let xlo = OutXLow::from_bits(buffer[3]);
Expand Down

0 comments on commit 4f64107

Please sign in to comment.