summaryrefslogtreecommitdiff
path: root/quantum/matrix.c
AgeCommit message (Collapse)Author
2022-12-09Core: Support inverted scan logic for optical switches (#19053)dexter93
2022-07-07Make debounce() signal changes in the cooked matrix as return value (#17554)Stefan Kerkmann
2022-02-12Format code according to conventions (#16322)QMK Bot
2022-02-11Various fixes for matrix _RIGHT handling (#16292)Joel Challis
* Various fixes for matrix _RIGHT handling * clang
2022-02-09Merge remote-tracking branch 'upstream/master' into developNick Brassel
2022-02-09Add support for driving unselected row/col. (#16278)Nick Brassel
2022-01-23Relocate matrix_init_quantum content (#15953)Joel Challis
* Relocate matrix_init_quantum content * Update include order * Fix cherry pick from 15722
2021-12-27Custom matrix lite support for split keyboards (#14674)Jay Greco
* Custom matrix lite support for split keyboards * WIP: matrix -> matrix_common refactor * Move matrix_post_scan() to matrix_common.c
2021-10-26Optimize matrix scanning by removing variable shifts (#14947)Chad Austin
2021-09-18Improvements to handling of disconnected split keyboards. (#14033)Joakim Tufvegren
* Use memcmp and memcpy to compare and copy slave matrix. ...and memset to initialize `matrix` and `raw_matrix`. Increased my scan rate (while connected) by ~100 (on Ergodox Infinity). Effect on AVR is unknown. Co-authored-by: Stefan Kerkmann <karlk90@pm.me> * Fix `matrix_post_scan` signalling change on every scan while disconnected. * Undo removal of initialization of `slave_matrix`. This has the effect of increasing my Ergodox Infinity firmware size by 8 bytes instead of decreasing by 8 bytes, and lowers the scan rate while connected back to the initial value before these changes, but _might_ solve some issues on AVR. Co-authored-by: Stefan Kerkmann <karlk90@pm.me>
2021-08-22Make solo half of split keyboards (more) usable. (#13523)Joakim Tufvegren
* Make solo half of split keyboards (more) usable. Using only one half of a split keyboard (that's using the split_common framework to communicate) is not a great experience, since several read timeouts per scan cycle cause an unusably slow scan rate. This change blocks all split communication attempts for 500 ms (configurable) after an error occurs, causing the scan rate to become at least _more_ usable, but might need some tweaking to work fully on most keyboards. One read timeout still needs to occur after the 500 ms has passed, and if that timeout isn't low enough, some scan cycles may still be too slow. * Fix lint complaint. * Require 25 consecutive comm errors to see comms as disconnected. The number of max errors can be overridden by defining `SPLIT_MAX_CONNECTION_ERRORS`. * Add comments to new defines, and ability to disable disconnection check. Also increase `SPLIT_MAX_CONNECTION_ERRORS` to 40, since it's divisible by most relevant numbers for the description. * Make lint happy ...again * Only update `connection_check_timer` when needed. * Add new defines to split keyboard documentation. * Move connection timeout logic to transport.c, add `is_transport_connected`. * Use split_common disconnection logic in matrix.c. Instead of doing more or less the same thing twice. * Move disconnection logic to `transport_master`. Is a cleaner implementation, and causes the scan rate while disconnected to increase instead of decrease. * Lint fixes. * Lower default `SERIAL_USART_TIMEOUT` to 20 ms. The read timeout must be low enough to not cause exessively long scan cycles when using a solo split half. 10 ms was determined from testing to work fine even with the slowest defined baudrate of 19200 (5 ms was too low for that case), so 20 ms should be fine for most cases. * Remove `SERIAL_USART_TIMEOUT` from ergodox_infinity/config.h Was somewhat mistakenly included in an earlier PR. * Fix building with `USE_I2C`. * Reduce built firmware size. Not really sure why this works, the idea was taken from tzarc's work on split disconnection. * Tweak and improve opt-out for split disconnection logic. There are now two ways to opt out from this feature: * Set `SPLIT_MAX_CONNECTION_ERRORS` to 0. This will completely disable the connection status checks (also affects the slave matrix reset logic in matrix.c, though). * Set `SPLIT_CONNECTION_CHECK_TIMEOUT` to 0. This will only disable the communication throttling while disconnected. Will make the firmware smaller. * Make split disconnection logic work with custom transports. Includes a fallback implementation for keyboards using a custom split_util.c but not a custom matrix.c (currently no such keyboard seems to be merged, though). * Remove unnecessary include of timer.h Co-authored-by: Joel Challis <git@zvecr.com> Co-authored-by: Joel Challis <git@zvecr.com>
2021-07-13Change the prototype of matrix_output_unselect_delay() (#13045)Takeshi ISHII
The prototype of matrix_output_unselect_delay() has been changed as follows. ```c void matrix_output_unselect_delay(uint8_t line, bool key_pressed); ``` Currently, no keyboard seems to be redefining `matrix_output_unselect_delay()`, so there is no change in the system behavior. With this change, the keyboard level code can get some optimization hints, for example, the following. ```c void matrix_output_unselect_delay(uint8_t line, bool key_pressed) { /* If none of the keys are pressed, * there is no need to wait for time for the next line. */ if (key_pressed) { #ifdef MATRIX_IO_DELAY # if MATRIX_IO_DELAY > 0 wait_us(MATRIX_IO_DELAY); # endif #else wait_us(30); #endif } } ```
2021-07-12Fix two out of bounds accesses from #13330. (#13525)Joakim Tufvegren
Two occurrences of `MATRIX_ROWS` weren't properly changed to `ROWS_PER_HAND` in #13330, causing a crash during boot on at least my Ergodox Infinity (including #13481).
2021-07-11Unify matrix for split common and regular matrix (#13330)Drashna Jaelre
2021-07-03Add support for NO_PIN to all matrix types (#12238)Drashna Jaelre
Co-authored-by: Nick Brassel <nick@tzarc.org>
2021-06-09Use single memcmp to determine if matrix changed. (#13064)Nick Brassel
* Use memcmp to determine if matrix changed. * Firmware size issues. * Add documentation for the lack of need of MATRIX_ROW_PINS/MATRIX_COL_PINS, when overriding low-level matrix functions.
2021-06-01Add weak refs on reading rows/cols. (#13062)Nick Brassel
2021-05-20matrix: wait for row signal to go HIGH for every row (#12945)Michael Stapelberg
I noticed this discrepancy (last row of the matrix treated differently than the others) when optimizing the input latency of my keyboard controller, see also https://michael.stapelberg.ch/posts/2021-05-08-keyboard-input-latency-qmk-kinesis/ Before this commit, when tuning the delays I noticed ghost key presses when pressing the F2 key, which is on the last row of the keyboard matrix: the dead_grave key, which is on the first row of the keyboard matrix, would be incorrectly detected as pressed. After this commit, all keyboard matrix rows are interpreted correctly. I suspect that my setup is more susceptible to this nuance than others because I use GPIO_INPUT_PIN_DELAY=0 and hence don’t have another delay that might mask the problem.
2021-01-13fix matrix_io_delay() timing in quantum/matrix.c (#9603)Takeshi ISHII
* fix matrix_io_delay() timing in quantum/matrix.c * Updated comments explaining the need for matrix_io_delay() in quantum/matrix.c * fix matrix_io_delay() timing in quantum/split_common/matrix.c * Update quantum/matrix.c Co-authored-by: Ryan <fauxpark@gmail.com> * Update quantum/split_common/matrix.c Co-authored-by: Ryan <fauxpark@gmail.com> * Update quantum/matrix.c Co-authored-by: Ryan <fauxpark@gmail.com> * Update quantum/split_common/matrix.c Co-authored-by: Ryan <fauxpark@gmail.com> * add waitOutputPinValid() and wait_cpuclock() into quantum/quantum.h and tmk_core/common/wait.h * add matrix_output_select_delay() and matrix_output_unselect_delay() * fix quantum/matrix_common.c, tmk_core/common/matrix.h * fix tmk_core/common/wait.h * fix quantum/quantum.h, tmk_core/common/wait.h * waitOutputPinValid() rename to waitInputPinDelay() in quantum/quantum.h. * waitOutputPinValid() rename to waitInputPinDelay() in quantum/matrix_common.c * update tmk_core/common/wait.h * update comment in quantum/matrix.c, quantum/split_common/matrix.c * update quantum/quantum.h: Make more margin in the GPIO_INPUT_PIN_DELAY default value. Co-authored-by: Ryan <fauxpark@gmail.com>
2020-12-17Run cformat and dos2unix manually (#11235)Ryan
2020-11-282020 November 28 Breaking Changes Update (#11053)James Young
* Branch point for 2020 November 28 Breaking Change * Remove matrix_col_t to allow MATRIX_ROWS > 32 (#10183) * Add support for soft serial to ATmega32U2 (#10204) * Change MIDI velocity implementation to allow direct control of velocity value (#9940) * Add ability to build a subset of all keyboards based on platform. * Actually use eeprom_driver_init(). * Make bootloader_jump weak for ChibiOS. (#10417) * Joystick 16-bit support (#10439) * Per-encoder resolutions (#10259) * Share button state from mousekey to pointing_device (#10179) * Add hotfix for chibios keyboards not wake (#10088) * Add advanced/efficient RGB Matrix Indicators (#8564) * Naming change. * Support for STM32 GPIOF,G,H,I,J,K (#10206) * Add milc as a dependency and remove the installed milc (#10563) * ChibiOS upgrade: early init conversions (#10214) * ChibiOS upgrade: configuration file migrator (#9952) * Haptic and solenoid cleanup (#9700) * XD75 cleanup (#10524) * OLED display update interval support (#10388) * Add definition based on currently-selected serial driver. (#10716) * New feature: Retro Tapping per key (#10622) * Allow for modification of output RGB values when using rgblight/rgb_matrix. (#10638) * Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (#10530) * Rescale both ChibiOS and AVR backlighting. * Reduce Helix keyboard build variation (#8669) * Minor change to behavior allowing display updates to continue between task ticks (#10750) * Some GPIO manipulations in matrix.c change to atomic. (#10491) * qmk cformat (#10767) * [Keyboard] Update the Speedo firmware for v3.0 (#10657) * Maartenwut/Maarten namechange to evyd13/Evy (#10274) * [quantum] combine repeated lines of code (#10837) * Add step sequencer feature (#9703) * aeboards/ext65 refactor (#10820) * Refactor xelus/dawn60 for Rev2 later (#10584) * add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (#10824) * [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (#10549) * update chibios os usb for the otg driver (#8893) * Remove HD44780 References, Part 4 (#10735) * [Keyboard] Add Valor FRL TKL (+refactor) (#10512) * Fix cursor position bug in oled_write_raw functions (#10800) * Fixup version.h writing when using SKIP_VERSION=yes (#10972) * Allow for certain code in the codebase assuming length of string. (#10974) * Add AT90USB support for serial.c (#10706) * Auto shift: support repeats and early registration (#9826) * Rename ledmatrix.h to match .c file (#7949) * Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (#10231) * Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (#10840) * Merge point for 2020 Nov 28 Breaking Change
2020-05-21format code according to conventions [skip ci]QMK Bot
2020-05-21Slight speed increases for matrix scanning (#9150)Joel Challis
2020-02-21Allow 30us matrix delay to be keyboard/user overridable (#8216)Joel Challis
* Allow 30us matrix delay to be configurable via define * Move wait logic to matrix_common * Move wait logic to matrix_common - fix wait includes
2020-01-19Enforce definition of `DIODE_DIRECTION` for non-custom matrix boards (#7915)fauxpark
* Enforce definition of `DIODE_DIRECTION` for non-custom matrix boards * Define diode direction for failing boards * Matching parentheses * Put onekey diode directions in top level config
2020-01-15Migrate more custom matrix 'lite' code to core (#7863)Joel Challis
* Migrate more custom matrix lite code to core * Align function names * fix up MATRIX_MASKED
2020-01-04Move some common matrix code to a common location (#7699)Joel Challis
* Move some common matrix code to a common location * Refactor some 'custom_matrix_helper' logic to use custom matrix lite * Fix build for kinesis/stapelberg - abuse of vpath was picking up matrix.c from core when custom matrix was enabled * Add validation for CUSTOM_MATRIX
2019-08-30clang-format changesskullY
2019-07-03fix unselect_rows() in quantum/matrix.c (#6243)Takeshi ISHII
unselect_col() uses setPinInputHigh(), but unselect_cols() uses setPinInput(). This is not correct. unselect_cols() should also use setPinInputHigh().
2019-05-28Fixing matrix_scan so it properly returns changed statusRyan Caltabiano
2019-04-11Port DIRECT_PINS from split_common/matrix.c to matrix.c (#5091)zvecr
* Port DIRECT_PINS from split_common/matrix.c to matrix.c * Reorder matrix.c to remove foward declaration and match split_common/matrix.c * Refactor nano to use DIRECT_PINS * Reorder matrix.c to remove foward declaration and match split_common/matrix.c * Add DIRECT_PINS documentation * Reorder matrix.c to remove foward declaration and match split_common/matrix.c - fix logic from inherited from split_common * Add DIRECT_PINS documentation - review comments
2019-02-14Debounce refactor / API (#3720)Drashna Jaelre
* Added xeal60 via clone of lets split * Delete removed other keymaps * Basic keymap (no FN). Compiles. * Removed NP_STAR and NP_SLSH. * Removed "debounce_algo = manual" in all keyboards with CUSTOM_MATRIX = yes. * Changed order of rules in TMK. Documented feature. * Fixed missing whitespace in debounce documentation Table wasn't working due to missing newline. * Added bold in a few areas. * DO NOT USE - Removed debounce from TMK. * Remove accidental xeal60 commit * DO NOT USE - debounce successfully compiled. * DO NOT USE Revert back to original API to support split_keyboards. * Working eager_pk * Whitespace cleanup. * Restored debounce.h since there wasnt any real change. * Moved debouncing_time variable to inside #if debounce * Removed check for custom_matrix. We can safely include the debounce file for compilation when custom_matrix is used. * Removed #include "matrix.h" from debounce.h * Bug fix - was using MATRIX_ROWS instead of num_rows * Fixed compilation error with debounce_sym_g * Renamed DEBOUNCE_ALGO to DEBOUNCE_TYPE * Malloc array in debounce_eager_pk, since split keyboards only use MATRIX_ROWS/2. * Fix compile error in debounce_eager_pk * Stricter, leaner DEBOUNCE_TYPE section in common_features.mk. Cleanup debounce_type.mk
2019-01-27Fix `1<col` instead of `1<<col` typo in matrix_is_on()James Churchill
2019-01-26DO NOT USE Revert back to original API to support split_keyboards.alex-ong
2019-01-26DO NOT USE - debounce successfully compiled.alex-ong
2019-01-26DO NOT USE Merge branch 'master' into debounce_refactorAlex Ong
Merged, however now there are two debounce.h and debounce.c to mess around with and coalesce. # Conflicts: # quantum/matrix.c
2019-01-17Simplify split_common Code significantly (#4772)James Churchill
* Eliminate separate slave loop Both master and slave run the standard keyboard_task main loop now. * Refactor i2c/serial specific code Simplify some of the preprocessor mess by using common function names. * Fix missing #endif * Move direct pin mapping support from miniaxe to split_common For boards with more pins than sense--sorry, switches. * Reordering and reformatting only * Don't run matrix_scan_quantum on slave side * Clean up the offset/slaveOffset calculations * Cut undebounced matrix size in half * Refactor debouncing * Minor fixups * Split split_common transport and debounce code into their own files Can now be replaced with custom versions per keyboard using CUSTOM_TRANSPORT = yes and CUSTOM_DEBOUNCE = yes * Refactor debounce for non-split keyboards too * Update handwired/xealous to build using new split_common * Fix debounce breaking basic test * Dodgy method to allow a split kb to only include one of i2c/serial SPLIT_TRANSPORT = serial or SPLIT_TRANSPORT = i2c will include only that driver code in the binary. SPLIT_TRANSPORT = custom (or anything else) will include neither, the keyboard must supply it's own code if SPLIT_TRANSPORT is not defined then the original behaviour (include both avr i2c and serial code) is maintained. This could be better but it would require explicitly updating all the existing split keyboards. * Enable LTO to get lets_split/sockets under the line * Add docs for SPLIT_TRANSPORT, CUSTOM_MATRIX, CUSTOM_DEBOUNCE * Remove avr-specific sei() from split matrix_setup Not needed now that slave doesn't have a separate main loop. Both sides (on avr) call sei() in lufa's main() after exiting keyboard_setup(). * Fix QUANTUM_LIB_SRC references and simplify SPLIT_TRANSPORT. * Add comments and fix formatting.
2019-01-04Merge branch 'master' into debounce_refactorAlex Ong
# Conflicts: # tmk_core/common/keyboard.c
2018-09-28Update quantum matrix to support both AVR and Chibios ARM (#3968)yiancar
* Update quantum matrix to support both AVR and Chibios ARM - Addition of STM32 pin definitions - Created abstruction layer defines to control GPIO (This is a bit pointless for Chibios as we are creating a PAL ontop of a PAL but it is necessary for uniformity with AVR) - Modified matrix.c to use the above functions * minor ifdef fix * Rename of functions and docs - Added documentation. - Renamed functions according to Jack's spec. * Massdrop fix * Update matrix.c * Update quantum.h * Update quantum.h * Update quantum.h * Update internals_gpio_control.md
2018-08-29Removed "debounce_algo = manual" in all keyboards with CUSTOM_MATRIX = yes.Alex Ong
2018-06-28Disable JTAG in keyboard initDrashna Jaelre
So that all boards, present and future will have JTAG disabled, even if using a custom matrix
2017-03-28Clarify the quantum license (#1042)skullydazed
* Clarify the license for files we have signoff on * Update against the currently signed off files * Remove unused and not clearly licensed headers * Replace an #endif I accidentally removed while resolving merge conflicts
2017-02-05Add new DIODE_DIRECTION optionNikolaus Wittenstein
The previous two options were COL2ROW, ROW2COL; this adds CUSTOM_MATRIX to disable the built-in matrix scanning code. Most notably, this obviates the need to set MATRIX_ROW_PINS or MATRIX_COL_PINS.
2017-02-05Remove unused matrix_raw variable in matrix.cNikolaus Wittenstein
2016-11-18don't always detect a matrix change (fixes debounce)Jack Humbert
2016-10-29added fixed debounce codeIBNobody
2016-10-29Made scanning more efficientIBNobody
2016-10-28Refactoring Matrix scanningIBNobody
2016-10-28Fixing Debounce - WIPIBNobody
2016-10-23Fixed some large keyboard bugsIBNobody
Fixed some bugs relating to keyboards with more than 16 columns. Also added the ability to mask off keyboard matrix bits.