This repository has been archived on 2026-08-31. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
donglora/vendor/ssd1306/src/i2c_interface.rs
T
swaitsandClaude Opus 4.6 3102fc747a feat: add display UI with splash screen, dashboard, and RSSI sparkline
Implement full SSD1306 OLED display support:
- Splash screen on boot (1.5s) with project name, version, board
- Dashboard showing radio state, config, counters, RSSI/SNR
- RSSI history sparkline (64-sample ring buffer, 2px-wide bars)
- DisplayOn/DisplayOff host commands routed via dedicated channel
- Pure render functions against generic DrawTarget (no hardware coupling)
- Display on/off control bypasses radio task entirely

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 20:42:54 -06:00

65 lines
2.0 KiB
Rust

//! I2C interface factory
use display_interface_i2c::I2CInterface;
/// Helper struct to create preconfigured I2C interfaces for the display.
#[derive(Debug, Copy, Clone)]
pub struct I2CDisplayInterface(());
impl I2CDisplayInterface {
/// Create new builder with a default I2C address of 0x3C
#[cfg(not(feature = "async"))]
#[allow(clippy::new_ret_no_self)]
// pub fn with_i2c<I>(i2c: I) -> I2CInterface<I> // alternative, but breaking change
pub fn new<I>(i2c: I) -> I2CInterface<I>
where
I: embedded_hal::i2c::I2c,
{
Self::new_custom_address(i2c, 0x3C)
}
#[cfg(feature = "async")]
#[allow(clippy::new_ret_no_self)]
/// Create a new async I2C interface with the address 0x3D
pub fn new<I>(i2c: I) -> I2CInterface<I>
where
I: embedded_hal_async::i2c::I2c,
{
Self::new_custom_address(i2c, 0x3C)
}
#[cfg(not(feature = "async"))]
/// Create a new I2C interface with the alternate address 0x3D as specified in the datasheet.
pub fn new_alternate_address<I>(i2c: I) -> I2CInterface<I>
where
I: embedded_hal::i2c::I2c,
{
Self::new_custom_address(i2c, 0x3D)
}
#[cfg(feature = "async")]
/// Create a new async I2C interface with the alternate address 0x3D as specified in the datasheet.
pub fn new_alternate_address<I>(i2c: I) -> I2CInterface<I>
where
I: embedded_hal_async::i2c::I2c,
{
Self::new_custom_address(i2c, 0x3D)
}
#[cfg(not(feature = "async"))]
/// Create a new I2C interface with a custom address.
pub fn new_custom_address<I>(i2c: I, address: u8) -> I2CInterface<I>
where
I: embedded_hal::i2c::I2c,
{
I2CInterface::new(i2c, address, 0x40)
}
#[cfg(feature = "async")]
/// Create a new async I2C interface with a custom address.
pub fn new_custom_address<I>(i2c: I, address: u8) -> I2CInterface<I>
where
I: embedded_hal_async::i2c::I2c,
{
I2CInterface::new(i2c, address, 0x40)
}
}