summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml4
-rw-r--r--build_keyboard.mk2
-rw-r--r--changelog.md3
-rw-r--r--common_features.mk1
-rw-r--r--drivers/avr/ws2812.c2
-rw-r--r--quantum/color.c9
-rw-r--r--quantum/led_tables.c48
-rw-r--r--quantum/mcu_selection.mk1
-rw-r--r--quantum/process_keycode/process_space_cadet.c39
-rw-r--r--quantum/process_keycode/process_space_cadet.h2
-rw-r--r--quantum/rgb_matrix.c7
-rw-r--r--quantum/rgb_matrix_animations/solid_reactive_anim.h3
-rw-r--r--quantum/rgb_matrix_animations/solid_reactive_simple_anim.h3
-rw-r--r--quantum/rgb_matrix_drivers.c4
-rw-r--r--quantum/rgblight.c212
-rw-r--r--quantum/rgblight.h31
-rw-r--r--quantum/rgblight_breathe_table.h116
-rw-r--r--quantum/rgblight_list.h32
-rw-r--r--quantum/stm32/proton_c.mk1
-rw-r--r--quantum/template/avr/config.h6
-rw-r--r--tmk_core/chibios.mk5
-rw-r--r--util/rgblight_breathing_table_calc.c49
22 files changed, 340 insertions, 240 deletions
diff --git a/.travis.yml b/.travis.yml
index 194c469b22..66b79139e6 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,10 +13,14 @@ env:
- MAKEFLAGS="-j3 --output-sync"
before_install:
- wget http://ww1.microchip.com/downloads/en/DeviceDoc/avr8-gnu-toolchain-3.5.4.1709-linux.any.x86_64.tar.gz || wget http://qmk.fm/avr8-gnu-toolchain-3.5.4.1709-linux.any.x86_64.tar.gz
+ # Need DFU > .5 for dfu-suffix
+ - sudo add-apt-repository --yes ppa:tormodvolden/ppa
+ - sudo apt-get update -qq
install:
- tar -zxf avr8-gnu-toolchain-3.5.4.1709-linux.any.x86_64.tar.gz
- export PATH="$PATH:$TRAVIS_BUILD_DIR/avr8-gnu-toolchain-linux_x86_64/bin"
- npm install -g moxygen
+ - sudo apt-get -y --force-yes install dfu-util
before_script:
- avr-gcc --version
script:
diff --git a/build_keyboard.mk b/build_keyboard.mk
index 5d633f2716..469a947f5e 100644
--- a/build_keyboard.mk
+++ b/build_keyboard.mk
@@ -324,7 +324,6 @@ ifneq ("$(wildcard $(KEYMAP_PATH)/config.h)","")
endif
# # project specific files
-SRC += $(patsubst %.c,%.clib,$(LIB_SRC))
SRC += $(KEYBOARD_SRC) \
$(KEYMAP_C) \
$(QUANTUM_SRC)
@@ -343,6 +342,7 @@ include $(TMK_PATH)/protocol.mk
include $(TMK_PATH)/common.mk
include bootloader.mk
+SRC += $(patsubst %.c,%.clib,$(LIB_SRC))
SRC += $(patsubst %.c,%.clib,$(QUANTUM_LIB_SRC))
SRC += $(TMK_COMMON_SRC)
OPT_DEFS += $(TMK_COMMON_DEFS)
diff --git a/changelog.md b/changelog.md
index 314d3a4863..e83216cfe9 100644
--- a/changelog.md
+++ b/changelog.md
@@ -13,4 +13,5 @@
04-22-2019 - Add Split RGB support
04-24-2019 - fix LIB_SRC and QUANTUM_LIB_SRC for ARM
04-24-2019 - Add RGB Split fixes and RGB Names
-05-05-2019 - Add `LINK_TIME_OPTIMIZATION_ENABLE` to enable LTO and disable problematic features that cause LTO to fail
+05-05-2019 - Add `LINK_TIME_OPTIMIZATION_ENABLE` to enable LTO and disable problematic features that cause LTO to fail
+05-05-2019 - Fix issue with Space Cadet
diff --git a/common_features.mk b/common_features.mk
index 6dffe31ff8..7c35f07d52 100644
--- a/common_features.mk
+++ b/common_features.mk
@@ -105,6 +105,7 @@ endif
ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
POST_CONFIG_H += $(QUANTUM_DIR)/rgblight_post_config.h
OPT_DEFS += -DRGBLIGHT_ENABLE
+ SRC += $(QUANTUM_DIR)/color.c
SRC += $(QUANTUM_DIR)/rgblight.c
CIE1931_CURVE = yes
LED_BREATHING_TABLE = yes
diff --git a/drivers/avr/ws2812.c b/drivers/avr/ws2812.c
index b3ed4fd0b0..7c3cb5174d 100644
--- a/drivers/avr/ws2812.c
+++ b/drivers/avr/ws2812.c
@@ -158,7 +158,7 @@ void inline ws2812_setled(int i, uint8_t r, uint8_t g, uint8_t b)
void ws2812_setled_all (uint8_t r, uint8_t g, uint8_t b)
{
- for (int i = 0; i < RGBLED_NUM; i++) {
+ for (int i = 0; i < sizeof(led)/sizeof(led[0]); i++) {
led[i].r = r;
led[i].g = g;
led[i].b = b;
diff --git a/quantum/color.c b/quantum/color.c
index c49877592e..466e6edacb 100644
--- a/quantum/color.c
+++ b/quantum/color.c
@@ -22,8 +22,8 @@
RGB hsv_to_rgb( HSV hsv )
{
RGB rgb;
- uint8_t region, p, q, t;
- uint16_t h, s, v, remainder;
+ uint8_t region, remainder, p, q, t;
+ uint16_t h, s, v;
if ( hsv.s == 0 )
{
@@ -37,8 +37,8 @@ RGB hsv_to_rgb( HSV hsv )
s = hsv.s;
v = hsv.v;
- region = h / 43;
- remainder = (h - (region * 43)) * 6;
+ region = h * 6 / 255;
+ remainder = (h * 2 - region * 85) * 3;
p = (v * (255 - s)) >> 8;
q = (v * (255 - ((s * remainder) >> 8))) >> 8;
@@ -46,6 +46,7 @@ RGB hsv_to_rgb( HSV hsv )
switch ( region )
{
+ case 6:
case 0:
rgb.r = v;
rgb.g = t;
diff --git a/quantum/led_tables.c b/quantum/led_tables.c
index b99f262097..0eeb5c44b6 100644
--- a/quantum/led_tables.c
+++ b/quantum/led_tables.c
@@ -19,38 +19,28 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifdef USE_CIE1931_CURVE
// Lightness curve using the CIE 1931 lightness formula
//Generated by the python script provided in http://jared.geek.nz/2013/feb/linear-led-pwm
-const uint8_t CIE1931_CURVE[] PROGMEM = {
- 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 3, 3, 3, 3, 3, 3, 3,
- 3, 4, 4, 4, 4, 4, 4, 5, 5, 5,
- 5, 5, 6, 6, 6, 6, 6, 7, 7, 7,
- 7, 8, 8, 8, 8, 9, 9, 9, 10, 10,
- 10, 10, 11, 11, 11, 12, 12, 12, 13, 13,
- 13, 14, 14, 15, 15, 15, 16, 16, 17, 17,
- 17, 18, 18, 19, 19, 20, 20, 21, 21, 22,
- 22, 23, 23, 24, 24, 25, 25, 26, 26, 27,
- 28, 28, 29, 29, 30, 31, 31, 32, 32, 33,
- 34, 34, 35, 36, 37, 37, 38, 39, 39, 40,
- 41, 42, 43, 43, 44, 45, 46, 47, 47, 48,
- 49, 50, 51, 52, 53, 54, 54, 55, 56, 57,
- 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
- 68, 70, 71, 72, 73, 74, 75, 76, 77, 79,
- 80, 81, 82, 83, 85, 86, 87, 88, 90, 91,
- 92, 94, 95, 96, 98, 99, 100, 102, 103, 105,
- 106, 108, 109, 110, 112, 113, 115, 116, 118, 120,
- 121, 123, 124, 126, 128, 129, 131, 132, 134, 136,
- 138, 139, 141, 143, 145, 146, 148, 150, 152, 154,
- 155, 157, 159, 161, 163, 165, 167, 169, 171, 173,
- 175, 177, 179, 181, 183, 185, 187, 189, 191, 193,
- 196, 198, 200, 202, 204, 207, 209, 211, 214, 216,
- 218, 220, 223, 225, 228, 230, 232, 235, 237, 240,
- 242, 245, 247, 250, 252, 255,
- };
+const uint8_t CIE1931_CURVE[256] PROGMEM = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3,
+ 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6,
+ 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11,
+ 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 16, 16, 16,
+ 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24,
+ 25, 25, 26, 26, 27, 28, 28, 29, 29, 30, 31, 31, 32, 33, 33, 34,
+ 35, 35, 36, 37, 37, 38, 39, 40, 40, 41, 42, 43, 44, 44, 45, 46,
+ 47, 48, 49, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
+ 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 75, 76, 77, 78,
+ 79, 80, 82, 83, 84, 85, 87, 88, 89, 90, 92, 93, 94, 96, 97, 99,
+100, 101, 103, 104, 106, 107, 108, 110, 111, 113, 114, 116, 118, 119, 121, 122,
+124, 125, 127, 129, 130, 132, 134, 135, 137, 139, 141, 142, 144, 146, 148, 149,
+151, 153, 155, 157, 159, 161, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180,
+182, 185, 187, 189, 191, 193, 195, 197, 200, 202, 204, 206, 208, 211, 213, 215,
+218, 220, 222, 225, 227, 230, 232, 234, 237, 239, 242, 244, 247, 249, 252, 255
+};
#endif
#ifdef USE_LED_BREATHING_TABLE
-const uint8_t LED_BREATHING_TABLE[] PROGMEM = {
+const uint8_t LED_BREATHING_TABLE[256] PROGMEM = {
0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 4, 5, 5, 6, 7, 9,
10, 11, 12, 14, 15, 17, 18, 20, 21, 23, 25, 27, 29, 31, 33, 35,
37, 40, 42, 44, 47, 49, 52, 54, 57, 59, 62, 65, 67, 70, 73, 76,
diff --git a/quantum/mcu_selection.mk b/quantum/mcu_selection.mk
index 209b578ea5..fa6dc8b53c 100644
--- a/quantum/mcu_selection.mk
+++ b/quantum/mcu_selection.mk
@@ -34,6 +34,7 @@ ifneq ($(findstring STM32F303, $(MCU)),)
# Options to pass to dfu-util when flashing
DFU_ARGS ?= -d 0483:df11 -a 0 -s 0x08000000:leave
+ DFU_SUFFIX_ARGS = -p DF11 -v 0483
endif
ifneq (,$(filter $(MCU),atmega32u4 at90usb1286))
diff --git a/quantum/process_keycode/process_space_cadet.c b/quantum/process_keycode/process_space_cadet.c
index a9c506168d..ac39df8089 100644
--- a/quantum/process_keycode/process_space_cadet.c
+++ b/quantum/process_keycode/process_space_cadet.c
@@ -62,16 +62,16 @@
#ifndef LCPO_KEYS
#define LCPO_KEYS KC_LCTL, KC_LCTL, KC_9
#endif
-#ifndef RCPO_KEYS
- #define RCPO_KEYS KC_RCTL, KC_RCTL, KC_0
+#ifndef RCPC_KEYS
+ #define RCPC_KEYS KC_RCTL, KC_RCTL, KC_0
#endif
// Alt / paren setup
#ifndef LAPO_KEYS
#define LAPO_KEYS KC_LALT, KC_LALT, KC_9
#endif
-#ifndef RAPO_KEYS
- #define RAPO_KEYS KC_RALT, KC_RALT, KC_0
+#ifndef RAPC_KEYS
+ #define RAPC_KEYS KC_RALT, KC_RALT, KC_0
#endif
// Shift / Enter setup
@@ -82,27 +82,32 @@
static uint8_t sc_last = 0;
static uint16_t sc_timer = 0;
-void perform_space_cadet(keyrecord_t *record, uint8_t normalMod, uint8_t tapMod, uint8_t keycode) {
+void perform_space_cadet(keyrecord_t *record, uint8_t holdMod, uint8_t tapMod, uint8_t keycode) {
if (record->event.pressed) {
- sc_last = normalMod;
+ sc_last = holdMod;
sc_timer = timer_read ();
- if (IS_MOD(normalMod)) {
- register_mods(MOD_BIT(normalMod));
+ if (IS_MOD(holdMod)) {
+ register_mods(MOD_BIT(holdMod));
}
}
else {
- if (IS_MOD(normalMod)) {
- unregister_mods(MOD_BIT(normalMod));
- }
-
- if (sc_last == normalMod && timer_elapsed(sc_timer) < TAPPING_TERM) {
- if (IS_MOD(tapMod)) {
- register_mods(MOD_BIT(tapMod));
+ if (sc_last == holdMod && timer_elapsed(sc_timer) < TAPPING_TERM) {
+ if (holdMod != tapMod) {
+ if (IS_MOD(holdMod)) {
+ unregister_mods(MOD_BIT(holdMod));
+ }
+ if (IS_MOD(tapMod)) {
+ register_mods(MOD_BIT(tapMod));
+ }
}
tap_code(keycode);
if (IS_MOD(tapMod)) {
unregister_mods(MOD_BIT(tapMod));
}
+ } else {
+ if (IS_MOD(holdMod)) {
+ unregister_mods(MOD_BIT(holdMod));
+ }
}
}
}
@@ -122,7 +127,7 @@ bool process_space_cadet(uint16_t keycode, keyrecord_t *record) {
return false;
}
case KC_RCPC: {
- perform_space_cadet(record, RCPO_KEYS);
+ perform_space_cadet(record, RCPC_KEYS);
return false;
}
case KC_LAPO: {
@@ -130,7 +135,7 @@ bool process_space_cadet(uint16_t keycode, keyrecord_t *record) {
return false;
}
case KC_RAPC: {
- perform_space_cadet(record, RAPO_KEYS);
+ perform_space_cadet(record, RAPC_KEYS);
return false;
}
case KC_SFTENT: {
diff --git a/quantum/process_keycode/process_space_cadet.h b/quantum/process_keycode/process_space_cadet.h
index 3f08b8002a..c823143504 100644
--- a/quantum/process_keycode/process_space_cadet.h
+++ b/quantum/process_keycode/process_space_cadet.h
@@ -17,5 +17,5 @@
#include "quantum.h"
-void perform_space_cadet(keyrecord_t *record, uint8_t normalMod, uint8_t tapMod, uint8_t keycode);
+void perform_space_cadet(keyrecord_t *record, uint8_t holdMod, uint8_t tapMod, uint8_t keycode);
bool process_space_cadet(uint16_t keycode, keyrecord_t *record);
diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c
index 1d27a620a2..3c83463146 100644
--- a/quantum/rgb_matrix.c
+++ b/quantum/rgb_matrix.c
@@ -144,9 +144,14 @@ void eeconfig_debug_rgb_matrix(void) {
dprintf("rgb_matrix_config.speed = %d\n", rgb_matrix_config.speed);
}
+__attribute__ ((weak))
+uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i) {
+ return 0;
+}
+
uint8_t rgb_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i) {
// TODO: This is kinda expensive, fix this soonish
- uint8_t led_count = 0;
+ uint8_t led_count = rgb_matrix_map_row_column_to_led_kb(row, column, led_i);
for (uint8_t i = 0; i < DRIVER_LED_TOTAL && led_count < LED_HITS_TO_REMEMBER; i++) {
matrix_co_t matrix_co = g_rgb_leds[i].matrix_co;
if (row == matrix_co.row && column == matrix_co.col) {
diff --git a/quantum/rgb_matrix_animations/solid_reactive_anim.h b/quantum/rgb_matrix_animations/solid_reactive_anim.h
index 220e542331..1116bb055c 100644
--- a/quantum/rgb_matrix_animations/solid_reactive_anim.h
+++ b/quantum/rgb_matrix_animations/solid_reactive_anim.h
@@ -14,7 +14,8 @@ bool rgb_matrix_solid_reactive(effect_params_t* params) {
// Relies on hue being 8-bit and wrapping
for (uint8_t i = led_min; i < led_max; i++) {
uint16_t tick = max_tick;
- for(uint8_t j = 0; j < g_last_hit_tracker.count; j++) {
+ // Reverse search to find most recent key hit
+ for (int8_t j = g_last_hit_tracker.count - 1; j >= 0; j--) {
if (g_last_hit_tracker.index[j] == i && g_last_hit_tracker.tick[j] < tick) {
tick = g_last_hit_tracker.tick[j];
break;
diff --git a/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h b/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h
index e84cd69392..a2d3f242c1 100644
--- a/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h
+++ b/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h
@@ -13,7 +13,8 @@ bool rgb_matrix_solid_reactive_simple(effect_params_t* params) {
uint16_t max_tick = 65535 / rgb_matrix_config.speed;
for (uint8_t i = led_min; i < led_max; i++) {
uint16_t tick = max_tick;
- for(uint8_t j = 0; j < g_last_hit_tracker.count; j++) {
+ // Reverse search to find most recent key hit
+ for (int8_t j = g_last_hit_tracker.count - 1; j >= 0; j--) {
if (g_last_hit_tracker.index[j] == i && g_last_hit_tracker.tick[j] < tick) {
tick = g_last_hit_tracker.tick[j];
break;
diff --git a/quantum/rgb_matrix_drivers.c b/quantum/rgb_matrix_drivers.c
index 3814dd61fc..1d64dc9093 100644
--- a/quantum/rgb_matrix_drivers.c
+++ b/quantum/rgb_matrix_drivers.c
@@ -99,12 +99,12 @@ const rgb_matrix_driver_t rgb_matrix_driver = {
#elif defined(WS2812)
-extern LED_TYPE led[RGBLED_NUM];
+extern LED_TYPE led[DRIVER_LED_TOTAL];
static void flush( void )
{
// Assumes use of RGB_DI_PIN
- ws2812_setleds(led, RGBLED_NUM);
+ ws2812_setleds(led, DRIVER_LED_TOTAL);
}
static void init( void )
diff --git a/quantum/rgblight.c b/quantum/rgblight.c
index 2f23768ed7..77772e2925 100644
--- a/quantum/rgblight.c
+++ b/quantum/rgblight.c
@@ -28,8 +28,10 @@
#include "progmem.h"
#include "timer.h"
#include "rgblight.h"
+#include "color.h"
#include "debug.h"
#include "led_tables.h"
+#include "lib/lib8tion/lib8tion.h"
#ifdef VELOCIKEY_ENABLE
#include "velocikey.h"
#endif
@@ -74,16 +76,13 @@ static inline int is_static_effect(uint8_t mode) {
return memchr(static_effect_table, mode, sizeof(static_effect_table)) != NULL;
}
-#define MIN(a,b) (((a)<(b))?(a):(b))
-#define MAX(a,b) (((a)>(b))?(a):(b))
-
#ifdef RGBLIGHT_LED_MAP
const uint8_t led_map[] PROGMEM = RGBLIGHT_LED_MAP;
#endif
#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
__attribute__ ((weak))
-const uint16_t RGBLED_GRADIENT_RANGES[] PROGMEM = {360, 240, 180, 120, 90};
+const uint8_t RGBLED_GRADIENT_RANGES[] PROGMEM = {255, 170, 127, 85, 64};
#endif
rgblight_config_t rgblight_config;
@@ -109,59 +108,10 @@ void rgblight_set_clipping_range(uint8_t start_pos, uint8_t num_leds) {
}
-void sethsv(uint16_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) {
- uint8_t r = 0, g = 0, b = 0, base, color;
-
- if (val > RGBLIGHT_LIMIT_VAL) {
- val=RGBLIGHT_LIMIT_VAL; // limit the val
- }
-
- if (sat == 0) { // Acromatic color (gray). Hue doesn't mind.
- r = val;
- g = val;
- b = val;
- } else {
- base = ((255 - sat) * val) >> 8;
- color = (val - base) * (hue % 60) / 60;
-
- switch (hue / 60) {
- case 0:
- r = val;
- g = base + color;
- b = base;
- break;
- case 1:
- r = val - color;
- g = val;
- b = base;
- break;
- case 2:
- r = base;
- g = val;
- b = base + color;
- break;
- case 3:
- r = base;
- g = val - color;
- b = val;
- break;
- case 4:
- r = base + color;
- g = base;
- b = val;
- break;
- case 5:
- r = val;
- g = base;
- b = val - color;
- break;
- }
- }
- r = pgm_read_byte(&CIE1931_CURVE[r]);
- g = pgm_read_byte(&CIE1931_CURVE[g]);
- b = pgm_read_byte(&CIE1931_CURVE[b]);
-
- setrgb(r, g, b, led1);
+void sethsv(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) {
+ HSV hsv = { hue, sat, val > RGBLIGHT_LIMIT_VAL ? RGBLIGHT_LIMIT_VAL : val };
+ RGB rgb = hsv_to_rgb(hsv);
+ setrgb(rgb.r, rgb.g, rgb.b, led1);
}
void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1) {
@@ -180,24 +130,9 @@ void rgblight_check_config(void) {
rgblight_config.mode = RGBLIGHT_MODES;
}
- if (rgblight_config.hue < 0) {
- rgblight_config.hue = 0;
- } else if (rgblight_config.hue > 360) {
- rgblight_config.hue %= 360;
- }
-
- if (rgblight_config.sat < 0) {
- rgblight_config.sat = 0;
- } else if (rgblight_config.sat > 255) {
- rgblight_config.sat = 255;
- }
-
- if (rgblight_config.val < 0) {
- rgblight_config.val = 0;
- } else if (rgblight_config.val > RGBLIGHT_LIMIT_VAL) {
+ if (rgblight_config.val > RGBLIGHT_LIMIT_VAL) {
rgblight_config.val = RGBLIGHT_LIMIT_VAL;
}
-
}
uint32_t eeconfig_read_rgblight(void) {
@@ -220,7 +155,7 @@ void eeconfig_update_rgblight_default(void) {
rgblight_config.enable = 1;
rgblight_config.mode = RGBLIGHT_MODE_STATIC_LIGHT;
rgblight_config.hue = 0;
- rgblight_config.sat = 255;
+ rgblight_config.sat = UINT8_MAX;
rgblight_config.val = RGBLIGHT_LIMIT_VAL;
rgblight_config.speed = 0;
RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS;
@@ -442,23 +377,8 @@ void rgblight_disable_noeeprom(void) {
rgblight_set();
}
-
-// Deals with the messy details of incrementing an integer
-static uint8_t increment( uint8_t value, uint8_t step, uint8_t min, uint8_t max ) {
- int16_t new_value = value;
- new_value += step;
- return MIN( MAX( new_value, min ), max );
-}
-
-static uint8_t decrement( uint8_t value, uint8_t step, uint8_t min, uint8_t max ) {
- int16_t new_value = value;
- new_value -= step;
- return MIN( MAX( new_value, min ), max );
-}
-
void rgblight_increase_hue_helper(bool write_to_eeprom) {
- uint16_t hue;
- hue = (rgblight_config.hue+RGBLIGHT_HUE_STEP) % 360;
+ uint8_t hue = rgblight_config.hue + RGBLIGHT_HUE_STEP;
rgblight_sethsv_eeprom_helper(hue, rgblight_config.sat, rgblight_config.val, write_to_eeprom);
}
void rgblight_increase_hue_noeeprom(void) {
@@ -468,12 +388,7 @@ void rgblight_increase_hue(void) {
rgblight_increase_hue_helper(true);
}
void rgblight_decrease_hue_helper(bool write_to_eeprom) {
- uint16_t hue;
- if (rgblight_config.hue-RGBLIGHT_HUE_STEP < 0) {
- hue = (rgblight_config.hue + 360 - RGBLIGHT_HUE_STEP) % 360;
- } else {
- hue = (rgblight_config.hue - RGBLIGHT_HUE_STEP) % 360;
- }
+ uint8_t hue = rgblight_config.hue - RGBLIGHT_HUE_STEP;
rgblight_sethsv_eeprom_helper(hue, rgblight_config.sat, rgblight_config.val, write_to_eeprom);
}
void rgblight_decrease_hue_noeeprom(void) {
@@ -483,12 +398,7 @@ void rgblight_decrease_hue(void) {
rgblight_decrease_hue_helper(true);
}
void rgblight_increase_sat_helper(bool write_to_eeprom) {
- uint8_t sat;
- if (rgblight_config.sat + RGBLIGHT_SAT_STEP > 255) {
- sat = 255;
- } else {
- sat = rgblight_config.sat + RGBLIGHT_SAT_STEP;
- }
+ uint8_t sat = qadd8(rgblight_config.sat, RGBLIGHT_SAT_STEP);
rgblight_sethsv_eeprom_helper(rgblight_config.hue, sat, rgblight_config.val, write_to_eeprom);
}
void rgblight_increase_sat_noeeprom(void) {
@@ -498,12 +408,7 @@ void rgblight_increase_sat(void) {
rgblight_increase_sat_helper(true);
}
void rgblight_decrease_sat_helper(bool write_to_eeprom) {
- uint8_t sat;
- if (rgblight_config.sat - RGBLIGHT_SAT_STEP < 0) {
- sat = 0;
- } else {
- sat = rgblight_config.sat - RGBLIGHT_SAT_STEP;
- }
+ uint8_t sat = qsub8(rgblight_config.sat, RGBLIGHT_SAT_STEP);
rgblight_sethsv_eeprom_helper(rgblight_config.hue, sat, rgblight_config.val, write_to_eeprom);
}
void rgblight_decrease_sat_noeeprom(void) {
@@ -513,12 +418,7 @@ void rgblight_decrease_sat(void) {
rgblight_decrease_sat_helper(true);
}
void rgblight_increase_val_helper(bool write_to_eeprom) {
- uint8_t val;
- if (rgblight_config.val + RGBLIGHT_VAL_STEP > RGBLIGHT_LIMIT_VAL) {
- val = RGBLIGHT_LIMIT_VAL;
- } else {
- val = rgblight_config.val + RGBLIGHT_VAL_STEP;
- }
+ uint8_t val = qadd8(rgblight_config.val, RGBLIGHT_VAL_STEP);
rgblight_sethsv_eeprom_helper(rgblight_config.hue, rgblight_config.sat, val, write_to_eeprom);
}
void rgblight_increase_val_noeeprom(void) {
@@ -528,12 +428,7 @@ void rgblight_increase_val(void) {
rgblight_increase_val_helper(true);
}
void rgblight_decrease_val_helper(bool write_to_eeprom) {
- uint8_t val;
- if (rgblight_config.val - RGBLIGHT_VAL_STEP < 0) {
- val = 0;
- } else {
- val = rgblight_config.val - RGBLIGHT_VAL_STEP;
- }
+ uint8_t val = qsub8(rgblight_config.val, RGBLIGHT_VAL_STEP);
rgblight_sethsv_eeprom_helper(rgblight_config.hue, rgblight_config.sat, val, write_to_eeprom);
}
void rgblight_decrease_val_noeeprom(void) {
@@ -543,18 +438,20 @@ void rgblight_decrease_val(void) {
rgblight_decrease_val_helper(true);
}
void rgblight_increase_speed(void) {
- rgblight_config.speed = increment( rgblight_config.speed, 1, 0, 3 );
+ if (rgblight_config.speed < 3)
+ rgblight_config.speed++;
//RGBLIGHT_SPLIT_SET_CHANGE_HSVS; // NEED?
eeconfig_update_rgblight(rgblight_config.raw);//EECONFIG needs to be increased to support this
}
void rgblight_decrease_speed(void) {
- rgblight_config.speed = decrement( rgblight_config.speed, 1, 0, 3 );
+ if (rgblight_config.speed > 0)
+ rgblight_config.speed--;
//RGBLIGHT_SPLIT_SET_CHANGE_HSVS; // NEED??
eeconfig_update_rgblight(rgblight_config.raw);//EECONFIG needs to be increased to support this
}
-void rgblight_sethsv_noeeprom_old(uint16_t hue, uint8_t sat, uint8_t val) {
+void rgblight_sethsv_noeeprom_old(uint8_t hue, uint8_t sat, uint8_t val) {
if (rgblight_config.enable) {
LED_TYPE tmp_led;
sethsv(hue, sat, val, &tmp_led);
@@ -563,7 +460,7 @@ void rgblight_sethsv_noeeprom_old(uint16_t hue, uint8_t sat, uint8_t val) {
}
}
-void rgblight_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom) {
+void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom) {
if (rgblight_config.enable) {
rgblight_status.base_mode = mode_base_table[rgblight_config.mode];
if (rgblight_config.mode == RGBLIGHT_MODE_STATIC_LIGHT) {
@@ -596,13 +493,22 @@ void rgblight_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool
#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
else if (rgblight_status.base_mode == RGBLIGHT_MODE_STATIC_GRADIENT) {
// static gradient
- uint16_t _hue;
uint8_t delta = rgblight_config.mode - rgblight_status.base_mode;
- int8_t direction = (delta % 2) ? -1 : 1;
- uint16_t range = pgm_read_word(&RGBLED_GRADIENT_RANGES[delta / 2]);
+ bool direction = (delta % 2) == 0;
+#ifdef __AVR__
+ // probably due to how pgm_read_word is defined for ARM, but the ARM compiler really hates this line
+ uint8_t range = pgm_read_word(&RGBLED_GRADIENT_RANGES[delta / 2]);
+#else
+ uint8_t range = RGBLED_GRADIENT_RANGES[delta / 2];
+#endif
for (uint8_t i = 0; i < RGBLED_NUM; i++) {
- _hue = (range / RGBLED_NUM * i * direction + hue + 360) % 360;
- dprintf("rgblight rainbow set hsv: %u,%u,%d,%u\n", i, _hue, direction, range);
+ uint8_t _hue = ((uint16_t)i * (uint16_t)range) / RGBLED_NUM;
+ if (direction) {
+ _hue = hue + _hue;
+ } else {
+ _hue = hue - _hue;
+ }
+ dprintf("rgblight rainbow set hsv: %d,%d,%d,%u\n", i, _hue, direction, range);
sethsv(_hue, sat, val, (LED_TYPE *)&led[i]);
}
rgblight_set();
@@ -628,15 +534,15 @@ void rgblight_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool
}
}
-void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val) {
+void rgblight_sethsv(uint8_t hue, uint8_t sat, uint8_t val) {
rgblight_sethsv_eeprom_helper(hue, sat, val, true);
}
-void rgblight_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) {
+void rgblight_sethsv_noeeprom(uint8_t hue, uint8_t sat, uint8_t val) {
rgblight_sethsv_eeprom_helper(hue, sat, val, false);
}
-uint16_t rgblight_get_hue(void) {
+uint8_t rgblight_get_hue(void) {
return rgblight_config.hue;
}
@@ -668,7 +574,7 @@ void rgblight_setrgb_at(uint8_t r, uint8_t g, uint8_t b, uint8_t index) {
rgblight_set();
}
-void rgblight_sethsv_at(uint16_t hue, uint8_t sat, uint8_t val, uint8_t index) {
+void rgblight_sethsv_at(uint8_t hue, uint8_t sat, uint8_t val, uint8_t index) {
if (!rgblight_config.enable) { return; }
LED_TYPE tmp_led;
@@ -701,7 +607,7 @@ void rgblight_setrgb_range(uint8_t r, uint8_t g, uint8_t b, uint8_t start, uint8
wait_ms(1);
}
-void rgblight_sethsv_range(uint16_t hue, uint8_t sat, uint8_t val, uint8_t start, uint8_t end) {
+void rgblight_sethsv_range(uint8_t hue, uint8_t sat, uint8_t val, uint8_t start, uint8_t end) {
if (!rgblight_config.enable) { return; }
LED_TYPE tmp_led;
@@ -717,11 +623,11 @@ void rgblight_setrgb_slave(uint8_t r, uint8_t g, uint8_t b) {
rgblight_setrgb_range(r, g, b, (uint8_t) RGBLED_NUM/2, (uint8_t) RGBLED_NUM);
}
-void rgblight_sethsv_master(uint16_t hue, uint8_t sat, uint8_t val) {
+void rgblight_sethsv_master(uint8_t hue, uint8_t sat, uint8_t val) {
rgblight_sethsv_range(hue, sat, val, 0, (uint8_t) RGBLED_NUM/2);
}
-void rgblight_sethsv_slave(uint16_t hue, uint8_t sat, uint8_t val) {
+void rgblight_sethsv_slave(uint8_t hue, uint8_t sat, uint8_t val) {
rgblight_sethsv_range(hue, sat, val, (uint8_t) RGBLED_NUM/2, (uint8_t) RGBLED_NUM);
}
@@ -973,6 +879,14 @@ void rgblight_task(void) {
// Effects
#ifdef RGBLIGHT_EFFECT_BREATHING
+
+#ifndef RGBLIGHT_EFFECT_BREATHE_CENTER
+ #ifndef RGBLIGHT_BREATHE_TABLE_SIZE
+ #define RGBLIGHT_BREATHE_TABLE_SIZE 256 // 256 or 128 or 64
+ #endif
+ #include <rgblight_breathe_table.h>
+#endif
+
__attribute__ ((weak))
const uint8_t RGBLED_BREATHING_INTERVALS[] PROGMEM = {30, 20, 10, 5};
@@ -980,9 +894,13 @@ void rgblight_effect_breathing(animation_status_t *anim) {
float val;
// http://sean.voisen.org/blog/2011/10/breathing-led-with-arduino/
+#ifdef RGBLIGHT_EFFECT_BREATHE_TABLE
+ val = pgm_read_byte(&rgblight_effect_breathe_table[anim->pos / table_scale]);
+#else
val = (exp(sin((anim->pos/255.0)*M_PI)) - RGBLIGHT_EFFECT_BREATHE_CENTER/M_E)*(RGBLIGHT_EFFECT_BREATHE_MAX/(M_E-1/M_E));
+#endif
rgblight_sethsv_noeeprom_old(rgblight_config.hue, rgblight_config.sat, val);
- anim->pos = (anim->pos + 1) % 256;
+ anim->pos = (anim->pos + 1);
}
#endif
@@ -992,36 +910,32 @@ const uint8_t RGBLED_RAINBOW_MOOD_INTERVALS[] PROGMEM = {120, 60, 30};
void rgblight_effect_rainbow_mood(animation_status_t *anim) {
rgblight_sethsv_noeeprom_old(anim->current_hue, rgblight_config.sat, rgblight_config.val);
- anim->current_hue = (anim->current_hue + 1) % 360;
+ anim->current_hue++;
}
#endif
#ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL
#ifndef RGBLIGHT_RAINBOW_SWIRL_RANGE
- #define RGBLIGHT_RAINBOW_SWIRL_RANGE 360
+ #define RGBLIGHT_RAINBOW_SWIRL_RANGE 255
#endif
__attribute__ ((weak))
const uint8_t RGBLED_RAINBOW_SWIRL_INTERVALS[] PROGMEM = {100, 50, 20};
void rgblight_effect_rainbow_swirl(animation_status_t *anim) {
- uint16_t hue;
+ uint8_t hue;
uint8_t i;
for (i = 0; i < RGBLED_NUM; i++) {
- hue = (RGBLIGHT_RAINBOW_SWIRL_RANGE / RGBLED_NUM * i + anim->current_hue) % 360;
+ hue = (RGBLIGHT_RAINBOW_SWIRL_RANGE / RGBLED_NUM * i + anim->current_hue);
sethsv(hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i]);
}
rgblight_set();
if (anim->delta % 2) {
- anim->current_hue = (anim->current_hue + 1) % 360;
+ anim->current_hue++;
} else {
- if (anim->current_hue - 1 < 0) {
- anim->current_hue = 359;
- } else {
- anim->current_hue = anim->current_hue - 1;
- }
+ anim->current_hue--;
}
}
#endif
@@ -1146,12 +1060,12 @@ void rgblight_effect_knight(animation_status_t *anim) {
#ifdef RGBLIGHT_EFFECT_CHRISTMAS
void rgblight_effect_christmas(animation_status_t *anim) {
- uint16_t hue;
+ uint8_t hue;
uint8_t i;
anim->current_offset = (anim->current_offset + 1) % 2;
for (i = 0; i < RGBLED_NUM; i++) {
- hue = 0 + ((i/RGBLIGHT_EFFECT_CHRISTMAS_STEP + anim->current_offset) % 2) * 120;
+ hue = 0 + ((i/RGBLIGHT_EFFECT_CHRISTMAS_STEP + anim->current_offset) % 2) * 85;
sethsv(hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i]);
}
rgblight_set();
diff --git a/quantum/rgblight.h b/quantum/rgblight.h
index 748d009dcf..35d7942ca6 100644
--- a/quantum/rgblight.h
+++ b/quantum/rgblight.h
@@ -80,9 +80,7 @@ enum RGBLIGHT_EFFECT_MODE {
#define RGBLIGHT_MODES (RGBLIGHT_MODE_last-1)
-#ifndef RGBLIGHT_EFFECT_BREATHE_CENTER
-#define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85 // 1-2.7
-#endif
+// sample: #define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85
#ifndef RGBLIGHT_EFFECT_BREATHE_MAX
#define RGBLIGHT_EFFECT_BREATHE_MAX 255 // 0-255
@@ -113,7 +111,7 @@ enum RGBLIGHT_EFFECT_MODE {
#endif
#ifndef RGBLIGHT_HUE_STEP
-#define RGBLIGHT_HUE_STEP 10
+#define RGBLIGHT_HUE_STEP 8
#endif
#ifndef RGBLIGHT_SAT_STEP
#define RGBLIGHT_SAT_STEP 17
@@ -151,12 +149,13 @@ extern const uint8_t RGBLED_KNIGHT_INTERVALS[3] PROGMEM;
extern const uint16_t RGBLED_RGBTEST_INTERVALS[1] PROGMEM;
extern bool is_rgblight_initialized;
+// Should stay in sycn with rgb matrix config as we reuse eeprom storage for both (for now)
typedef union {
uint32_t raw;
struct {
bool enable :1;
- uint8_t mode :6;
- uint16_t hue :9;
+ uint8_t mode :7;
+ uint8_t hue :8;
uint8_t sat :8;
uint8_t val :8;
uint8_t speed :8;//EECONFIG needs to be increased to support this
@@ -211,19 +210,19 @@ void rgblight_increase_val(void);
void rgblight_decrease_val(void);
void rgblight_increase_speed(void);
void rgblight_decrease_speed(void);
-void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val);
-uint16_t rgblight_get_hue(void);
+void rgblight_sethsv(uint8_t hue, uint8_t sat, uint8_t val);
+uint8_t rgblight_get_hue(void);
uint8_t rgblight_get_sat(void);
uint8_t rgblight_get_val(void);
void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b);
void rgblight_setrgb_at(uint8_t r, uint8_t g, uint8_t b, uint8_t index);
-void rgblight_sethsv_at(uint16_t hue, uint8_t sat, uint8_t val, uint8_t index);
+void rgblight_sethsv_at(uint8_t hue, uint8_t sat, uint8_t val, uint8_t index);
void rgblight_setrgb_range(uint8_t r, uint8_t g, uint8_t b, uint8_t start, uint8_t end);
-void rgblight_sethsv_range(uint16_t hue, uint8_t sat, uint8_t val, uint8_t start, uint8_t end);
+void rgblight_sethsv_range(uint8_t hue, uint8_t sat, uint8_t val, uint8_t start, uint8_t end);
void rgblight_setrgb_master(uint8_t r, uint8_t g, uint8_t b);
void rgblight_setrgb_slave(uint8_t r, uint8_t g, uint8_t b);
-void rgblight_sethsv_master(uint16_t hue, uint8_t sat, uint8_t val);
-void rgblight_sethsv_slave(uint16_t hue, uint8_t sat, uint8_t val);
+void rgblight_sethsv_master(uint8_t hue, uint8_t sat, uint8_t val);
+void rgblight_sethsv_slave(uint8_t hue, uint8_t sat, uint8_t val);
void rgblight_set_clipping_range(uint8_t start_pos, uint8_t num_leds);
uint32_t eeconfig_read_rgblight(void);
@@ -234,10 +233,10 @@ void eeconfig_debug_rgblight(void);
void rgb_matrix_increase(void);
void rgb_matrix_decrease(void);
-void sethsv(uint16_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1);
+void sethsv(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1);
void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1);
-void rgblight_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val);
+void rgblight_sethsv_noeeprom(uint8_t hue, uint8_t sat, uint8_t val);
void rgblight_mode_noeeprom(uint8_t mode);
void rgblight_toggle_noeeprom(void);
void rgblight_enable_noeeprom(void);
@@ -251,7 +250,7 @@ void rgblight_decrease_sat_noeeprom(void);
void rgblight_increase_val_noeeprom(void);
void rgblight_decrease_val_noeeprom(void);
-void rgblight_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom);
+void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom);
void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom);
@@ -274,7 +273,7 @@ typedef struct _animation_status_t {
union {
uint16_t pos16;
uint8_t pos;
- int16_t current_hue;
+ int8_t current_hue;
uint16_t current_offset;
};
} animation_status_t;
diff --git a/quantum/rgblight_breathe_table.h b/quantum/rgblight_breathe_table.h
new file mode 100644
index 0000000000..7ab8cc9479
--- /dev/null
+++ b/quantum/rgblight_breathe_table.h
@@ -0,0 +1,116 @@
+#ifndef RGBLIGHT_EFFECT_BREATHE_TABLE
+#define RGBLIGHT_EFFECT_BREATHE_TABLE
+
+const uint8_t rgblight_effect_breathe_table[] PROGMEM = {
+ /* #define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85 */
+ /* #define RGBLIGHT_EFFECT_BREATHE_MAX 255 */
+
+ #if RGBLIGHT_BREATHE_TABLE_SIZE == 256
+ 0x22, 0x23, 0x25, 0x26, 0x28, 0x29, 0x2a, 0x2c,
+ 0x2d, 0x2f, 0x30, 0x32, 0x33, 0x35, 0x36, 0x38,
+ 0x3a, 0x3b, 0x3d, 0x3e, 0x40, 0x42, 0x43, 0x45,
+ 0x47, 0x49, 0x4a, 0x4c, 0x4e, 0x50, 0x51, 0x53,
+ 0x55, 0x57, 0x59, 0x5a, 0x5c, 0x5e, 0x60, 0x62,
+ 0x64, 0x66, 0x68, 0x69, 0x6b, 0x6d, 0x6f, 0x71,
+ 0x73, 0x75, 0x77, 0x79, 0x7b, 0x7d, 0x7f, 0x81,
+ 0x83, 0x85, 0x87, 0x89, 0x8a, 0x8c, 0x8e, 0x90,
+ 0x92, 0x94, 0x96, 0x98, 0x9a, 0x9c, 0x9e, 0x9f,
+ 0xa1, 0xa3, 0xa5, 0xa7, 0xa8, 0xaa, 0xac, 0xae,
+ 0xaf, 0xb1, 0xb3, 0xb4, 0xb6, 0xb8, 0xb9, 0xbb,
+ 0xbc, 0xbe, 0xbf, 0xc1, 0xc2, 0xc3, 0xc5, 0xc6,
+ 0xc7, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xd0,
+ 0xd1, 0xd2, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
+ 0xd7, 0xd8, 0xd9, 0xd9, 0xda, 0xda, 0xdb, 0xdb,
+ 0xdb, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdb,
+ 0xdb, 0xdb, 0xda, 0xda, 0xd9, 0xd9, 0xd8, 0xd7,
+ 0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd2, 0xd1,
+ 0xd0, 0xce, 0xcd, 0xcc, 0xcb, 0xca, 0xc9, 0xc7,
+ 0xc6, 0xc5, 0xc3, 0xc2, 0xc1, 0xbf, 0xbe, 0xbc,
+ 0xbb, 0xb9, 0xb8, 0xb6, 0xb4, 0xb3, 0xb1, 0xaf,
+ 0xae, 0xac, 0xaa, 0xa8, 0xa7, 0xa5, 0xa3, 0xa1,
+ 0x9f, 0x9e, 0x9c, 0x9a, 0x98, 0x96, 0x94, 0x92,
+ 0x90, 0x8e, 0x8c, 0x8a, 0x89, 0x87, 0x85, 0x83,
+ 0x81, 0x7f, 0x7d, 0x7b, 0x79, 0x77, 0x75, 0x73,
+ 0x71, 0x6f, 0x6d, 0x6b, 0x69, 0x68, 0x66, 0x64,
+ 0x62, 0x60, 0x5e, 0x5c, 0x5a, 0x59, 0x57, 0x55,
+ 0x53, 0x51, 0x50, 0x4e, 0x4c, 0x4a, 0x49, 0x47,
+ 0x45, 0x43, 0x42, 0x40, 0x3e, 0x3d, 0x3b, 0x3a,
+ 0x38, 0x36, 0x35, 0x33, 0x32, 0x30, 0x2f, 0x2d,
+ 0x2c, 0x2a, 0x29, 0x28, 0x26, 0x25, 0x23, 0x22
+ #endif /* 256 bytes table */
+
+ #if RGBLIGHT_BREATHE_TABLE_SIZE == 128
+ 0x22, 0x25, 0x28, 0x2a,
+ 0x2d, 0x30, 0x33, 0x36,
+ 0x3a, 0x3d, 0x40, 0x43,
+ 0x47, 0x4a, 0x4e, 0x51,
+ 0x55, 0x59, 0x5c, 0x60,
+ 0x64, 0x68, 0x6b, 0x6f,
+ 0x73, 0x77, 0x7b, 0x7f,
+ 0x83, 0x87, 0x8a, 0x8e,
+ 0x92, 0x96, 0x9a, 0x9e,
+ 0xa1, 0xa5, 0xa8, 0xac,
+ 0xaf, 0xb3, 0xb6, 0xb9,
+ 0xbc, 0xbf, 0xc2, 0xc5,
+ 0xc7, 0xca, 0xcc, 0xce,
+ 0xd1, 0xd2, 0xd4, 0xd6,
+ 0xd7, 0xd9, 0xda, 0xdb,
+ 0xdb, 0xdc, 0xdc, 0xdd,
+ 0xdd, 0xdc, 0xdc, 0xdc,
+ 0xdb, 0xda, 0xd9, 0xd8,
+ 0xd7, 0xd5, 0xd3, 0xd2,
+ 0xd0, 0xcd, 0xcb, 0xc9,
+ 0xc6, 0xc3, 0xc1, 0xbe,
+ 0xbb, 0xb8, 0xb4, 0xb1,
+ 0xae, 0xaa, 0xa7, 0xa3,
+ 0x9f, 0x9c, 0x98, 0x94,
+ 0x90, 0x8c, 0x89, 0x85,
+ 0x81, 0x7d, 0x79, 0x75,
+ 0x71, 0x6d, 0x69, 0x66,
+ 0x62, 0x5e, 0x5a, 0x57,
+ 0x53, 0x50, 0x4c, 0x49,
+ 0x45, 0x42, 0x3e, 0x3b,
+ 0x38, 0x35, 0x32, 0x2f,
+ 0x2c, 0x29, 0x26, 0x23
+ #endif /* 128 bytes table */
+
+ #if RGBLIGHT_BREATHE_TABLE_SIZE == 64
+ 0x22, 0x28,
+ 0x2d, 0x33,
+ 0x3a, 0x40,
+ 0x47, 0x4e,
+ 0x55, 0x5c,
+ 0x64, 0x6b,
+ 0x73, 0x7b,
+ 0x83, 0x8a,
+ 0x92, 0x9a,
+ 0xa1, 0xa8,
+ 0xaf, 0xb6,
+ 0xbc, 0xc2,
+ 0xc7, 0xcc,
+ 0xd1, 0xd4,
+ 0xd7, 0xda,
+ 0xdb, 0xdc,
+ 0xdd, 0xdc,
+ 0xdb, 0xd9,
+ 0xd7, 0xd3,
+ 0xd0, 0xcb,
+ 0xc6, 0xc1,
+ 0xbb, 0xb4,
+ 0xae, 0xa7,
+ 0x9f, 0x98,
+ 0x90, 0x89,
+ 0x81, 0x79,
+ 0x71, 0x69,
+ 0x62, 0x5a,
+ 0x53, 0x4c,
+ 0x45, 0x3e,
+ 0x38, 0x32,
+ 0x2c, 0x26
+ #endif /* 64 bytes table */
+};
+
+static const int table_scale = 256/sizeof(rgblight_effect_breathe_table);
+
+#endif /* RGBLIGHT_EFFECT_BREATHE_TABLE */
diff --git a/quantum/rgblight_list.h b/quantum/rgblight_list.h
index e024364f05..702e33e765 100644
--- a/quantum/rgblight_list.h
+++ b/quantum/rgblight_list.h
@@ -38,22 +38,22 @@
/* HSV COLORS */
#define HSV_WHITE 0, 0, 255
#define HSV_RED 0, 255, 255
-#define HSV_CORAL 16, 176, 255
-#define HSV_ORANGE 39, 255, 255
-#define HSV_GOLDENROD 43, 218, 218
-#define HSV_GOLD 51, 255, 255
-#define HSV_YELLOW 60, 255, 255
-#define HSV_CHARTREUSE 90, 255, 255
-#define HSV_GREEN 120, 255, 255
-#define HSV_SPRINGGREEN 150, 255, 255
-#define HSV_TURQUOISE 174, 90, 112
-#define HSV_TEAL 180, 255, 128
-#define HSV_CYAN 180, 255, 255
-#define HSV_AZURE 186, 102, 255
-#define HSV_BLUE 240, 255, 255
-#define HSV_PURPLE 270, 255, 255
-#define HSV_MAGENTA 300, 255, 255
-#define HSV_PINK 330, 128, 255
+#define HSV_CORAL 11, 176, 255
+#define HSV_ORANGE 28, 255, 255
+#define HSV_GOLDENROD 30, 218, 218
+#define HSV_GOLD 36, 255, 255
+#define HSV_YELLOW 43, 255, 255
+#define HSV_CHARTREUSE 64, 255, 255
+#define HSV_GREEN 85, 255, 255
+#define HSV_SPRINGGREEN 106, 255, 255
+#define HSV_TURQUOISE 123, 90, 112
+#define HSV_TEAL 128, 255, 128
+#define HSV_CYAN 128, 255, 255
+#define HSV_AZURE 132, 102, 255
+#define HSV_BLUE 170, 255, 255
+#define HSV_PURPLE 191, 255, 255
+#define HSV_MAGENTA 213, 255, 255
+#define HSV_PINK 234, 128, 255
/*
diff --git a/quantum/stm32/proton_c.mk b/quantum/stm32/proton_c.mk
index a0fa013736..a65e283d3f 100644
--- a/quantum/stm32/proton_c.mk
+++ b/quantum/stm32/proton_c.mk
@@ -42,3 +42,4 @@ OPT_DEFS =
# Options to pass to dfu-util when flashing
DFU_ARGS = -d 0483:df11 -a 0 -s 0x08000000:leave
+DFU_SUFFIX_ARGS = -p df11 -v 0483
diff --git a/quantum/template/avr/config.h b/quantum/template/avr/config.h
index a9bb754821..48d7afb149 100644
--- a/quantum/template/avr/config.h
+++ b/quantum/template/avr/config.h
@@ -77,6 +77,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// #define RGBLIGHT_EFFECT_STATIC_GRADIENT
// #define RGBLIGHT_EFFECT_RGB_TEST
// #define RGBLIGHT_EFFECT_ALTERNATING
+// /*== customize breathing effect ==*/
+// /*==== (DEFAULT) use fixed table instead of exp() and sin() ====*/
+// #define RGBLIGHT_BREATHE_TABLE_SIZE 256 // 256(default) or 128 or 64
+// /*==== use exp() and sin() ====*/
+// #define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85 // 1 to 2.7
+// #define RGBLIGHT_EFFECT_BREATHE_MAX 255 // 0 to 255
// #endif
/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
diff --git a/tmk_core/chibios.mk b/tmk_core/chibios.mk
index 01edebfd74..44c00bdd15 100644
--- a/tmk_core/chibios.mk
+++ b/tmk_core/chibios.mk
@@ -201,6 +201,7 @@ DFU_ARGS ?=
ifneq ("$(SERIAL)","")
DFU_ARGS += -S $(SERIAL)
endif
+DFU_SUFFIX_ARGS ?=
ST_LINK_ARGS ?=
@@ -208,6 +209,7 @@ ST_LINK_ARGS ?=
EXTRALIBDIRS = $(RULESPATH)/ld
DFU_UTIL ?= dfu-util
+DFU_SUFFIX ?= dfu-suffix
ST_LINK_CLI ?= st-link_cli
# Generate a .qmk for the QMK-FF
@@ -259,4 +261,7 @@ st-link-cli: $(BUILD_DIR)/$(TARGET).hex sizeafter
$(ST_LINK_CLI) $(ST_LINK_ARGS) -q -c SWD -p $(BUILD_DIR)/$(TARGET).hex -Rst
bin: $(BUILD_DIR)/$(TARGET).bin sizeafter
+ if [ ! -z "$(DFU_SUFFIX_ARGS)" ]; then \
+ $(DFU_SUFFIX) $(DFU_SUFFIX_ARGS) -a $(BUILD_DIR)/$(TARGET).bin 1>/dev/null ;\
+ fi
$(COPY) $(BUILD_DIR)/$(TARGET).bin $(TARGET).bin;
diff --git a/util/rgblight_breathing_table_calc.c b/util/rgblight_breathing_table_calc.c
new file mode 100644
index 0000000000..fc4d49ea58
--- /dev/null
+++ b/util/rgblight_breathing_table_calc.c
@@ -0,0 +1,49 @@
+//
+// calculate rgblight_effect_breathe_table[] values
+//
+// this is host program for quantum/rgblight.c:void rgblight_effect_breathing();
+//
+// example:
+// $ edit util/rgblight_breathing_table_calc.c
+// $ cc -o util/rgblight_breathing_table_calc util/rgblight_breathing_table_calc.c
+// $ ./util/rgblight_breathing_table_calc > keyboards/KEYBOARD_NAME/keymaps/KEYMAP_NAME/rgblight_breathe_table.h
+//
+#include <stdio.h>
+#include <math.h>
+#include <stdint.h>
+
+/// customize breeathing effect part ///////////////////////////
+#define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85 // 1 to 2.7
+#define RGBLIGHT_EFFECT_BREATHE_MAX 255 // 0 to 255
+////////////////////////////////////////////////////////////////
+
+int main(void) {
+ int pos, step;
+ int table[256];
+ for (pos = 0; pos < 256; pos ++ ) {
+ table[pos] = (uint8_t)(
+ (exp(sin((pos/255.0)*M_PI))- RGBLIGHT_EFFECT_BREATHE_CENTER/M_E)
+ * (RGBLIGHT_EFFECT_BREATHE_MAX/(M_E-1/M_E))
+ );
+ }
+ printf("#ifndef RGBLIGHT_EFFECT_BREATHE_TABLE\n");
+ printf("#define RGBLIGHT_EFFECT_BREATHE_TABLE\n\n");
+ printf("const uint8_t rgblight_effect_breathe_table[] PROGMEM = {\n");
+ printf(" /* #define RGBLIGHT_EFFECT_BREATHE_CENTER %.2f */\n", RGBLIGHT_EFFECT_BREATHE_CENTER);
+ printf(" /* #define RGBLIGHT_EFFECT_BREATHE_MAX %d */\n", RGBLIGHT_EFFECT_BREATHE_MAX);
+
+ for (int s = 0, step = (1<<s); s < 3 ; s += 1, step = (1<<s) ) {
+ printf("\n #if RGBLIGHT_BREATHE_TABLE_SIZE == %d\n",
+ s == 0 ? 256:(s== 1 ? 128: 64));
+ for (pos = 0; pos < 256; pos += step ) {
+ printf(" 0x%x%s", table[pos], (pos+step)>=256?"":"," );
+ if ((pos+step) % 8 == 0)
+ printf("\n");
+ }
+ printf(" #endif /* %d bytes table */\n", s == 0 ? 256:(s== 1 ? 128: 64));
+ }
+ printf("};\n");
+ printf("\nstatic const int table_scale = 256/sizeof(rgblight_effect_breathe_table);\n");
+ printf("\n#endif /* RGBLIGHT_EFFECT_BREATHE_TABLE */\n");
+ return 0;
+}