Adafruit 7segment backpack Hal
Additional features on top of the ht16k33 crate to drive an Adafruit 7-segment LED Alphanumeric Backpack using traits from embedded-hal.
Derived from the adafruit-alphanum4 crate and modified for the 7-segment backpacks.
Features
- Sending a
u8to one of the 4 segments. Limited to 0x00 to 0x0F. - Sending an
AsciiCharto one of the 4 segments. Limited to ascii hex chars and - sign. - Setting or unsetting the dot associated with one of the 4 segments.
- Setting or unsetting the colon.
- Formatting a
f32to 1 to 4 segments
Usage
Embedded platforms
Example on a STM32F4-Discovery board
For examples on other platforms see the ht16k33 crate.
Cargo.toml dependencies example:
[]
= { = "0.4.0", = false }
= { = "0.1.0", = false }
= "0.2.3"
= "0.6.2"
= "0.6.12"
= "0.2.0"
[]
= "0.8"
= ["rt", "stm32f407"]
Test code:
use panic_halt as _;
use cortex_m;
use entry;
use stm32f4xx_hal as hal;
use crate;
use ;
use ;
pub use ;
!
All platforms, using I2C simulation
use I2cMock;
use ;
use ;
// The I2C device address.
const DISP_I2C_ADDR: u8 = 112;
// Create a mock I2C device.
let mut i2c = new;
let mut ht16k33 = HT16K33new;
ht16k33.initialize.expect;
ht16k33.set_display.expect;
ht16k33.set_dimming.expect;
// Sending individual digits
ht16k33.update_buffer_with_digit;
ht16k33.update_buffer_with_digit;
ht16k33.update_buffer_with_digit;
ht16k33.update_buffer_with_digit;
// Note: none of the above methods actually commit the buffer to the display,
// call write_display_buffer to actually send it to the display
ht16k33.write_display_buffer.unwrap
Performance warning
Due to the api of the ht16k33 crate the display buffer is not directly accessible so each LED that makes up the character is updated sequentially. The way the hardware on this backpack is set up allows a character to be updated by setting a single 16-bit value in the buffer. Iterating over each bit of the 16 every update is clearly not optimal but it's sufficiently fast for my current usage. If the ht16k33 crate is updated to grant mut access to the buffer this can be improved.
Release History
This is a changelog describing the most important changes per release.
Version 0.1.0 — August 7th, 2020
- First version
License
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.