Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change to embedded-graphics-core and update embedded-hal #24

Merged
merged 2 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ readme = "README.md"
documentation = "https://docs.rs/st7735-lcd"

[dependencies]
embedded-hal = "0.2"
nb = "0.1"
embedded-hal = "1.0.0"
nb = "1.1.0"

[dependencies.embedded-graphics]
version = "0.8"
[dependencies.embedded-graphics-core]
version = "0.4"
optional = true

[features]
default = ["graphics"]
graphics = ["embedded-graphics"]
graphics = ["embedded-graphics-core"]
22 changes: 11 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ pub mod instruction;

use crate::instruction::Instruction;

use embedded_hal::blocking::delay::DelayMs;
use embedded_hal::blocking::spi;
use embedded_hal::digital::v2::OutputPin;
use embedded_hal::delay::DelayNs;
use embedded_hal::spi;
use embedded_hal::digital::OutputPin;

/// ST7735 driver to connect to TFT displays.
pub struct ST7735<SPI, DC, RST>
where
SPI: spi::Write<u8>,
SPI: spi::SpiDevice,
DC: OutputPin,
RST: OutputPin,
{
Expand Down Expand Up @@ -50,7 +50,7 @@ pub enum Orientation {

impl<SPI, DC, RST> ST7735<SPI, DC, RST>
where
SPI: spi::Write<u8>,
SPI: spi::SpiDevice,
DC: OutputPin,
RST: OutputPin,
{
Expand Down Expand Up @@ -82,7 +82,7 @@ where
/// Runs commands to initialize the display.
pub fn init<DELAY>(&mut self, delay: &mut DELAY) -> Result<(), ()>
where
DELAY: DelayMs<u8>,
DELAY: DelayNs,
{
self.hard_reset(delay)?;
self.write_command(Instruction::SWRESET, &[])?;
Expand Down Expand Up @@ -117,7 +117,7 @@ where

pub fn hard_reset<DELAY>(&mut self, delay: &mut DELAY) -> Result<(), ()>
where
DELAY: DelayMs<u8>,
DELAY: DelayNs,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for changing to DelayNs? I think maybe not all devices support nanosecond resolution and we definitely don't need it here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it is the only trait which can be implemented in 1.0.0 if I haven't missed something.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see.

{
self.rst.set_high().map_err(|_| ())?;
delay.delay_ms(10);
Expand Down Expand Up @@ -245,9 +245,9 @@ where
}

#[cfg(feature = "graphics")]
extern crate embedded_graphics;
extern crate embedded_graphics_core;
#[cfg(feature = "graphics")]
use self::embedded_graphics::{
use self::embedded_graphics_core::{
draw_target::DrawTarget,
pixelcolor::{
raw::{RawData, RawU16},
Expand All @@ -260,7 +260,7 @@ use self::embedded_graphics::{
#[cfg(feature = "graphics")]
impl<SPI, DC, RST> DrawTarget for ST7735<SPI, DC, RST>
where
SPI: spi::Write<u8>,
SPI: spi::SpiDevice,
DC: OutputPin,
RST: OutputPin,
{
Expand Down Expand Up @@ -327,7 +327,7 @@ where
#[cfg(feature = "graphics")]
impl<SPI, DC, RST> OriginDimensions for ST7735<SPI, DC, RST>
where
SPI: spi::Write<u8>,
SPI: spi::SpiDevice,
DC: OutputPin,
RST: OutputPin,
{
Expand Down