Squashed commit of the following:

commit 9f6c282e48
Author: Valentin Weber <valentin@wv2.ch>
Date:   Sat Feb 22 18:42:03 2025 +0100

    feat: move proporional font functonality to feature

commit 36f748c092
Author: Valentin Weber <valentin@wv2.ch>
Date:   Sat Feb 22 02:51:54 2025 +0100

    chore: clean up LICENSE-MIT copyriht notice

commit fe3abd83d7
Author: Valentin Weber <valentin@wv2.ch>
Date:   Fri Feb 21 22:28:40 2025 +0100

    feat: Move to proportional font

    To use the available space on the bade more efficient, I changed the
    font to u8g2_font_lucasfont_alternate_tf from
    [u8g2-fonts](https://docs.rs/crate/u8g2-fonts/).

    Lucasfont Alternate was created by Patrick Lauke and is licensed under
    [CC BY 3.0](https://creativecommons.org/licenses/by/3.0/).
    No changes to the font were made.
This commit is contained in:
Valentin Weber 2025-02-22 18:50:20 +01:00
parent f13e4c215b
commit 00cdff615a
No known key found for this signature in database
GPG key ID: 44797000F143F522
2 changed files with 18 additions and 3 deletions

View file

@ -35,6 +35,7 @@ embedded-graphics = ["dep:embedded-graphics"]
serde = ["dep:serde"]
usb-hid = ["dep:hidapi"]
ble = ["dep:btleplug", "dep:uuid", "dep:tokio"]
u8g2-fonts = ["dep:u8g2-fonts"]
[dependencies]
anyhow = "1.0.95"
@ -50,4 +51,4 @@ serde_json = { version = "1.0.134", optional = true }
time = "0.3.37"
toml = { version = "0.8.19", optional = true }
zerocopy = { version = "0.8.14", features = ["derive"] }
u8g2-fonts = { version = "0.5.2", features = ["embedded_graphics_textstyle"] }
u8g2-fonts = { version = "0.5.2", features = ["embedded_graphics_textstyle"], optional = true}

View file

@ -18,6 +18,10 @@ 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};
#[cfg(feature = "u8g2-fonts")]
use u8g2_fonts::{fonts::u8g2_font_lucasfont_alternate_tf, U8g2TextStyle};
#[derive(Parser)]
@ -106,7 +110,7 @@ fn main() -> Result<()> {
return list_devices(&args.transport);
}
let payload = gnerate_payload(&mut args)?;
let payload = generate_payload(&mut args)?;
write_payload(&args.transport, payload)
}
@ -132,7 +136,7 @@ fn list_devices(transport: &TransportProtocol) -> Result<()> {
Ok(())
}
fn gnerate_payload(args: &mut Args) -> Result<PayloadBuffer> {
fn generate_payload(args: &mut Args) -> Result<PayloadBuffer> {
let config_path = args.config.take().unwrap_or_default();
let config = fs::read_to_string(&config_path)
.with_context(|| format!("load config: {config_path:?}"))?;
@ -161,8 +165,18 @@ fn gnerate_payload(args: &mut Args) -> Result<PayloadBuffer> {
style = style.border();
}
style = style.speed(message.speed).mode(message.mode);
match message.content {
Content::Text { text } => {
#[cfg(not(any(feature = "u8g2-fonts")))]
let text = Text::new(
&text,
Point::new(0, 8),
U8g2TextStyle::new(u8g2_font_lucasfont_alternate_tf, BinaryColor::On),
);
#[cfg(feature = "u8g2-fonts")]
let text = Text::new(
&text,
Point::new(0, 8),