uc8151 0.2.0

no_std library for the UC8151(IL0373) e-ink display with embedded-graphics support
Documentation
#[repr(u8)]
pub enum Instruction {
    PSR = 0x00,
    PWR = 0x01,
    POF = 0x02,
    PFS = 0x03,
    PON = 0x04,
    PMES = 0x05,
    BTST = 0x06,
    DSLP = 0x07,
    DTM1 = 0x10,
    DSP = 0x11,
    DRF = 0x12,
    DTM2 = 0x13,
    LUT_VCOM = 0x20,
    LUT_WW = 0x21,
    LUT_BW = 0x22,
    LUT_WB = 0x23,
    LUT_BB = 0x24,
    PLL = 0x30,
    TSC = 0x40,
    TSE = 0x41,
    TSR = 0x43,
    TSW = 0x42,
    CDI = 0x50,
    LPD = 0x51,
    TCON = 0x60,
    TRES = 0x61,
    REV = 0x70,
    FLG = 0x71,
    AMV = 0x80,
    VV = 0x81,
    VDCS = 0x82,
    PTL = 0x90,
    PTIN = 0x91,
    PTOU = 0x92,
    PGM = 0xa0,
    APG = 0xa1,
    ROTP = 0xa2,
    CCSET = 0xe0,
    PWS = 0xe3,
    TSSET = 0xe5,
}

pub mod psrflags {
    pub const RES_96X230: PsrFlags = 0b00000000;
    pub const RES_96X252: PsrFlags = 0b01000000;
    pub const RES_128X296: PsrFlags = 0b10000000;
    pub const RES_160X296: PsrFlags = 0b11000000;

    /// Use lookup table from OTP memory
    pub const LUT_OTP: PsrFlags = 0b00000000;
    /// Use lookup table from Register
    pub const LUT_REG: PsrFlags = 0b00100000;

    pub const FORMAT_BWR: PsrFlags = 0b00000000;
    pub const FORMAT_BW: PsrFlags = 0b00010000;

    pub const SCAN_DOWN: PsrFlags = 0b00000000;
    pub const SCAN_UP: PsrFlags = 0b00001000;

    pub const SHIFT_LEFT: PsrFlags = 0b00000000;
    pub const SHIFT_RIGHT: PsrFlags = 0b00000100;

    pub const BOOSTER_OFF: PsrFlags = 0b00000000;
    pub const BOOSTER_ON: PsrFlags = 0b00000010;

    pub const RESET_SOFT: PsrFlags = 0b00000000;
    pub const RESET_NONE: PsrFlags = 0b00000001;
    pub type PsrFlags = u8;
}

pub mod pwr_flags_1 {
    pub const VDS_EXTERNAL: PwrFlags1 = 0b00000000;
    pub const VDS_INTERNAL: PwrFlags1 = 2;

    pub const VDG_EXTERNAL: PwrFlags1 = 0b00000000;
    pub const VDG_INTERNAL: PwrFlags1 = 1;
    pub type PwrFlags1 = u8;
}

pub mod pwr_flags_2 {
    pub const VCOM_VD: PwrFlags2 = 0b00000000;
    pub const VCOM_VG: PwrFlags2 = 4;

    pub const VGHL_16V: PwrFlags2 = 0;
    pub const VGHL_15V: PwrFlags2 = 1;
    pub const VGHL_14V: PwrFlags2 = 2;
    pub const VGHL_13V: PwrFlags2 = 3;
    pub type PwrFlags2 = u8;
}

pub mod booster_flags {
    pub const START_10MS: BoosterFlags = 0b00000000;
    pub const START_20MS: BoosterFlags = 0b01000000;
    pub const START_30MS: BoosterFlags = 0b10000000;
    pub const START_40MS: BoosterFlags = 0b11000000;

    pub const STRENGTH_1: BoosterFlags = 0b00000000;
    pub const STRENGTH_2: BoosterFlags = 0b00001000;
    pub const STRENGTH_3: BoosterFlags = 0b00010000;
    pub const STRENGTH_4: BoosterFlags = 0b00011000;
    pub const STRENGTH_5: BoosterFlags = 0b00100000;
    pub const STRENGTH_6: BoosterFlags = 0b00101000;
    pub const STRENGTH_7: BoosterFlags = 0b00110000;
    pub const STRENGTH_8: BoosterFlags = 0b00111000;

