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>
54 lines
1.0 KiB
Rust
54 lines
1.0 KiB
Rust
#![allow(clippy::module_name_repetitions)]
|
|
|
|
use std::error::Error as StdError;
|
|
use std::fmt::{self, Display};
|
|
use std::sync::atomic::{AtomicBool, Ordering};
|
|
use std::sync::Arc;
|
|
|
|
#[derive(Debug)]
|
|
pub struct Flag {
|
|
atomic: Arc<AtomicBool>,
|
|
}
|
|
|
|
impl Flag {
|
|
pub fn new() -> Self {
|
|
Flag {
|
|
atomic: Arc::new(AtomicBool::new(false)),
|
|
}
|
|
}
|
|
|
|
pub fn get(&self) -> bool {
|
|
self.atomic.load(Ordering::Relaxed)
|
|
}
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub struct DetectDrop {
|
|
has_dropped: Flag,
|
|
}
|
|
|
|
impl DetectDrop {
|
|
pub fn new(has_dropped: &Flag) -> Self {
|
|
DetectDrop {
|
|
has_dropped: Flag {
|
|
atomic: Arc::clone(&has_dropped.atomic),
|
|
},
|
|
}
|
|
}
|
|
}
|
|
|
|
impl StdError for DetectDrop {}
|
|
|
|
impl Display for DetectDrop {
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
write!(f, "oh no!")
|
|
}
|
|
}
|
|
|
|
impl Drop for DetectDrop {
|
|
fn drop(&mut self) {
|
|
let already_dropped = self.has_dropped.atomic.swap(true, Ordering::Relaxed);
|
|
assert!(!already_dropped);
|
|
}
|
|
}
|