Skip to content

Commit

Permalink
Merge pull request #27 from crembz/dev-q2
Browse files Browse the repository at this point in the history
q2 update rgb
  • Loading branch information
crembz authored Feb 8, 2023
2 parents e84c337 + 0b99591 commit c6938d9
Show file tree
Hide file tree
Showing 6 changed files with 219 additions and 0 deletions.
70 changes: 70 additions & 0 deletions keyboards/keychron/q2/ansi_encoder/keymaps/harvester/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#pragma once

#ifdef RGB_MATRIX_ENABLE
# define RGB_MATRIX_KEYPRESSES // reacts to keypresses
// # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses)
// # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
# define RGB_MATRIX_FRAMEBUFFER_EFFECTS
// # define RGB_MATRIX_LED_PROCESS_LIMIT (DRIVER_LED_TOTAL + 4) / 5 // limits the number of LEDs to process in an animation per task run (increases keyboard responsiveness)
// # define RGB_MATRIX_LED_FLUSH_LIMIT 16 // limits in milliseconds how frequently an animation will update the LEDs. 16 (16ms) is equivalent to limiting to 60fps (increases keyboard responsiveness)
# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150 // limits maximum brightness of LEDs to 150 out of 255. Higher may cause the controller to crash.
# define RGB_MATRIX_HUE_STEP 8
# define RGB_MATRIX_SAT_STEP 8
# define RGB_MATRIX_VAL_STEP 8
# define RGB_MATRIX_SPD_STEP 10

/* Enable the animations you want/need. You may need to enable only a small number of these because *
* they take up a lot of space. Enable and confirm that you can still successfully compile your firmware. */
// RGB Matrix Animation modes. Explicitly enabled
// For full list of effects, see:
// https://docs.qmk.fm/#/feature_rgb_matrix?id=rgb-matrix-effects
# define ENABLE_RGB_MATRIX_ALPHAS_MODS
# define ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN
# define ENABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT
# define ENABLE_RGB_MATRIX_BREATHING
# define ENABLE_RGB_MATRIX_BAND_SAT
# define ENABLE_RGB_MATRIX_BAND_VAL
# define ENABLE_RGB_MATRIX_BAND_PINWHEEL_SAT
# define ENABLE_RGB_MATRIX_BAND_PINWHEEL_VAL
# define ENABLE_RGB_MATRIX_BAND_SPIRAL_SAT
# define ENABLE_RGB_MATRIX_BAND_SPIRAL_VAL
# define ENABLE_RGB_MATRIX_CYCLE_ALL
# define ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
# define ENABLE_RGB_MATRIX_CYCLE_UP_DOWN
# define ENABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
# define ENABLE_RGB_MATRIX_CYCLE_OUT_IN
# define ENABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL
# define ENABLE_RGB_MATRIX_CYCLE_PINWHEEL
# define ENABLE_RGB_MATRIX_CYCLE_SPIRAL
# define ENABLE_RGB_MATRIX_DUAL_BEACON
# define ENABLE_RGB_MATRIX_RAINBOW_BEACON
# define ENABLE_RGB_MATRIX_RAINBOW_PINWHEELS
# define ENABLE_RGB_MATRIX_RAINDROPS
# define ENABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS
# define ENABLE_RGB_MATRIX_HUE_BREATHING
# define ENABLE_RGB_MATRIX_HUE_PENDULUM
# define ENABLE_RGB_MATRIX_HUE_WAVE
# define ENABLE_RGB_MATRIX_PIXEL_RAIN
# define ENABLE_RGB_MATRIX_PIXEL_FLOW
# define ENABLE_RGB_MATRIX_PIXEL_FRACTAL
// enabled only if RGB_MATRIX_FRAMEBUFFER_EFFECTS is defined
# define ENABLE_RGB_MATRIX_TYPING_HEATMAP
# define ENABLE_RGB_MATRIX_DIGITAL_RAIN
// enabled only of RGB_MATRIX_KEYPRESSES or RGB_MATRIX_KEYRELEASES is defined
# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE
# define ENABLE_RGB_MATRIX_SOLID_REACTIVE
# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE
# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE
# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS
# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS
# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS
# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS
# define ENABLE_RGB_MATRIX_SPLASH
# define ENABLE_RGB_MATRIX_MULTISPLASH
# define ENABLE_RGB_MATRIX_SOLID_SPLASH
# define ENABLE_RGB_MATRIX_SOLID_MULTISPLASH
#endif

#define USB_POLLING_INTERVAL_MS 1
#define QMK_KEYS_PER_SCAN 12
25 changes: 25 additions & 0 deletions keyboards/keychron/q2/ansi_encoder/keymaps/harvester/enums.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// [Q2 layers Init] -------------------------------------------------------//
typedef enum {
MAC_BASE,
WIN_BASE,
_FN1,
_MEDIA,
_FUNC
}Q2_LAYERS;

extern enum Q2_LAYERS crkbd_layers;

typedef enum {
_RGB_INDICATORS,
_RGB_DANGER,
_RGB_NUM,
_RGB_FUNC,
_RGB_MEDIA,
_RGB_GAME,
_RGB_MOD,
_RGB_DEFAULT,
_RGB_TRANS,
_RGB_DISABLED
}Q2_RGB;

