Comments (4)
I've reproduce this locally which is good. Looks like tinybmp
and it's older nom
dependency is the culprit:
memchr v2.3.4
└── nom v6.2.1
└── tinybmp v0.3.1
[dev-dependencies]
└── ssd1306 v0.7.0 (/Users/james/Repositories/ssd1306)
I'll do some fiddling in tinybmp and see what I can do there.
from ssd1306.
Looks like the dependency issue is fixed by using edition = "2021"
in Cargo.toml. I want to do the same with tinybmp anyway, so this would be a good opportunity to upgrade (and open the door to some shinier new features perhaps).
from ssd1306.
Ok, that solves the dependency issue. FWIW, copied below is example rtic_dvd
with the gross syntax/renaming/etc of cortex-m-rtic v1.0.0
. It gets as far as locking issues and de-referencing problems that are a bit beyond me. I've possibly added some unneeded things and maybe clobbered things that are needed.
//! Bounce a DVD player logo around the screen
//!
//! Like this, but with no color changing: https://bouncingdvdlogo.com/
//!
//! For best results, run with the `--release` flag.
#![no_std]
#![no_main]
use panic_halt as _;
use rtic::app;
#[rtic::app(device = stm32f1xx_hal::pac, dispatchers = [TIM1_UP, EXTI0])]
mod app {
use ssd1306::{mode::BufferedGraphicsMode, prelude::*, Ssd1306};
use systick_monotonic::*;
// secs() and millis() methods from https://docs.rs/fugit/latest/fugit/trait.ExtU32.html#tymethod.secs
use fugit::TimerDuration;
const MONOTICK: u32 = 100;
const CLOCK: u32 = 8_000_000;
use stm32f1xx_hal::{
delay::Delay,
gpio,
pac::{self, SPI1},
prelude::*,
spi::{self, Mode, Phase, Polarity, Spi},
timer::{CountDownTimer, Event, Timer},
};
use tinybmp::Bmp;
type Display = Ssd1306<
SPIInterfaceNoCS<
spi::Spi<
SPI1,
spi::Spi1NoRemap,
(
gpio::gpioa::PA5<gpio::Alternate<gpio::PushPull>>,
gpio::gpioa::PA6<gpio::Input<gpio::Floating>>,
gpio::gpioa::PA7<gpio::Alternate<gpio::PushPull>>,
),
u8,
>,
gpio::gpiob::PB1<gpio::Output<gpio::PushPull>>,
>,
DisplaySize128x64,
BufferedGraphicsMode<DisplaySize128x64>,
>;
use display_interface_spi::SPIInterfaceNoCS;
use embedded_graphics::{
geometry::Point,
image::Image,
pixelcolor::{BinaryColor, Rgb565},
prelude::*,
primitives::{PrimitiveStyle, Rectangle},
};
#[shared]
struct Shared {
display: Display,
timer: CountDownTimer<pac::TIM1>,
top_left: Point,
velocity: Point,
bmp: Bmp<Rgb565, 'static>,
}
#[local]
struct Local {}
#[monotonic(binds = SysTick, default = true)]
type MyMono = Systick<MONOTICK>;
#[init]
fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) {
let dp = cx.device;
let core = cx.core;
let mut flash = dp.FLASH.constrain();
let mut rcc = dp.RCC.constrain();
let clocks = rcc
.cfgr
.use_hse(8.mhz())
.sysclk(72.mhz())
.pclk1(36.mhz())
.freeze(&mut flash.acr);
let mut afio = dp.AFIO.constrain(&mut rcc.apb2);
let mut gpiob = dp.GPIOB.split(&mut rcc.apb2);
let mut gpioa = dp.GPIOA.split(&mut rcc.apb2);
// SPI1
let sck = gpioa.pa5.into_alternate_push_pull(&mut gpioa.crl);
let miso = gpioa.pa6;
let mosi = gpioa.pa7.into_alternate_push_pull(&mut gpioa.crl);
let mut delay = Delay::new(core.SYST, clocks);
let mut rst = gpiob.pb0.into_push_pull_output(&mut gpiob.crl);
let dc = gpiob.pb1.into_push_pull_output(&mut gpiob.crl);
let spi = Spi::spi1(
dp.SPI1,
(sck, miso, mosi),
&mut afio.mapr,
Mode {
polarity: Polarity::IdleLow,
phase: Phase::CaptureOnFirstTransition,
},
8.mhz(),
clocks,
&mut rcc.apb2,
);
let interface = display_interface_spi::SPIInterfaceNoCS::new(spi, dc);
let mut display = Ssd1306::new(interface, DisplaySize128x64, DisplayRotation::Rotate180)
.into_buffered_graphics_mode();
display.reset(&mut rst, &mut delay).unwrap();
display.init().unwrap();
// Update framerate
let fps = 20;
let mut timer = Timer::tim1(dp.TIM1, &clocks, &mut rcc.apb2).start_count_down(fps.hz());
timer.listen(Event::Update);
let bmp = Bmp::from_slice(include_bytes!("dvd.bmp")).unwrap();
let mono = Systick::new(cx.core.SYST, CLOCK);
(Shared { timer, display, top_left: Point::new(5, 3),velocity: Point::new(1, 1), bmp },
Local {},
init::Monotonics(mono))
}
// just guessing on capacity
#[task(shared = [timer, display, top_left, velocity, bmp], capacity=2)]
fn update(cx: update::Context) {
// let update::Resources {
// display,
// top_left,
// velocity,
// timer,
// bmp,
// ..
// } = cx.resources;
let bottom_right = *cx.shared.top_left + cx.shared.bmp.bounding_box().size;
// Erase previous image position with a filled black rectangle
Rectangle::with_corners(*cx.shared.top_left, bottom_right)
.into_styled(PrimitiveStyle::with_fill(BinaryColor::Off))
.draw(cx.shared.display)
.unwrap();
// Check if the image collided with a screen edge
{
if bottom_right.x > cx.shared.display.size().width as i32 || cx.shared.top_left.x < 0 {
cx.shared.velocity.x = -cx.shared.velocity.x;
}
if bottom_right.y > cx.shared.display.size().height as i32 || cx.shared.top_left.y < 0 {
cx.shared.velocity.y = -cx.shared.velocity.y;
}
}
// Move the image
*cx.shared.top_left += *cx.shared.velocity;
// Draw image at new position
Image::new(cx.shared.bmp, *cx.shared.top_left)
.draw(&mut cx.shared.display.color_converted())
.unwrap();
// Write changes to the display
cx.shared.display.flush().unwrap();
// Clears the update flag
cx.shared.timer.clear_update_interrupt_flag();
}
}
from ssd1306.
I think this has been resolved.
from ssd1306.
Related Issues (20)
- ssd1306 with rtic 1.0.0 HOT 7
- memory.x or probe-run "fix" HOT 6
- [N00b help request] Init fails with Raspberry Pi Pico and Adafruit OLED HOT 3
- Noob Issue: Cant manage to get this building for the stm32f1xx_hal HOT 6
- Newbie: No signs of life from SSD1306 atmega32u4 SPI 128x64 HOT 2
- How to use display with multiple I2C peripherals ([shared-bus] crate?) HOT 3
- Static noise when using crate with embedded_graphics HOT 4
- Using `DrawTarget::clear` is difficult in buffered graphics mode HOT 5
- `DrawTarget` is not implemented for `Ssd1306<I2CInterface<avr_hal_generic::i2c::I2c<.....` HOT 4
- Yet another `DrawTarget` is not implemented for `Ssd1306<SPIInterface<Spi... HOT 6
- Unable to draw circles & lines using embedded graphics crate
- Issues with 128x32 Display on Elegoo Arduino UnoR3
- read or toggle pixel in bufferedMode? HOT 4
- Using terminal mode with 90/270 degree rotation leads to incorrect output and panic HOT 1
- Configurable I2C address HOT 1
- trait `DrawTarget` is not implemented for ... / esp_idf_hal::i2c::*
- Buffered graphics paging issues.
- embedded-hal v1.0.0 and embedded-hal-bus HOT 4
- Custom mode support
- :rotating_light: Finding a new owner for this crate HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ssd1306.