Skip to content

Commit 60158f4

Browse files
authored
Fix brightness for 72x40 display (#141)
Add a new command. Add SSD1306B datasheet.
1 parent c27cf56 commit 60158f4

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
### Changed
1010

11+
- [#141](https://github.com/jamwaffles/ssd1306/pull/141) Brightness for 72x40 display.
1112
- **(breaking)** [#139] Removed default display size type parameters.
1213

1314
## [0.4.1] - 2020-12-01

doc/SSD1306B_rev1.1.pdf

1.03 MB
Binary file not shown.

src/command.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ pub enum Command {
8686
Noop,
8787
/// Enable charge pump
8888
ChargePump(bool),
89+
/// Select external or internal I REF. Only for 72 x 40 display with SSD1306B driver
90+
InternalIref(bool, bool),
8991
}
9092

9193
impl Command {
@@ -160,6 +162,18 @@ impl Command {
160162
Command::VcomhDeselect(level) => ([0xDB, (level as u8) << 4, 0, 0, 0, 0, 0], 2),
161163
Command::Noop => ([0xE3, 0, 0, 0, 0, 0, 0], 1),
162164
Command::ChargePump(en) => ([0x8D, 0x10 | ((en as u8) << 2), 0, 0, 0, 0, 0], 2),
165+
Command::InternalIref(en, current) => (
166+
[
167+
0xAD,
168+
((current as u8) << 5) | ((en as u8) << 4),
169+
0,
170+
0,
171+
0,
172+
0,
173+
0,
174+
],
175+
2,
176+
),
163177
};
164178

165179
// Send command over the interface

src/displaysize.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ pub trait DisplaySize {
2828
/// width * height / 8
2929
type BufferSize: ArrayLength<u8>;
3030

31-
/// Send resolution-dependent configuration to the display
31+
/// Send resolution and model-dependent configuration to the display
3232
///
3333
/// See [`Command::ComPinConfig`](../command/enum.Command.html#variant.ComPinConfig)
34+
/// and [`Command::InternalIref`](../command/enum.Command.html#variant.InternalIref)
3435
/// for more information
3536
fn configure(&self, iface: &mut impl WriteOnlyDataCommand) -> Result<(), DisplayError>;
3637
}
@@ -85,7 +86,8 @@ impl DisplaySize for DisplaySize72x40 {
8586
type BufferSize = U360;
8687

8788
fn configure(&self, iface: &mut impl WriteOnlyDataCommand) -> Result<(), DisplayError> {
88-
Command::ComPinConfig(true, false).send(iface)
89+
Command::ComPinConfig(true, false).send(iface)?;
90+
Command::InternalIref(true, true).send(iface)
8991
}
9092
}
9193

0 commit comments

Comments
 (0)