mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-07-17 21:22:05 +00:00
update skyloong/gk75/q2/matrix.c
This commit is contained in:
parent
3ef6ac1542
commit
7974bb17c5
@ -9,9 +9,9 @@
|
|||||||
#define CLOCK_TIME 15
|
#define CLOCK_TIME 15
|
||||||
#define MATRIX_INPUT_PRESSED_STATE 0
|
#define MATRIX_INPUT_PRESSED_STATE 0
|
||||||
|
|
||||||
#define HC595_ST_PIN A6
|
#define MATRIX_HC595_ST_PIN A6
|
||||||
#define HC595_SH_PIN A5
|
#define MATRIX_HC595_SH_PIN A5
|
||||||
#define HC595_DS_PIN A7 //定义74HC595的串口数据输入端
|
#define MATRIX_HC595_DS_PIN A7 //定义74HC595的串口数据输入端
|
||||||
|
|
||||||
/* matrix state(1:on, 0:off) */
|
/* matrix state(1:on, 0:off) */
|
||||||
extern matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values
|
extern matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values
|
||||||
@ -57,22 +57,22 @@ static inline uint8_t readMatrixPin(pin_t pin) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline void clockPulse(uint16_t n) {
|
static inline void clockPulse(uint16_t n) {
|
||||||
gpio_write_pin_high(HC595_SH_PIN);
|
gpio_write_pin_high(MATRIX_HC595_SH_PIN);
|
||||||
gpio_write_pin_high(HC595_ST_PIN);
|
gpio_write_pin_high(MATRIX_HC595_ST_PIN);
|
||||||
select_delay(n);
|
select_delay(n);
|
||||||
gpio_write_pin_low(HC595_SH_PIN);
|
gpio_write_pin_low(MATRIX_HC595_SH_PIN);
|
||||||
gpio_write_pin_low(HC595_ST_PIN);
|
gpio_write_pin_low(MATRIX_HC595_ST_PIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
// matrix code
|
// matrix code
|
||||||
|
|
||||||
static bool select_col(uint8_t col) {
|
static bool select_col(uint8_t col) {
|
||||||
gpio_atomic_set_pin_output_high(HC595_DS_PIN);
|
gpio_atomic_set_pin_output_high(MATRIX_HC595_DS_PIN);
|
||||||
for (uint8_t m = 0; m <= col; m++) {
|
for (uint8_t m = 0; m <= col; m++) {
|
||||||
if(m == 0){
|
if(m == 0){
|
||||||
gpio_write_pin_low(HC595_DS_PIN);
|
gpio_write_pin_low(MATRIX_HC595_DS_PIN);
|
||||||
}else{
|
}else{
|
||||||
gpio_write_pin_high(HC595_DS_PIN);
|
gpio_write_pin_high(MATRIX_HC595_DS_PIN);
|
||||||
}
|
}
|
||||||
clockPulse(CLOCK_TIME);
|
clockPulse(CLOCK_TIME);
|
||||||
}
|
}
|
||||||
@ -82,16 +82,16 @@ static bool select_col(uint8_t col) {
|
|||||||
|
|
||||||
static void unselect_col(uint8_t col) {
|
static void unselect_col(uint8_t col) {
|
||||||
uint8_t x = (MATRIX_COLS - col);
|
uint8_t x = (MATRIX_COLS - col);
|
||||||
gpio_atomic_set_pin_output_high(HC595_DS_PIN);
|
gpio_atomic_set_pin_output_high(MATRIX_HC595_DS_PIN);
|
||||||
for (uint8_t y = 0; y < x ; y++) {
|
for (uint8_t y = 0; y < x ; y++) {
|
||||||
clockPulse(CLOCK_TIME);
|
clockPulse(CLOCK_TIME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void unselect_cols(void) {
|
static void unselect_cols(void) {
|
||||||
gpio_atomic_set_pin_output_low(HC595_SH_PIN);
|
gpio_atomic_set_pin_output_low(MATRIX_HC595_SH_PIN);
|
||||||
gpio_atomic_set_pin_output_low(HC595_ST_PIN);
|
gpio_atomic_set_pin_output_low(MATRIX_HC595_ST_PIN);
|
||||||
gpio_atomic_set_pin_output_high(HC595_DS_PIN);
|
gpio_atomic_set_pin_output_high(MATRIX_HC595_DS_PIN);
|
||||||
for (uint8_t x = 0; x < MATRIX_COLS; x++) {
|
for (uint8_t x = 0; x < MATRIX_COLS; x++) {
|
||||||
clockPulse(CLOCK_TIME);
|
clockPulse(CLOCK_TIME);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user