L3 fixed wireless LED indication, added Win locking indication, tidied up code

This commit is contained in:
lokher 2024-11-28 11:32:38 +08:00
parent 1e72758c02
commit 161a6984ba
15 changed files with 82 additions and 96 deletions

View file

@ -44,7 +44,7 @@ enum {
BAT_LVL = _______,
__LK_WIRELESS_ENABLE_END = KC_LOCK_SCREEN,
#endif
NEW_SAFE_RANGE = __LK_WIRELESS_ENABLE_END + 1,
NEW_SAFE_RANGE = __LK_WIRELESS_ENABLE_END + 1,
};
#define KC_TASK KC_TASK_VIEW

View file

@ -18,28 +18,17 @@
#ifdef RGB_MATRIX_ENABLE
/* RGB Matrix driver configuration */
# define DRIVER_COUNT 2
# define RGB_MATRIX_LED_COUNT 86
# define SPI_SCK_PIN A5
# define SPI_MISO_PIN A6
# define SPI_MOSI_PIN A7
# define DRIVER_CS_PINS \
{ B9, B8 }
# define SNLED23751_SPI_DIVISOR 16
# define SPI_DRIVER SPID1
# define DRIVER_COUNT 2
/* Scan phase of led driver set as MSKPHASE_9CHANNEL(defined as 0x03 in snled27351.h) */
# define SNLED27351_PHASE_CHANNEL MSKPHASE_9CHANNEL
/* Set LED driver current */
# define SNLED27351_CURRENT_TUNE \
{ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 }
/* Set to infinit, which is use in USB mode by default */
# define RGB_MATRIX_TIMEOUT RGB_MATRIX_TIMEOUT_INFINITE
/* Allow shutdown of led driver to save power */
# define RGB_MATRIX_DRIVER_SHUTDOWN_ENABLE
/* Turn off backlight on low brightness to save power */

View file

@ -20,7 +20,21 @@
#define ENCODER_DEFAULT_POS 0x3
#define ENCODER_MAP_KEY_DELAY 2
# define LED_DRIVER_SHUTDOWN_PIN B7
#if defined(RGB_MATRIX_ENABLE) || defined(LK_WIRELESS_ENABLE)
/* SPI configuration */
# define SPI_DRIVER SPID1
# define SPI_SCK_PIN A5
# define SPI_MISO_PIN A6
# define SPI_MOSI_PIN A7
#endif
#if defined(RGB_MATRIX_ENABLE)
# define DRIVER_COUNT 2
# define DRIVER_CS_PINS \
{ B8, B9 }
# define LED_DRIVER_SHUTDOWN_PIN B7
# define SNLED23751_SPI_DIVISOR 16
#endif
#ifdef LK_WIRELESS_ENABLE
/* Hardware configuration */
@ -65,12 +79,6 @@
/* Enable bluetooth NKRO */
# define WIRELESS_NKRO_ENABLE
/* Raw hid command for factory test and bluetooth DFU */
# define RAW_HID_CMD 0xAA ... 0xAB
#else
/* Raw hid command for factory test */
# define RAW_HID_CMD 0xAB
#endif
/* Factory test keys */

View file

