рефакторинг библиотеки.

This commit is contained in:
Кобелев Андрей Андреевич
2026-08-15 23:53:45 +05:00
parent 896670b62f
commit efc53e6ef5
13 changed files with 584 additions and 371 deletions
+8 -23
View File
@@ -1,7 +1,9 @@
//! Демонстрирует четыре уровня яркости и обновление строки без полного мерцания.
mod common;
use anyhow::Result;
use std::time::Duration;
use m::vfd::VfdConfig;
use m::worker::VfdWorker;
fn main() -> Result<()> {
@@ -9,26 +11,9 @@ fn main() -> Result<()> {
// 1) port (default: /dev/cu.usbmodem101)
// 2) width (default: 20)
// 3) delay_ms (default: 800)
let port_name = std::env::args()
.nth(1)
.unwrap_or("/dev/cu.usbmodem101".into());
let width: usize = std::env::args()
.nth(2)
.as_deref()
.unwrap_or("20")
.parse()
.unwrap_or(20);
let delay_ms: u64 = std::env::args()
.nth(3)
.as_deref()
.unwrap_or("800")
.parse()
.unwrap_or(800);
let cfg = VfdConfig::new(port_name).with_width(width);
let worker = VfdWorker::start(cfg)?;
let mut args = common::ExampleArgs::from_env();
let delay_ms: u64 = args.parse_or(800);
let worker = VfdWorker::start(args.config)?;
let vfd = worker.handle();
vfd.clear();
@@ -47,7 +32,7 @@ fn main() -> Result<()> {
let _ = vfd.print_line_diff(2, line2);
std::thread::sleep(Duration::from_millis(delay_ms));
common::sleep_ms(delay_ms);
}
}
}