reflow-firmware2.0/src/st7735/commands.rs

97 lines
1.7 KiB
Rust

// ST7735 commands
pub enum Command {
NOP,
SWRESET,
RDDID,
RDDST,
SLPIN,
SLPOUT,
PTLON,
NORON,
INVOFF,
INVON,
DISPOFF,
DISPON,
CASET([u8; 4]),
RASET([u8; 4]),
RAMWR,
RAMRD,
PTLAR,
COLMOD(u8),
MADCTL(u8),
FRMCTR1([u8; 3]),
FRMCTR2([u8; 3]),
FRMCTR3([u8; 6]),
INVCTR(u8),
DISSET5([u8; 2]),
PWCTR1([u8; 2]),
PWCTR2(u8),
PWCTR3([u8; 2]),
PWCTR4([u8; 2]),
PWCTR5([u8; 2]),
PWCTR6([u8; 2]),
VMCTR1([u8; 2]),
RDID1,
RDID2,
RDID3,
RDID4,
GMCTRP1([u8; 16]),
GMCTRN1([u8; 16]),
}
pub fn command_to_byte(cmd : &Command) -> u8 {
match cmd {
Command::NOP => 0x00,
Command::SWRESET => 0x01,
Command::RDDID => 0x04,
Command::RDDST => 0x09,
Command::SLPIN => 0x10,
Command::SLPOUT => 0x11,
Command::PTLON => 0x12,
Command::NORON => 0x13,
Command::INVOFF => 0x20,
Command::INVON => 0x21,
Command::DISPOFF => 0x28,
Command::DISPON => 0x29,
Command::CASET(_) => 0x2A,
Command::RASET(_) => 0x2B,
Command::RAMWR => 0x2C,
Command::RAMRD => 0x2E,
Command::PTLAR => 0x30,
Command::COLMOD(_) => 0x3A,
Command::MADCTL(_) => 0x36,
Command::FRMCTR1(_) => 0xB1,
Command::FRMCTR2(_) => 0xB2,
Command::FRMCTR3(_) => 0xB3,
Command::INVCTR(_) => 0xB4,
Command::DISSET5(_) => 0xB6,
Command::PWCTR1(_) => 0xC0,
Command::PWCTR2(_) => 0xC1,
Command::PWCTR3(_) => 0xC2,
Command::PWCTR4(_) => 0xC3,
Command::PWCTR5(_) => 0xC4,
Command::PWCTR6(_) => 0xFC,
Command::VMCTR1(_) => 0xC5,
Command::RDID1 => 0xDA,
Command::RDID2 => 0xDB,
Command::RDID3 => 0xDC,
Command::RDID4 => 0xDD,
Command::GMCTRP1(_) => 0xE0,
Command::GMCTRN1(_) => 0xE1
}
}