    pub const OFF_0_27US: BoosterFlags = 0;
    pub const OFF_0_34US: BoosterFlags = 1;
    pub const OFF_0_40US: BoosterFlags = 2;
    pub const OFF_0_54US: BoosterFlags = 3;
    pub const OFF_0_80US: BoosterFlags = 4;
    pub const OFF_1_54US: BoosterFlags = 5;
    pub const OFF_3_34US: BoosterFlags = 6;
    pub const OFF_6_58US: BoosterFlags = 7;
    pub type BoosterFlags = u8;
}

pub mod pfs_flags {
    pub const FRAMES_1: PfsFlags = 0b00000000;
    pub const FRAMES_2: PfsFlags = 0b00010000;
    pub const FRAMES_3: PfsFlags = 0b00100000;
    pub const FRAMES_4: PfsFlags = 0b00110000;
    pub type PfsFlags = u8;
}

pub mod tse_flags {
    pub const TEMP_INTERNAL: TseFlags = 0b00000000;
    pub const TEMP_EXTERNAL: TseFlags = 0b10000000;
    pub const OFFSET_0: TseFlags = 0;
    pub const OFFSET_1: TseFlags = 1;
    pub const OFFSET_2: TseFlags = 2;
    pub const OFFSET_3: TseFlags = 3;
    pub const OFFSET_4: TseFlags = 4;
    pub const OFFSET_5: TseFlags = 5;
    pub const OFFSET_6: TseFlags = 6;
    pub const OFFSET_7: TseFlags = 7;

    pub const OFFSET_MIN_8: TseFlags = 8;
    pub const OFFSET_MIN_7: TseFlags = 9;
    pub const OFFSET_MIN_6: TseFlags = 10;
    pub const OFFSET_MIN_5: TseFlags = 11;
    pub const OFFSET_MIN_4: TseFlags = 12;
    pub const OFFSET_MIN_3: TseFlags = 13;
    pub const OFFSET_MIN_2: TseFlags = 14;
    pub const OFFSET_MIN_1: TseFlags = 15;
    pub type TseFlags = u8;
}

pub mod pll_flags {
    pub const HZ_29: PllFlags = 0b00_111_111;
    pub const HZ_33: PllFlags = 0b00_111_110;
    pub const HZ_40: PllFlags = 0b00_111_101;
    pub const HZ_50: PllFlags = 0b00_111_100;
    pub const HZ_67: PllFlags = 0b00_111_011;
    pub const HZ_100: PllFlags = 0b00_111_010;
    pub const HZ_150: PllFlags = 0b00_101_001;
    pub const HZ_200: PllFlags = 0b00_111_001;
    pub type PllFlags = u8;
}

pub struct Lut {
    pub vcom: [u8; 44],
    pub ww: [u8; 42],
    pub bw: [u8; 42],
    pub wb: [u8; 42],
    pub bb: [u8; 42],
    pub update_time: u16,
    pub pll: pll_flags::PllFlags,
}

pub const DEFAULT_LUT: Lut = Lut {
    vcom: [
        0x00, 0x64, 0x64, 0x37, 0x00, 0x01, 0x00, 0x8c, 0x8c, 0x00, 0x00, 0x04, 0x00, 0x64, 0x64,
        0x37, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    ],
    ww: [
        0x54, 0x64, 0x64, 0x37, 0x00, 0x01, 0x60, 0x8c, 0x8c, 0x00, 0x00, 0x04, 0xa8, 0x64, 0x64,
        0x37, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    ],
    bw: [
        0x54, 0x64, 0x64, 0x37, 0x00, 0x01, 0x60, 0x8c, 0x8c, 0x00, 0x00, 0x04, 0xa8, 0x64, 0x64,
        0x37, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    ],
    wb: [
        0xa8, 0x64, 0x64, 0x37, 0x00, 0x01, 0x60, 0x8c, 0x8c, 0x00, 0x00, 0x04, 0x54, 0x64, 0x64,
        0x37, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    ],
    bb: [
        0xa8, 0x64, 0x64, 0x37, 0x00, 0x01, 0x60, 0x8c, 0x8c, 0x00, 0x00, 0x04, 0x54, 0x64, 0x64,
        0x37, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    ],
    update_time: 4500,
    pll: pll_flags::HZ_100,
};

