Ejemplo n.º 1
0
void delegateGetLiveMatrix(uint8_t *xCurrentMatrix, uint8_t *xIsModified){
	uint8_t col, row;
	uint8_t prev, cur;

	for (col = 0; col < COLUMNS; ++col) {
		delegateSetCellStatus(col);

		for (row = 0; row < ROWS; ++row) {

			cur = delegateGetCellStatus(row);

			prev = xCurrentMatrix[row] & BV(col);

			if(!(prev && cur) && !(!prev && !cur)) {
				if(cur)
					xCurrentMatrix[row] |= BV(col);
				else
					xCurrentMatrix[row] &=~ BV(col);

				*xIsModified = 1;
			}
		}


	}

}
Ejemplo n.º 2
0
uint8_t getLiveMatrix(void){
    uint8_t col, row;
    uint8_t prev, cur;
    
    uint8_t isModified = 0;

    for(col=0;col<COLUMNS;col++)
    {
        // Col -> set only one port as input and all others as output low
        delegateSetCellStatus(col);
        
        // scan each rows
        for(row=0;row<ROWS;row++)
        {
            cur = delegateGetCellStatus(row);

            prev = currentMatrix[row] & BV(col);

            if(!(prev && cur) && !(!prev && !cur)) {
                if(cur)
                    currentMatrix[row] |= BV(col);
                else
                    currentMatrix[row] &=~ BV(col);

                isModified = 1;
            }
        }

    }

    if(isModified){
        debounce=0;
    }else if(debounce<100){ // to prevent going over limit of int
        // 키 입력에 변화가 없다면 99에서 멈춰서 0을 계속 반환하게 된다. 때문에, 키 변화없을때는 키코드 갱신없음;
        debounce++;
    }

    if(debounce != debounceMAX){
        return 0;
    }

#ifdef GHOST_KEY_PREVENTION
    // ghost-key prevention
    // col에 2개 이상의 입력이 있을 경우, 입력이 있는 row에는 더이상 입력을 허용하지 않는다.    
    
    if(findGhostKey() > 0){
        ghostFilterMatrixPointer = prevMatrix;
    }else{
        ghostFilterMatrixPointer = currentMatrix;
    }

    // DEBUG_PRINT(("GHOST_KEY_PREVENTION  p : %d, prevMatrix : %d, currentMatrix : %d \n", ghostFilterMatrixPointer, prevMatrix, currentMatrix));
#endif

    return 1;
}