mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-07-21 15:12:02 +00:00
update skyloong/gk87/q1
This commit is contained in:
parent
997c3aa33a
commit
0c46346600
@ -2,19 +2,19 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
#include "led_hc595.h"
|
#include "led_hc595.h"
|
||||||
|
|
||||||
#ifndef HC595_ST_PIN
|
#ifndef LED_HC595_ST_PIN
|
||||||
# error hc595: no storage register clock pins defined!
|
# error hc595: no storage register clock pins defined!
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HC595_SH_PIN
|
#ifndef LED_HC595_SH_PIN
|
||||||
# error hc595: no shift register clock pins defined!
|
# error hc595: no shift register clock pins defined!
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HC595_DS
|
#ifndef LED_HC595_DS
|
||||||
# error hc595: no serial data input pins defined!
|
# error hc595: no serial data input pins defined!
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CLOCK_TIME 15
|
#define LED_CLOCK_TIME 15
|
||||||
|
|
||||||
static inline void gpio_set_pin_output_write_low(pin_t pin) {
|
static inline void gpio_set_pin_output_write_low(pin_t pin) {
|
||||||
ATOMIC_BLOCK_FORCEON {
|
ATOMIC_BLOCK_FORCEON {
|
||||||
@ -37,25 +37,25 @@ static inline void select_delay(uint16_t n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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(LED_HC595_SH_PIN);
|
||||||
gpio_write_pin_high(HC595_ST_PIN);
|
gpio_write_pin_high(LED_HC595_ST_PIN);
|
||||||
select_delay(n);
|
select_delay(n);
|
||||||
gpio_write_pin_low(HC595_SH_PIN);
|
gpio_write_pin_low(LED_HC595_SH_PIN);
|
||||||
gpio_write_pin_low(HC595_ST_PIN);
|
gpio_write_pin_low(LED_HC595_ST_PIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
void s_serial_to_parallel(uint8_t data) __attribute__((unused));
|
void s_serial_to_parallel(uint8_t data) __attribute__((unused));
|
||||||
void s_serial_to_parallel(uint8_t data) { // Serial port to parallel port function
|
void s_serial_to_parallel(uint8_t data) { // Serial port to parallel port function
|
||||||
gpio_set_pin_output_write_low(HC595_DS);
|
gpio_set_pin_output_write_low(LED_HC595_DS);
|
||||||
gpio_set_pin_output_write_low(HC595_SH_PIN);
|
gpio_set_pin_output_write_low(LED_HC595_SH_PIN);
|
||||||
gpio_set_pin_output_write_low(HC595_ST_PIN);
|
gpio_set_pin_output_write_low(LED_HC595_ST_PIN);
|
||||||
for(uint8_t i = 0; i < 8; i++) {
|
for(uint8_t i = 0; i < 8; i++) {
|
||||||
if(data & 0x01){
|
if(data & 0x01){
|
||||||
gpio_write_pin_high(HC595_DS);
|
gpio_write_pin_high(LED_HC595_DS);
|
||||||
}else{
|
}else{
|
||||||
gpio_write_pin_low(HC595_DS);
|
gpio_write_pin_low(LED_HC595_DS);
|
||||||
}
|
}
|
||||||
clockPulse(CLOCK_TIME);
|
clockPulse(LED_CLOCK_TIME);
|
||||||
data >>= 1; // Move the data one digit to the right
|
data >>= 1; // Move the data one digit to the right
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
#include "atomic_util.h"
|
#include "atomic_util.h"
|
||||||
#include "gpio.h"
|
#include "gpio.h"
|
||||||
|
|
||||||
#define HC595_ST_PIN B1 //74HC595 storage register clock input
|
#define LED_HC595_ST_PIN B1 //74HC595 storage register clock input
|
||||||
#define HC595_SH_PIN B0 //74HC595 shift register clock input
|
#define LED_HC595_SH_PIN B0 //74HC595 shift register clock input
|
||||||
#define HC595_DS B3 // 74HC595 serial data input
|
#define LED_HC595_DS B3 // 74HC595 serial data input
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*LED display driver.74HC595 Serial to parallel control LED field on/off.
|
*LED display driver.74HC595 Serial to parallel control LED field on/off.
|
||||||
|
@ -6,12 +6,12 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "atomic_util.h"
|
#include "atomic_util.h"
|
||||||
|
|
||||||
#define CLOCK_TIME 15
|
#define MATRIX_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,24 +57,24 @@ 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(MATRIX_CLOCK_TIME);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -82,18 +82,18 @@ 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(MATRIX_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(MATRIX_CLOCK_TIME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,14 +184,6 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
|
|||||||
}
|
}
|
||||||
return true; // continue all further processing of this key
|
return true; // continue all further processing of this key
|
||||||
|
|
||||||
case TO(0):
|
|
||||||
set_single_persistent_default_layer(0);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case TO(1):
|
|
||||||
set_single_persistent_default_layer(1);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user