diff --git a/examples/image/main.rs b/examples/image/main.rs index 491b7da..258e176 100644 --- a/examples/image/main.rs +++ b/examples/image/main.rs @@ -6,6 +6,7 @@ //! However, to keep the example simple, we instead enable std. It significantly //! increases the binary size but it's good enough for simple apps. +#![allow(static_mut_refs)] #![no_main] use firefly_rust as ff; use std::cell::OnceCell; diff --git a/src/graphics/bindings.rs b/src/graphics/bindings.rs index 2d2337a..b9aea4f 100644 --- a/src/graphics/bindings.rs +++ b/src/graphics/bindings.rs @@ -88,6 +88,7 @@ extern { y: i32, color: i32, ); + pub(crate) fn draw_qr(ptr: u32, len: u32, x: i32, y: i32, black: i32, white: i32); pub(crate) fn draw_sub_image( ptr: u32, len: u32, diff --git a/src/graphics/funcs.rs b/src/graphics/funcs.rs index b6ce78d..06b11c8 100644 --- a/src/graphics/funcs.rs +++ b/src/graphics/funcs.rs @@ -163,6 +163,15 @@ pub fn draw_text(t: &str, f: &Font, p: Point, c: Color) { } } +/// Render a QR code for the given text. +pub fn draw_qr(t: &str, p: Point, black: Color, white: Color) { + let ptr = t.as_ptr(); + let len = t.len(); + unsafe { + b::draw_qr(ptr as u32, len as u32, p.x, p.y, black.into(), white.into()); + } +} + /// Render an image using the given colors. pub fn draw_image(i: &Image, p: Point) { let ptr = i.raw.as_ptr();