diff options
| author | Nick Brassel <nick@tzarc.org> | 2021-01-12 19:48:24 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-12 19:48:24 +1100 |
| commit | 79d1db332477963555416d9fff82ecac4399bd52 (patch) | |
| tree | 1d5465b40e857c60e13a855d4667923d6eee0521 /tmk_core/common/keyboard.c | |
| parent | a2aed8ebd7f7501cc33af4cae26608447209a65b (diff) | |
| download | qmk_firmware-79d1db332477963555416d9fff82ecac4399bd52.tar.gz qmk_firmware-79d1db332477963555416d9fff82ecac4399bd52.zip | |
Keep track of last matrix activity (#10730)
* Allow recording of the last matrix activity time, to simplify implementation of display timeouts and the like.
* Add requested changes from code review.
* Simplify split matrix last changed.
Diffstat (limited to 'tmk_core/common/keyboard.c')
| -rw-r--r-- | tmk_core/common/keyboard.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index a1fbc01da..aea09169f 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c | |||
| @@ -97,6 +97,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 97 | # include "dip_switch.h" | 97 | # include "dip_switch.h" |
| 98 | #endif | 98 | #endif |
| 99 | 99 | ||
| 100 | static uint32_t last_matrix_modification_time = 0; | ||
| 101 | uint32_t last_matrix_activity_time(void) { return last_matrix_modification_time; } | ||
| 102 | uint32_t last_matrix_activity_elapsed(void) { return timer_elapsed32(last_matrix_modification_time); } | ||
| 103 | |||
| 100 | // Only enable this if console is enabled to print to | 104 | // Only enable this if console is enabled to print to |
| 101 | #if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE) | 105 | #if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE) |
| 102 | static uint32_t matrix_timer = 0; | 106 | static uint32_t matrix_timer = 0; |
| @@ -338,11 +342,8 @@ void keyboard_task(void) { | |||
| 338 | housekeeping_task_kb(); | 342 | housekeeping_task_kb(); |
| 339 | housekeeping_task_user(); | 343 | housekeeping_task_user(); |
| 340 | 344 | ||
| 341 | #if defined(OLED_DRIVER_ENABLE) && !defined(OLED_DISABLE_TIMEOUT) | 345 | uint8_t matrix_changed = matrix_scan(); |
| 342 | uint8_t ret = matrix_scan(); | 346 | if (matrix_changed) last_matrix_modification_time = timer_read32(); |
| 343 | #else | ||
| 344 | matrix_scan(); | ||
| 345 | #endif | ||
| 346 | 347 | ||
| 347 | if (should_process_keypress()) { | 348 | if (should_process_keypress()) { |
| 348 | for (uint8_t r = 0; r < MATRIX_ROWS; r++) { | 349 | for (uint8_t r = 0; r < MATRIX_ROWS; r++) { |
| @@ -409,7 +410,7 @@ MATRIX_LOOP_END: | |||
| 409 | oled_task(); | 410 | oled_task(); |
| 410 | # ifndef OLED_DISABLE_TIMEOUT | 411 | # ifndef OLED_DISABLE_TIMEOUT |
| 411 | // Wake up oled if user is using those fabulous keys! | 412 | // Wake up oled if user is using those fabulous keys! |
| 412 | if (ret) oled_on(); | 413 | if (matrix_changed) oled_on(); |
| 413 | # endif | 414 | # endif |
| 414 | #endif | 415 | #endif |
| 415 | 416 | ||
