Update to match firmware's expectation of name
This commit is contained in:
parent
cd9d3f4f0d
commit
8b17d1a9ca
21
src/main.rs
21
src/main.rs
@ -58,12 +58,6 @@ impl Display for Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> Result<(), Error> {
|
fn main() -> Result<(), Error> {
|
||||||
let args: Vec<String> = env::args().collect();
|
|
||||||
let img = image::open(&args[1])?;
|
|
||||||
let img = img.crop_imm(28, 28, img.width() - 56, img.height() - 56);
|
|
||||||
let img = img.resize_exact(240, 320, FilterType::Gaussian);
|
|
||||||
let img = img.into_rgb8();
|
|
||||||
|
|
||||||
let device = list_devices().wait()?
|
let device = list_devices().wait()?
|
||||||
.find(|dev| dev.vendor_id() == 0xCAFE && dev.product_id() == 0xCA6D)
|
.find(|dev| dev.vendor_id() == 0xCAFE && dev.product_id() == 0xCA6D)
|
||||||
.ok_or(Error { message: "Device not found" })?;
|
.ok_or(Error { message: "Device not found" })?;
|
||||||
@ -73,8 +67,23 @@ fn main() -> Result<(), Error> {
|
|||||||
|
|
||||||
let mut writer = interface.endpoint::<Bulk, Out>(0x01)?.writer(4096);
|
let mut writer = interface.endpoint::<Bulk, Out>(0x01)?.writer(4096);
|
||||||
|
|
||||||
|
let args: Vec<String> = env::args().collect();
|
||||||
|
if args.len() == 1 {
|
||||||
|
writer.write(&[0x42])?;
|
||||||
|
writer.flush()?;
|
||||||
|
} else {
|
||||||
|
// name of card
|
||||||
|
writer.write(&[0])?;
|
||||||
|
|
||||||
|
let img = image::open(&args[1])?;
|
||||||
|
let img = img.crop_imm(28, 28, img.width() - 56, img.height() - 56);
|
||||||
|
let img = img.resize_exact(240, 320, FilterType::Gaussian);
|
||||||
|
let img = img.into_rgb8();
|
||||||
|
|
||||||
|
// image of card
|
||||||
writer.write_all(img.as_flat_samples().samples)?;
|
writer.write_all(img.as_flat_samples().samples)?;
|
||||||
writer.flush()?;
|
writer.flush()?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user