Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot render with MonoTextStyle #194

Open
abergmeier opened this issue Feb 26, 2024 · 2 comments
Open

Cannot render with MonoTextStyle #194

abergmeier opened this issue Feb 26, 2024 · 2 comments

Comments

@abergmeier
Copy link

I have the following code:

    let display = Display7in5::default();
    let char_style = MonoTextStyleBuilder::new()
        .font(&embedded_graphics::mono_font::ascii::FONT_10X20)
        .text_color(BinaryColor::On)
        .background_color(BinaryColor::Off)
        .build();

    let text = Text::new("Foo", (10, 10).into(), char_style);
    text.draw(&mut display).unwrap();

which does not compile due to a BinaryColor <> Color mismatch.

@diajowe
Copy link

diajowe commented May 16, 2024

Can confirm, it does not compile with the following error:

error[E0277]: the trait bound `epd_waveshare::epd7in5_v2::Display7in5: DrawTarget` is not satisfied
   --> src/main.rs:107:11
    |
107 | text.draw(&mut display).unwrap();
    |      ---- ^^^^^^^^^^^^ the trait `DrawTarget` is not implemented for `epd_waveshare::epd7in5_v2::Display7in5`
    |      |
    |      required by a bound introduced by this call
    |
    = help: the following other types implement trait `DrawTarget`:
              mono_font::draw_target::MonoFontDrawTarget<'_, T, mono_font::draw_target::Foreground<<T as DrawTarget>::Color>>
              mono_font::draw_target::MonoFontDrawTarget<'_, T, mono_font::draw_target::Background<<T as DrawTarget>::Color>>
              mono_font::draw_target::MonoFontDrawTarget<'_, T, mono_font::draw_target::Both<<T as DrawTarget>::Color>>
              Clipped<'_, T>
              ColorConverted<'_, T, C>
              Cropped<'_, T>
              embedded_graphics::draw_target::Translated<'_, T>
              Framebuffer<C, RawU1, BO, WIDTH, HEIGHT, N>
            and 10 others
note: required by a bound in `embedded_graphics::Drawable::draw`
   --> /home/jowe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/embedded-graphics-core-0.4.0/src/drawable.rs:106:12
    |
104 |     fn draw<D>(&self, target: &mut D) -> Result<Self::Output, D::Error>
    |        ---- required by a bound in this associated function
105 |     where
106 |         D: DrawTarget<Color = Self::Color>;
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Drawable::draw`

In generally, I've tried this with Display4in2, and does not compile either. The relevant crates I used are:

epd-waveshare = {version="0.5.0", features=["graphics"]}
embedded-hal = "0.2.4"
embedded-hal-compat = "0.13.0"
embedded-graphics = "0.8.1"

@diajowe
Copy link

diajowe commented May 16, 2024

By digging a bit, I found PR #196 which seems to fix this problem. One can add .color_converted() to the parameter in the draw()-function. This function seems to exist in version 0.5.0 already, but is still not working in this case outside of that PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants