macro_rules! progmem_display {
    ($text:expr) => { ... };
}
Expand description

Define a single-use string in progmem usable as impl Display + uDisplay

This is a short-cut macro to create an ad-hoc static storing the given string literal as a PmString and return it. This is somewhat similar to the F macro available in Arduino IDE, but different. For a macro more in line with the F macro, see progmem_str.

Unlike the F macro, this macro neither loads the string here, nor, can it be use as a &str. However, the returned value implements Display as well as ufmt::uDisplay (if the ufmt crate feature is enabled).

This macro allows to conveniently put a literal string into progmem right where it is used. However, since it is not loaded (yet) into RAM it is not a &str, it only exposes a Display and ufmt::uDisplay (if the ufmt crate feature is enabled) implementation, which will load it char-by-char when used, thus limiting the RAM usage, and allowing arbitrarily large strings to be wrapped.

Example

use avr_progmem::progmem_display as D;
use ufmt::uWrite;

let mut writer = // impl uWrite
    /* SNIP */;

// Put the literal `str` into progmem and use it as `impl uDisplay`
#[cfg(feature = "ufmt")] // requires the `ufmt` crate feature
ufmt::uwrite!(&mut writer, "{}", D!("dai 大賢者 kenja"));

// Huge strings are fine
#[cfg(feature = "ufmt")] // requires the `ufmt` crate feature
ufmt::uwrite!(&mut writer, "{}", D!(include_str!("../examples/test_text.txt")));