-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #166 from rfuest/ili9488
Add support for ILI9488
- Loading branch information
Showing
7 changed files
with
111 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
//! * ILI9341 | ||
//! * ILI9342C | ||
//! * ILI9486 | ||
//! * ILI9488 | ||
//! * RM67162 | ||
//! * ST7735 | ||
//! * ST7789 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use embedded_graphics_core::pixelcolor::{Rgb565, Rgb666}; | ||
use embedded_hal::delay::DelayNs; | ||
|
||
use crate::{ | ||
dcs::{BitsPerPixel, PixelFormat, SetAddressMode}, | ||
interface::Interface, | ||
options::ModelOptions, | ||
}; | ||
|
||
use super::{ili948x, Model}; | ||
|
||
/// ILI9488 display in Rgb565 color mode. | ||
pub struct ILI9488Rgb565; | ||
|
||
/// ILI9488 display in Rgb666 color mode. | ||
pub struct ILI9488Rgb666; | ||
|
||
impl Model for ILI9488Rgb565 { | ||
type ColorFormat = Rgb565; | ||
const FRAMEBUFFER_SIZE: (u16, u16) = (320, 480); | ||
|
||
fn init<DELAY, DI>( | ||
&mut self, | ||
di: &mut DI, | ||
delay: &mut DELAY, | ||
options: &ModelOptions, | ||
) -> Result<SetAddressMode, DI::Error> | ||
where | ||
DELAY: DelayNs, | ||
DI: Interface, | ||
{ | ||
delay.delay_us(120_000); | ||
|
||
let pf = PixelFormat::with_all(BitsPerPixel::from_rgb_color::<Self::ColorFormat>()); | ||
ili948x::init_common(di, delay, options, pf) | ||
} | ||
} | ||
|
||
impl Model for ILI9488Rgb666 { | ||
type ColorFormat = Rgb666; | ||
const FRAMEBUFFER_SIZE: (u16, u16) = (320, 480); | ||
|
||
fn init<DELAY, DI>( | ||
&mut self, | ||
di: &mut DI, | ||
delay: &mut DELAY, | ||
options: &ModelOptions, | ||
) -> Result<SetAddressMode, DI::Error> | ||
where | ||
DELAY: DelayNs, | ||
DI: Interface, | ||
{ | ||
delay.delay_us(120_000); | ||
|
||
let pf = PixelFormat::with_all(BitsPerPixel::from_rgb_color::<Self::ColorFormat>()); | ||
ili948x::init_common(di, delay, options, pf) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use embedded_hal::delay::DelayNs; | ||
|
||
use crate::{ | ||
dcs::{ | ||
EnterNormalMode, ExitSleepMode, InterfaceExt, PixelFormat, SetAddressMode, SetDisplayOn, | ||
SetInvertMode, SetPixelFormat, | ||
}, | ||
interface::Interface, | ||
options::ModelOptions, | ||
}; | ||
|
||
/// Common init for all ILI948x models and color formats. | ||
pub fn init_common<DELAY, DI>( | ||
di: &mut DI, | ||
delay: &mut DELAY, | ||
options: &ModelOptions, | ||
pixel_format: PixelFormat, | ||
) -> Result<SetAddressMode, DI::Error> | ||
where | ||
DELAY: DelayNs, | ||
DI: Interface, | ||
{ | ||
let madctl = SetAddressMode::from(options); | ||
di.write_command(ExitSleepMode)?; // turn off sleep | ||
di.write_command(SetPixelFormat::new(pixel_format))?; // pixel format | ||
di.write_command(madctl)?; // left -> right, bottom -> top RGB | ||
// dcs.write_command(Instruction::VCMOFSET, &[0x00, 0x48, 0x00, 0x48])?; //VCOM Control 1 [00 40 00 40] | ||
// dcs.write_command(Instruction::INVCO, &[0x0])?; //Inversion Control [00] | ||
di.write_command(SetInvertMode::new(options.invert_colors))?; | ||
|
||
// optional gamma setup | ||
// dcs.write_raw(Instruction::PGC, &[0x00, 0x2C, 0x2C, 0x0B, 0x0C, 0x04, 0x4C, 0x64, 0x36, 0x03, 0x0E, 0x01, 0x10, 0x01, 0x00])?; // Positive Gamma Control | ||
// dcs.write_raw(Instruction::NGC, &[0x0F, 0x37, 0x37, 0x0C, 0x0F, 0x05, 0x50, 0x32, 0x36, 0x04, 0x0B, 0x00, 0x19, 0x14, 0x0F])?; // Negative Gamma Control | ||
|
||
di.write_raw(0xB6, &[0b0000_0010, 0x02, 0x3B])?; // DFC | ||
di.write_command(EnterNormalMode)?; // turn to normal mode | ||
di.write_command(SetDisplayOn)?; // turn on display | ||
|
||
// DISPON requires some time otherwise we risk SPI data issues | ||
delay.delay_us(120_000); | ||
|
||
Ok(madctl) | ||
} |