@ -1,4 +1,4 @@
/* Copyright 2023 @ Lemokey (https://www.lemokey.com)
/* Copyright 2023 ~ 2024 @ Lemokey (https://www.lemokey.com)
*
* This program is free software : you can redistribute it and /or modify
* it under the terms of the GNU General Public License as published by
@ -22,9 +22,9 @@ const snled27351_led_t g_snled27351_leds[RGB_MATRIX_LED_COUNT] = {
/* Refer to SNLED27351 manual for these locations
* driver
* | R location
* | | G location
* | | | B location
* | | | | */
* | | G location
* | | | B location
* | | | | */
{0, G_2, I_2, H_2},
{0, G_3, I_3, H_3},
{0, G_4, I_4, H_4},
@ -126,9 +126,9 @@ const snled27351_led_t g_snled27351_leds[RGB_MATRIX_LED_COUNT] = {
#define __ NO_LED
led_config_t g_led_config = {
{
{
// Key Matrix to LED Index
{ __, __, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, },
{ __, __, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, },
{ __, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, },
{ 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, },
{ 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, __, 64, __, __, __, },

View file

@ -1,4 +1,4 @@
/* Copyright 2023 @ Lemokey (https://www.lemokey.com)
/* Copyright 2023 ~ 2024 @ Lemokey (https://www.lemokey.com)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -16,37 +16,31 @@
#pragma once
#define VIA_FIRMWARE_VERSION 0x00000001
#ifdef RGB_MATRIX_ENABLE
/* RGB Matrix driver configuration */
# define DRIVER_COUNT 2
# define DRIVER_1_LED_COUNT 47
# define DRIVER_2_LED_COUNT 44
# define RGB_MATRIX_LED_COUNT (DRIVER_1_LED_COUNT + DRIVER_2_LED_COUNT)
# define SPI_SCK_PIN A5
# define SPI_MISO_PIN A6
# define SPI_MOSI_PIN A7
# define DRIVER_CS_PINS \
{ B8, B9 }
# define SNLED23751_SPI_DIVISOR 16
# define SPI_DRIVER SPID1
/* Scan phase of led driver set as MSKPHASE_9CHANNEL(defined as 0x03 in snled27351.h) */
# define SNLED27351_PHASE_CHANNEL MSKPHASE_9CHANNEL
/* Set LED driver current */
# define SNLED27351_CURRENT_TUNE \
{ 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C }
{ 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24 }
/* Set to infinit, which is use in USB mode by default */
# define RGB_MATRIX_TIMEOUT RGB_MATRIX_TIMEOUT_INFINITE
/* Allow shutdown of led driver to save power */
# define RGB_MATRIX_DRIVER_SHUTDOWN_ENABLE
/* Turn off backlight on low brightness to save power */
# define RGB_MATRIX_BRIGHTNESS_TURN_OFF_VAL 32
/* Indications */
# define WINLOCK_LED_LIST \
{ 81 }
# define RGB_MATRIX_KEYPRESSES
# define RGB_MATRIX_FRAMEBUFFER_EFFECTS

View file

@ -36,7 +36,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
_______, BT_HST1, BT_HST2, BT_HST3, P2P4G, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, RGB_TOG, RGB_MOD, RGB_VAI, RGB_HUI, RGB_SAI, RGB_SPI, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, RGB_RMOD, RGB_VAD, RGB_HUD, RGB_SAD, RGB_SPD, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, BAT_LVL, NK_TOGG, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, BAT_LVL, _______, _______, _______, _______, _______, _______, _______,
_______, _______, GUI_TOG, _______, _______, _______, _______, _______, _______, _______, _______, _______),
};
// clang-format on

View file

@ -33,12 +33,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
MC_1, 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,
MC_2, 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,
MC_3, KC_LCTL, KC_LWIN, KC_LALT, KC_SPC, KC_RALT, MO(FN), KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),
[FN] = LAYOUT_ansi_tkl(
RGB_TOG, _______, KC_BRID, KC_BRIU, KC_TASK, KC_FILE, RGB_VAD, RGB_VAI, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, _______, _______, _______,
_______, BT_HST1, BT_HST2, BT_HST3, P2P4G, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, RGB_TOG, RGB_MOD, RGB_VAI, RGB_HUI, RGB_SAI, RGB_SPI, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, RGB_RMOD, RGB_VAD, RGB_HUD, RGB_SAD, RGB_SPD, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, BAT_LVL, NK_TOGG, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, BAT_LVL, _______, _______, _______, _______, _______, _______, _______,
_______, _______, GUI_TOG, _______, _______, _______, _______, _______, _______, _______, _______, _______),
};

View file

