Add matrix command
This commit is contained in:
committed by
Jeremy Soller
parent
c931eb4eef
commit
2ef4cd7bbd
@ -5,6 +5,7 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <board/keymap.h>
|
||||
#include <ec/kbscan.h>
|
||||
|
||||
// EC config reset key combo: Fn+Esc
|
||||
@ -18,6 +19,9 @@ extern uint16_t kbscan_repeat_period;
|
||||
// ms between pressing key and repeating
|
||||
extern uint16_t kbscan_repeat_delay;
|
||||
|
||||
// Debounced kbscan matrix
|
||||
extern uint8_t kbscan_matrix[KM_OUT];
|
||||
|
||||
void kbscan_init(void);
|
||||
void kbscan_event(void);
|
||||
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include <board/kbc.h>
|
||||
#include <board/kbled.h>
|
||||
#include <board/kbscan.h>
|
||||
#include <board/keymap.h>
|
||||
#include <board/lid.h>
|
||||
#include <board/pmc.h>
|
||||
#include <board/power.h>
|
||||
@ -26,6 +25,8 @@ bool kbscan_enabled = false;
|
||||
uint16_t kbscan_repeat_period = 91;
|
||||
uint16_t kbscan_repeat_delay = 500;
|
||||
|
||||
uint8_t kbscan_matrix[KM_OUT] = { 0 };
|
||||
|
||||
uint8_t sci_extra = 0;
|
||||
|
||||
static inline bool matrix_position_is_esc(int row, int col) {
|
||||
@ -289,7 +290,6 @@ static inline bool key_should_repeat(uint16_t key) {
|
||||
void kbscan_event(void) {
|
||||
static uint8_t kbscan_layer = 0;
|
||||
uint8_t layer = kbscan_layer;
|
||||
static uint8_t kbscan_last[KM_OUT] = { 0 };
|
||||
static uint8_t kbscan_last_layer[KM_OUT][KM_IN] = { { 0 } };
|
||||
static bool kbscan_ghost[KM_OUT] = { false };
|
||||
|
||||
@ -312,7 +312,7 @@ void kbscan_event(void) {
|
||||
int i;
|
||||
for (i = 0; i < KM_OUT; i++) {
|
||||
uint8_t new = kbscan_get_row(i);
|
||||
uint8_t last = kbscan_last[i];
|
||||
uint8_t last = kbscan_matrix[i];
|
||||
if (new != last) {
|
||||
if (kbscan_has_ghost_in_row(i, new)) {
|
||||
kbscan_ghost[i] = true;
|
||||
@ -388,7 +388,7 @@ void kbscan_event(void) {
|
||||
}
|
||||
}
|
||||
|
||||
kbscan_last[i] = new;
|
||||
kbscan_matrix[i] = new;
|
||||
} else if (new && repeat_key != 0 && key_should_repeat(repeat_key)) {
|
||||
// A key is being pressed
|
||||
uint32_t time = time_get();
|
||||
|
@ -20,7 +20,7 @@
|
||||
#ifndef __SCRATCH__
|
||||
#include <board/scratch.h>
|
||||
#include <board/kbled.h>
|
||||
#include <board/keymap.h>
|
||||
#include <board/kbscan.h>
|
||||
#endif
|
||||
#include <board/smfi.h>
|
||||
#include <common/command.h>
|
||||
@ -232,6 +232,17 @@ static enum Result cmd_led_set_color(void) {
|
||||
return RES_ERR;
|
||||
}
|
||||
}
|
||||
|
||||
static enum Result cmd_matrix_get(void) {
|
||||
smfi_cmd[SMFI_CMD_DATA] = KM_OUT;
|
||||
smfi_cmd[SMFI_CMD_DATA + 1] = KM_IN;
|
||||
for (uint8_t row = 0; row < KM_OUT; row++) {
|
||||
if ((SMFI_CMD_DATA + 2 + row) < ARRAY_SIZE(smfi_cmd)) {
|
||||
smfi_cmd[SMFI_CMD_DATA + 2 + row] = kbscan_matrix[row];
|
||||
}
|
||||
}
|
||||
return RES_OK;
|
||||
}
|
||||
#endif // !defined(__SCRATCH__)
|
||||
|
||||
#if defined(__SCRATCH__)
|
||||
@ -357,6 +368,9 @@ void smfi_event(void) {
|
||||
case CMD_LED_SET_COLOR:
|
||||
smfi_cmd[SMFI_CMD_RES] = cmd_led_set_color();
|
||||
break;
|
||||
case CMD_MATRIX_GET:
|
||||
smfi_cmd[SMFI_CMD_RES] = cmd_matrix_get();
|
||||
break;
|
||||
#endif // !defined(__SCRATCH__)
|
||||
case CMD_SPI:
|
||||
smfi_cmd[SMFI_CMD_RES] = cmd_spi();
|
||||
|
@ -38,6 +38,8 @@ enum Command {
|
||||
CMD_LED_GET_MODE = 15,
|
||||
// Set LED matrix mode and speed
|
||||
CMD_LED_SET_MODE = 16,
|
||||
// Get key matrix state
|
||||
CMD_MATRIX_GET = 17,
|
||||
//TODO
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user