Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moonlander: Add RGB LED layout map macro #18745

Merged
merged 1 commit into from
Dec 8, 2022

Conversation

joukewitteveen
Copy link
Contributor

Description

A macro that allows pretty definitions of RGB LED maps. The macro name LED_LAYOUT_moonlander is rather generic, maybe RGB_LAYOUT_moonlander was better, but it is in line with the macro name used for ergodox_ez (LED_LAYOUT_ergodox_pretty) and the name used for the keyhive sofle (LED_LAYOUT).

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout/userspace (addition or update)
  • Documentation

Checklist

  • My code follows the code style of this project: C, Python
  • I have read the PR Checklist document and have made the appropriate changes.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

@drashna drashna requested a review from a team October 21, 2022 02:05
@joukewitteveen
Copy link
Contributor Author

This PR is the result of a piece of documentation:

Do not lump features in with keymap PR’s. Submit the feature first and then a second PR for the keymap.

In other words, I would like to use the macro proposed here in a keymap that I intend to open a merge request for.

@drashna drashna requested a review from a team November 8, 2022 18:36
@joukewitteveen joukewitteveen force-pushed the moonlander-led-layout branch 2 times, most recently from 14d7629 to 8b5a886 Compare November 26, 2022 12:49
Copy link
Contributor Author

@joukewitteveen joukewitteveen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added usage of the led layout macro to the keyboard source and discover some oddities in the coordinate map.

1, 4, 4, 4, 4, 4,
4, 4, 1, 1, 1, 1
} };
}, LED_LAYOUT_moonlander(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, qmk lint (lib/python/qmk/c_parse.py) does not like the use of macros here. Reverting would be easy, but using this macro brought to light some issues, so there is value in using a macro here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See this thread #18973 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe g_led_config can be represented in info.json yet, can it? I guess the benefits provided by using a macro here (i.e. catching mapping oddities) are out of reach to the DD approach, or are there some cool plans in this direction?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible, but a lot of the data-driven stuff is not well documented just yet, and some things are only in develop (which should merge in a day or so).
https://github.com/qmk/qmk_firmware/blob/master/keyboards/1upkeyboards/pi60_hse/info.json#L31-L51
https://github.com/qmk/qmk_firmware/blob/master/data/schemas/keyboard.jsonschema#L294-L320

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, unfortunately the order in the json file is the LED indexing order. This precludes generating a layout macro from them automatically. Automatic generation on the basis of a key layout is possible, but only if every led has a position on the matrix that also has a key assigned to it. Even then, it is quite involved and we don't have a way to configure the name of the macro (LED_{layout_name} is possible, though).

I guess for now this leaves no other option than to set the LED layout macro the old fashioned way in moonlander.h, but revert its usage in defining g_led_config. I'll do that once I know what to do with the weird positions currently set in g_led_config.

4, 4, 1, 1, 1, 1
} };
}, LED_LAYOUT_moonlander(
{ 0, 0 }, { 17, 0 }, { 34, 0 }, { 51, 0 }, { 68, 0 }, { 86, 0 }, { 105, 0 }, { 146, 0 }, { 163, 0 }, { 181, 0 }, { 198, 0 }, { 216, 0 }, { 233, 0 }, { 250, 0 },
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noted that the steps in the x-coordinate are uneven. They are mostly 17, but between 86 and 105 is a step size of 19. Also, the distribution of some excess horizontal spacing is uneven: the columns between which we have a step size of 18 differ between the left and right halves.

Moreover, the midpoint (set to 125) is not halfway between 105 and 146.

{ 0, 25 }, { 17, 25 }, { 34, 25 }, { 51, 25 }, { 68, 25 }, { 86, 25 }, { 105, 25 }, { 146, 25 }, { 163, 25 }, { 181, 25 }, { 198, 25 }, { 216, 25 }, { 233, 25 }, { 250, 25 },
{ 0, 38 }, { 17, 38 }, { 34, 38 }, { 51, 38 }, { 68, 38 }, { 86, 38 }, { 105, 38 }, { 146, 38 }, { 163, 38 }, { 181, 38 }, { 198, 38 }, { 216, 38 }, { 233, 38 }, { 250, 38 },
{ 0, 51 }, { 17, 51 }, { 34, 51 }, { 51, 51 }, { 68, 51 }, { 116, 59 }, { 131, 59 }, { 181, 51 }, { 198, 51 }, { 216, 51 }, { 233, 51 }, { 250, 51 },
{ 90, 55 }, { 105, 68 }, { 116, 86 }, { 146, 86 }, { 161, 68 }, { 161, 55 }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something weird is going on with the column coordinates of the right thumb cluster. The coordinates in the left thumb cluster seem reasonable.

Before addressing this or the other layout issue, I would like to know how these coordinates were obtained. @drashna, do you know?

And fix led positions. Mistakes were uncovered when introducing the LED
layout map macro to the definition of g_led_config, but that had to be
reverted because our tooling does not expand macros yet wants to  read
the led configuration.
@tzarc tzarc merged commit c9fe884 into qmk:develop Dec 8, 2022
omikronik pushed a commit to omikronik/qmk_firmware that referenced this pull request Jan 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants