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

If RGBLIGHT_EFFECT_BREATHE_CENTER is undefined, use fixed breathe table instead of exp() and sin() #5484

Merged
merged 3 commits into from
May 2, 2019

Conversation

mtei
Copy link
Contributor

@mtei mtei commented Mar 25, 2019

Description

This is alternative (radical) version of #5480.

Changed rgblight.c's breathing effect to use a fixed table instead of calculating with exp() and sin(). This change reduces the size of the firmware when using the rgblight breathing effect.

I could not decide whether to adopt #5480 or this. So I presented both.
This is the result of compilation smaller than #5480, so use this.

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

add RGBLIGHT_BREATHE_TABLE_SIZE macro for customize breathing effect.
@Lenbok
Copy link
Contributor

Lenbok commented Apr 3, 2019

I've been testing this one for the last few days, it gives a nice reduction in firmware size!

@drashna
Copy link
Member

drashna commented Apr 3, 2019

Is it possible to specify a custom table for this?

@Lenbok
Copy link
Contributor

Lenbok commented Apr 3, 2019

@drashna In the top of rgblight_breathing_table_calc.c it tells you how to generate a custom table for your keymap.

@drashna
Copy link
Member

drashna commented Apr 3, 2019

Ah, I missed that.

And I see that if you add the define for the table in a config.h, you can use your own.

@drashna
Copy link
Member

drashna commented Apr 30, 2019

It's not really in the scope of this PR, but unfortunately, you cannot use the userspace folder to host the file. It has to be in a keymap file. Which is unfortunate.

Otherwise, it looks good!

@mtei
Copy link
Contributor Author

mtei commented Apr 30, 2019

The current makefile system has a search path set as follows:

$ make crkbd:drashna
....
$ cat .build/obj_crkbd_rev1_drashna/cflags.txt | tr ' ' '\n' | grep ^-I
-Ikeyboards/crkbd/keymaps/drashna       ** keymap **
-Ikeyboards/.
-Ikeyboards/.
-Ikeyboards/.
-Ikeyboards/crkbd
-Ikeyboards/crkbd/rev1
-I.
-Itmk_core
-Iquantum                               ** quantum **
-Iquantum/keymap_extras
-Iquantum/audio
-Iquantum/process_keycode
-Iquantum/api
-Idrivers
-Iquantum/serial_link
-Idrivers/oled
-Idrivers/avr
-Iusers/drashna                         ** users ***
-Itmk_core/protocol
-Itmk_core/common
-Itmk_core/protocol/lufa
-Ilib/lufa

I feel that it is ideal to change build_keyboard.mk as follows.

diff --git a/build_keyboard.mk b/build_keyboard.mk
index 5d633f271..510923ebe 100644
--- a/build_keyboard.mk
+++ b/build_keyboard.mk
@@ -334,9 +334,9 @@ SRC += $(KEYBOARD_SRC) \
 
 # Search Path
 VPATH += $(KEYMAP_PATH)
+VPATH += $(USER_PATH)
 VPATH += $(KEYBOARD_PATHS)
 VPATH += $(COMMON_VPATH)
-VPATH += $(USER_PATH)
 
 include common_features.mk
 include $(TMK_PATH)/protocol.mk

However, the easiest way is the following.

diff --git a/users/drashna/rules.mk b/users/drashna/rules.mk
index bef25e259..37554489d 100644
--- a/users/drashna/rules.mk
+++ b/users/drashna/rules.mk
@@ -1,3 +1,4 @@
+VPATH += $(USER_PATH)
 SRC += drashna.c \
        process_records.c

@mtei
Copy link
Contributor Author

mtei commented Apr 30, 2019

Another way is to do the following:

$ ./util/rgblight_breathing_table_calc > users/drashna/breathe_table.h
$ echo "#include <breathe_table.h>" > keyboards/crkbd/keymaps/drashna/rgblight_breathe_table.h

@drashna
Copy link
Member

drashna commented May 2, 2019

Thanks for the info!

I think the changes to build_keyboard.mk is the best option, long term. But outside the scope of this PR. Until that change drops, the change to the userspace looks fine.

Also, I've tested the code, and it works perfectly. I don't see any issues with it, and I do see a drop in the firmware size. And I'd like to see this merged sooner, rather than later.

Also, a similar change for the rgb matrix feature may be a good idea, for the future.

drashna added a commit to drashna/qmk_firmware that referenced this pull request May 2, 2019
Specifically, to fix some edge cases, and keep the handling consistent, the userspace folder should not actually be added at the end.  Ideally, it should be added after the keymap paths, but before the keyboard's path.

