summaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
authorJack Humbert <jack.humb@gmail.com>2016-11-12 20:54:37 -0500
committerJack Humbert <jack.humb@gmail.com>2016-11-12 20:54:37 -0500
commit33e62c080c9161a0fc921c90ed299a67fc2e1799 (patch)
tree253ea910d8f2ba464ab28709f5f93d09b27c05fd /quantum
parenta889b899e2cf52b3b7807d8a7ad39f12e0761a10 (diff)
parent631b8999a737ec73610f8b569b1f775cadf08172 (diff)
merging
Diffstat (limited to 'quantum')
-rw-r--r--quantum/dynamic_macro.h9
-rw-r--r--quantum/keymap.h13
-rw-r--r--quantum/keymap_extras/keymap_br_abnt2.h58
-rw-r--r--quantum/keymap_extras/keymap_dvp.h82
-rwxr-xr-xquantum/light_ws2812.c20
-rw-r--r--quantum/process_keycode/process_unicode.c51
-rw-r--r--quantum/process_keycode/process_unicode.h13
-rw-r--r--quantum/quantum.c2
-rw-r--r--quantum/rgblight.c61
-rw-r--r--quantum/rgblight.h6
-rw-r--r--quantum/variable_trace.c110
-rw-r--r--quantum/variable_trace.h34
12 files changed, 422 insertions, 37 deletions
diff --git a/quantum/dynamic_macro.h b/quantum/dynamic_macro.h
index a3ad61bc7e..e6dbc5b9c1 100644
--- a/quantum/dynamic_macro.h
+++ b/quantum/dynamic_macro.h
@@ -8,8 +8,13 @@
/* May be overridden with a custom value. Be aware that the effective
* macro length is half of this value: each keypress is recorded twice
* because of the down-event and up-event. This is not a bug, it's the
- * intended behavior. */
-#define DYNAMIC_MACRO_SIZE 256
+ * intended behavior.
+ *
+ * Usually it should be fine to set the macro size to at least 256 but
+ * there have been reports of it being too much in some users' cases,
+ * so 128 is considered a safe default.
+ */
+#define DYNAMIC_MACRO_SIZE 128
#endif
/* DYNAMIC_MACRO_RANGE must be set as the last element of user's
diff --git a/quantum/keymap.h b/quantum/keymap.h
index 41aa116228..ae56d16c75 100644
--- a/quantum/keymap.h
+++ b/quantum/keymap.h
@@ -84,6 +84,10 @@ enum quantum_keycodes {
QK_MOD_TAP_MAX = 0x6FFF,
QK_TAP_DANCE = 0x7100,
QK_TAP_DANCE_MAX = 0x71FF,
+#ifdef UNICODEMAP_ENABLE
+ QK_UNICODE_MAP = 0x7800,
+ QK_UNICODE_MAP_MAX = 0x7FFF,
+#endif
#ifdef UNICODE_ENABLE
QK_UNICODE = 0x8000,
QK_UNICODE_MAX = 0xFFFF,
@@ -195,6 +199,7 @@ enum quantum_keycodes {
#define HYPR(kc) (kc | QK_LCTL | QK_LSFT | QK_LALT | QK_LGUI)
#define MEH(kc) (kc | QK_LCTL | QK_LSFT | QK_LALT)
#define LCAG(kc) (kc | QK_LCTL | QK_LALT | QK_LGUI)
+#define ALTG(kc) (kc | QK_RCTL | QK_RALT)
#define MOD_HYPR 0xf
#define MOD_MEH 0x7
@@ -299,7 +304,10 @@ enum quantum_keycodes {
// ON_PRESS = 1
// ON_RELEASE = 2
// Unless you have a good reason not to do so, prefer ON_PRESS (1) as your default.
-#define TO(layer, when) (layer | QK_TO | (when << 0x4))
+// In fact, we changed it to assume ON_PRESS for sanity/simplicity. If needed, you can add your own
+// keycode modeled after the old version, kept below for this.
+/* #define TO(layer, when) (layer | QK_TO | (when << 0x4)) */
+#define TO(layer) (layer | QK_TO | (ON_PRESS << 0x4))
// Momentary switch layer - 256 layer max
#define MO(layer) (layer | QK_MOMENTARY)
@@ -339,5 +347,8 @@ enum quantum_keycodes {
#define UC(n) UNICODE(n)
#endif
+#ifdef UNICODEMAP_ENABLE
+ #define X(n) (n | QK_UNICODE_MAP)
+#endif
#endif
diff --git a/quantum/keymap_extras/keymap_br_abnt2.h b/quantum/keymap_extras/keymap_br_abnt2.h
new file mode 100644
index 0000000000..0df177721d
--- /dev/null
+++ b/quantum/keymap_extras/keymap_br_abnt2.h
@@ -0,0 +1,58 @@
+#ifndef KEYMAP_BR_ABNT2_H
+#define KEYMAP_BR_ABNT2_H
+
+#include "keymap_common.h"
+
+/* Scan codes for the Brazilian ABNT2 keyboard layout */
+
+#define BR_CCDL KC_SCLN // Ç same scancode as ;: on US layout
+#define BR_SCLN KC_SLSH // ;: same scancode as /? on US layout
+#define BR_QUOT KC_GRV // '" same scancode as `~ on US layout
+#define BR_TILD KC_QUOT // ~^ dead keys, same scancode as '" on US layout
+#define BR_ACUT KC_LBRC // ´` dead keys, same scancode as [{ on US layout
+#define BR_LBRC KC_RBRC // [{ same scancode as ]} on US layout
+#define BR_RBRC KC_BSLS // ]} same scancode as \| on US layout
+#define BR_BSLS KC_NUBS // \| uses the non-US hash scancode (#~, sometimes §±)
+#define BR_SLSH KC_INT1 // /? uses the INTL1 scancode
+
+#define BR_COLN LSFT(BR_SCLN) // shifted :
+#define BR_DQT LSFT(BR_QUOT) // shifted "
+#define BR_CIRC LSFT(BR_TILD) // shifted ^ (dead key)
+#define BR_GRAV LSFT(BR_ACUT) // shifted ` (dead key)
+#define BR_LCBR LSFT(BR_LBRC) // shifted {
+#define BR_RCBR LSFT(BR_RBRC) // shifted }
+#define BR_PIPE LSFT(BR_BSLS) // shifted |
+#define BR_QUES LSFT(BR_SLSH) // shifted ?
+#define BR_TRMA LSFT(KC_6) // shifted ¨ (dead key - trema accent)
+
+// On the ABNT2 the keypad comma and the keypad dot scancodes are switched
+// (presumably because in Brazil comma is used as the decimal separator)
+#define BR_KPDT KC_KP_COMMA // keypad .
+#define BR_KPCM KC_KP_DOT // keypad ,
+
+#define BR_1UP LALT(KC_1) // 1 superscript ¹ alt+1
+#define BR_2UP LALT(KC_2) // 2 superscript ² alt+2
+#define BR_3UP LALT(KC_3) // 3 superscript ³ alt+3
+#define BR_PND LALT(KC_4) // Pound sign £ alt+4
+#define BR_CENT LALT(KC_5) // Cent sign ¢ alt+5
+#define BR_NOT LALT(KC_6) // Not sign ¬ alt+6
+#define BR_SECT LALT(KC_EQL) // Section sign § alt+=
+#define BR_FORD LALT(BR_LBRC) // Feminine Ordinal Sign ª alt+[
+#define BR_MORD LALT(BR_RBRC) // Masculine Ordinal Sign º alt+]
+#define BR_DGRE LALT(BR_SLSH) // Degree sign ° alt+/
+
+#define BR_EURO LALT(KC_E) // Euro sign € alt+e
+#define BR_NDTD LALT(BR_TILD) // Non-dead key tilde ~ alt+~
+#define BR_NDAC LALT(BR_ACUT) // Non-dead key acute accent ´ alt+´
+#define BR_NDGV LALT(BR_QUOT) // Non-dead key grave accent ` alt+'
+#define BR_NDCR LALT(BR_CIRC) // Non-dead key circumflex accent ^ alt+^ (alt+shift+~)
+#define BR_NDTR LALT(BR_TRMA) // Non-dead key trema accent ¨ alt+¨ (alt+shift+6)
+
+// For 101-key keyboard layouts, the ABNT2 layout allows
+// the slash and question mark to be typed using alt+q and alt+w.
+// The shortcuts are provided here for completeness' sake,
+// but it's recommended to use BR_SLSH and BR_QUES instead
+#define BR_ASLS LALT(KC_Q)
+#define BR_AQST LALT(KC_W)
+
+#endif
diff --git a/quantum/keymap_extras/keymap_dvp.h b/quantum/keymap_extras/keymap_dvp.h
new file mode 100644
index 0000000000..83f49a52b5
--- /dev/null
+++ b/quantum/keymap_extras/keymap_dvp.h
@@ -0,0 +1,82 @@
+#ifndef KEYMAP_DVP_H
+#define KEYMAP_DVP_H
+
+#include "keymap.h"
+
+// Normal characters
+#define DP_DLR KC_GRV
+#define DP_AMPR KC_1
+#define DP_LBRC KC_2
+#define DP_LCBR KC_3
+#define DP_RCBR KC_4
+#define DP_LPRN KC_5
+#define DP_EQL KC_6
+#define DP_ASTR KC_7
+#define DP_RPRN KC_8
+#define DP_PLUS KC_9
+#define DP_RBRC KC_0
+#define DP_EXLM KC_MINS
+#define DP_HASH KC_EQL
+
+#define DP_SCLN KC_Q
+#define DP_COMM KC_W
+#define DP_DOT KC_E
+#define DP_P KC_R
+#define DP_Y KC_T
+#define DP_F KC_Y
+#define DP_G KC_U
+#define DP_C KC_I
+#define DP_R KC_O
+#define DP_L KC_P
+#define DP_SLSH KC_LBRC
+#define DP_AT KC_RBRC
+#define DP_BSLS KC_BSLS
+
+#define DP_A KC_A
+#define DP_O KC_S
+#define DP_E KC_D
+#define DP_U KC_F
+#define DP_I KC_G
+#define DP_D KC_H
+#define DP_H KC_J
+#define DP_T KC_K
+#define DP_N KC_L
+#define DP_S KC_SCLN
+#define DP_MINS KC_QUOT
+
+#define DP_QUOT KC_Z
+#define DP_Q KC_X
+#define DP_J KC_C
+#define DP_K KC_V
+#define DP_X KC_B
+#define DP_B KC_N
+#define DP_M KC_M
+#define DP_W KC_COMM
+#define DP_V KC_DOT
+#define DP_Z KC_SLSH
+
+// Shifted characters
+#define DP_TILD LSFT(DP_DLR)
+#define DP_PERC LSFT(DP_AMPR)
+#define DP_7 LSFT(DP_LBRC)
+#define DP_5 LSFT(DP_LCBR)
+#define DP_3 LSFT(DP_RCBR)
+#define DP_1 LSFT(DP_LPRN)
+#define DP_9 LSFT(DP_EQL)
+#define DP_0 LSFT(DP_ASTR)
+#define DP_2 LSFT(DP_RPRN)
+#define DP_4 LSFT(DP_PLUS)
+#define DP_6 LSFT(DP_RBRC)
+#define DP_8 LSFT(DP_EXLM)
+#define DP_GRV LSFT(DP_HASH)
+
+#define DP_COLN LSFT(DP_SCLN)
+#define DP_LABK LSFT(DP_COMM)
+#define DP_RABK LSFT(DP_DOT)
+#define DP_QUES LSFT(DP_SLSH)
+#define DP_CIRC LSFT(DP_AT)
+#define DP_PIPE LSFT(DP_BSLS)
+#define DP_UNDS LSFT(DP_MINS)
+#define DP_DQUO LSFT(DP_QUOT)
+
+#endif
diff --git a/quantum/light_ws2812.c b/quantum/light_ws2812.c
index d38dac4c69..497543339b 100755
--- a/quantum/light_ws2812.c
+++ b/quantum/light_ws2812.c
@@ -152,11 +152,6 @@ void inline ws2812_setleds_pin(struct cRGB *ledarray, uint16_t leds, uint8_t pin
// Setleds for SK6812RGBW
void inline ws2812_setleds_rgbw(struct cRGBW *ledarray, uint16_t leds)
{
- // ws2812_DDRREG |= _BV(ws2812_pin); // Enable DDR
- // new universal format (DDR)
- _SFR_IO8((RGB_DI_PIN >> 4) + 1) |= _BV(RGB_DI_PIN & 0xF);
-
- ws2812_sendarray_mask((uint8_t*)ledarray,leds<<2,_BV(RGB_DI_PIN & 0xF));
#ifdef RGBW_BB_TWI
cli();
@@ -169,14 +164,23 @@ void inline ws2812_setleds_rgbw(struct cRGBW *ledarray, uint16_t leds)
uint8_t * data = (uint8_t*)ledarray;
while (datlen--) {
curbyte=*data++;
- I2C_Write(curbyte % 0x10);
+ I2C_Write(curbyte);
}
I2C_Stop();
sei();
+ #else
+ _delay_us(80);
#endif
- _delay_us(80);
+ // ws2812_DDRREG |= _BV(ws2812_pin); // Enable DDR
+ // new universal format (DDR)
+ _SFR_IO8((RGB_DI_PIN >> 4) + 1) |= _BV(RGB_DI_PIN & 0xF);
+
+ ws2812_sendarray_mask((uint8_t*)ledarray,leds<<2,_BV(RGB_DI_PIN & 0xF));
+
+
+
}
void ws2812_sendarray(uint8_t *data,uint16_t datlen)
@@ -258,7 +262,7 @@ void inline ws2812_sendarray_mask(uint8_t *data,uint16_t datlen,uint8_t maskhi)
cli();
while (datlen--) {
- curbyte=(*data++) % 0x10;
+ curbyte=(*data++);
asm volatile(
" ldi %0,8 \n\t"
diff --git a/quantum/process_keycode/process_unicode.c b/quantum/process_keycode/process_unicode.c
index 6a30afe293..cd3a610b4d 100644
--- a/quantum/process_keycode/process_unicode.c
+++ b/quantum/process_keycode/process_unicode.c
@@ -42,6 +42,11 @@ void unicode_input_start (void) {
register_code(KC_PPLS);
unregister_code(KC_PPLS);
break;
+ case UC_WINC:
+ register_code(KC_RALT);
+ unregister_code(KC_RALT);
+ register_code(KC_U);
+ unregister_code(KC_U);
}
wait_ms(UNICODE_TYPE_DELAY);
}
@@ -78,6 +83,52 @@ bool process_unicode(uint16_t keycode, keyrecord_t *record) {
return true;
}
+#ifdef UNICODEMAP_ENABLE
+__attribute__((weak))
+const uint32_t PROGMEM unicode_map[] = {
+};
+
+void register_hex32(uint32_t hex) {
+ uint8_t onzerostart = 1;
+ for(int i = 7; i >= 0; i--) {
+ if (i <= 3) {
+ onzerostart = 0;
+ }
+ uint8_t digit = ((hex >> (i*4)) & 0xF);
+ if (digit == 0) {
+ if (onzerostart == 0) {
+ register_code(hex_to_keycode(digit));
+ unregister_code(hex_to_keycode(digit));
+ }
+ } else {
+ register_code(hex_to_keycode(digit));
+ unregister_code(hex_to_keycode(digit));
+ onzerostart = 0;
+ }
+ }
+}
+
+__attribute__((weak))
+void unicode_map_input_error() {}
+
+bool process_unicode_map(uint16_t keycode, keyrecord_t *record) {
+ if ((keycode & QK_UNICODE_MAP) == QK_UNICODE_MAP && record->event.pressed) {
+ const uint32_t* map = unicode_map;
+ uint16_t index = keycode & 0x7FF;
+ uint32_t code = pgm_read_dword_far(&map[index]);
+ if ((code > 0xFFFF && input_mode == UC_OSX) || (code > 0xFFFFF && input_mode == UC_LNX)) {
+ // when character is out of range supported by the OS
+ unicode_map_input_error();
+ } else {
+ unicode_input_start();
+ register_hex32(code);
+ unicode_input_finish();
+ }
+ }
+ return true;
+}
+#endif
+
#ifdef UCIS_ENABLE
qk_ucis_state_t qk_ucis_state;
diff --git a/quantum/process_keycode/process_unicode.h b/quantum/process_keycode/process_unicode.h
index 27f8072ee6..065eeb5f6a 100644
--- a/quantum/process_keycode/process_unicode.h
+++ b/quantum/process_keycode/process_unicode.h
@@ -3,10 +3,11 @@
#include "quantum.h"
-#define UC_OSX 0
-#define UC_LNX 1
-#define UC_WIN 2
-#define UC_BSD 3
+#define UC_OSX 0 // Mac OS X
+#define UC_LNX 1 // Linux
+#define UC_WIN 2 // Windows 'HexNumpad'
+#define UC_BSD 3 // BSD (not implemented)
+#define UC_WINC 4 // WinCompose https://github.com/samhocevar/wincompose
#ifndef UNICODE_TYPE_DELAY
#define UNICODE_TYPE_DELAY 10
@@ -20,6 +21,10 @@ void register_hex(uint16_t hex);
bool process_unicode(uint16_t keycode, keyrecord_t *record);
+#ifdef UNICODEMAP_ENABLE
+bool process_unicode_map(uint16_t keycode, keyrecord_t *record);
+#endif
+
#ifdef UCIS_ENABLE
#ifndef UCIS_MAX_SYMBOL_LENGTH
#define UCIS_MAX_SYMBOL_LENGTH 32
diff --git a/quantum/quantum.c b/quantum/quantum.c
index 5fa5e66b32..b8a81a76ba 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -131,6 +131,8 @@ bool process_record_quantum(keyrecord_t *record) {
#endif
#ifdef PRINTING_ENABLE
process_printer(keycode, record) &&
+ #ifdef UNICODEMAP_ENABLE
+ process_unicode_map(keycode, record) &&
#endif
true)) {
return false;
diff --git a/quantum/rgblight.c b/quantum/rgblight.c
index 801ca1d0d9..221a164026 100644
--- a/quantum/rgblight.c
+++ b/quantum/rgblight.c
@@ -6,24 +6,37 @@
#include "rgblight.h"
#include "debug.h"
+// 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 DIM_CURVE[] PROGMEM = {
- 0, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6,
- 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8,
- 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11,
- 11, 11, 12, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15,
- 15, 15, 16, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20,
- 20, 20, 21, 21, 22, 22, 22, 23, 23, 24, 24, 25, 25, 25, 26, 26,
- 27, 27, 28, 28, 29, 29, 30, 30, 31, 32, 32, 33, 33, 34, 35, 35,
- 36, 36, 37, 38, 38, 39, 40, 40, 41, 42, 43, 43, 44, 45, 46, 47,
- 48, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
- 63, 64, 65, 66, 68, 69, 70, 71, 73, 74, 75, 76, 78, 79, 81, 82,
- 83, 85, 86, 88, 90, 91, 93, 94, 96, 98, 99, 101, 103, 105, 107, 109,
- 110, 112, 114, 116, 118, 121, 123, 125, 127, 129, 132, 134, 136, 139, 141, 144,
- 146, 149, 151, 154, 157, 159, 162, 165, 168, 171, 174, 177, 180, 183, 186, 190,
- 193, 196, 200, 203, 207, 211, 214, 218, 222, 226, 230, 234, 238, 242, 248, 255
-};
+ 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 RGBLED_BREATHING_TABLE[] 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,
@@ -42,10 +55,16 @@ const uint8_t RGBLED_BREATHING_TABLE[] PROGMEM = {
37, 35, 33, 31, 29, 27, 25, 23, 21, 20, 18, 17, 15, 14, 12, 11,
10, 9, 7, 6, 5, 5, 4, 3, 2, 2, 1, 1, 1, 0, 0, 0
};
+
+__attribute__ ((weak))
const uint8_t RGBLED_BREATHING_INTERVALS[] PROGMEM = {30, 20, 10, 5};
+__attribute__ ((weak))
const uint8_t RGBLED_RAINBOW_MOOD_INTERVALS[] PROGMEM = {120, 60, 30};
+__attribute__ ((weak))
const uint8_t RGBLED_RAINBOW_SWIRL_INTERVALS[] PROGMEM = {100, 50, 20};
+__attribute__ ((weak))
const uint8_t RGBLED_SNAKE_INTERVALS[] PROGMEM = {100, 50, 20};
+__attribute__ ((weak))
const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {100, 50, 20};
rgblight_config_t rgblight_config;
@@ -59,13 +78,8 @@ uint8_t rgblight_inited = 0;
void sethsv(uint16_t hue, uint8_t sat, uint8_t val, struct cRGB *led1) {
- // Convert hue, saturation, and value (HSV/HSB) to RGB. DIM_CURVE is used only
- // on value and saturation (inverted). This looks the most natural.
uint8_t r = 0, g = 0, b = 0, base, color;
- val = pgm_read_byte(&DIM_CURVE[val]);
- sat = 255 - pgm_read_byte(&DIM_CURVE[255 - sat]);
-
if (sat == 0) { // Acromatic color (gray). Hue doesn't mind.
r = val;
g = val;
@@ -107,6 +121,9 @@ void sethsv(uint16_t hue, uint8_t sat, uint8_t val, struct cRGB *led1) {
break;
}
}
+ r = pgm_read_byte(&DIM_CURVE[r]);
+ g = pgm_read_byte(&DIM_CURVE[g]);
+ b = pgm_read_byte(&DIM_CURVE[b]);
setrgb(r, g, b, led1);
}
diff --git a/quantum/rgblight.h b/quantum/rgblight.h
index 2a712d8be4..efc685f312 100644
--- a/quantum/rgblight.h
+++ b/quantum/rgblight.h
@@ -41,6 +41,12 @@
#include "eeconfig.h"
#include "light_ws2812.h"
+extern const uint8_t RGBLED_BREATHING_INTERVALS[4] PROGMEM;
+extern const uint8_t RGBLED_RAINBOW_MOOD_INTERVALS[3] PROGMEM;
+extern const uint8_t RGBLED_RAINBOW_SWIRL_INTERVALS[3] PROGMEM;
+extern const uint8_t RGBLED_SNAKE_INTERVALS[3] PROGMEM;
+extern const uint8_t RGBLED_KNIGHT_INTERVALS[3] PROGMEM;
+
typedef union {
uint32_t raw;
struct {
diff --git a/quantum/variable_trace.c b/quantum/variable_trace.c
new file mode 100644
index 0000000000..de580244c3
--- /dev/null
+++ b/quantum/variable_trace.c
@@ -0,0 +1,110 @@
+#include "variable_trace.h"
+#include <stddef.h>
+#include <string.h>
+
+#ifdef NO_PRINT
+#error "You need undef NO_PRINT to use the variable trace feature"
+#endif
+
+#ifndef CONSOLE_ENABLE
+#error "The console needs to be enabled in the makefile to use the variable trace feature"
+#endif
+
+
+#define NUM_TRACED_VARIABLES 1
+#ifndef MAX_VARIABLE_TRACE_SIZE
+ #define MAX_VARIABLE_TRACE_SIZE 4
+#endif
+
+typedef struct {
+ const char* name;
+ void* addr;
+ unsigned size;
+ const char* func;
+ int line;
+ uint8_t last_value[MAX_VARIABLE_TRACE_SIZE];
+
+} traced_variable_t;
+
+static traced_variable_t traced_variables[NUM_TRACED_VARIABLES];
+
+void add_traced_variable(const char* name, void* addr, unsigned size, const char* func, int line) {
+ verify_traced_variables(func, line);
+ if (size > MAX_VARIABLE_TRACE_SIZE) {
+#if defined(__AVR__)
+ xprintf("Traced variable \"%S\" exceeds the maximum size %d\n", name, size);
+#else
+ xprintf("Traced variable \"%s\" exceeds the maximum size %d\n", name, size);
+#endif
+ size = MAX_VARIABLE_TRACE_SIZE;
+ }
+ int index = -1;
+ for (int i = 0; i < NUM_TRACED_VARIABLES; i++) {
+ if (index == -1 && traced_variables[i].addr == NULL){
+ index = i;
+ }
+ else if (strcmp_P(name, traced_variables[i].name)==0) {
+ index = i;
+ break;
+ }
+ }
+
+ if (index == -1) {
+ xprintf("You can only trace %d variables at the same time\n", NUM_TRACED_VARIABLES);
+ return;
+ }
+
+ traced_variable_t* t = &traced_variables[index];
+ t->name = name;
+ t->addr = addr;
+ t->size = size;
+ t->func = func;
+ t->line = line;
+ memcpy(&t->last_value[0], addr, size);
+
+}
+
+void remove_traced_variable(const char* name, const char* func, int line) {
+ verify_traced_variables(func, line);
+ for (int i = 0; i < NUM_TRACED_VARIABLES; i++) {
+ if (strcmp_P(name, traced_variables[i].name)==0) {
+ traced_variables[i].name = 0;
+ traced_variables[i].addr = NULL;
+ break;
+ }
+ }
+}
+
+void verify_traced_variables(const char* func, int line) {
+ for (int i = 0; i < NUM_TRACED_VARIABLES; i++) {
+ traced_variable_t* t = &traced_variables[i];
+ if (t->addr != NULL && t->name != NULL) {
+ if (memcmp(t->last_value, t->addr, t->size)!=0){
+#if defined(__AVR__)
+ xprintf("Traced variable \"%S\" has been modified\n", t->name);
+ xprintf("Between %S:%d\n", t->func, t->line);
+ xprintf("And %S:%d\n", func, line);
+
+#else
+ xprintf("Traced variable \"%s\" has been modified\n", t->name);
+ xprintf("Between %s:%d\n", t->func, t->line);
+ xprintf("And %s:%d\n", func, line);
+#endif
+ xprintf("Previous value ");
+ for (int j=0; j<t->size;j++) {
+ print_hex8(t->last_value[j]);
+ }
+ xprintf("\nNew value ");
+ uint8_t* addr = (uint8_t*)(t->addr);
+ for (int j=0; j<t->size;j++) {
+ print_hex8(addr[j]);
+ }
+ xprintf("\n");
+ memcpy(t->last_value, addr, t->size);
+ }
+ }
+
+ t->func = func;
+ t->line = line;
+ }
+}
diff --git a/quantum/variable_trace.h b/quantum/variable_trace.h
new file mode 100644
index 0000000000..46bd827861
--- /dev/null
+++ b/quantum/variable_trace.h
@@ -0,0 +1,34 @@
+#ifndef VARIABLE_TRACE_H
+#define VARIABLE_TRACE_H
+
+// For more information about the variable tracing see the readme.
+
+#include "print.h"
+
+#ifdef NUM_TRACED_VARIABLES
+
+// Start tracing a variable at the memory address addr
+// The name can be anything and is used only for reporting
+// The size should usually be the same size as the variable you are interested in
+#define ADD_TRACED_VARIABLE(name, addr, size) \
+ add_traced_variable(PSTR(name), (void*)addr, size, PSTR(__FILE__), __LINE__)
+
+// Stop tracing the variable with the given name
+#define REMOVE_TRACED_VARIABLE(name) remove_traced_variable(PSTR(name), PSTR(__FILE__), __LINE__)
+
+// Call to get messages when the variable has been changed
+#define VERIFY_TRACED_VARIABLES() verify_traced_variables(PSTR(__FILE__), __LINE__)
+
+#else
+
+#define ADD_TRACED_VARIABLE(name, addr, size)
+#define REMOVE_TRACED_VARIABLE(name)
+#define VERIFY_TRACED_VARIABLES()
+
+#endif
+
+// Don't call directly, use the macros instead
+void add_traced_variable(const char* name, void* addr, unsigned size, const char* func, int line);
+void remove_traced_variable(const char* name, const char* func, int line);
+void verify_traced_variables(const char* func, int line);
+#endif