@ -1,4 +1,4 @@
/* Copyright 2023 @ Lemokey (https://www.lemokey.com)
/* Copyright 2023 ~ 2024 @ Lemokey (https://www.lemokey.com)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -20,9 +20,21 @@
#define ENCODER_DEFAULT_POS 0x3
#define ENCODER_MAP_KEY_DELAY 2
/* Caps lock LED */
#define LED_CAPS_LOCK_PIN A13
#define LED_PIN_ON_STATE 1
#if defined(RGB_MATRIX_ENABLE) || defined(LK_WIRELESS_ENABLE)
/* SPI configuration */
# define SPI_DRIVER SPID1
# define SPI_SCK_PIN A5
# define SPI_MISO_PIN A6
# define SPI_MOSI_PIN A7
#endif
#if defined(RGB_MATRIX_ENABLE)
# define DRIVER_COUNT 2
# define DRIVER_CS_PINS \
{ B8, B9 }
# define LED_DRIVER_SHUTDOWN_PIN B7
# define SNLED23751_SPI_DIVISOR 16
#endif
#ifdef LK_WIRELESS_ENABLE
/* Hardware configuration */
@ -41,19 +53,14 @@
# define BT_HOST_DEVICES_COUNT 3
# define BT_HOST_LED_PIN_LIST \
# define BT_INDICATION_LED_PIN_LIST \
{ C9, C9, C9 }
# define HOST_LED_PIN_ON_STATE 0
# define BT_INDICATION_LED_ON_STATE 0
# define P24G_HOST_DEVICES_COUNT 1
# define P24G_HOST_LED_PIN_LIST \
{ A8 }
# define P24G_INDICATION_LED_PIN A8
# if defined(RGB_MATRIX_ENABLE) || defined(LED_MATRIX_ENABLE)
# define LED_DRIVER_SHUTDOWN_PIN B7
# define BT_INDICATION_LED_LIST \
{ 17, 18, 19 }
@ -78,12 +85,6 @@
/* Enable bluetooth NKRO */
# define WIRELESS_NKRO_ENABLE
/* Raw hid command for factory test and bluetooth DFU */
# define RAW_HID_CMD 0xAA ... 0xAB
#else
/* Raw hid command for factory test */
# define RAW_HID_CMD 0xAB
#endif
/* Factory test keys */

View file

@ -27,12 +27,16 @@
"encoder": {
"rotary": [
{
"pin_a": "B15",
"pin_b": "B14",
"resolution": 4
}
"pin_a": "B15",
"pin_b": "B14",
"resolution": 4
}
]
},
"indicators": {
"caps_lock": "A13",
"on_state": 1
},
"rgb_matrix": {
"driver": "snled27351_spi",
"sleep": true,

View file

@ -1,4 +1,4 @@
/* Copyright 2023 @ Lemokey (https://www.lemokey.com)
/* Copyright 2023 ~ 2024 @ Lemokey (https://www.lemokey.com)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -18,35 +18,27 @@
#ifdef RGB_MATRIX_ENABLE
/* RGB Matrix driver configuration */
# define DRIVER_COUNT 2
# define DRIVER_1_LED_COUNT 47
# define DRIVER_2_LED_COUNT 45
# define RGB_MATRIX_LED_COUNT (DRIVER_1_LED_COUNT + DRIVER_2_LED_COUNT)
# define SPI_SCK_PIN A5
# define SPI_MISO_PIN A6
# define SPI_MOSI_PIN A7
# define DRIVER_CS_PINS \
{ B8, B9 }
# define SNLED23751_SPI_DIVISOR 16
# define SPI_DRIVER SPID1
/* Scan phase of led driver set as MSKPHASE_9CHANNEL(defined as 0x03 in snled27351.h) */
# define PHASE_CHANNEL MSKPHASE_9CHANNEL
/* Set LED driver current */
# define SNLED27351_CURRENT_TUNE \
{ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 }
{ 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24 }
/* Set to infinit, which is use in USB mode by default */
# define RGB_MATRIX_TIMEOUT RGB_MATRIX_TIMEOUT_INFINITE
/* Allow shutdown of led driver to save power */
# define RGB_MATRIX_DRIVER_SHUTDOWN_ENABLE
/* Turn off backlight on low brightness to save power */
# define RGB_MATRIX_BRIGHTNESS_TURN_OFF_VAL 32
/* Indications */
# define WINLOCK_LED_LIST \
{ 82 }
# define RGB_MATRIX_KEYPRESSES
# define RGB_MATRIX_FRAMEBUFFER_EFFECTS

View file

@ -82,7 +82,7 @@
{"matrix":[4,0], "x":0, "y":4},
{"matrix":[4,1], "x":1.25, "y":4.25, "w":1.25},
{"matrix":[4,2], "x":2.5, "y":4.25},
{"matrix":[4,2], "x":2.5, "y":4.25},
{"matrix":[4,3], "x":3.5, "y":4.25},
{"matrix":[4,4], "x":4.5, "y":4.25},
{"matrix":[4,5], "x":5.5, "y":4.25},

View file

@ -1,4 +1,4 @@
/* Copyright 2023 @ Lemokey (https://www.lemokey.com)
/* Copyright 2023 ~ 2024 @ Lemokey (https://www.lemokey.com)
*
* This program is free software : you can redistribute it and /or modify
* it under the terms of the GNU General Public License as published by
@ -22,9 +22,9 @@ const snled27351_led_t g_snled27351_leds[RGB_MATRIX_LED_COUNT] = {
/* Refer to SNLED27351 manual for these locations
* driver
* | R location
* | | G location
* | | | B location
* | | | | */
* | | G location
* | | | B location
* | | | | */
{0, G_2, I_2, H_2},
{0, G_3, I_3, H_3},
{0, G_4, I_4, H_4},
@ -125,8 +125,8 @@ const snled27351_led_t g_snled27351_leds[RGB_MATRIX_LED_COUNT] = {
};
led_config_t g_led_config = {
{
{ NO_LED, NO_LED, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, },
{
{ NO_LED, NO_LED, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, },
{ NO_LED, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, },
{ 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, },
{ 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, NO_LED, 64, NO_LED, NO_LED, NO_LED, },

View file

@ -36,7 +36,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
_______, BT_HST1, BT_HST2, BT_HST3, P2P4G, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, RGB_TOG, RGB_MOD, RGB_VAI, RGB_HUI, RGB_SAI, RGB_SPI, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, RGB_RMOD, RGB_VAD, RGB_HUD, RGB_SAD, RGB_SPD, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, BAT_LVL, NK_TOGG, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, BAT_LVL, _______, _______, _______, _______, _______, _______, _______,
_______, _______, GUI_TOG, _______, _______, _______, _______, _______, _______, _______, _______, _______),
};
// clang-format on

View file

@ -36,7 +36,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
_______, BT_HST1, BT_HST2, BT_HST3, P2P4G, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, RGB_TOG, RGB_MOD, RGB_VAI, RGB_HUI, RGB_SAI, RGB_SPI, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, RGB_RMOD, RGB_VAD, RGB_HUD, RGB_SAD, RGB_SPD, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, BAT_LVL, NK_TOGG, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, BAT_LVL, _______, _______, _______, _______, _______, _______, _______,
_______, _______, GUI_TOG, _______, _______, _______, _______, _______, _______, _______, _______, _______),
};
// clang-format on

