Closed pdgilbert closed 1 year ago
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.
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).
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();
}
}
I think this has been resolved.
ssd1306
in use (if applicable): fork from recent git (15e47c135b )Description of the problem/feature request/other
I forked to check how difficult it will be to convert rtic examples to recent release
cortex-m-rtic v1.0.0
. (I'm expecting some updating will be needed so if anyone has already done this then please point the way.) The very first thing I've hit is a problem which must be trivial but I don't understand. Changing onlyCargo.toml
linecortex-m-rtic = "0.5.6"
tocortex-m-rtic = "1.0.0"
I getCargo update after the change gave
so it looks like there is no change to
memchr
. If I add[dependencies]
memchr = { version = "2", default-features = false }
it makes no difference. Thememchr
documentation suggests it isno_std
, and in any case I do not see why the change in version ofcortex-m-rtic
affects this.Any hints?