Author Topic: How to Toggle RGB Modes with Rotary Encoder?  (Read 1153 times)

0 Members and 1 Guest are viewing this topic.

Offline pabile

  • Thread Starter
  • Posts: 140
  • Location: Southeast Asia
    • pabile online
How to Toggle RGB Modes with Rotary Encoder?
« on: Mon, 31 August 2020, 05:43:03 »
hello gh, i have my custom keyboard with 40 WS2812B leds and 2 ec11 rotary encoders. i am running QMK and the keyboard is working great. i can toggle rgb modes using key combinations but what i wanted is to toggle rgb modes and/or colors using the 2 rotary encoders installed. so, my question is, how do i do this?

what i want for my keymap.c but does not work:
Code: [Select]
void encoder_update_user(uint8_t index, bool clockwise) {
    if (index == 0) { /* First encoder */
        if (clockwise) {
            tap_code(RGB_MOD);
        } else {
            tap_code(RGB_RMOD);
        }
    } else if (index == 1) { /* Second encoder */
        if (clockwise) {
            tap_code(RGB_HUI);
        } else {
            tap_code(RGB_HUD);
        }
    }


when i use the above keymap, i am getting this error:
Code: [Select]
QMK Firmware 0.7.44
WARNING: Some git submodules are out of date or modified.
 Please consider running make git-submodule.

Making pabile/p42 with keymap default

avr-gcc (GCC) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Size before:
   text    data     bss     dec     hex filename
      0   22810       0   22810    591a .build/pabile_p42_default.hex

Compiling: keyboards/pabile/p42/keymaps/default/keymap.c                                           In file included from quantum/keymap.h:44:0,
                 from quantum/quantum.h:30,
                 from keyboards/pabile/p42/p42.h:3,
                 from keyboards/pabile/p42/keymaps/default/keymap.c:1:
keyboards/pabile/p42/keymaps/default/keymap.c: In function ‘encoder_update_user’:
quantum/quantum_keycodes.h:648:17: error: large integer implicitly truncated to unsigned type [-Werror=overflow]
 #define RGB_MOD RGB_MODE_FORWARD
                 ^
keyboards/pabile/p42/keymaps/default/keymap.c:34:16: note: in expansion of macro ‘RGB_MOD’
       tap_code(RGB_MOD); /*mouse wheel down */
                ^
cc1: all warnings being treated as errors
 [ERRORS]
 |
 |
 |
tmk_core/rules.mk:383: recipe for target '.build/obj_pabile_p42_default/keyboards/pabile/p42/keymaps/default/keymap.o' failed
make[1]: *** [.build/obj_pabile_p42_default/keyboards/pabile/p42/keymaps/default/keymap.o] Error 1
Make finished with errors
Makefile:563: recipe for target 'pabile/p42:default' failed
make: *** [pabile/p42:default] Error 1

my config.h looks like this:
Code: [Select]
#define RGB_DI_PIN B0
#define RGBLIGHT_SLEEP
#define RGBLED_NUM 40
#define RGBLIGHT_HUE_STEP 8
#define RGBLIGHT_SAT_STEP 8
#define RGBLIGHT_VAL_STEP 8
#define RGBLIGHT_LIMIT_VAL 40
#define RGBLIGHT_ANIMATIONS
#define RGBLIGHT_LED_MAP { 0,1,2,3,4,5,6,7,8,9,19,18,17,16,15,14,13,12,11,10,20,21,22,23,24,25,26,27,28,29,39,38,37,36,35,34,33,32,31,30}


Offline pabile

  • Thread Starter
  • Posts: 140
  • Location: Southeast Asia
    • pabile online
Re: How to Toggle RGB Modes with Rotary Encoder?
« Reply #1 on: Mon, 31 August 2020, 07:13:19 »
i arrived to this after a help from a local guru:
Code: [Select]
void encoder_update_user(uint8_t index, bool clockwise) {
    if (index == 0) { /* First encoder */
        if (clockwise) {
            rgblight_step();
        } else {
           rgblight_step_reverse();
        }
    } ...

i am yet to finish reading this document sent to me but i guess possibilities are truly limitless with QMK  :D
https://github.com/qmk/qmk_firmware/blob/master/quantum/rgblight.h

Offline coarse

  • * Maker
  • Posts: 34
    • Coarse Keys
Re: How to Toggle RGB Modes with Rotary Encoder?
« Reply #2 on: Mon, 31 August 2020, 09:27:07 »
if you find yourself stuck with trying to implement something in qmk again, the qmk docs is your friend

Offline pabile

  • Thread Starter
  • Posts: 140
  • Location: Southeast Asia
    • pabile online
Re: How to Toggle RGB Modes with Rotary Encoder?
« Reply #3 on: Wed, 09 September 2020, 05:57:00 »
thanks! i am indeed going back and fort to the docs trying to find the right settings for the promicro and rgb. my keyboard is acting up and could not seem to properly power my leds :)