Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for 128x128 size displays #31

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,22 @@ pub enum Page {
Page6 = 6,
/// Page 7
Page7 = 7,
/// Page 8
Page8 = 8,
/// Page 9
Page9 = 9,
/// Page 10
Page10 = 10,
/// Page 11
Page11 = 11,
/// Page 12
Page12 = 12,
/// Page 13
Page13 = 13,
/// Page 14
Page14 = 14,
/// Page 15
Page15 = 15
}

impl From<u8> for Page {
Expand All @@ -119,6 +135,14 @@ impl From<u8> for Page {
5 => Page::Page5,
6 => Page::Page6,
7 => Page::Page7,
8 => Page::Page8,
9 => Page::Page9,
10 => Page::Page10,
11 => Page::Page11,
12 => Page::Page12,
13 => Page::Page13,
14 => Page::Page14,
15 => Page::Page15,
_ => panic!("Page too high"),
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/displaysize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
/// Display size enumeration
#[derive(Clone, Copy)]
pub enum DisplaySize {
/// 128 by 128 pixels
Display128x128,
/// 128 by 64 pixels
Display128x64,
/// 128 by 64 pixels without 2px X offset
Expand All @@ -17,6 +19,7 @@ impl DisplaySize {
/// Get integral dimensions from DisplaySize
pub fn dimensions(self) -> (u8, u8) {
match self {
DisplaySize::Display128x128 => (128, 128),
DisplaySize::Display128x64 => (128, 64),
DisplaySize::Display128x64NoOffset => (128, 64),
DisplaySize::Display128x32 => (128, 32),
Expand All @@ -27,6 +30,7 @@ impl DisplaySize {
/// Get the panel column offset from DisplaySize
pub fn column_offset(self) -> u8 {
match self {
DisplaySize::Display128x128 => 2,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just confirming this is the correct offset

DisplaySize::Display128x64 => 2,
DisplaySize::Display128x64NoOffset => 0,
DisplaySize::Display128x32 => 2,
Expand Down
13 changes: 8 additions & 5 deletions src/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ where
let display_rotation = self.display_rotation;

Command::DisplayOn(false).send(&mut self.iface)?;
Command::DisplayClockDiv(0x8, 0x0).send(&mut self.iface)?;
Command::Multiplex(display_height - 1).send(&mut self.iface)?;
Command::DisplayOffset(0).send(&mut self.iface)?;
Command::StartLine(0).send(&mut self.iface)?;
Command::Contrast(0x80).send(&mut self.iface)?;
Command::SegmentRemap(false).send(&mut self.iface)?;
Command::Multiplex(128).send(&mut self.iface)?;
Command::DisplayOffset(0x60).send(&mut self.iface)?;
Command::DisplayClockDiv(0x8, 0x0).send(&mut self.iface)?;
Comment on lines +52 to +56
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have hardware to test with on hand at the moment, but I'm concerned these changes will cause regressions for the currently supported display sizes. What are the minimum changes needed to support 128x128 displays?

// TODO: Ability to turn charge pump on/off
// Display must be off when performing this command
Command::ChargePump(true).send(&mut self.iface)?;
Expand All @@ -60,12 +62,13 @@ where

match self.display_size {
DisplaySize::Display128x32 => Command::ComPinConfig(false).send(&mut self.iface),
DisplaySize::Display128x64
DisplaySize::Display128x128
| DisplaySize::Display128x64
| DisplaySize::Display128x64NoOffset
| DisplaySize::Display132x64 => Command::ComPinConfig(true).send(&mut self.iface),
}?;

Command::Contrast(0x80).send(&mut self.iface)?;

Command::PreChargePeriod(0x1, 0xF).send(&mut self.iface)?;
Command::VcomhDeselect(VcomhLevel::Auto).send(&mut self.iface)?;
Command::AllOn(false).send(&mut self.iface)?;
Expand Down