-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Add addition for range registers to simplify extraction
Showing
4 changed files
with
97 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use core::ops::Add; | ||
use crate::{OutXHigh, OutXLow, OutYHigh, OutYLow, OutZHigh, OutZLow}; | ||
|
||
impl Add<OutXHigh> for OutXLow { | ||
type Output = i16; | ||
|
||
fn add(self, hi: OutXHigh) -> Self::Output { | ||
(hi.bits() as i16) << 8 | (self.bits() as i16) | ||
} | ||
} | ||
|
||
impl Add<OutXLow> for OutXHigh { | ||
type Output = i16; | ||
|
||
fn add(self, lo: OutXLow) -> Self::Output { | ||
lo.add(self) | ||
} | ||
} | ||
|
||
impl Add<OutYHigh> for OutYLow { | ||
type Output = i16; | ||
|
||
fn add(self, hi: OutYHigh) -> Self::Output { | ||
(hi.bits() as i16) << 8 | (self.bits() as i16) | ||
} | ||
} | ||
|
||
impl Add<OutYLow> for OutYHigh { | ||
type Output = i16; | ||
|
||
fn add(self, lo: OutYLow) -> Self::Output { | ||
lo.add(self) | ||
} | ||
} | ||
|
||
impl Add<OutZHigh> for OutZLow { | ||
type Output = i16; | ||
|
||
fn add(self, hi: OutZHigh) -> Self::Output { | ||
(hi.bits() as i16) << 8 | (self.bits() as i16) | ||
} | ||
} | ||
|
||
impl Add<OutZLow> for OutZHigh { | ||
type Output = i16; | ||
|
||
fn add(self, lo: OutZLow) -> Self::Output { | ||
lo.add(self) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,6 +78,7 @@ macro_rules! writable_register { | |
}; | ||
} | ||
|
||
mod conversions; | ||
mod gyro; | ||
mod types; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters