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>
109 lines
2.8 KiB
Rust
109 lines
2.8 KiB
Rust
use criterion::*;
|
|
use embedded_graphics::{
|
|
geometry::Point,
|
|
mono_font::{
|
|
ascii::{FONT_10X20, FONT_6X9},
|
|
MonoTextStyle, MonoTextStyleBuilder,
|
|
},
|
|
pixelcolor::Gray8,
|
|
prelude::*,
|
|
text::Text,
|
|
};
|
|
|
|
mod common;
|
|
|
|
use common::Framebuffer;
|
|
|
|
fn one_line<S>(style: S) -> Text<'static, S> {
|
|
Text::new("Hello world!", Point::new_equal(20), style)
|
|
}
|
|
|
|
fn three_lines<S>(style: S) -> Text<'static, S> {
|
|
Text::new("line 1\nl2\nThis is line 3", Point::new_equal(20), style)
|
|
}
|
|
|
|
fn font_6x9(c: &mut Criterion) {
|
|
let mut group = c.benchmark_group("font 6x9");
|
|
|
|
let style = MonoTextStyle::new(&FONT_6X9, Gray8::WHITE);
|
|
let style_with_bg = MonoTextStyleBuilder::new()
|
|
.font(&FONT_6X9)
|
|
.text_color(Gray8::WHITE)
|
|
.background_color(Gray8::BLACK)
|
|
.build();
|
|
|
|
group.bench_function("one line", |b| {
|
|
let object = one_line(style);
|
|
|
|
let mut framebuffer = Framebuffer::new();
|
|
b.iter(|| object.draw(&mut framebuffer))
|
|
});
|
|
|
|
group.bench_function("one line with background", |b| {
|
|
let object = one_line(style_with_bg);
|
|
|
|
let mut framebuffer = Framebuffer::new();
|
|
b.iter(|| object.draw(&mut framebuffer))
|
|
});
|
|
|
|
group.bench_function("three lines", |b| {
|
|
let object = three_lines(style);
|
|
|
|
let mut framebuffer = Framebuffer::new();
|
|
b.iter(|| object.draw(&mut framebuffer))
|
|
});
|
|
|
|
group.bench_function("three lines with background)", |b| {
|
|
let object = three_lines(style_with_bg);
|
|
|
|
let mut framebuffer = Framebuffer::new();
|
|
b.iter(|| object.draw(&mut framebuffer))
|
|
});
|
|
|
|
group.finish();
|
|
}
|
|
|
|
fn font_10x20(c: &mut Criterion) {
|
|
let mut group = c.benchmark_group("font 10x20");
|
|
|
|
let style = MonoTextStyle::new(&FONT_10X20, Gray8::WHITE);
|
|
let style_with_bg = MonoTextStyleBuilder::new()
|
|
.font(&FONT_10X20)
|
|
.text_color(Gray8::WHITE)
|
|
.background_color(Gray8::BLACK)
|
|
.build();
|
|
|
|
group.bench_function("one line", |b| {
|
|
let object = one_line(style);
|
|
|
|
let mut framebuffer = Framebuffer::new();
|
|
b.iter(|| object.draw(&mut framebuffer))
|
|
});
|
|
|
|
group.bench_function("one line with background", |b| {
|
|
let object = one_line(style_with_bg);
|
|
|
|
let mut framebuffer = Framebuffer::new();
|
|
b.iter(|| object.draw(&mut framebuffer))
|
|
});
|
|
|
|
group.bench_function("three lines", |b| {
|
|
let object = three_lines(style);
|
|
|
|
let mut framebuffer = Framebuffer::new();
|
|
b.iter(|| object.draw(&mut framebuffer))
|
|
});
|
|
|
|
group.bench_function("three lines with background)", |b| {
|
|
let object = three_lines(style_with_bg);
|
|
|
|
let mut framebuffer = Framebuffer::new();
|
|
b.iter(|| object.draw(&mut framebuffer))
|
|
});
|
|
|
|
group.finish();
|
|
}
|
|
|
|
criterion_group!(fonts, font_6x9, font_10x20);
|
|
criterion_main!(fonts);
|