Some Changes

This commit is contained in:
Rishabh Kundu 2021-03-26 15:32:28 +05:30
parent 3cc0e77074
commit 97f4e2b85f
2 changed files with 24 additions and 20 deletions

View File

@ -618,7 +618,7 @@ impl CommandsGeneral {
/// eg. for a BK1 Command2 instruction, "current" must be set to /// eg. for a BK1 Command2 instruction, "current" must be set to
/// Command2Selection::BK1. /// Command2Selection::BK1.
pub fn set_command_2(set: Command2Selection) -> Result<Command, &'static str> { pub fn set_command_2(set: Command2Selection) -> Result<Command, &'static str> {
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 front_porch: u8 = (mode.vtotal - mode.vsync_end).try_into().unwrap();
let back_porch: u8 = (mode.vsync_start - mode.vdisplay).try_into().unwrap(); let back_porch: u8 = (mode.vsync_start - mode.vdisplay).try_into().unwrap();
Self::validate(CMD2, || { Self::validate(CMD2, || {
Command::new(Self::PORCTRL as u8).args(&[front_porch, back_porch]) Command::new(Self::PORCTRL as u8).args(&[front_porch, 0x02])
}) })
} }

View File

@ -20,32 +20,32 @@ pub fn init(display: &mut ST7701S, mode: Mode) {
display.write_command(BK0Command2::porch_control(&CMD2, &mode)); display.write_command(BK0Command2::porch_control(&CMD2, &mode));
display.write_command(BK0Command2::inversion_select( display.write_command(BK0Command2::inversion_select(
&CMD2, &CMD2,
instructions::Inversion::OneDot, instructions::Inversion::Column,
0x02, 0x02,
)); ));
display.write_command(Ok(Command { display.write_command(Ok(Command {
address: 0xCC, address: 0xCC,
parameters: vec![0x10], parameters: vec![0x10],
})); }));
display.write_command(BK0Command2::color_control( //display.write_command(BK0Command2::color_control(
&CMD2, // &CMD2,
instructions::PWMPolarity::Low, // instructions::PWMPolarity::Low,
instructions::LEDPolarity::Low, // instructions::LEDPolarity::Low,
instructions::PixelPinout::Condensed, // instructions::PixelPinout::Condensed,
instructions::EndPixelFormat::SelfMSB, // instructions::EndPixelFormat::SelfMSB,
)); //));
display.write_command(BK0Command2::positive_gamma_control( display.write_command(BK0Command2::positive_gamma_control(
&CMD2, &CMD2,
&[ &[
0x02, 0x13, 0x1B, 0x0D, 0x10, 0x05, 0x08, 0x07, 0x07, 0x24, 0x04, 0x11, 0x0E, 0x2C, 0x33, 0x00, 0x11, 0x16, 0x0e, 0x11, 0x06, 0x05, 0x09, 0x08, 0x21, 0x06, 0x13, 0x10, 0x29, 0x31,
0x1D, 0x18,
], ],
)); ));
display.write_command(BK0Command2::negative_gamma_control( display.write_command(BK0Command2::negative_gamma_control(
&CMD2, &CMD2,
&[ &[
0xB1, 0x05, 0x13, 0x1B, 0x0D, 0x11, 0x05, 0x08, 0x07, 0x07, 0x24, 0x04, 0x11, 0x0E, 0x2C, 0x00, 0x11, 0x16, 0x0e, 0x11, 0x07, 0x05, 0x09, 0x09, 0x21, 0x05, 0x13, 0x11, 0x2a, 0x31,
0x33, 0x1D, 0x18,
], ],
)); ));
@ -53,8 +53,8 @@ pub fn init(display: &mut ST7701S, mode: Mode) {
display.write_command(CommandsGeneral::set_command_2(Command2Selection::BK1)); display.write_command(CommandsGeneral::set_command_2(Command2Selection::BK1));
CMD2 = Command2Selection::BK1; CMD2 = Command2Selection::BK1;
display.write_command(BK1Command2::set_vop_amplitude(&CMD2, 0x5d)); display.write_command(BK1Command2::set_vop_amplitude(&CMD2, 0x6d));
display.write_command(BK1Command2::set_vcom_amplitude(&CMD2, 0x43)); display.write_command(BK1Command2::set_vcom_amplitude(&CMD2, 0x37));
display.write_command(BK1Command2::set_vgh_voltage(&CMD2, 0x81)); display.write_command(BK1Command2::set_vgh_voltage(&CMD2, 0x81));
display.write_command(BK1Command2::test_command_setting(&CMD2)); display.write_command(BK1Command2::test_command_setting(&CMD2));
display.write_command(BK1Command2::set_vgl_voltage(&CMD2, 0x43)); 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::VoltageAVDD::Pos6_6,
instructions::VoltageAVCL::Neg4_4, instructions::VoltageAVCL::Neg4_4,
)); ));
display.write_command(BK1Command2::set_pre_drive_timing_one(&CMD2, 0x08)); display.write_command(BK1Command2::set_pre_drive_timing_one(&CMD2, 0x78));
display.write_command(BK1Command2::set_pre_drive_timing_two(&CMD2, 0x08)); display.write_command(BK1Command2::set_pre_drive_timing_two(&CMD2, 0x78));
display.write_command(Ok(Command { display.write_command(Ok(Command {
address: 0xD0, address: 0xD0,
parameters: vec![0x88], parameters: vec![0x88],
@ -137,6 +137,10 @@ pub fn init(display: &mut ST7701S, mode: Mode) {
address: 0xEF, address: 0xEF,
parameters: vec![0x10, 0x0D, 0x04, 0x08, 0x3F, 0x1F], 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 // Set Command2 for BK3
display.write_command(CommandsGeneral::set_command_2(Command2Selection::BK1)); 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_on());
display.write_command(CommandsGeneral::display_data_control( display.write_command(CommandsGeneral::display_data_control(
instructions::ScanDirection::Normal, instructions::ScanDirection::Normal,
instructions::ColorOrder::Rgb, instructions::ColorOrder::Bgr,
)); ));
display.write_command(CommandsGeneral::set_color_mode( display.write_command(CommandsGeneral::set_color_mode(
instructions::BitsPerPixel::Rgb666, instructions::BitsPerPixel::Rgb888,
)); ));
} }