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

Shapes and text example from README panics #729

Open
tmcw opened this issue Jul 28, 2023 · 1 comment
Open

Shapes and text example from README panics #729

tmcw opened this issue Jul 28, 2023 · 1 comment

Comments

@tmcw
Copy link

tmcw commented Jul 28, 2023

  • Version of embedded-graphics in use (if applicable): 0.8
  • Target: simulator.
  • If using real hardware: [display driver used]

I'm trying to get started and tried the example in the readme from "Shapes and Text" ( https://github.com/embedded-graphics/embedded-graphics#shapes-and-text ) - but running it unmodified produces

     Running `target/debug/tidbyt-2`
thread 'main' panicked at 'tried to draw pixel twice (x: 61, y: 10)', /Users/tmcw/.cargo/registry/src/index.crates.io-6f17d22bba15001f/embedded-graphics-0.8.0/src/mock_display/mod.rs:383:13
stack backtrace:
   0: rust_begin_unwind
             at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/panicking.rs:593:5
   1: core::panicking::panic_fmt
             at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/core/src/panicking.rs:67:14
   2: embedded_graphics::mock_display::MockDisplay<C>::draw_pixel
             at /Users/tmcw/.cargo/registry/src/index.crates.io-6f17d22bba15001f/embedded-graphics-0.8.0/src/mock_display/mod.rs:383:13
   3: <embedded_graphics::mock_display::MockDisplay<C> as embedded_graphics_core::draw_target::DrawTarget>::draw_iter
             at /Users/tmcw/.cargo/registry/src/index.crates.io-6f17d22bba15001f/embedded-graphics-0.8.0/src/mock_display/mod.rs:714:13
   4: embedded_graphics_core::draw_target::DrawTarget::fill_contiguous
             at /Users/tmcw/.cargo/registry/src/index.crates.io-6f17d22bba15001f/embedded-graphics-core-0.4.0/src/draw_target/mod.rs:392:9
   5: embedded_graphics_core::draw_target::DrawTarget::fill_solid
             at /Users/tmcw/.cargo/registry/src/index.crates.io-6f17d22bba15001f/embedded-graphics-core-0.4.0/src/draw_target/mod.rs:408:9
   6: embedded_graphics::primitives::rectangle::styled::<impl embedded_graphics::primitives::styled::StyledDrawable<embedded_graphics::primitives::primitive_style::PrimitiveStyle<C>> for embedded_graphics_core::primitives::rectangle::Rectangle>::draw_styled
             at /Users/tmcw/.cargo/registry/src/index.crates.io-6f17d22bba15001f/embedded-graphics-0.8.0/src/primitives/rectangle/styled.rs:88:13
   7: <embedded_graphics::primitives::styled::Styled<T,S> as embedded_graphics_core::drawable::Drawable>::draw
             at /Users/tmcw/.cargo/registry/src/index.crates.io-6f17d22bba15001f/embedded-graphics-0.8.0/src/primitives/styled.rs:121:9
   8: tidbyt_2::main
             at ./src/main.rs:45:5
   9: core::ops::function::FnOnce::call_once
             at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

My guess is that this code example should be able to complete drawing?

@Jeffrey-P-McAteer
Copy link

Wanted to buzz in, I've got the same issue. I have a small embedded display I'd like to send frames to, and the following give me this error:

let mut display: MockDisplay<BinaryColor> = MockDisplay::new();
loop {
      /*business logic*/

      let mut data = [BinaryColor::Off; 12 * 11];
      let mut fbuf = FrameBuf::new(&mut data, 12, 11);


      Line::new(Point::new(2, 2), Point::new(10, 2))
          .into_styled(PrimitiveStyle::with_stroke(BinaryColor::On, 2))
          .draw(&mut fbuf)?;
      // Write it all to the display
      let area = Rectangle::new(Point::new(0, 0), fbuf.size());

      display.fill_contiguous(&area, data)?;
}
thread 'main' panicked at /j/.cargo/registry/src/index.crates.io-6f17d22bba15001f/embedded-graphics-0.8.1/src/mock_display/mod.rs:383:13:
tried to draw pixel twice (x: 0, y: 0)
stack backtrace:
   0: rust_begin_unwind
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:72:14
   2: camera_display::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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