SonixQMK / qmk_firmware

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

[Keyboard] Add Redragon K556 #347

Closed Xinayder closed 10 months ago

Xinayder commented 1 year ago

First attempt at upstreaming K556 to the latest branch.

Description

Types of Changes

Issues Fixed or Closed by This PR

None

Checklist

Xinayder commented 1 year ago

Issues so far:

I have based off the K630 code already on the repo and changed to use the full size ANSI layout (104) keys.

dexter93 commented 1 year ago

although k556 state is.. dubious in current form ( old code faking ortho + keymap being a hybrid for iso/ansi) probably the best base for identifying the matrix coords will be this, at least as a starting point.

for rgb_matrix: K556 uses a non-standard transistor setup. Default is as follows:

#define PWM_OUTPUT_ACTIVE_LEVEL PWM_OUTPUT_ACTIVE_LOW
#define RGB_OUTPUT_ACTIVE_LEVEL RGB_OUTPUT_ACTIVE_HIGH

you need to select the appropriate active levels for PNP/NPN transistors in the board. See here for ref.

Xinayder commented 11 months ago

I have updated the matrix mapping on the K556. Almost everything works except the numpad DEL, which I cannot find a way to map it correctly. I mostly used the VIA coords for everything.

you need to select the appropriate active levels for PNP/NPN transistors in the board. See here for ref.

does it make a difference? I can't find it on the old code, maybe I am overlooking something.

EDIT: with regards to RGB, how can I get it to work? I know the matrix might be a bit off but no lights are turning on, only the indicator (num lock, caps lock) LEDs.

Xinayder commented 11 months ago

Thanks for the tip, I inverted the logic states of the transistors and RGB is working. The brightness control doesn't seem to work.

As for VIA support, I get the following error:

Compiling: quantum/dynamic_keymap.c                                                                quantum/dynamic_keymap.c:91:1: error: static assertion failed: "Dynamic keymaps are configured to use more EEPROM than is available."
   91 | _Static_assert((DYNAMIC_KEYMAP_EEPROM_MAX_ADDR) - (DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR) >= 100, "Dynamic keymaps are configured to use more EEPROM than is available.");
      | ^~~~~~~~~~~~~~

If I try to use the DYNAMIC_KEYMAP_EEPROM_MAX_ADDR define, this is what I get:

Compiling: quantum/dynamic_keymap.c                                                                quantum/dynamic_keymap.c:55:13: error: expected a string after '#pragma message' [-Werror=pragmas]
   55 | #    pragma message STR(DYNAMIC_KEYMAP_EEPROM_MAX_ADDR) " > " STR((TOTAL_EEPROM_BYTE_COUNT - 1))
      |             ^~~~~~~
quantum/dynamic_keymap.c:56:6: error: #error DYNAMIC_KEYMAP_EEPROM_MAX_ADDR is configured to use more space than what is available for the selected EEPROM driver
   56 | #    error DYNAMIC_KEYMAP_EEPROM_MAX_ADDR is configured to use more space than what is available for the selected EEPROM driver
      |      ^~~~~
cc1: all warnings being treated as errors
 [ERRORS]

I'm using the EEPROM wear leveling feature with the sn32_flash driver selected.

EDIT: good news! I got the missing numpad del key to work, turns out there was an extra comma on the keymap definition file and for that reason I couldn't set the correct matrix location for the key. I also managed to get VIA to work by reducing the amount of layers to just 2 (base + FN keys). Thanks to VIA, I could find out that some of the RGB function keys were shifted to the left and it also helped to find out how to fix the missing key on the layout.

~The only problem now, I believe, is that the RGB is a bit too dim (it's on max brightness) and it flickers a bit. Some keys don't have LED lighting as well.~

EDIT2: I added #define MATRIX_UNSELECT_DRIVE_HIGH to config.h and made some modifications to the RGB matrix on info.json, RGB leds are bright and it seems like everything is working!

sunbinyuan commented 10 months ago

Are the LEDs still flickering in this new version? Waiting for this to work so I can port it to the K582.

Xinayder commented 10 months ago

@sunbinyuan no, they aren't. Adding #define MATRIX_UNSELECT_DRIVE_HIGH to config.h fixed the problem.

I believe that the port is roughly complete. VIA works with 2 layers only, but that's not a big deal. RGB is working on every key. I tested it with the ANSI version, I believe the ISO version would require some changes.

Feel free to try to adapt the changes to your K582!

sunbinyuan commented 10 months ago

Awesome to know, thanks! Curiously, is 2 layers the maximum number supported by the eprom?

Xinayder commented 10 months ago

It was the maximum I could get it to build. It's weird, the K630 uses the same driver and chip and has more layers. As mentioned on the comments above, I was having EEPROM size issues when using 4 or 5 layers.

Xinayder commented 10 months ago

I've applied the suggestions and it's compiling and working.

bladyle commented 9 months ago

Can I compile and flash this to K556 with SN32F248 MCU?

Xinayder commented 9 months ago

Can I compile and flash this to K556 with SN32F248 MCU?

yes.

sunbinyuan commented 5 months ago

Are the LEDs still flickering in this new version? Waiting for this to work so I can port it to the K582.

I finally got around and tried porting this to k582. After comparing with the old branch sn32_master_stable, I noticed there weren't a lot of changes, if any. I proceeded to build the firmware for the k582 then flashed it. However, it seem the firmware wasn't very stable, and as I started typing faster, the keyboard started freezing (with spasming RGB light) and wouldn't accept any input unless I unplug and replug the keyboard. I also tried with the unchanged k556 firmware from sn32_develop but I am getting the same issue.

I tried going back to an older build from the k582 from the sn32_master_stable branch and don't seem to have any issue with keyboard freezing, except for the flickering. Really not sure what is happening.

Is there anyway to debug the reason of the freeze?

My branch here (merged the latest QMK changes): https://github.com/sunbinyuan/sonixqmk_firmware/tree/sn32_develop

gwagner613 commented 3 months ago

Would this work for k556 dharma, the tkl wired version?

Xinayder commented 3 months ago

Would this work for k556 dharma, the tkl wired version?

If the hardware mapping didn't change, then yes (that is, if the RGB/key matrix didn't change and use the same mappings as the 100% version). You can try uploading the firmware file to your keyboard and check if everything works.