diff options
author | Joel Challis <git@zvecr.com> | 2020-05-01 17:59:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-01 17:59:22 +0100 |
commit | f7324ec68494026c27b9c4af4b34bf4a98d2c75b (patch) | |
tree | ce303538e8eed3d667ef5097eb7b279ad3030e77 /keyboards/xd002/keymaps/rgb_lite | |
parent | 750c7c2bdbfb4b4e9d3a9efe6cb3f95ef0b43c53 (diff) |
Add xd002 support (#8598)
* Add xd002 support
* tidy some whitespace
* align filename
* Update keyboards/xd002/info.json
Co-authored-by: Erovia <Erovia@users.noreply.github.com>
Co-authored-by: Erovia <Erovia@users.noreply.github.com>
Diffstat (limited to 'keyboards/xd002/keymaps/rgb_lite')
-rw-r--r-- | keyboards/xd002/keymaps/rgb_lite/keymap.c | 31 | ||||
-rw-r--r-- | keyboards/xd002/keymaps/rgb_lite/rgblite.h | 26 | ||||
-rw-r--r-- | keyboards/xd002/keymaps/rgb_lite/rules.mk | 1 |
3 files changed, 58 insertions, 0 deletions
diff --git a/keyboards/xd002/keymaps/rgb_lite/keymap.c b/keyboards/xd002/keymaps/rgb_lite/keymap.c new file mode 100644 index 0000000000..ed9185e3b5 --- /dev/null +++ b/keyboards/xd002/keymaps/rgb_lite/keymap.c @@ -0,0 +1,31 @@ +#include QMK_KEYBOARD_H +#include "rgblite.h" + +// Defines the keycodes used by our macros in process_record_user +enum custom_keycodes { + QMKURL = SAFE_RANGE, +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [0] = LAYOUT( + RGB_HUI, QMKURL + ) +}; + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + if (record->event.pressed) { + switch (keycode) { + case RGB_HUI: + rgblight_increase_hue(); + break; + case QMKURL: + SEND_STRING("https://qmk.fm/" SS_TAP(X_ENTER)); + break; + } + } + return true; +} + +void keyboard_post_init_user(void) { + rgblight_increase_hue(); +} diff --git a/keyboards/xd002/keymaps/rgb_lite/rgblite.h b/keyboards/xd002/keymaps/rgb_lite/rgblite.h new file mode 100644 index 0000000000..ca98484b81 --- /dev/null +++ b/keyboards/xd002/keymaps/rgb_lite/rgblite.h @@ -0,0 +1,26 @@ +#pragma once + +#include "ws2812.h" +#include "rgblight_list.h" + +static inline void rgblight_setrgb(uint8_t _r, uint8_t _g, uint8_t _b) { + LED_TYPE leds[RGBLED_NUM] = {{.r = _r, .g = _g, .b = _b}, {.r = _r, .g = _g, .b = _b}}; + ws2812_setleds(leds, RGBLED_NUM); +} + +static void rgblight_increase_hue(void) { + static uint8_t state = 0; + + state = (state + 1) % 3; + switch (state) { + case 1: + rgblight_setrgb_red(); + break; + case 2: + rgblight_setrgb_blue(); + break; + default: + rgblight_setrgb_green(); + break; + } +} diff --git a/keyboards/xd002/keymaps/rgb_lite/rules.mk b/keyboards/xd002/keymaps/rgb_lite/rules.mk new file mode 100644 index 0000000000..227bbcae32 --- /dev/null +++ b/keyboards/xd002/keymaps/rgb_lite/rules.mk @@ -0,0 +1 @@ +SRC += ws2812.c |