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

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
+10 -36
View File
@@ -1,7 +1,10 @@
//! Демонстрирует фоновую бегущую строку с регулируемой скоростью и паузой в конце.
mod common;
use anyhow::Result;
use std::time::Duration;
use m::vfd::VfdConfig;
use m::worker::VfdWorker;
fn main() -> Result<()> {
@@ -11,40 +14,11 @@ fn main() -> Result<()> {
// 3) cps (chars per second, default: 8)
// 4) end_pause_ms (default: 1500)
// 5) brightness 1..4 (default: 2)
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 cps: u32 = std::env::args()
.nth(3)
.as_deref()
.unwrap_or("8")
.parse()
.unwrap_or(8);
let end_pause_ms: u64 = std::env::args()
.nth(4)
.as_deref()
.unwrap_or("1500")
.parse()
.unwrap_or(1500);
let brightness: u8 = std::env::args()
.nth(5)
.as_deref()
.unwrap_or("2")
.parse()
.unwrap_or(2);
let cfg = VfdConfig::new(port_name).with_width(width);
let worker = VfdWorker::start(cfg)?;
let mut args = common::ExampleArgs::from_env();
let cps: u32 = args.parse_or(8);
let end_pause_ms: u64 = args.parse_or(1500);
let brightness: u8 = args.parse_or(2);
let worker = VfdWorker::start(args.config)?;
let vfd = worker.handle();
vfd.clear();
@@ -61,6 +35,6 @@ fn main() -> Result<()> {
let _ = vfd.print_line_diff(1, "Бегущая строка");
loop {
std::thread::sleep(Duration::from_secs(3600));
common::sleep_ms(3_600_000);
}
}