extern enum Q2_RGB crkbd_rgb;
68 changes: 68 additions & 0 deletions keyboards/keychron/q2/ansi_encoder/keymaps/harvester/keymap.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/* Copyright 2021 @ Keychron (https://www.keychron.com)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include QMK_KEYBOARD_H
#include "enums.h"

#define KC_TASK LGUI(KC_TAB)
#define KC_FLXP LGUI(KC_E)

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[MAC_BASE] = LAYOUT_ansi_67(
KC_ESC, 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, KC_MUTE,
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,
KC_CAPS, 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_HOME,
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_LCTL, KC_LOPT, KC_LCMD, KC_SPC, KC_RCMD, MO(_FN1), MO(_FUNC), KC_LEFT, KC_DOWN, KC_RGHT),

[WIN_BASE] = LAYOUT_ansi_67(
KC_ESC, 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, KC_MUTE,
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,
KC_CAPS, 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_HOME,
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_LCTL, KC_LWIN, KC_LALT, KC_SPC, KC_RALT, MO(_MEDIA), MO(_FUNC), KC_LEFT, KC_DOWN, KC_RGHT),

[_FN1] = LAYOUT_ansi_67(
KC_GRV, KC_BRID, KC_BRIU, _______, _______, RGB_VAD, RGB_VAI, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, _______, RGB_TOG,
RGB_TOG, RGB_MOD, RGB_VAI, RGB_HUI, RGB_SAI, RGB_SPI, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, RGB_RMOD,RGB_VAD, RGB_HUD, RGB_SAD, RGB_SPD, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, NK_TOGG, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______),

[_MEDIA] = LAYOUT_ansi_67(
KC_GRV, KC_BRID, KC_BRIU, KC_TASK, KC_FLXP, RGB_VAD, RGB_VAI, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, _______, RGB_TOG,
RGB_TOG, RGB_MOD, RGB_VAI, RGB_HUI, RGB_SAI, RGB_SPI, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, RGB_RMOD,RGB_VAD, RGB_HUD, RGB_SAD, RGB_SPD, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, NK_TOGG, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______),

[_FUNC] = LAYOUT_ansi_67(
KC_TILD, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______,
RGB_TOG, RGB_MOD, RGB_VAI, RGB_HUI, RGB_SAI, RGB_SPI, _______, _______, _______, _______, _______, _______, _______, _______, EE_CLR ,
_______, RGB_RMOD,RGB_VAD, RGB_HUD, RGB_SAD, RGB_SPD, _______, _______, _______, _______, _______, _______, _______, QK_BOOT,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______)
};

#if defined(ENCODER_MAP_ENABLE)
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = {
[MAC_BASE] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
[WIN_BASE] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
[_FN1] = { ENCODER_CCW_CW(RGB_VAD, RGB_VAI) },
[_MEDIA] = { ENCODER_CCW_CW(RGB_VAD, RGB_VAI) },
[_FUNC] = { ENCODER_CCW_CW(_______, _______) },
};
#endif
39 changes: 39 additions & 0 deletions keyboards/keychron/q2/ansi_encoder/keymaps/harvester/rgb.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include QMK_KEYBOARD_H
#include "enums.h"
#include "rgb.h"

#ifdef RGB_MATRIX_ENABLE

__attribute__ ((weak))

bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {

if (host_keyboard_led_state().caps_lock) {
for (uint8_t i = led_min; i <= led_max; i++) {
if (g_led_config.flags[i] & LED_FLAG_KEYLIGHT) {
rgb_matrix_set_color(i, RGB_INDICATORS);
}
}
}

if (get_highest_layer(layer_state) > 0) {
uint8_t layer = get_highest_layer(layer_state);
for (uint8_t row = 0; row < MATRIX_ROWS; ++row) {
for (uint8_t col = 0; col < MATRIX_COLS; ++col) {
uint8_t index = g_led_config.matrix_co[row][col];
if (index >= led_min && index <= led_max && index != NO_LED && (keymap_key_to_keycode(layer, (keypos_t){col, row}) == QK_BOOTLOADER || keymap_key_to_keycode(layer, (keypos_t){col, row}) == QK_CLEAR_EEPROM)) {
rgb_matrix_set_color(index, RGB_DANGER);
}
else if (index >= led_min && index <= led_max && index != NO_LED && keymap_key_to_keycode(layer, (keypos_t){col, row}) > KC_TRNS) {
rgb_matrix_set_color(index, RGB_DEFAULT);
} /*else if (index >= led_min && index <= led_max && index != NO_LED && keymap_key_to_keycode(layer, (keypos_t){col, row}) == KC_TRNS) {
rgb_matrix_set_color(index, RGB_TRANS);
} else if (index >= led_min && index <= led_max && index != NO_LED && keymap_key_to_keycode(layer, (keypos_t){col, row}) == KC_NO) {
rgb_matrix_set_color(index, RGB_DISABLED);
}*/
}
}
}
return true;
}
#endif
11 changes: 11 additions & 0 deletions keyboards/keychron/q2/ansi_encoder/keymaps/harvester/rgb.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#define RGB_INDICATORS 255,255,255
#define RGB_DANGER 255,0,0
#define RGB_NUM 0,255,255
#define RGB_FUNC 255,255,0
#define RGB_MEDIA 255,0,255
#define RGB_GAME 255,0,0
#define RGB_MODS 0,0,255
#define RGB_MODS2 0,255,0
#define RGB_DEFAULT 255,255,255
#define RGB_TRANS 10,10,10
#define RGB_DISABLED 0,0,0
6 changes: 6 additions & 0 deletions keyboards/keychron/q2/ansi_encoder/keymaps/harvester/rules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
VIA_ENABLE = yes
ENCODER_MAP_ENABLE = yes

DEBOUNCE_TYPE = asym_eager_defer_pk

SRC += ./rgb.c

0 comments on commit c6938d9

Please sign in to comment.