diff options
| author | Nick Brassel <nick@tzarc.org> | 2021-01-18 05:01:38 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-18 05:01:38 +1100 |
| commit | e702c7f1b4cfa8fe1579498ef2877994baa64056 (patch) | |
| tree | 6fcb6c74a1e69f7f981303659cae857f50d0a208 /tmk_core | |
| parent | d6d15b91f3a43b74f177fea9fd2f632eaf303696 (diff) | |
| download | qmk_firmware-e702c7f1b4cfa8fe1579498ef2877994baa64056.tar.gz qmk_firmware-e702c7f1b4cfa8fe1579498ef2877994baa64056.zip | |
Keep track of last matrix activity. (#11552)
Co-authored-by: Dasky <daskygit@users.noreply.github.com>
Co-authored-by: Dasky <daskygit@users.noreply.github.com>
Diffstat (limited to 'tmk_core')
| -rw-r--r-- | tmk_core/common/keyboard.c | 13 | ||||
| -rw-r--r-- | tmk_core/common/keyboard.h | 3 |
2 files changed, 10 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 | ||
diff --git a/tmk_core/common/keyboard.h b/tmk_core/common/keyboard.h index d04e685cd..cc5b2e5e4 100644 --- a/tmk_core/common/keyboard.h +++ b/tmk_core/common/keyboard.h | |||
| @@ -73,6 +73,9 @@ void keyboard_post_init_user(void); | |||
| 73 | void housekeeping_task_kb(void); | 73 | void housekeeping_task_kb(void); |
| 74 | void housekeeping_task_user(void); | 74 | void housekeeping_task_user(void); |
| 75 | 75 | ||
| 76 | uint32_t last_matrix_activity_time(void); // Timestamp of the last matrix activity | ||
| 77 | uint32_t last_matrix_activity_elapsed(void); // Number of milliseconds since the last matrix activity | ||
| 78 | |||
| 76 | #ifdef __cplusplus | 79 | #ifdef __cplusplus |
| 77 | } | 80 | } |
| 78 | #endif | 81 | #endif |
