From e84daa0179f7f4df77fe8a035a03b23d3f1d6fa3 Mon Sep 17 00:00:00 2001 From: bunnie Date: Fri, 28 Feb 2025 17:42:30 +0800 Subject: [PATCH] fixup more emulation issues --- libs/cramium-hal/src/sh1107.rs | 12 ++++-------- services/cramium-emu/src/display.rs | 12 ++++-------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/libs/cramium-hal/src/sh1107.rs b/libs/cramium-hal/src/sh1107.rs index 549c1905b..ccf3d09e7 100644 --- a/libs/cramium-hal/src/sh1107.rs +++ b/libs/cramium-hal/src/sh1107.rs @@ -38,7 +38,7 @@ pub enum Mono { impl From for Mono { fn from(value: ColorNative) -> Self { match value.0 { - 0 => Mono::Black, + 1 => Mono::Black, _ => Mono::White, } } @@ -46,8 +46,8 @@ impl From for Mono { impl Into for Mono { fn into(self) -> ColorNative { match self { - Mono::Black => ColorNative::from(0), - Mono::White => ColorNative::from(1), + Mono::Black => ColorNative::from(1), + Mono::White => ColorNative::from(0), } } } @@ -500,11 +500,7 @@ impl<'a> FrameBuffer for Oled128x128<'a> { return None; } let bitnum = (p.x + p.y * COLUMN) as usize; - if self.buffer[bitnum / 32] & 1 << (bitnum % 32) != 0 { - Some(Mono::White.into()) - } else { - Some(Mono::Black.into()) - } + if self.buffer[bitnum / 32] & 1 << (bitnum % 32) != 0 { Some(1.into()) } else { Some(0.into()) } } fn xor_pixel(&mut self, p: Point) { diff --git a/services/cramium-emu/src/display.rs b/services/cramium-emu/src/display.rs index 68c96dc00..3c24181b0 100644 --- a/services/cramium-emu/src/display.rs +++ b/services/cramium-emu/src/display.rs @@ -23,7 +23,7 @@ pub enum Mono { impl From for Mono { fn from(value: ColorNative) -> Self { match value.0 { - 0 => Mono::Black, + 1 => Mono::Black, _ => Mono::White, } } @@ -31,8 +31,8 @@ impl From for Mono { impl Into for Mono { fn into(self) -> ColorNative { match self { - Mono::Black => ColorNative::from(0), - Mono::White => ColorNative::from(1), + Mono::Black => ColorNative::from(1), + Mono::White => ColorNative::from(0), } } } @@ -178,11 +178,7 @@ impl FrameBuffer for Oled128x128 { return None; } let bitnum = (p.x + p.y * COLUMN) as usize; - if self.buffer[bitnum / 32] & 1 << (bitnum % 32) != 0 { - Some(Mono::White.into()) - } else { - Some(Mono::Black.into()) - } + if self.buffer[bitnum / 32] & 1 << (bitnum % 32) != 0 { Some(1.into()) } else { Some(0.into()) } } fn xor_pixel(&mut self, p: Point) {