Remember when I wrote about the buttons on the top panel? After some investigation, I discovered the buttons use a scan matrix - nothing particularly complicated. The columns require the addition of pull-up or pull-down resistors on each row that's scanned to prevent floating pins from reading false positives.
After spending some hours with a multimeter and pressing buttons repeatedly (it was a fascinating evening) I've mapped all of the buttons in the matrix. There are now two options: buy and off-the-shelf matrix scanner, such as the TCA8418 or do it in software. The keyboard scanner ICs are often both (relatively) expensive and produced for industrial applications, so they come in home-assembly-unfriendly WQFN packages. Sure, I can probably solder one - but where's the fun in that? (you'll find this is a common theme in my projects...)
There are two options: I could connect the lines directly to the ESP32 - but there aren't enough GPIOs left for that, or I could use another MCU. This isn't a complex task, so the code will be fairly simple. The most complicated bit will likely be the communication. I2C makes the most sense as it only requires two pins, and since the NFC card reader will be using I2C on the front panel as well, the connections will already be present.
I've settled on the ATtiny series from Atmel. I've used them before and the work here is trivial, so the ATtiny series is ideal. Only a few devices come with enough GPIO pins and come in packages I want to work with, so I've settled with the x61 series. Most likely I'll use the 861 although it will probably be overkill, even if I used the Arduino framework (which I won't). The only hiccup is that the ATtiny x61 series doesn't support any I2C slave functionality, but there is an application note on how to achieve this.
A few days later...
Well, that was fun! I've re-written my code a few times, but I've got there. With the use of timers, interrupts and a few modifications to the usitwislave library, I have the whole thing working nicely on a proto board. I've written a fairly in-depth readme to go with the code so you can read more about how it all works. I've tested this with an ESP32 dev module as the I2C master and it works perfectly. I've made up the PCBs for the front panel, so now I just have to wire it up to the prototype main board and insert the ATTiny. I'll write more about the front panel board in my next post.