Add TearingMode
This commit is contained in:
parent
1cdd390440
commit
854efe3d0f
@ -119,6 +119,8 @@ pub enum Command {
|
||||
PTLAR = 0x30,
|
||||
VSCRDEF = 0x33,
|
||||
ColorMode = 0x3A,
|
||||
TearingOff = 0x34,
|
||||
TearingOn = 0x35,
|
||||
MADCTL = 0x36,
|
||||
VSCSAD = 0x37,
|
||||
// MadCTLMY = 0x80,
|
||||
@ -188,6 +190,12 @@ pub struct SetAddressMode {
|
||||
pub refresh_order: RefreshOrder,
|
||||
}
|
||||
|
||||
pub enum TearingMode {
|
||||
Off,
|
||||
Horizontal,
|
||||
HorizontalAndVertical,
|
||||
}
|
||||
|
||||
impl SetAddressMode {
|
||||
pub fn into_madctl(&self) -> u8 {
|
||||
let mut result = 0;
|
||||
@ -296,6 +304,21 @@ impl<'d, DM: DriverMode, T: DelayNs> Display<'d, DM, T> {
|
||||
self.write(Writeable::Data(&[mode & 0x77]));
|
||||
}
|
||||
|
||||
pub fn set_tearing(&mut self, tearing: TearingMode) {
|
||||
let cmd = match tearing {
|
||||
TearingMode::Off => Command::TearingOff,
|
||||
TearingMode::Horizontal => Command::TearingOn,
|
||||
TearingMode::HorizontalAndVertical => Command::TearingOn,
|
||||
};
|
||||
self.write(Writeable::Command(cmd));
|
||||
|
||||
match tearing {
|
||||
TearingMode::Off => {}
|
||||
TearingMode::Horizontal => self.write(Writeable::Data(&[0])),
|
||||
TearingMode::HorizontalAndVertical => self.write(Writeable::Data(&[1])),
|
||||
}
|
||||
}
|
||||
|
||||
fn set_columns(&mut self, start: u16, end: u16) {
|
||||
let [start1, start2] = start.to_be_bytes();
|
||||
let [end1, end2] = end.to_be_bytes();
|
||||
|
||||
@ -94,6 +94,8 @@ fn main() -> ! {
|
||||
color_order: display::ColorOrder::Bgr,
|
||||
..Default::default()
|
||||
});
|
||||
display.set_tearing(display::TearingMode::Horizontal);
|
||||
|
||||
display.draw_rect(
|
||||
Position::new(0, 0),
|
||||
Position::new(32, 32),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user