SonixQMK / qmk_firmware

Open-source keyboard firmware for Atmel AVR and Arm USB families
https://qmk.fm
GNU General Public License v2.0
515 stars 408 forks source link

[Bug] GMMK 1 full size ISO - RGB_* values off by one in VIA firmware and # key lighting not working #330

Closed sesquipedality closed 10 months ago

sesquipedality commented 1 year ago

GMMK 1 full size ISO - RGB lighting disabled after re-plug

Describe the Bug

When i first flash a Sonix image to the keyboard, the keys light up as normal, and the fn keys to change lighting effects work. However, once the keyboard is unplugged and replugged, the LEDS do not light up.

Other oddness that may or may not be related 1) The ISO specific keys (\| and #~) do not light up even on the first power up. 2) The RGB_SPD function assigned to fn + numpad 7 slows down the lighting till it stops but never increases it again.

System Information

Additional Context

Build environment set up using

qmk setup SonixQMK/qmk_firmware -b sn32_master

I have tried this with both the VIA and standard ISO firmware and the result is the same

sesquipedality commented 1 year ago

As an extra data point - the following firmware is working as expected (although still without the # key)

https://github.com/gloryhzw/qmk_tool/wiki/VIA-OpenRGB-for-GMMK

sesquipedality commented 1 year ago

I am reasonably confident that the missing light on the # key is due to an error in config_led.c, sicnce the Tab Row and Caps Lock rows appear identical between the ANSI and ISO layouts. This is probably unrelated to the issue with RGB lighting stopping working (but is still a bug). Unfortunately, I cannot intuit what the correct values are supposed to be,

sesquipedality commented 1 year ago

OK, I think I now understand the issue more. I was getting confused because the NVRAM was not being wiped when a new firmware was installed. I think that the issue is that the current VIA build for a Rev3 board does not use the right RGB_ codes. As such, it's possible to get the board in a state where the RGB lighting is turned off and cannot be turned back on.

Confirmed: There is an off by 1 error in the RGB_ codes when compiling the Rev3 VIA firmware. Each of the codes below is actually mapped to the next one in the list

RGB_TOG,
RGB_MODE_FORWARD,
RGB_MODE_REVERSE,
RGB_HUI,
RGB_HUD,
RGB_SAI,
RGB_SAD,
RGB_VAI,
RGB_VAD,
RGB_SPI,
RGB_SPD,
RGB_MODE_PLAIN,
RGB_MODE_BREATHE,
RGB_MODE_RAINBOW,
RGB_MODE_SWIRL,
RGB_MODE_SNAKE,
RGB_MODE_KNIGHT,
RGB_MODE_XMAS,
RGB_MODE_GRADIENT,
RGB_MODE_RGBTEST,

So to activate the RGB_TOG function, you need to use RGB_MODE_FORWARD (or RGB_MOD) and so on. This error is not present in the OpenRGB hybrid firmware, which is why that works.

So to conclude I have identified two bugs which I do not know how to fix

1) Incorrect position data for the #~ key on ISO keyboards, meaning this key does not light up. 2) In the VIA firmware, the RGB_ codes are offset by one from their correct values.

I'm not sure anyone is reading this, or is even maintaining this firmware any more, but I leave it here in case the info is of use to someone. I have worked around the problem by using the offset RGB_ values in my VIA keymap.

sesquipedality commented 1 year ago

Here is a fix for the ISO led map for the GMMK full size, diff against the "sn32" branch.

I have also had to force #define KEYMAP_ISO on to get this working in the VIA build. It may be that a separate via_iso layout is needed, but I am not sure how to integrate that sensibly.

diff --git a/keyboards/gmmk/full/rev3/backlight.c b/keyboards/gmmk/full/rev3/backlight.c
index 117702437b..80c8aa604b 100644
--- a/keyboards/gmmk/full/rev3/backlight.c
+++ b/keyboards/gmmk/full/rev3/backlight.c
@@ -93,8 +93,8 @@ void spi_r3(uint8_t page, uint8_t addr, uint8_t *data)
 static const uint8_t g_led_pos[DRIVER_LED_TOTAL] = {
 /* 0*/    0,   2,   3,   4,   5,   6,   7,   8,   9,  10,   11,  12,  13,  14,  15,  16,
 /*16*/  100, 101, 102, 103, 104, 105, 106, 107, 108, 109,  110, 111, 112, 113,  21,  22,  23,  24,   25,   26,  27,
-/*37*/  116, 117, 118, 119, 120, 121, 122, 123, 124, 125,  126, 127, 128, 129,  32,  33,  34,  35,   36,   37,  38,
-/*58*/  132, 133, 134, 135, 136, 137, 138, 139, 140, 141,  142, 143, 145,  42,  43,  44,
+/*37*/  116, 117, 118, 119, 120, 121, 122, 123, 124, 125,  126, 127, 128, 145,  32,  33,  34,  35,   36,   37,  38,
+/*58*/  132, 133, 134, 135, 136, 137, 138, 139, 140, 141,  142, 143, 144,  42,  43,  44,
 /*74*/  148, 150, 151, 152, 153, 154, 155, 156, 157, 158,  159, 161,  49,  51,  52,  53,  54,
 /*91*/  114, 115, 130, 131, 146, 147, 162, 163,  55,  56,   57,  59,  60, 149 /* KC_NUBS */
 };
sesquipedality commented 1 year ago

I have also now solved the offset keycodes issue by replacing quantum/quantum_keycodes.h in sn32 from sn32master. This does not appear to have had any negative side effects and the RGB key codes are now showing correctly in VIA.