LuckyTurtleDev / pybadge-high

High Level Board Support crate for the Adafruit pybadge
Apache License 2.0
0 stars 0 forks source link

embedded-graphics 0.8.0+ compatibility #11

Open orsinium opened 9 months ago

orsinium commented 9 months ago

When trying to use pybadge-high with embedded-graphics 0.8.1, I get multiple errors about missed methods and unsatisfied traits on the display

#![no_std]
#![no_main]

use embedded_graphics::{
    mono_font::{ascii::FONT_6X10, MonoTextStyle},
    pixelcolor::Rgb565,
    prelude::*,
    text::Text,
};
use pybadge::{prelude::*, *};
use pybadge_high as pybadge;

#[entry]
fn main() -> ! {
    let red = Color::new(255, 0, 0);
    let mut pybadge = PyBadge::take().unwrap();
    // pybadge.display.clear(red).unwrap();
    let style = MonoTextStyle::new(&FONT_6X10, Rgb565::WHITE);
    Text::new("Hello Rust!", Point::new(20, 30), style)
        .draw(&mut pybadge.display)
        .unwrap();
}
error[E0599]: no method named `clear` found for struct `ST7735` in the current scope
   --> src/main.rs:19:21
    |
19  |     pybadge.display.clear(Color::RED).unwrap();
    |                     ^^^^^ method not found in `ST7735<SPIMaster4<Pad<SERCOM4, Pad2, Pin<PB14, Alternate<C>>>, Pad<SERCOM4, Pad3, Pin<PB15, Alternate<C>>>, Pad<SERCOM4, Pad1, Pin<PB13, ...>>>, ..., ...>`
    |
   ::: /home/gram/.cargo/registry/src/index.crates.io-6f17d22bba15001f/embedded-graphics-core-0.3.3/src/draw_target/mod.rs:422:8
    |
