I'm interested in creating a simple 8x8 keyboard matrix scanner and was wondering if I was heading down the right path with my code.
Initializations:
int m,j,i;
for(m=0;m<8;m++){
MIOS32_DOUT_PinSet(m,1);
}
int prevState[8] = {1,1,1,1,1,1,1,1};
And this is inside of APP_Background, repeating endlessly:
for (j=0; j<8; j++) {
MIOS32_DOUT_PinSet(j,0);
for (i=0; i<8; i++) {
if(MIOS32_DIN_PinGet(i)==0 && prevState[i]==1)
{
//Send button on message
prevState[i]=0;
}
if (MIOS32_DIN_PinGet(i)==1 && prevState[i]==0)
{
//Send button off message
prevState[i]=1;
}
else prevState[i] = MIOS32_DIN_PinGet(i);
}
MIOS32_DOUT_PinSet(j,1);
}