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

remove HAL traits (unneeded with updates to ht16k33) #1

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ documentation = "https://docs.rs/adafruit-7segment"
homepage = "https://github.com/kallemooo/adafruit-7segment"

[dependencies]
ht16k33 = { version = "0.4.0", default-features = false }
embedded-hal = { version = "0.2.3" }
ht16k33 = { version = "0.4.0", default-features = false, git="https://github.com/danjl1100/ht16k33", branch = "data-only-methods" }
ascii = { version = "1.0.0", default-features = false }

[dev-dependencies]
embedded-hal = { version = "1.0.0-rc.1" }

[dev-dependencies.embedded-hal-mock]
version = "0.4"

Expand Down
18 changes: 4 additions & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ mod fonts;
use fonts::*;

pub use ascii::{AsciiChar, ToAsciiChar};
use embedded_hal::blocking::i2c::{Write, WriteRead};
use ht16k33::{DisplayData, DisplayDataAddress, LedLocation, COMMONS_SIZE, HT16K33};

/// Possible errors returned by this crate.
Expand All @@ -163,7 +162,7 @@ pub enum Error {
}

/// Trait enabling using the Adafruit 7-segment LED numeric Backpack.
pub trait SevenSegment<E> {
pub trait SevenSegment {
/// Update the buffer with a digit value (0 to F) at the specified index.
fn update_buffer_with_digit(&mut self, index: Index, value: u8);
/// Update the buffer to turn the . on or off at the specified index.
Expand Down Expand Up @@ -224,21 +223,15 @@ const DOT_BIT: u8 = 7;

const COLON_BIT: u8 = 1;

fn set_bit<I2C, E>(display: &mut HT16K33<I2C>, index: u8, bit: u8, on: bool)
where
I2C: Write<Error = E> + WriteRead<Error = E>,
{
fn set_bit<I2C>(display: &mut HT16K33<I2C>, index: u8, bit: u8, on: bool) {
debug_assert!((bit as usize) < (COMMONS_SIZE * 2));
let index = index * 2;
let row = DisplayDataAddress::from_bits_truncate(if bit < 8 { index } else { index + 1 });
let common = DisplayData::from_bits_truncate(1 << (bit % 8));
display.update_display_buffer(LedLocation { row, common }, on);
}

fn update_bits<I2C, E>(display: &mut HT16K33<I2C>, index: Index, bits: u8)
where
I2C: Write<Error = E> + WriteRead<Error = E>,
{
fn update_bits<I2C>(display: &mut HT16K33<I2C>, index: Index, bits: u8) {
let pos: u8;
if index > Index::Two {
// Move one step to compensate for colon at pos 2.
Expand All @@ -252,10 +245,7 @@ where
}
}

impl<I2C, E> SevenSegment<E> for HT16K33<I2C>
where
I2C: Write<Error = E> + WriteRead<Error = E>,
{
impl<I2C> SevenSegment for HT16K33<I2C> {
/// Update the buffer with a hex digit value (0x00 to 0x0F) at the specified index
/// # Arguments
///
Expand Down