Mercurial > louis > kiibohd-controller
comparison Scan/MatrixARM/matrix_scan.c @ 424:0d1cc6ec4af7
Merge branch 'master' of github.com:kiibohd/controller
author | CryHam <cryham@gmail.com> |
---|---|
date | Tue, 01 Mar 2016 19:40:00 +0100 |
parents | be6b57c5b438 23a1868b4ac2 |
children | 7bc4c6249dff |
comparison
equal
deleted
inserted
replaced
423:be6b57c5b438 | 424:0d1cc6ec4af7 |
---|---|
1 /* Copyright (C) 2014-2015 by Jacob Alexander | 1 /* Copyright (C) 2014-2016 by Jacob Alexander |
2 * | 2 * |
3 * Permission is hereby granted, free of charge, to any person obtaining a copy | 3 * Permission is hereby granted, free of charge, to any person obtaining a copy |
4 * of this software and associated documentation files (the "Software"), to deal | 4 * of this software and associated documentation files (the "Software"), to deal |
5 * in the Software without restriction, including without limitation the rights | 5 * in the Software without restriction, including without limitation the rights |
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | 6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
450 Matrix_pin( Matrix_cols[ strobe ], Type_StrobeOff ); | 450 Matrix_pin( Matrix_cols[ strobe ], Type_StrobeOff ); |
451 } | 451 } |
452 | 452 |
453 | 453 |
454 // Matrix ghosting check and elimination | 454 // Matrix ghosting check and elimination |
455 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | 455 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
456 #ifdef GHOSTING_MATRIX | 456 #ifdef GHOSTING_MATRIX |
457 // strobe = column, sense = row | 457 // strobe = column, sense = row |
458 | 458 |
459 // Count (rows) use for columns | 459 // Count (rows) use for columns |
460 //print("C "); | 460 //print("C "); |
487 } | 487 } |
488 //printInt8(used); | 488 //printInt8(used); |
489 row_use[row] = used; | 489 row_use[row] = used; |
490 row_ghost[row] = 0; // clear | 490 row_ghost[row] = 0; // clear |
491 } | 491 } |
492 | 492 |
493 // Check if matrix has ghost | 493 // Check if matrix has ghost |
494 // Happens when key is pressed and some other key is pressed in same row and another in same column | 494 // Happens when key is pressed and some other key is pressed in same row and another in same column |
495 //print(" G "); | 495 //print(" G "); |
496 for ( uint8_t col = 0; col < Matrix_colsNum; col++ ) | 496 for ( uint8_t col = 0; col < Matrix_colsNum; col++ ) |
497 { | 497 { |
516 for ( uint8_t row = 0; row < Matrix_rowsNum; row++ ) | 516 for ( uint8_t row = 0; row < Matrix_rowsNum; row++ ) |
517 { | 517 { |
518 uint8_t key = Matrix_colsNum * row + col; | 518 uint8_t key = Matrix_colsNum * row + col; |
519 KeyState *state = &Matrix_scanArray[ key ]; | 519 KeyState *state = &Matrix_scanArray[ key ]; |
520 KeyGhost *st = &Matrix_ghostArray[ key ]; | 520 KeyGhost *st = &Matrix_ghostArray[ key ]; |
521 | 521 |
522 // col or row is ghosting (crossed) | 522 // col or row is ghosting (crossed) |
523 uint8_t ghost = (col_ghost[col] > 0 || row_ghost[row] > 0) ? 1 : 0; | 523 uint8_t ghost = (col_ghost[col] > 0 || row_ghost[row] > 0) ? 1 : 0; |
524 | 524 |
525 st->prev = st->cur; // previous | 525 st->prev = st->cur; // previous |
526 // save state if no ghost or outside ghosted area | 526 // save state if no ghost or outside ghosted area |
527 if ( ghost == 0 ) | 527 if ( ghost == 0 ) |
528 st->saved = state->curState; // save state if no ghost | 528 st->saved = state->curState; // save state if no ghost |
529 // final | 529 // final |
530 // use saved state if ghosting, or current if not | 530 // use saved state if ghosting, or current if not |
531 st->cur = ghost > 0 ? st->saved : state->curState; | 531 st->cur = ghost > 0 ? st->saved : state->curState; |
532 | 532 |
533 // Send keystate to macro module | 533 // Send keystate to macro module |
534 KeyPosition k = !st->cur | 534 KeyPosition k = !st->cur |
535 ? (!st->prev ? KeyState_Off : KeyState_Release) | 535 ? (!st->prev ? KeyState_Off : KeyState_Release) |
536 : ( st->prev ? KeyState_Hold : KeyState_Press); | 536 : ( st->prev ? KeyState_Hold : KeyState_Press); |
537 Macro_keyState( key, k ); | 537 Macro_keyState( key, k ); |
538 } | 538 } |
539 } | 539 } |
540 #endif | 540 #endif |
541 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | 541 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
542 | 542 |
543 | 543 |
544 // State Table Output Debug | 544 // State Table Output Debug |
545 if ( matrixDebugStateCounter > 0 ) | 545 if ( matrixDebugStateCounter > 0 ) |
546 { | 546 { |
585 print( NL ); | 585 print( NL ); |
586 } | 586 } |
587 } | 587 } |
588 | 588 |
589 | 589 |
590 // Called by parent scan module whenever the available current changes | |
591 // current - mA | |
592 void Matrix_currentChange( unsigned int current ) | |
593 { | |
594 // TODO - Any potential power savings? | |
595 } | |
596 | |
597 | |
598 | |
590 // ----- CLI Command Functions ----- | 599 // ----- CLI Command Functions ----- |
591 | 600 |
592 void cliFunc_matrixDebug ( char* args ) | 601 void cliFunc_matrixDebug ( char* args ) |
593 { | 602 { |
594 // Parse number from argument | 603 // Parse number from argument |