mirror of
https://github.com/fossasia/badgemagic-rs
synced 2025-08-14 11:17:59 +00:00
Merge 9929cf70bb
into 5d745ab8fd
This commit is contained in:
commit
4411a504af
3 changed files with 21 additions and 8 deletions
11
Cargo.lock
generated
11
Cargo.lock
generated
|
@ -125,6 +125,7 @@ dependencies = [
|
|||
"time",
|
||||
"tokio",
|
||||
"toml",
|
||||
"u8g2-fonts",
|
||||
"uuid",
|
||||
"zerocopy",
|
||||
]
|
||||
|
@ -1104,6 +1105,16 @@ version = "1.0.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
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]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.12"
|
||||
|
|
|
@ -50,3 +50,4 @@ serde_json = { version = "1.0.140", optional = true }
|
|||
time = "0.3.41"
|
||||
toml = { version = "0.9.2", optional = true }
|
||||
zerocopy = { version = "0.8.26", features = ["derive"] }
|
||||
u8g2-fonts = { version = "0.7.1", features = ["embedded_graphics_textstyle"] }
|
17
src/main.rs
17
src/main.rs
|
@ -4,22 +4,23 @@
|
|||
use std::{fs, path::PathBuf};
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use badgemagic::{
|
||||
ble::Device as BleDevice,
|
||||
protocol::{Mode, PayloadBuffer, Speed, Style},
|
||||
usb_hid::Device as UsbDevice,
|
||||
};
|
||||
use base64::Engine;
|
||||
use clap::{Parser, ValueEnum};
|
||||
use embedded_graphics::{
|
||||
geometry::Point,
|
||||
image::{Image, ImageRawLE},
|
||||
mono_font::{iso_8859_1::FONT_6X9, MonoTextStyle},
|
||||
pixelcolor::BinaryColor,
|
||||
text::Text,
|
||||
Drawable, Pixel,
|
||||
};
|
||||
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)]
|
||||
/// 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 } => {
|
||||
let text = Text::new(
|
||||
&text,
|
||||
Point::new(0, 7),
|
||||
MonoTextStyle::new(&FONT_6X9, BinaryColor::On),
|
||||
Point::new(0, 8),
|
||||
U8g2TextStyle::new(u8g2_font_lucasfont_alternate_tf, BinaryColor::On),
|
||||
);
|
||||
payload.add_message_drawable(style, &text);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue