mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-07-17 13:12:08 +00:00
update skyloong/gk104/q1
This commit is contained in:
parent
581af2c161
commit
328a294d86
@ -2,15 +2,15 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#include "led_hc595.h"
|
||||
|
||||
#ifndef HC595_ST_PIN
|
||||
#ifndef LED_HC595_ST_PIN
|
||||
# error hc595: no storage register clock pins defined!
|
||||
#endif
|
||||
|
||||
#ifndef HC595_SH_PIN
|
||||
#ifndef LED_HC595_SH_PIN
|
||||
# error hc595: no shift register clock pins defined!
|
||||
#endif
|
||||
|
||||
#ifndef HC595_DS
|
||||
#ifndef LED_HC595_DS_PIN
|
||||
# error hc595: no serial data input pins defined!
|
||||
#endif
|
||||
|
||||
@ -37,23 +37,23 @@ static inline void select_delay(uint16_t n) {
|
||||
}
|
||||
|
||||
static inline void clockPulse(uint16_t n) {
|
||||
gpio_write_pin_high(HC595_SH_PIN);
|
||||
gpio_write_pin_high(HC595_ST_PIN);
|
||||
gpio_write_pin_high(LED_HC595_SH_PIN);
|
||||
gpio_write_pin_high(LED_HC595_ST_PIN);
|
||||
select_delay(n);
|
||||
gpio_write_pin_low(HC595_SH_PIN);
|
||||
gpio_write_pin_low(HC595_ST_PIN);
|
||||
gpio_write_pin_low(LED_HC595_SH_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) { // Serial port to parallel port function
|
||||
gpio_set_pin_output_write_low(HC595_DS);
|
||||
gpio_set_pin_output_write_low(HC595_SH_PIN);
|
||||
gpio_set_pin_output_write_low(HC595_ST_PIN);
|
||||
gpio_set_pin_output_write_low(LED_HC595_DS_PIN);
|
||||
gpio_set_pin_output_write_low(LED_HC595_SH_PIN);
|
||||
gpio_set_pin_output_write_low(LED_HC595_ST_PIN);
|
||||
for(uint8_t i = 0; i < 8; i++) {
|
||||
if(data & 0x01){
|
||||
gpio_write_pin_high(HC595_DS);
|
||||
gpio_write_pin_high(LED_HC595_DS_PIN);
|
||||
}else{
|
||||
gpio_write_pin_low(HC595_DS);
|
||||
gpio_write_pin_low(LED_HC595_DS_PIN);
|
||||
}
|
||||
clockPulse(CLOCK_TIME);
|
||||
data >>= 1; // Move the data one digit to the right
|
||||
|
@ -5,9 +5,9 @@
|
||||
#include "atomic_util.h"
|
||||
#include "gpio.h"
|
||||
|
||||
#define HC595_ST_PIN B1 //74HC595 storage register clock input
|
||||
#define HC595_SH_PIN B0 //74HC595 shift register clock input
|
||||
#define HC595_DS B3 // 74HC595 serial data input
|
||||
#define LED_HC595_ST_PIN B1 //74HC595 storage register clock input
|
||||
#define LED_HC595_SH_PIN B0 //74HC595 shift register clock input
|
||||
#define LED_HC595_DS_PIN B3 // 74HC595 serial data input
|
||||
|
||||
/*
|
||||
*LED display driver.74HC595 Serial to parallel control LED field on/off.
|
||||
|
@ -9,9 +9,9 @@
|
||||
#define ClOCK_TIME 15
|
||||
#define MATRIX_INPUT_PRESSED_STATE 0
|
||||
|
||||
#define HC595_ST_PIN A6
|
||||
#define HC595_SH_PIN A5
|
||||
#define HC595_DS_PIN A7 //定义74HC595的串口数据输入端
|
||||
#define MARTIX_HC595_ST_PIN A6
|
||||
#define MARTIX_HC595_SH_PIN A5
|
||||
#define MARTIX_HC595_DS_PIN A7 //定义74HC595的串口数据输入端
|
||||
|
||||
/* matrix state(1:on, 0:off) */
|
||||
extern matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values
|
||||
@ -57,22 +57,22 @@ static inline uint8_t read_matrix_pin(pin_t pin) {
|
||||
}
|
||||
|
||||
static inline void clock_pulse(uint16_t n) {
|
||||
gpio_write_pin_high(HC595_SH_PIN);
|
||||
gpio_write_pin_high(HC595_ST_PIN);
|
||||
gpio_write_pin_high(MARTIX_HC595_SH_PIN);
|
||||
gpio_write_pin_high(MARTIX_HC595_ST_PIN);
|
||||
select_delay(n);
|
||||
gpio_write_pin_low(HC595_SH_PIN);
|
||||
gpio_write_pin_low(HC595_ST_PIN);
|
||||
gpio_write_pin_low(MARTIX_HC595_SH_PIN);
|
||||
gpio_write_pin_low(MARTIX_HC595_ST_PIN);
|
||||
}
|
||||
|
||||
// matrix code
|
||||
|
||||
static bool select_col(uint8_t col) {
|
||||
gpio_set_pin_output_write_high(HC595_DS_PIN);
|
||||
gpio_set_pin_output_write_high(MARTIX_HC595_DS_PIN);
|
||||
for (uint8_t m = 0; m <= col; m++) {
|
||||
if(m == 0){
|
||||
gpio_write_pin_low(HC595_DS_PIN);
|
||||
gpio_write_pin_low(MARTIX_HC595_DS_PIN);
|
||||
}else{
|
||||
gpio_write_pin_high(HC595_DS_PIN);
|
||||
gpio_write_pin_high(MARTIX_HC595_DS_PIN);
|
||||
}
|
||||
clock_pulse(ClOCK_TIME);
|
||||
}
|
||||
@ -82,16 +82,16 @@ static bool select_col(uint8_t col) {
|
||||
|
||||
static void unselect_col(uint8_t col) {
|
||||
uint8_t x = (MATRIX_COLS - col);
|
||||
gpio_set_pin_output_write_high(HC595_DS_PIN);
|
||||
gpio_set_pin_output_write_high(MARTIX_HC595_DS_PIN);
|
||||
for (uint8_t y = 0; y < x ; y++) {
|
||||
clock_pulse(ClOCK_TIME);
|
||||
}
|
||||
}
|
||||
|
||||
static void unselect_cols(void) {
|
||||
gpio_set_pin_output_write_low(HC595_SH_PIN);
|
||||
gpio_set_pin_output_write_low(HC595_ST_PIN);
|
||||
gpio_set_pin_output_write_high(HC595_DS_PIN);
|
||||
gpio_set_pin_output_write_low(MARTIX_HC595_SH_PIN);
|
||||
gpio_set_pin_output_write_low(MARTIX_HC595_ST_PIN);
|
||||
gpio_set_pin_output_write_high(MARTIX_HC595_DS_PIN);
|
||||
for (uint8_t x = 0; x < MATRIX_COLS; x++) {
|
||||
clock_pulse(ClOCK_TIME);
|
||||
}
|
||||
|
@ -136,6 +136,9 @@ const aw20216s_led_t PROGMEM g_aw20216s_leds[AW20216S_LED_COUNT] = {
|
||||
};
|
||||
#endif
|
||||
|
||||
static bool is_function_layer_on(void) {
|
||||
return (layer_state_is(2) || layer_state_is(3));
|
||||
}
|
||||
|
||||
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
|
||||
if (!process_record_user(keycode, record)) {
|
||||
@ -161,32 +164,8 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
|
||||
return true;
|
||||
# endif
|
||||
|
||||
case MO(1):
|
||||
if (record->event.pressed) {
|
||||
FN_ON = 1;
|
||||
} else {
|
||||
FN_ON = 0;
|
||||
}
|
||||
return true;
|
||||
|
||||
case MO(2):
|
||||
if (record->event.pressed) {
|
||||
FN_ON = 1;
|
||||
} else {
|
||||
FN_ON = 0;
|
||||
}
|
||||
return true;
|
||||
|
||||
case MO(3):
|
||||
if (record->event.pressed) {
|
||||
FN_ON = 1;
|
||||
} else {
|
||||
FN_ON = 0;
|
||||
}
|
||||
return true;
|
||||
|
||||
case KC_LGUI:
|
||||
if (FN_ON){
|
||||
if (is_function_layer_on()){
|
||||
if ( record->event.pressed){
|
||||
WIN_LOCK = !WIN_LOCK ; //change win lock state
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user