-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
308 additions
and
500 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,5 +22,5 @@ optional = true | |
version = "0.7.16" | ||
|
||
[features] | ||
default = ["batch"] | ||
#default = ["batch"] | ||
batch = ["heapless"] |
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,53 @@ | ||
use display_interface::WriteOnlyDataCommand; | ||
use embedded_graphics_core::prelude::*; | ||
use embedded_hal::blocking::delay::DelayUs; | ||
use embedded_hal::digital::v2::OutputPin; | ||
|
||
use crate::{error::InitError, Display, Error}; | ||
|
||
mod ili9341; | ||
mod ili934x; | ||
|
||
pub use ili9341::ILI9341; | ||
|
||
pub enum NoResetPin {} | ||
|
||
impl OutputPin for NoResetPin { | ||
type Error = core::convert::Infallible; | ||
|
||
fn set_low(&mut self) -> Result<(), Self::Error> { | ||
Ok(()) | ||
} | ||
|
||
fn set_high(&mut self) -> Result<(), Self::Error> { | ||
Ok(()) | ||
} | ||
} | ||
|
||
pub trait Controller: Sized + private::Sealed { | ||
type Color: PixelColor; | ||
|
||
const FRAMEBUFFER_SIZE: (u16, u16); | ||
|
||
fn init<DI, RST, DELAY>( | ||
display: &mut Display<Self, DI, RST>, | ||
delay: &mut DELAY, | ||
) -> Result<(), InitError<RST::Error>> | ||
where | ||
DI: WriteOnlyDataCommand, | ||
RST: OutputPin, | ||
DELAY: DelayUs<u32>; | ||
|
||
fn write_pixels<DI, RST, I>( | ||
display: &mut Display<Self, DI, RST>, | ||
colors: I, | ||
) -> Result<(), Error> | ||
where | ||
DI: WriteOnlyDataCommand, | ||
RST: OutputPin, | ||
I: IntoIterator<Item = Self::Color>; | ||
} | ||
|
||
mod private { | ||
pub trait Sealed {} | ||
} |
File renamed without changes.
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,83 @@ | ||
use core::marker::PhantomData; | ||
|
||
use display_interface::WriteOnlyDataCommand; | ||
use embedded_graphics_core::pixelcolor::{Rgb565, Rgb666}; | ||
use embedded_hal::{blocking::delay::DelayUs, digital::v2::OutputPin}; | ||
|
||
use crate::{ | ||
controllers::{ili934x, Controller}, | ||
dcs::{BitsPerPixel, PixelFormat}, | ||
error::InitError, | ||
Display, Error, | ||
}; | ||
|
||
use super::private::Sealed; | ||
|
||
/// ILI9341 controller. | ||
pub struct ILI9341<C> { | ||
color_type: PhantomData<C>, | ||
} | ||
|
||
impl Controller for ILI9341<Rgb565> { | ||
type Color = Rgb565; | ||
const FRAMEBUFFER_SIZE: (u16, u16) = (240, 320); | ||
|
||
fn init<DI, RST, DELAY>( | ||
display: &mut Display<Self, DI, RST>, | ||
delay: &mut DELAY, | ||
) -> Result<(), InitError<RST::Error>> | ||
where | ||
DI: WriteOnlyDataCommand, | ||
RST: OutputPin, | ||
DELAY: DelayUs<u32>, | ||
{ | ||
display.reset(delay)?; | ||
|
||
let pf = PixelFormat::with_all(BitsPerPixel::from_rgb_color::<Rgb565>()); | ||
ili934x::init_common(display, delay, pf).map_err(Into::into) | ||
} | ||
|
||
fn write_pixels<DI, RST, I>( | ||
display: &mut Display<Self, DI, RST>, | ||
colors: I, | ||
) -> Result<(), Error> | ||
where | ||
DI: WriteOnlyDataCommand, | ||
I: IntoIterator<Item = Rgb565>, | ||
{ | ||
ili934x::write_pixels_rgb565(display, colors) | ||
} | ||
} | ||
|
||
impl Controller for ILI9341<Rgb666> { | ||
type Color = Rgb666; | ||
const FRAMEBUFFER_SIZE: (u16, u16) = (240, 320); | ||
|
||
fn init<DI, RST, DELAY>( | ||
display: &mut Display<Self, DI, RST>, | ||
delay: &mut DELAY, | ||
) -> Result<(), InitError<RST::Error>> | ||
where | ||
DI: WriteOnlyDataCommand, | ||
RST: OutputPin, | ||
DELAY: DelayUs<u32>, | ||
{ | ||
display.reset(delay)?; | ||
|
||
let pf = PixelFormat::with_all(BitsPerPixel::from_rgb_color::<Rgb666>()); | ||
ili934x::init_common(display, delay, pf).map_err(Into::into) | ||
} | ||
|
||
fn write_pixels<DI, RST, I>( | ||
display: &mut Display<Self, DI, RST>, | ||
colors: I, | ||
) -> Result<(), Error> | ||
where | ||
DI: WriteOnlyDataCommand, | ||
I: IntoIterator<Item = Rgb666>, | ||
{ | ||
ili934x::write_pixels_rgb666(display, colors) | ||
} | ||
} | ||
|
||
impl<C> Sealed for ILI9341<C> {} |
File renamed without changes.
Oops, something went wrong.