Skip to content

Commit a252d07

Browse files
authored
Merge pull request #66 from BuggStream/feature/epd1in54c
Add support for epd1in54c
2 parents 181010f + b479edd commit a252d07

File tree

6 files changed

+389
-0
lines changed

6 files changed

+389
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ Cargo.lock
1111

1212
# vscode
1313
.vscode/*
14+
15+
# intellij/clion
16+
.idea/

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ epd.update_and_display_frame(&mut spi, &display.buffer())?;
4545
| [2.13 Inch B/W (A) V2](https://www.waveshare.com/product/2.13inch-e-paper-hat.htm) | Black, White |||||
4646
| [2.9 Inch B/W (A)](https://www.waveshare.com/product/2.9inch-e-paper-module.htm) | Black, White |||||
4747
| [1.54 Inch B/W/R (B)](https://www.waveshare.com/product/modules/oleds-lcds/e-paper/1.54inch-e-paper-module-b.htm) | Black, White, Red |||||
48+
| [1.54 Inch B/W/Y (C)](https://www.waveshare.com/1.54inch-e-paper-c.htm) | Black, White, Yellow |||||
4849
| [2.9 Inch B/W/R (B/C)](https://www.waveshare.com/product/displays/e-paper/epaper-2/2.9inch-e-paper-module-b.htm) | Black, White, Red |||||
4950
| [5.65 Inch 7 Color (F)](https://www.waveshare.com/5.65inch-e-paper-module-f.htm) | Black, White, Red, Green, Blue, Yellow, Orange |||||
5051
| [2.7 Inch 3 Color (B)](https://www.waveshare.com/2.7inch-e-paper-b.htm) | Black, White, Red |||||

src/epd1in54c/command.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//! SPI Commands for the Waveshare 1.54" C yellow E-Ink Display
2+
use crate::traits;
3+
4+
#[allow(dead_code)]
5+
#[allow(non_camel_case_types)]
6+
#[derive(Copy, Clone)]
7+
pub(crate) enum Command {
8+
PANEL_SETTING = 0x00,
9+
10+
POWER_SETTING = 0x01,
11+
POWER_OFF = 0x02,
12+
POWER_ON = 0x04,
13+
BOOSTER_SOFT_START = 0x06,
14+
DEEP_SLEEP = 0x07,
15+
DATA_START_TRANSMISSION_1 = 0x10,
16+
DISPLAY_REFRESH = 0x12,
17+
DATA_START_TRANSMISSION_2 = 0x13,
18+
19+
LUT_FOR_VCOM = 0x20,
20+
LUT_WHITE_TO_WHITE = 0x21,
21+
LUT_BLACK_TO_WHITE = 0x22,
22+
LUT_WHITE_TO_BLACK = 0x23,
23+
LUT_BLACK_TO_BLACK = 0x24,
24+
25+
PLL_CONTROL = 0x30,
26+
TEMPERATURE_SENSOR_COMMAND = 0x40,
27+
TEMPERATURE_SENSOR_SELECTION = 0x41,
28+
VCOM_AND_DATA_INTERVAL_SETTING = 0x50,
29+
RESOLUTION_SETTING = 0x61,
30+
VCM_DC_SETTING = 0x82,
31+
POWER_SAVING = 0xE3,
32+
}
33+
34+
impl traits::Command for Command {
35+
/// Returns the address of the command
36+
fn address(self) -> u8 {
37+
self as u8
38+
}
39+
}

src/epd1in54c/graphics.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
use crate::epd1in54c::{DEFAULT_BACKGROUND_COLOR, HEIGHT, NUM_DISPLAY_BITS, WIDTH};
2+
use crate::graphics::{Display, DisplayRotation};
3+
use embedded_graphics::pixelcolor::BinaryColor;
4+
use embedded_graphics::prelude::*;
5+
6+
/// Full size buffer for use with the 1in54c EPD
7+
///
8+
/// Can also be manually constructed and be used together with VarDisplay
9+
pub struct Display1in54c {
10+
buffer: [u8; NUM_DISPLAY_BITS as usize],
11+
rotation: DisplayRotation,
12+
}
13+
14+
impl Default for Display1in54c {
15+
fn default() -> Self {
16+
Display1in54c {
17+
buffer: [DEFAULT_BACKGROUND_COLOR.get_byte_value(); NUM_DISPLAY_BITS as usize],
18+
rotation: DisplayRotation::default(),
19+
}
20+
}
21+
}
22+
23+
impl DrawTarget<BinaryColor> for Display1in54c {
24+
type Error = core::convert::Infallible;
25+
26+
fn draw_pixel(&mut self, pixel: Pixel<BinaryColor>) -> Result<(), Self::Error> {
27+
self.draw_helper(WIDTH, HEIGHT, pixel)
28+
}
29+
30+
fn size(&self) -> Size {
31+
Size::new(WIDTH, HEIGHT)
32+
}
33+
}
34+
35+
impl Display for Display1in54c {
36+
fn buffer(&self) -> &[u8] {
37+
&self.buffer
38+
}
39+
40+
fn get_mut_buffer(&mut self) -> &mut [u8] {
41+
&mut self.buffer
42+
}
43+
44+
fn set_rotation(&mut self, rotation: DisplayRotation) {
45+
self.rotation = rotation;
46+
}
47+
48+
fn rotation(&self) -> DisplayRotation {
49+
self.rotation
50+
}
51+
}

0 commit comments

Comments
 (0)