diff options
| author | MxBlu <mundekkat@hotmail.com> | 2018-07-08 12:33:36 +1000 |
|---|---|---|
| committer | Drashna Jaelre <drashna@live.com> | 2018-07-07 19:33:36 -0700 |
| commit | e661f1559ebdf90c3bb806b6f5940c5363720738 (patch) | |
| tree | d4104b21c10e6522d3c03339687354092de49e5e | |
| parent | df8b564518930969f6ee319edeee2fcb0d715db6 (diff) | |
| download | qmk_firmware-e661f1559ebdf90c3bb806b6f5940c5363720738.tar.gz qmk_firmware-e661f1559ebdf90c3bb806b6f5940c5363720738.zip | |
Add MxSS keyboard (#3335)
* Added basic MxSS support
* Fixed split RSHFT for ISO layouts
* Updated readme.md for MxSS
* Added initial support for individual control of front RGB LEDs
* Changed RGBLED color selection to work using hue and saturation rather than RGB
Added code for LED state change on layer change
* Avoid needing an entire 8 bits to store the brightness value
* Added custom keycodes, along with their handlers
* Added EEPROM storage for front LED config
* Fixed up ability to use QMK Configurator and updated readme.md
* Applied suggested changes from pull request: https://github.com/standard/standard/issues/452
Updated name in license descriptions
Updated layouts to snake case
Corrected mistakes in info.json
Updated layer_colors to a weak attributed array in mxss.c
* Defined a new safe range for custom keycodes in keymap.c
| -rw-r--r-- | keyboards/mxss/config.h | 138 | ||||
| -rw-r--r-- | keyboards/mxss/info.json | 45 | ||||
| -rw-r--r-- | keyboards/mxss/keymaps/default/config.h | 24 | ||||
| -rw-r--r-- | keyboards/mxss/keymaps/default/keymap.c | 89 | ||||
| -rw-r--r-- | keyboards/mxss/mxss.c | 209 | ||||
| -rw-r--r-- | keyboards/mxss/mxss.h | 207 | ||||
| -rw-r--r-- | keyboards/mxss/mxss_frontled.h | 81 | ||||
| -rw-r--r-- | keyboards/mxss/readme.md | 54 | ||||
| -rw-r--r-- | keyboards/mxss/rgblight.c | 804 | ||||
| -rw-r--r-- | keyboards/mxss/rules.mk | 75 | ||||
| -rw-r--r-- | keyboards/mxss/templates/keymap.c | 42 |
11 files changed, 1768 insertions, 0 deletions
diff --git a/keyboards/mxss/config.h b/keyboards/mxss/config.h new file mode 100644 index 000000000..8be64e0b3 --- /dev/null +++ b/keyboards/mxss/config.h | |||
| @@ -0,0 +1,138 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2018 Jumail Mundekkat / MxBlue | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #ifndef CONFIG_H | ||
| 19 | #define CONFIG_H | ||
| 20 | |||
| 21 | #include "config_common.h" | ||
| 22 | |||
| 23 | /* USB Device descriptor parameter */ | ||
| 24 | #define VENDOR_ID 0xFEED | ||
| 25 | #define PRODUCT_ID 0x6060 | ||
| 26 | #define DEVICE_VER 0x0001 | ||
| 27 | #define MANUFACTURER MxBlue | ||
| 28 | #define PRODUCT MxSS | ||
| 29 | #define DESCRIPTION Custom Polycarb Keyboard | ||
| 30 | |||
| 31 | /* key matrix size */ | ||
| 32 | #define MATRIX_ROWS 5 | ||
| 33 | #define MATRIX_COLS 15 | ||
| 34 | |||
| 35 | /* matrix pin configuration */ | ||
| 36 | #define MATRIX_ROW_PINS { F4, F1, F7, B1, B7 } | ||
| 37 | #define MATRIX_COL_PINS { D7, D6, D4, D0, C6, B6, D1, B5, D2, B4, D3, D5, B0, B2, B3 } | ||
| 38 | #define UNUSED_PINS | ||
| 39 | |||
| 40 | /* COL2ROW, ROW2COL, or CUSTOM_MATRIX */ | ||
| 41 | #define DIODE_DIRECTION COL2ROW | ||
| 42 | |||
| 43 | /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ | ||
| 44 | #define DEBOUNCING_DELAY 5 | ||
| 45 | |||
| 46 | /* Basic RGB configuration */ | ||
| 47 | #define RGB_DI_PIN C7 | ||
| 48 | #define RGBLIGHT_ANIMATIONS | ||
| 49 | #define RGBLED_NUM 20 | ||
| 50 | #define RGBLIGHT_HUE_STEP 8 | ||
| 51 | #define RGBLIGHT_SAT_STEP 8 | ||
| 52 | #define RGBLIGHT_VAL_STEP 8 | ||
| 53 | |||
| 54 | /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ | ||
| 55 | #define LOCKING_SUPPORT_ENABLE | ||
| 56 | /* Locking resynchronize hack */ | ||
| 57 | #define LOCKING_RESYNC_ENABLE | ||
| 58 | |||
| 59 | /* If defined, GRAVE_ESC will always act as ESC when CTRL is held. | ||
| 60 | * This is userful for the Windows task manager shortcut (ctrl+shift+esc). | ||
| 61 | */ | ||
| 62 | // #define GRAVE_ESC_CTRL_OVERRIDE | ||
| 63 | |||
| 64 | /* | ||
| 65 | * Force NKRO | ||
| 66 | * | ||
| 67 | * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved | ||
| 68 | * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the | ||
| 69 | * makefile for this to work.) | ||
| 70 | * | ||
| 71 | * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N) | ||
| 72 | * until the next keyboard reset. | ||
| 73 | * | ||
| 74 | * NKRO may prevent your keystrokes from being detected in the BIOS, but it is | ||
| 75 | * fully operational during normal computer usage. | ||
| 76 | * | ||
| 77 | * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N) | ||
| 78 | * or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by | ||
| 79 | * bootmagic, NKRO mode will always be enabled until it is toggled again during a | ||
| 80 | * power-up. | ||
| 81 | * | ||
| 82 | */ | ||
| 83 | //#define FORCE_NKRO | ||
| 84 | |||
| 85 | /* | ||
| 86 | * Magic Key Options | ||
| 87 | * | ||
| 88 | * Magic keys are hotkey commands that allow control over firmware functions of | ||
| 89 | * the keyboard. They are best used in combination with the HID Listen program, | ||
| 90 | * found here: https://www.pjrc.com/teensy/hid_listen.html | ||
| 91 | * | ||
| 92 | * The options below allow the magic key functionality to be changed. This is | ||
| 93 | * useful if your keyboard/keypad is missing keys and you want magic key support. | ||
| 94 | * | ||
| 95 | */ | ||
| 96 | |||
| 97 | /* key combination for magic key command */ | ||
| 98 | #define IS_COMMAND() ( \ | ||
| 99 | keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ | ||
| 100 | ) | ||
| 101 | |||
| 102 | /* control how magic key switches layers */ | ||
| 103 | //#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS true | ||
| 104 | //#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS true | ||
| 105 | //#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM false | ||
| 106 | |||
| 107 | /* override magic key keymap */ | ||
| 108 | //#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS | ||
| 109 | //#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS | ||
| 110 | //#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM | ||
| 111 | //#define MAGIC_KEY_HELP1 H | ||
| 112 | //#define MAGIC_KEY_HELP2 SLASH | ||
| 113 | //#define MAGIC_KEY_DEBUG D | ||
| 114 | //#define MAGIC_KEY_DEBUG_MATRIX X | ||
| 115 | //#define MAGIC_KEY_DEBUG_KBD K | ||
| 116 | //#define MAGIC_KEY_DEBUG_MOUSE M | ||
| 117 | //#define MAGIC_KEY_VERSION V | ||
| 118 | //#define MAGIC_KEY_STATUS S | ||
| 119 | //#define MAGIC_KEY_CONSOLE C | ||
| 120 | //#define MAGIC_KEY_LAYER0_ALT1 ESC | ||
| 121 | //#define MAGIC_KEY_LAYER0_ALT2 GRAVE | ||
| 122 | //#define MAGIC_KEY_LAYER0 0 | ||
| 123 | //#define MAGIC_KEY_LAYER1 1 | ||
| 124 | //#define MAGIC_KEY_LAYER2 2 | ||
| 125 | //#define MAGIC_KEY_LAYER3 3 | ||
| 126 | //#define MAGIC_KEY_LAYER4 4 | ||
| 127 | //#define MAGIC_KEY_LAYER5 5 | ||
| 128 | //#define MAGIC_KEY_LAYER6 6 | ||
| 129 | //#define MAGIC_KEY_LAYER7 7 | ||
| 130 | //#define MAGIC_KEY_LAYER8 8 | ||
| 131 | //#define MAGIC_KEY_LAYER9 9 | ||
| 132 | //#define MAGIC_KEY_BOOTLOADER PAUSE | ||
| 133 | //#define MAGIC_KEY_LOCK CAPS | ||
| 134 | //#define MAGIC_KEY_EEPROM E | ||
| 135 | //#define MAGIC_KEY_NKRO N | ||
| 136 | //#define MAGIC_KEY_SLEEP_LED Z | ||
| 137 | |||
| 138 | #endif | ||
diff --git a/keyboards/mxss/info.json b/keyboards/mxss/info.json new file mode 100644 index 000000000..76321e813 --- /dev/null +++ b/keyboards/mxss/info.json | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | { | ||
| 2 | "keyboard_name": "MxSS", | ||
| 3 | "maintainer": "qmk", | ||
| 4 | "url": "https://geekhack.org/index.php?topic=94986.0", | ||
| 5 | "height": 5, | ||
| 6 | "width": 16, | ||
| 7 | "layouts": { | ||
| 8 | "LAYOUT": { | ||
| 9 | "layout": [{"x":0, "y":0}, {"x":1, "y":0}, {"x":2, "y":0}, {"x":3, "y":0}, {"x":4, "y":0}, {"x":5, "y":0}, {"x":6, "y":0}, {"x":7, "y":0}, {"x":8, "y":0}, {"x":9, "y":0}, {"x":10, "y":0}, {"x":11, "y":0}, {"x":12, "y":0}, {"x":13, "y":0, "w":2}, {"x":0, "y":1, "w":1.5}, {"x":1.5, "y":1}, {"x":2.5, "y":1}, {"x":3.5, "y":1}, {"x":4.5, "y":1}, {"x":5.5, "y":1}, {"x":6.5, "y":1}, {"x":7.5, "y":1}, {"x":8.5, "y":1}, {"x":9.5, "y":1}, {"x":10.5, "y":1}, {"x":11.5, "y":1}, {"x":12.5, "y":1}, {"x":13.5, "y":1, "w":1.5}, {"x":15, "y":1}, {"x":0, "y":2, "w":1.75}, {"x":1.75, "y":2}, {"x":2.75, "y":2}, {"x":3.75, "y":2}, {"x":4.75, "y":2}, {"x":5.75, "y":2}, {"x":6.75, "y":2}, {"x":7.75, "y":2}, {"x":8.75, "y":2}, {"x":9.75, "y":2}, {"x":10.75, "y":2}, {"x":11.75, "y":2}, {"x":12.75, "y":2, "w":2.25}, {"x":15, "y":2}, {"x":0, "y":3, "w":2.25}, {"x":2.25, "y":3}, {"x":3.25, "y":3}, {"x":4.25, "y":3}, {"x":5.25, "y":3}, {"x":6.25, "y":3}, {"x":7.25, "y":3}, {"x":8.25, "y":3}, {"x":9.25, "y":3}, {"x":10.25, "y":3}, {"x":11.25, "y":3}, {"x":12.25, "y":3, "w":1.75}, {"x":14, "y":3}, {"x":15, "y":3}, {"x":0, "y":4, "w":1.25}, {"x":1.25, "y":4, "w":1.25}, {"x":2.5, "y":4, "w":1.25}, {"x":3.75, "y":4, "w":6.25}, {"x":10, "y":4, "w":1.25}, {"x":11.25, "y":4, "w":1.25}, {"x":13, "y":4}, {"x":14, "y":4}, {"x":15, "y":4}] | ||
| 10 | }, | ||
| 11 | "LAYOUT_7u": { | ||
| 12 | "layout": [{"x":0, "y":0}, {"x":1, "y":0}, {"x":2, "y":0}, {"x":3, "y":0}, {"x":4, "y":0}, {"x":5, "y":0}, {"x":6, "y":0}, {"x":7, "y":0}, {"x":8, "y":0}, {"x":9, "y":0}, {"x":10, "y":0}, {"x":11, "y":0}, {"x":12, "y":0}, {"x":13, "y":0, "w":2}, {"x":0, "y":1, "w":1.5}, {"x":1.5, "y":1}, {"x":2.5, "y":1}, {"x":3.5, "y":1}, {"x":4.5, "y":1}, {"x":5.5, "y":1}, {"x":6.5, "y":1}, {"x":7.5, "y":1}, {"x":8.5, "y":1}, {"x":9.5, "y":1}, {"x":10.5, "y":1}, {"x":11.5, "y":1}, {"x":12.5, "y":1}, {"x":13.5, "y":1, "w":1.5}, {"x":15, "y":1}, {"x":0, "y":2, "w":1.75}, {"x":1.75, "y":2}, {"x":2.75, "y":2}, {"x":3.75, "y":2}, {"x":4.75, "y":2}, {"x":5.75, "y":2}, {"x":6.75, "y":2}, {"x":7.75, "y":2}, {"x":8.75, "y":2}, {"x":9.75, "y":2}, {"x":10.75, "y":2}, {"x":11.75, "y":2}, {"x":12.75, "y":2, "w":2.25}, {"x":15, "y":2}, {"x":0, "y":3, "w":2.25}, {"x":2.25, "y":3}, {"x":3.25, "y":3}, {"x":4.25, "y":3}, {"x":5.25, "y":3}, {"x":6.25, "y":3}, {"x":7.25, "y":3}, {"x":8.25, "y":3}, {"x":9.25, "y":3}, {"x":10.25, "y":3}, {"x":11.25, "y":3}, {"x":12.25, "y":3, "w":1.75}, {"x":14, "y":3}, {"x":15, "y":3}, {"x":0, "y":4, "w":1.5}, {"x":1.5, "y":4}, {"x":2.5, "y":4, "w":1.5}, {"x":4, "y":4, "w":7}, {"x":11, "y":4, "w":1.5}, {"x":13, "y":4}, {"x":14, "y":4}, {"x":15, "y":4}] | ||
| 13 | }, | ||
| 14 | "LAYOUT_splitspace": { | ||
| 15 | "layout": [{"x":0, "y":0}, {"x":1, "y":0}, {"x":2, "y":0}, {"x":3, "y":0}, {"x":4, "y":0}, {"x":5, "y":0}, {"x":6, "y":0}, {"x":7, "y":0}, {"x":8, "y":0}, {"x":9, "y":0}, {"x":10, "y":0}, {"x":11, "y":0}, {"x":12, "y":0}, {"x":13, "y":0, "w":2}, {"x":0, "y":1, "w":1.5}, {"x":1.5, "y":1}, {"x":2.5, "y":1}, {"x":3.5, "y":1}, {"x":4.5, "y":1}, {"x":5.5, "y":1}, {"x":6.5, "y":1}, {"x":7.5, "y":1}, {"x":8.5, "y":1}, {"x":9.5, "y":1}, {"x":10.5, "y":1}, {"x":11.5, "y":1}, {"x":12.5, "y":1}, {"x":13.5, "y":1, "w":1.5}, {"x":15, "y":1}, {"x":0, "y":2, "w":1.75}, {"x":1.75, "y":2}, {"x":2.75, "y":2}, {"x":3.75, "y":2}, {"x":4.75, "y":2}, {"x":5.75, "y":2}, {"x":6.75, "y":2}, {"x":7.75, "y":2}, {"x":8.75, "y":2}, {"x":9.75, "y":2}, {"x":10.75, "y":2}, {"x":11.75, "y":2}, {"x":12.75, "y":2, "w":2.25}, {"x":15, "y":2}, {"x":0, "y":3, "w":2.25}, {"x":2.25, "y":3}, {"x":3.25, "y":3}, {"x":4.25, "y":3}, {"x":5.25, "y":3}, {"x":6.25, "y":3}, {"x":7.25, "y":3}, {"x":8.25, "y":3}, {"x":9.25, "y":3}, {"x":10.25, "y":3}, {"x":11.25, "y":3}, {"x":12.25, "y":3, "w":1.75}, {"x":14, "y":3}, {"x":15, "y":3}, {"x":0, "y":4, "w":1.25}, {"x":1.25, "y":4, "w":1.25}, {"x":2.5, "y":4, "w":1.25}, {"x":3.75, "y":4, "w":2.25}, {"x":6, "y":4, "w":1.25}, {"x":7.25, "y":4, "w":2.75}, {"x":10, "y":4, "w":1.25}, {"x":11.25, "y":4, "w":1.25}, {"x":13, "y":4}, {"x":14, "y":4}, {"x":15, "y":4}] | ||
| 16 | }, | ||
| 17 | "LAYOUT_splitbs": { | ||
| 18 | "layout": [{"x":0, "y":0}, {"x":1, "y":0}, {"x":2, "y":0}, {"x":3, "y":0}, {"x":4, "y":0}, {"x":5, "y":0}, {"x":6, "y":0}, {"x":7, "y":0}, {"x":8, "y":0}, {"x":9, "y":0}, {"x":10, "y":0}, {"x":11, "y":0}, {"x":12, "y":0}, {"x":13, "y":0}, {"x":14, "y":0}, {"x":0, "y":1, "w":1.5}, {"x":1.5, "y":1}, {"x":2.5, "y":1}, {"x":3.5, "y":1}, {"x":4.5, "y":1}, {"x":5.5, "y":1}, {"x":6.5, "y":1}, {"x":7.5, "y":1}, {"x":8.5, "y":1}, {"x":9.5, "y":1}, {"x":10.5, "y":1}, {"x":11.5, "y":1}, {"x":12.5, "y":1}, {"x":13.5, "y":1, "w":1.5}, {"x":15, "y":1}, {"x":0, "y":2, "w":1.75}, {"x":1.75, "y":2}, {"x":2.75, "y":2}, {"x":3.75, "y":2}, {"x":4.75, "y":2}, {"x":5.75, "y":2}, {"x":6.75, "y":2}, {"x":7.75, "y":2}, {"x":8.75, "y":2}, {"x":9.75, "y":2}, {"x":10.75, "y":2}, {"x":11.75, "y":2}, {"x":12.75, "y":2, "w":2.25}, {"x":15, "y":2}, {"x":0, "y":3, "w":2.25}, {"x":2.25, "y":3}, {"x":3.25, "y":3}, {"x":4.25, "y":3}, {"x":5.25, "y":3}, {"x":6.25, "y":3}, {"x":7.25, "y":3}, {"x":8.25, "y":3}, {"x":9.25, "y":3}, {"x":10.25, "y":3}, {"x":11.25, "y":3}, {"x":12.25, "y":3, "w":1.75}, {"x":14, "y":3}, {"x":15, "y":3}, {"x":0, "y":4, "w":1.25}, {"x":1.25, "y":4, "w":1.25}, {"x":2.5, "y":4, "w":1.25}, {"x":3.75, "y":4, "w":6.25}, {"x":10, "y":4, "w":1.25}, {"x":11.25, "y":4, "w":1.25}, {"x":13, "y":4}, {"x":14, "y":4}, {"x":15, "y":4}] | ||
| 19 | }, | ||
| 20 | "LAYOUT_splitbs_7u": { | ||
| 21 | "layout": [{"x":0, "y":0}, {"x":1, "y":0}, {"x":2, "y":0}, {"x":3, "y":0}, {"x":4, "y":0}, {"x":5, "y":0}, {"x":6, "y":0}, {"x":7, "y":0}, {"x":8, "y":0}, {"x":9, "y":0}, {"x":10, "y":0}, {"x":11, "y":0}, {"x":12, "y":0}, {"x":13, "y":0}, {"x":14, "y":0}, {"x":0, "y":1, "w":1.5}, {"x":1.5, "y":1}, {"x":2.5, "y":1}, {"x":3.5, "y":1}, {"x":4.5, "y":1}, {"x":5.5, "y":1}, {"x":6.5, "y":1}, {"x":7.5, "y":1}, {"x":8.5, "y":1}, {"x":9.5, "y":1}, {"x":10.5, "y":1}, {"x":11.5, "y":1}, {"x":12.5, "y":1}, {"x":13.5, "y":1, "w":1.5}, {"x":15, "y":1}, {"x":0, "y":2, "w":1.75}, {"x":1.75, "y":2}, {"x":2.75, "y":2}, {"x":3.75, "y":2}, {"x":4.75, "y":2}, {"x":5.75, "y":2}, {"x":6.75, "y":2}, {"x":7.75, "y":2}, {"x":8.75, "y":2}, {"x":9.75, "y":2}, {"x":10.75, "y":2}, {"x":11.75, "y":2}, {"x":12.75, "y":2, "w":2.25}, {"x":15, "y":2}, {"x":0, "y":3, "w":2.25}, {"x":2.25, "y":3}, {"x":3.25, "y":3}, {"x":4.25, "y":3}, {"x":5.25, "y":3}, {"x":6.25, "y":3}, {"x":7.25, "y":3}, {"x":8.25, "y":3}, {"x":9.25, "y":3}, {"x":10.25, "y":3}, {"x":11.25, "y":3}, {"x":12.25, "y":3, "w":1.75}, {"x":14, "y":3}, {"x":15, "y":3}, {"x":0, "y":4, "w":1.5}, {"x":1.5, "y":4}, {"x":2.5, "y":4, "w":1.5}, {"x":4, "y":4, "w":7}, {"x":11, "y":4, "w":1.5}, {"x":13, "y":4}, {"x":14, "y":4}, {"x":15, "y":4}] | ||
| 22 | }, | ||
| 23 | "LAYOUT_splitbs_splitspace": { | ||
| 24 | "layout": [{"x":0, "y":0}, {"x":1, "y":0}, {"x":2, "y":0}, {"x":3, "y":0}, {"x":4, "y":0}, {"x":5, "y":0}, {"x":6, "y":0}, {"x":7, "y":0}, {"x":8, "y":0}, {"x":9, "y":0}, {"x":10, "y":0}, {"x":11, "y":0}, {"x":12, "y":0}, {"x":13, "y":0}, {"x":14, "y":0}, {"x":0, "y":1, "w":1.5}, {"x":1.5, "y":1}, {"x":2.5, "y":1}, {"x":3.5, "y":1}, {"x":4.5, "y":1}, {"x":5.5, "y":1}, {"x":6.5, "y":1}, {"x":7.5, "y":1}, {"x":8.5, "y":1}, {"x":9.5, "y":1}, {"x":10.5, "y":1}, {"x":11.5, "y":1}, {"x":12.5, "y":1}, {"x":13.5, "y":1, "w":1.5}, {"x":15, "y":1}, {"x":0, "y":2, "w":1.75}, {"x":1.75, "y":2}, {"x":2.75, "y":2}, {"x":3.75, "y":2}, {"x":4.75, "y":2}, {"x":5.75, "y":2}, {"x":6.75, "y":2}, {"x":7.75, "y":2}, {"x":8.75, "y":2}, {"x":9.75, "y":2}, {"x":10.75, "y":2}, {"x":11.75, "y":2}, {"x":12.75, "y":2, "w":2.25}, {"x":15, "y":2}, {"x":0, "y":3, "w":2.25}, {"x":2.25, "y":3}, {"x":3.25, "y":3}, {"x":4.25, "y":3}, {"x":5.25, "y":3}, {"x":6.25, "y":3}, {"x":7.25, "y":3}, {"x":8.25, "y":3}, {"x":9.25, "y":3}, {"x":10.25, "y":3}, {"x":11.25, "y":3}, {"x":12.25, "y":3, "w":1.75}, {"x":14, "y":3}, {"x":15, "y":3}, {"x":0, "y":4, "w":1.25}, {"x":1.25, "y":4, "w":1.25}, {"x":2.5, "y":4, "w":1.25}, {"x":3.75, "y":4, "w":2.25}, {"x":6, "y":4, "w":1.25}, {"x":7.25, "y":4, "w":2.75}, {"x":10, "y":4, "w":1.25}, {"x":11.25, "y":4, "w":1.25}, {"x":13, "y":4}, {"x":14, "y":4}, {"x":15, "y":4}] | ||
| 25 | }, | ||
| 26 | "LAYOUT_iso": { | ||
| 27 | "layout": [{"x":0, "y":0}, {"x":1, "y":0}, {"x":2, "y":0}, {"x":3, "y":0}, {"x":4, "y":0}, {"x":5, "y":0}, {"x":6, "y":0}, {"x":7, "y":0}, {"x":8, "y":0}, {"x":9, "y":0}, {"x":10, "y":0}, {"x":11, "y":0}, {"x":12, "y":0}, {"x":13, "y":0, "w":2}, {"x":0, "y":1, "w":1.5}, {"x":1.5, "y":1}, {"x":2.5, "y":1}, {"x":3.5, "y":1}, {"x":4.5, "y":1}, {"x":5.5, "y":1}, {"x":6.5, "y":1}, {"x":7.5, "y":1}, {"x":8.5, "y":1}, {"x":9.5, "y":1}, {"x":10.5, "y":1}, {"x":11.5, "y":1}, {"x":12.5, "y":1}, {"x":13.75, "y":1, "w":1.25, "h":2}, {"x":15, "y":1}, {"x":0, "y":2, "w":1.75}, {"x":1.75, "y":2}, {"x":2.75, "y":2}, {"x":3.75, "y":2}, {"x":4.75, "y":2}, {"x":5.75, "y":2}, {"x":6.75, "y":2}, {"x":7.75, "y":2}, {"x":8.75, "y":2}, {"x":9.75, "y":2}, {"x":10.75, "y":2}, {"x":11.75, "y":2}, {"x":12.75, "y":2}, {"x":15, "y":2}, {"x":0, "y":3, "w":1.25}, {"x":1.25, "y":3}, {"x":2.25, "y":3}, {"x":3.25, "y":3}, {"x":4.25, "y":3}, {"x":5.25, "y":3}, {"x":6.25, "y":3}, {"x":7.25, "y":3}, {"x":8.25, "y":3}, {"x":9.25, "y":3}, {"x":10.25, "y":3}, {"x":11.25, "y":3}, {"x":12.25, "y":3, "w":1.75}, {"x":14, "y":3}, {"x":15, "y":3}, {"x":0, "y":4, "w":1.25}, {"x":1.25, "y":4, "w":1.25}, {"x":2.5, "y":4, "w":1.25}, {"x":3.75, "y":4, "w":6.25}, {"x":10, "y":4, "w":1.25}, {"x":11.25, "y":4, "w":1.25}, {"x":13, "y":4}, {"x":14, "y":4}, {"x":15, "y":4}] | ||
| 28 | }, | ||
| 29 | "LAYOUT_iso_7u": { | ||
| 30 | "layout": [{"x":0, "y":0}, {"x":1, "y":0}, {"x":2, "y":0}, {"x":3, "y":0}, {"x":4, "y":0}, {"x":5, "y":0}, {"x":6, "y":0}, {"x":7, "y":0}, {"x":8, "y":0}, {"x":9, "y":0}, {"x":10, "y":0}, {"x":11, "y":0}, {"x":12, "y":0}, {"x":13, "y":0, "w":2}, {"x":0, "y":1, "w":1.5}, {"x":1.5, "y":1}, {"x":2.5, "y":1}, {"x":3.5, "y":1}, {"x":4.5, "y":1}, {"x":5.5, "y":1}, {"x":6.5, "y":1}, {"x":7.5, "y":1}, {"x":8.5, "y":1}, {"x":9.5, "y":1}, {"x":10.5, "y":1}, {"x":11.5, "y":1}, {"x":12.5, "y":1}, {"x":13.75, "y":1, "w":1.25, "h":2}, {"x":15, "y":1}, {"x":0, "y":2, "w":1.75}, {"x":1.75, "y":2}, {"x":2.75, "y":2}, {"x":3.75, "y":2}, {"x":4.75, "y":2}, {"x":5.75, "y":2}, {"x":6.75, "y":2}, {"x":7.75, "y":2}, {"x":8.75, "y":2}, {"x":9.75, "y":2}, {"x":10.75, "y":2}, {"x":11.75, "y":2}, {"x":12.75, "y":2}, {"x":15, "y":2}, {"x":0, "y":3, "w":1.25}, {"x":1.25, "y":3}, {"x":2.25, "y":3}, {"x":3.25, "y":3}, {"x":4.25, "y":3}, {"x":5.25, "y":3}, {"x":6.25, "y":3}, {"x":7.25, "y":3}, {"x":8.25, "y":3}, {"x":9.25, "y":3}, {"x":10.25, "y":3}, {"x":11.25, "y":3}, {"x":12.25, "y":3, "w":1.75}, {"x":14, "y":3}, {"x":15, "y":3}, {"x":0, "y":4, "w":1.5}, {"x":1.5, "y":4}, {"x":2.5, "y":4, "w":1.5}, {"x":4, "y":4, "w":7}, {"x":11, "y":4, "w":1.5}, {"x":13, "y":4}, {"x":14, "y":4}, {"x":15, "y":4}] | ||
| 31 | }, | ||
| 32 | "LAYOUT_iso_splitspace": { | ||
| 33 | "layout": [{"x":0, "y":0}, {"x":1, "y":0}, {"x":2, "y":0}, {"x":3, "y":0}, {"x":4, "y":0}, {"x":5, "y":0}, {"x":6, "y":0}, {"x":7, "y":0}, {"x":8, "y":0}, {"x":9, "y":0}, {"x":10, "y":0}, {"x":11, "y":0}, {"x":12, "y":0}, {"x":13, "y":0, "w":2}, {"x":0, "y":1, "w":1.5}, {"x":1.5, "y":1}, {"x":2.5, "y":1}, {"x":3.5, "y":1}, {"x":4.5, "y":1}, {"x":5.5, "y":1}, {"x":6.5, "y":1}, {"x":7.5, "y":1}, {"x":8.5, "y":1}, {"x":9.5, "y":1}, {"x":10.5, "y":1}, {"x":11.5, "y":1}, {"x":12.5, "y":1}, {"x":13.75, "y":1, "w":1.25, "h":2}, {"x":15, "y":1}, {"x":0, "y":2, "w":1.75}, {"x":1.75, "y":2}, {"x":2.75, "y":2}, {"x":3.75, "y":2}, {"x":4.75, "y":2}, {"x":5.75, "y":2}, {"x":6.75, "y":2}, {"x":7.75, "y":2}, {"x":8.75, "y":2}, {"x":9.75, "y":2}, {"x":10.75, "y":2}, {"x":11.75, "y":2}, {"x":12.75, "y":2}, {"x":15, "y":2}, {"x":0, "y":3, "w":1.25}, {"x":1.25, "y":3}, {"x":2.25, "y":3}, {"x":3.25, "y":3}, {"x":4.25, "y":3}, {"x":5.25, "y":3}, {"x":6.25, "y":3}, {"x":7.25, "y":3}, {"x":8.25, "y":3}, {"x":9.25, "y":3}, {"x":10.25, "y":3}, {"x":11.25, "y":3}, {"x":12.25, "y":3, "w":1.75}, {"x":14, "y":3}, {"x":15, "y":3}, {"x":0, "y":4, "w":1.25}, {"x":1.25, "y":4, "w":1.25}, {"x":2.5, "y":4, "w":1.25}, {"x":3.75, "y":4, "w":2.25}, {"x":6, "y":4, "w":1.25}, {"x":7.25, "y":4, "w":2.75}, {"x":10, "y":4, "w":1.25}, {"x":11.25, "y":4, "w":1.25}, {"x":13, "y":4}, {"x":14, "y":4}, {"x":15, "y":4}] | ||
| 34 | }, | ||
| 35 | "LAYOUT_iso_splitbs": { | ||
| 36 | "layout": [{"x":0, "y":0}, {"x":1, "y":0}, {"x":2, "y":0}, {"x":3, "y":0}, {"x":4, "y":0}, {"x":5, "y":0}, {"x":6, "y":0}, {"x":7, "y":0}, {"x":8, "y":0}, {"x":9, "y":0}, {"x":10, "y":0}, {"x":11, "y":0}, {"x":12, "y":0}, {"x":13, "y":0}, {"x":14, "y":0}, {"x":0, "y":1, "w":1.5}, {"x":1.5, "y":1}, {"x":2.5, "y":1}, {"x":3.5, "y":1}, {"x":4.5, "y":1}, {"x":5.5, "y":1}, {"x":6.5, "y":1}, {"x":7.5, "y":1}, {"x":8.5, "y":1}, {"x":9.5, "y":1}, {"x":10.5, "y":1}, {"x":11.5, "y":1}, {"x":12.5, "y":1}, {"x":13.75, "y":1, "w":1.25, "h":2}, {"x":15, "y":1}, {"x":0, "y":2, "w":1.75}, {"x":1.75, "y":2}, {"x":2.75, "y":2}, {"x":3.75, "y":2}, {"x":4.75, "y":2}, {"x":5.75, "y":2}, {"x":6.75, "y":2}, {"x":7.75, "y":2}, {"x":8.75, "y":2}, {"x":9.75, "y":2}, {"x":10.75, "y":2}, {"x":11.75, "y":2}, {"x":12.75, "y":2}, {"x":15, "y":2}, {"x":0, "y":3, "w":1.25}, {"x":1.25, "y":3}, {"x":2.25, "y":3}, {"x":3.25, "y":3}, {"x":4.25, "y":3}, {"x":5.25, "y":3}, {"x":6.25, "y":3}, {"x":7.25, "y":3}, {"x":8.25, "y":3}, {"x":9.25, "y":3}, {"x":10.25, "y":3}, {"x":11.25, "y":3}, {"x":12.25, "y":3, "w":1.75}, {"x":14, "y":3}, {"x":15, "y":3}, {"x":0, "y":4, "w":1.25}, {"x":1.25, "y":4, "w":1.25}, {"x":2.5, "y":4, "w":1.25}, {"x":3.75, "y":4, "w":6.25}, {"x":10, "y":4, "w":1.25}, {"x":11.25, "y":4, "w":1.25}, {"x":13, "y":4}, {"x":14, "y":4}, {"x":15, "y":4}] | ||
| 37 | }, | ||
| 38 | "LAYOUT_iso_splitbs_7u": { | ||
| 39 | "layout": [{"x":0, "y":0}, {"x":1, "y":0}, {"x":2, "y":0}, {"x":3, "y":0}, {"x":4, "y":0}, {"x":5, "y":0}, {"x":6, "y":0}, {"x":7, "y":0}, {"x":8, "y":0}, {"x":9, "y":0}, {"x":10, "y":0}, {"x":11, "y":0}, {"x":12, "y":0}, {"x":13, "y":0}, {"x":14, "y":0}, {"x":0, "y":1, "w":1.5}, {"x":1.5, "y":1}, {"x":2.5, "y":1}, {"x":3.5, "y":1}, {"x":4.5, "y":1}, {"x":5.5, "y":1}, {"x":6.5, "y":1}, {"x":7.5, "y":1}, {"x":8.5, "y":1}, {"x":9.5, "y":1}, {"x":10.5, "y":1}, {"x":11.5, "y":1}, {"x":12.5, "y":1}, {"x":13.75, "y":1, "w":1.25, "h":2}, {"x":15, "y":1}, {"x":0, "y":2, "w":1.75}, {"x":1.75, "y":2}, {"x":2.75, "y":2}, {"x":3.75, "y":2}, {"x":4.75, "y":2}, {"x":5.75, "y":2}, {"x":6.75, "y":2}, {"x":7.75, "y":2}, {"x":8.75, "y":2}, {"x":9.75, "y":2}, {"x":10.75, "y":2}, {"x":11.75, "y":2}, {"x":12.75, "y":2}, {"x":15, "y":2}, {"x":0, "y":3, "w":1.25}, {"x":1.25, "y":3}, {"x":2.25, "y":3}, {"x":3.25, "y":3}, {"x":4.25, "y":3}, {"x":5.25, "y":3}, {"x":6.25, "y":3}, {"x":7.25, "y":3}, {"x":8.25, "y":3}, {"x":9.25, "y":3}, {"x":10.25, "y":3}, {"x":11.25, "y":3}, {"x":12.25, "y":3, "w":1.75}, {"x":14, "y":3}, {"x":15, "y":3}, {"x":0, "y":4, "w":1.5}, {"x":1.5, "y":4}, {"x":2.5, "y":4, "w":1.5}, {"x":4, "y":4, "w":7}, {"x":11, "y":4, "w":1.5}, {"x":13, "y":4}, {"x":14, "y":4}, {"x":15, "y":4}] | ||
| 40 | }, | ||
| 41 | "LAYOUT_ISO_splitbs_splitspace": { | ||
| 42 | "layout": [{"x":0, "y":0}, {"x":1, "y":0}, {"x":2, "y":0}, {"x":3, "y":0}, {"x":4, "y":0}, {"x":5, "y":0}, {"x":6, "y":0}, {"x":7, "y":0}, {"x":8, "y":0}, {"x":9, "y":0}, {"x":10, "y":0}, {"x":11, "y":0}, {"x":12, "y":0}, {"x":13, "y":0}, {"x":14, "y":0}, {"x":0, "y":1, "w":1.5}, {"x":1.5, "y":1}, {"x":2.5, "y":1}, {"x":3.5, "y":1}, {"x":4.5, "y":1}, {"x":5.5, "y":1}, {"x":6.5, "y":1}, {"x":7.5, "y":1}, {"x":8.5, "y":1}, {"x":9.5, "y":1}, {"x":10.5, "y":1}, {"x":11.5, "y":1}, {"x":12.5, "y":1}, {"x":13.75, "y":1, "w":1.25, "h":2}, {"x":15, "y":1}, {"x":0, "y":2, "w":1.75}, {"x":1.75, "y":2}, {"x":2.75, "y":2}, {"x":3.75, "y":2}, {"x":4.75, "y":2}, {"x":5.75, "y":2}, {"x":6.75, "y":2}, {"x":7.75, "y":2}, {"x":8.75, "y":2}, {"x":9.75, "y":2}, {"x":10.75, "y":2}, {"x":11.75, "y":2}, {"x":12.75, "y":2}, {"x":15, "y":2}, {"x":0, "y":3, "w":1.25}, {"x":1.25, "y":3}, {"x":2.25, "y":3}, {"x":3.25, "y":3}, {"x":4.25, "y":3}, {"x":5.25, "y":3}, {"x":6.25, "y":3}, {"x":7.25, "y":3}, {"x":8.25, "y":3}, {"x":9.25, "y":3}, {"x":10.25, "y":3}, {"x":11.25, "y":3}, {"x":12.25, "y":3, "w":1.75}, {"x":14, "y":3}, {"x":15, "y":3}, {"x":0, "y":4, "w":1.25}, {"x":1.25, "y":4, "w":1.25}, {"x":2.5, "y":4, "w":1.25}, {"x":3.75, "y":4, "w":2.25}, {"x":6, "y":4, "w":1.25}, {"x":7.25, "y":4, "w":2.75}, {"x":10, "y":4, "w":1.25}, {"x":11.25, "y":4, "w":1.25}, {"x":13, "y":4}, {"x":14, "y":4}, {"x":15, "y":4}] | ||
| 43 | } | ||
| 44 | } | ||
| 45 | } | ||
diff --git a/keyboards/mxss/keymaps/default/config.h b/keyboards/mxss/keymaps/default/config.h new file mode 100644 index 000000000..9f8622579 --- /dev/null +++ b/keyboards/mxss/keymaps/default/config.h | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | /* Copyright 2018 Jumail Mundekkat / MxBlue | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #ifndef CONFIG_USER_H | ||
| 18 | #define CONFIG_USER_H | ||
| 19 | |||
| 20 | #include "config_common.h" | ||
| 21 | |||
| 22 | // place overrides here | ||
| 23 | |||
| 24 | #endif | ||
diff --git a/keyboards/mxss/keymaps/default/keymap.c b/keyboards/mxss/keymaps/default/keymap.c new file mode 100644 index 000000000..47983c90c --- /dev/null +++ b/keyboards/mxss/keymaps/default/keymap.c | |||
| @@ -0,0 +1,89 @@ | |||
| 1 | /* Copyright 2018 Jumail Mundekkat / MxBlue | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #include QMK_KEYBOARD_H | ||
| 17 | |||
| 18 | // Colors for layers | ||
| 19 | // Format: {hue, saturation} | ||
| 20 | // {0, 0} to turn off the LED | ||
| 21 | // Add additional rows to handle more layers | ||
| 22 | const hs_set layer_colors[] = { | ||
| 23 | [0] = {0, 0}, // Color for Layer 0 | ||
| 24 | [1] = {86, 255}, // Color for Layer 1 | ||
| 25 | [2] = {36, 255}, // Color for Layer 2 | ||
| 26 | [3] = {185, 255}, // Color for Layer 3 | ||
| 27 | }; | ||
| 28 | const size_t lc_size = sizeof(layer_colors) / sizeof(uint16_t); | ||
| 29 | |||
| 30 | // Use NEW_SAFE_RANGE to define new custom keycodes in order to not overwrite the ones used for front LED control | ||
| 31 | enum custom_keycodes { | ||
| 32 | MY_KEYCODE = NEW_SAFE_RANGE, | ||
| 33 | }; | ||
| 34 | |||
| 35 | |||
| 36 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 37 | LAYOUT( /* Base */ | ||
| 38 | KC_GESC, 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, | ||
| 39 | 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_DEL, | ||
| 40 | KC_CAPSLOCK, 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_PGUP, | ||
| 41 | 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_PGDN, | ||
| 42 | KC_LCTL, KC_LGUI, KC_LALT, KC_SPACE, KC_RALT, MO(1), KC_LEFT, KC_DOWN, KC_RGHT | ||
| 43 | ), | ||
| 44 | |||
| 45 | LAYOUT( /* L1 */ | ||
| 46 | 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, | ||
| 47 | 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, | ||
| 48 | 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, | ||
| 49 | 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, | ||
| 50 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RGB_HUD, RGB_SAD, RGB_HUI | ||
| 51 | ), | ||
| 52 | }; | ||
| 53 | |||
| 54 | |||
| 55 | const uint16_t PROGMEM fn_actions[] = { | ||
| 56 | |||
| 57 | }; | ||
| 58 | |||
| 59 | const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) | ||
| 60 | { | ||
| 61 | // MACRODOWN only works in this function | ||
| 62 | switch(id) { | ||
| 63 | case 0: | ||
| 64 | if (record->event.pressed) { | ||
| 65 | register_code(KC_RSFT); | ||
| 66 | } else { | ||
| 67 | unregister_code(KC_RSFT); | ||
| 68 | } | ||
| 69 | break; | ||
| 70 | } | ||
| 71 | return MACRO_NONE; | ||
| 72 | }; | ||
| 73 | |||
| 74 | |||
| 75 | void matrix_init_user(void) { | ||
| 76 | |||
| 77 | } | ||
| 78 | |||
| 79 | void matrix_scan_user(void) { | ||
| 80 | |||
| 81 | } | ||
| 82 | |||
| 83 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
| 84 | return true; | ||
| 85 | } | ||
| 86 | |||
| 87 | void led_set_user(uint8_t usb_led) { | ||
| 88 | |||
| 89 | } | ||
diff --git a/keyboards/mxss/mxss.c b/keyboards/mxss/mxss.c new file mode 100644 index 000000000..b16348c7b --- /dev/null +++ b/keyboards/mxss/mxss.c | |||
| @@ -0,0 +1,209 @@ | |||
| 1 | /* Copyright 2018 Jumail Mundekkat / MxBlue | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include QMK_KEYBOARD_H | ||
| 18 | #include "tmk_core/common/eeprom.h" | ||
| 19 | #include "tmk_core/common/action_layer.h" | ||
| 20 | #include "rgblight.h" | ||
| 21 | |||
| 22 | // Variables for controlling front LED application | ||
| 23 | uint8_t fled_mode; // Mode for front LEDs | ||
| 24 | uint8_t fled_val; // Brightness for front leds (0 - 255) | ||
| 25 | LED_TYPE fleds[2]; // Front LED rgb values for indicator mode use | ||
| 26 | |||
| 27 | // Predefined colors for layers | ||
| 28 | // Format: {hue, saturation} | ||
| 29 | // {0, 0} to turn off the LED | ||
| 30 | // Add additional rows to handle more layers | ||
| 31 | __attribute__ ((weak)) | ||
| 32 | const hs_set layer_colors[] = { | ||
| 33 | [0] = {0, 0}, // Color for Layer 0 | ||
| 34 | [1] = {86, 255}, // Color for Layer 1 | ||
| 35 | [2] = {36, 255}, // Color for Layer 2 | ||
| 36 | [3] = {185, 255}, // Color for Layer 3 | ||
| 37 | }; | ||
| 38 | |||
| 39 | __attribute__ ((weak)) | ||
| 40 | const size_t lc_size = sizeof(layer_colors) / sizeof(uint16_t); | ||
| 41 | |||
| 42 | void matrix_init_kb(void) { | ||
| 43 | // If EEPROM config exists, load it | ||
| 44 | if (eeprom_is_valid()) { | ||
| 45 | fled_config fled_conf; | ||
| 46 | fled_conf.raw = eeprom_read_byte(EEPROM_FRONTLED_ADDR); | ||
| 47 | fled_mode = fled_conf.mode; | ||
| 48 | fled_val = fled_conf.val * FLED_VAL_STEP; | ||
| 49 | // Else, default config | ||
| 50 | } else { | ||
| 51 | fled_mode = FLED_RGB; | ||
| 52 | fled_val = 10 * FLED_VAL_STEP; | ||
| 53 | eeprom_update_conf(); // Store default config to EEPROM | ||
| 54 | } | ||
| 55 | |||
| 56 | // Set default values for leds | ||
| 57 | setrgb(0, 0, 0, &fleds[0]); | ||
| 58 | setrgb(0, 0, 0, &fleds[1]); | ||
| 59 | |||
| 60 | // Handle lighting for indicator mode | ||
| 61 | if (fled_mode == FLED_INDI) { | ||
| 62 | // Enable capslock led if enabled on host | ||
| 63 | if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) | ||
| 64 | sethsv(FLED_CAPS_H, FLED_CAPS_S, fled_val, &fleds[0]); | ||
| 65 | |||
| 66 | // Determine and set colour of layer LED according to current layer | ||
| 67 | // if hue = sat = 0, leave LED off | ||
| 68 | uint8_t layer = biton32(layer_state); | ||
| 69 | if (layer < lc_size && !(layer_colors[layer].hue == 0 && layer_colors[layer].hue == 0)) | ||
| 70 | sethsv(layer_colors[layer].hue, layer_colors[layer].sat, fled_val, &fleds[1]); | ||
| 71 | } | ||
| 72 | |||
| 73 | matrix_init_user(); | ||
| 74 | } | ||
| 75 | |||
| 76 | void matrix_scan_kb(void) { | ||
| 77 | // put your looping keyboard code here | ||
| 78 | // runs every cycle (a lot) | ||
| 79 | |||
| 80 | matrix_scan_user(); | ||
| 81 | } | ||
| 82 | |||
| 83 | bool process_record_kb(uint16_t keycode, keyrecord_t *record) { | ||
| 84 | // Handle custom keycodes for front LED operation | ||
| 85 | switch (keycode) { | ||
| 86 | case FLED_MOD: // Change between front LED operation modes (off, indicator, RGB) | ||
| 87 | if (record->event.pressed) | ||
| 88 | fled_mode_cycle(); | ||
| 89 | break; | ||
| 90 | |||
| 91 | case FLED_VAI: // Increase the brightness of the front LEDs by FLED_VAL_STEP | ||
| 92 | if (record->event.pressed) | ||
| 93 | fled_val_increase(); | ||
| 94 | break; | ||
| 95 | |||
| 96 | case FLED_VAD: // Decrease the brightness of the front LEDs by FLED_VAL_STEP | ||
| 97 | if (record->event.pressed) | ||
| 98 | fled_val_decrease(); | ||
| 99 | break; | ||
| 100 | |||
| 101 | default: | ||
| 102 | break; // Process all other keycodes normally | ||
| 103 | } | ||
| 104 | |||
| 105 | return process_record_user(keycode, record); | ||
| 106 | } | ||
| 107 | |||
| 108 | void led_set_kb(uint8_t usb_led) { | ||
| 109 | // Set indicator LED appropriately, whether it is used or not | ||
| 110 | if (usb_led & (1 << USB_LED_CAPS_LOCK)) { | ||
| 111 | sethsv(FLED_CAPS_H, FLED_CAPS_S, fled_val, &fleds[0]); | ||
| 112 | } else { | ||
| 113 | setrgb(0, 0, 0, &fleds[0]); | ||
| 114 | } | ||
| 115 | |||
| 116 | led_set_user(usb_led); | ||
| 117 | } | ||
| 118 | |||
| 119 | uint32_t layer_state_set_kb(uint32_t state) { | ||
| 120 | // Determine and set colour of layer LED according to current layer | ||
| 121 | // if hue = sat = 0, leave LED off | ||
| 122 | uint8_t layer = biton32(state); | ||
| 123 | |||
| 124 | if (layer < lc_size && !(layer_colors[layer].hue == 0 && layer_colors[layer].hue == 0)) | ||
| 125 | sethsv(layer_colors[layer].hue, layer_colors[layer].sat, fled_val, &fleds[1]); | ||
| 126 | else | ||
| 127 | setrgb(0, 0, 0, &fleds[1]); | ||
| 128 | |||
| 129 | return state; | ||
| 130 | } | ||
| 131 | |||
| 132 | // EEPROM Management | ||
| 133 | |||
| 134 | // Test if magic value is present at expected location | ||
| 135 | bool eeprom_is_valid(void) | ||
| 136 | { | ||
| 137 | return (eeprom_read_word(EEPROM_MAGIC_ADDR) == EEPROM_MAGIC); | ||
| 138 | } | ||
| 139 | |||
| 140 | // Set magic value at expected location | ||
| 141 | void eeprom_set_valid(bool valid) | ||
| 142 | { | ||
| 143 | eeprom_update_word(EEPROM_MAGIC_ADDR, valid ? EEPROM_MAGIC : 0xFFFF); | ||
| 144 | } | ||
| 145 | |||
| 146 | // Store current front led config in EEPROM | ||
| 147 | void eeprom_update_conf(void) | ||
| 148 | { | ||
| 149 | // Create storage struct and set values | ||
| 150 | fled_config conf; | ||
| 151 | conf.mode = fled_mode; | ||
| 152 | |||
| 153 | // Small hack to ensure max value is stored correctly | ||
| 154 | if (fled_val == 255) | ||
| 155 | conf.val = 256 / FLED_VAL_STEP; | ||
| 156 | else | ||
| 157 | conf.val = fled_val / FLED_VAL_STEP; | ||
| 158 | |||
| 159 | // Set magic value and store config | ||
| 160 | eeprom_set_valid(true); | ||
| 161 | eeprom_update_byte(EEPROM_FRONTLED_ADDR, conf.raw); | ||
| 162 | } | ||
| 163 | |||
| 164 | // Custom keycode functions | ||
| 165 | |||
| 166 | void fled_mode_cycle(void) | ||
| 167 | { | ||
| 168 | // FLED -> FLED_RGB -> FLED_INDI | ||
| 169 | switch (fled_mode) { | ||
| 170 | case FLED_OFF: | ||
| 171 | fled_mode = FLED_RGB; | ||
| 172 | break; | ||
| 173 | |||
| 174 | case FLED_RGB: | ||
| 175 | fled_mode = FLED_INDI; | ||
| 176 | break; | ||
| 177 | |||
| 178 | case FLED_INDI: | ||
| 179 | fled_mode = FLED_OFF; | ||
| 180 | break; | ||
| 181 | } | ||
| 182 | |||
| 183 | // Update stored config | ||
| 184 | eeprom_update_conf(); | ||
| 185 | } | ||
| 186 | |||
| 187 | void fled_val_increase(void) | ||
| 188 | { | ||
| 189 | // Increase val by FLED_VAL_STEP, handling the upper edge case | ||
| 190 | if (fled_val + FLED_VAL_STEP > 255) | ||
| 191 | fled_val = 255; | ||
| 192 | else | ||
| 193 | fled_val += FLED_VAL_STEP; | ||
| 194 | |||
| 195 | // Update stored config | ||
| 196 | eeprom_update_conf(); | ||
| 197 | } | ||
| 198 | |||
| 199 | void fled_val_decrease(void) | ||
| 200 | { | ||
| 201 | // Decrease val by FLED_VAL_STEP, handling the lower edge case | ||
| 202 | if (fled_val - FLED_VAL_STEP > 255) | ||
| 203 | fled_val = 255; | ||
| 204 | else | ||
| 205 | fled_val -= FLED_VAL_STEP; | ||
| 206 | |||
| 207 | // Update stored config | ||
| 208 | eeprom_update_conf(); | ||
| 209 | } | ||
diff --git a/keyboards/mxss/mxss.h b/keyboards/mxss/mxss.h new file mode 100644 index 000000000..bd0af86ca --- /dev/null +++ b/keyboards/mxss/mxss.h | |||
| @@ -0,0 +1,207 @@ | |||
| 1 | /* Copyright 2018 Jumail Mundekkat / MxBlue | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #ifndef MXSS_H | ||
| 17 | #define MXSS_H | ||
| 18 | |||
| 19 | #include "quantum.h" | ||
| 20 | #include "mxss_frontled.h" | ||
| 21 | |||
| 22 | // This a shortcut to help you visually see your layout. | ||
| 23 | // The following is an example using the Planck MIT layout | ||
| 24 | // The first section contains all of the arguments | ||
| 25 | // The second converts the arguments into a two-dimensional array | ||
| 26 | |||
| 27 | #define LAYOUT( \ | ||
| 28 | k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0A, k0B, k0C, k0E, \ | ||
| 29 | k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1A, k1B, k1C, k1D, k10E, \ | ||
| 30 | k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2A, k2B, k2D, k2E, \ | ||
| 31 | k30, k32, k33, k34, k35, k36, k37, k38, k39, k3A, k3B, k3C, k3D, k3E, \ | ||
| 32 | k40, k41, k42, k46, k4A, k4B, k4C, k4D, k4E \ | ||
| 33 | ) \ | ||
| 34 | { \ | ||
| 35 | { k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0A, k0B, k0C, KC_NO, k0E }, \ | ||
| 36 | { k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1A, k1B, k1C, k1D, k10E }, \ | ||
| 37 | { k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2A, k2B, KC_NO, k2D, k2E }, \ | ||
| 38 | { k30, KC_NO, k32, k33, k34, k35, k36, k37, k38, k39, k3A, k3B, k3C, k3D, k3E }, \ | ||
| 39 | { k40, k41, k42, KC_NO, KC_NO, KC_NO, k46, KC_NO, KC_NO, KC_NO, k4A, k4B, k4C, k4D, k4E }, \ | ||
| 40 | } | ||
| 41 | //ANSI, normalBS, 7u | ||
| 42 | #define LAYOUT_7u( \ | ||
| 43 | k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0A, k0B, k0C, k0E, \ | ||
| 44 | k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1A, k1B, k1C, k1D, k1E, \ | ||
| 45 | k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2A, k2B, k2D, k2E, \ | ||
| 46 | k30, k32, k33, k34, k35, k36, k37, k38, k39, k3A, k3B, k3C, k3D, k3E, \ | ||
| 47 | k40, k41, k42, k46, k4B, k4C, k4D, k4E \ | ||
| 48 | ) \ | ||
| 49 | { \ | ||
| 50 | { k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0A, k0B, k0C, KC_NO, k0E }, \ | ||
| 51 | { k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1A, k1B, k1C, k1D, k1E }, \ | ||
| 52 | { k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2A, k2B, KC_NO, k2D, k2E }, \ | ||
| 53 | { k30, KC_NO, k32, k33, k34, k35, k36, k37, k38, k39, k3A, k3B, k3C, k3D, k3E }, \ | ||
| 54 | { k40, k41, k42, KC_NO, KC_NO, KC_NO, k46, KC_NO, KC_NO, KC_NO, KC_NO, k4B, k4C, k4D, k4E }, \ | ||
| 55 | } | ||
| 56 | //ANSI, normalBS, split space | ||
| 57 | #define LAYOUT_splitspace( \ | ||
| 58 | k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0A, k0B, k0C, k0E, \ | ||
| 59 | k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1A, k1B, k1C, k1D, k1E, \ | ||
| 60 | k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2A, k2B, k2D, k2E, \ | ||
| 61 | k30, k32, k33, k34, k35, k36, k37, k38, k39, k3A, k3B, k3C, k3D, k3E, \ | ||
| 62 | k40, k41, k42, k43, k46, k48, k4A, k4B, k4C, k4D, k4E \ | ||
| 63 | ) \ | ||
| 64 | { \ | ||
| 65 | { k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0A, k0B, k0C, KC_NO, k0E }, \ | ||
| 66 | { k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1A, k1B, k1C, k1D, k1E }, \ | ||
| 67 | { k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2A, k2B, KC_NO, k2D, k2E }, \ | ||
| 68 | { k30, KC_NO, k32, k33, k34, k35, k36, k37, k38, k39, k3A, k3B, k3C, k3D, k3E }, \ | ||
| 69 | { k40, k41, k42, k43, KC_NO, KC_NO, k46, KC_NO, k48, KC_NO, k4A, k4B, k4C, k4D, k4E }, \ | ||
| 70 | } | ||
| 71 | //ANSI, splitBS, 6.25u | ||
| 72 | #define LAYOUT_splitbs( \ | ||
| 73 | k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0A, k0B, k0C, k0D, k0E, \ | ||
| 74 | k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1A, k1B, k1C, k1D, k1E, \ | ||
| 75 | k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2A, k2B, k2D, k2E, \ | ||
| 76 | k30, k32, k33, k34, k35, k36, k37, k38, k39, k3A, k3B, k3C, k3D, k3E, \ | ||
| 77 | k40, k41, k42, k46, k4A, k4B, k4C, k4D, k4E \ | ||
| 78 | ) \ | ||
| 79 | { \ | ||
| 80 | { k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0A, k0B, k0C, k0D, k0E }, \ | ||
| 81 | { k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1A, k1B, k1C, k1D, k1E }, \ | ||
| 82 | { k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2A, k2B, KC_NO, k2D, k2E }, \ | ||
| 83 | { k30, KC_NO, k32, k33, k34, k35, k36, k37, k38, k39, k3A, k3B, k3C, k3D, k3E }, \ | ||
| 84 | { k40, k41, k42, KC_NO, KC_NO, KC_NO, k46, KC_NO, KC_NO, KC_NO, k4A, k4B, k4C, k4D, k4E }, \ | ||
| 85 | } | ||
| 86 | //ANSI, splitBS, 7u | ||
| 87 | #define LAYOUT_splitbs_7u( \ | ||
| 88 | k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0A, k0B, k0C, k0D, k0E, \ | ||
| 89 | k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1A, k1B, k1C, k1D, k1E, \ | ||
| 90 | k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2A, k2B, k2D, k2E, \ | ||
| 91 | k30, k32, k33, k34, k35, k36, k37, k38, k39, k3A, k3B, k3C, k3D, k3E, \ | ||
| 92 | k40, k41, k42, k46, k4B, k4C, k4D, k4E \ | ||
| 93 | ) \ | ||
| 94 | { \ | ||
| 95 | { k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0A, k0B, k0C, k0D, k0E }, \ | ||
| 96 | { k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1A, k1B, k1C, k1D, k1E }, \ | ||
| 97 | { k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2A, k2B, KC_NO, k2D, k2E }, \ | ||
| 98 | { k30, KC_NO, k32, k33, k34, k35, k36, k37, k38, k39, k3A, k3B, k3C, k3D, k3E }, \ | ||
| 99 | { k40, k41, k42, KC_NO, KC_NO, KC_NO, k46, KC_NO, KC_NO, KC_NO, KC_NO, k4B, k4C, k4D, k4E }, \ | ||
| 100 | } | ||
| 101 | //ANSI, normalBS, split space | ||
| 102 | #define LAYOUT_splitbs_splitspace( \ | ||
| 103 | k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0A, k0B, k0C, k0D, k0E, \ | ||
| 104 | k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1A, k1B, k1C, k1D, k1E, \ | ||
| 105 | k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2A, k2B, k2D, k2E, \ | ||
| 106 | k30, k32, k33, k34, k35, k36, k37, k38, k39, k3A, k3B, k3C, k3D, k3E, \ | ||
| 107 | k40, k41, k42, k43, k46, k48, k4A, k4B, k4C, k4D, k4E \ | ||
| 108 | ) \ | ||
| 109 | { \ | ||
| 110 | { k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0A, k0B, k0C, k0D, k0E }, \ | ||
| 111 | { k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1A, k1B, k1C, k1D, k1E }, \ | ||
| 112 | { k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2A, k2B, KC_NO, k2D, k2E }, \ | ||
| 113 | { k30, KC_NO, k32, k33, k34, k35, k36, k37, k38, k39, k3A, k3B, k3C, k3D, k3E }, \ | ||
| 114 | { k40, k41, k42, k43, KC_NO, KC_NO, k46, KC_NO, k48, KC_NO, k4A, k4B, k4C, k4D, k4E }, \ | ||
| 115 | } | ||
| 116 | //ISO, normalBS, 6.25u | ||
| 117 | #define LAYOUT_iso( \ | ||
| 118 | k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0A, k0B, k0C, k0E, \ | ||
| 119 | k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1A, k1B, k1C, k1D, k1E, \ | ||
| 120 | k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2A, k2B, k2C, k2D, k2E, \ | ||
| 121 | k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3A, k3B, k3C, k3D, k3E, \ | ||
| 122 | k40, k41, k42, k46, k4A, k4B, k4C, k4D, k4E \ | ||
| 123 | ) \ | ||
| 124 | { \ | ||
| 125 | { k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0A, k0B, k0C, KC_NO, k0E }, \ | ||
| 126 | { k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1A, k1B, k1C, k1D, k1E }, \ | ||
| 127 | { k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2A, k2B, k2C, k2D, k2E }, \ | ||
| 128 | { k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3A, k3B, k3C, k3D, k3E }, \ | ||
| 129 | { k40, k41, k42, KC_NO, KC_NO, KC_NO, k46, KC_NO, KC_NO, KC_NO, k4A, k4B, k4C, k4D, k4E }, \ | ||
| 130 | } | ||
| 131 | //ISO, normalBS, 7u | ||
| 132 | #define LAYOUT_iso_7u( \ | ||
| 133 | k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0A, k0B, k0C, k0E, \ | ||
| 134 | k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1A, k1B, k1C, k1D, k1E, \ | ||
| 135 | k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2A, k2B, k2C, k2D, k2E, \ | ||
| 136 | k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3A, k3B, k3C, k3D, k3E, \ | ||
| 137 | k40, k41, k42, k46, k4B, k4C, k4D, k4E \ | ||
| 138 | ) \ | ||
| 139 | { \ | ||
| 140 | { k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0A, k0B, k0C, KC_NO, k0E }, \ | ||
| 141 | { k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1A, k1B, k1C, k1D, k1E }, \ | ||
| 142 | { k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2A, k2B, k2C, k2D, k2E }, \ | ||
| 143 | { k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3A, k3B, k3C, k3D, k3E }, \ | ||
| 144 | { k40, k41, k42, KC_NO, KC_NO, KC_NO, k46, KC_NO, KC_NO, KC_NO, KC_NO, k4B, k4C, k4D, k4E }, \ | ||
| 145 | } | ||
| 146 | //ISO, normalBS, split space | ||
| 147 | #define LAYOUT_iso_splitspace( \ | ||
| 148 | k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0A, k0B, k0C, k0E, \ | ||
| 149 | k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1A, k1B, k1C, k1D, k1E, \ | ||
| 150 | k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2A, k2B, k2C, k2D, k2E, \ | ||
| 151 | k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3A, k3B, k3C, k3D, k3E, \ | ||
| 152 | k40, k41, k42, k43, k46, k48, k4A, k4B, k4C, k4D, k4E \ | ||
| 153 | ) \ | ||
| 154 | { \ | ||
| 155 | { k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0A, k0B, k0C, KC_NO, k0E }, \ | ||
| 156 | { k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1A, k1B, k1C, k1D, k1E }, \ | ||
| 157 | { k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2A, k2B, k2C, k2D, k2E }, \ | ||
| 158 | { k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3A, k3B, k3C, k3D, k3E }, \ | ||
| 159 | { k40, k41, k42, k43, KC_NO, KC_NO, k46, KC_NO, k48, KC_NO, k4A, k4B, k4C, k4D, k4E }, \ | ||
| 160 | } | ||
| 161 | //ISO, splitBS, 6.25u | ||
| 162 | #define LAYOUT_iso_splitbs( \ | ||
| 163 | k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0A, k0B, k0C, k0D, k0E, \ | ||
| 164 | k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1A, k1B, k1C, k1D, k1E, \ | ||
| 165 | k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2A, k2B, k2C, k2D, k2E, \ | ||
| 166 | k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3A, k3B, k3C, k3D, k3E, \ | ||
| 167 | k40, k41, k42, k46, k4A, k4B, k4C, k4D, k4E \ | ||
| 168 | ) \ | ||
| 169 | { \ | ||
| 170 | { k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0A, k0B, k0C, k0D, k0E }, \ | ||
| 171 | { k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1A, k1B, k1C, k1D, k1E }, \ | ||
| 172 | { k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2A, k2B, k2C, k2D, k2E }, \ | ||
| 173 | { k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3A, k3B, k3C, k3D, k3E }, \ | ||
| 174 | { k40, k41, k42, KC_NO, KC_NO, KC_NO, k46, KC_NO, KC_NO, KC_NO, k4A, k4B, k4C, k4D, k4E }, \ | ||
| 175 | } | ||
| 176 | //ISO, splitBS, 7u | ||
| 177 | #define LAYOUT_iso_splitbs_7u( \ | ||
| 178 | k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0A, k0B, k0C, k0D, k0E, \ | ||
| 179 | k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1A, k1B, k1C, k1D, k1E, \ | ||
| 180 | k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2A, k2B, k2C, k2D, k2E, \ | ||
| 181 | k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3A, k3B, k3C, k3D, k3E, \ | ||
| 182 | k40, k41, k42, k46, k4B, k4C, k4D, k4E \ | ||
| 183 | ) \ | ||
| 184 | { \ | ||
| 185 | { k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0A, k0B, k0C, k0D, k0E }, \ | ||
| 186 | { k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1A, k1B, k1C, k1D, k1E }, \ | ||
| 187 | { k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2A, k2B, k2C, k2D, k2E }, \ | ||
| 188 | { k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3A, k3B, k3C, k3D, k3E }, \ | ||
| 189 | { k40, k41, k42, KC_NO, KC_NO, KC_NO, k46, KC_NO, KC_NO, KC_NO, KC_NO, k4B, k4C, k4D, k4E }, \ | ||
| 190 | } | ||
| 191 | //ISO, splitBS, split space | ||
| 192 | #define LAYOUT_iso_splitbs_splitspace( \ | ||
| 193 | k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0A, k0B, k0C, k0D, k0E, \ | ||
| 194 | k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1A, k1B, k1C, k1D, k1E, \ | ||
| 195 | k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2A, k2B, k2C, k2D, k2E, \ | ||
| 196 | k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3A, k3B, k3C, k3D, k3E, \ | ||
| 197 | k40, k41, k42, k43, k46, k48, k4A, k4B, k4C, k4D, k4E \ | ||
| 198 | ) \ | ||
| 199 | { \ | ||
| 200 | { k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0A, k0B, k0C, k0D, k0E }, \ | ||
| 201 | { k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1A, k1B, k1C, k1D, k1E }, \ | ||
| 202 | { k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2A, k2B, k2C, k2D, k2E }, \ | ||
| 203 | { k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3A, k3B, k3C, k3D, k3E }, \ | ||
| 204 | { k40, k41, k42, k43, KC_NO, KC_NO, k46, KC_NO, k48, KC_NO, k4A, k4B, k4C, k4D, k4E }, \ | ||
| 205 | } | ||
| 206 | |||
| 207 | #endif | ||
diff --git a/keyboards/mxss/mxss_frontled.h b/keyboards/mxss/mxss_frontled.h new file mode 100644 index 000000000..1350266ba --- /dev/null +++ b/keyboards/mxss/mxss_frontled.h | |||
| @@ -0,0 +1,81 @@ | |||
| 1 | /* Copyright 2018 Jumail Mundekkat / MxBlue | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | // EEPROM management code taken from Wilba6582 | ||
| 18 | // https://github.com/Wilba6582/qmk_firmware/blob/zeal60/keyboards/zeal60/zeal_eeprom.h | ||
| 19 | |||
| 20 | #ifndef MXSS_FRONTLED_H | ||
| 21 | #define MXSS_FRONTLED_H | ||
| 22 | |||
| 23 | #include "quantum_keycodes.h" | ||
| 24 | |||
| 25 | // RGBLED index for front LEDs | ||
| 26 | #define RGBLIGHT_FLED1 14 | ||
| 27 | #define RGBLIGHT_FLED2 15 | ||
| 28 | |||
| 29 | // Brightness increase step for front LEDs | ||
| 30 | #define FLED_VAL_STEP 8 | ||
| 31 | |||
| 32 | // QMK never uses more then 32bytes of EEPROM, so our region starts there | ||
| 33 | // Magic value to verify the state of the EEPROM | ||
| 34 | #define EEPROM_MAGIC 0xC3E7 | ||
| 35 | #define EEPROM_MAGIC_ADDR ((void*)32) | ||
| 36 | |||
| 37 | // Front LED settings | ||
| 38 | #define EEPROM_FRONTLED_ADDR ((void*)34) | ||
| 39 | |||
| 40 | // Modes for front LEDs | ||
| 41 | #define FLED_OFF 0b00 | ||
| 42 | #define FLED_INDI 0b01 | ||
| 43 | #define FLED_RGB 0b10 | ||
| 44 | #define FLED_UNDEF 0b11 | ||
| 45 | |||
| 46 | // Hard-coded color for capslock indicator in FLED_INDI mode, H:0% S:100% = Red | ||
| 47 | #define FLED_CAPS_H 0 | ||
| 48 | #define FLED_CAPS_S 255 | ||
| 49 | |||
| 50 | // Config storage format for EEPROM | ||
| 51 | typedef union { | ||
| 52 | uint8_t raw; | ||
| 53 | struct { | ||
| 54 | uint8_t mode :2; | ||
| 55 | uint8_t val :6; | ||
| 56 | }; | ||
| 57 | } fled_config; | ||
| 58 | |||
| 59 | // Structure to store hue and saturation values | ||
| 60 | typedef struct _hs_set { | ||
| 61 | uint16_t hue; | ||
| 62 | uint8_t sat; | ||
| 63 | } hs_set; | ||
| 64 | |||
| 65 | // Custom keycodes for front LED control | ||
| 66 | enum fled_keycodes { | ||
| 67 | FLED_MOD = SAFE_RANGE, | ||
| 68 | FLED_VAI, | ||
| 69 | FLED_VAD, | ||
| 70 | NEW_SAFE_RANGE // define a new safe range | ||
| 71 | }; | ||
| 72 | |||
| 73 | bool eeprom_is_valid(void); // Check if EEPROM has been set up | ||
| 74 | void eeprom_set_valid(bool valid); // Change validity state of EEPROM | ||
| 75 | void eeprom_update_conf(void); // Store current front LED config to EEPROM | ||
| 76 | |||
| 77 | void fled_mode_cycle(void); // Cycle between the 3 modes for the front LEDs | ||
| 78 | void fled_val_increase(void); // Increase the brightness of the front LEDs | ||
| 79 | void fled_val_decrease(void); // Decrease the brightness of the front LEDs | ||
| 80 | |||
| 81 | #endif //MXSS_FRONTLED_H \ No newline at end of file | ||
diff --git a/keyboards/mxss/readme.md b/keyboards/mxss/readme.md new file mode 100644 index 000000000..54e07e27b --- /dev/null +++ b/keyboards/mxss/readme.md | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | # MxSS - Polycarb 65% Kit for MX/SMK | ||
| 2 | |||
| 3 |  | ||
| 4 | |||
| 5 | ### Information: | ||
| 6 | |||
| 7 | - Case: Frosted Polycarbonate, CNC milled | ||
| 8 | - Plate: Brass, mirror-finished and electroplated | ||
| 9 | - Weight: Same as plate | ||
| 10 | - PCB: Custom designed for the MxSS by kawasaki161, White solder mask and ENIG finish | ||
| 11 | |||
| 12 | ### Details: | ||
| 13 | |||
| 14 | - 2.9 degrees angle on the case | ||
| 15 | - Top mount plate | ||
| 16 | - Center USB, Type-B Mini | ||
| 17 | - MX and SMK (White and Orange) switch support | ||
| 18 | - Holtite support | ||
| 19 | - RGB underglow | ||
| 20 | - 1.5kg with plate and weight | ||
| 21 | |||
| 22 | Keyboard Maintainer: [MxBlue](https://github.com/mxblu) | ||
| 23 | |||
| 24 | Hardware Supported: Custom PCB, ATMega32u4 | ||
| 25 | |||
| 26 | Hardware Availability: https://geekhack.org/index.php?topic=94986.0 | ||
| 27 | |||
| 28 | Make example for this keyboard (after setting up your build environment): | ||
| 29 | |||
| 30 | make mxss:default | ||
| 31 | |||
| 32 | See [build environment setup](https://docs.qmk.fm/build_environment_setup.html) then the [make instructions](https://docs.qmk.fm/make_instructions.html) for more information. | ||
| 33 | |||
| 34 | # Front LED Operation | ||
| 35 | |||
| 36 | 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. | ||
| 37 | |||
| 38 | There are 3 modes of operation: | ||
| 39 | |||
| 40 | - FLED_OFF - Front LEDs stay off | ||
| 41 | - FLED_RGB - Front LEDs are part of the standard RGB LED modes, only works correctly with rainbow modes (will fix on request) | ||
| 42 | - FLED_INDI - Top front LED represents Caps Lock status, bottom LED represents current layer | ||
| 43 | |||
| 44 | 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). | ||
| 45 | |||
| 46 | ## Custom Keycodes | ||
| 47 | |||
| 48 | - FLED_MOD - Cycle between the 3 modes (FLED_OFF -> FLED_RGB -> FLED_INDI) | ||
| 49 | - FLED_VAI - Increase front LED brightness | ||
| 50 | - FLED_VAD - Decrease front LED brightness | ||
| 51 | |||
| 52 | # Further Notes | ||
| 53 | |||
| 54 | As SAFE_RANGE is used for defining the custom keycodes seen above, please use NEW_SAFE_RANGE as the starting value for any custom keycodes in keymap.c, as per the example. \ No newline at end of file | ||
diff --git a/keyboards/mxss/rgblight.c b/keyboards/mxss/rgblight.c new file mode 100644 index 000000000..f65d23c8c --- /dev/null +++ b/keyboards/mxss/rgblight.c | |||
| @@ -0,0 +1,804 @@ | |||
| 1 | /* Copyright 2016-2017 Yang Liu | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #include <math.h> | ||
| 17 | #include <avr/eeprom.h> | ||
| 18 | #include <avr/interrupt.h> | ||
| 19 | #include <util/delay.h> | ||
| 20 | #include "progmem.h" | ||
| 21 | #include "timer.h" | ||
| 22 | #include "rgblight.h" | ||
| 23 | #include "debug.h" | ||
| 24 | #include "led_tables.h" | ||
| 25 | #include "mxss_frontled.h" | ||
| 26 | |||
| 27 | #ifndef RGBLIGHT_LIMIT_VAL | ||
| 28 | #define RGBLIGHT_LIMIT_VAL 255 | ||
| 29 | #endif | ||
| 30 | |||
| 31 | #define MIN(a,b) (((a)<(b))?(a):(b)) | ||
| 32 | #define MAX(a,b) (((a)>(b))?(a):(b)) | ||
| 33 | |||
| 34 | #define LED_PTRTOIND(ptr) ((uint32_t) (ptr - led)/sizeof(LED_TYPE)) | ||
| 35 | |||
| 36 | void copyrgb(LED_TYPE *src, LED_TYPE *dst); | ||
| 37 | |||
| 38 | __attribute__ ((weak)) | ||
| 39 | const uint8_t RGBLED_BREATHING_INTERVALS[] PROGMEM = {30, 20, 10, 5}; | ||
| 40 | __attribute__ ((weak)) | ||
| 41 | const uint8_t RGBLED_RAINBOW_MOOD_INTERVALS[] PROGMEM = {120, 60, 30}; | ||
| 42 | __attribute__ ((weak)) | ||
| 43 | const uint8_t RGBLED_RAINBOW_SWIRL_INTERVALS[] PROGMEM = {100, 50, 20}; | ||
| 44 | __attribute__ ((weak)) | ||
| 45 | const uint8_t RGBLED_SNAKE_INTERVALS[] PROGMEM = {100, 50, 20}; | ||
| 46 | __attribute__ ((weak)) | ||
| 47 | const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {127, 63, 31}; | ||
| 48 | __attribute__ ((weak)) | ||
| 49 | const uint16_t RGBLED_GRADIENT_RANGES[] PROGMEM = {360, 240, 180, 120, 90}; | ||
| 50 | __attribute__ ((weak)) | ||
| 51 | const uint16_t RGBLED_RGBTEST_INTERVALS[] PROGMEM = {1024}; | ||
| 52 | |||
| 53 | rgblight_config_t rgblight_config; | ||
| 54 | |||
| 55 | LED_TYPE led[RGBLED_NUM]; | ||
| 56 | |||
| 57 | bool rgblight_timer_enabled = false; | ||
| 58 | |||
| 59 | extern uint8_t fled_mode; | ||
| 60 | extern uint8_t fled_val; | ||
| 61 | extern LED_TYPE fleds[2]; | ||
| 62 | hs_set fled_hs[2]; | ||
| 63 | |||
| 64 | void sethsv(uint16_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) { | ||
| 65 | uint8_t r = 0, g = 0, b = 0, base, color; | ||
| 66 | |||
| 67 | // if led is front leds, cache the hue and sat values | ||
| 68 | if (led1 == &led[RGBLIGHT_FLED1]) { | ||
| 69 | fled_hs[0].hue = hue; | ||
| 70 | fled_hs[0].sat = sat; | ||
| 71 | } else if (led1 == &led[RGBLIGHT_FLED2]) { | ||
| 72 | fled_hs[1].hue = hue; | ||
| 73 | fled_hs[1].sat = sat; | ||
| 74 | } | ||
| 75 | |||
| 76 | if (val > RGBLIGHT_LIMIT_VAL) { | ||
| 77 | val=RGBLIGHT_LIMIT_VAL; // limit the val | ||
| 78 | } | ||
| 79 | |||
| 80 | if (sat == 0) { // Acromatic color (gray). Hue doesn't mind. | ||
| 81 | r = val; | ||
| 82 | g = val; | ||
| 83 | b = val; | ||
| 84 | } else { | ||
| 85 | base = ((255 - sat) * val) >> 8; | ||
| 86 | color = (val - base) * (hue % 60) / 60; | ||
| 87 | |||
| 88 | switch (hue / 60) { | ||
| 89 | case 0: | ||
| 90 | r = val; | ||
| 91 | g = base + color; | ||
| 92 | b = base; | ||
| 93 | break; | ||
| 94 | case 1: | ||
| 95 | r = val - color; | ||
| 96 | g = val; | ||
| 97 | b = base; | ||
| 98 | break; | ||
| 99 | case 2: | ||
| 100 | r = base; | ||
| 101 | g = val; | ||
| 102 | b = base + color; | ||
| 103 | break; | ||
| 104 | case 3: | ||
| 105 | r = base; | ||
| 106 | g = val - color; | ||
| 107 | b = val; | ||
| 108 | break; | ||
| 109 | case 4: | ||
| 110 | r = base + color; | ||
| 111 | g = base; | ||
| 112 | b = val; | ||
| 113 | break; | ||
| 114 | case 5: | ||
| 115 | r = val; | ||
| 116 | g = base; | ||
| 117 | b = val - color; | ||
| 118 | break; | ||
| 119 | } | ||
| 120 | } | ||
| 121 | r = pgm_read_byte(&CIE1931_CURVE[r]); | ||
| 122 | g = pgm_read_byte(&CIE1931_CURVE[g]); | ||
| 123 | b = pgm_read_byte(&CIE1931_CURVE[b]); | ||
| 124 | |||
| 125 | setrgb(r, g, b, led1); | ||
| 126 | } | ||
| 127 | |||
| 128 | void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1) { | ||
| 129 | (*led1).r = r; | ||
| 130 | (*led1).g = g; | ||
| 131 | (*led1).b = b; | ||
| 132 | } | ||
| 133 | |||
| 134 | void copyrgb(LED_TYPE *src, LED_TYPE *dst) { | ||
| 135 | (*dst).r = (*src).r; | ||
| 136 | (*dst).g = (*src).g; | ||
| 137 | (*dst).b = (*src).b; | ||
| 138 | } | ||
| 139 | |||
| 140 | uint32_t eeconfig_read_rgblight(void) { | ||
| 141 | return eeprom_read_dword(EECONFIG_RGBLIGHT); | ||
| 142 | } | ||
| 143 | void eeconfig_update_rgblight(uint32_t val) { | ||
| 144 | eeprom_update_dword(EECONFIG_RGBLIGHT, val); | ||
| 145 | } | ||
| 146 | void eeconfig_update_rgblight_default(void) { | ||
| 147 | dprintf("eeconfig_update_rgblight_default\n"); | ||
| 148 | rgblight_config.enable = 1; | ||
| 149 | rgblight_config.mode = 1; | ||
| 150 | rgblight_config.hue = 0; | ||
| 151 | rgblight_config.sat = 255; | ||
| 152 | rgblight_config.val = RGBLIGHT_LIMIT_VAL; | ||
| 153 | rgblight_config.speed = 0; | ||
| 154 | eeconfig_update_rgblight(rgblight_config.raw); | ||
| 155 | } | ||
| 156 | void eeconfig_debug_rgblight(void) { | ||
| 157 | dprintf("rgblight_config eprom\n"); | ||
| 158 | dprintf("rgblight_config.enable = %d\n", rgblight_config.enable); | ||
| 159 | dprintf("rghlight_config.mode = %d\n", rgblight_config.mode); | ||
| 160 | dprintf("rgblight_config.hue = %d\n", rgblight_config.hue); | ||
| 161 | dprintf("rgblight_config.sat = %d\n", rgblight_config.sat); | ||
| 162 | dprintf("rgblight_config.val = %d\n", rgblight_config.val); | ||
| 163 | dprintf("rgblight_config.speed = %d\n", rgblight_config.speed); | ||
| 164 | } | ||
| 165 | |||
| 166 | void rgblight_init(void) { | ||
| 167 | debug_enable = 1; // Debug ON! | ||
| 168 | dprintf("rgblight_init called.\n"); | ||
| 169 | dprintf("rgblight_init start!\n"); | ||
| 170 | if (!eeconfig_is_enabled()) { | ||
| 171 | dprintf("rgblight_init eeconfig is not enabled.\n"); | ||
| 172 | eeconfig_init(); | ||
| 173 | eeconfig_update_rgblight_default(); | ||
| 174 | } | ||
| 175 | rgblight_config.raw = eeconfig_read_rgblight(); | ||
| 176 | if (!rgblight_config.mode) { | ||
| 177 | dprintf("rgblight_init rgblight_config.mode = 0. Write default values to EEPROM.\n"); | ||
| 178 | eeconfig_update_rgblight_default(); | ||
| 179 | rgblight_config.raw = eeconfig_read_rgblight(); | ||
| 180 | } | ||
| 181 | eeconfig_debug_rgblight(); // display current eeprom values | ||
| 182 | |||
| 183 | #ifdef RGBLIGHT_ANIMATIONS | ||
| 184 | rgblight_timer_init(); // setup the timer | ||
| 185 | #endif | ||
| 186 | |||
| 187 | if (rgblight_config.enable) { | ||
| 188 | rgblight_mode_noeeprom(rgblight_config.mode); | ||
| 189 | } | ||
| 190 | } | ||
| 191 | |||
| 192 | void rgblight_update_dword(uint32_t dword) { | ||
| 193 | rgblight_config.raw = dword; | ||
| 194 | eeconfig_update_rgblight(rgblight_config.raw); | ||
| 195 | if (rgblight_config.enable) | ||
| 196 | rgblight_mode(rgblight_config.mode); | ||
| 197 | else { | ||
| 198 | #ifdef RGBLIGHT_ANIMATIONS | ||
| 199 | rgblight_timer_disable(); | ||
| 200 | #endif | ||
| 201 | rgblight_set(); | ||
| 202 | } | ||
| 203 | } | ||
| 204 | |||
| 205 | void rgblight_increase(void) { | ||
| 206 | uint8_t mode = 0; | ||
| 207 | if (rgblight_config.mode < RGBLIGHT_MODES) { | ||
| 208 | mode = rgblight_config.mode + 1; | ||
| 209 | } | ||
| 210 | rgblight_mode(mode); | ||
| 211 | } | ||
| 212 | void rgblight_decrease(void) { | ||
| 213 | uint8_t mode = 0; | ||
| 214 | // Mode will never be < 1. If it ever is, eeprom needs to be initialized. | ||
| 215 | if (rgblight_config.mode > 1) { | ||
| 216 | mode = rgblight_config.mode - 1; | ||
| 217 | } | ||
| 218 | rgblight_mode(mode); | ||
| 219 | } | ||
| 220 | void rgblight_step(void) { | ||
| 221 | uint8_t mode = 0; | ||
| 222 | mode = rgblight_config.mode + 1; | ||
| 223 | if (mode > RGBLIGHT_MODES) { | ||
| 224 | mode = 1; | ||
| 225 | } | ||
| 226 | rgblight_mode(mode); | ||
| 227 | } | ||
| 228 | void rgblight_step_reverse(void) { | ||
| 229 | uint8_t mode = 0; | ||
| 230 | mode = rgblight_config.mode - 1; | ||
| 231 | if (mode < 1) { | ||
| 232 | mode = RGBLIGHT_MODES; | ||
| 233 | } | ||
| 234 | rgblight_mode(mode); | ||
| 235 | } | ||
| 236 | |||
| 237 | uint32_t rgblight_get_mode(void) { | ||
| 238 | if (!rgblight_config.enable) { | ||
| 239 | return false; | ||
| 240 | } | ||
| 241 | |||
| 242 | return rgblight_config.mode; | ||
| 243 | } | ||
| 244 | |||
| 245 | void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) { | ||
| 246 | if (!rgblight_config.enable) { | ||
| 247 | return; | ||
| 248 | } | ||
| 249 | if (mode < 1) { | ||
| 250 | rgblight_config.mode = 1; | ||
| 251 | } else if (mode > RGBLIGHT_MODES) { | ||
| 252 | rgblight_config.mode = RGBLIGHT_MODES; | ||
| 253 | } else { | ||
| 254 | rgblight_config.mode = mode; | ||
| 255 | } | ||
| 256 | if (write_to_eeprom) { | ||
| 257 | eeconfig_update_rgblight(rgblight_config.raw); | ||
| 258 | xprintf("rgblight mode [EEPROM]: %u\n", rgblight_config.mode); | ||
| 259 | } else { | ||
| 260 | xprintf("rgblight mode [NOEEPROM]: %u\n", rgblight_config.mode); | ||
| 261 | } | ||
| 262 | if (rgblight_config.mode == 1) { | ||
| 263 | #ifdef RGBLIGHT_ANIMATIONS | ||
| 264 | rgblight_timer_disable(); | ||
| 265 | #endif | ||
| 266 | } else if ((rgblight_config.mode >= 2 && rgblight_config.mode <= 24) || | ||
| 267 | rgblight_config.mode == 35 ) { | ||
| 268 | // MODE 2-5, breathing | ||
| 269 | // MODE 6-8, rainbow mood | ||
| 270 | // MODE 9-14, rainbow swirl | ||
| 271 | // MODE 15-20, snake | ||
| 272 | // MODE 21-23, knight | ||
| 273 | // MODE 24, xmas | ||
| 274 | // MODE 35 RGB test | ||
| 275 | |||
| 276 | #ifdef RGBLIGHT_ANIMATIONS | ||
| 277 | rgblight_timer_enable(); | ||
| 278 | #endif | ||
| 279 | } else if (rgblight_config.mode >= 25 && rgblight_config.mode <= 34) { | ||
| 280 | // MODE 25-34, static gradient | ||
| 281 | |||
| 282 | #ifdef RGBLIGHT_ANIMATIONS | ||
| 283 | rgblight_timer_disable(); | ||
| 284 | #endif | ||
| 285 | } | ||
| 286 | rgblight_sethsv_noeeprom(rgblight_config.hue, rgblight_config.sat, rgblight_config.val); | ||
| 287 | } | ||
| 288 | |||
| 289 | void rgblight_mode(uint8_t mode) { | ||
| 290 | rgblight_mode_eeprom_helper(mode, true); | ||
| 291 | } | ||
| 292 | |||
| 293 | void rgblight_mode_noeeprom(uint8_t mode) { | ||
| 294 | rgblight_mode_eeprom_helper(mode, false); | ||
| 295 | } | ||
| 296 | |||
| 297 | |||
| 298 | void rgblight_toggle(void) { | ||
| 299 | xprintf("rgblight toggle [EEPROM]: rgblight_config.enable = %u\n", !rgblight_config.enable); | ||
| 300 | if (rgblight_config.enable) { | ||
| 301 | rgblight_disable(); | ||
| 302 | } | ||
| 303 | else { | ||
| 304 | rgblight_enable(); | ||
| 305 | } | ||
| 306 | } | ||
| 307 | |||
| 308 | void rgblight_toggle_noeeprom(void) { | ||
| 309 | xprintf("rgblight toggle [NOEEPROM]: rgblight_config.enable = %u\n", !rgblight_config.enable); | ||
| 310 | if (rgblight_config.enable) { | ||
| 311 | rgblight_disable_noeeprom(); | ||
| 312 | } | ||
| 313 | else { | ||
| 314 | rgblight_enable_noeeprom(); | ||
| 315 | } | ||
| 316 | } | ||
| 317 | |||
| 318 | void rgblight_enable(void) { | ||
| 319 | rgblight_config.enable = 1; | ||
| 320 | // No need to update EEPROM here. rgblight_mode() will do that, actually | ||
| 321 | //eeconfig_update_rgblight(rgblight_config.raw); | ||
| 322 | xprintf("rgblight enable [EEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable); | ||
| 323 | rgblight_mode(rgblight_config.mode); | ||
| 324 | } | ||
| 325 | |||
| 326 | void rgblight_enable_noeeprom(void) { | ||
| 327 | rgblight_config.enable = 1; | ||
| 328 | xprintf("rgblight enable [NOEEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable); | ||
| 329 | rgblight_mode_noeeprom(rgblight_config.mode); | ||
| 330 | } | ||
| 331 | |||
| 332 | void rgblight_disable(void) { | ||
| 333 | rgblight_config.enable = 0; | ||
| 334 | eeconfig_update_rgblight(rgblight_config.raw); | ||
| 335 | xprintf("rgblight disable [EEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable); | ||
| 336 | #ifdef RGBLIGHT_ANIMATIONS | ||
| 337 | //rgblight_timer_disable(); | ||
| 338 | #endif | ||
| 339 | _delay_ms(50); | ||
| 340 | rgblight_set(); | ||
| 341 | } | ||
| 342 | |||
| 343 | void rgblight_disable_noeeprom(void) { | ||
| 344 | rgblight_config.enable = 0; | ||
| 345 | xprintf("rgblight disable [noEEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable); | ||
| 346 | #ifdef RGBLIGHT_ANIMATIONS | ||
| 347 | rgblight_timer_disable(); | ||
| 348 | #endif | ||
| 349 | _delay_ms(50); | ||
| 350 | rgblight_set(); | ||
| 351 | } | ||
| 352 | |||
| 353 | |||
| 354 | // Deals with the messy details of incrementing an integer | ||
| 355 | uint8_t increment( uint8_t value, uint8_t step, uint8_t min, uint8_t max ) { | ||
| 356 | int16_t new_value = value; | ||
| 357 | new_value += step; | ||
| 358 | return MIN( MAX( new_value, min ), max ); | ||
| 359 | } | ||
| 360 | |||
| 361 | uint8_t decrement( uint8_t value, uint8_t step, uint8_t min, uint8_t max ) { | ||
| 362 | int16_t new_value = value; | ||
| 363 | new_value -= step; | ||
| 364 | return MIN( MAX( new_value, min ), max ); | ||
| 365 | } | ||
| 366 | |||
| 367 | void rgblight_increase_hue(void) { | ||
| 368 | uint16_t hue; | ||
| 369 | hue = (rgblight_config.hue+RGBLIGHT_HUE_STEP) % 360; | ||
| 370 | rgblight_sethsv(hue, rgblight_config.sat, rgblight_config.val); | ||
| 371 | } | ||
| 372 | void rgblight_decrease_hue(void) { | ||
| 373 | uint16_t hue; | ||
| 374 | if (rgblight_config.hue-RGBLIGHT_HUE_STEP < 0) { | ||
| 375 | hue = (rgblight_config.hue + 360 - RGBLIGHT_HUE_STEP) % 360; | ||
| 376 | } else { | ||
| 377 | hue = (rgblight_config.hue - RGBLIGHT_HUE_STEP) % 360; | ||
| 378 | } | ||
| 379 | rgblight_sethsv(hue, rgblight_config.sat, rgblight_config.val); | ||
| 380 | } | ||
| 381 | void rgblight_increase_sat(void) { | ||
| 382 | uint8_t sat; | ||
| 383 | if (rgblight_config.sat + RGBLIGHT_SAT_STEP > 255) { | ||
| 384 | sat = 255; | ||
| 385 | } else { | ||
| 386 | sat = rgblight_config.sat + RGBLIGHT_SAT_STEP; | ||
| 387 | } | ||
| 388 | rgblight_sethsv(rgblight_config.hue, sat, rgblight_config.val); | ||
| 389 | } | ||
| 390 | void rgblight_decrease_sat(void) { | ||
| 391 | uint8_t sat; | ||
| 392 | if (rgblight_config.sat - RGBLIGHT_SAT_STEP < 0) { | ||
| 393 | sat = 0; | ||
| 394 | } else { | ||
| 395 | sat = rgblight_config.sat - RGBLIGHT_SAT_STEP; | ||
| 396 | } | ||
| 397 | rgblight_sethsv(rgblight_config.hue, sat, rgblight_config.val); | ||
| 398 | } | ||
| 399 | void rgblight_increase_val(void) { | ||
| 400 | uint8_t val; | ||
| 401 | if (rgblight_config.val + RGBLIGHT_VAL_STEP > RGBLIGHT_LIMIT_VAL) { | ||
| 402 | val = RGBLIGHT_LIMIT_VAL; | ||
| 403 | } else { | ||
| 404 | val = rgblight_config.val + RGBLIGHT_VAL_STEP; | ||
| 405 | } | ||
| 406 | rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, val); | ||
| 407 | } | ||
| 408 | void rgblight_decrease_val(void) { | ||
| 409 | uint8_t val; | ||
| 410 | if (rgblight_config.val - RGBLIGHT_VAL_STEP < 0) { | ||
| 411 | val = 0; | ||
| 412 | } else { | ||
| 413 | val = rgblight_config.val - RGBLIGHT_VAL_STEP; | ||
| 414 | } | ||
| 415 | rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, val); | ||
| 416 | } | ||
| 417 | void rgblight_increase_speed(void) { | ||
| 418 | rgblight_config.speed = increment( rgblight_config.speed, 1, 0, 3 ); | ||
| 419 | eeconfig_update_rgblight(rgblight_config.raw);//EECONFIG needs to be increased to support this | ||
| 420 | } | ||
| 421 | |||
| 422 | void rgblight_decrease_speed(void) { | ||
| 423 | rgblight_config.speed = decrement( rgblight_config.speed, 1, 0, 3 ); | ||
| 424 | eeconfig_update_rgblight(rgblight_config.raw);//EECONFIG needs to be increased to support this | ||
| 425 | } | ||
| 426 | |||
| 427 | void rgblight_sethsv_noeeprom_old(uint16_t hue, uint8_t sat, uint8_t val) { | ||
| 428 | if (rgblight_config.enable) { | ||
| 429 | LED_TYPE tmp_led; | ||
| 430 | sethsv(hue, sat, val, &tmp_led); | ||
| 431 | // dprintf("rgblight set hue [MEMORY]: %u,%u,%u\n", inmem_config.hue, inmem_config.sat, inmem_config.val); | ||
| 432 | rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b); | ||
| 433 | } | ||
| 434 | } | ||
| 435 | |||
| 436 | void rgblight_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom) { | ||
| 437 | if (rgblight_config.enable) { | ||
| 438 | if (rgblight_config.mode == 1) { | ||
| 439 | // same static color | ||
| 440 | LED_TYPE tmp_led; | ||
| 441 | sethsv(hue, sat, val, &tmp_led); | ||
| 442 | rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b); | ||
| 443 | } else { | ||
| 444 | // all LEDs in same color | ||
| 445 | if (rgblight_config.mode >= 2 && rgblight_config.mode <= 5) { | ||
| 446 | // breathing mode, ignore the change of val, use in memory value instead | ||
| 447 | val = rgblight_config.val; | ||
| 448 | } else if (rgblight_config.mode >= 6 && rgblight_config.mode <= 14) { | ||
| 449 | // rainbow mood and rainbow swirl, ignore the change of hue | ||
| 450 | hue = rgblight_config.hue; | ||
| 451 | } else if (rgblight_config.mode >= 25 && rgblight_config.mode <= 34) { | ||
| 452 | // static gradient | ||
| 453 | uint16_t _hue; | ||
| 454 | int8_t direction = ((rgblight_config.mode - 25) % 2) ? -1 : 1; | ||
| 455 | uint16_t range = pgm_read_word(&RGBLED_GRADIENT_RANGES[(rgblight_config.mode - 25) / 2]); | ||
| 456 | for (uint8_t i = 0; i < RGBLED_NUM; i++) { | ||
| 457 | _hue = (range / RGBLED_NUM * i * direction + hue + 360) % 360; | ||
| 458 | dprintf("rgblight rainbow set hsv: %u,%u,%d,%u\n", i, _hue, direction, range); | ||
| 459 | sethsv(_hue, sat, val, (LED_TYPE *)&led[i]); | ||
| 460 | } | ||
| 461 | rgblight_set(); | ||
| 462 | } | ||
| 463 | } | ||
| 464 | rgblight_config.hue = hue; | ||
| 465 | rgblight_config.sat = sat; | ||
| 466 | rgblight_config.val = val; | ||
| 467 | if (write_to_eeprom) { | ||
| 468 | eeconfig_update_rgblight(rgblight_config.raw); | ||
| 469 | xprintf("rgblight set hsv [EEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val); | ||
| 470 | } else { | ||
| 471 | xprintf("rgblight set hsv [NOEEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val); | ||
| 472 | } | ||
| 473 | } | ||
| 474 | } | ||
| 475 | |||
| 476 | void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val) { | ||
| 477 | rgblight_sethsv_eeprom_helper(hue, sat, val, true); | ||
| 478 | } | ||
| 479 | |||
| 480 | void rgblight_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) { | ||
| 481 | rgblight_sethsv_eeprom_helper(hue, sat, val, false); | ||
| 482 | } | ||
| 483 | |||
| 484 | uint16_t rgblight_get_hue(void) { | ||
| 485 | return rgblight_config.hue; | ||
| 486 | } | ||
| 487 | |||
| 488 | uint8_t rgblight_get_sat(void) { | ||
| 489 | return rgblight_config.sat; | ||
| 490 | } | ||
| 491 | |||
| 492 | uint8_t rgblight_get_val(void) { | ||
| 493 | return rgblight_config.val; | ||
| 494 | } | ||
| 495 | |||
| 496 | void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b) { | ||
| 497 | if (!rgblight_config.enable) { return; } | ||
| 498 | |||
| 499 | for (uint8_t i = 0; i < RGBLED_NUM; i++) { | ||
| 500 | led[i].r = r; | ||
| 501 | led[i].g = g; | ||
| 502 | led[i].b = b; | ||
| 503 | } | ||
| 504 | rgblight_set(); | ||
| 505 | } | ||
| 506 | |||
| 507 | void rgblight_setrgb_at(uint8_t r, uint8_t g, uint8_t b, uint8_t index) { | ||
| 508 | if (!rgblight_config.enable || index >= RGBLED_NUM) { return; } | ||
| 509 | |||
| 510 | led[index].r = r; | ||
| 511 | led[index].g = g; | ||
| 512 | led[index].b = b; | ||
| 513 | rgblight_set(); | ||
| 514 | } | ||
| 515 | |||
| 516 | void rgblight_sethsv_at(uint16_t hue, uint8_t sat, uint8_t val, uint8_t index) { | ||
| 517 | if (!rgblight_config.enable) { return; } | ||
| 518 | |||
| 519 | LED_TYPE tmp_led; | ||
| 520 | sethsv(hue, sat, val, &tmp_led); | ||
| 521 | rgblight_setrgb_at(tmp_led.r, tmp_led.g, tmp_led.b, index); | ||
| 522 | } | ||
| 523 | |||
| 524 | void rgblight_set(void) { | ||
| 525 | if (!rgblight_config.enable) { | ||
| 526 | for (uint8_t i = 0; i < RGBLED_NUM; i++) { | ||
| 527 | if (i == RGBLIGHT_FLED1 && i == RGBLIGHT_FLED2) | ||
| 528 | continue; | ||
| 529 | |||
| 530 | led[i].r = 0; | ||
| 531 | led[i].g = 0; | ||
| 532 | led[i].b = 0; | ||
| 533 | } | ||
| 534 | } | ||
| 535 | |||
| 536 | switch (fled_mode) { | ||
| 537 | case FLED_OFF: | ||
| 538 | setrgb(0, 0, 0, &led[RGBLIGHT_FLED1]); | ||
| 539 | setrgb(0, 0, 0, &led[RGBLIGHT_FLED2]); | ||
| 540 | break; | ||
| 541 | |||
| 542 | case FLED_INDI: | ||
| 543 | copyrgb(&fleds[0], &led[RGBLIGHT_FLED1]); | ||
| 544 | copyrgb(&fleds[1], &led[RGBLIGHT_FLED2]); | ||
| 545 | break; | ||
| 546 | |||
| 547 | case FLED_RGB: | ||
| 548 | sethsv(fled_hs[0].hue, fled_hs[0].sat, fled_val, &led[RGBLIGHT_FLED1]); | ||
| 549 | sethsv(fled_hs[1].hue, fled_hs[1].sat, fled_val, &led[RGBLIGHT_FLED2]); | ||
| 550 | break; | ||
| 551 | |||
| 552 | default: | ||
| 553 | break; | ||
| 554 | } | ||
| 555 | |||
| 556 | ws2812_setleds(led, RGBLED_NUM); | ||
| 557 | } | ||
| 558 | |||
| 559 | #ifdef RGBLIGHT_ANIMATIONS | ||
| 560 | |||
| 561 | // Animation timer -- AVR Timer3 | ||
| 562 | void rgblight_timer_init(void) { | ||
| 563 | // static uint8_t rgblight_timer_is_init = 0; | ||
| 564 | // if (rgblight_timer_is_init) { | ||
| 565 | // return; | ||
| 566 | // } | ||
| 567 | // rgblight_timer_is_init = 1; | ||
| 568 | // /* Timer 3 setup */ | ||
| 569 | // TCCR3B = _BV(WGM32) // CTC mode OCR3A as TOP | ||
| 570 | // | _BV(CS30); // Clock selelct: clk/1 | ||
| 571 | // /* Set TOP value */ | ||
| 572 | // uint8_t sreg = SREG; | ||
| 573 | // cli(); | ||
| 574 | // OCR3AH = (RGBLED_TIMER_TOP >> 8) & 0xff; | ||
| 575 | // OCR3AL = RGBLED_TIMER_TOP & 0xff; | ||
| 576 | // SREG = sreg; | ||
| 577 | |||
| 578 | rgblight_timer_enabled = true; | ||
| 579 | } | ||
| 580 | void rgblight_timer_enable(void) { | ||
| 581 | rgblight_timer_enabled = true; | ||
| 582 | dprintf("TIMER3 enabled.\n"); | ||
| 583 | } | ||
| 584 | void rgblight_timer_disable(void) { | ||
| 585 | rgblight_timer_enabled = false; | ||
| 586 | dprintf("TIMER3 disabled.\n"); | ||
| 587 | } | ||
| 588 | void rgblight_timer_toggle(void) { | ||
| 589 | rgblight_timer_enabled ^= rgblight_timer_enabled; | ||
| 590 | dprintf("TIMER3 toggled.\n"); | ||
| 591 | } | ||
| 592 | |||
| 593 | void rgblight_show_solid_color(uint8_t r, uint8_t g, uint8_t b) { | ||
| 594 | rgblight_enable(); | ||
| 595 | rgblight_mode(1); | ||
| 596 | rgblight_setrgb(r, g, b); | ||
| 597 | } | ||
| 598 | |||
| 599 | void rgblight_task(void) { | ||
| 600 | if (rgblight_timer_enabled) { | ||
| 601 | // mode = 1, static light, do nothing here | ||
| 602 | if (rgblight_config.mode >= 2 && rgblight_config.mode <= 5) { | ||
| 603 | // mode = 2 to 5, breathing mode | ||
| 604 | rgblight_effect_breathing(rgblight_config.mode - 2); | ||
| 605 | } else if (rgblight_config.mode >= 6 && rgblight_config.mode <= 8) { | ||
| 606 | // mode = 6 to 8, rainbow mood mod | ||
| 607 | rgblight_effect_rainbow_mood(rgblight_config.mode - 6); | ||
| 608 | } else if (rgblight_config.mode >= 9 && rgblight_config.mode <= 14) { | ||
| 609 | // mode = 9 to 14, rainbow swirl mode | ||
| 610 | rgblight_effect_rainbow_swirl(rgblight_config.mode - 9); | ||
| 611 | } else if (rgblight_config.mode >= 15 && rgblight_config.mode <= 20) { | ||
| 612 | // mode = 15 to 20, snake mode | ||
| 613 | rgblight_effect_snake(rgblight_config.mode - 15); | ||
| 614 | } else if (rgblight_config.mode >= 21 && rgblight_config.mode <= 23) { | ||
| 615 | // mode = 21 to 23, knight mode | ||
| 616 | rgblight_effect_knight(rgblight_config.mode - 21); | ||
| 617 | } else if (rgblight_config.mode == 24) { | ||
| 618 | // mode = 24, christmas mode | ||
| 619 | rgblight_effect_christmas(); | ||
| 620 | } else if (rgblight_config.mode == 35) { | ||
| 621 | // mode = 35, RGB test | ||
| 622 | rgblight_effect_rgbtest(); | ||
| 623 | } | ||
| 624 | } | ||
| 625 | } | ||
| 626 | |||
| 627 | // Effects | ||
| 628 | void rgblight_effect_breathing(uint8_t interval) { | ||
| 629 | static uint8_t pos = 0; | ||
| 630 | static uint16_t last_timer = 0; | ||
| 631 | float val; | ||
| 632 | |||
| 633 | if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_BREATHING_INTERVALS[interval])) { | ||
| 634 | return; | ||
| 635 | } | ||
| 636 | last_timer = timer_read(); | ||
| 637 | |||
| 638 | |||
| 639 | // http://sean.voisen.org/blog/2011/10/breathing-led-with-arduino/ | ||
| 640 | val = (exp(sin((pos/255.0)*M_PI)) - RGBLIGHT_EFFECT_BREATHE_CENTER/M_E)*(RGBLIGHT_EFFECT_BREATHE_MAX/(M_E-1/M_E)); | ||
| 641 | rgblight_sethsv_noeeprom_old(rgblight_config.hue, rgblight_config.sat, val); | ||
| 642 | pos = (pos + 1) % 256; | ||
| 643 | } | ||
| 644 | void rgblight_effect_rainbow_mood(uint8_t interval) { | ||
| 645 | static uint16_t current_hue = 0; | ||
| 646 | static uint16_t last_timer = 0; | ||
| 647 | |||
| 648 | if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_RAINBOW_MOOD_INTERVALS[interval])) { | ||
| 649 | return; | ||
| 650 | } | ||
| 651 | last_timer = timer_read(); | ||
| 652 | rgblight_sethsv_noeeprom_old(current_hue, rgblight_config.sat, rgblight_config.val); | ||
| 653 | current_hue = (current_hue + 1) % 360; | ||
| 654 | } | ||
| 655 | void rgblight_effect_rainbow_swirl(uint8_t interval) { | ||
| 656 | static uint16_t current_hue = 0; | ||
| 657 | static uint16_t last_timer = 0; | ||
| 658 | uint16_t hue; | ||
| 659 | uint8_t i; | ||
| 660 | if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_RAINBOW_SWIRL_INTERVALS[interval / 2])) { | ||
| 661 | return; | ||
| 662 | } | ||
| 663 | last_timer = timer_read(); | ||
| 664 | for (i = 0; i < RGBLED_NUM; i++) { | ||
| 665 | hue = (360 / RGBLED_NUM * i + current_hue) % 360; | ||
| 666 | sethsv(hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i]); | ||
| 667 | } | ||
| 668 | rgblight_set(); | ||
| 669 | |||
| 670 | if (interval % 2) { | ||
| 671 | current_hue = (current_hue + 1) % 360; | ||
| 672 | } else { | ||
| 673 | if (current_hue - 1 < 0) { | ||
| 674 | current_hue = 359; | ||
| 675 | } else { | ||
| 676 | current_hue = current_hue - 1; | ||
| 677 | } | ||
| 678 | } | ||
| 679 | } | ||
| 680 | void rgblight_effect_snake(uint8_t interval) { | ||
| 681 | static uint8_t pos = 0; | ||
| 682 | static uint16_t last_timer = 0; | ||
| 683 | uint8_t i, j; | ||
| 684 | int8_t k; | ||
| 685 | int8_t increment = 1; | ||
| 686 | if (interval % 2) { | ||
| 687 | increment = -1; | ||
| 688 | } | ||
| 689 | if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_SNAKE_INTERVALS[interval / 2])) { | ||
| 690 | return; | ||
| 691 | } | ||
| 692 | last_timer = timer_read(); | ||
| 693 | for (i = 0; i < RGBLED_NUM; i++) { | ||
| 694 | led[i].r = 0; | ||
| 695 | led[i].g = 0; | ||
| 696 | led[i].b = 0; | ||
| 697 | for (j = 0; j < RGBLIGHT_EFFECT_SNAKE_LENGTH; j++) { | ||
| 698 | k = pos + j * increment; | ||
| 699 | if (k < 0) { | ||
| 700 | k = k + RGBLED_NUM; | ||
| 701 | } | ||
| 702 | if (i == k) { | ||
| 703 | sethsv(rgblight_config.hue, rgblight_config.sat, (uint8_t)(rgblight_config.val*(RGBLIGHT_EFFECT_SNAKE_LENGTH-j)/RGBLIGHT_EFFECT_SNAKE_LENGTH), (LED_TYPE *)&led[i]); | ||
| 704 | } | ||
| 705 | } | ||
| 706 | } | ||
| 707 | rgblight_set(); | ||
| 708 | if (increment == 1) { | ||
| 709 | if (pos - 1 < 0) { | ||
| 710 | pos = RGBLED_NUM - 1; | ||
| 711 | } else { | ||
| 712 | pos -= 1; | ||
| 713 | } | ||
| 714 | } else { | ||
| 715 | pos = (pos + 1) % RGBLED_NUM; | ||
| 716 | } | ||
| 717 | } | ||
| 718 | void rgblight_effect_knight(uint8_t interval) { | ||
| 719 | static uint16_t last_timer = 0; | ||
| 720 | if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_KNIGHT_INTERVALS[interval])) { | ||
| 721 | return; | ||
| 722 | } | ||
| 723 | last_timer = timer_read(); | ||
| 724 | |||
| 725 | static int8_t low_bound = 0; | ||
| 726 | static int8_t high_bound = RGBLIGHT_EFFECT_KNIGHT_LENGTH - 1; | ||
| 727 | static int8_t increment = 1; | ||
| 728 | uint8_t i, cur; | ||
| 729 | |||
| 730 | // Set all the LEDs to 0 | ||
| 731 | for (i = 0; i < RGBLED_NUM; i++) { | ||
| 732 | led[i].r = 0; | ||
| 733 | led[i].g = 0; | ||
| 734 | led[i].b = 0; | ||
| 735 | } | ||
| 736 | // Determine which LEDs should be lit up | ||
| 737 | for (i = 0; i < RGBLIGHT_EFFECT_KNIGHT_LED_NUM; i++) { | ||
| 738 | cur = (i + RGBLIGHT_EFFECT_KNIGHT_OFFSET) % RGBLED_NUM; | ||
| 739 | |||
| 740 | if (i >= low_bound && i <= high_bound) { | ||
| 741 | sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[cur]); | ||
| 742 | } else { | ||
| 743 | led[cur].r = 0; | ||
| 744 | led[cur].g = 0; | ||
| 745 | led[cur].b = 0; | ||
| 746 | } | ||
| 747 | } | ||
| 748 | rgblight_set(); | ||
| 749 | |||
| 750 | // Move from low_bound to high_bound changing the direction we increment each | ||
| 751 | // time a boundary is hit. | ||
| 752 | low_bound += increment; | ||
| 753 | high_bound += increment; | ||
| 754 | |||
| 755 | if (high_bound <= 0 || low_bound >= RGBLIGHT_EFFECT_KNIGHT_LED_NUM - 1) { | ||
| 756 | increment = -increment; | ||
| 757 | } | ||
| 758 | } | ||
| 759 | |||
| 760 | |||
| 761 | void rgblight_effect_christmas(void) { | ||
| 762 | static uint16_t current_offset = 0; | ||
| 763 | static uint16_t last_timer = 0; | ||
| 764 | uint16_t hue; | ||
| 765 | uint8_t i; | ||
| 766 | if (timer_elapsed(last_timer) < RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL) { | ||
| 767 | return; | ||
| 768 | } | ||
| 769 | last_timer = timer_read(); | ||
| 770 | current_offset = (current_offset + 1) % 2; | ||
| 771 | for (i = 0; i < RGBLED_NUM; i++) { | ||
| 772 | hue = 0 + ((i/RGBLIGHT_EFFECT_CHRISTMAS_STEP + current_offset) % 2) * 120; | ||
| 773 | sethsv(hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i]); | ||
| 774 | } | ||
| 775 | rgblight_set(); | ||
| 776 | } | ||
| 777 | |||
| 778 | void rgblight_effect_rgbtest(void) { | ||
| 779 | static uint8_t pos = 0; | ||
| 780 | static uint16_t last_timer = 0; | ||
| 781 | static uint8_t maxval = 0; | ||
| 782 | uint8_t g; uint8_t r; uint8_t b; | ||
| 783 | |||
| 784 | if (timer_elapsed(last_timer) < pgm_read_word(&RGBLED_RGBTEST_INTERVALS[0])) { | ||
| 785 | return; | ||
| 786 | } | ||
| 787 | |||
| 788 | if( maxval == 0 ) { | ||
| 789 | LED_TYPE tmp_led; | ||
| 790 | sethsv(0, 255, RGBLIGHT_LIMIT_VAL, &tmp_led); | ||
| 791 | maxval = tmp_led.r; | ||
| 792 | } | ||
| 793 | last_timer = timer_read(); | ||
| 794 | g = r = b = 0; | ||
| 795 | switch( pos ) { | ||
| 796 | case 0: r = maxval; break; | ||
| 797 | case 1: g = maxval; break; | ||
| 798 | case 2: b = maxval; break; | ||
| 799 | } | ||
| 800 | rgblight_setrgb(r, g, b); | ||
| 801 | pos = (pos + 1) % 3; | ||
| 802 | } | ||
| 803 | |||
| 804 | #endif /* RGBLIGHT_ANIMATIONS */ | ||
diff --git a/keyboards/mxss/rules.mk b/keyboards/mxss/rules.mk new file mode 100644 index 000000000..f46ae6374 --- /dev/null +++ b/keyboards/mxss/rules.mk | |||
| @@ -0,0 +1,75 @@ | |||
| 1 | # MCU name | ||
| 2 | #MCU = at90usb1286 | ||
| 3 | MCU = atmega32u4 | ||
| 4 | |||
| 5 | # Processor frequency. | ||
| 6 | # This will define a symbol, F_CPU, in all source code files equal to the | ||
| 7 | # processor frequency in Hz. You can then use this symbol in your source code to | ||
| 8 | # calculate timings. Do NOT tack on a 'UL' at the end, this will be done | ||
| 9 | # automatically to create a 32-bit value in your source code. | ||
| 10 | # | ||
| 11 | # This will be an integer division of F_USB below, as it is sourced by | ||
| 12 | # F_USB after it has run through any CPU prescalers. Note that this value | ||
| 13 | # does not *change* the processor frequency - it should merely be updated to | ||
| 14 | # reflect the processor speed set externally so that the code can use accurate | ||
| 15 | # software delays. | ||
| 16 | F_CPU = 16000000 | ||
| 17 | |||
| 18 | |||
| 19 | # | ||
| 20 | # LUFA specific | ||
| 21 | # | ||
| 22 | # Target architecture (see library "Board Types" documentation). | ||
| 23 | ARCH = AVR8 | ||
| 24 | |||
| 25 | # Input clock frequency. | ||
| 26 | # This will define a symbol, F_USB, in all source code files equal to the | ||
| 27 | # input clock frequency (before any prescaling is performed) in Hz. This value may | ||
| 28 | # differ from F_CPU if prescaling is used on the latter, and is required as the | ||
| 29 | # raw input clock is fed directly to the PLL sections of the AVR for high speed | ||
| 30 | # clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' | ||
| 31 | # at the end, this will be done automatically to create a 32-bit value in your | ||
| 32 | # source code. | ||
| 33 | # | ||
| 34 | # If no clock division is performed on the input clock inside the AVR (via the | ||
| 35 | # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. | ||
| 36 | F_USB = $(F_CPU) | ||
| 37 | |||
| 38 | # Interrupt driven control endpoint task(+60) | ||
| 39 | OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT | ||
| 40 | |||
| 41 | |||
| 42 | # Boot Section Size in *bytes* | ||
| 43 | # Teensy halfKay 512 | ||
| 44 | # Teensy++ halfKay 1024 | ||
| 45 | # Atmel DFU loader 4096 | ||
| 46 | # LUFA bootloader 4096 | ||
| 47 | # USBaspLoader 2048 | ||
| 48 | OPT_DEFS += -DBOOTLOADER_SIZE=4096 | ||
| 49 | |||
| 50 | |||
| 51 | # Build Options | ||
| 52 | # change yes to no to disable | ||
| 53 | # | ||
| 54 | BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) | ||
| 55 | MOUSEKEY_ENABLE = yes # Mouse keys(+4700) | ||
| 56 | EXTRAKEY_ENABLE = yes # Audio control and System control(+450) | ||
| 57 | CONSOLE_ENABLE = no # Console for debug(+400) | ||
| 58 | COMMAND_ENABLE = yes # Commands for debug and configuration | ||
| 59 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | ||
| 60 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | ||
| 61 | # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | ||
| 62 | NKRO_ENABLE = no # USB Nkey Rollover | ||
| 63 | BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality on B7 by default | ||
| 64 | MIDI_ENABLE = no # MIDI support (+2400 to 4200, depending on config) | ||
| 65 | UNICODE_ENABLE = no # Unicode | ||
| 66 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID | ||
| 67 | AUDIO_ENABLE = no # Audio output on port C6 | ||
| 68 | FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches | ||
| 69 | |||
| 70 | # Remove the common RGB light code and use my iteration instead | ||
| 71 | OPT_DEFS += -DRGBLIGHT_ENABLE | ||
| 72 | SRC += rgblight.c | ||
| 73 | SRC += ws2812.c | ||
| 74 | CIE1931_CURVE = yes | ||
| 75 | LED_BREATHING_TABLE = yes | ||
diff --git a/keyboards/mxss/templates/keymap.c b/keyboards/mxss/templates/keymap.c new file mode 100644 index 000000000..86a0f231d --- /dev/null +++ b/keyboards/mxss/templates/keymap.c | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | /* Copyright 2018 REPLACE_WITH_YOUR_NAME | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #include QMK_KEYBOARD_H | ||
| 17 | #include "mxss_frontled.h" | ||
| 18 | |||
| 19 | // Helpful defines | ||
| 20 | #define _______ KC_TRNS | ||
| 21 | |||
| 22 | // Predefined colors for layers | ||
| 23 | // Format: {hue, saturation} | ||
| 24 | // {0, 0} to turn off the LED | ||
| 25 | // Add additional rows to handle more layers | ||
| 26 | hs_set layer_colors[] = { | ||
| 27 | [0] = {0, 0}, // Color for Layer 0 | ||
| 28 | [1] = {86, 255}, // Color for Layer 1 | ||
| 29 | [2] = {36, 255}, // Color for Layer 2 | ||
| 30 | [3] = {185, 255}, // Color for Layer 3 | ||
| 31 | }; | ||
| 32 | const size_t lc_size = sizeof(layer_colors) / sizeof(uint16_t); | ||
| 33 | |||
| 34 | // Use NEW_SAFE_RANGE to define new custom keycodes in order to not overwrite the ones used for front LED control | ||
| 35 | enum custom_keycodes { | ||
| 36 | MY_KEYCODE = NEW_SAFE_RANGE, | ||
| 37 | }; | ||
| 38 | |||
| 39 | |||
| 40 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 41 | __KEYMAP_GOES_HERE__ | ||
| 42 | }; \ No newline at end of file | ||
