[DISP] Works on raspi this way

This commit is contained in:
Berkus Decker 2018-11-17 15:33:00 +02:00
parent 0ecdb774f5
commit 72d4e52009
1 changed files with 14 additions and 11 deletions

View File

@ -96,18 +96,21 @@ impl Display {
} }
} }
pub fn putpixel(&mut self, x: u16, y: u16, color: u32) { #[inline]
let c = |chan: u16| { fn color_component(&self, chan: u16) -> u32 {
if self.order == PixelOrder::BGR { u32::from(if self.order == PixelOrder::BGR {
2 - chan 2 - chan
} else { } else {
chan chan
})
} }
};
let f = |v: u32, chan: u16| unsafe { pub fn putpixel(&mut self, x: u16, y: u16, color: u32) {
*(self.base as *mut u8).offset( let f = |mut v: u32, chan: u16| unsafe {
(y as u32 * self.pitch + x as u32 * (self.depth / 8) + c(chan) as u32) as isize, *(self.base as *mut u8)
) = v as u8; .offset((u32::from(y) * self.pitch
+ u32::from(x) * 4//(self.depth / 8)
+ self.color_component(chan)) as isize) = v as u8;
}; };
f(color & 0xff, 0); f(color & 0xff, 0);