diff options
| author | Takeshi ISHII <2170248+mtei@users.noreply.github.com> | 2020-03-10 17:46:03 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-10 01:46:03 -0700 |
| commit | dbbab409812ea7c579760e2973399245c21ff843 (patch) | |
| tree | b19d9baf161435f61abd48b0ba00f5907cd61ecc /quantum/rgblight.h | |
| parent | 20a0fa9209756288b014f65671bcaab12a028229 (diff) | |
| download | qmk_firmware-dbbab409812ea7c579760e2973399245c21ff843.tar.gz qmk_firmware-dbbab409812ea7c579760e2973399245c21ff843.zip | |
Refactor rgblight_reconfig.h (#7773)
* Moved contents of rgblight_reconfig.h to rgblight_post_config.h.
In #3582, rgblight_reconfig.h had to be newly created. Now, the build system of qmk_firmware has a post_cofig feature, so that what was done in rgblight_reconfig.h can now be realized in rgblight_post_config.h.
**This commit does not change the build result.**
Testing script
```shell
# build on master
git checkout master
echo master > /tmp/master_md5.txt
# RGBLIGHT_ENABLE = no
make HELIX=verbose helix/rev2:default:clean
make HELIX=verbose helix/rev2:default
md5 helix_rev2_default.hex >> /tmp/master_md5.txt
# RGBLIGHT_ENABLE = yes, with animations
make HELIX=verbose helix/rev2/back:default:clean
make HELIX=verbose helix/rev2/back:default
md5 helix_rev2_back_default.hex >> /tmp/master_md5.txt
# RGBLIGHT_ENABLE = yes, without animations
make HELIX=verbose,no_ani helix/rev2/back:default:clean
make HELIX=verbose,no_ani helix/rev2/back:default
md5 helix_rev2_back_default.hex >> /tmp/master_md5.txt
# build on refactor_rgblight_reconfig.h
git checkout refactor_rgblight_reconfig.h
echo refactor_rgblight_reconfig.h > /tmp/branch_md5.txt
# RGBLIGHT_ENABLE = no
make HELIX=verbose helix/rev2:default:clean
make HELIX=verbose helix/rev2:default
md5 helix_rev2_default.hex >> /tmp/branch_md5.txt
# RGBLIGHT_ENABLE = yes, with animations
make HELIX=verbose helix/rev2/back:default:clean
make HELIX=verbose helix/rev2/back:default
md5 helix_rev2_back_default.hex >> /tmp/branch_md5.txt
# RGBLIGHT_ENABLE = yes, without animations
make HELIX=verbose,no_ani helix/rev2/back:default:clean
make HELIX=verbose,no_ani helix/rev2/back:default
md5 helix_rev2_back_default.hex >> /tmp/branch_md5.txt
diff -u /tmp/master_md5.txt /tmp/branch_md5.txt
```
Test result:
```
--- /tmp/master_md5.txt 2020-01-03 15:42:22.000000000 +0900
+++ /tmp/branch_md5.txt 2020-01-03 15:42:42.000000000 +0900
@@ -1,4 +1,4 @@
-master
+refactor_rgblight_reconfig.h
MD5 (helix_rev2_default.hex) = f360032edd522448366d471d8f4f8181
MD5 (helix_rev2_back_default.hex) = 0c663acc6cccc44476b3b969ad22a48f
MD5 (helix_rev2_back_default.hex) = e66b1195ff6d38e6e22c975b8ae42fd3
```
* Expressions that are too long are difficult to read, so wrap them.
* Edit the expression again
* remove `defined(RGBLIGHT_ANIMATIONS)` in `tmk_core/common/*/suspend.c`, `tmk_core/protocol/*/main.c`
move contents of rgblight_reconfig.h to rgblight.h.
The following changes were made to rgblight.h.
```diff
+#ifdef RGBLIGHT_USE_TIMER
void rgblight_task(void);
void rgblight_timer_init(void);
void rgblight_timer_enable(void);
void rgblight_timer_disable(void);
void rgblight_timer_toggle(void);
+#else
+#define rgblight_task()
+#define rgblight_timer_init()
+#define rgblight_timer_enable()
+#define rgblight_timer_disable()
+#define rgblight_timer_toggle()
+#endif
```
The following changes were made to tmk_core/common/avr/suspend.c, tmk_core/common/chibios/suspend.c, tmk_core/protocol/chibios/main.c, tmk_core/protocol/lufa/lufa.c, tmk_core/protocol/vusb/main.c.
```diff
-# ifdef RGBLIGHT_ANIMATIONS
rgblight_timer_enable();
-# endif
```
```diff
-#if defined(RGBLIGHT_ANIMATIONS) && defined(RGBLIGHT_ENABLE)
+#if defined(RGBLIGHT_ENABLE)
rgblight_task();
#endif
```
* remove 'defined(RGBLIGHT_ANIMATIONS)' in tmk_core/common/keyboard.c
Co-authored-by: Joel Challis <git@zvecr.com>
Diffstat (limited to 'quantum/rgblight.h')
| -rw-r--r-- | quantum/rgblight.h | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/quantum/rgblight.h b/quantum/rgblight.h index c0fc0f3c6..39c4c2784 100644 --- a/quantum/rgblight.h +++ b/quantum/rgblight.h | |||
| @@ -16,8 +16,6 @@ | |||
| 16 | #ifndef RGBLIGHT_H | 16 | #ifndef RGBLIGHT_H |
| 17 | #define RGBLIGHT_H | 17 | #define RGBLIGHT_H |
| 18 | 18 | ||
| 19 | #include "rgblight_reconfig.h" | ||
| 20 | |||
| 21 | /***** rgblight_mode(mode)/rgblight_mode_noeeprom(mode) **** | 19 | /***** rgblight_mode(mode)/rgblight_mode_noeeprom(mode) **** |
| 22 | 20 | ||
| 23 | old mode number (before 0.6.117) to new mode name table | 21 | old mode number (before 0.6.117) to new mode name table |
| @@ -64,6 +62,39 @@ | |||
| 64 | |-----------------|-----------------------------------| | 62 | |-----------------|-----------------------------------| |
| 65 | *****/ | 63 | *****/ |
| 66 | 64 | ||
| 65 | #ifdef RGBLIGHT_ANIMATIONS | ||
| 66 | // for backward compatibility | ||
| 67 | # define RGBLIGHT_EFFECT_BREATHING | ||
| 68 | # define RGBLIGHT_EFFECT_RAINBOW_MOOD | ||
| 69 | # define RGBLIGHT_EFFECT_RAINBOW_SWIRL | ||
| 70 | # define RGBLIGHT_EFFECT_SNAKE | ||
| 71 | # define RGBLIGHT_EFFECT_KNIGHT | ||
| 72 | # define RGBLIGHT_EFFECT_CHRISTMAS | ||
| 73 | # define RGBLIGHT_EFFECT_STATIC_GRADIENT | ||
| 74 | # define RGBLIGHT_EFFECT_RGB_TEST | ||
| 75 | # define RGBLIGHT_EFFECT_ALTERNATING | ||
| 76 | #endif | ||
| 77 | |||
| 78 | #ifdef RGBLIGHT_STATIC_PATTERNS | ||
| 79 | # define RGBLIGHT_EFFECT_STATIC_GRADIENT | ||
| 80 | #endif | ||
| 81 | |||
| 82 | // clang-format off | ||
| 83 | |||
| 84 | // check dynamic animation effects chose ? | ||
| 85 | #if defined(RGBLIGHT_EFFECT_BREATHING) \ | ||
| 86 | || defined(RGBLIGHT_EFFECT_RAINBOW_MOOD) \ | ||
| 87 | || defined(RGBLIGHT_EFFECT_RAINBOW_SWIRL) \ | ||
| 88 | || defined(RGBLIGHT_EFFECT_SNAKE) \ | ||
| 89 | || defined(RGBLIGHT_EFFECT_KNIGHT) \ | ||
| 90 | || defined(RGBLIGHT_EFFECT_CHRISTMAS) \ | ||
| 91 | || defined(RGBLIGHT_EFFECT_RGB_TEST) \ | ||
| 92 | || defined(RGBLIGHT_EFFECT_ALTERNATING) | ||
| 93 | # define RGBLIGHT_USE_TIMER | ||
| 94 | #endif | ||
| 95 | |||
| 96 | // clang-format on | ||
| 97 | |||
| 67 | #define _RGBM_SINGLE_STATIC(sym) RGBLIGHT_MODE_##sym, | 98 | #define _RGBM_SINGLE_STATIC(sym) RGBLIGHT_MODE_##sym, |
| 68 | #define _RGBM_SINGLE_DYNAMIC(sym) RGBLIGHT_MODE_##sym, | 99 | #define _RGBM_SINGLE_DYNAMIC(sym) RGBLIGHT_MODE_##sym, |
| 69 | #define _RGBM_MULTI_STATIC(sym) RGBLIGHT_MODE_##sym, | 100 | #define _RGBM_MULTI_STATIC(sym) RGBLIGHT_MODE_##sym, |
| @@ -263,12 +294,19 @@ void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom); | |||
| 263 | # define EZ_RGB(val) rgblight_show_solid_color((val >> 16) & 0xFF, (val >> 8) & 0xFF, val & 0xFF) | 294 | # define EZ_RGB(val) rgblight_show_solid_color((val >> 16) & 0xFF, (val >> 8) & 0xFF, val & 0xFF) |
| 264 | void rgblight_show_solid_color(uint8_t r, uint8_t g, uint8_t b); | 295 | void rgblight_show_solid_color(uint8_t r, uint8_t g, uint8_t b); |
| 265 | 296 | ||
| 297 | #ifdef RGBLIGHT_USE_TIMER | ||
| 266 | void rgblight_task(void); | 298 | void rgblight_task(void); |
| 267 | |||
| 268 | void rgblight_timer_init(void); | 299 | void rgblight_timer_init(void); |
| 269 | void rgblight_timer_enable(void); | 300 | void rgblight_timer_enable(void); |
| 270 | void rgblight_timer_disable(void); | 301 | void rgblight_timer_disable(void); |
| 271 | void rgblight_timer_toggle(void); | 302 | void rgblight_timer_toggle(void); |
| 303 | #else | ||
| 304 | #define rgblight_task() | ||
| 305 | #define rgblight_timer_init() | ||
| 306 | #define rgblight_timer_enable() | ||
| 307 | #define rgblight_timer_disable() | ||
| 308 | #define rgblight_timer_toggle() | ||
| 309 | #endif | ||
| 272 | 310 | ||
| 273 | # ifdef RGBLIGHT_SPLIT | 311 | # ifdef RGBLIGHT_SPLIT |
| 274 | # define RGBLIGHT_STATUS_CHANGE_MODE (1 << 0) | 312 | # define RGBLIGHT_STATUS_CHANGE_MODE (1 << 0) |
