chore: some typos and fmt

This commit is contained in:
Valentin Weber 2025-07-10 17:52:57 +02:00
parent 6e25fbb266
commit 1dd4c4cc43
No known key found for this signature in database
GPG key ID: 44797000F143F522
5 changed files with 12 additions and 20 deletions

8
Cargo.lock generated
View file

@ -1506,18 +1506,18 @@ checksum = "791978798f0597cfc70478424c2b4fdc2b7a8024aaff78497ef00f24ef674193"
[[package]]
name = "zerocopy"
version = "0.8.14"
version = "0.8.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a367f292d93d4eab890745e75a778da40909cab4d6ff8173693812f79c4a2468"
checksum = "1039dd0d3c310cf05de012d8a39ff557cb0d23087fd44cad61df08fc31907a2f"
dependencies = [
"zerocopy-derive",
]
[[package]]
name = "zerocopy-derive"
version = "0.8.14"
version = "0.8.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3931cb58c62c13adec22e38686b559c86a30565e16ad6e8510a337cedc611e1"
checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181"
dependencies = [
"proc-macro2",
"quote",

View file

@ -51,4 +51,4 @@ serde_json = { version = "1.0.140", optional = true }
time = "0.3.41"
toml = { version = "0.9.0", optional = true }
zerocopy = { version = "0.8.14", features = ["derive"] }
u8g2-fonts = { version = "0.7.1", features = ["embedded_graphics_textstyle"], optional = true}
u8g2-fonts = { version = "0.7.1", features = ["embedded_graphics_textstyle"], optional = true }

View file

@ -191,7 +191,7 @@ impl Device {
BLE_CHAR_CHUNK_SIZE
);
// the device will brick itself if the payload is too long (more then 8192 bytes)
// the device will brick itself if the payload is too long (more than 8192 bytes)
anyhow::ensure!(data.len() <= 8192, "payload too long (max 8192 bytes)");
for chunk in data.chunks(BLE_CHAR_CHUNK_SIZE) {

View file

@ -1,7 +1,5 @@
#![warn(clippy::all, clippy::pedantic)]
use std::{fs, path::PathBuf};
use anyhow::{Context, Result};
use badgemagic::{
ble::Device as BleDevice,
@ -10,6 +8,8 @@ use badgemagic::{
};
use base64::Engine;
use clap::{Parser, ValueEnum};
#[cfg(not(any(feature = "u8g2-fonts")))]
use embedded_graphics::mono_font::{iso_8859_1::FONT_6X9, MonoTextStyle};
use embedded_graphics::{
geometry::Point,
image::{Image, ImageRawLE},
@ -18,9 +18,7 @@ use embedded_graphics::{
Drawable, Pixel,
};
use serde::Deserialize;
#[cfg(not(any(feature = "u8g2-fonts")))]
use embedded_graphics::mono_font::{iso_8859_1::FONT_6X9, MonoTextStyle};
use std::{fs, path::PathBuf};
#[cfg(feature = "u8g2-fonts")]
use u8g2_fonts::{fonts::u8g2_font_lucasfont_alternate_tf, U8g2TextStyle};
@ -99,8 +97,6 @@ enum Content {
Bitstring { bitstring: String },
BitmapBase64 { width: u32, bitmap_base64: String },
BitmapFile { width: u32, bitmap_file: PathBuf },
// TODO: implement png
// PngFile { png_file: PathBuf },
}
fn main() -> Result<()> {
@ -208,12 +204,8 @@ fn generate_payload(args: &mut Args) -> Result<PayloadBuffer> {
// off
}
'X' => {
Pixel(
Point::new(x.try_into().unwrap(), y.try_into().unwrap()),
BinaryColor::On,
)
.draw(&mut buffer)
.unwrap();
Pixel(Point::new(x.try_into()?, y.try_into()?), BinaryColor::On)
.draw(&mut buffer)?;
}
_ => anyhow::bail!("invalid bit value for bit ({x}, {y}): {c:?}"),
}

View file

@ -92,7 +92,7 @@ impl Device {
fn write_raw(device: &HidDevice, data: &[u8]) -> Result<()> {
anyhow::ensure!(data.len() % 64 == 0, "payload not padded to 64 bytes");
// the device will brick itself if the payload is too long (more then 8192 bytes)
// the device will brick itself if the payload is too long (more than 8192 bytes)
anyhow::ensure!(data.len() <= 8192, "payload too long (max 8192 bytes)");
// just to be sure