Pārlūkot izejas kodu

Fix ghost block and remove matrix_has_ghost()

led_matrix
tmk pirms 11 gadiem
vecāks
revīzija
9e9a85c142
4 mainītis faili ar 27 papildinājumiem un 16 dzēšanām
  1. 24
    1
      common/keyboard.c
  2. 0
    2
      common/matrix.h
  3. 1
    0
      keyboard/hbkb/Makefile.lufa
  4. 2
    13
      keyboard/hbkb/matrix.c

+ 24
- 1
common/keyboard.c Parādīt failu

#endif #endif




#ifdef MATRIX_HAS_GHOST
static bool has_ghost_in_row(uint8_t row)
{
matrix_row_t matrix_row = matrix_get_row(row);
// No ghost exists when less than 2 keys are down on the row
if (((matrix_row - 1) & matrix_row) == 0)
return false;

// Ghost occurs when the row shares column line with other row
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
if (i != row && (matrix_get_row(i) & matrix_row))
return true;
}
return false;
}
#endif


void keyboard_init(void) void keyboard_init(void)
{ {
// TODO: configuration of sendchar impl // TODO: configuration of sendchar impl
matrix_change = matrix_row ^ matrix_prev[r]; matrix_change = matrix_row ^ matrix_prev[r];
if (matrix_change) { if (matrix_change) {
if (debug_matrix) matrix_print(); if (debug_matrix) matrix_print();

#ifdef MATRIX_HAS_GHOST
if (has_ghost_in_row(r)) {
matrix_prev[r] = matrix_row;
continue;
}
#endif
for (uint8_t c = 0; c < MATRIX_COLS; c++) { for (uint8_t c = 0; c < MATRIX_COLS; c++) {
if (matrix_change & ((matrix_row_t)1<<c)) { if (matrix_change & ((matrix_row_t)1<<c)) {
action_exec((keyevent_t){ action_exec((keyevent_t){

+ 0
- 2
common/matrix.h Parādīt failu

uint8_t matrix_scan(void); uint8_t matrix_scan(void);
/* whether modified from previous scan. used after matrix_scan. */ /* whether modified from previous scan. used after matrix_scan. */
bool matrix_is_modified(void); bool matrix_is_modified(void);
/* whether ghosting occur on matrix. */
bool matrix_has_ghost(void);
/* whether a swtich is on */ /* whether a swtich is on */
bool matrix_is_on(uint8_t row, uint8_t col); bool matrix_is_on(uint8_t row, uint8_t col);
/* matrix state on row */ /* matrix state on row */

+ 1
- 0
keyboard/hbkb/Makefile.lufa Parādīt failu

# #
MOUSEKEY_ENABLE = yes # Mouse keys MOUSEKEY_ENABLE = yes # Mouse keys
EXTRAKEY_ENABLE = yes # Audio control and System control EXTRAKEY_ENABLE = yes # Audio control and System control
CONSOLE_ENABLE = yes # Console for debug
#NKRO_ENABLE = yes # USB Nkey Rollover #NKRO_ENABLE = yes # USB Nkey Rollover
#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support



+ 2
- 13
keyboard/hbkb/matrix.c Parādīt failu

return false; return false;
} }


inline
bool matrix_has_ghost(void)
{
#ifdef MATRIX_HAS_GHOST
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
if (matrix_has_ghost_in_row(i))
return true;
}
#endif
return false;
}

inline inline
bool matrix_is_on(uint8_t row, uint8_t col) bool matrix_is_on(uint8_t row, uint8_t col)
{ {


// ghost exists in case same state as other row // ghost exists in case same state as other row
for (uint8_t i=0; i < MATRIX_ROWS; i++) { for (uint8_t i=0; i < MATRIX_ROWS; i++) {
if (i != row && (matrix[i] & matrix[row]) == matrix[row])
//if (i != row && (matrix[i] & matrix[row]) == matrix[row])
if (i != row && (matrix[i] & matrix[row]))
return true; return true;
} }
return false; return false;