Struct sevseg_3642bs::Display

source ·
pub struct Display<A, B, C, D, E, F, G, SD, D1, D2, D3, D4, DL> { /* private fields */ }
Expand description

To use the display you’ll need to pass the microcontroller’s pins and the delay object in your HAL.

The example uses pins 12-26, but any GPIO pin can be used for any of the fields.

let mut display = SevenSeg::new(
    pins.gpio16.into_push_pull_output(), // Segment A
    pins.gpio17.into_push_pull_output(), // Segment B
    pins.gpio18.into_push_pull_output(), // Segment C
    pins.gpio19.into_push_pull_output(), // Segment D
    pins.gpio20.into_push_pull_output(), // Segment E
    pins.gpio21.into_push_pull_output(), // Segment F
    pins.gpio22.into_push_pull_output(), // Segment G

    pins.gpio26.into_push_pull_output(), // Dots segment

    pins.gpio15.into_push_pull_output(), // Digit 0 common anode
    pins.gpio14.into_push_pull_output(), // Digit 1 common anode
    pins.gpio13.into_push_pull_output(), // Digit 2 common anode
    pins.gpio12.into_push_pull_output(), // Digit 3 common anode

    delay,
    );

Implementations§

source§

impl<A, B, C, D, E, F, G, SD, D1, D2, D3, D4, DL> Display<A, B, C, D, E, F, G, SD, D1, D2, D3, D4, DL>where A: OutputPin, B: OutputPin, C: OutputPin, D: OutputPin, E: OutputPin, F: OutputPin, G: OutputPin, SD: OutputPin, D1: OutputPin, D2: OutputPin, D3: OutputPin, D4: OutputPin, DL: DelayMs<u8>, Infallible: From<<A as OutputPin>::Error> + From<<B as OutputPin>::Error> + From<<C as OutputPin>::Error> + From<<D as OutputPin>::Error> + From<<E as OutputPin>::Error> + From<<F as OutputPin>::Error> + From<<G as OutputPin>::Error> + From<<SD as OutputPin>::Error> + From<<D1 as OutputPin>::Error> + From<<D2 as OutputPin>::Error> + From<<D3 as OutputPin>::Error> + From<<D4 as OutputPin>::Error>,

source

pub const fn new( seg_a: A, seg_b: B, seg_c: C, seg_d: D, seg_e: E, seg_f: F, seg_g: G, seg_dots: SD, dig_1: D1, dig_2: D2, dig_3: D3, dig_4: D4, delay: DL ) -> Self

Creates a new display object from the pins you pass it. Order: A, B, C, D, E, F, G, SD, D1, D2, D3, D4. D1, D2, D3 and D4 are the common anodes.

  _______
/-\__A__/-\
| |     | |
|F|     |B|
| |     | |
\ /-----\ /
/ \__G__/ \
| |     | |
|E|     |C|
| |_____| |
\_/__D__\_/ __
           |SD|
            --
source

pub fn clear(&mut self) -> Result<(), Infallible>

Pulls the common anodes low, turning off the display.

Errors

Will return an error if it fails to set the pins low.

source

pub fn custom(&mut self, digits: [u8; 4]) -> Result<(), Infallible>

You can make your own custom charcaters by writing which segments should turn on:

let letter_a: u8 = SEG_A | SEG_B | SEG_C | SEG_E | SEG_F | SEG_G

The .custom() function modifies the 4 digits, so you’ll have to pass an array with the value for the four digits.

let custom_msg: [u8; 4] = [0, 0, 0, letter_a];
display.custom(custom_msg);
Errors

Will return an error if it fails to set the state of any of the pins

source

pub fn number(&mut self, number: i32) -> Result<(), DisplayErr>

Displays a 4 digit number between -1999 and 9999.

Errors

Will return an error if the number is not in the range or if the .custom() call inside returns an error.

source

pub fn hex(&mut self, number: i32) -> Result<(), DisplayErr>

Displays a hex value between -0x1FFF and 0xFFFF.

Errors

Will return an error if the value is not in the range or if the .custom() call inside returns an error

source

pub fn time( &mut self, left: u8, right: u8, seconds: u8 ) -> Result<(), DisplayErr>

Displays a time value, blinks every second.

Errors

Will return an error if either of the numbers is bigger than 99 or if the .custom() call inside returns an error

Auto Trait Implementations§

§

impl<A, B, C, D, E, F, G, SD, D1, D2, D3, D4, DL> RefUnwindSafe for Display<A, B, C, D, E, F, G, SD, D1, D2, D3, D4, DL>where A: RefUnwindSafe, B: RefUnwindSafe, C: RefUnwindSafe, D: RefUnwindSafe, D1: RefUnwindSafe, D2: RefUnwindSafe, D3: RefUnwindSafe, D4: RefUnwindSafe, DL: RefUnwindSafe, E: RefUnwindSafe, F: RefUnwindSafe, G: RefUnwindSafe, SD: RefUnwindSafe,

§

impl<A, B, C, D, E, F, G, SD, D1, D2, D3, D4, DL> Send for Display<A, B, C, D, E, F, G, SD, D1, D2, D3, D4, DL>where A: Send, B: Send, C: Send, D: Send, D1: Send, D2: Send, D3: Send, D4: Send, DL: Send, E: Send, F: Send, G: Send, SD: Send,

§

impl<A, B, C, D, E, F, G, SD, D1, D2, D3, D4, DL> Sync for Display<A, B, C, D, E, F, G, SD, D1, D2, D3, D4, DL>where A: Sync, B: Sync, C: Sync, D: Sync, D1: Sync, D2: Sync, D3: Sync, D4: Sync, DL: Sync, E: Sync, F: Sync, G: Sync, SD: Sync,

§

impl<A, B, C, D, E, F, G, SD, D1, D2, D3, D4, DL> Unpin for Display<A, B, C, D, E, F, G, SD, D1, D2, D3, D4, DL>where A: Unpin, B: Unpin, C: Unpin, D: Unpin, D1: Unpin, D2: Unpin, D3: Unpin, D4: Unpin, DL: Unpin, E: Unpin, F: Unpin, G: Unpin, SD: Unpin,

§

impl<A, B, C, D, E, F, G, SD, D1, D2, D3, D4, DL> UnwindSafe for Display<A, B, C, D, E, F, G, SD, D1, D2, D3, D4, DL>where A: UnwindSafe, B: UnwindSafe, C: UnwindSafe, D: UnwindSafe, D1: UnwindSafe, D2: UnwindSafe, D3: UnwindSafe, D4: UnwindSafe, DL: UnwindSafe, E: UnwindSafe, F: UnwindSafe, G: UnwindSafe, SD: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.