!zbjndUiYJDvhDRkPGw:matrix.org

rp-rs

293 Members
Rust on the Raspberry Pi Microcontrollers/Pico https://github.com/rp-rs 30 Servers

Load older messages


SenderMessageTime
27 Sep 2022
@dirbaio:matrix.orgdirbaioyou can use Option and initialize them at runtime https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=9d9856bee24e3d4a43e64c8af79156c019:58:53
@dirbaio:matrix.orgdirbaio with StaticCell and critical_section::Mutex you can get that to have no unsafe 19:59:27
@dirbaio:matrix.orgdirbaiobut there's no way to do it with only static initialization20:00:19
@ithinuel:matrix.orgithinuelYou can also probably get that by not using dyn Trait but instead use an enum of your own with a variant for each type you want to share with the interrupt.20:01:15
@dirbaio:matrix.orgdirbaiof these need to own peripheral singletons, I don't think you can statically initialize them either way20:01:54
@dirbaio:matrix.orgdirbaio * if these need to own peripheral singletons, I don't think you can statically initialize them either way20:01:57
@ithinuel:matrix.orgithinuelThe enum can then have a `fn as_you_trait(&mut self) -> &mut dyn Trait`20:02:16
@ithinuel:matrix.orgithinuel
In reply to @dirbaio:matrix.org
if these need to own peripheral singletons, I don't think you can statically initialize them either way
Yeah, You'll always need the option to share peripheral because they can't be statically initiallized.
20:03:09
@ithinuel:matrix.orgithinuelBut it can become `static mut ABC: Option<[YourEnum; 123_884]>` (that's a large array)20:04:28
@ithinuel:matrix.orgithinuel * The enum can then have a fn as_you_trait(&mut self) -> &mut dyn Trait 20:06:53
@ithinuel:matrix.orgithinuel * But it can become static mut ABC: Option<[YourEnum; 123_884]> (that's a large array) 20:07:06
@ithinuel:matrix.orgithinuel * But it can become static mut ABC: Option<[YourEnum<Variant1,Varian2,Variant3>; 123_884]> (that's a large array) 20:07:51
@ithinuel:matrix.orgithinuelhttps://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=cbf295442e822bca88790ba4881f592620:19:17
@ithinuel:matrix.orgithinuelI hope that's clearer than my english version 😄 20:21:12
@jannic:matrix.orgjannicCould become a huge enum though, given that the type should be "generic over the DMA Channel, PIOExt and StateMachineIndex".20:26:53
@ithinuel:matrix.orgithinuelmacro_rules for the win ! 😄 20:28:52
@dirbaio:matrix.orgdirbaiosomething something too much generics? :P20:28:53
@ithinuel:matrix.orgithinuelI made the enum generic but they could just as well not be generic at all if you know which channel are associated to which PIOExt/StateMachine20:29:43
@dirbaio:matrix.orgdirbaioI mean, if the thing you're storing wasn't generic over the PIOx/DMA_CHx/etc20:30:38
@dirbaio:matrix.orgdirbaioyou wouldn't need dyn/enum in the first place20:31:09
@ithinuel:matrix.orgithinuelIt depends, maybe for a library20:36:12
@ithinuel:matrix.orgithinuelor for readability 20:38:36
@pauldfaria:matrix.orgPaul D. FariaSorry, in between meetings. It's for a library, so not so easy to remove generics (I might end up removing them if I can't solve this). Also, the Option trick does not work for trait objects because of Copy: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=798c47bbde9d4ced390c7dae62b3ebae and adding Copy makes it not a trait object. I'll try the enum approach21:21:08
@dirbaio:matrix.orgdirbaio Paul D. Faria: that's for the array init, you can workaround it by moving the None to a const: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=642399c01eb11757977fee41f68c91d0 21:22:50
@dirbaio:matrix.orgdirbaio or, with #![feature(inline_const)] you can do [const { None }; 2] 21:23:51
@pauldfaria:matrix.orgPaul D. FariaThat is a really nice workaround. I never thought to use that.21:49:22
28 Sep 2022
@yavor:nikolay.ems.hostyavor20220927_221227_4160241036522718899.jpg
Download 20220927_221227_4160241036522718899.jpg
05:12:58
@yavor:nikolay.ems.hostyavorDo you guys know how i can use this?05:13:10
@yavor:nikolay.ems.hostyavorWith rp-rs ofc05:13:17
@jannic:matrix.orgjannicLooks like a HD44780. If it really is one, the lcd_display example might work.05:15:43

There are no newer messages yet.


Back to Room List