Skip to content

Commit

Permalink
Support 128x64 displays with no X offset (#22)
Browse files Browse the repository at this point in the history
* Support 128x64 displays with no X offset

* Changelog entry
  • Loading branch information
jamwaffles authored Jun 9, 2020
1 parent 366e64a commit b3ef870
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ with the [embedded-hal](crates.io/crates/embedded-hal) traits for maximum portab

## [Unreleased] - ReleaseDate

### Added

- [#22](https://github.com/jamwaffles/sh1106/pull/22) Add `DisplaySize::Display128x64NoOffset` variant for 128x64 displays that don't use a 132x64 buffer internally.

## [0.3.2] - 2020-04-30

### Added
Expand Down Expand Up @@ -69,9 +73,9 @@ Upgrade to new embedded-graphics `0.6.0-alpha.1` release. Please see the [embedd
- **(breaking)** #9 Upgraded to [embedded-graphics](https://crates.io/crates/embedded-graphics) 0.6.0-alpha.1

<!-- next-url -->

[unreleased]: https://github.com/jamwaffles/sh1106/compare/v0.3.2...HEAD
[0.3.2]: https://github.com/jamwaffles/sh1106/compare/v0.3.1...v0.3.2

[0.3.1]: https://github.com/jamwaffles/sh1106/compare/v0.3.0...v0.3.1
[0.3.0]: https://github.com/jamwaffles/sh1106/compare/v0.3.0-alpha.4...v0.3.0
[0.3.0-alpha.4]: https://github.com/jamwaffles/sh1106/compare/v0.3.0-alpha.3...v0.3.0-alpha.4
Expand Down
4 changes: 4 additions & 0 deletions src/displaysize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
pub enum DisplaySize {
/// 128 by 64 pixels
Display128x64,
/// 128 by 64 pixels without 2px X offset
Display128x64NoOffset,
/// 128 by 32 pixels
Display128x32,
/// 132 by 64 pixels
Expand All @@ -16,6 +18,7 @@ impl DisplaySize {
pub fn dimensions(self) -> (u8, u8) {
match self {
DisplaySize::Display128x64 => (128, 64),
DisplaySize::Display128x64NoOffset => (128, 64),
DisplaySize::Display128x32 => (128, 32),
DisplaySize::Display132x64 => (132, 64),
}
Expand All @@ -25,6 +28,7 @@ impl DisplaySize {
pub fn column_offset(self) -> u8 {
match self {
DisplaySize::Display128x64 => 2,
DisplaySize::Display128x64NoOffset => 0,
DisplaySize::Display128x32 => 2,
DisplaySize::Display132x64 => 0,
}
Expand Down
5 changes: 3 additions & 2 deletions src/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ where

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

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

0 comments on commit b3ef870

Please sign in to comment.