This issue was discovered in qmk#5484, and the fix created by mtei.
@drashna drashna mentioned this pull request May 2, 2019
13 tasks
Copy link
Contributor

@mechmerlin mechmerlin left a comment

Choose a reason for hiding this comment

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

Thanks!

@mechmerlin mechmerlin merged commit 3da8d46 into qmk:master May 2, 2019
mechmerlin pushed a commit that referenced this pull request May 2, 2019
Specifically, to fix some edge cases, and keep the handling consistent, the userspace folder should not actually be added at the end.  Ideally, it should be added after the keymap paths, but before the keyboard's path.

This issue was discovered in #5484, and the fix created by mtei.
drashna pushed a commit to zsa/qmk_firmware that referenced this pull request May 2, 2019
…le instead of exp() and sin() (qmk#5484)

* If RGBLIGHT_EFFECT_BREATHE_CENTER is undefined, use fixed breathe table instead of exp() and sin()

* Change rgblight breathing table size to be easily selectable.

add RGBLIGHT_BREATHE_TABLE_SIZE macro for customize breathing effect.
foosinn pushed a commit to foosinn/qmk_firmware that referenced this pull request May 6, 2019
…le instead of exp() and sin() (qmk#5484)

* If RGBLIGHT_EFFECT_BREATHE_CENTER is undefined, use fixed breathe table instead of exp() and sin()

* Change rgblight breathing table size to be easily selectable.

add RGBLIGHT_BREATHE_TABLE_SIZE macro for customize breathing effect.
foosinn pushed a commit to foosinn/qmk_firmware that referenced this pull request May 6, 2019
Specifically, to fix some edge cases, and keep the handling consistent, the userspace folder should not actually be added at the end.  Ideally, it should be added after the keymap paths, but before the keyboard's path.

This issue was discovered in qmk#5484, and the fix created by mtei.
@mtei mtei deleted the rgblight_breathing_table_radical branch May 11, 2019 06:41
Timbus pushed a commit to Timbus/qmk_firmware that referenced this pull request Jun 23, 2019
…le instead of exp() and sin() (qmk#5484)

* If RGBLIGHT_EFFECT_BREATHE_CENTER is undefined, use fixed breathe table instead of exp() and sin()

* Change rgblight breathing table size to be easily selectable.

add RGBLIGHT_BREATHE_TABLE_SIZE macro for customize breathing effect.
Timbus pushed a commit to Timbus/qmk_firmware that referenced this pull request Jun 23, 2019
Specifically, to fix some edge cases, and keep the handling consistent, the userspace folder should not actually be added at the end.  Ideally, it should be added after the keymap paths, but before the keyboard's path.

This issue was discovered in qmk#5484, and the fix created by mtei.
ridingqwerty pushed a commit to ridingqwerty/qmk_firmware that referenced this pull request Jan 10, 2020
…le instead of exp() and sin() (qmk#5484)

* If RGBLIGHT_EFFECT_BREATHE_CENTER is undefined, use fixed breathe table instead of exp() and sin()

* Change rgblight breathing table size to be easily selectable.

add RGBLIGHT_BREATHE_TABLE_SIZE macro for customize breathing effect.
ridingqwerty pushed a commit to ridingqwerty/qmk_firmware that referenced this pull request Jan 10, 2020
Specifically, to fix some edge cases, and keep the handling consistent, the userspace folder should not actually be added at the end.  Ideally, it should be added after the keymap paths, but before the keyboard's path.

This issue was discovered in qmk#5484, and the fix created by mtei.
JeffreyPalmer pushed a commit to JeffreyPalmer/qmk_firmware that referenced this pull request Feb 27, 2020
…le instead of exp() and sin() (qmk#5484)

* If RGBLIGHT_EFFECT_BREATHE_CENTER is undefined, use fixed breathe table instead of exp() and sin()

* Change rgblight breathing table size to be easily selectable.

add RGBLIGHT_BREATHE_TABLE_SIZE macro for customize breathing effect.
JeffreyPalmer pushed a commit to JeffreyPalmer/qmk_firmware that referenced this pull request Feb 27, 2020
Specifically, to fix some edge cases, and keep the handling consistent, the userspace folder should not actually be added at the end.  Ideally, it should be added after the keymap paths, but before the keyboard's path.

This issue was discovered in qmk#5484, and the fix created by mtei.
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.

None yet

4 participants