Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the prototype of matrix_output_unselect_delay() #13045

Merged
merged 1 commit into from
Jul 13, 2021

Conversation

mtei
Copy link
Contributor

@mtei mtei commented May 30, 2021

Description

The prototype of matrix_output_unselect_delay() has been changed as follows.

--- a/quantum/matrix.h
+++ b/quantum/matrix.h
@@ -56,7 +56,7 @@ matrix_row_t matrix_get_row(uint8_t row);
 void matrix_print(void);
 /* delay between changing matrix pin state and reading values */
 void matrix_output_select_delay(void);
-void matrix_output_unselect_delay(void);
+void matrix_output_unselect_delay(uint8_t line, bool key_pressed);
 /* only for backwards compatibility. delay between changing matrix pin state and reading values */
 void matrix_io_delay(void);

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.

 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
     }
}

note: I have not yet checked the operation on real hardware.
I used Helix Rev3 (ProMicro) to verify that it works.

Using matrix_output_unselect_delay() in the above example to optimize the delay processing, the matrix scan rate has been improved from 1525 to 1975.

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout/userspace (addition or update)
  • Documentation

Checklist

  • My code follows the code style of this project: C, Python
  • I have read the PR Checklist document and have made the appropriate changes.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

@tzarc tzarc requested a review from a team June 1, 2021 13:52
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
     }
}
```
@mtei mtei force-pushed the update_matrix_output_unselect_delay branch from a2b2396 to 59c47e3 Compare July 12, 2021 10:51
@mtei mtei marked this pull request as ready for review July 13, 2021 07:20
@mtei mtei merged commit ac2e6e0 into qmk:develop Jul 13, 2021
@mtei mtei deleted the update_matrix_output_unselect_delay branch July 13, 2021 08:14
@alex-ong
Copy link
Contributor

Beautiful optimization!

@mtei
Copy link
Contributor Author

mtei commented Jul 15, 2021

Beautiful optimization!

Thanks!

This is a port of one of the findings gained in the process of trying to create a faster and more flexible matrix.c into the current matrix.c.
see: https://github.com/qmk/qmk_firmware/tree/master/keyboards/handwired/symmetric70_proto/matrix_fast

nhongooi pushed a commit to nhongooi/qmk_firmware that referenced this pull request Dec 5, 2021
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
     }
}
```
BorisTestov pushed a commit to BorisTestov/qmk_firmware that referenced this pull request May 23, 2024
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
     }
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants