[][src]Crate segment_display

A platform agnostic driver to interface with 7-segments displays connected to shift registers

This is work-in-progress!

Example


#![no_main]
#![no_std]

extern crate cortex_m;
extern crate cortex_m_rt;
extern crate nucleo_f401re as board;
extern crate panic_semihosting;

use cortex_m_rt::entry;

use board::hal::delay::Delay;
use board::hal::prelude::*;
use board::hal::stm32;
use board::spi::{self, Spi};
use cortex_m::peripheral::Peripherals;

use segment_display::SegmentDisplay;


#[entry]
fn main() -> ! {
   let device = stm32::Peripherals::take().unwrap();
   let core = Peripherals::take().unwrap();

   let rcc = device.RCC.constrain();
   let clocks = rcc.cfgr.sysclk(84.mhz()).freeze();

   let gpiob = device.GPIOB.split();
   let sck = gpiob.pb3.into_alternate_af5();
   let miso = spi::NoMiso;
   let mosi = gpiob.pb5.into_alternate_af5();
   let latch = gpiob.pb4.into_push_pull_output();

   let spi = Spi::spi1(
       device.SPI1,
       (sck, miso, mosi),
       spi::Mode { polarity: spi::Polarity::IdleHigh, phase: spi::Phase::CaptureOnFirstTransition, },
       4_000_000.hz(),
       clocks,
   );

   let mut segment_display = SegmentDisplay::new(spi, latch);
   let mut delay = Delay::new(core.SYST, clocks);

   segment_display.write_str("HELO");

   loop {
       segment_display.refresh().unwrap();
       delay.delay_us(1000_u16);
   }
}

Structs

SegmentDisplay