-
Notifications
You must be signed in to change notification settings - Fork 185
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
Cannot create static HistoryBuffer #158
Comments
That's (currently) unavoidable since the |
So currently I can create it only to stack? |
I will have a look at fixing this, it's was a miss in my review of the |
For now, you can put it in an option as a workaround. |
Like this? #[app(device = hal::stm32, peripherals = true)]
const APP: () = {
struct Resources {
ntc: &'static HistoryBuffer<u16, U100>,
}
#[init]
fn init(mut ctx: init::Context) -> init::LateResources {
// hack to make a static alloc
static mut NTC: Option<HistoryBuffer::<u16, U100>> = None;
unsafe {NTC = Some(HistoryBuffer::new())};
init::LateResources {
ntc: unsafe {NTC.as_mut().unwrap()},
}
} |
Ah no, I think this should work with RTFM: #[app(device = hal::stm32, peripherals = true)]
const APP: () = {
struct Resources {
ntc: HistoryBuffer<u16, U100>,
}
#[init]
fn init(mut ctx: init::Context) -> init::LateResources {
init::LateResources {
ntc: HistoryBuffer::new(),
}
} |
Indeed, this is much better. |
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With
Vec
it is possible to do this:However HistoryBuffer is missing in
heapless::i
.The text was updated successfully, but these errors were encountered: