Closed ASoldo closed 1 year ago
Hi @ASoldo,
Nice to hear that you're using the Flipper Zero as a way of learning Rust!
Sadly the flipperzero
crate doesn't currently expose GPIO or notifications, but it's not too painful to do so using the low-level flipperzero-sys
crate.
I've just added a notification example showing how this can be done. I still need to take a look at what GPIO would require.
That is great, thank you. If you could take a look at GPIO and simple toggle open pin/close pin, I will have more than enough to start playing. Since I do have all that in C. But I kinda like Rust and would like to switch to it 100%. This would help me a lot. Also, I can share demos faster and document stuff myself.
I dug out the breadboard and was able to get a GPIO example working.
The biggest issue I found is that a number of the furi_hal_gpio_
functions are defined inline
, thus there's no implementation in the SDK. Hence the need for reimplementing gpio_write
.
Let me know if that's enough to get you unblocked. Happy hacking!
Thank you for your quick response, I do appreciate time and effort. I will try it right now (ERRATA: Works great!). I have one question rn, since you mention that gpio_write needs re implementation, is that something that will take some time to do or that could be done fairly easy? Just to know for future reference when I get back for more examples, will this example work or I will need to use exposed api.
Awesome! Glad that it works for you!
Here's my implementation of gpio_write
. It's almost a 1:1 port of furi_hal_gpio_write
to Rust. The gpio_read
function would be quite similar.
These functions should be good to go "as-is". The only real risk is if the C API has a breaking change.
Now that I've implemented these once with flipperzero-sys
, it shouldn't be too much work to turn them into safe bindings. I'd like to do that before I release 0.6.0
.
Hi, can we get simple example how to use notification/notification_messages in rust? So far demo with DialogMessageButtons is only way we can interact with key presses. I am new to Rust and Flipper Zero and would really appropriate sample how to achieve this. Simple key input check and log message. Also GPIO would also be great to have some guides. Thank you!