mirror of
https://github.com/qmk/qmk_firmware.git
synced 2024-11-22 03:19:24 +00:00
gk104_q1_ansi compiled pass.
This commit is contained in:
parent
5ae58a483e
commit
47b1f3871b
@ -2,32 +2,172 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include QMK_KEYBOARD_H
|
#include QMK_KEYBOARD_H
|
||||||
|
int FN_WIN = 0;
|
||||||
|
int FN_MAC = 0;
|
||||||
|
int L_WIN = 0;
|
||||||
|
int L_MAC = 0;
|
||||||
|
|
||||||
|
enum layer_names {
|
||||||
|
_WIN,
|
||||||
|
_MAC,
|
||||||
|
_WIN_INDEX,
|
||||||
|
_MAC_INDEX
|
||||||
|
};
|
||||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
|
|
||||||
[0] = LAYOUT_all(
|
[_WIN] = LAYOUT_all(
|
||||||
KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_MUTE, KC_SCRL, KC_PAUS, KC_HOME, KC_END,
|
KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_MUTE, KC_DEL, KC_PGUP, KC_PGDN, KC_PSCR,
|
||||||
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_NUM, KC_PSLS, KC_PAST, KC_PMNS,
|
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_NUM, KC_PSLS, KC_PAST, KC_PMNS,
|
||||||
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_P7, KC_P8, KC_P9, KC_PPLS,
|
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_P7, KC_P8, KC_P9, KC_PPLS,
|
||||||
KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_P4, KC_P5, KC_P6,
|
KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_P4, KC_P5, KC_P6,
|
||||||
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_P1, KC_P2, KC_P3, KC_PENT,
|
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_P1, KC_P2, KC_P3, KC_PENT,
|
||||||
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_SPC, KC_SPC, KC_RALT, MO(1), KC_MENU, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT
|
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_SPC, KC_SPC, KC_RALT, MO(_WIN_INDEX), KC_APP, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT
|
||||||
),
|
),
|
||||||
|
|
||||||
[1] = LAYOUT_all(
|
[_MAC] = LAYOUT_all(
|
||||||
_______, KC_F14, KC_F15, G(KC_TAB), KC_WSCH, G(C(KC_S)), KC_SLEP, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, G(KC_SPC), RCS(KC_SPC), G(RCS(KC_4)), KC_PGUP, KC_PGDN,
|
KC_ESC, KC_F14, KC_F15, C(KC_UP), G(KC_D), G(KC_SPC), LAG(KC_EJCT), KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, KC_MUTE, KC_DEL, KC_PGUP, KC_PGDN, KC_PSCR,
|
||||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_TOG, RGB_RMOD, RGB_MOD, KC_DEL, KC_NUM, KC_PSLS, KC_PAST, KC_PMNS,
|
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_NUM, KC_PSLS, KC_PAST, KC_PMNS,
|
||||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_P7, KC_P8, KC_P9, KC_PPLS,
|
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_P7, KC_P8, KC_P9, KC_PPLS,
|
||||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_P4, KC_P5, KC_P6,
|
KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_P4, KC_P5, KC_P6,
|
||||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_VAI, KC_P1, KC_P2, KC_P3, KC_PENT,
|
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_P1, KC_P2, KC_P3, KC_PENT,
|
||||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SPD, RGB_VAD, RGB_SPI, KC_P0, KC_PDOT
|
KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, KC_SPC, KC_SPC, KC_RCMD, MO(_MAC_INDEX), KC_RALT, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT
|
||||||
),
|
),
|
||||||
|
|
||||||
|
[_WIN_INDEX] = LAYOUT_all(
|
||||||
|
_______, KC_F14, KC_F15, G(KC_TAB), KC_WSCH, G(C(KC_S)), KC_SLEP, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, G(KC_SPC), RCS(KC_SPC), G(RCS(KC_4)), KC_HOME, KC_END,
|
||||||
|
_______, _______, _______, _______, _______, _______, TO(_WIN), TO(_MAC), _______, _______, RGB_TOG, RGB_RMOD, RGB_MOD, KC_DEL, KC_NUM, KC_PSLS, KC_PAST, KC_PMNS,
|
||||||
|
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_P7, KC_P8, KC_P9, KC_PPLS,
|
||||||
|
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_P4, KC_P5, KC_P6,
|
||||||
|
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_VAI, KC_P1, KC_P2, KC_P3, KC_PENT,
|
||||||
|
KC_LCTL, KC_LGUI, KC_LALT, _______, _______, _______, KC_RALT, _______, KC_APP, RGB_SPD, RGB_VAD, RGB_SPI, KC_P0, KC_PDOT
|
||||||
|
),
|
||||||
|
|
||||||
|
[_MAC_INDEX] = LAYOUT_all(
|
||||||
|
_______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, G(KC_SPC), RCS(KC_SPC), G(RCS(KC_4)), KC_HOME, KC_END,
|
||||||
|
_______, _______, _______, _______, _______, _______, TO(_WIN), TO(_MAC), _______, _______, RGB_TOG, RGB_RMOD, RGB_MOD, KC_DEL, KC_NUM, KC_PSLS, KC_PAST, KC_PMNS,
|
||||||
|
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_P7, KC_P8, KC_P9, KC_PPLS,
|
||||||
|
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_P4, KC_P5, KC_P6,
|
||||||
|
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_VAI, KC_P1, KC_P2, KC_P3, KC_PENT,
|
||||||
|
KC_LCTL, KC_LALT, KC_LGUI, _______, _______, _______, KC_RCMD, _______, KC_RALT, RGB_SPD, RGB_VAD, RGB_SPI, KC_P0, KC_PDOT
|
||||||
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(ENCODER_MAP_ENABLE)
|
#if defined(ENCODER_MAP_ENABLE)
|
||||||
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = {
|
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = {
|
||||||
[0] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU), ENCODER_CCW_CW(RGB_VAD, RGB_VAI), ENCODER_CCW_CW(RGB_HUD, RGB_HUI), ENCODER_CCW_CW(RGB_SPD, RGB_SPI), ENCODER_CCW_CW(C(KC_WH_D), C(KC_WH_U))},
|
[_WIN] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU), ENCODER_CCW_CW(C(KC_MINS), C(KC_EQL)), ENCODER_CCW_CW(RGB_SPD, RGB_SPI),ENCODER_CCW_CW(RGB_VAD, RGB_VAI), ENCODER_CCW_CW(C(KC_WH_D), C(KC_WH_U))},
|
||||||
[1] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU), ENCODER_CCW_CW(RGB_VAD, RGB_VAI), ENCODER_CCW_CW(RGB_HUD, RGB_HUI), ENCODER_CCW_CW(RGB_SPD, RGB_SPI), ENCODER_CCW_CW(C(KC_WH_D), C(KC_WH_U))}
|
[_MAC] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU), ENCODER_CCW_CW(G(KC_MINS), G(KC_EQL)), ENCODER_CCW_CW(RGB_SPD, RGB_SPI),ENCODER_CCW_CW(RGB_VAD, RGB_VAI), ENCODER_CCW_CW(C(KC_WH_D), C(KC_WH_U))},
|
||||||
|
[_WIN_INDEX] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU), ENCODER_CCW_CW(C(KC_MINS), C(KC_EQL)), ENCODER_CCW_CW(RGB_SPD, RGB_SPI),ENCODER_CCW_CW(RGB_VAD, RGB_VAI), ENCODER_CCW_CW(C(KC_WH_D), C(KC_WH_U))},
|
||||||
|
[_MAC_INDEX] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU), ENCODER_CCW_CW(G(KC_MINS), G(KC_EQL)), ENCODER_CCW_CW(RGB_SPD, RGB_SPI),ENCODER_CCW_CW(RGB_VAD, RGB_VAI), ENCODER_CCW_CW(C(KC_WH_D), C(KC_WH_U))}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
|
||||||
|
|
||||||
|
switch (get_highest_layer(layer_state)) {
|
||||||
|
case 2:{
|
||||||
|
RGB_MATRIX_INDICATOR_SET_COLOR(WIN_MOD_INDEX, 255, 255, 255);
|
||||||
|
if (!rgb_matrix_get_flags()) {
|
||||||
|
RGB_MATRIX_INDICATOR_SET_COLOR(MAC_MOD_INDEX, 0, 0, 0);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case 3:{
|
||||||
|
RGB_MATRIX_INDICATOR_SET_COLOR(MAC_MOD_INDEX, 255, 255, 255);
|
||||||
|
if (!rgb_matrix_get_flags()) {
|
||||||
|
RGB_MATRIX_INDICATOR_SET_COLOR(WIN_MOD_INDEX, 0, 0, 0);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case 0:{
|
||||||
|
if (L_WIN) {
|
||||||
|
RGB_MATRIX_INDICATOR_SET_COLOR(WIN_MOD_INDEX, 255, 255, 255);
|
||||||
|
if (!rgb_matrix_get_flags()) {
|
||||||
|
RGB_MATRIX_INDICATOR_SET_COLOR(MAC_MOD_INDEX, 0, 0, 0);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if (!rgb_matrix_get_flags()) {
|
||||||
|
RGB_MATRIX_INDICATOR_SET_COLOR(WIN_MOD_INDEX, 0, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case 1:{
|
||||||
|
if (L_MAC) {
|
||||||
|
RGB_MATRIX_INDICATOR_SET_COLOR(MAC_MOD_INDEX, 255, 255, 255);
|
||||||
|
if (!rgb_matrix_get_flags()) {
|
||||||
|
RGB_MATRIX_INDICATOR_SET_COLOR(WIN_MOD_INDEX, 0, 0, 0);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if (!rgb_matrix_get_flags()) {
|
||||||
|
RGB_MATRIX_INDICATOR_SET_COLOR(MAC_MOD_INDEX, 0, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
default:{
|
||||||
|
if (!rgb_matrix_get_flags()) {
|
||||||
|
RGB_MATRIX_INDICATOR_SET_COLOR(WIN_MOD_INDEX, 0, 0, 0);
|
||||||
|
RGB_MATRIX_INDICATOR_SET_COLOR(MAC_MOD_INDEX, 0, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
|
switch (keycode) {
|
||||||
|
# ifdef RGB_MATRIX_ENABLE
|
||||||
|
case RGB_TOG:
|
||||||
|
if (record->event.pressed) {
|
||||||
|
switch (rgb_matrix_get_flags()) {
|
||||||
|
case LED_FLAG_ALL: {
|
||||||
|
rgb_matrix_set_flags(LED_FLAG_NONE);
|
||||||
|
rgb_matrix_set_color_all(0, 0, 0);
|
||||||
|
} break;
|
||||||
|
default: {
|
||||||
|
rgb_matrix_set_flags(LED_FLAG_ALL);
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
case RGB_VAI:
|
||||||
|
rgb_matrix_set_flags(LED_FLAG_ALL);
|
||||||
|
return true;
|
||||||
|
# endif
|
||||||
|
case TO(0):
|
||||||
|
if (record->event.pressed) {
|
||||||
|
L_WIN = 1;
|
||||||
|
set_single_persistent_default_layer(0); // Save default layer 0 to eeprom
|
||||||
|
} else {
|
||||||
|
L_WIN = 0;
|
||||||
|
}
|
||||||
|
return true; // continue all further processing of this key
|
||||||
|
|
||||||
|
case MO(2):
|
||||||
|
if (record->event.pressed) {
|
||||||
|
FN_WIN = 1;
|
||||||
|
} else {
|
||||||
|
FN_WIN = 0;
|
||||||
|
}
|
||||||
|
return true; // continue all further processing of this key
|
||||||
|
|
||||||
|
case TO(1):
|
||||||
|
if (record->event.pressed) {
|
||||||
|
L_MAC = 1;
|
||||||
|
set_single_persistent_default_layer(1); //Save default layer 1 to eeprom
|
||||||
|
} else {
|
||||||
|
L_MAC = 0;
|
||||||
|
}
|
||||||
|
return true; // continue all further processing of this key
|
||||||
|
|
||||||
|
case MO(3):
|
||||||
|
if (record->event.pressed) {
|
||||||
|
FN_MAC = 1;
|
||||||
|
} else {
|
||||||
|
FN_MAC = 0;
|
||||||
|
}
|
||||||
|
return true; // continue all further processing of this key
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -1 +0,0 @@
|
|||||||
ENCODER_MAP_ENABLE = yes
|
|
@ -21,9 +21,30 @@
|
|||||||
# define WIN_MOD_INDEX 23
|
# define WIN_MOD_INDEX 23
|
||||||
# define MAC_MOD_INDEX 24
|
# define MAC_MOD_INDEX 24
|
||||||
# define WIN_LOCK_INDEX 75
|
# define WIN_LOCK_INDEX 75
|
||||||
|
# define CAPS_LOCK_INDEX 35
|
||||||
# define SCR_LOCK_INDEX 14
|
# define SCR_LOCK_INDEX 14
|
||||||
# define SDB B5
|
# define SDB B5
|
||||||
# define RGB_MATRIX_KEYPRESSES
|
# define RGB_MATRIX_KEYPRESSES
|
||||||
# define RGB_MATRIX_FRAMEBUFFER_EFFECTS
|
# define RGB_MATRIX_FRAMEBUFFER_EFFECTS
|
||||||
#endif // RGB_MATRIX_ENABLE
|
#endif // RGB_MATRIX_ENABLE
|
||||||
|
|
||||||
|
/*
|
||||||
|
*LED display driver.74HC595 Serial to parallel control LED field on/off.
|
||||||
|
* data(default):1-on/0-off
|
||||||
|
* bit0 --- MAC layer indicator
|
||||||
|
* bit1 --- Win layer indicator
|
||||||
|
* bit2 --- CAPS indicator
|
||||||
|
* bit3 --- NUM indicator
|
||||||
|
* bit4 --- SCR indicator
|
||||||
|
* bit7 --- Skyloong LOGO display
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#define MAC_ON 0b00000001
|
||||||
|
#define WIN_ON 0b00000010
|
||||||
|
#define CAPS_ON 0b00000100
|
||||||
|
#define NUM_ON 0b00001000
|
||||||
|
#define SCR_ON 0b00010000
|
||||||
|
#define SKYLOONG 0b10000000
|
||||||
|
|
||||||
|
|
||||||
|
104
keyboards/skyloong/gk104/q1/led_hc595.c
Normal file
104
keyboards/skyloong/gk104/q1/led_hc595.c
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
// Copyright 2023 NaturalZh (@NaturalZh)
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
#include "quantum.h"
|
||||||
|
|
||||||
|
#ifndef HC595_ST_PIN
|
||||||
|
# error hc595: no storage register clock pins defined!
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HC595_SH_PIN
|
||||||
|
# error hc595: no shift register clock pins defined!
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HC595_DS
|
||||||
|
# error hc595: no serial data input pins defined!
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 74HC595 Skyloong LED display Driver
|
||||||
|
* data(default):1-on/0-off
|
||||||
|
* bit0 --- MAC layer indicator
|
||||||
|
* bit1 --- Win layer indicator
|
||||||
|
* bit2 --- CAPS indicator
|
||||||
|
* bit3 --- NUM indicator
|
||||||
|
* bit4 --- SCR indicator
|
||||||
|
* bit7 --- Skyloong LOGO display
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
#ifndef ClockTime
|
||||||
|
# define ClockTime 15
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//enable mac layer indicator on LED diaplay
|
||||||
|
#ifndef MAC_ON
|
||||||
|
# define MAC_ON 0b00000001
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//enable win layer indicator on LED diaplay
|
||||||
|
#ifndef WIN_ON
|
||||||
|
# define WIN_ON 0b00000010
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//enable caps lock indicator on LED diaplay
|
||||||
|
#ifndef CAPS_ON
|
||||||
|
# define CAPS_ON 0b00000100
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//enable number lock indicator on LED diaplay
|
||||||
|
#ifndef NUM_ON
|
||||||
|
# define NUM_ON 0b00001000
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//enable scroll lock indicator on LED diaplay
|
||||||
|
#ifndef SCR_ON
|
||||||
|
# define SCR_ON 0b00010000
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//Skyloong LOGO display on
|
||||||
|
#ifndef SKYLOONG
|
||||||
|
# define SKYLOONG 0b10000000
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline void setPinOutput_writeLow(pin_t pin) {
|
||||||
|
ATOMIC_BLOCK_FORCEON {
|
||||||
|
setPinOutput(pin);
|
||||||
|
writePinLow(pin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void setPinOutput_writeHigh(pin_t pin) {
|
||||||
|
ATOMIC_BLOCK_FORCEON {
|
||||||
|
setPinOutput(pin);
|
||||||
|
writePinHigh(pin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void select_delay(uint16_t n) {
|
||||||
|
while (n-- > 0) {
|
||||||
|
asm volatile("nop" ::: "memory");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void clockPulse(uint16_t n) {
|
||||||
|
writePinHigh(HC595_SH_PIN);
|
||||||
|
writePinHigh(HC595_ST_PIN);
|
||||||
|
select_delay(n);
|
||||||
|
writePinLow(HC595_SH_PIN);
|
||||||
|
writePinLow(HC595_ST_PIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void s_serial_to_parallel(uint8_t data) { // Serial port to parallel port function
|
||||||
|
setPinOutput_writeLow(HC595_DS);
|
||||||
|
setPinOutput_writeLow(HC595_SH_PIN);
|
||||||
|
setPinOutput_writeLow(HC595_ST_PIN);
|
||||||
|
for(uint8_t i = 0; i < 8; i++) {
|
||||||
|
if(data & 0x01){
|
||||||
|
writePinHigh(HC595_DS);
|
||||||
|
}else{
|
||||||
|
writePinLow(HC595_DS);
|
||||||
|
}
|
||||||
|
clockPulse(ClockTime);
|
||||||
|
data >>= 1; // Move the data one digit to the right
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,11 +1,22 @@
|
|||||||
// Copyright 2023 JZ-Skyloong (@JZ-Skyloong)
|
// Copyright 2023 NaturalZh (@NaturalZh)
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
|
|
||||||
#define MAC_OFF 0x1A //disable mac layer indicator on LED display
|
/**
|
||||||
#define MAC_ON 0x3B //enable mac layer indicator on LED diaplay
|
* 74HC595 Skyloong LED display Driver
|
||||||
|
* data(default):1-on/0-off
|
||||||
|
* bit0 --- MAC layer indicator
|
||||||
|
* bit1 --- Win layer indicator
|
||||||
|
* bit2 --- CAPS indicator
|
||||||
|
* bit3 --- NUM indicator
|
||||||
|
* bit4 --- SCR indicator
|
||||||
|
* bit7 --- Skyloong LOGO display
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
#define HC595_ST_PIN A6 //74HC595 storage register clock input
|
||||||
|
#define HC595_SH_PIN A5 //74HC595 shift register clock input
|
||||||
|
#define HC595_DS A7 // 74HC595 serial data input
|
||||||
|
#include "led_hc595.c"
|
||||||
uint8_t IND = 0; //buffer of LED Display
|
uint8_t IND = 0; //buffer of LED Display
|
||||||
|
|
||||||
#if defined(RGB_MATRIX_ENABLE) /*&& defined(CAPS_LOCK_INDEX)*/
|
#if defined(RGB_MATRIX_ENABLE) /*&& defined(CAPS_LOCK_INDEX)*/
|
||||||
@ -128,16 +139,14 @@ const aw20216s_led_t PROGMEM g_aw20216s_leds[AW20216S_LED_COUNT] = {
|
|||||||
{1, CS16_SW5, CS17_SW5, CS18_SW5},
|
{1, CS16_SW5, CS17_SW5, CS18_SW5},
|
||||||
{1, CS16_SW6, CS17_SW6, CS18_SW6}
|
{1, CS16_SW6, CS17_SW6, CS18_SW6}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void suspend_power_down_kb() {
|
void suspend_power_down_kb() {
|
||||||
# ifdef RGB_MATRIX_ENABLE
|
# ifdef RGB_MATRIX_ENABLE
|
||||||
writePinLow(SDB);
|
writePinLow(SDB);
|
||||||
# endif
|
# endif
|
||||||
writePinLow(MAC_PIN);
|
writePinLow(MAC_PIN);
|
||||||
|
s_serial_to_parallel(0);
|
||||||
suspend_power_down_user();
|
suspend_power_down_user();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,11 +154,13 @@ void suspend_wakeup_init_kb() {
|
|||||||
# ifdef RGB_MATRIX_ENABLE
|
# ifdef RGB_MATRIX_ENABLE
|
||||||
writePinHigh(SDB);
|
writePinHigh(SDB);
|
||||||
# endif
|
# endif
|
||||||
|
s_serial_to_parallel(IND);
|
||||||
suspend_wakeup_init_user();
|
suspend_wakeup_init_user();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool shutdown_kb(bool jump_to_bootloader) {
|
bool shutdown_kb(bool jump_to_bootloader) {
|
||||||
writePinLow(SDB);
|
writePinLow(SDB);
|
||||||
|
s_serial_to_parallel(0);
|
||||||
return shutdown_user(jump_to_bootloader);
|
return shutdown_user(jump_to_bootloader);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,15 +168,18 @@ layer_state_t default_layer_state_set_kb(layer_state_t state) {
|
|||||||
switch (get_highest_layer(state)) {
|
switch (get_highest_layer(state)) {
|
||||||
case 0:
|
case 0:
|
||||||
writePinLow(MAC_PIN);
|
writePinLow(MAC_PIN);
|
||||||
IND =& MAC_OFF;
|
//switch to win layer display
|
||||||
serial_to_parallel(IND);
|
IND = IND & (~MAC_ON);
|
||||||
|
IND = IND | WIN_ON;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
writePinHigh(MAC_PIN);
|
writePinHigh(MAC_PIN);
|
||||||
IND =|| MAC_ON;
|
//switch to mac layer display
|
||||||
serial_to_parallel(IND);
|
IND = IND & (~WIN_ON);
|
||||||
|
IND = IND | MAC_ON;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
s_serial_to_parallel(IND);
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,63 +188,39 @@ bool rgb_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max) {
|
|||||||
if (!rgb_matrix_indicators_advanced_user(led_min, led_max)) {
|
if (!rgb_matrix_indicators_advanced_user(led_min, led_max)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
//caps lock display
|
||||||
if (host_keyboard_led_state().caps_lock) {
|
if (host_keyboard_led_state().caps_lock) {
|
||||||
RGB_MATRIX_INDICATOR_SET_COLOR(CAPS_LOCK_INDEX, 255, 255, 255);
|
RGB_MATRIX_INDICATOR_SET_COLOR(CAPS_LOCK_INDEX, 255, 255, 255);
|
||||||
|
IND = IND | CAPS_ON;
|
||||||
} else {
|
} else {
|
||||||
if (!rgb_matrix_get_flags()) {
|
if (!rgb_matrix_get_flags()) {
|
||||||
RGB_MATRIX_INDICATOR_SET_COLOR(CAPS_LOCK_INDEX, 0, 0, 0);
|
RGB_MATRIX_INDICATOR_SET_COLOR(CAPS_LOCK_INDEX, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
IND = IND & (~CAPS_ON);
|
||||||
|
}
|
||||||
|
//number lock display
|
||||||
|
if (host_keyboard_led_state().num_lock) {
|
||||||
|
RGB_MATRIX_INDICATOR_SET_COLOR(NUM_LOCK_INDEX, 255, 255, 255);
|
||||||
|
IND = IND | NUM_ON;
|
||||||
|
} else {
|
||||||
|
if (!rgb_matrix_get_flags()) {
|
||||||
|
RGB_MATRIX_INDICATOR_SET_COLOR(NUM_LOCK_INDEX, 0, 0, 0);
|
||||||
|
}
|
||||||
|
IND = IND & (~NUM_ON);
|
||||||
|
}
|
||||||
|
//scroll lock display
|
||||||
|
if (host_keyboard_led_state().scroll_lock) {
|
||||||
|
RGB_MATRIX_INDICATOR_SET_COLOR(SCR_LOCK_INDEX, 255, 255, 255);
|
||||||
|
IND = IND | SCR_ON;
|
||||||
|
} else {
|
||||||
|
if (!rgb_matrix_get_flags()) {
|
||||||
|
RGB_MATRIX_INDICATOR_SET_COLOR(SCR_LOCK_INDEX, 0, 0, 0);
|
||||||
|
}
|
||||||
|
IND = IND & (~SCR_ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (get_highest_layer(layer_state)) {
|
s_serial_to_parallel(IND);
|
||||||
case 2:{
|
return true;
|
||||||
RGB_MATRIX_INDICATOR_SET_COLOR(WIN_MOD_INDEX, 255, 255, 255);
|
|
||||||
if (!rgb_matrix_get_flags()) {
|
|
||||||
RGB_MATRIX_INDICATOR_SET_COLOR(MAC_MOD_INDEX, 0, 0, 0);
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
case 3:{
|
|
||||||
RGB_MATRIX_INDICATOR_SET_COLOR(MAC_MOD_INDEX, 255, 255, 255);
|
|
||||||
if (!rgb_matrix_get_flags()) {
|
|
||||||
RGB_MATRIX_INDICATOR_SET_COLOR(WIN_MOD_INDEX, 0, 0, 0);
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case 0:{
|
|
||||||
if (L_WIN) {
|
|
||||||
RGB_MATRIX_INDICATOR_SET_COLOR(WIN_MOD_INDEX, 255, 255, 255);
|
|
||||||
if (!rgb_matrix_get_flags()) {
|
|
||||||
RGB_MATRIX_INDICATOR_SET_COLOR(MAC_MOD_INDEX, 0, 0, 0);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
if (!rgb_matrix_get_flags()) {
|
|
||||||
RGB_MATRIX_INDICATOR_SET_COLOR(WIN_MOD_INDEX, 0, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case 1:{
|
|
||||||
if (L_MAC) {
|
|
||||||
RGB_MATRIX_INDICATOR_SET_COLOR(MAC_MOD_INDEX, 255, 255, 255);
|
|
||||||
if (!rgb_matrix_get_flags()) {
|
|
||||||
RGB_MATRIX_INDICATOR_SET_COLOR(WIN_MOD_INDEX, 0, 0, 0);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
if (!rgb_matrix_get_flags()) {
|
|
||||||
RGB_MATRIX_INDICATOR_SET_COLOR(MAC_MOD_INDEX, 0, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
|
|
||||||
default:{
|
|
||||||
if (!rgb_matrix_get_flags()) {
|
|
||||||
RGB_MATRIX_INDICATOR_SET_COLOR(WIN_MOD_INDEX, 0, 0, 0);
|
|
||||||
RGB_MATRIX_INDICATOR_SET_COLOR(MAC_MOD_INDEX, 0, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -243,51 +233,6 @@ void board_init(void) {
|
|||||||
# endif
|
# endif
|
||||||
setPinOutput(MAC_PIN);
|
setPinOutput(MAC_PIN);
|
||||||
writePinHigh(MAC_PIN);
|
writePinHigh(MAC_PIN);
|
||||||
|
s_serial_to_parallel(SKYLOONG);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
LED display driver
|
|
||||||
*/
|
|
||||||
#define ClockTime 15
|
|
||||||
#define HC595_ST_PIN A6 //74HC595 storage register clock input
|
|
||||||
#define HC595_SH_PIN A5 //74HC595 shift register clock input
|
|
||||||
#define HC595_DS A7 // 74HC595 serial data input
|
|
||||||
|
|
||||||
static inline void setPinOutput_writeLow(pin_t pin) {
|
|
||||||
ATOMIC_BLOCK_FORCEON {
|
|
||||||
setPinOutput(pin);
|
|
||||||
writePinLow(pin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void setPinOutput_writeHigh(pin_t pin) {
|
|
||||||
ATOMIC_BLOCK_FORCEON {
|
|
||||||
setPinOutput(pin);
|
|
||||||
writePinHigh(pin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void select_delay(uint16_t n) {
|
|
||||||
while (n-- > 0) {
|
|
||||||
asm volatile("nop" ::: "memory");
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void clockPulse(uint16_t n) {
|
|
||||||
writePinHigh(HC595_SH_PIN);
|
|
||||||
writePinHigh(HC595_ST_PIN);
|
|
||||||
select_delay(n);
|
|
||||||
writePinLow(HC595_SH_PIN);
|
|
||||||
writePinLow(HC595_ST_PIN);
|
|
||||||
}
|
|
||||||
|
|
||||||
void serial_to_parallel(uint8_t data) { // 串口转并口函数
|
|
||||||
setPinOutput_writeLow(HC595_DS);
|
|
||||||
setPinOutput_writeLow(HC595_SH_PIN);
|
|
||||||
setPinOutput_writeLow(HC595_ST_PIN);
|
|
||||||
for(uint8_t i = 0; i < 8; i++) { // 循环8次,每次输出一位数据
|
|
||||||
HC595_DS = (data & 0x01); // 将最低位写入串口数据输入端
|
|
||||||
clockPulse(ClockTime);
|
|
||||||
data >>= 1; // 将数据右移一位,准备输出下一位数据
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,26 +1,26 @@
|
|||||||
# GK980 Q1 Keyboard
|
# GK104 Q1 LED Display Keyboard
|
||||||
|
|
||||||
![GK980 Q1](https://i.imgur.com/TYx22dhh.jpg)
|
![GK104 Q1](https://i.imgur.com/TYx22dhh.jpg)
|
||||||
|
|
||||||
## The PCB features:
|
## The PCB features:
|
||||||
* QMK & VIA compatibility
|
* QMK & VIA compatibility
|
||||||
* RGB Matrix backlight
|
* RGB Matrix backlight
|
||||||
* Use PTIR switches instead of mechanical switches to increase the service life and reliability of switches.
|
* Mechanical switches Keyboard with LED display.
|
||||||
|
|
||||||
|
|
||||||
The following is the QMK Firmware for the Destop 87% keylayout - designed by Dongguan Jizhi Electronic Technology Co., Ltd
|
The following is the QMK Firmware for the Destop 87% keylayout - designed by Dongguan Jizhi Electronic Technology Co., Ltd
|
||||||
|
|
||||||
* Keyboard Maintainer: [JZ-Skyloong](https://github.com/JZ-skyloong)
|
* Keyboard Maintainer: [NaturalZh](https://github.com/NaturalZh)
|
||||||
* Hardware Supported: DestopPCB for Skyloong keylayout 85%, STM32F103C8T6
|
* Hardware Supported: DestopPCB for Skyloong keylayout 100%, STM32F103C8T6
|
||||||
* Hardware Availability: http://www.skyloong.com.cn https://skyloong.vip
|
* Hardware Availability: http://www.skyloong.com.cn https://skyloong.vip
|
||||||
|
|
||||||
Make example for this keyboard (after setting up your build environment):
|
Make example for this keyboard (after setting up your build environment):
|
||||||
|
|
||||||
make skyloong/gk980/q1:default
|
make skyloong/gk104/q1/ansi:default
|
||||||
|
|
||||||
Flashing example for this keyboard:
|
Flashing example for this keyboard:
|
||||||
|
|
||||||
make skyloong/gk980/q1:default:flash
|
make skyloong/gk104/q1/ansi:default:flash
|
||||||
|
|
||||||
See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).
|
See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user