mirror of
https://github.com/fossasia/badgemagic-rs
synced 2025-06-23 23:33:58 +00:00
51 lines
1.3 KiB
Rust
51 lines
1.3 KiB
Rust
#![warn(clippy::all, clippy::pedantic)]
|
|
|
|
use anyhow::Result;
|
|
use badgemagic::{
|
|
embedded_graphics::{
|
|
geometry::Point, mono_font::MonoTextStyle, pixelcolor::BinaryColor, text::Text,
|
|
},
|
|
protocol::{Mode, PayloadBuffer, Style},
|
|
usb_hid::Device,
|
|
util::DrawableLayoutExt,
|
|
};
|
|
|
|
fn main() -> Result<()> {
|
|
let mut payload = PayloadBuffer::new();
|
|
|
|
payload.add_message_drawable(
|
|
Style::default().mode(Mode::Center),
|
|
&Text::new(
|
|
"Hello",
|
|
Point::new(0, 8),
|
|
MonoTextStyle::new(
|
|
&embedded_graphics::mono_font::iso_8859_1::FONT_6X9,
|
|
BinaryColor::On,
|
|
),
|
|
),
|
|
);
|
|
|
|
payload.add_message_drawable(
|
|
Style::default().mode(Mode::Center),
|
|
&Text::new(
|
|
"Hello",
|
|
Point::new(0, 5),
|
|
MonoTextStyle::new(
|
|
&embedded_graphics::mono_font::iso_8859_1::FONT_4X6,
|
|
BinaryColor::On,
|
|
),
|
|
)
|
|
.z_stack(Text::new(
|
|
"World",
|
|
Point::new(23, 8),
|
|
MonoTextStyle::new(
|
|
&embedded_graphics::mono_font::iso_8859_1::FONT_4X6,
|
|
BinaryColor::On,
|
|
),
|
|
)),
|
|
);
|
|
|
|
Device::single()?.write(payload)?;
|
|
|
|
Ok(())
|
|
}
|