Defining custom scan function
I would like to use this as the basis for a hall-effect keyboard. However, I plan on using an analog multiplexer which would require some custom scan function going through each channel of the multiplexer then reading out the analog pin and comparing to a threshold (ideally per key) to determine if the key is pressed or not.
Where do I start to implement something like this? Any help is appreciated.
Not sure which parts you're unfamiliar with or how much progress you've made.
- "hall effect read arduino" will be a good starting point for concepts for the firmware side. There's a port of Arduino for CH55x, the code there might work.
- Otherwise, look for the CH55x EVT / Examples for relevant examples of using firmware. (e.g. reading analog values).
- You'd then want to read through FAK to see where it does its matrix scanning. FAK uses the term "central" to refer to the USB HID device. The code might also be generated in the Nickel code.
If you're not committed to using a CH55x, & just like the idea of "nickel-generated keymaps", I'd also point to my nickel-generated keymap project. https://github.com/rgoulter/smart-keymap -- You'd either be able to use an MCU that's just as cheap but is more powerful (like CH32X035), or be able to use RP2040.
Otherwise, it can be useful to study other existing code which uses Hall Effect switches, like https://github.com/peppapighs/libhmk