diff options
| author | Kenneth Aloysius <krusli@users.noreply.github.com> | 2018-01-02 09:34:46 +1100 |
|---|---|---|
| committer | Jack Humbert <jack.humb@gmail.com> | 2018-01-01 17:34:46 -0500 |
| commit | eba4cb7a0437c115c56dfe1796a76c69a99c4d4f (patch) | |
| tree | d8b1e3152733bacb8cca0fe55d876146487993bb /keyboards | |
| parent | 85ea96393131e4080737f574c93b001cbc99d46d (diff) | |
| download | qmk_firmware-eba4cb7a0437c115c56dfe1796a76c69a99c4d4f.tar.gz qmk_firmware-eba4cb7a0437c115c56dfe1796a76c69a99c4d4f.zip | |
RGB underglow support for JJ40, clean up redundant code in Mechmini keymap (#2196)
* Cleanup Mechmini keymap. Once the custom RGB function is defined, there is no need to manually handle RGB code.
* Change default to KEYMAP_MIT, not KEYMAP_OFFSET
* Add custom RGB code for JJ40
* Reset Mechmini advertised power draw to 500. Will have to test actual maximum power draw later.
* RGB working on JJ40.
* Fix: saturation increase/decrease flipped
* Add new directory for my custom keymap with RGB keycodes
* Swap LAlt and LGUI
* Update JJ40 max power draw with measured value
* Update: fun40 rules.mk to enable underglow; earlier failed Travis CI
Diffstat (limited to 'keyboards')
| -rw-r--r-- | keyboards/jj40/config.h | 9 | ||||
| -rw-r--r-- | keyboards/jj40/jj40.c | 32 | ||||
| -rw-r--r-- | keyboards/jj40/jj40.h | 2 | ||||
| -rw-r--r-- | keyboards/jj40/keymaps/fun40/rules.mk | 6 | ||||
| -rw-r--r-- | keyboards/jj40/keymaps/krusli/keymap.c | 85 | ||||
| -rw-r--r-- | keyboards/jj40/keymaps/krusli/readme.md | 2 | ||||
| -rw-r--r-- | keyboards/jj40/rules.mk | 9 | ||||
| -rw-r--r-- | keyboards/jj40/usbconfig.h | 3 | ||||
| -rw-r--r-- | keyboards/mechmini/config.h | 7 | ||||
| -rw-r--r-- | keyboards/mechmini/keymaps/default/keymap.c | 118 | ||||
| -rw-r--r-- | keyboards/mechmini/mechmini.c | 7 | ||||
| -rw-r--r-- | keyboards/mechmini/usbconfig.h | 2 |
12 files changed, 143 insertions, 139 deletions
diff --git a/keyboards/jj40/config.h b/keyboards/jj40/config.h index 02339a33f..3152f22be 100644 --- a/keyboards/jj40/config.h +++ b/keyboards/jj40/config.h | |||
| @@ -15,6 +15,8 @@ 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/>. | 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ | 16 | */ |
| 17 | 17 | ||
| 18 | #include "config_common.h" | ||
| 19 | |||
| 18 | #ifndef CONFIG_H | 20 | #ifndef CONFIG_H |
| 19 | #define CONFIG_H | 21 | #define CONFIG_H |
| 20 | 22 | ||
| @@ -39,6 +41,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 39 | 41 | ||
| 40 | #define NO_UART 1 | 42 | #define NO_UART 1 |
| 41 | 43 | ||
| 44 | /* RGB underglow */ | ||
| 45 | // The RGB_DI_PIN value seems to be shared between all PS2AVRGB boards. | ||
| 46 | // The same pin is used on the JJ40, at least. | ||
| 47 | #define RGBLED_NUM 5 | ||
| 48 | #define RGB_DI_PIN E2 | ||
| 49 | #define RGBLIGHT_ANIMATIONS | ||
| 50 | |||
| 42 | /* key combination for command */ | 51 | /* key combination for command */ |
| 43 | #define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) | 52 | #define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) |
| 44 | 53 | ||
diff --git a/keyboards/jj40/jj40.c b/keyboards/jj40/jj40.c index d5add2a6b..6044e83fd 100644 --- a/keyboards/jj40/jj40.c +++ b/keyboards/jj40/jj40.c | |||
| @@ -22,19 +22,25 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 22 | #include "action_layer.h" | 22 | #include "action_layer.h" |
| 23 | #include "quantum.h" | 23 | #include "quantum.h" |
| 24 | 24 | ||
| 25 | __attribute__ ((weak)) | 25 | #include "i2c.h" |
| 26 | void matrix_scan_user(void) { | 26 | |
| 27 | /* Nothing to do here... yet */ | 27 | // custom RGB driver |
| 28 | extern rgblight_config_t rgblight_config; | ||
| 29 | void rgblight_set(void) { | ||
| 30 | if (!rgblight_config.enable) { | ||
| 31 | for (uint8_t i=0; i<RGBLED_NUM; i++) { | ||
| 32 | led[i].r = 0; | ||
| 33 | led[i].g = 0; | ||
| 34 | led[i].b = 0; | ||
| 35 | } | ||
| 36 | } | ||
| 37 | |||
| 38 | i2c_init(); | ||
| 39 | i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM); | ||
| 28 | } | 40 | } |
| 29 | 41 | ||
| 30 | void matrix_init_kb(void) { | 42 | __attribute__ ((weak)) |
| 31 | 43 | void matrix_scan_user(void) { | |
| 32 | // Call the keymap level matrix init. | 44 | rgblight_task(); |
| 33 | matrix_init_user(); | 45 | /* Nothing else for now. */ |
| 34 | |||
| 35 | // Set our LED pins as output | ||
| 36 | DDRB |= (1<<6); | ||
| 37 | } | 46 | } |
| 38 | |||
| 39 | void matrix_init_user(void) { | ||
| 40 | } \ No newline at end of file | ||
diff --git a/keyboards/jj40/jj40.h b/keyboards/jj40/jj40.h index 6e90cb972..6837423f8 100644 --- a/keyboards/jj40/jj40.h +++ b/keyboards/jj40/jj40.h | |||
| @@ -65,6 +65,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 65 | { K312, K311, K310, K39, K35, K36, K3X, KC_NO, K34, K33, K32, K31 } \ | 65 | { K312, K311, K310, K39, K35, K36, K3X, KC_NO, K34, K33, K32, K31 } \ |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | #define KEYMAP KEYMAP_OFFSET | 68 | #define KEYMAP KEYMAP_MIT |
| 69 | 69 | ||
| 70 | #endif | 70 | #endif |
diff --git a/keyboards/jj40/keymaps/fun40/rules.mk b/keyboards/jj40/keymaps/fun40/rules.mk index cd2208edd..6fe3b0515 100644 --- a/keyboards/jj40/keymaps/fun40/rules.mk +++ b/keyboards/jj40/keymaps/fun40/rules.mk | |||
| @@ -11,7 +11,11 @@ MIDI_ENABLE = no # MIDI controls | |||
| 11 | AUDIO_ENABLE = yes # Audio output on port C6 | 11 | AUDIO_ENABLE = yes # Audio output on port C6 |
| 12 | UNICODE_ENABLE = no # Unicode | 12 | UNICODE_ENABLE = no # Unicode |
| 13 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID | 13 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID |
| 14 | RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. | 14 | |
| 15 | RGBLIGHT_ENABLE = yes | ||
| 16 | RGBLIGHT_CUSTOM_DRIVER = yes | ||
| 17 | DISABLE_WS2812 = yes | ||
| 18 | |||
| 15 | 19 | ||
| 16 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | 20 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend |
| 17 | 21 | ||
diff --git a/keyboards/jj40/keymaps/krusli/keymap.c b/keyboards/jj40/keymaps/krusli/keymap.c new file mode 100644 index 000000000..59e3988e1 --- /dev/null +++ b/keyboards/jj40/keymaps/krusli/keymap.c | |||
| @@ -0,0 +1,85 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com> | ||
| 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 | #include "jj40.h" | ||
| 19 | #include "action_layer.h" | ||
| 20 | |||
| 21 | #define _QWERTY 0 | ||
| 22 | #define _LOWER 1 | ||
| 23 | #define _RAISE 2 | ||
| 24 | |||
| 25 | enum custom_keycodes { | ||
| 26 | QWERTY = SAFE_RANGE, | ||
| 27 | LOWER, | ||
| 28 | RAISE, | ||
| 29 | }; | ||
| 30 | |||
| 31 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 32 | /* Qwerty | ||
| 33 | * ,-----------------------------------------------------------------------------------. | ||
| 34 | * | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp | | ||
| 35 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
| 36 | * | Esc | A | S | D | F | G | H | J | K | L | ; | " | | ||
| 37 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
| 38 | * | Shift| Z | X | C | V | B | N | M | , | . | / |Enter | | ||
| 39 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 40 | * | | Ctrl | GUI | Alt |Lower | Space |Raise | Left | Down | Up |Right | | ||
| 41 | * `-----------------------------------------------------------------------------------' | ||
| 42 | */ | ||
| 43 | [_QWERTY] = KEYMAP( \ | ||
| 44 | KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \ | ||
| 45 | KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \ | ||
| 46 | KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \ | ||
| 47 | _______, KC_LCTL, KC_LGUI, KC_LALT, MO(_LOWER), KC_SPC, MO(_RAISE), KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ | ||
| 48 | ), | ||
| 49 | |||
| 50 | /* Lower | ||
| 51 | * ,-----------------------------------------------------------------------------------. | ||
| 52 | * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp | | ||
| 53 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
| 54 | * | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | | \ | | | | ||
| 55 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
| 56 | * | | F7 | F8 | F9 | F10 | F11 | F12 | | | | |Enter | | ||
| 57 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 58 | * | | | | | | | | Next | Vol- | Vol+ | Play | | ||
| 59 | * `-----------------------------------------------------------------------------------' | ||
| 60 | */ | ||
| 61 | [_LOWER] = KEYMAP( \ | ||
| 62 | KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, \ | ||
| 63 | KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \ | ||
| 64 | _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______,_______, _______, _______, \ | ||
| 65 | _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \ | ||
| 66 | ), | ||
| 67 | |||
| 68 | /* Raise | ||
| 69 | * ,-----------------------------------------------------------------------------------. | ||
| 70 | * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp | | ||
| 71 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
| 72 | * | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ | | ||
| 73 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
| 74 | * | | F7 | F8 | F9 | F10 | F11 | F12 | RGB | RGB | RGB | RGB |Enter | | ||
| 75 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 76 | * | | RGB | RGB | RGB | RGB | | | Next | Vol- | Vol+ | Play | | ||
| 77 | * `-----------------------------------------------------------------------------------' | ||
| 78 | */ | ||
| 79 | [_RAISE] = KEYMAP( \ | ||
| 80 | KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \ | ||
| 81 | KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \ | ||
| 82 | _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, RGB_TOG, RGB_MOD, RGB_VAD, RGB_VAI, _______, \ | ||
| 83 | _______, RGB_HUD, RGB_HUI, RGB_SAD, RGB_SAI, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \ | ||
| 84 | ) | ||
| 85 | }; | ||
diff --git a/keyboards/jj40/keymaps/krusli/readme.md b/keyboards/jj40/keymaps/krusli/readme.md new file mode 100644 index 000000000..75a84d0e6 --- /dev/null +++ b/keyboards/jj40/keymaps/krusli/readme.md | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | # krusli | ||
| 2 | Default JJ40 keymap, adapted with RGB underglow support. GUI and LAlt is also swapped. | ||
diff --git a/keyboards/jj40/rules.mk b/keyboards/jj40/rules.mk index c6279a2a5..cdc898c0f 100644 --- a/keyboards/jj40/rules.mk +++ b/keyboards/jj40/rules.mk | |||
| @@ -26,7 +26,7 @@ F_CPU = 12000000 | |||
| 26 | 26 | ||
| 27 | # Bootloader | 27 | # Bootloader |
| 28 | # This definition is optional, and if your keyboard supports multiple bootloaders of | 28 | # This definition is optional, and if your keyboard supports multiple bootloaders of |
| 29 | # different sizes, comment this out, and the correct address will be loaded | 29 | # different sizes, comment this out, and the correct address will be loaded |
| 30 | # automatically (+60). See bootloader.mk for all options. | 30 | # automatically (+60). See bootloader.mk for all options. |
| 31 | BOOTLOADER = bootloadHID | 31 | BOOTLOADER = bootloadHID |
| 32 | 32 | ||
| @@ -37,8 +37,11 @@ EXTRAKEY_ENABLE = yes | |||
| 37 | CONSOLE_ENABLE = no | 37 | CONSOLE_ENABLE = no |
| 38 | COMMAND_ENABLE = yes | 38 | COMMAND_ENABLE = yes |
| 39 | BACKLIGHT_ENABLE = no | 39 | BACKLIGHT_ENABLE = no |
| 40 | RGBLIGHT_ENABLE = no | 40 | |
| 41 | RGBLIGHT_CUSTOM_DRIVER = no | 41 | RGBLIGHT_ENABLE = yes |
| 42 | RGBLIGHT_CUSTOM_DRIVER = yes | ||
| 43 | DISABLE_WS2812 = yes # TODO check if this is necessary | ||
| 44 | |||
| 42 | KEY_LOCK_ENABLE = yes | 45 | KEY_LOCK_ENABLE = yes |
| 43 | 46 | ||
| 44 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | 47 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE |
diff --git a/keyboards/jj40/usbconfig.h b/keyboards/jj40/usbconfig.h index cae839e74..520d08f61 100644 --- a/keyboards/jj40/usbconfig.h +++ b/keyboards/jj40/usbconfig.h | |||
| @@ -118,7 +118,8 @@ section at the end of this file). | |||
| 118 | /* Define this to 1 if the device has its own power supply. Set it to 0 if the | 118 | /* Define this to 1 if the device has its own power supply. Set it to 0 if the |
| 119 | * device is powered from the USB bus. | 119 | * device is powered from the USB bus. |
| 120 | */ | 120 | */ |
| 121 | #define USB_CFG_MAX_BUS_POWER 500 | 121 | // max power draw with maxed white underglow measured at 120 mA (peaks) |
| 122 | #define USB_CFG_MAX_BUS_POWER 150 | ||
| 122 | /* Set this variable to the maximum USB bus power consumption of your device. | 123 | /* Set this variable to the maximum USB bus power consumption of your device. |
| 123 | * The value is in milliamperes. [It will be divided by two since USB | 124 | * The value is in milliamperes. [It will be divided by two since USB |
| 124 | * communicates power requirements in units of 2 mA.] | 125 | * communicates power requirements in units of 2 mA.] |
diff --git a/keyboards/mechmini/config.h b/keyboards/mechmini/config.h index e7004608e..6a4523f85 100644 --- a/keyboards/mechmini/config.h +++ b/keyboards/mechmini/config.h | |||
| @@ -30,12 +30,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 30 | #define MATRIX_ROWS 8 | 30 | #define MATRIX_ROWS 8 |
| 31 | #define MATRIX_COLS 15 | 31 | #define MATRIX_COLS 15 |
| 32 | 32 | ||
| 33 | #define NO_UART 1 | ||
| 34 | |||
| 35 | /* RGB underglow */ | ||
| 36 | // The RGB_DI_PIN value seems to be shared between all PS2AVRGB boards. | ||
| 37 | // The same pin is used on the JJ40, at least. | ||
| 33 | #define RGBLED_NUM 16 | 38 | #define RGBLED_NUM 16 |
| 34 | #define RGBLIGHT_ANIMATIONS | 39 | #define RGBLIGHT_ANIMATIONS |
| 35 | #define RGB_DI_PIN E2 | 40 | #define RGB_DI_PIN E2 |
| 36 | 41 | ||
| 37 | #define NO_UART 1 | ||
| 38 | |||
| 39 | /* key combination for command */ | 42 | /* key combination for command */ |
| 40 | #define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) | 43 | #define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) |
| 41 | 44 | ||
diff --git a/keyboards/mechmini/keymaps/default/keymap.c b/keyboards/mechmini/keymaps/default/keymap.c index 5cae1bc81..4a0a4dc0a 100644 --- a/keyboards/mechmini/keymaps/default/keymap.c +++ b/keyboards/mechmini/keymaps/default/keymap.c | |||
| @@ -14,16 +14,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 14 | */ | 14 | */ |
| 15 | 15 | ||
| 16 | #include "mechmini.h" | 16 | #include "mechmini.h" |
| 17 | #include "rgblight.h" | ||
| 18 | #include "quantum.h" | 17 | #include "quantum.h" |
| 19 | 18 | ||
| 20 | #define MAX_BRIGHTNESS 15 | 19 | #define _BL 0 // base layer |
| 21 | #define MAX_BRIGHTNESS_IOS 5 // max brightness suitable for iOS devices | 20 | #define _FN1 1 // function layer 1 |
| 22 | 21 | #define _FN2 2 // function layer 2 | |
| 23 | #define _BL 0 | 22 | #define _FN3 3 // function layer 3 |
| 24 | #define _FN1 1 | ||
| 25 | #define _FN2 2 | ||
| 26 | #define _FN3 3 | ||
| 27 | #define _____ KC_TRNS | 23 | #define _____ KC_TRNS |
| 28 | 24 | ||
| 29 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | 25 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { |
| @@ -52,109 +48,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 52 | _____, _____, _____, _____, _____, _____, _____, _____ | 48 | _____, _____, _____, _____, _____, _____, _____, _____ |
| 53 | ) | 49 | ) |
| 54 | }; | 50 | }; |
| 55 | |||
| 56 | /** | ||
| 57 | * Blank keymap | ||
| 58 | [0] = KEYMAP( | ||
| 59 | _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____ | ||
| 60 | _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, | ||
| 61 | _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, | ||
| 62 | _____, _____, _____, _____, _____, _____, _____, _____ | ||
| 63 | ) | ||
| 64 | */ | ||
| 65 | |||
| 66 | uint8_t current_level = 4; | ||
| 67 | int is_on = 0; | ||
| 68 | |||
| 69 | uint8_t r = 0xFF; | ||
| 70 | uint8_t g = 0xFF; | ||
| 71 | uint8_t b = 0xFF; | ||
| 72 | |||
| 73 | uint8_t max_brightness = MAX_BRIGHTNESS_IOS; | ||
| 74 | |||
| 75 | enum macro_id { | ||
| 76 | TOGGLE_RGB, | ||
| 77 | BRIGHTNESS_DOWN, | ||
| 78 | BRIGHTNESS_UP, | ||
| 79 | COLOR_1, | ||
| 80 | COLOR_2, | ||
| 81 | COLOR_3, | ||
| 82 | ENABLE_MAX_BRIGHTNESS | ||
| 83 | }; | ||
| 84 | |||
| 85 | const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { | ||
| 86 | keyevent_t event = record->event; | ||
| 87 | |||
| 88 | switch (id) { | ||
| 89 | case TOGGLE_RGB: | ||
| 90 | if (event.pressed) { | ||
| 91 | if (!is_on) { | ||
| 92 | current_level = 4; | ||
| 93 | is_on = 1; | ||
| 94 | } else { | ||
| 95 | is_on = 0; | ||
| 96 | } | ||
| 97 | } | ||
| 98 | case BRIGHTNESS_DOWN: | ||
| 99 | if (event.pressed && current_level > 0) { | ||
| 100 | current_level--; | ||
| 101 | } | ||
| 102 | break; | ||
| 103 | case BRIGHTNESS_UP: | ||
| 104 | if (event.pressed && current_level < max_brightness) { | ||
| 105 | current_level++; | ||
| 106 | } | ||
| 107 | break; | ||
| 108 | case COLOR_1: // set to pink | ||
| 109 | if (event.pressed) { | ||
| 110 | r = 0xFF; | ||
| 111 | g = 0x81; | ||
| 112 | b = 0xC2; | ||
| 113 | } | ||
| 114 | break; | ||
| 115 | case COLOR_2: // set to cyan | ||
| 116 | if (event.pressed) { | ||
| 117 | r = 0x00; | ||
| 118 | g = 0xE0; | ||
| 119 | b = 0xFF; | ||
| 120 | } | ||
| 121 | break; | ||
| 122 | case COLOR_3: // set to white | ||
| 123 | if (event.pressed) { | ||
| 124 | r = 0xFF; | ||
| 125 | g = 0xFF; | ||
| 126 | b = 0xFF; | ||
| 127 | } | ||
| 128 | break; | ||
| 129 | case ENABLE_MAX_BRIGHTNESS: // enable all 16 brightness steps | ||
| 130 | if (event.pressed) { | ||
| 131 | max_brightness = MAX_BRIGHTNESS; | ||
| 132 | } | ||
| 133 | break; | ||
| 134 | } | ||
| 135 | |||
| 136 | return MACRO_NONE; | ||
| 137 | } | ||
| 138 | |||
| 139 | const uint16_t fn_actions[] PROGMEM = { | ||
| 140 | }; | ||
| 141 | |||
| 142 | void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b); | ||
| 143 | |||
| 144 | uint8_t dim(uint8_t color, uint8_t opacity) { | ||
| 145 | return ((uint16_t) color * opacity / 0xFF) & 0xFF; | ||
| 146 | } | ||
| 147 | |||
| 148 | void user_setrgb(uint8_t r, uint8_t g, uint8_t b) { | ||
| 149 | uint8_t alpha = current_level * 0x11; | ||
| 150 | rgblight_setrgb(dim(r, alpha), dim(g, alpha), dim(b, alpha)); | ||
| 151 | } | ||
| 152 | |||
| 153 | void matrix_scan_user(void) { | ||
| 154 | if (!is_on) { | ||
| 155 | current_level = 0; | ||
| 156 | user_setrgb(r, g, b); | ||
| 157 | } else { | ||
| 158 | user_setrgb(r, g, b); | ||
| 159 | } | ||
| 160 | } | ||
diff --git a/keyboards/mechmini/mechmini.c b/keyboards/mechmini/mechmini.c index baa2e0357..9897da099 100644 --- a/keyboards/mechmini/mechmini.c +++ b/keyboards/mechmini/mechmini.c | |||
| @@ -16,16 +16,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 16 | */ | 16 | */ |
| 17 | 17 | ||
| 18 | #include "mechmini.h" | 18 | #include "mechmini.h" |
| 19 | #include "rgblight.h" | ||
| 20 | |||
| 21 | #include <avr/pgmspace.h> | 19 | #include <avr/pgmspace.h> |
| 22 | 20 | ||
| 23 | #include "action_layer.h" | 21 | #include "action_layer.h" |
| 24 | #include "i2c.h" | 22 | #include "i2c.h" |
| 25 | #include "quantum.h" | 23 | #include "quantum.h" |
| 26 | 24 | ||
| 27 | extern rgblight_config_t rgblight_config; | 25 | #include "rgblight.h" |
| 28 | 26 | ||
| 27 | // custom RGB driver | ||
| 28 | extern rgblight_config_t rgblight_config; | ||
| 29 | void rgblight_set(void) { | 29 | void rgblight_set(void) { |
| 30 | if (!rgblight_config.enable) { | 30 | if (!rgblight_config.enable) { |
| 31 | for (uint8_t i = 0; i < RGBLED_NUM; i++) { | 31 | for (uint8_t i = 0; i < RGBLED_NUM; i++) { |
| @@ -42,4 +42,5 @@ void rgblight_set(void) { | |||
| 42 | __attribute__ ((weak)) | 42 | __attribute__ ((weak)) |
| 43 | void matrix_scan_user(void) { | 43 | void matrix_scan_user(void) { |
| 44 | rgblight_task(); | 44 | rgblight_task(); |
| 45 | /* add other tasks to be done on each matrix scan */ | ||
| 45 | } | 46 | } |
diff --git a/keyboards/mechmini/usbconfig.h b/keyboards/mechmini/usbconfig.h index b6b8cdbbb..d2d848fcd 100644 --- a/keyboards/mechmini/usbconfig.h +++ b/keyboards/mechmini/usbconfig.h | |||
| @@ -118,7 +118,7 @@ section at the end of this file). | |||
| 118 | /* Define this to 1 if the device has its own power supply. Set it to 0 if the | 118 | /* Define this to 1 if the device has its own power supply. Set it to 0 if the |
| 119 | * device is powered from the USB bus. | 119 | * device is powered from the USB bus. |
| 120 | */ | 120 | */ |
| 121 | #define USB_CFG_MAX_BUS_POWER 100 | 121 | #define USB_CFG_MAX_BUS_POWER 500 |
| 122 | /* Set this variable to the maximum USB bus power consumption of your device. | 122 | /* Set this variable to the maximum USB bus power consumption of your device. |
| 123 | * The value is in milliamperes. [It will be divided by two since USB | 123 | * The value is in milliamperes. [It will be divided by two since USB |
| 124 | * communicates power requirements in units of 2 mA.] | 124 | * communicates power requirements in units of 2 mA.] |
