This commit is contained in:
Valentin Weber 2025-07-19 15:04:15 +00:00 committed by GitHub
commit 4411a504af
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 21 additions and 8 deletions

11
Cargo.lock generated
View file

@ -125,6 +125,7 @@ dependencies = [
"time", "time",
"tokio", "tokio",
"toml", "toml",
"u8g2-fonts",
"uuid", "uuid",
"zerocopy", "zerocopy",
] ]
@ -1104,6 +1105,16 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcc842091f2def52017664b53082ecbbeb5c7731092bad69d2c63050401dfd64" checksum = "fcc842091f2def52017664b53082ecbbeb5c7731092bad69d2c63050401dfd64"
[[package]]
name = "u8g2-fonts"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e4bdc43a7fb3720ece9ba4405b57db4fc479ad6af6b57090f6ff4c040f5d54b"
dependencies = [
"embedded-graphics",
"embedded-graphics-core",
]
[[package]] [[package]]
name = "unicode-ident" name = "unicode-ident"
version = "1.0.12" version = "1.0.12"

View file

@ -50,3 +50,4 @@ serde_json = { version = "1.0.140", optional = true }
time = "0.3.41" time = "0.3.41"
toml = { version = "0.9.2", optional = true } toml = { version = "0.9.2", optional = true }
zerocopy = { version = "0.8.26", features = ["derive"] } zerocopy = { version = "0.8.26", features = ["derive"] }
u8g2-fonts = { version = "0.7.1", features = ["embedded_graphics_textstyle"] }

View file

@ -4,22 +4,23 @@
use std::{fs, path::PathBuf}; use std::{fs, path::PathBuf};
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use badgemagic::{
ble::Device as BleDevice,
protocol::{Mode, PayloadBuffer, Speed, Style},
usb_hid::Device as UsbDevice,
};
use base64::Engine; use base64::Engine;
use clap::{Parser, ValueEnum}; use clap::{Parser, ValueEnum};
use embedded_graphics::{ use embedded_graphics::{
geometry::Point, geometry::Point,
image::{Image, ImageRawLE}, image::{Image, ImageRawLE},
mono_font::{iso_8859_1::FONT_6X9, MonoTextStyle},
pixelcolor::BinaryColor, pixelcolor::BinaryColor,
text::Text, text::Text,
Drawable, Pixel, Drawable, Pixel,
}; };
use serde::Deserialize; use serde::Deserialize;
use u8g2_fonts::{fonts::u8g2_font_lucasfont_alternate_tf, U8g2TextStyle};
use badgemagic::{
ble::Device as BleDevice,
protocol::{Mode, PayloadBuffer, Speed, Style},
usb_hid::Device as UsbDevice,
};
#[derive(Parser)] #[derive(Parser)]
/// Upload a configuration with up to 8 messages to an LED badge /// Upload a configuration with up to 8 messages to an LED badge
@ -162,8 +163,8 @@ fn gnerate_payload(args: &mut Args) -> Result<PayloadBuffer> {
Content::Text { text } => { Content::Text { text } => {
let text = Text::new( let text = Text::new(
&text, &text,
Point::new(0, 7), Point::new(0, 8),
MonoTextStyle::new(&FONT_6X9, BinaryColor::On), U8g2TextStyle::new(u8g2_font_lucasfont_alternate_tf, BinaryColor::On),
); );
payload.add_message_drawable(style, &text); payload.add_message_drawable(style, &text);
} }