From 03f2cbc9426cc63ce9895ffeace998f3646683cc Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 26 May 2018 17:38:51 +0200 Subject: [PATCH] decreased the change of a overflow happening in draw_pixel, some more calculations and improvements are needed --- examples/embedded_linux/src/main.rs | 2 ++ src/drawing/mod.rs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/embedded_linux/src/main.rs b/examples/embedded_linux/src/main.rs index ebc7171..172630a 100644 --- a/examples/embedded_linux/src/main.rs +++ b/examples/embedded_linux/src/main.rs @@ -13,6 +13,8 @@ use lin_hal::sysfs_gpio::Direction; use lin_hal::Delay; // activate spi, gpio in raspi-config +// needs to be run with sudo because of some sysfs_gpio permission problems and follow-up timing problems +// see https://github.com/rust-embedded/rust-sysfs-gpio/issues/5 and follow-up issues // DigitalIn Hack as long as it's not in the linux_embedded_hal diff --git a/src/drawing/mod.rs b/src/drawing/mod.rs index 6c7741f..85f7b2e 100644 --- a/src/drawing/mod.rs +++ b/src/drawing/mod.rs @@ -87,7 +87,7 @@ impl Graphics { pub fn draw_pixel(&self, buffer: &mut[u8], x: u16, y: u16, color: &Color) { let (idx, bit) = match self.rotation { Displayorientation::Rotate0 | Displayorientation::Rotate180 - => ((x + self.width * y) / 8, + => ((x / 8 + (self.width / 8) * y) , 0x80 >> (x % 8)), Displayorientation::Rotate90 | Displayorientation::Rotate270 => (y / 8 * self.width + x,