Skip to content

Commit

Permalink
Add epd12in48b_v2
Browse files Browse the repository at this point in the history
  • Loading branch information
vadimcn committed Feb 10, 2024
1 parent a083583 commit 18f9793
Show file tree
Hide file tree
Showing 5 changed files with 854 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/epd12in48b_v2/command.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//! SPI Commands for the Waveshare 12.48"(B) V2 Ink Display
use crate::traits;

/// Epd12in48 commands
///
#[allow(unused, non_camel_case_types)]
#[derive(Clone, Copy)]
pub enum Command {
PanelSetting = 0x00,
PowerOff = 0x02,
PowerOn = 0x04,
BoosterSoftStart = 0x06,
DeepSleep = 0x07,
DataStartTransmission1 = 0x10,
DisplayRefresh = 0x12,
DataStartTransmission2 = 0x13,
DualSPI = 0x15,
LUTC = 0x20,
LUTWW = 0x21,
LUTKW_LUTR = 0x22,
LUTWK_LUTW = 0x23,
LUTKK_LUTK = 0x24,
LUTBD = 0x25,
KWLUTOption = 0x2B,
VcomAndDataIntervalSetting = 0x50,
TconSetting = 0x60,
TconResolution = 0x61,
GetStatus = 0x71,
PartialWindow = 0x90,
PartialIn = 0x91,
PartialOut = 0x92,
CascadeSetting = 0xE0,
PowerSaving = 0xE3,
ForceTemperature = 0xE5,
}

impl traits::Command for Command {
/// Returns the address of the command
fn address(self) -> u8 {
self as u8
}
}
42 changes: 42 additions & 0 deletions src/epd12in48b_v2/config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#[derive(Copy, Clone, Debug)]
/// EPD Configuration
pub struct Config {
/// Specifies how data1 bits are mapped to colors:
/// - `false`: 0 => black, 1 => white
/// - `true`: 0 => white, 1 => black
pub inverted_kw: bool,
/// Specifies how data2 bits are mapped to colors:
/// - `false`: 0 => red not active, 1 => red active
/// - `true`: 0 => red active, 1 => red not active
///
/// Note that whenever the red channel is active, the black/white channel is ignored.
pub inverted_r: bool,
/// Lookup table to use for the screen border
pub border_lut: BorderLUT,
/// Whether to use the lookup tables loaded via `set_lut...` methods, or the built-in ones.
pub external_lut: bool,
}

impl Default for Config {
fn default() -> Self {
Self {
inverted_kw: false,
inverted_r: false,
border_lut: BorderLUT::LUTBD,
external_lut: false,
}
}
}

/// Screen border lookup table variants
#[derive(Copy, Clone, Debug)]
pub enum BorderLUT {
/// Use LUTBD
LUTBD,
/// Use LUTK
LUTK,
/// Use LUTW
LUTW,
/// Use LUTR
LUTR,
}
Loading

0 comments on commit 18f9793

Please sign in to comment.