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>
65 lines
1.7 KiB
Rust
65 lines
1.7 KiB
Rust
//! Endlessly fill the screen with characters from the alphabet
|
|
//!
|
|
//! This example is for the STM32F103 "Blue Pill" board using I2C1.
|
|
//!
|
|
//! Wiring connections are as follows for a CRIUS-branded display:
|
|
//!
|
|
//! ```
|
|
//! Display -> Blue Pill
|
|
//! (black) GND -> GND
|
|
//! (red) +5V -> VCC
|
|
//! (yellow) SDA -> PB7
|
|
//! (green) SCL -> PB6
|
|
//! ```
|
|
//!
|
|
//! Run on a Blue Pill with `cargo run --example async_terminal_i2c`.
|
|
|
|
#![no_std]
|
|
#![no_main]
|
|
|
|
use defmt_rtt as _;
|
|
use embassy_executor::Spawner;
|
|
use embassy_stm32::{bind_interrupts, i2c, peripherals, time::Hertz};
|
|
use panic_probe as _;
|
|
use ssd1306::{prelude::*, I2CDisplayInterface, Ssd1306Async};
|
|
|
|
bind_interrupts!(struct Irqs {
|
|
I2C1_EV => i2c::EventInterruptHandler<peripherals::I2C1>;
|
|
I2C1_ER => i2c::ErrorInterruptHandler<peripherals::I2C1>;
|
|
});
|
|
|
|
#[embassy_executor::main]
|
|
async fn main(_spawner: Spawner) {
|
|
let p = embassy_stm32::init(Default::default());
|
|
let i2c = embassy_stm32::i2c::I2c::new(
|
|
p.I2C1,
|
|
p.PB6,
|
|
p.PB7,
|
|
Irqs,
|
|
p.DMA1_CH6,
|
|
p.DMA1_CH7,
|
|
Hertz::khz(400),
|
|
Default::default(),
|
|
);
|
|
|
|
let interface = I2CDisplayInterface::new(i2c);
|
|
let mut display = Ssd1306Async::new(interface, DisplaySize128x64, DisplayRotation::Rotate0)
|
|
.into_terminal_mode();
|
|
display.init().await.unwrap();
|
|
let _ = display.clear().await;
|
|
|
|
/* Endless loop */
|
|
loop {
|
|
for c in 97..123 {
|
|
let _ = display
|
|
.write_str(unsafe { core::str::from_utf8_unchecked(&[c]) })
|
|
.await;
|
|
}
|
|
for c in 65..91 {
|
|
let _ = display
|
|
.write_str(unsafe { core::str::from_utf8_unchecked(&[c]) })
|
|
.await;
|
|
}
|
|
}
|
|
}
|