Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed MxSS ISO layouts in QMK configuator (hopefully) #3352

Merged
merged 16 commits into from
Jul 9, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added initial support for individual control of front RGB LEDs
  • Loading branch information
MxBlu committed Jul 4, 2018
commit 3b8fdd2463d75bb9a426ede3c1134afbaf2fcdfc
2 changes: 1 addition & 1 deletion keyboards/mxss/info.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"keyboard_name": "MxSS",
"maintainer": "qmk",
"url": "",
"url": "https://geekhack.org/index.php?topic=94986.0",
"height": 5,
"width": 16,
"layouts": {
Expand Down
17 changes: 15 additions & 2 deletions keyboards/mxss/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include QMK_KEYBOARD_H
#include "rgblight.h"

// Predefined colors for layers
// Format: {red, green, blue}
// Add additional rows to handle more layers
LED_TYPE layer_colors[] = {
{0, 0, 0}, // Color for Layer 0
{255, 0, 0}, // Color for Layer 1
{0, 255, 0}, // Color for Layer 2
{0, 0, 255}, // Color for Layer 3
};

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
LAYOUT( /* Base */
Expand All @@ -27,12 +38,14 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
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_TRNS, KC_MPLY, KC_MPRV, KC_MNXT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_HOME, KC_PSCR, KC_TRNS, KC_TRNS, RGB_VAI,
KC_TRNS, 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,
RESET, 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,
RESET, 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
),
};

const size_t array_size = sizeof(keymaps) / sizeof(uint16_t);

const uint16_t PROGMEM fn_actions[] = {

};
Expand Down
60 changes: 58 additions & 2 deletions keyboards/mxss/mxss.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2018 REPLACE_WITH_YOUR_NAME
/* Copyright 2018 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
Expand All @@ -13,11 +13,42 @@
* 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 "tmk_core/common/eeprom.h"
#include "rgblight.h"
#include "mxss_frontled.h"

// Variables for controlling front LED application
uint8_t fled_mode;
uint8_t fled_val;

LED_TYPE fleds[2];

void matrix_init_kb(void) {
// put your keyboard start-up code here
// runs once when the firmware starts up

// If EEPROM config exists, load it
if (eeprom_is_valid()) {
fled_config fled_conf;
fled_conf.raw = eeprom_read_byte(EEPROM_FRONTLED_ADDR);
fled_mode = fled_conf.mode;
fled_val = fled_conf.val;
// Else, default config
} else {
fled_mode = FLED_INDI;
fled_val = 3;
}

// Set default values for leds
setrgb(0, 0, 0, &fleds[0]);
setrgb(0, 0, 0, &fleds[1]);

// Enable capslock led if enabled on host
if (fled_mode == FLED_INDI && (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK))) {
setrgb(FLED_CAPS_R, FLED_CAPS_G, FLED_CAPS_B, &fleds[0]);
}

matrix_init_user();
}
Expand All @@ -37,7 +68,32 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
}

void led_set_kb(uint8_t usb_led) {
// put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
// Set indicator LED appropriately, whether it is used or not
if (usb_led & (1 << USB_LED_CAPS_LOCK)) {
setrgb(FLED_CAPS_R, FLED_CAPS_G, FLED_CAPS_B, &fleds[0]);
} else {
setrgb(0, 0, 0, &fleds[0]);
}

led_set_user(usb_led);
}

// EEPROM Management

bool eeprom_is_valid(void)
{
return (eeprom_read_word(EEPROM_MAGIC_ADDR) == EEPROM_MAGIC);
}

void eeprom_set_valid(bool valid)
{
eeprom_update_word(EEPROM_MAGIC_ADDR, valid ? EEPROM_MAGIC : 0xFFFF);
}

void eeprom_update_conf(void)
{
fled_config conf;
conf.mode = fled_mode;
conf.val = fled_val;
eeprom_update_word(EEPROM_FRONTLED_ADDR, conf.raw);
}
61 changes: 61 additions & 0 deletions keyboards/mxss/mxss_frontled.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/* Copyright 2018 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

#ifndef MXSS_FRONTLED_H
#define MXSS_FRONTLED_H

#define RGBLIGHT_FLED1 14
#define RGBLIGHT_FLED2 15

// QMK never uses more then 32bytes of EEPROM, so our region starts there
// Magic value to verify the state of the EEPROM
#define EEPROM_MAGIC 0xC3E7
#define EEPROM_MAGIC_ADDR ((void*)32)

// Front LED settings
#define EEPROM_FRONTLED_ADDR ((void*)34)

// Modes for front LEDs
#define FLED_OFF 0b00
#define FLED_INDI 0b01
#define FLED_RGB 0b10
#define FLED_UNDEF 0b11

// Hard-coded color for capslock indicator in FLED_INDI mode
#define FLED_CAPS_R 255
#define FLED_CAPS_G 0
#define FLED_CAPS_B 0

typedef union {
uint8_t raw;
struct {
uint8_t mode :2;
uint8_t val :6;
};
} fled_config;

typedef struct _hs_set {
uint16_t hue;
uint8_t sat;
} hs_set;

bool eeprom_is_valid(void); // Check if EEPROM has been set up
void eeprom_set_valid(bool valid); // Change validity state of EEPROM

#endif //MXSS_FRONTLED_H
Loading