From 97f4e2b85f7b4dded6706d246946f304e3da1ecf Mon Sep 17 00:00:00 2001 From: Rishabh Kundu Date: Fri, 26 Mar 2021 15:32:28 +0530 Subject: [PATCH] Some Changes --- src/instructions.rs | 4 ++-- src/sequence_tdo.rs | 40 ++++++++++++++++++++++------------------ 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/instructions.rs b/src/instructions.rs index a162abf..4b6dcf2 100644 --- a/src/instructions.rs +++ b/src/instructions.rs @@ -618,7 +618,7 @@ impl CommandsGeneral { /// eg. for a BK1 Command2 instruction, "current" must be set to /// Command2Selection::BK1. pub fn set_command_2(set: Command2Selection) -> Result { - Ok(Command::new(Self::CND2BKxSEL as u8).args(&[0x77, 0x01, 0x00, 0x00, set as u8])) + Ok(Command::new(Self::CND2BKxSEL as u8).args(&[0x77, 0x01, 0x00, 0x00, 0x10, set as u8])) } } @@ -672,7 +672,7 @@ impl BK0Command2 { let front_porch: u8 = (mode.vtotal - mode.vsync_end).try_into().unwrap(); let back_porch: u8 = (mode.vsync_start - mode.vdisplay).try_into().unwrap(); Self::validate(CMD2, || { - Command::new(Self::PORCTRL as u8).args(&[front_porch, back_porch]) + Command::new(Self::PORCTRL as u8).args(&[front_porch, 0x02]) }) } diff --git a/src/sequence_tdo.rs b/src/sequence_tdo.rs index ab45726..6e9172b 100644 --- a/src/sequence_tdo.rs +++ b/src/sequence_tdo.rs @@ -20,32 +20,32 @@ pub fn init(display: &mut ST7701S, mode: Mode) { display.write_command(BK0Command2::porch_control(&CMD2, &mode)); display.write_command(BK0Command2::inversion_select( &CMD2, - instructions::Inversion::OneDot, + instructions::Inversion::Column, 0x02, )); display.write_command(Ok(Command { address: 0xCC, parameters: vec![0x10], })); - display.write_command(BK0Command2::color_control( - &CMD2, - instructions::PWMPolarity::Low, - instructions::LEDPolarity::Low, - instructions::PixelPinout::Condensed, - instructions::EndPixelFormat::SelfMSB, - )); + //display.write_command(BK0Command2::color_control( + // &CMD2, + // instructions::PWMPolarity::Low, + // instructions::LEDPolarity::Low, + // instructions::PixelPinout::Condensed, + // instructions::EndPixelFormat::SelfMSB, + //)); display.write_command(BK0Command2::positive_gamma_control( &CMD2, &[ - 0x02, 0x13, 0x1B, 0x0D, 0x10, 0x05, 0x08, 0x07, 0x07, 0x24, 0x04, 0x11, 0x0E, 0x2C, 0x33, - 0x1D, + 0x00, 0x11, 0x16, 0x0e, 0x11, 0x06, 0x05, 0x09, 0x08, 0x21, 0x06, 0x13, 0x10, 0x29, 0x31, + 0x18, ], )); display.write_command(BK0Command2::negative_gamma_control( &CMD2, &[ - 0xB1, 0x05, 0x13, 0x1B, 0x0D, 0x11, 0x05, 0x08, 0x07, 0x07, 0x24, 0x04, 0x11, 0x0E, 0x2C, - 0x33, 0x1D, + 0x00, 0x11, 0x16, 0x0e, 0x11, 0x07, 0x05, 0x09, 0x09, 0x21, 0x05, 0x13, 0x11, 0x2a, 0x31, + 0x18, ], )); @@ -53,8 +53,8 @@ pub fn init(display: &mut ST7701S, mode: Mode) { display.write_command(CommandsGeneral::set_command_2(Command2Selection::BK1)); CMD2 = Command2Selection::BK1; - display.write_command(BK1Command2::set_vop_amplitude(&CMD2, 0x5d)); - display.write_command(BK1Command2::set_vcom_amplitude(&CMD2, 0x43)); + display.write_command(BK1Command2::set_vop_amplitude(&CMD2, 0x6d)); + display.write_command(BK1Command2::set_vcom_amplitude(&CMD2, 0x37)); display.write_command(BK1Command2::set_vgh_voltage(&CMD2, 0x81)); display.write_command(BK1Command2::test_command_setting(&CMD2)); display.write_command(BK1Command2::set_vgl_voltage(&CMD2, 0x43)); @@ -70,8 +70,8 @@ pub fn init(display: &mut ST7701S, mode: Mode) { instructions::VoltageAVDD::Pos6_6, instructions::VoltageAVCL::Neg4_4, )); - display.write_command(BK1Command2::set_pre_drive_timing_one(&CMD2, 0x08)); - display.write_command(BK1Command2::set_pre_drive_timing_two(&CMD2, 0x08)); + display.write_command(BK1Command2::set_pre_drive_timing_one(&CMD2, 0x78)); + display.write_command(BK1Command2::set_pre_drive_timing_two(&CMD2, 0x78)); display.write_command(Ok(Command { address: 0xD0, parameters: vec![0x88], @@ -137,6 +137,10 @@ pub fn init(display: &mut ST7701S, mode: Mode) { address: 0xEF, parameters: vec![0x10, 0x0D, 0x04, 0x08, 0x3F, 0x1F], })); + display.write_command(Ok(Command { + address: 0xFF, + parameters: vec![0x77, 0x01, 0x00, 0x00, 0x13], + })); // Set Command2 for BK3 display.write_command(CommandsGeneral::set_command_2(Command2Selection::BK1)); @@ -156,9 +160,9 @@ pub fn init(display: &mut ST7701S, mode: Mode) { display.write_command(CommandsGeneral::display_on()); display.write_command(CommandsGeneral::display_data_control( instructions::ScanDirection::Normal, - instructions::ColorOrder::Rgb, + instructions::ColorOrder::Bgr, )); display.write_command(CommandsGeneral::set_color_mode( - instructions::BitsPerPixel::Rgb666, + instructions::BitsPerPixel::Rgb888, )); }