| Crates.io | as1115 |
| lib.rs | as1115 |
| version | 0.1.0 |
| created_at | 2025-08-04 23:39:32.025467+00 |
| updated_at | 2025-08-04 23:39:32.025467+00 |
| description | Rust driver for ams AS1115 LED Driver IC |
| homepage | |
| repository | https://github.com/nonik0/as1115 |
| max_upload_size | |
| id | 1781312 |
| size | 31,125 |
Driver for ams AS1115 LED Driver IC. Many thanks to @blemasle's existing AS1115 Arduino library, which I used as a reference implementation.
To install this driver in your project add the following line to your Cargo.toml's dependencies table:
as1115 = "0.1.0"
For projects needing float support (increases binary size, avoid using on MCUs without native float support):
as1115 = { version = "0.1.0", features = ["display_float_value"] }
The AS1115 uses I2C for communication and requires access to an I2C bus that implements the embedded_hal::i2c::I2c trait. This allows the driver to work with any HAL that provides I2C functionality.
use as1115::AS1115;
const NUM_DIGITS: u8 = 4; // AS1115 supports 1-8 seven-segment displays
const INTENSITY: u8 = 3; // global brightness [0-15]
let mut as1115: AS1115<_, NUM_DIGITS> = AS1115::new(i2c_device);
as1115.init(INTENSITY).unwrap();
as1115.display_value(1234).unwrap();
as1115.display_hex_value(0xDEAD).unwrap();
as1115.display_ascii(b"HI").unwrap();
// Requires "display_float_value" feature
as1115.display_float_value(12.34, 2).unwrap();
Or to specify an address using the self-addressing feature (also needs pins wired correctly):
use as1115::AS1115;
const NUM_DIGITS: u8 = 4;
const INTENSITY: u8 = 2;
const I2C_ADDR: u8 = 0x01;
let mut as1115: AS1115<_, NUM_DIGITS> = AS1115::new_with_addr(i2c_device, I2C_ADDR);
as1115.init(INTENSITY).unwrap();
as1115.display_value(4321).unwrap();
as1115.display_hex_value(0xBEEF).unwrap();
// Requires "display_float_value" feature
as1115.display_float_value(432.1, 1).unwrap();