update skyloong/gk87/bl_pro

This commit is contained in:
NaturalZh 2025-05-07 15:28:29 +08:00
parent 7f0f712d6e
commit dc2a22fbda
4 changed files with 35 additions and 55 deletions

View File

@ -10,37 +10,17 @@ bool WIN_LOCK = 0;
bool DIS_BRETH = 0;
bool SLEEP = 0;
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)) {
return false;
}
switch (keycode) {
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
}
@ -108,7 +88,7 @@ void suspend_wakeup_init_kb() {
SLEEP = 0;
gpio_write_pin(LED_CAPS_LOCK_PIN, !host_keyboard_led_state().caps_lock);
gpio_write_pin(LED_SCROLL_LOCK_PIN, !host_keyboard_led_state().scroll_lock);
gpio_write_pin(WIN_LOCK_PIN, !keycode_config.no_gui);
gpio_write_pin(WIN_LOCK_PIN, !WIN_LOCK);
s_serial_to_parallel(IND);
suspend_wakeup_init_user();
}

View File

@ -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

View File

@ -3,9 +3,9 @@
#include "atomic_util.h"
#include "gpio.h"
#define HC595_ST_PIN B5 //74HC595 storage register clock input
#define HC595_SH_PIN B4 //74HC595 shift register clock input
#define HC595_DS B3 // 74HC595 serial data input
#define LED_HC595_ST_PIN B5 //74HC595 storage register clock input
#define LED_HC595_SH_PIN B4 //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.

View File

@ -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 MATRIX_HC595_ST_PIN A6
#define MATRIX_HC595_SH_PIN A5
#define MATRIX_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 readMatrixPin(pin_t pin) {
}
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(MATRIX_HC595_SH_PIN);
gpio_write_pin_high(MATRIX_HC595_ST_PIN);
select_delay(n);
gpio_write_pin_low(HC595_SH_PIN);
gpio_write_pin_low(HC595_ST_PIN);
gpio_write_pin_low(MATRIX_HC595_SH_PIN);
gpio_write_pin_low(MATRIX_HC595_ST_PIN);
}
// matrix code
static bool select_col(uint8_t col) {
setPinOutput_writeHigh(HC595_DS_PIN);
setPinOutput_writeHigh(MATRIX_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(MATRIX_HC595_DS_PIN);
}else{
gpio_write_pin_high(HC595_DS_PIN);
gpio_write_pin_high(MATRIX_HC595_DS_PIN);
}
clockPulse(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);
setPinOutput_writeHigh(HC595_DS_PIN);
setPinOutput_writeHigh(MATRIX_HC595_DS_PIN);
for (uint8_t y = 0; y < x ; y++) {
clockPulse(ClOCK_TIME);
}
}
static void unselect_cols(void) {
setPinOutput_writeLow(HC595_SH_PIN);
setPinOutput_writeLow(HC595_ST_PIN);
setPinOutput_writeHigh(HC595_DS_PIN);
setPinOutput_writeLow(MATRIX_HC595_SH_PIN);
setPinOutput_writeLow(MATRIX_HC595_ST_PIN);
setPinOutput_writeHigh(MATRIX_HC595_DS_PIN);
for (uint8_t x = 0; x < MATRIX_COLS; x++) {
clockPulse(ClOCK_TIME);
}