From 3bf7ebc99720d940baeca66d1983014a099d9b82 Mon Sep 17 00:00:00 2001 From: Victoria Fischer Date: Mon, 5 Jan 2026 13:03:58 +0100 Subject: [PATCH] graphics: ssd1306: fix crash in dithering --- src/graphics/ssd1306.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/graphics/ssd1306.rs b/src/graphics/ssd1306.rs index 6d1bbf7..dd42b10 100644 --- a/src/graphics/ssd1306.rs +++ b/src/graphics/ssd1306.rs @@ -38,7 +38,7 @@ impl SsdPixel { } } -const DITHER_MAP: [u32;15] = [ +const DITHER_MAP: [u16;15] = [ 0b1000_0000_0000_0000, 0b1000_0000_0010_0000, 0b1010_0000_0010_0000, @@ -62,9 +62,9 @@ impl AdditivePixelSink for SsdPixel { 0 => (), 255 => self.set_pixel(pixel), _ => { - let dither_value = DITHER_MAP[opacity as usize / 16]; + let dither_value = DITHER_MAP[opacity as usize / 17]; let dither_x = self.coords.x % 4; - let dither_y = self.coords.x % 4; + let dither_y = self.coords.y % 4; if dither_value.shr(dither_x).shr(dither_y * 4).bitand(0x01) == 1 { self.set_pixel(pixel); }