View file

@ -1,4 +1,4 @@
/* Copyright 2023 @ Lemokey (https://www.lemokey.com)
/* Copyright 2023 ~ 2024 @ Lemokey (https://www.lemokey.com)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -32,8 +32,7 @@
static uint32_t power_on_indicator_timer_buffer;
#ifdef LK_WIRELESS_ENABLE
pin_t bt_led_pins[] = BT_HOST_LED_PIN_LIST;
pin_t p24g_led_pins[] = P24G_HOST_LED_PIN_LIST;
pin_t bt_led_pins[] = BT_INDICATION_LED_PIN_LIST;
#endif
bool process_record_lemokey_kb(uint16_t keycode, keyrecord_t *record) {
@ -69,9 +68,8 @@ bool lemokey_task_kb(void) {
#ifdef LK_WIRELESS_ENABLE
writePin(BAT_LOW_LED_PIN, !BAT_LOW_LED_PIN_ON_STATE);
for (uint8_t i = 0; i < sizeof(bt_led_pins) / sizeof(pin_t); i++)
writePin(bt_led_pins[i], 1);
for (uint8_t i = 0; i < sizeof(p24g_led_pins) / sizeof(pin_t); i++)
writePin(p24g_led_pins[i], 1);
writePin(bt_led_pins[i], !BT_INDICATION_LED_ON_STATE);
writePin(P24G_INDICATION_LED_PIN, !BT_INDICATION_LED_ON_STATE);
#endif
} else {
@ -80,10 +78,9 @@ bool lemokey_task_kb(void) {
writePin(BAT_LOW_LED_PIN, BAT_LOW_LED_PIN_ON_STATE);
if (get_transport() != TRANSPORT_P2P4)
for (uint8_t i = 0; i < sizeof(bt_led_pins) / sizeof(pin_t); i++)
writePin(bt_led_pins[i], 0);
writePin(bt_led_pins[i], BT_INDICATION_LED_ON_STATE);
if (get_transport() != TRANSPORT_BLUETOOTH)
for (uint8_t i = 0; i < sizeof(p24g_led_pins) / sizeof(pin_t); i++)
writePin(p24g_led_pins[i], 0);
writePin(P24G_INDICATION_LED_PIN, BT_INDICATION_LED_ON_STATE);
#endif
}