Remove duplicated rgblight implementation from mxss (#22122)
This commit is contained in:
parent
c597731d1d
commit
a4760c4d1b
@ -21,6 +21,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#define LOCKING_SUPPORT_ENABLE
|
#define LOCKING_SUPPORT_ENABLE
|
||||||
/* Locking resynchronize hack */
|
/* Locking resynchronize hack */
|
||||||
#define LOCKING_RESYNC_ENABLE
|
#define LOCKING_RESYNC_ENABLE
|
||||||
|
|
||||||
// FLED config takes up 1 byte, stored color count takes 1, stored colors take up to 8
|
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 10
|
|
||||||
|
@ -8,6 +8,15 @@
|
|||||||
"pid": "0x5353",
|
"pid": "0x5353",
|
||||||
"device_version": "0.0.1"
|
"device_version": "0.0.1"
|
||||||
},
|
},
|
||||||
|
"features": {
|
||||||
|
"bootmagic": true,
|
||||||
|
"command": false,
|
||||||
|
"console": false,
|
||||||
|
"extrakey": true,
|
||||||
|
"mousekey": true,
|
||||||
|
"nkro": false,
|
||||||
|
"rgblight": true
|
||||||
|
},
|
||||||
"rgblight": {
|
"rgblight": {
|
||||||
"saturation_steps": 8,
|
"saturation_steps": 8,
|
||||||
"brightness_steps": 8,
|
"brightness_steps": 8,
|
||||||
|
@ -14,21 +14,6 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include QMK_KEYBOARD_H
|
#include QMK_KEYBOARD_H
|
||||||
#include "mxss_frontled.h"
|
|
||||||
|
|
||||||
hs_set caps_color = { .hue = 0, .sat = 255 };
|
|
||||||
|
|
||||||
// Colors for layers
|
|
||||||
// Format: {hue, saturation}
|
|
||||||
// {0, 0} to turn off the LED
|
|
||||||
// Add additional rows to handle more layers
|
|
||||||
hs_set layer_colors[4] = {
|
|
||||||
[0] = {.hue = 0, .sat = 0}, // Color for Layer 0
|
|
||||||
[1] = {.hue = 86, .sat = 255}, // Color for Layer 1
|
|
||||||
[2] = {.hue = 36, .sat = 255}, // Color for Layer 2
|
|
||||||
[3] = {.hue = 185, .sat = 255}, // Color for Layer 3
|
|
||||||
};
|
|
||||||
size_t lc_size = ARRAY_SIZE(layer_colors);
|
|
||||||
|
|
||||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
LAYOUT( /* Base */
|
LAYOUT( /* Base */
|
||||||
@ -41,7 +26,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||||||
|
|
||||||
LAYOUT( /* L1 */
|
LAYOUT( /* L1 */
|
||||||
KC_GRV, 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_DEL,
|
KC_GRV, 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_DEL,
|
||||||
KC_TRNS, KC_MPLY, KC_MPRV, KC_MNXT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_HOME, KC_PSCR, FLED_VAD, FLED_VAI, FLED_MOD, RGB_VAI,
|
KC_TRNS, KC_MPLY, KC_MPRV, KC_MNXT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_HOME, KC_PSCR, KC_TRNS, KC_TRNS, KC_TRNS, RGB_VAI,
|
||||||
QK_BOOT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_END, KC_TRNS, KC_TRNS, KC_TRNS, RGB_VAD,
|
QK_BOOT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_END, KC_TRNS, KC_TRNS, KC_TRNS, RGB_VAD,
|
||||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MUTE, KC_VOLD, KC_VOLU, KC_TRNS, RGB_MOD, RGB_SAI, RGB_TOG,
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MUTE, KC_VOLD, KC_VOLU, KC_TRNS, RGB_MOD, RGB_SAI, RGB_TOG,
|
||||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RGB_HUD, RGB_SAD, RGB_HUI
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RGB_HUD, RGB_SAD, RGB_HUI
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include QMK_KEYBOARD_H
|
#include QMK_KEYBOARD_H
|
||||||
#include "mxss_frontled.h"
|
|
||||||
|
|
||||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
LAYOUT_all( /* L0 */
|
LAYOUT_all( /* L0 */
|
||||||
@ -26,7 +25,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||||||
),
|
),
|
||||||
LAYOUT_all( /* L1 */
|
LAYOUT_all( /* L1 */
|
||||||
KC_GRV, 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_TRNS, KC_TRNS,
|
KC_GRV, 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_TRNS, KC_TRNS,
|
||||||
KC_TRNS, KC_MPLY, KC_MPRV, KC_MNXT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_HOME, KC_PSCR, FLED_VAD, FLED_VAI, FLED_MOD, RGB_VAI,
|
KC_TRNS, KC_MPLY, KC_MPRV, KC_MNXT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_HOME, KC_PSCR, KC_TRNS, KC_TRNS, KC_TRNS, RGB_VAI,
|
||||||
QK_BOOT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_END, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RGB_VAD,
|
QK_BOOT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_END, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RGB_VAD,
|
||||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MUTE, KC_VOLD, KC_VOLU, KC_TRNS, RGB_MOD, RGB_SAI, RGB_TOG,
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MUTE, KC_VOLD, KC_VOLU, KC_TRNS, RGB_MOD, RGB_SAI, RGB_TOG,
|
||||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RGB_HUD, RGB_SAD, RGB_HUI
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RGB_HUD, RGB_SAD, RGB_HUI
|
||||||
|
@ -1,73 +0,0 @@
|
|||||||
/* Copyright 2020 Jumail Mundekkat / MxBlue
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
* the Free Software Foundation, either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* EEPROM management code from ../cannonkeys/stm32f072/keyboard.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "quantum.h"
|
|
||||||
#include "eeprom.h"
|
|
||||||
#include "mxss_frontled.h"
|
|
||||||
#include "version.h" // for QMK_BUILDDATE used in EEPROM magic
|
|
||||||
|
|
||||||
void via_init_kb(void) {
|
|
||||||
fled_init();
|
|
||||||
}
|
|
||||||
|
|
||||||
void matrix_init_kb(void) {
|
|
||||||
// If VIA is disabled, we still need to load settings
|
|
||||||
// Call via_init_kb() the same way as via_init(), with setting
|
|
||||||
// EEPROM valid afterwards.
|
|
||||||
#ifndef VIA_ENABLE
|
|
||||||
fled_init();
|
|
||||||
via_eeprom_set_valid(true);
|
|
||||||
#endif // VIA_ENABLE
|
|
||||||
|
|
||||||
matrix_init_user();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
|
|
||||||
// Handle custom keycodes for front LED operation
|
|
||||||
process_record_fled(keycode, record);
|
|
||||||
return process_record_user(keycode, record);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool led_update_kb(led_t led_state) {
|
|
||||||
fled_lock_update(led_state);
|
|
||||||
return led_update_user(led_state);
|
|
||||||
}
|
|
||||||
|
|
||||||
layer_state_t layer_state_set_kb(layer_state_t state) {
|
|
||||||
fled_layer_update(state);
|
|
||||||
return layer_state_set_user(state);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fallback eeprom functions if VIA is not enabled
|
|
||||||
#ifndef VIA_ENABLE
|
|
||||||
|
|
||||||
// Sets VIA/keyboard level usage of EEPROM to valid/invalid
|
|
||||||
// Keyboard level code (eg. via_init_kb()) should not call this
|
|
||||||
void via_eeprom_set_valid(bool valid)
|
|
||||||
{
|
|
||||||
char *p = QMK_BUILDDATE; // e.g. "2019-11-05-11:29:54"
|
|
||||||
uint8_t magic0 = ( ( p[2] & 0x0F ) << 4 ) | ( p[3] & 0x0F );
|
|
||||||
uint8_t magic1 = ( ( p[5] & 0x0F ) << 4 ) | ( p[6] & 0x0F );
|
|
||||||
uint8_t magic2 = ( ( p[8] & 0x0F ) << 4 ) | ( p[9] & 0x0F );
|
|
||||||
|
|
||||||
eeprom_update_byte( (void*)VIA_EEPROM_MAGIC_ADDR+0, valid ? magic0 : 0xFF);
|
|
||||||
eeprom_update_byte( (void*)VIA_EEPROM_MAGIC_ADDR+1, valid ? magic1 : 0xFF);
|
|
||||||
eeprom_update_byte( (void*)VIA_EEPROM_MAGIC_ADDR+2, valid ? magic2 : 0xFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,278 +0,0 @@
|
|||||||
/* Copyright 2020 Jumail Mundekkat / MxBlue
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
* the Free Software Foundation, either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* Extended from the work done by fcoury: https://github.com/qmk/qmk_firmware/pull/4915
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "mxss_frontled.h"
|
|
||||||
#include "eeprom.h"
|
|
||||||
#include "rgblight.h"
|
|
||||||
#include "via.h"
|
|
||||||
#include "version.h" // for QMK_BUILDDATE used in EEPROM magic
|
|
||||||
|
|
||||||
// Variables for controlling front LED application
|
|
||||||
uint8_t fled_mode; // Mode for front LEDs
|
|
||||||
uint8_t fled_val; // Brightness for front leds (0 - 255)
|
|
||||||
rgb_led_t fleds[2]; // Front LED rgb values for indicator mode use
|
|
||||||
|
|
||||||
// Layer indicator colors
|
|
||||||
__attribute__ ((weak))
|
|
||||||
hs_set layer_colors[FRONTLED_COLOR_MAXCNT];
|
|
||||||
|
|
||||||
// Caps lock indicator color
|
|
||||||
__attribute__ ((weak))
|
|
||||||
hs_set caps_color;
|
|
||||||
|
|
||||||
__attribute__ ((weak))
|
|
||||||
size_t lc_size = ARRAY_SIZE(layer_colors);
|
|
||||||
|
|
||||||
void fled_init(void) {
|
|
||||||
// This checks both an EEPROM reset (from bootmagic lite, keycodes)
|
|
||||||
// and also firmware build date (from via_eeprom_is_valid())
|
|
||||||
if (eeconfig_is_enabled()) {
|
|
||||||
fled_load_conf();
|
|
||||||
// Else, default config
|
|
||||||
} else {
|
|
||||||
// Default mode/brightness
|
|
||||||
fled_mode = FLED_RGB;
|
|
||||||
fled_val = 10 * FLED_VAL_STEP;
|
|
||||||
|
|
||||||
// Default colors
|
|
||||||
caps_color.hue = 0;
|
|
||||||
caps_color.sat = 255;
|
|
||||||
layer_colors[0].hue = 0;
|
|
||||||
layer_colors[0].sat = 0;
|
|
||||||
layer_colors[1].hue = 86;
|
|
||||||
layer_colors[1].sat = 255;
|
|
||||||
layer_colors[2].hue = 36;
|
|
||||||
layer_colors[2].sat = 255;
|
|
||||||
layer_colors[3].hue = 185;
|
|
||||||
layer_colors[3].sat = 255;
|
|
||||||
|
|
||||||
fled_update_conf(); // Store default config to EEPROM
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set default values for leds
|
|
||||||
setrgb(0, 0, 0, &fleds[0]);
|
|
||||||
setrgb(0, 0, 0, &fleds[1]);
|
|
||||||
|
|
||||||
// Handle lighting for indicator mode
|
|
||||||
if (fled_mode == FLED_INDI) {
|
|
||||||
fled_lock_update(host_keyboard_led_state());
|
|
||||||
fled_layer_update(layer_state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void process_record_fled(uint16_t keycode, keyrecord_t *record) {
|
|
||||||
// Handle custom keycodes for front LED operation
|
|
||||||
switch (keycode) {
|
|
||||||
case FLED_MOD: // Change between front LED operation modes (off, indicator, RGB)
|
|
||||||
if (record->event.pressed)
|
|
||||||
fled_mode_cycle();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FLED_VAI: // Increase the brightness of the front LEDs by FLED_VAL_STEP
|
|
||||||
if (record->event.pressed)
|
|
||||||
fled_val_increase();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FLED_VAD: // Decrease the brightness of the front LEDs by FLED_VAL_STEP
|
|
||||||
if (record->event.pressed)
|
|
||||||
fled_val_decrease();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break; // Process all other keycodes normally
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void fled_load_conf(void) {
|
|
||||||
// Load config
|
|
||||||
fled_config fled_conf;
|
|
||||||
fled_conf.raw = eeprom_read_byte(FRONTLED_CONF_ADDR);
|
|
||||||
fled_mode = fled_conf.mode;
|
|
||||||
fled_val = fled_conf.val * FLED_VAL_STEP;
|
|
||||||
|
|
||||||
// Load color data
|
|
||||||
uint8_t stored_cnt = eeprom_read_byte(FRONTLED_COLOR_CNT_ADDR);
|
|
||||||
uint16_t *color_ptr = FRONTLED_COLOR_ADDR;
|
|
||||||
caps_color.raw = eeprom_read_word(color_ptr); // Should always store at least 1 color
|
|
||||||
for (uint8_t i = 1; i < stored_cnt; i++) {
|
|
||||||
if (i == lc_size) // Can't load more layers than we have available
|
|
||||||
break;
|
|
||||||
layer_colors[i].raw = eeprom_read_word(&color_ptr[i]);
|
|
||||||
}
|
|
||||||
layer_colors[0].raw = 0; // hue = sat = 0 for layer 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// Store current front led config in EEPROM
|
|
||||||
void fled_update_conf(void)
|
|
||||||
{
|
|
||||||
// Create storage struct and set values
|
|
||||||
fled_config conf;
|
|
||||||
conf.mode = fled_mode;
|
|
||||||
|
|
||||||
// Small hack to ensure max value is stored correctly
|
|
||||||
if (fled_val == 255)
|
|
||||||
conf.val = 256 / FLED_VAL_STEP;
|
|
||||||
else
|
|
||||||
conf.val = fled_val / FLED_VAL_STEP;
|
|
||||||
|
|
||||||
// Store config
|
|
||||||
eeprom_update_byte(FRONTLED_CONF_ADDR, conf.raw);
|
|
||||||
|
|
||||||
// Store color data
|
|
||||||
uint16_t *color_ptr = FRONTLED_COLOR_ADDR;
|
|
||||||
eeprom_update_word(color_ptr, caps_color.raw);
|
|
||||||
// Start from 1, layer 0 is not modifiable and therefore not persisted
|
|
||||||
uint8_t i = 1;
|
|
||||||
for (; i < lc_size; i++) {
|
|
||||||
if (i == FRONTLED_COLOR_MAXCNT) // Can't store more than the EEPROM we have available
|
|
||||||
break;
|
|
||||||
eeprom_update_word(&color_ptr[i], layer_colors[i].raw);
|
|
||||||
}
|
|
||||||
eeprom_update_byte(FRONTLED_COLOR_CNT_ADDR, i); // For safety, store the count of colors stored
|
|
||||||
}
|
|
||||||
|
|
||||||
// Custom keycode functions
|
|
||||||
|
|
||||||
void fled_mode_cycle(void)
|
|
||||||
{
|
|
||||||
// FLED -> FLED_RGB -> FLED_INDI
|
|
||||||
switch (fled_mode) {
|
|
||||||
case FLED_OFF:
|
|
||||||
fled_mode = FLED_RGB;
|
|
||||||
rgblight_timer_enable();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FLED_RGB:
|
|
||||||
fled_mode = FLED_INDI;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FLED_INDI:
|
|
||||||
fled_mode = FLED_OFF;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update stored config
|
|
||||||
fled_update_conf();
|
|
||||||
rgblight_set();
|
|
||||||
}
|
|
||||||
|
|
||||||
void fled_val_increase(void)
|
|
||||||
{
|
|
||||||
// Increase val by FLED_VAL_STEP, handling the upper edge case
|
|
||||||
if (fled_val + FLED_VAL_STEP > 255)
|
|
||||||
fled_val = 255;
|
|
||||||
else
|
|
||||||
fled_val += FLED_VAL_STEP;
|
|
||||||
|
|
||||||
// Update stored config
|
|
||||||
fled_update_conf();
|
|
||||||
|
|
||||||
// Update and set LED state
|
|
||||||
if (fled_mode == FLED_INDI) {
|
|
||||||
fled_layer_update(layer_state);
|
|
||||||
fled_lock_update(host_keyboard_led_state());
|
|
||||||
} else {
|
|
||||||
rgblight_set();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void fled_val_decrease(void)
|
|
||||||
{
|
|
||||||
// Decrease val by FLED_VAL_STEP, handling the lower edge case
|
|
||||||
if (fled_val - FLED_VAL_STEP > 255)
|
|
||||||
fled_val = 255;
|
|
||||||
else
|
|
||||||
fled_val -= FLED_VAL_STEP;
|
|
||||||
|
|
||||||
// Update stored config
|
|
||||||
fled_update_conf();
|
|
||||||
|
|
||||||
// Update and set LED state
|
|
||||||
if (fled_mode == FLED_INDI) {
|
|
||||||
fled_layer_update(layer_state);
|
|
||||||
fled_lock_update(host_keyboard_led_state());
|
|
||||||
} else {
|
|
||||||
rgblight_set();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void fled_layer_update(layer_state_t state) {
|
|
||||||
// Determine and set colour of layer LED according to current layer
|
|
||||||
// if hue = sat = 0, leave LED off
|
|
||||||
uint8_t layer = get_highest_layer(state);
|
|
||||||
|
|
||||||
if (layer < lc_size && !(layer_colors[layer].hue == 0 && layer_colors[layer].sat == 0)) {
|
|
||||||
sethsv(layer_colors[layer].hue, layer_colors[layer].sat, fled_val, &fleds[1]);
|
|
||||||
} else {
|
|
||||||
setrgb(0, 0, 0, &fleds[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void fled_lock_update(led_t led_state) {
|
|
||||||
// Set indicator LED appropriately, whether it is used or not
|
|
||||||
if (led_state.caps_lock) {
|
|
||||||
sethsv(caps_color.hue, caps_color.sat, fled_val, &fleds[0]);
|
|
||||||
} else {
|
|
||||||
setrgb(0, 0, 0, &fleds[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
rgblight_set();
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_fled_layer_color(uint8_t layer, hs_set hs) {
|
|
||||||
// Update layer colors and refresh LEDs
|
|
||||||
layer_colors[layer] = hs;
|
|
||||||
fled_layer_update(layer_state);
|
|
||||||
fled_update_conf();
|
|
||||||
}
|
|
||||||
|
|
||||||
hs_set get_fled_layer_color(uint8_t layer) {
|
|
||||||
return layer_colors[layer];
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_fled_caps_color(hs_set hs) {
|
|
||||||
// Update caplock color and refresh LEDs
|
|
||||||
caps_color = hs;
|
|
||||||
fled_lock_update(host_keyboard_led_state());
|
|
||||||
fled_update_conf();
|
|
||||||
}
|
|
||||||
|
|
||||||
hs_set get_fled_caps_color(void) {
|
|
||||||
return caps_color;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fallback eeprom functions if VIA is not enabled
|
|
||||||
#ifndef VIA_ENABLE
|
|
||||||
|
|
||||||
// Can be called in an overriding via_init_kb() to test if keyboard level code usage of
|
|
||||||
// EEPROM is invalid and use/save defaults.
|
|
||||||
bool via_eeprom_is_valid(void)
|
|
||||||
{
|
|
||||||
char *p = QMK_BUILDDATE; // e.g. "2019-11-05-11:29:54"
|
|
||||||
uint8_t magic0 = ( ( p[2] & 0x0F ) << 4 ) | ( p[3] & 0x0F );
|
|
||||||
uint8_t magic1 = ( ( p[5] & 0x0F ) << 4 ) | ( p[6] & 0x0F );
|
|
||||||
uint8_t magic2 = ( ( p[8] & 0x0F ) << 4 ) | ( p[9] & 0x0F );
|
|
||||||
|
|
||||||
return (eeprom_read_byte( (void*)VIA_EEPROM_MAGIC_ADDR+0 ) == magic0 &&
|
|
||||||
eeprom_read_byte( (void*)VIA_EEPROM_MAGIC_ADDR+1 ) == magic1 &&
|
|
||||||
eeprom_read_byte( (void*)VIA_EEPROM_MAGIC_ADDR+2 ) == magic2 );
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,87 +0,0 @@
|
|||||||
/* Copyright 2020 Jumail Mundekkat / MxBlue
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
* the Free Software Foundation, either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// EEPROM management code taken from Wilba6582
|
|
||||||
// https://github.com/Wilba6582/qmk_firmware/blob/zeal60/keyboards/zeal60/zeal_eeprom.h
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "quantum.h"
|
|
||||||
#include "quantum_keycodes.h"
|
|
||||||
#include "via.h"
|
|
||||||
|
|
||||||
// RGBLED index for front LEDs
|
|
||||||
#define RGBLIGHT_FLED1 14
|
|
||||||
#define RGBLIGHT_FLED2 15
|
|
||||||
|
|
||||||
// Brightness increase step for front LEDs
|
|
||||||
#define FLED_VAL_STEP 8
|
|
||||||
|
|
||||||
// Front LED settings
|
|
||||||
#define FRONTLED_CONF_ADDR ((uint8_t*) VIA_EEPROM_CUSTOM_CONFIG_ADDR)
|
|
||||||
#define FRONTLED_COLOR_CNT_ADDR (FRONTLED_CONF_ADDR + 1)
|
|
||||||
#define FRONTLED_COLOR_ADDR ((uint16_t*)(FRONTLED_COLOR_CNT_ADDR + 1))
|
|
||||||
|
|
||||||
// No point persisting more 4, VIA only allows editing of 3 + 1 for caps
|
|
||||||
#define FRONTLED_COLOR_MAXCNT 4
|
|
||||||
|
|
||||||
// Modes for front LEDs
|
|
||||||
#define FLED_OFF 0b00
|
|
||||||
#define FLED_INDI 0b01
|
|
||||||
#define FLED_RGB 0b10
|
|
||||||
#define FLED_UNDEF 0b11
|
|
||||||
|
|
||||||
// Config storage format for EEPROM
|
|
||||||
typedef union {
|
|
||||||
uint8_t raw;
|
|
||||||
struct {
|
|
||||||
uint8_t mode :2;
|
|
||||||
uint8_t val :6;
|
|
||||||
};
|
|
||||||
} fled_config;
|
|
||||||
|
|
||||||
// Structure to store hue and saturation values
|
|
||||||
typedef union {
|
|
||||||
uint16_t raw;
|
|
||||||
struct {
|
|
||||||
uint8_t hue;
|
|
||||||
uint8_t sat;
|
|
||||||
};
|
|
||||||
} hs_set;
|
|
||||||
|
|
||||||
// Custom keycodes for front LED control
|
|
||||||
enum fled_keycodes {
|
|
||||||
FLED_MOD = QK_KB_0, // QK_KB_0 = VIA custom keycode start
|
|
||||||
FLED_VAI,
|
|
||||||
FLED_VAD,
|
|
||||||
};
|
|
||||||
|
|
||||||
void fled_init(void); // Run init functions for front LEDs
|
|
||||||
void process_record_fled(uint16_t keycode, keyrecord_t* record); // Process keycodes for front LEDs
|
|
||||||
void fled_load_conf(void); // Load front LED config from EEPROM
|
|
||||||
void fled_update_conf(void); // Store current front LED config to EEPROM
|
|
||||||
|
|
||||||
void fled_mode_cycle(void); // Cycle between the 3 modes for the front LEDs
|
|
||||||
void fled_val_increase(void); // Increase the brightness of the front LEDs
|
|
||||||
void fled_val_decrease(void); // Decrease the brightness of the front LEDs
|
|
||||||
|
|
||||||
void fled_layer_update(layer_state_t state); // Process layer update for front LEDs
|
|
||||||
void fled_lock_update(led_t led_state); // Process lock update for front LEDs
|
|
||||||
|
|
||||||
void set_fled_layer_color(uint8_t layer, hs_set hs); // Set color for a given layer
|
|
||||||
void set_fled_caps_color(hs_set hs); // Set color for the capslock indicator
|
|
||||||
hs_set get_fled_caps_color(void); // Get color for the capslock indicator
|
|
||||||
hs_set get_fled_layer_color(uint8_t layer); // Get color for a given layer
|
|
@ -2,11 +2,6 @@
|
|||||||
|
|
||||||
![MxSS - Polycarb 65% Kit for MX/SMK](https://i.imgur.com/WDTWcmU.jpg)
|
![MxSS - Polycarb 65% Kit for MX/SMK](https://i.imgur.com/WDTWcmU.jpg)
|
||||||
|
|
||||||
### Important Note:
|
|
||||||
**This PCB supports the VIA configurator, and this is the recommended way to configure the keymap on this keyboard. Building the firmware should only be necessary if you would like to change the colours of the front LEDs in indicator mode.**
|
|
||||||
|
|
||||||
**For more information about the VIA configurator, [see here](https://caniusevia.com/).**
|
|
||||||
|
|
||||||
### Information:
|
### Information:
|
||||||
|
|
||||||
- Case: Frosted Polycarbonate, CNC milled
|
- Case: Frosted Polycarbonate, CNC milled
|
||||||
@ -24,32 +19,23 @@
|
|||||||
- RGB underglow
|
- RGB underglow
|
||||||
- 1.5kg with plate and weight
|
- 1.5kg with plate and weight
|
||||||
|
|
||||||
Keyboard Maintainer: [MxBlue](https://github.com/mxblu)
|
* Keyboard Maintainer: [MxBlue](https://github.com/mxblu)
|
||||||
|
* Hardware Supported: Custom PCB, ATMega32u4
|
||||||
Hardware Supported: Custom PCB, ATMega32u4
|
* Hardware Availability: https://geekhack.org/index.php?topic=94986.0
|
||||||
|
|
||||||
Hardware Availability: https://geekhack.org/index.php?topic=94986.0
|
|
||||||
|
|
||||||
Make example for this keyboard (after setting up your build environment):
|
Make example for this keyboard (after setting up your build environment):
|
||||||
|
|
||||||
make mxss:default
|
make mxss:default
|
||||||
|
|
||||||
See [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) then the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information.
|
Flashing example for this keyboard:
|
||||||
|
|
||||||
# Front LED Operation
|
make mxss:default:flash
|
||||||
|
|
||||||
The MxSS PCB has 2 front RGB LEDs which has a separate brightness and mode of operation to the rest of the RGB LEDs. These are controlled through the supplied custom keycodes.
|
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).
|
||||||
|
|
||||||
There are 3 modes of operation:
|
## Bootloader
|
||||||
|
|
||||||
- FLED_OFF - Front LEDs stay off
|
Enter the bootloader in 2 ways:
|
||||||
- FLED_RGB - Front LEDs are part of the standard RGB LED modes, only works correctly with rainbow modes (will fix on request)
|
|
||||||
- FLED_INDI - Top front LED represents Caps Lock status, bottom LED represents current layer
|
|
||||||
|
|
||||||
Colors for FLED_INDI mode are hardcoded as hue/saturation values, the caps lock color can be found in mxss_frontled.h, the layer colors are defined in keymap.c (see default/keymap.c for example).
|
|
||||||
|
|
||||||
## Custom Keycodes
|
* **Bootmagic reset**: Hold down the key at (0,0) in the matrix (usually the top left key or Escape) and plug in the keyboard
|
||||||
|
* **Keycode in layout**: Press the key mapped to `QK_BOOT` if it is available
|
||||||
- FLED_MOD - Cycle between the 3 modes (FLED_OFF -> FLED_RGB -> FLED_INDI)
|
|
||||||
- FLED_VAI - Increase front LED brightness
|
|
||||||
- FLED_VAD - Decrease front LED brightness
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,22 +1 @@
|
|||||||
# Build Options
|
# This file intentionally left blank
|
||||||
# change yes to no to disable
|
|
||||||
#
|
|
||||||
BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite
|
|
||||||
MOUSEKEY_ENABLE = yes # Mouse keys
|
|
||||||
EXTRAKEY_ENABLE = yes # Audio control and System control
|
|
||||||
CONSOLE_ENABLE = no # Console for debug
|
|
||||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
|
||||||
NKRO_ENABLE = no # Enable N-Key Rollover
|
|
||||||
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
|
|
||||||
AUDIO_ENABLE = no # Audio output
|
|
||||||
|
|
||||||
SRC += mxss_frontled.c
|
|
||||||
|
|
||||||
# Remove the common RGB light code and use my iteration instead
|
|
||||||
COMMON_VPATH += $(QUANTUM_DIR)/rgblight
|
|
||||||
OPT_DEFS += -DRGBLIGHT_ENABLE
|
|
||||||
SRC += rgblight.c
|
|
||||||
SRC += $(QUANTUM_DIR)/color.c
|
|
||||||
WS2812_DRIVER_REQUIRED = yes
|
|
||||||
CIE1931_CURVE = yes
|
|
||||||
RGB_KEYCODES_ENABLE = yes
|
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
/* Copyright 2018 REPLACE_WITH_YOUR_NAME
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
* the Free Software Foundation, either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
#include QMK_KEYBOARD_H
|
|
||||||
#include "mxss_frontled.h"
|
|
||||||
|
|
||||||
hs_set caps_color = { .hue = 0, .sat = 255 };
|
|
||||||
|
|
||||||
// Colors for layers
|
|
||||||
// Format: {hue, saturation}
|
|
||||||
// {0, 0} to turn off the LED
|
|
||||||
// Add additional rows to handle more layers
|
|
||||||
hs_set layer_colors[4] = {
|
|
||||||
[0] = {.hue = 0, .sat = 0}, // Color for Layer 0
|
|
||||||
[1] = {.hue = 86, .sat = 255}, // Color for Layer 1
|
|
||||||
[2] = {.hue = 36, .sat = 255}, // Color for Layer 2
|
|
||||||
[3] = {.hue = 185, .sat = 255}, // Color for Layer 3
|
|
||||||
};
|
|
||||||
size_t lc_size = ARRAY_SIZE(layer_colors);
|
|
||||||
|
|
||||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|
||||||
__KEYMAP_GOES_HERE__
|
|
||||||
};
|
|
Loading…
Reference in New Issue
Block a user