cat-in-136 / ws2812-esp32-rmt-driver

WS2812 driver using ESP32 RMT for Rust
MIT License
40 stars 21 forks source link

Example does not compile when using embedded graphics 0.8.0 #27

Closed punkto closed 12 months ago

punkto commented 1 year ago

Hello,

I'm having compiler errors when using a code like the m5atom_embedded_graphics.rs example. Rust is still a little criptic for me, so I cannot tell exactly what the error means. Here it is when I use embedded-graphics 0.8.0:

error[E0599]: the method `translated` exists for struct `LedPixelDrawTarget<Rgb888, LedPixelColorImpl<3, 1, 0, 2, 255>, LedPixelMatrix<28, 8>>`, but its trait bounds were not satisfied
  --> examples/ws2812_embedded_graphics.rs:32:40
   |
32 |         let mut translated_draw = draw.translated(Point::zero());
   |                                        ^^^^^^^^^^ method cannot be called due to unsatisfied trait bounds
   |
  ::: /home/xxxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ws2812-esp32-rmt-driver-0.5.0/src/lib_embedded_graphics.rs:51:1
   |
51 | pub struct LedPixelDrawTarget<CDraw, CDev, S>
   | ---------------------------------------------
   | |
   | doesn't satisfy `<_ as Iterator>::Item = Pixel<_>`
   | doesn't satisfy `_: DrawTargetExt`
   | doesn't satisfy `_: DrawTarget`
   | doesn't satisfy `_: Iterator`
   | doesn't satisfy `_: PixelIteratorExt<_>`
   |
   = note: the following trait bounds were not satisfied:
           `<LedPixelDrawTarget<embedded_graphics_core::pixelcolor::rgb_color::Rgb888, LedPixelColorImpl<3, 1, 0, 2, 255>, LedPixelMatrix<28, 8>> as Iterator>::Item = Pixel<_>`
           which is required by `LedPixelDrawTarget<embedded_graphics_core::pixelcolor::rgb_color::Rgb888, LedPixelColorImpl<3, 1, 0, 2, 255>, LedPixelMatrix<28, 8>>: embedded_graphics::iterator::PixelIteratorExt<_>`
           `LedPixelDrawTarget<embedded_graphics_core::pixelcolor::rgb_color::Rgb888, LedPixelColorImpl<3, 1, 0, 2, 255>, LedPixelMatrix<28, 8>>: Iterator`
           which is required by `LedPixelDrawTarget<embedded_graphics_core::pixelcolor::rgb_color::Rgb888, LedPixelColorImpl<3, 1, 0, 2, 255>, LedPixelMatrix<28, 8>>: embedded_graphics::iterator::PixelIteratorExt<_>`
           `<&LedPixelDrawTarget<embedded_graphics_core::pixelcolor::rgb_color::Rgb888, LedPixelColorImpl<3, 1, 0, 2, 255>, LedPixelMatrix<28, 8>> as Iterator>::Item = Pixel<_>`
           which is required by `&LedPixelDrawTarget<embedded_graphics_core::pixelcolor::rgb_color::Rgb888, LedPixelColorImpl<3, 1, 0, 2, 255>, LedPixelMatrix<28, 8>>: embedded_graphics::iterator::PixelIteratorExt<_>`
           `&LedPixelDrawTarget<embedded_graphics_core::pixelcolor::rgb_color::Rgb888, LedPixelColorImpl<3, 1, 0, 2, 255>, LedPixelMatrix<28, 8>>: Iterator`
           which is required by `&LedPixelDrawTarget<embedded_graphics_core::pixelcolor::rgb_color::Rgb888, LedPixelColorImpl<3, 1, 0, 2, 255>, LedPixelMatrix<28, 8>>: embedded_graphics::iterator::PixelIteratorExt<_>`
           `LedPixelDrawTarget<embedded_graphics_core::pixelcolor::rgb_color::Rgb888, LedPixelColorImpl<3, 1, 0, 2, 255>, LedPixelMatrix<28, 8>>: DrawTarget`
           which is required by `LedPixelDrawTarget<embedded_graphics_core::pixelcolor::rgb_color::Rgb888, LedPixelColorImpl<3, 1, 0, 2, 255>, LedPixelMatrix<28, 8>>: embedded_graphics::draw_target::DrawTargetExt`
           `<&mut LedPixelDrawTarget<embedded_graphics_core::pixelcolor::rgb_color::Rgb888, LedPixelColorImpl<3, 1, 0, 2, 255>, LedPixelMatrix<28, 8>> as Iterator>::Item = Pixel<_>`
           which is required by `&mut LedPixelDrawTarget<embedded_graphics_core::pixelcolor::rgb_color::Rgb888, LedPixelColorImpl<3, 1, 0, 2, 255>, LedPixelMatrix<28, 8>>: embedded_graphics::iterator::PixelIteratorExt<_>`
           `&mut LedPixelDrawTarget<embedded_graphics_core::pixelcolor::rgb_color::Rgb888, LedPixelColorImpl<3, 1, 0, 2, 255>, LedPixelMatrix<28, 8>>: Iterator`
           which is required by `&mut LedPixelDrawTarget<embedded_graphics_core::pixelcolor::rgb_color::Rgb888, LedPixelColorImpl<3, 1, 0, 2, 255>, LedPixelMatrix<28, 8>>: embedded_graphics::iterator::PixelIteratorExt<_>`

For more information about this error, try `rustc --explain E0599`.
warning: `pixel-board-firmware` (example "ws2812_embedded_graphics") generated 1 warning

I have read that are some (breaking) API changes between embedded-graphics versions. I have tried a number of versions and 0.7.1 works for me.

Thanks for your work in this library.

cat-in-136 commented 1 year ago

As you understand it, for now, I simply have not taken enough time to make my library compatible with embedded graphics 0.8.x upgrading.

punkto commented 1 year ago

Thanks again.

cat-in-136 commented 1 year ago

@punkto I'm preparing PR #28 and the embedded-graphics-0.8 branch to resolve this issue.

If you still face same issue even for the branch, please let me know.

punkto commented 1 year ago

It works! Thanks @cat-in-136