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.8 KiB
Rust
54 lines
1.8 KiB
Rust
//! Display brightness
|
|
|
|
/// Struct that holds display brightness
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
|
pub struct Brightness {
|
|
pub(crate) precharge: u8,
|
|
pub(crate) contrast: u8,
|
|
}
|
|
|
|
impl Default for Brightness {
|
|
fn default() -> Self {
|
|
Brightness::NORMAL
|
|
}
|
|
}
|
|
|
|
impl Brightness {
|
|
/// The dimmest predefined brightness level
|
|
pub const DIMMEST: Brightness = Brightness::custom(0x1, 0x00);
|
|
|
|
/// A dim predefined brightness level
|
|
pub const DIM: Brightness = Brightness::custom(0x2, 0x2F);
|
|
|
|
/// A medium predefined brightness level
|
|
pub const NORMAL: Brightness = Brightness::custom(0x2, 0x5F);
|
|
|
|
/// A bright predefined brightness level
|
|
pub const BRIGHT: Brightness = Brightness::custom(0x2, 0x9F);
|
|
|
|
/// The brightest predefined brightness level
|
|
pub const BRIGHTEST: Brightness = Brightness::custom(0x2, 0xFF);
|
|
|
|
/// Create a Brightness object from a precharge period and contrast pair.
|
|
///
|
|
/// `precharge` sets the `phase 2` argument of the `0xD9 Set Pre-Charge Period` command and must
|
|
/// be must be between 1 and 15.
|
|
/// The effects of this parameter are hardware dependent. For the common 128x64 displays, values
|
|
/// 1 and 2 result in different brightness levels, values above 2 behave the same was as 2.
|
|
/// See section 10.1.17 of the SSD1306 datasheet for more information.
|
|
///
|
|
/// `contrast` sets the value used in the `0x81 Set Contrast Control` command and must be
|
|
/// between 0 and 255. See section 10.1.7 of the SSD1306 datasheet for more information.
|
|
pub const fn custom(precharge: u8, contrast: u8) -> Self {
|
|
debug_assert!(
|
|
0 < precharge && precharge <= 15,
|
|
"Precharge value must be between 1 and 15"
|
|
);
|
|
|
|
Self {
|
|
precharge,
|
|
contrast,
|
|
}
|
|
}
|
|
}
|