Skip to content

Commit

Permalink
Distinguish written and read rotation values
Browse files Browse the repository at this point in the history
  • Loading branch information
baskerville committed Dec 14, 2020
1 parent cee3e48 commit 99240d0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ impl Device {
}
}

// The written rotation that makes the screen be in portrait mode
// with the Kobo logo at the bottom.
pub fn startup_rotation(&self) -> i8 {
match self.model {
Model::LibraH2O => 0,
Expand All @@ -303,19 +305,21 @@ impl Device {
}

// Return a device independent rotation value given
// the device dependent rotation value *n*.
// the device dependent written rotation value *n*.
pub fn to_canonical(&self, n: i8) -> i8 {
let (_, dir) = self.mirroring_scheme();
(4 + dir * (n - self.startup_rotation())) % 4
}

// Return a device dependent rotation value given
// Return a device dependent written rotation value given
// the device independent rotation value *n*.
pub fn from_canonical(&self, n: i8) -> i8 {
let (_, dir) = self.mirroring_scheme();
(self.startup_rotation() + (4 + dir * n) % 4) % 4
}

// Return a device dependent written rotation value given
// the device dependent read rotation value *n*.
pub fn transformed_rotation(&self, n: i8) -> i8 {
match self.model {
Model::AuraHD | Model::AuraH2O => n ^ 2,
Expand Down

0 comments on commit 99240d0

Please sign in to comment.