So, last time I've made a python class to handle the keypad. Then I thought : "why not trying to make a driver that will behave as a keyboard ?". It took me a couple of days but I was able to make it.
When I tried it, it wasn't always precise BUT, it's because the PCB is currently hanged on a poor and weak third hand, with the buttons just placed on top of it. When I want to press a button, I have to hold it and most of the time, I don't press it straight so it's moving a lot. I've added a software debounce in the driver but it may need some tuning. And I keep in mind that when it is placed in the phone, the buttons are driven by the holes in the case so it will be more stable thant it is now.
An issue I ran into is the usage of the GPIO. At start I was using one of the SPI_CE pin for one of the row but I will probably need it since the screen and the NFC reader use SPI. So I moved onto using both of the UART pins to free some more GPIO for other stuffs (and since I don't use UART, I can skip it). Then the issue arose. The GPIO 14 boot by default in UART_TX mode, which is pulled to HIGH and can't be changed later with the gpio.h library. Luckily, ArchLinux on Raspberry Pi implements device tree. Following this instructions, I was able to make a device tree overlay to initialize all the pins I wanted with pull-downs.
You can find the driver and the device-tree overlay on Github. The driver is not compiled yet so if you want to use it, you have to get the kernel sources and make a "make" in the folder where you put it. You may also want to edit the sources to change the GPIO to fit to your wanting. You can also change the keypad mapping.
Later, we will talk about Tox using PyTox as we already made a small working example.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.