From 0c95dedfd0875fe992f3c1ef2b46f60cef916b45 Mon Sep 17 00:00:00 2001 From: BodyweightEnergy Date: Mon, 28 Dec 2020 12:10:26 -0600 Subject: [PATCH] Fixed command bytes Changed first bytes for "PreChargePeriod" and "VcomhDeselect" to be what they should be in the datasheet (0xD9 and 0xDB, respectively). This fix got the driver working properly for my hardware (raspberry pi zero w + WaveShare SH1106 HAT). Before this fix, the display would behave differently in based on what seemed to be background cosmic radiation; sometimes it would work perfectly, sometimes it would go dark after a few seconds of displaying something. --- src/command.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/command.rs b/src/command.rs index 9a96f9e..06e1d47 100644 --- a/src/command.rs +++ b/src/command.rs @@ -74,10 +74,10 @@ impl Command { ([0xD5, ((0xF & fosc) << 4) | (0xF & div), 0, 0, 0, 0, 0], 2) } Command::PreChargePeriod(phase1, phase2) => ( - [0x22, ((0xF & phase2) << 4) | (0xF & phase1), 0, 0, 0, 0, 0], + [0xD9, ((0xF & phase2) << 4) | (0xF & phase1), 0, 0, 0, 0, 0], 2, ), - Command::VcomhDeselect(level) => ([0x35, (level as u8) << 4, 0, 0, 0, 0, 0], 2), + Command::VcomhDeselect(level) => ([0xDB, (level as u8) << 4, 0, 0, 0, 0, 0], 2), Command::Noop => ([0xE3, 0, 0, 0, 0, 0, 0], 1), Command::ChargePump(en) => ([0xAD, 0x8A | (en as u8), 0, 0, 0, 0, 0], 2), };