pub struct EightSegment<'a> {
pub high_on: bool,
pub seg_a: &'a mut dyn OutputPin,
pub seg_b: &'a mut dyn OutputPin,
pub seg_c: &'a mut dyn OutputPin,
pub seg_d: &'a mut dyn OutputPin,
pub seg_e: &'a mut dyn OutputPin,
pub seg_f: &'a mut dyn OutputPin,
pub seg_g: &'a mut dyn OutputPin,
pub seg_p: &'a mut dyn OutputPin,
}
Expand description
An eight segment display that can display a single digit from 0x0 to 0xF at a time. Intended for use with the HDSP-H101 and HDSP-H103.
The labels on the segments are as described in the H101 and H103 datasheet:
_______
| a |
|f b|
| g |
|-------|
|e c|
| d |
'-------' .
p
Some like the H101 have the segment turned on being pin-low, and some like the H103 have on being pin-high.
Set the high_on
boolean as appropriate.
§Examples
ⓘ
// in this case using the `atsamd21_hal` library to provide access to the pins
// but any embedded-hal implementation should work
let mut peripherals = Peripherals::take().unwrap();
let mut pins = peripherals.PORT.split();
let mut seg_a = pins.pa21.into_open_drain_output(&mut pins.port);
let mut seg_b = pins.pa20.into_open_drain_output(&mut pins.port);
let mut seg_c = pins.pa11.into_open_drain_output(&mut pins.port);
let mut seg_d = pins.pb10.into_open_drain_output(&mut pins.port);
let mut seg_e = pins.pb11.into_open_drain_output(&mut pins.port);
let mut seg_f = pins.pa16.into_open_drain_output(&mut pins.port);
let mut seg_g = pins.pa17.into_open_drain_output(&mut pins.port);
let mut seg_p = pins.pa10.into_open_drain_output(&mut pins.port);
let mut eight_segment = EightSegment {
high_on: false,
seg_a: &mut seg_a,
seg_b: &mut seg_b,
seg_c: &mut seg_c,
seg_d: &mut seg_d,
seg_e: &mut seg_e,
seg_f: &mut seg_f,
seg_g: &mut seg_g,
seg_p: &mut seg_p,
};
eight_segment.blank(); // All segments off
eight_segment.display(0xb, false); // Display 'b' with decimal point off
Fields§
§high_on: bool
§seg_a: &'a mut dyn OutputPin
§seg_b: &'a mut dyn OutputPin
§seg_c: &'a mut dyn OutputPin
§seg_d: &'a mut dyn OutputPin
§seg_e: &'a mut dyn OutputPin
§seg_f: &'a mut dyn OutputPin
§seg_g: &'a mut dyn OutputPin
§seg_p: &'a mut dyn OutputPin
Implementations§
Auto Trait Implementations§
impl<'a> Freeze for EightSegment<'a>
impl<'a> !RefUnwindSafe for EightSegment<'a>
impl<'a> !Send for EightSegment<'a>
impl<'a> !Sync for EightSegment<'a>
impl<'a> Unpin for EightSegment<'a>
impl<'a> !UnwindSafe for EightSegment<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more