esp-rs / esp8266-hal

A experimental hardware abstraction layer for the esp8266 written in Rust.
Apache License 2.0
157 stars 16 forks source link

Expose Pin Traits #13

Closed Chaostheorie closed 3 years ago

Chaostheorie commented 3 years ago

Thank you for your work on this crate. I've recently started to work with rust for embedded programming, and I've wanted to write a library for LCD peripherals (similar to the ones available for Arduino). But I've been kinda stuck with how to handle the storage of Objects representing a GPIO Pin for Data Pins. This may just be me being blind when reading the documentation, but I'm unable to access the used InputPin, OutputPin, StatefulOutputPin traits that all GPIO pins implement.

The intended usage would be to either get the pins from a dev and store them in a slice or vec on runtime. I would've tried to use something like [dyn ...Pin. 8]. ATM I'm handling this by having functions that run a match on usize ints to toggle pins with sth similar to high(pin: usize) but this isn't an efficient or portable solution. I've also tried creating an enum and implementing methods for all pins, but that has the same problems with performance and portability.

Any help would be appreciated :)

Chaostheorie commented 3 years ago

Huh, even the idea of using usize as alias has problems. I might consider just writing to the register directly on runtime.

Chaostheorie commented 3 years ago

Using the embedded-hal crate solved the problem