That's my current state for the actual keyboard. I will probably drop this and move over to python, since I just don't get the uinput stuff in C and the linux input system. Hey future Dave, research before developing, you know this stuff!
https://github.com/adafruit/Adafruit_Python_MPR121
#include <wiringPi.h>
#include <wiringPiI2C.h>
#include <stdio.h>
int fdH;
int fdL;
int fd;
int rpl;
int ret;
int row = 1;
int rowI = 1;
int col = 1024;
int i = 0;
int j = 0;
int k = 0;
void printByte(int a)
{
printf("\n0x");
for (j=0x8000; j>0; j=j>>1)
{
if ((a&j) > 0) printf("1");
else printf("0");
}
}
int main (void)
{
wiringPiSetup ();
fdH = wiringPiI2CSetup(0x20); // rows only
fdL = wiringPiI2CSetup(0x21); // cols with rows
for (;;)
{
int rowS = 0x03FF ^ row;
int rowL = (rowS<<5) & 0x00FF; // High
int rowH = (rowS>>3) & 0x00FF; // Low
int addL = rowL | 0x1F;
int addH = rowH;
wiringPiI2CWrite(fdH, addH);
wiringPiI2CWrite(fdL, addL);
int keys = wiringPiI2CRead(fdL);
keys = keys & 0x1F;
int keyI = 1;
for (k=0x10; k>0; k=k>>1)
{
if (!(k & keys))
{
delay(50);
printf("%i\t%i\n", keyI, rowI);
}
keyI++;
}
rowI++;
row = row << 1;
if (row == col)
{
row = 1;
rowI = 1;
}
}
return 0 ;
}
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.