Skip to content

Commit

Permalink
[Keymap] update andrebrait GMMK Pro keymap (#18608)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrebrait authored Oct 7, 2022
1 parent 111dcdf commit 150572d
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions keyboards/gmmk/pro/rev1/ansi/keymaps/andrebrait/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

#ifdef RGB_MATRIX_ENABLE

#define RGB_CONFIRMATION_BLINKING_TIME 2000 // 2 seconds

/* Renaming those to make the purpose on this keymap clearer */
#define LED_FLAG_CAPS LED_FLAG_NONE
#define LED_FLAG_EFFECTS LED_FLAG_INDICATOR
Expand All @@ -116,12 +114,18 @@ static uint16_t effect_started_time = 0;
static uint8_t r_effect = 0x0, g_effect = 0x0, b_effect = 0x0;
static void start_effects(void);

/* The higher this is, the slower the blinking will be */
#ifndef TIME_SELECTED_BIT
#define TIME_SELECTED_BIT 8
/* The interval time in ms */
#ifndef EFFECTS_TIME
#define EFFECTS_TIME 2000
#endif
#ifndef EFFECTS_INTERVAL
#define EFFECTS_INTERVAL 250
#endif
#if EFFECTS_TIME <= 0 || EFFECTS_TIME >= 32767
#error "EFFECTS_TIME must be a positive integer smaller than 32767"
#endif
#if TIME_SELECTED_BIT < 0 || TIME_SELECTED_BIT >= 16
#error "TIME_SELECTED_BIT must be a positive integer smaller than 16"
#if EFFECTS_INTERVAL <= 0 || EFFECTS_INTERVAL >= 32767
#error "EFFECTS_INTERVAL must be a positive integer smaller than 32767"
#endif
#define effect_red() r_effect = 0xFF, g_effect = 0x0, b_effect = 0x0
#define effect_green() r_effect = 0x0, g_effect = 0xFF, b_effect = 0x0
Expand Down Expand Up @@ -257,16 +261,16 @@ bool rgb_matrix_indicators_user(void) {
if (effect_started_time > 0) {
/* Render blinking EFFECTS */
const uint16_t deltaTime = sync_timer_elapsed(effect_started_time);
if (deltaTime <= RGB_CONFIRMATION_BLINKING_TIME) {
const uint8_t led_state = ((~deltaTime) >> TIME_SELECTED_BIT) & 0x01;
if (deltaTime <= EFFECTS_TIME) {
const uint8_t led_state = ((deltaTime / EFFECTS_INTERVAL) + 1) & 0x01;
const uint8_t val_r = led_state * r_effect;
const uint8_t val_g = led_state * g_effect;
const uint8_t val_b = led_state * b_effect;
rgb_matrix_set_color_all(val_r, val_g, val_b);
if (host_keyboard_led_state().caps_lock) {
set_rgb_caps_leds();
}
return;
return false;
} else {
/* EFFECTS duration is finished */
effect_started_time = 0;
Expand Down Expand Up @@ -316,6 +320,20 @@ static void start_effects() {
// 91, led 08 92, led 19

static void set_rgb_caps_leds() {
rgb_matrix_set_color(0, 0xFF, 0x0, 0x0); // ESC
rgb_matrix_set_color(6, 0xFF, 0x0, 0x0); // F1
rgb_matrix_set_color(12, 0xFF, 0x0, 0x0); // F2
rgb_matrix_set_color(18, 0xFF, 0x0, 0x0); // F3
rgb_matrix_set_color(23, 0xFF, 0x0, 0x0); // F4
rgb_matrix_set_color(28, 0xFF, 0x0, 0x0); // F5
rgb_matrix_set_color(34, 0xFF, 0x0, 0x0); // F6
rgb_matrix_set_color(39, 0xFF, 0x0, 0x0); // F7
rgb_matrix_set_color(44, 0xFF, 0x0, 0x0); // F8
rgb_matrix_set_color(50, 0xFF, 0x0, 0x0); // F9
rgb_matrix_set_color(56, 0xFF, 0x0, 0x0); // F10
rgb_matrix_set_color(61, 0xFF, 0x0, 0x0); // F11
rgb_matrix_set_color(66, 0xFF, 0x0, 0x0); // F12
rgb_matrix_set_color(69, 0xFF, 0x0, 0x0); // Prt
rgb_matrix_set_color(67, 0xFF, 0x0, 0x0); // Left side LED 1
rgb_matrix_set_color(68, 0xFF, 0x0, 0x0); // Right side LED 1
rgb_matrix_set_color(70, 0xFF, 0x0, 0x0); // Left side LED 2
Expand Down

0 comments on commit 150572d

Please sign in to comment.