422 |     fn clear(&mut self, color: Self::Color) -> Result<(), Self::Error> {
    |        ----- the method is available for `st7735_lcd::ST7735<atsamd_hal::thumbv7em::sercom::v1::spi::SPIMaster4<atsamd_hal::sercom::v1::pads::Pad<atsamd51j::SERCOM4, atsamd_hal::sercom::v2::pad::Pad2, atsamd_hal::gpio::v1::Pin<atsamd_hal::gpio::v2::pin::PB14, atsamd_hal::gpio::v2::pin::Alternate<atsamd_hal::gpio::v2::pin::C>>>, atsamd_hal::sercom::v1::pads::Pad<atsamd51j::SERCOM4, atsamd_hal::sercom::v2::pad::Pad3, atsamd_hal::gpio::v1::Pin<atsamd_hal::gpio::v2::pin::PB15, atsamd_hal::gpio::v2::pin::Alternate<atsamd_hal::gpio::v2::pin::C>>>, atsamd_hal::sercom::v1::pads::Pad<atsamd51j::SERCOM4, atsamd_hal::sercom::v2::pad::Pad1, atsamd_hal::gpio::v1::Pin<atsamd_hal::gpio::v2::pin::PB13, atsamd_hal::gpio::v2::pin::Alternate<atsamd_hal::gpio::v2::pin::C>>>>, atsamd_hal::gpio::v1::Pin<atsamd_hal::gpio::v2::pin::PB05, atsamd_hal::gpio::v2::pin::Output<atsamd_hal::gpio::v2::pin::PushPull>>, atsamd_hal::gpio::v1::Pin<atsamd_hal::gpio::v2::pin::PA00, atsamd_hal::gpio::v2::pin::Output<atsamd_hal::gpio::v2::pin::PushPull>>>` here
    |
    = note: the full type name has been written to '/home/gram/Documents/pybadge-wasm/target/thumbv7em-none-eabihf/release/deps/pybadge_wasm-ad84cd4bd4c9d2ac.long-type-1586697540914931542.txt'
    = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
4   + use embedded_graphics_core::draw_target::DrawTarget;
    |

error[E0599]: no associated item named `RED` found for struct `embedded_graphics_core::pixelcolor::rgb_color::Rgb565` in the current scope
  --> src/main.rs:19:34
   |
19 |     pybadge.display.clear(Color::RED).unwrap();
   |                                  ^^^ associated item not found in `Rgb565`
   |
   = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
   |
4  + use embedded_graphics_core::pixelcolor::rgb_color::RgbColor;
   |

error[E0277]: the trait bound `st7735_lcd::ST7735<atsamd_hal::thumbv7em::sercom::v1::spi::SPIMaster4<atsamd_hal::sercom::v1::pads::Pad<atsamd51j::SERCOM4, atsamd_hal::sercom::v2::pad::Pad2, atsamd_hal::gpio::v1::Pin<atsamd_hal::gpio::v2::pin::PB14, atsamd_hal::gpio::v2::pin::Alternate<atsamd_hal::gpio::v2::pin::C>>>, atsamd_hal::sercom::v1::pads::Pad<atsamd51j::SERCOM4, atsamd_hal::sercom::v2::pad::Pad3, atsamd_hal::gpio::v1::Pin<atsamd_hal::gpio::v2::pin::PB15, atsamd_hal::gpio::v2::pin::Alternate<atsamd_hal::gpio::v2::pin::C>>>, atsamd_hal::sercom::v1::pads::Pad<atsamd51j::SERCOM4, atsamd_hal::sercom::v2::pad::Pad1, atsamd_hal::gpio::v1::Pin<atsamd_hal::gpio::v2::pin::PB13, atsamd_hal::gpio::v2::pin::Alternate<atsamd_hal::gpio::v2::pin::C>>>>, atsamd_hal::gpio::v1::Pin<atsamd_hal::gpio::v2::pin::PB05, atsamd_hal::gpio::v2::pin::Output<atsamd_hal::gpio::v2::pin::PushPull>>, atsamd_hal::gpio::v1::Pin<atsamd_hal::gpio::v2::pin::PA00, atsamd_hal::gpio::v2::pin::Output<atsamd_hal::gpio::v2::pin::PushPull>>>: embedded_graphics::draw_target::DrawTarget` is not satisfied
   --> src/main.rs:22:15
    |
22  |         .draw(&mut pybadge.display)
    |          ---- ^^^^^^^^^^^^^^^^^^^^ the trait `embedded_graphics::draw_target::DrawTarget` is not implemented for `st7735_lcd::ST7735<atsamd_hal::thumbv7em::sercom::v1::spi::SPIMaster4<atsamd_hal::sercom::v1::pads::Pad<atsamd51j::SERCOM4, atsamd_hal::sercom::v2::pad::Pad2, atsamd_hal::gpio::v1::Pin<atsamd_hal::gpio::v2::pin::PB14, atsamd_hal::gpio::v2::pin::Alternate<atsamd_hal::gpio::v2::pin::C>>>, atsamd_hal::sercom::v1::pads::Pad<atsamd51j::SERCOM4, atsamd_hal::sercom::v2::pad::Pad3, atsamd_hal::gpio::v1::Pin<atsamd_hal::gpio::v2::pin::PB15, atsamd_hal::gpio::v2::pin::Alternate<atsamd_hal::gpio::v2::pin::C>>>, atsamd_hal::sercom::v1::pads::Pad<atsamd51j::SERCOM4, atsamd_hal::sercom::v2::pad::Pad1, atsamd_hal::gpio::v1::Pin<atsamd_hal::gpio::v2::pin::PB13, atsamd_hal::gpio::v2::pin::Alternate<atsamd_hal::gpio::v2::pin::C>>>>, atsamd_hal::gpio::v1::Pin<atsamd_hal::gpio::v2::pin::PB05, atsamd_hal::gpio::v2::pin::Output<atsamd_hal::gpio::v2::pin::PushPull>>, atsamd_hal::gpio::v1::Pin<atsamd_hal::gpio::v2::pin::PA00, atsamd_hal::gpio::v2::pin::Output<atsamd_hal::gpio::v2::pin::PushPull>>>`
    |          |
    |          required by a bound introduced by this call
    |
orsinium commented 9 months ago

Related: https://github.com/sajattack/st7735-lcd-rs/issues/22

Might be related: https://github.com/atsamd-rs/atsamd/issues/603

LuckyTurtleDev commented 9 months ago

I have check this. Pybade-high is only a small wrapper over the edgebadge crate, which a more easy api. However the edgebadge crate still stuck at st7735-lcd-rs 8.0.1, which does not support embedded-graphics 0.8 yet. So we need to wait for an update of the edgebadge crate( or fork it).

Looks like the edgebadge crate is a bit outdated and unmaintained. Anyway I have open an issue for this now to discuss this issue: https://github.com/atsamd-rs/atsamd/issues/724

orsinium commented 9 months ago

Thank you! Subscribed.