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

skip transport for another matrix based on error count #10468

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 25 additions & 11 deletions quantum/split_common/matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "config.h"
#include "transport.h"

#define MAX_ERROR_COUNT 2048
#define ERROR_DISCONNECT_COUNT 5

#define ROWS_PER_HAND (MATRIX_ROWS / 2)
Expand Down Expand Up @@ -251,21 +252,34 @@ void matrix_init(void) {
split_post_init();
}

// should_skip_by_error now skip twice of the error count
bool should_skip_by_error(uint8_t error_count) {
static uint16_t skip_count = 0;
if(skip_count < error_count * 2) {
skip_count++;
return true;
} else {
skip_count = 0;
return false;
}
}

void matrix_post_scan(void) {
if (is_keyboard_master()) {
static uint8_t error_count;

if (!transport_master(matrix + thatHand)) {
error_count++;

if (error_count > ERROR_DISCONNECT_COUNT) {
// reset other half if disconnected
for (int i = 0; i < ROWS_PER_HAND; ++i) {
matrix[thatHand + i] = 0;
static uint16_t error_count = 0;

if (!should_skip_by_error(error_count)) {
if (!transport_master(matrix + thatHand)) {
error_count = (error_count == MAX_ERROR_COUNT) ? error_count : error_count+1;
if (error_count > ERROR_DISCONNECT_COUNT) {
// reset other half if disconnected
for (int i = 0; i < ROWS_PER_HAND; ++i) {
matrix[thatHand + i] = 0;
}
}
} else {
error_count = 0;
}
} else {
error_count = 0;
}

matrix_scan_quantum();
Expand Down