Skip to content

Commit

Permalink
Fix #9 Use DataFormat::U16BEIter to prevent endianness issue
Browse files Browse the repository at this point in the history
  • Loading branch information
IniterWorker committed Sep 26, 2024
1 parent 0b74b95 commit 1afd767
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,6 @@ where
.skip(starting_page)
.take(num_pages)
.map(|s| &s[page_lower..page_upper])
.try_for_each(|c| interface.send_data(DataFormat::U16(c)))
.try_for_each(|c| interface.send_data(DataFormat::U16BEIter(&mut c.iter().copied())))
}
}
7 changes: 4 additions & 3 deletions src/mode/graphics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ where
}
}

// Turn a pixel on or off
/// Set a pixel color. If the X and Y coordinates are out of the bounds
/// of the display, this method call is a noop
pub fn set_pixel(&mut self, x: u32, y: u32, value: u16) {
let rotation = self.display_rotation;

Expand All @@ -176,13 +177,13 @@ where
}
};

if let Some(byte) = self.mode.buffer.as_mut().get_mut(idx) {
if let Some(color) = self.mode.buffer.as_mut().get_mut(idx) {
self.mode.min_x = self.mode.min_x.min(x as u16);
self.mode.max_x = self.mode.max_x.max(x as u16);
self.mode.min_y = self.mode.min_y.min(y as u16);
self.mode.max_y = self.mode.max_y.max(y as u16);

*byte = (value >> 8) & 0xFF | (value << 8) & 0xFF00;
*color = value;
}
}
}
Expand Down

0 comments on commit 1afd767

Please sign in to comment.