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 /tmk_core/common/avr | |
| 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 'tmk_core/common/avr')
| -rw-r--r-- | tmk_core/common/avr/suspend.c | 22 | ||||
| -rw-r--r-- | tmk_core/common/avr/suspend_avr.h | 33 |
2 files changed, 17 insertions, 38 deletions
diff --git a/tmk_core/common/avr/suspend.c b/tmk_core/common/avr/suspend.c index c59c19688..11ac146eb 100644 --- a/tmk_core/common/avr/suspend.c +++ b/tmk_core/common/avr/suspend.c | |||
| @@ -9,7 +9,6 @@ | |||
| 9 | #include "timer.h" | 9 | #include "timer.h" |
| 10 | #include "led.h" | 10 | #include "led.h" |
| 11 | #include "host.h" | 11 | #include "host.h" |
| 12 | #include "rgblight_reconfig.h" | ||
| 13 | 12 | ||
| 14 | #ifdef PROTOCOL_LUFA | 13 | #ifdef PROTOCOL_LUFA |
| 15 | # include "lufa.h" | 14 | # include "lufa.h" |
| @@ -30,23 +29,6 @@ static bool rgblight_enabled; | |||
| 30 | static bool is_suspended; | 29 | static bool is_suspended; |
| 31 | #endif | 30 | #endif |
| 32 | 31 | ||
| 33 | #define wdt_intr_enable(value) \ | ||
| 34 | __asm__ __volatile__("in __tmp_reg__,__SREG__" \ | ||
| 35 | "\n\t" \ | ||
| 36 | "cli" \ | ||
| 37 | "\n\t" \ | ||
| 38 | "wdr" \ | ||
| 39 | "\n\t" \ | ||
| 40 | "sts %0,%1" \ | ||
| 41 | "\n\t" \ | ||
| 42 | "out __SREG__,__tmp_reg__" \ | ||
| 43 | "\n\t" \ | ||
| 44 | "sts %0,%2" \ | ||
| 45 | "\n\t" \ | ||
| 46 | : /* no outputs */ \ | ||
| 47 | : "M"(_SFR_MEM_ADDR(_WD_CONTROL_REG)), "r"(_BV(_WD_CHANGE_BIT) | _BV(WDE)), "r"((uint8_t)((value & 0x08 ? _WD_PS3_MASK : 0x00) | _BV(WDIE) | (value & 0x07))) \ | ||
| 48 | : "r0") | ||
| 49 | |||
| 50 | /** \brief Suspend idle | 32 | /** \brief Suspend idle |
| 51 | * | 33 | * |
| 52 | * FIXME: needs doc | 34 | * FIXME: needs doc |
| @@ -122,9 +104,7 @@ static void power_down(uint8_t wdto) { | |||
| 122 | // stop_all_notes(); | 104 | // stop_all_notes(); |
| 123 | # endif /* AUDIO_ENABLE */ | 105 | # endif /* AUDIO_ENABLE */ |
| 124 | # if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) | 106 | # if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) |
| 125 | # ifdef RGBLIGHT_ANIMATIONS | ||
| 126 | rgblight_timer_disable(); | 107 | rgblight_timer_disable(); |
| 127 | # endif | ||
| 128 | if (!is_suspended) { | 108 | if (!is_suspended) { |
| 129 | is_suspended = true; | 109 | is_suspended = true; |
| 130 | rgblight_enabled = rgblight_config.enable; | 110 | rgblight_enabled = rgblight_config.enable; |
| @@ -204,9 +184,7 @@ void suspend_wakeup_init(void) { | |||
| 204 | # endif | 184 | # endif |
| 205 | rgblight_enable_noeeprom(); | 185 | rgblight_enable_noeeprom(); |
| 206 | } | 186 | } |
| 207 | # ifdef RGBLIGHT_ANIMATIONS | ||
| 208 | rgblight_timer_enable(); | 187 | rgblight_timer_enable(); |
| 209 | # endif | ||
| 210 | #endif | 188 | #endif |
| 211 | suspend_wakeup_init_kb(); | 189 | suspend_wakeup_init_kb(); |
| 212 | } | 190 | } |
diff --git a/tmk_core/common/avr/suspend_avr.h b/tmk_core/common/avr/suspend_avr.h index d73852ba1..e4cc0be50 100644 --- a/tmk_core/common/avr/suspend_avr.h +++ b/tmk_core/common/avr/suspend_avr.h | |||
| @@ -7,21 +7,22 @@ | |||
| 7 | #include <avr/wdt.h> | 7 | #include <avr/wdt.h> |
| 8 | #include <avr/interrupt.h> | 8 | #include <avr/interrupt.h> |
| 9 | 9 | ||
| 10 | #define wdt_intr_enable(value) \ | 10 | // clang-format off |
| 11 | __asm__ __volatile__("in __tmp_reg__,__SREG__" \ | 11 | #define wdt_intr_enable(value) \ |
| 12 | "\n\t" \ | 12 | __asm__ __volatile__ ( \ |
| 13 | "cli" \ | 13 | "in __tmp_reg__,__SREG__" "\n\t" \ |
| 14 | "\n\t" \ | 14 | "cli" "\n\t" \ |
| 15 | "wdr" \ | 15 | "wdr" "\n\t" \ |
| 16 | "\n\t" \ | 16 | "sts %0,%1" "\n\t" \ |
| 17 | "sts %0,%1" \ | 17 | "out __SREG__,__tmp_reg__" "\n\t" \ |
| 18 | "\n\t" \ | 18 | "sts %0,%2" "\n\t" \ |
| 19 | "out __SREG__,__tmp_reg__" \ | 19 | : /* no outputs */ \ |
| 20 | "\n\t" \ | 20 | : "M" (_SFR_MEM_ADDR(_WD_CONTROL_REG)), \ |
| 21 | "sts %0,%2" \ | 21 | "r" (_BV(_WD_CHANGE_BIT) | _BV(WDE)), \ |
| 22 | "\n\t" \ | 22 | "r" ((uint8_t) ((value & 0x08 ? _WD_PS3_MASK : 0x00) | \ |
| 23 | : /* no outputs */ \ | 23 | _BV(WDIE) | (value & 0x07)) ) \ |
| 24 | : "M"(_SFR_MEM_ADDR(_WD_CONTROL_REG)), "r"(_BV(_WD_CHANGE_BIT) | _BV(WDE)), "r"((uint8_t)((value & 0x08 ? _WD_PS3_MASK : 0x00) | _BV(WDIE) | (value & 0x07))) \ | 24 | : "r0" \ |
| 25 | : "r0") | 25 | ) |
| 26 | // clang-format on | ||
| 26 | 27 | ||
| 27 | #endif | 28 | #endif |
