Rust ESP32 Community Meeting 2023-08-31 #189
Replies: 4 comments 1 reply
-
Rust Releases
ESP-IDF Releases
Books
Future Events
Experiments
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I'd like to talk a bit about having the pins in a frunk hlist: esp-rs/esp-hal#745 In short: "Compile-time checked HashSet, but indexed by type (not value), and If you're familiar with FP style lists, it's that, but a list of types, all done at compile-time. Essentially, it could turn this code: struct SomePeriph {
pin4: GpioPin<Unknown, 4>,
pin5: GpioPin<Unknown, 5>,
pin6: GpioPin<Unknown, 6>,
}
let io = IO::new(peripherals.GPIO, peripherals.IO_MUX);
let pin4 = io.pins.gpio4;
let pin5 = io.pins.gpio5;
let pin6 = io.pins.gpio6;
let periph = SomePeriph::init(
pin4,
pin5,
pin6,
); into: #[derive(frunk::ListBuild)]
struct SomePeriph {
pin4: GpioPin<Unknown, 4>,
pin5: GpioPin<Unknown, 5>,
pin6: GpioPin<Unknown, 6>,
}
let io = IO::hl_new(peripherals.GPIO, peripherals.IO_MUX);
let (blinker, _io) = SomePeriph::hl_build(io.pins); ...with a bit more work #[derive(frunk::ListBuild)]
struct SomePeriph {
// needs better ergonomics, but: these annotations show how to pluck and initialize each pin.
// I have some ideas that would require only the pluck annotation.
// The pluck annotation is essentially saying "this is the type-index by which you are obtaining the needed value"
#[init(into_push_pull_output)]
#[init(set_high)]
#[pluck(GpioPin<Unknown, 4>)]
pin4: GpioPin<Output<PushPull>, 4>,
#[init(into_push_pull_output)]
#[init(set_high)]
#[pluck(GpioPin<Unknown, 5>)]
pin5: GpioPin<Output<PushPull>, 5>,
#[pluck(GpioPin<Unknown, 6>)]
#[init(into_push_pull_output)]
#[init(set_high)]
pin6: GpioPin<Output<PushPull>, 6>,
}
fn main() -> ! {
// snip
let io = IO::hl_new(peripherals.GPIO, peripherals.IO_MUX);
let (blinker, _io) = SomePeriph::hl_init(io);
// snip...
} as for applying the list-approach internally, the goal is for it to just be a matter of adding The goal, ultimately is:
By seeing how this fits into this hal, I'd like to get an understanding of its value: how much, why, when, etc., with a possible follow-up of doing some research of what it might add to the upstream |
Beta Was this translation helpful? Give feedback.
-
no_std-training
esp-wifi
esp-ieee802154
esp-openthread
esp-hal
esp-storage
|
Beta Was this translation helpful? Give feedback.
-
Please add topics and links to this discussion.
The meeting is scheduled for 31st August 2023 - 5 pm CEST/GMT+2 (a.k.a. Brno time) via Google Meet. The meeting invite is automatically sent to attendees of previous meetings. If you'd like to join, please notify us at https://matrix.to/#/#esp-rs-community-meetins:matrix.org
You can find information from the previous meeting at https://github.com/esp-rs/rust/discussions
If you find a topic exciting, click Arrow Icon or Emoji, and your vote will give the preference to the topic.
Beta Was this translation helpful? Give feedback.
All reactions