pub const MEDIUM_LUT: Lut = Lut {
    vcom: [
        0x00, 0x16, 0x16, 0x0d, 0x00, 0x01, 0x00, 0x23, 0x23, 0x00, 0x00, 0x02, 0x00, 0x16, 0x16,
        0x0d, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    ],
    ww: [
        0x54, 0x16, 0x16, 0x0d, 0x00, 0x01, 0x60, 0x23, 0x23, 0x00, 0x00, 0x02, 0xa8, 0x16, 0x16,
        0x0d, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    ],
    bw: [
        0x54, 0x16, 0x16, 0x0d, 0x00, 0x01, 0x60, 0x23, 0x23, 0x00, 0x00, 0x02, 0xa8, 0x16, 0x16,
        0x0d, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    ],
    wb: [
        0xa8, 0x16, 0x16, 0x0d, 0x00, 0x01, 0x60, 0x23, 0x23, 0x00, 0x00, 0x02, 0x54, 0x16, 0x16,
        0x0d, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    ],
    bb: [
        0xa8, 0x16, 0x16, 0x0d, 0x00, 0x01, 0x60, 0x23, 0x23, 0x00, 0x00, 0x02, 0x54, 0x16, 0x16,
        0x0d, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    ],
    update_time: 2000,
    pll: pll_flags::HZ_100,
};

pub const FAST_LUT: Lut = Lut {
    vcom: [
        0x00, 0x04, 0x04, 0x07, 0x00, 0x01, 0x00, 0x0c, 0x0c, 0x00, 0x00, 0x02, 0x00, 0x04, 0x04,
        0x07, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    ],
    ww: [
        0x54, 0x04, 0x04, 0x07, 0x00, 0x01, 0x60, 0x0c, 0x0c, 0x00, 0x00, 0x02, 0xa8, 0x04, 0x04,
        0x07, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    ],
    bw: [
        0x54, 0x04, 0x04, 0x07, 0x00, 0x01, 0x60, 0x0c, 0x0c, 0x00, 0x00, 0x02, 0xa8, 0x04, 0x04,
        0x07, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    ],
    wb: [
        0xa8, 0x04, 0x04, 0x07, 0x00, 0x01, 0x60, 0x0c, 0x0c, 0x00, 0x00, 0x02, 0x54, 0x04, 0x04,
        0x07, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    ],
    bb: [
        0xa8, 0x04, 0x04, 0x07, 0x00, 0x01, 0x60, 0x0c, 0x0c, 0x00, 0x00, 0x02, 0x54, 0x04, 0x04,
        0x07, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    ],
    update_time: 800,
    pll: pll_flags::HZ_100, // TODO: work out why this doesn't work at 200hz
};

pub const ULTRA_LUT: Lut = Lut {
    vcom: [
        0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x00, 0x02, 0x02,
        0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    ],
    ww: [
        0x54, 0x01, 0x01, 0x02, 0x00, 0x01, 0x60, 0x02, 0x02, 0x00, 0x00, 0x02, 0xa8, 0x02, 0x02,
        0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    ],
    bw: [
        0x54, 0x01, 0x01, 0x02, 0x00, 0x01, 0x60, 0x02, 0x02, 0x00, 0x00, 0x02, 0xa8, 0x02, 0x02,
        0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    ],
    wb: [
        0xa8, 0x01, 0x01, 0x02, 0x00, 0x01, 0x60, 0x02, 0x02, 0x00, 0x00, 0x02, 0x54, 0x02, 0x02,
        0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    ],
    bb: [
        0xa8, 0x01, 0x01, 0x02, 0x00, 0x01, 0x60, 0x02, 0x02, 0x00, 0x00, 0x02, 0x54, 0x02, 0x02,
        0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    ],
    update_time: 250,
    pll: pll_flags::HZ_100, // TODO: work out why these don't work at 200hz
};