HaoboGu / rmk

Rust keyboard firmware library with layers, macros, real-time keymap editing, wireless(BLE) and split support
https://haobogu.github.io/rmk/
Apache License 2.0
632 stars 44 forks source link

[Feature Request] SPI 74HC595 shift register as part of matrix scanning #87

Open ramonimbao opened 1 month ago

ramonimbao commented 1 month ago

ZMK has support for 74HC595 shift registers as parts of its matrix scanning as of adding additional GPIO. This works really well for small boards with few GPIO available like the Seeed Studio XIAO NRF52840. I have boards here I can test for this. I'd like to be able to contribute but I am unfamiliar with embedded Rust, and my Rust skills are definitely rusty 😅

HaoboGu commented 1 month ago

I'm happy to see more matrix types are supported :D

You can combine embedded_hal::spi and MatrixTrait to write a platform diagnostic 74HC595 matrix scanning algorithm. If you have any question about implementing it, just feel free to ask

HaoboGu commented 1 month ago

If you knew Rust before, learning embedded stuff is not that hard. I think some basic embedded and spi protocol knowledge is all you need to implement it.

ramonimbao commented 1 month ago

Was searching around for crates to reference and I found this crate: shiftreg-spi. It seems like exactly what's needed since it implements the OutputPin trait. Does this mean we'll be able to mix it in with a normal matrix alongside other microcontroller GPIO pins? That's exactly how some of my boards are set up.

HaoboGu commented 1 month ago

Was searching around for crates to reference and I found this crate: shiftreg-spi. It seems like exactly what's needed since it implements the OutputPin trait. Does this mean we'll be able to mix it in with a normal matrix alongside other microcontroller GPIO pins? That's exactly how some of my boards are set up.

Yes, it seems that you even don't need to change any RMK code. If I understand it correctly, you can just put the OutputPin list to the matrix, that should work.