32 lines
1.1 KiB
Rust
32 lines
1.1 KiB
Rust
extern crate flfire;
|
|
extern crate libusb;
|
|
|
|
const TO: std::time::Duration = std::time::Duration::from_millis(10);
|
|
fn main() {
|
|
let args: Vec<String> = std::env::args().collect();
|
|
if args.len() != 2 {
|
|
eprintln!("Incorrect amount of arguments. Usage: bin <folder>");
|
|
std::process::exit(1);
|
|
}
|
|
|
|
let cont = libusb::Context::new().expect("Failed to initialize a libusb context");
|
|
let fires = flfire::get_fires(&cont);
|
|
let mut handles = flfire::claim_fires(&fires[0..1]);
|
|
let handle = &mut handles[0];
|
|
|
|
handle.write_bulk(1, &[0x0b,0xb0,0x7f,0], TO).unwrap();
|
|
|
|
loop {
|
|
let files = std::fs::read_dir(&args[1]).expect("Failed to read folder.");
|
|
for f in files {
|
|
let f = f.expect("Some file info error occured.");
|
|
let (x_dim, y_dim, image) = flfire::read_pbm(
|
|
f.path().as_os_str().to_str().expect("Failed to crate a file path string"));
|
|
let vbuf = flfire::render_pixelbuf(&image, x_dim, y_dim, 0, 0);
|
|
handle.write_bulk(1, &vbuf, TO).unwrap();
|
|
|
|
std::thread::sleep_ms(1000 / 60);
|
|
}
|
|
}
|
|
}
|