-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from michaelbeaumont/epd2in9b
Add epd2in9bc support
- Loading branch information
Showing
9 changed files
with
520 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//! SPI Commands for the Waveshare 2.9" (B/C) E-Ink Display | ||
use crate::traits; | ||
|
||
#[allow(dead_code)] | ||
#[allow(non_camel_case_types)] | ||
#[derive(Copy, Clone)] | ||
pub(crate) enum Command { | ||
PANEL_SETTING = 0x00, | ||
|
||
POWER_SETTING = 0x01, | ||
POWER_OFF = 0x02, | ||
POWER_ON = 0x04, | ||
BOOSTER_SOFT_START = 0x06, | ||
DEEP_SLEEP = 0x07, | ||
DATA_START_TRANSMISSION_1 = 0x10, | ||
DISPLAY_REFRESH = 0x12, | ||
DATA_START_TRANSMISSION_2 = 0x13, | ||
|
||
LUT_FOR_VCOM = 0x20, | ||
LUT_WHITE_TO_WHITE = 0x21, | ||
LUT_BLACK_TO_WHITE = 0x22, | ||
LUT_WHITE_TO_BLACK = 0x23, | ||
LUT_BLACK_TO_BLACK = 0x24, | ||
|
||
PLL_CONTROL = 0x30, | ||
TEMPERATURE_SENSOR_COMMAND = 0x40, | ||
TEMPERATURE_SENSOR_SELECTION = 0x41, | ||
VCOM_AND_DATA_INTERVAL_SETTING = 0x50, | ||
RESOLUTION_SETTING = 0x61, | ||
VCM_DC_SETTING = 0x82, | ||
POWER_SAVING = 0xE3, | ||
} | ||
|
||
impl traits::Command for Command { | ||
/// Returns the address of the command | ||
fn address(self) -> u8 { | ||
self as u8 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
use crate::epd2in9bc::{DEFAULT_BACKGROUND_COLOR, HEIGHT, NUM_DISPLAY_BITS, WIDTH}; | ||
use crate::graphics::{Display, DisplayRotation}; | ||
use embedded_graphics::pixelcolor::BinaryColor; | ||
use embedded_graphics::prelude::*; | ||
|
||
/// Full size buffer for use with the 2in9b/c EPD | ||
/// | ||
/// Can also be manually constructed and be used together with VarDisplay | ||
pub struct Display2in9bc { | ||
buffer: [u8; NUM_DISPLAY_BITS as usize], | ||
rotation: DisplayRotation, | ||
} | ||
|
||
impl Default for Display2in9bc { | ||
fn default() -> Self { | ||
Display2in9bc { | ||
buffer: [DEFAULT_BACKGROUND_COLOR.get_byte_value(); NUM_DISPLAY_BITS as usize], | ||
rotation: DisplayRotation::default(), | ||
} | ||
} | ||
} | ||
|
||
impl DrawTarget<BinaryColor> for Display2in9bc { | ||
type Error = core::convert::Infallible; | ||
|
||
fn draw_pixel(&mut self, pixel: Pixel<BinaryColor>) -> Result<(), Self::Error> { | ||
self.draw_helper(WIDTH, HEIGHT, pixel) | ||
} | ||
|
||
fn size(&self) -> Size { | ||
Size::new(WIDTH, HEIGHT) | ||
} | ||
} | ||
|
||
impl Display for Display2in9bc { | ||
fn buffer(&self) -> &[u8] { | ||
&self.buffer | ||
} | ||
|
||
fn get_mut_buffer(&mut self) -> &mut [u8] { | ||
&mut self.buffer | ||
} | ||
|
||
fn set_rotation(&mut self, rotation: DisplayRotation) { | ||
self.rotation = rotation; | ||
} | ||
|
||
fn rotation(&self) -> DisplayRotation { | ||
self.rotation | ||
} | ||
} |
Oops, something went wrong.