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

sn32 rgb: yet another major update - more modularity #369

Merged
merged 19 commits into from
Sep 17, 2024

Conversation

dexter93
Copy link

@dexter93 dexter93 commented Jan 2, 2024

  • Decouple key and rgb matrix scanning. Not always required - can live as a standalone rgb driver now
  • init bugfixes for SN32_PWM_OUTPUT_ACTIVE_LOW
  • configuration cleanup - everything is now in a header
  • remove most hardcoded values, inherit and/or calculate instead
  • driver renamed
  • added 26x support
  • introducing individual ( per channel) color correction/ luminosity fine tuning

Description

Types of Changes

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

Issues Fixed or Closed by This PR

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).

@dexter93 dexter93 force-pushed the sn32_rgb_v3 branch 2 times, most recently from 837aee2 to 9989fdc Compare January 2, 2024 18:01
@dexter93 dexter93 force-pushed the sn32_rgb_v3 branch 5 times, most recently from 257f08e to 456a43a Compare January 3, 2024 09:54
@fightforlife
Copy link

Working good for me on 268F with ROW2COL. But I had two things to change to make it perfect.
Maybe a second board/user would be good to make sure these are no issues on my side/config.

Here I need to use current_key_col vs last_key_col, otherwise the keypress effects are lit one to the left.

# if (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_HIGH)
writePinHigh(led_col_pins[last_key_col]);
# elif (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_LOW)
writePinLow(led_col_pins[last_key_col]);
# endif // SN32_RGB_OUTPUT_ACTIVE_LEVEL

This is also needed for HARDWARE_PWM. If not included, columns which have not the max amount of keys(rows) will light the last key all the time.

# if (SN32_PWM_CONTROL == SOFTWARE_PWM)
if (led_index >= SN32F2XX_LED_COUNT) continue;
# endif // SN32_PWM_CONTROL

# if (SN32_PWM_CONTROL == SOFTWARE_PWM)
if (led_index >= SN32F2XX_LED_COUNT) continue;
# endif

@github-actions github-actions bot added the stale label Feb 18, 2024
@dexter93 dexter93 removed the stale label Feb 21, 2024
@github-actions github-actions bot added the stale label Apr 7, 2024
@dexter93 dexter93 removed the stale label Apr 7, 2024
@SonixQMK SonixQMK deleted a comment from github-actions bot Apr 7, 2024
@SonixQMK SonixQMK deleted a comment from github-actions bot Apr 7, 2024
@github-actions github-actions bot added the stale label May 23, 2024
@SonixQMK SonixQMK deleted a comment from github-actions bot Jun 5, 2024
@dexter93 dexter93 removed the stale label Jun 5, 2024
@github-actions github-actions bot added the dd label Jun 20, 2024
Copy link

@fightforlife fightforlife left a comment

Choose a reason for hiding this comment

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

Tested on K66 v1 with ROW2COL hardware PWM shared matrix.
With these 3 changes it is working very good for me.

drivers/led/sn32f2xx.c Outdated Show resolved Hide resolved
}
bool enable_pwm_output = false;
for (uint8_t current_key_col = 0; current_key_col < SN32_RGB_MATRIX_COLS; current_key_col++) {
uint8_t led_index = g_led_config.matrix_co[current_key_row][current_key_col];
# if (SN32_PWM_CONTROL == SOFTWARE_PWM)
if (led_index >= SN32F24XB_LED_COUNT) continue;
if (led_index >= SN32F2XX_LED_COUNT) continue;

Choose a reason for hiding this comment

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

For me this line is necessary also for hardware PWM.
If this is not used the last keys in cols which have less then the standard amount of keys. (e.g. just 4 than normally 5) will light up dimly.

@@ -380,7 +500,7 @@ static void update_pwm_channels(PWMDriver *pwmp) {
for (uint8_t current_key_row = 0; current_key_row < MATRIX_ROWS; current_key_row++) {
uint8_t led_index = g_led_config.matrix_co[current_key_row][current_key_col];
# if (SN32_PWM_CONTROL == SOFTWARE_PWM)
if (led_index >= SN32F24XB_LED_COUNT) continue;
if (led_index >= SN32F2XX_LED_COUNT) continue;

Choose a reason for hiding this comment

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

For me this line is necessary also for hardware PWM.
If this is not used the last keys in cols which have less then the standard amount of keys. (e.g. just 4 than normally 5) will light up dimly.

@@ -380,7 +500,7 @@ static void update_pwm_channels(PWMDriver *pwmp) {
for (uint8_t current_key_row = 0; current_key_row < MATRIX_ROWS; current_key_row++) {
uint8_t led_index = g_led_config.matrix_co[current_key_row][current_key_col];
# if (SN32_PWM_CONTROL == SOFTWARE_PWM)
if (led_index >= SN32F24XB_LED_COUNT) continue;
if (led_index >= SN32F2XX_LED_COUNT) continue;
# endif
uint8_t led_row_id = (current_key_row * SN32_RGB_MATRIX_ROW_CHANNELS);
// Check if we need to enable RGB output

Choose a reason for hiding this comment

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

In line 519 and 521 I need current_key_col instead of last_key_col.
Otherwise the keypress effects are shifted one col to the left.

    // Enable RGB output
    if (enable_pwm_output) {
#        if (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_HIGH)
        writePinHigh(led_col_pins[current_key_col  ]);
#        elif (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_LOW)
        writePinLow(led_col_pins[current_key_col  ]);
#        endif // SN32_RGB_OUTPUT_ACTIVE_LEVEL
    }

@github-actions github-actions bot added the stale label Aug 27, 2024
@SonixQMK SonixQMK deleted a comment from github-actions bot Aug 28, 2024
@dexter93
Copy link
Author

@fightforlife after revisiting this and updating ROW2COL scenario, I could not reproduce your issues. If they persist, they are probably related to indexing on your specific board/setup

@dexter93 dexter93 merged commit bfbfc84 into SonixQMK:sn32_develop Sep 17, 2024
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants