From a916f4e8b897b6b8925d7113d84f9eac7e7b67be Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Sat, 3 Jun 2017 14:34:50 +0300 Subject: Let BACKLIGHT_ENABLE control the Infinity LEDs --- quantum/visualizer/visualizer.c | 4 ++-- quantum/visualizer/visualizer.mk | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'quantum') diff --git a/quantum/visualizer/visualizer.c b/quantum/visualizer/visualizer.c index 6f134097f0..cd2dff6a6d 100644 --- a/quantum/visualizer/visualizer.c +++ b/quantum/visualizer/visualizer.c @@ -309,7 +309,7 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) { update_keyframe_animation(animations[i], &state, delta, &sleep_time); } } -#ifdef LED_ENABLE +#ifdef BACKLIGHT_ENABLE gdispGFlush(LED_DISPLAY); #endif @@ -372,7 +372,7 @@ void visualizer_init(void) { #ifdef LCD_ENABLE LCD_DISPLAY = get_lcd_display(); #endif -#ifdef LED_ENABLE +#ifdef BACKLIGHT_ENABLE LED_DISPLAY = get_led_display(); #endif diff --git a/quantum/visualizer/visualizer.mk b/quantum/visualizer/visualizer.mk index 5f710124bc..6f97603bd8 100644 --- a/quantum/visualizer/visualizer.mk +++ b/quantum/visualizer/visualizer.mk @@ -42,9 +42,8 @@ SRC += $(VISUALIZER_DIR)/resources/lcd_logo.c OPT_DEFS += -DLCD_BACKLIGHT_ENABLE endif -ifeq ($(strip $(LED_ENABLE)), yes) +ifeq ($(strip $(BACKLIGHT_ENABLE)), yes) SRC += $(VISUALIZER_DIR)/led_keyframes.c -OPT_DEFS += -DLED_ENABLE endif include $(GFXLIB)/gfx.mk -- cgit v1.2.3 From effffa33a503a093be4fa00b570df7a4e2996edc Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Sat, 3 Jun 2017 21:14:26 +0300 Subject: Backlight level handling for the visualizer --- quantum/visualizer/visualizer.c | 30 +++++++++++++++++++++++++++++- quantum/visualizer/visualizer.h | 9 ++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) (limited to 'quantum') diff --git a/quantum/visualizer/visualizer.c b/quantum/visualizer/visualizer.c index cd2dff6a6d..29db7005ce 100644 --- a/quantum/visualizer/visualizer.c +++ b/quantum/visualizer/visualizer.c @@ -58,8 +58,11 @@ SOFTWARE. static visualizer_keyboard_status_t current_status = { .layer = 0xFFFFFFFF, .default_layer = 0xFFFFFFFF, - .mods = 0xFF, .leds = 0xFFFFFFFF, +#ifdef BACKLIGHT_ENABLE + .backlight_level = 0, +#endif + .mods = 0xFF, .suspended = false, #ifdef VISUALIZER_USER_DATA_SIZE .user_data = {0} @@ -72,6 +75,9 @@ static bool same_status(visualizer_keyboard_status_t* status1, visualizer_keyboa status1->mods == status2->mods && status1->leds == status2->leds && status1->suspended == status2->suspended +#ifdef BACKLIGHT_ENABLE + && status1->backlight_level == status2->backlight_level +#endif #ifdef VISUALIZER_USER_DATA_SIZE && memcmp(status1->user_data, status2->user_data, VISUALIZER_USER_DATA_SIZE) == 0 #endif @@ -279,6 +285,18 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) { bool enabled = visualizer_enabled; if (force_update || !same_status(&state.status, ¤t_status)) { force_update = false; + #if BACKLIGHT_ENABLE + if(current_status.backlight_level != state.status.backlight_level) { + if (current_status.backlight_level != 0) { + gdispGSetPowerMode(LED_DISPLAY, powerOn); + uint16_t percent = (uint16_t)current_status.backlight_level * 100 / 255; + gdispGSetBacklight(LED_DISPLAY, percent); + } + else { + gdispGSetPowerMode(LED_DISPLAY, powerOff); + } + } + #endif if (visualizer_enabled) { if (current_status.suspended) { stop_all_keyframe_animations(); @@ -445,6 +463,9 @@ void visualizer_update(uint32_t default_state, uint32_t state, uint8_t mods, uin .default_layer = default_state, .mods = mods, .leds = leds, +#ifdef BACKLIGHT_ENABLE + .backlight_level = current_status.backlight_level, +#endif .suspended = current_status.suspended, }; #ifdef VISUALIZER_USER_DATA_SIZE @@ -467,3 +488,10 @@ void visualizer_resume(void) { current_status.suspended = false; update_status(true); } + +#ifdef BACKLIGHT_ENABLE +void backlight_set(uint8_t level) { + current_status.backlight_level = level; + update_status(true); +} +#endif diff --git a/quantum/visualizer/visualizer.h b/quantum/visualizer/visualizer.h index d6f279e101..1c567440fb 100644 --- a/quantum/visualizer/visualizer.h +++ b/quantum/visualizer/visualizer.h @@ -34,6 +34,10 @@ SOFTWARE. #include "lcd_backlight.h" #endif +#ifdef BACKLIGHT_ENABLE +#include "backlight.h" +#endif + // use this function to merge both real_mods and oneshot_mods in a uint16_t uint8_t visualizer_get_mods(void); @@ -65,9 +69,12 @@ struct keyframe_animation_t; typedef struct { uint32_t layer; uint32_t default_layer; - uint8_t mods; uint32_t leds; // See led.h for available statuses + uint8_t mods; bool suspended; +#ifdef BACKLIGHT_ENABLE + uint8_t backlight_level; +#endif #ifdef VISUALIZER_USER_DATA_SIZE uint8_t user_data[VISUALIZER_USER_DATA_SIZE]; #endif -- cgit v1.2.3 From b51a0db6ed03d939baad7cb9d87ed13c3653c7d2 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Sat, 3 Jun 2017 22:04:10 +0300 Subject: Add backlight support to the default Ergodox Infinity animations --- quantum/visualizer/led_keyframes.c | 14 ++++++++++++++ quantum/visualizer/led_keyframes.h | 3 +++ 2 files changed, 17 insertions(+) (limited to 'quantum') diff --git a/quantum/visualizer/led_keyframes.c b/quantum/visualizer/led_keyframes.c index 2dacd990d1..c14491e5e1 100644 --- a/quantum/visualizer/led_keyframes.c +++ b/quantum/visualizer/led_keyframes.c @@ -127,3 +127,17 @@ bool led_keyframe_normal_orientation(keyframe_animation_t* animation, visualizer gdispGSetOrientation(LED_DISPLAY, GDISP_ROTATE_0); return false; } + +bool led_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) { + (void)state; + (void)animation; + gdispGSetPowerMode(LED_DISPLAY, powerOff); + return false; +} + +bool led_keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state) { + (void)state; + (void)animation; + gdispGSetPowerMode(LED_DISPLAY, powerOn); + return false; +} diff --git a/quantum/visualizer/led_keyframes.h b/quantum/visualizer/led_keyframes.h index a689430417..a59a4f37d1 100644 --- a/quantum/visualizer/led_keyframes.h +++ b/quantum/visualizer/led_keyframes.h @@ -35,6 +35,9 @@ bool led_keyframe_crossfade(keyframe_animation_t* animation, visualizer_state_t* bool led_keyframe_mirror_orientation(keyframe_animation_t* animation, visualizer_state_t* state); bool led_keyframe_normal_orientation(keyframe_animation_t* animation, visualizer_state_t* state); +bool led_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state); +bool led_keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state); + extern keyframe_animation_t led_test_animation; -- cgit v1.2.3 From 2c404cca1222fe2ceee0975605dcfc53f1e57262 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor?= Date: Mon, 12 Jun 2017 20:49:51 +0200 Subject: Fix keymap definitions referencing inexistent macros --- quantum/keymap_extras/keymap_spanish.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'quantum') diff --git a/quantum/keymap_extras/keymap_spanish.h b/quantum/keymap_extras/keymap_spanish.h index 3a5787e9c4..e859001e8c 100644 --- a/quantum/keymap_extras/keymap_spanish.h +++ b/quantum/keymap_extras/keymap_spanish.h @@ -55,8 +55,8 @@ #define ES_UMLT LSFT(ES_GRV) #define ES_GRTR LSFT(ES_LESS) -#define ES_SCLN LSFT(ES_COMM) -#define ES_COLN LSFT(ES_DOT) +#define ES_SCLN LSFT(KC_COMM) +#define ES_COLN LSFT(KC_DOT) #define ES_UNDS LSFT(ES_MINS) // Alt Gr-ed characters -- cgit v1.2.3 From 21fa16651c500ac3f91231ae5dd2749b739b401b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor?= Date: Mon, 12 Jun 2017 21:02:30 +0200 Subject: Rename ES_RCRB to ES_RCBR for consistency reasons (left curly bracket is defined as ES_LCBR) --- quantum/keymap_extras/keymap_spanish.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'quantum') diff --git a/quantum/keymap_extras/keymap_spanish.h b/quantum/keymap_extras/keymap_spanish.h index e859001e8c..224db7be16 100644 --- a/quantum/keymap_extras/keymap_spanish.h +++ b/quantum/keymap_extras/keymap_spanish.h @@ -72,6 +72,6 @@ #define ES_RBRC ALGR(ES_PLUS) #define ES_LCBR ALGR(ES_ACUT) -#define ES_RCRB ALGR(ES_CCED) +#define ES_RCBR ALGR(ES_CCED) #endif -- cgit v1.2.3 From 7d5606085fbd775019fc514f3ffca84edfc11aa6 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Fri, 16 Jun 2017 02:01:02 +0300 Subject: Correctly calculate backlight level --- quantum/visualizer/visualizer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'quantum') diff --git a/quantum/visualizer/visualizer.c b/quantum/visualizer/visualizer.c index 29db7005ce..486ff25b3f 100644 --- a/quantum/visualizer/visualizer.c +++ b/quantum/visualizer/visualizer.c @@ -289,7 +289,7 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) { if(current_status.backlight_level != state.status.backlight_level) { if (current_status.backlight_level != 0) { gdispGSetPowerMode(LED_DISPLAY, powerOn); - uint16_t percent = (uint16_t)current_status.backlight_level * 100 / 255; + uint16_t percent = (uint16_t)current_status.backlight_level * 100 / BACKLIGHT_LEVELS; gdispGSetBacklight(LED_DISPLAY, percent); } else { -- cgit v1.2.3 From 98316ef0170c6e0f994a45e1f62959ae0f278177 Mon Sep 17 00:00:00 2001 From: jamesofarrell Date: Sat, 17 Jun 2017 07:56:50 +1000 Subject: Added Grave Escape (#1391) * added QK_GRAVE_ESC and KC_GESC * fixed name * Fixed keycode emnu * Removed layer check, added left and right GUI mod detection for OSX GUI+~ --- quantum/quantum.c | 8 ++++++++ quantum/quantum_keycodes.h | 3 +++ 2 files changed, 11 insertions(+) (limited to 'quantum') diff --git a/quantum/quantum.c b/quantum/quantum.c index 4f4cee4e9b..f5fb1e35c8 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -437,6 +437,14 @@ bool process_record_quantum(keyrecord_t *record) { return false; // break; } + case GRAVE_ESC: { + void (*method)(uint8_t) = (record->event.pressed) ? &add_key : &del_key; + uint8_t shifted = get_mods() & ((MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT) + |MOD_BIT(KC_LGUI)|MOD_BIT(KC_RGUI))); + + method(shifted ? KC_GRAVE : KC_ESCAPE); + send_keyboard_report(); + } default: { shift_interrupted[0] = true; shift_interrupted[1] = true; diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 7354ae0da1..c34ecafa51 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -104,6 +104,7 @@ enum quantum_keycodes { MAGIC_UNHOST_NKRO, MAGIC_UNSWAP_ALT_GUI, MAGIC_TOGGLE_NKRO, + GRAVE_ESC, // Leader key #ifndef DISABLE_LEADER @@ -514,6 +515,8 @@ enum quantum_keycodes { #define MACROTAP(kc) (kc | QK_MACRO | FUNC_TAP<<8) #define MACRODOWN(...) (record->event.pressed ? MACRO(__VA_ARGS__) : MACRO_NONE) +#define KC_GESC GRAVE_ESC + // L-ayer, T-ap - 256 keycode max, 16 layer max #define LT(layer, kc) (kc | QK_LAYER_TAP | ((layer & 0xF) << 8)) -- cgit v1.2.3 From 6c9b4743f766cffe0f382d39591219543dc92d48 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Sat, 15 Apr 2017 12:35:55 +0300 Subject: Include config.h before visualizer.h --- quantum/visualizer/visualizer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'quantum') diff --git a/quantum/visualizer/visualizer.c b/quantum/visualizer/visualizer.c index 486ff25b3f..a4b3ea7e49 100644 --- a/quantum/visualizer/visualizer.c +++ b/quantum/visualizer/visualizer.c @@ -22,8 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "visualizer.h" #include "config.h" +#include "visualizer.h" #include #ifdef PROTOCOL_CHIBIOS #include "ch.h" -- cgit v1.2.3 From ff49259a1a965f13761d8f1dda4813a2aa87d718 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Sat, 15 Apr 2017 14:24:26 +0300 Subject: Include config.h from visualizer.h --- quantum/visualizer/visualizer.h | 1 + 1 file changed, 1 insertion(+) (limited to 'quantum') diff --git a/quantum/visualizer/visualizer.h b/quantum/visualizer/visualizer.h index 1c567440fb..90ecdcbaea 100644 --- a/quantum/visualizer/visualizer.h +++ b/quantum/visualizer/visualizer.h @@ -28,6 +28,7 @@ SOFTWARE. #include #include +#include "config.h" #include "gfx.h" #ifdef LCD_BACKLIGHT_ENABLE -- cgit v1.2.3 From da19852964e5c1a03b505bcbc7e063fbd8a63fa9 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Sat, 22 Apr 2017 12:47:45 +0300 Subject: Add function for getting the LCD backlight brightness --- quantum/visualizer/lcd_backlight.c | 4 ++++ quantum/visualizer/lcd_backlight.h | 1 + 2 files changed, 5 insertions(+) (limited to 'quantum') diff --git a/quantum/visualizer/lcd_backlight.c b/quantum/visualizer/lcd_backlight.c index 00de3fab52..6cd996f75e 100644 --- a/quantum/visualizer/lcd_backlight.c +++ b/quantum/visualizer/lcd_backlight.c @@ -83,3 +83,7 @@ void lcd_backlight_brightness(uint8_t b) { current_brightness = b; lcd_backlight_color(current_hue, current_saturation, current_intensity); } + +uint8_t lcd_get_backlight_brightness(void) { + return current_brightness; +} diff --git a/quantum/visualizer/lcd_backlight.h b/quantum/visualizer/lcd_backlight.h index 14dde64a1a..172e9bac58 100644 --- a/quantum/visualizer/lcd_backlight.h +++ b/quantum/visualizer/lcd_backlight.h @@ -39,6 +39,7 @@ inline uint32_t change_lcd_color_intensity(uint32_t color, uint8_t new_intensity void lcd_backlight_init(void); void lcd_backlight_color(uint8_t hue, uint8_t saturation, uint8_t intensity); void lcd_backlight_brightness(uint8_t b); +uint8_t lcd_get_backlight_brightness(void); void lcd_backlight_hal_init(void); void lcd_backlight_hal_color(uint16_t r, uint16_t g, uint16_t b); -- cgit v1.2.3 From f912c74fe7a4a7108e8966ebe4802eae92739dd1 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Sat, 22 Apr 2017 19:49:41 +0300 Subject: Change inline to static inline --- quantum/visualizer/lcd_backlight.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'quantum') diff --git a/quantum/visualizer/lcd_backlight.h b/quantum/visualizer/lcd_backlight.h index 172e9bac58..95d7a07b46 100644 --- a/quantum/visualizer/lcd_backlight.h +++ b/quantum/visualizer/lcd_backlight.h @@ -32,7 +32,7 @@ SOFTWARE. #define LCD_SAT(color) ((color >> 8) & 0xFF) #define LCD_INT(color) (color & 0xFF) -inline uint32_t change_lcd_color_intensity(uint32_t color, uint8_t new_intensity) { +static inline uint32_t change_lcd_color_intensity(uint32_t color, uint8_t new_intensity) { return (color & 0xFFFFFF00) | new_intensity; } -- cgit v1.2.3 From 5dae013ff8794564e46acf7bd75ad43bdcafb8ea Mon Sep 17 00:00:00 2001 From: rai-suta Date: Sat, 24 Jun 2017 18:29:37 +0900 Subject: Add JIS_KEYCODE layout for send_string() --- quantum/quantum.c | 142 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 120 insertions(+), 22 deletions(-) (limited to 'quantum') diff --git a/quantum/quantum.c b/quantum/quantum.c index f5fb1e35c8..3b5e52ff12 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -455,7 +455,103 @@ bool process_record_quantum(keyrecord_t *record) { return process_action_kb(record); } -const bool ascii_to_qwerty_shift_lut[0x80] PROGMEM = { +#ifdef JIS_KEYCODE +static const uint16_t ascii_to_shift_lut[8] PROGMEM = { + 0x0000, /*0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0,*/ + 0x0000, /*0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0,*/ + 0x7ff0, /*0, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 0, 0, 0, 0,*/ + 0x000f, /*0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 1,*/ + 0x7fff, /*0, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1,*/ + 0xffe1, /*1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 1,*/ + 0x8000, /*1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0,*/ + 0x001e, /*0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 1, 1, 1, 0*/ +}; + +static const struct { + uint8_t controls_0[16], + controls_1[16], + numerics[16], + alphabets_0[16], + alphabets_1[16]; +} lower_to_keycode PROGMEM = { + .controls_0 = { + 0, 0, 0, 0, 0, 0, 0, 0, + KC_BSPC, KC_TAB, KC_ENT, 0, 0, 0, 0, 0, + }, + .controls_1 = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, KC_ESC, 0, 0, 0, 0, + }, + .numerics = { + KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, + KC_8, KC_9, KC_QUOT, KC_SCLN, KC_COMM, KC_MINS, KC_DOT, KC_SLSH, + }, + .alphabets_0 = { + KC_LBRC, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G, + KC_H, KC_I, KC_J, KC_K, KC_L, KC_M, KC_N, KC_O, + }, + .alphabets_1 = { + KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W, + KC_X, KC_Y, KC_Z, KC_RBRC, KC_JYEN, KC_BSLS, KC_EQL, KC_RO, + }, +}; +static const uint8_t* ascii_to_keycode_lut[8] = { + lower_to_keycode.controls_0, + lower_to_keycode.controls_1, + lower_to_keycode.numerics, + lower_to_keycode.numerics, + lower_to_keycode.alphabets_0, + lower_to_keycode.alphabets_1, + lower_to_keycode.alphabets_0, + lower_to_keycode.alphabets_1 +}; + +void send_string(const char *str) { + while (1) { + uint8_t keycode; + bool shift; + uint8_t ascii_code = pgm_read_byte(str); + + if ( ascii_code == 0x00u ){ break; } + else if (ascii_code == 0x20u) { + keycode = KC_SPC; + shift = false; + } + else if (ascii_code == 0x7Fu) { + keycode = KC_DEL; + shift = false; + } + else { + int hi = ascii_code>>4 & 0x0f; + lo = ascii_code & 0x0f; + keycode = pgm_read_byte(&ascii_to_keycode_lut[hi][lo]); + shift = !!( pgm_read_word(&ascii_to_shift_lut[hi]) & (0x8000u>>lo) ); + } + + if (shift) { + register_code(KC_LSFT); + register_code(keycode); + unregister_code(keycode); + unregister_code(KC_LSFT); + } + else { + register_code(keycode); + unregister_code(keycode); + } + ++str; + } +} + +#else +static const bool ascii_to_qwerty_shift_lut[0x80] PROGMEM = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -474,7 +570,7 @@ const bool ascii_to_qwerty_shift_lut[0x80] PROGMEM = { 0, 0, 0, 1, 1, 1, 1, 0 }; -const uint8_t ascii_to_qwerty_keycode_lut[0x80] PROGMEM = { +static const uint8_t ascii_to_qwerty_keycode_lut[0x80] PROGMEM = { 0, 0, 0, 0, 0, 0, 0, 0, KC_BSPC, KC_TAB, KC_ENT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -493,6 +589,28 @@ const uint8_t ascii_to_qwerty_keycode_lut[0x80] PROGMEM = { KC_X, KC_Y, KC_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_GRV, KC_DEL }; +void send_string(const char *str) { + while (1) { + uint8_t keycode; + uint8_t ascii_code = pgm_read_byte(str); + if (!ascii_code) break; + keycode = pgm_read_byte(&ascii_to_qwerty_keycode_lut[ascii_code]); + if (pgm_read_byte(&ascii_to_qwerty_shift_lut[ascii_code])) { + register_code(KC_LSFT); + register_code(keycode); + unregister_code(keycode); + unregister_code(KC_LSFT); + } + else { + register_code(keycode); + unregister_code(keycode); + } + ++str; + } +} + +#endif + /* for users whose OSes are set to Colemak */ #if 0 #include "keymap_colemak.h" @@ -537,26 +655,6 @@ const uint8_t ascii_to_colemak_keycode_lut[0x80] PROGMEM = { #endif -void send_string(const char *str) { - while (1) { - uint8_t keycode; - uint8_t ascii_code = pgm_read_byte(str); - if (!ascii_code) break; - keycode = pgm_read_byte(&ascii_to_qwerty_keycode_lut[ascii_code]); - if (pgm_read_byte(&ascii_to_qwerty_shift_lut[ascii_code])) { - register_code(KC_LSFT); - register_code(keycode); - unregister_code(keycode); - unregister_code(KC_LSFT); - } - else { - register_code(keycode); - unregister_code(keycode); - } - ++str; - } -} - void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) { if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) { layer_on(layer3); -- cgit v1.2.3 From 582a6ac75ca52bc9f30657906878385be4d16643 Mon Sep 17 00:00:00 2001 From: skullY Date: Sat, 24 Jun 2017 15:28:13 -0700 Subject: Fix #1135 by changing the default to at90usb1286 --- quantum/template/rules.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'quantum') diff --git a/quantum/template/rules.mk b/quantum/template/rules.mk index a1f9377d87..a3571e8deb 100644 --- a/quantum/template/rules.mk +++ b/quantum/template/rules.mk @@ -1,5 +1,5 @@ # MCU name -#MCU = at90usb1287 +#MCU = at90usb1286 MCU = atmega32u4 # Processor frequency. -- cgit v1.2.3 From 1e6a3f9e170759dd88ba29f67d35d9c34b3f8f8c Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Sun, 25 Jun 2017 12:55:18 +0300 Subject: Change M_2_PI to 2 * PI as it should be --- quantum/visualizer/led_keyframes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'quantum') diff --git a/quantum/visualizer/led_keyframes.c b/quantum/visualizer/led_keyframes.c index c14491e5e1..2f4e200439 100644 --- a/quantum/visualizer/led_keyframes.c +++ b/quantum/visualizer/led_keyframes.c @@ -48,7 +48,7 @@ static uint8_t crossfade_start_frame[NUM_ROWS][NUM_COLS]; static uint8_t crossfade_end_frame[NUM_ROWS][NUM_COLS]; static uint8_t compute_gradient_color(float t, float index, float num) { - const float two_pi = M_2_PI; + const float two_pi = M_PI * 2.0f; float normalized_index = (1.0f - index / (num - 1.0f)) * two_pi; float x = t * two_pi + normalized_index; float v = 0.5 * (cosf(x) + 1.0f); -- cgit v1.2.3 From e740520b3fe8fdeebd087fe6b7390582661f86f8 Mon Sep 17 00:00:00 2001 From: rai-suta Date: Mon, 26 Jun 2017 00:24:32 +0900 Subject: Fix bug. --- quantum/quantum.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'quantum') diff --git a/quantum/quantum.c b/quantum/quantum.c index 3b5e52ff12..5bb7b04d53 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -530,7 +530,7 @@ void send_string(const char *str) { shift = false; } else { - int hi = ascii_code>>4 & 0x0f; + int hi = ascii_code>>4 & 0x0f, lo = ascii_code & 0x0f; keycode = pgm_read_byte(&ascii_to_keycode_lut[hi][lo]); shift = !!( pgm_read_word(&ascii_to_shift_lut[hi]) & (0x8000u>>lo) ); -- cgit v1.2.3 From 42e6ecc36b65ad0f0d29c6c35c93b95078c11a1a Mon Sep 17 00:00:00 2001 From: Ethan Madden Date: Sun, 25 Jun 2017 18:30:40 -0700 Subject: Whitefox LED control (#1432) * use new grave_esc functionality * Port LED control from Ergodox Infinity to Whitefox --- quantum/visualizer/led_keyframes.c | 4 ++-- quantum/visualizer/visualizer.c | 33 +++++++++++++++++++-------------- quantum/visualizer/visualizer.mk | 26 +++++++++++++++----------- 3 files changed, 36 insertions(+), 27 deletions(-) (limited to 'quantum') diff --git a/quantum/visualizer/led_keyframes.c b/quantum/visualizer/led_keyframes.c index 2f4e200439..7e6e5d1ab9 100644 --- a/quantum/visualizer/led_keyframes.c +++ b/quantum/visualizer/led_keyframes.c @@ -41,8 +41,8 @@ static void keyframe_fade_all_leds_from_to(keyframe_animation_t* animation, uint } // TODO: Should be customizable per keyboard -#define NUM_ROWS 7 -#define NUM_COLS 7 +#define NUM_ROWS LED_NUM_ROWS +#define NUM_COLS LED_NUM_COLS static uint8_t crossfade_start_frame[NUM_ROWS][NUM_COLS]; static uint8_t crossfade_end_frame[NUM_ROWS][NUM_COLS]; diff --git a/quantum/visualizer/visualizer.c b/quantum/visualizer/visualizer.c index a4b3ea7e49..cc99d1e3b6 100644 --- a/quantum/visualizer/visualizer.c +++ b/quantum/visualizer/visualizer.c @@ -105,15 +105,19 @@ static remote_object_t* remote_objects[] = { GDisplay* LCD_DISPLAY = 0; GDisplay* LED_DISPLAY = 0; +#ifdef LCD_DISPLAY_NUMBER __attribute__((weak)) GDisplay* get_lcd_display(void) { - return gdispGetDisplay(0); + return gdispGetDisplay(LCD_DISPLAY_NUMBER); } +#endif +#ifdef LED_DISPLAY_NUMBER __attribute__((weak)) GDisplay* get_led_display(void) { - return gdispGetDisplay(1); + return gdispGetDisplay(LED_DISPLAY_NUMBER); } +#endif void start_keyframe_animation(keyframe_animation_t* animation) { animation->current_frame = -1; @@ -251,9 +255,9 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) { .mods = 0xFF, .leds = 0xFFFFFFFF, .suspended = false, -#ifdef VISUALIZER_USER_DATA_SIZE + #ifdef VISUALIZER_USER_DATA_SIZE .user_data = {0}, -#endif + #endif }; visualizer_state_t state = { @@ -379,25 +383,26 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) { void visualizer_init(void) { gfxInit(); -#ifdef LCD_BACKLIGHT_ENABLE + #ifdef LCD_BACKLIGHT_ENABLE lcd_backlight_init(); -#endif + #endif -#ifdef SERIAL_LINK_ENABLE + #ifdef SERIAL_LINK_ENABLE add_remote_objects(remote_objects, sizeof(remote_objects) / sizeof(remote_object_t*) ); -#endif + #endif -#ifdef LCD_ENABLE + #ifdef LCD_ENABLE LCD_DISPLAY = get_lcd_display(); -#endif -#ifdef BACKLIGHT_ENABLE + #endif + + #ifdef BACKLIGHT_ENABLE LED_DISPLAY = get_led_display(); -#endif + #endif // We are using a low priority thread, the idea is to have it run only // when the main thread is sleeping during the matrix scanning - gfxThreadCreate(visualizerThreadStack, sizeof(visualizerThreadStack), - VISUALIZER_THREAD_PRIORITY, visualizerThread, NULL); + gfxThreadCreate(visualizerThreadStack, sizeof(visualizerThreadStack), + VISUALIZER_THREAD_PRIORITY, visualizerThread, NULL); } void update_status(bool changed) { diff --git a/quantum/visualizer/visualizer.mk b/quantum/visualizer/visualizer.mk index 6f97603bd8..0f7d8636cf 100644 --- a/quantum/visualizer/visualizer.mk +++ b/quantum/visualizer/visualizer.mk @@ -51,19 +51,23 @@ GFXSRC := $(patsubst $(TOP_DIR)/%,%,$(GFXSRC)) GFXDEFS := $(patsubst %,-D%,$(patsubst -D%,%,$(GFXDEFS))) ifneq ("$(wildcard $(KEYMAP_PATH)/visualizer.c)","") - SRC += keyboards/$(KEYBOARD)/keymaps/$(KEYMAP)/visualizer.c + SRC += keyboards/$(KEYBOARD)/keymaps/$(KEYMAP)/visualizer.c else - ifeq ("$(wildcard $(SUBPROJECT_PATH)/keymaps/$(KEYMAP)/visualizer.c)","") - ifeq ("$(wildcard $(SUBPROJECT_PATH)/visualizer.c)","") -$(error "$(KEYMAP_PATH)/visualizer.c" does not exist) - else - SRC += keyboards/$(KEYBOARD)/$(SUBPROJECT)/visualizer.c - endif - else - SRC += keyboards/$(KEYBOARD)/$(SUBPROJECT)/keymaps/$(KEYMAP)/visualizer.c - endif + ifeq ("$(wildcard $(SUBPROJECT_PATH)/keymaps/$(KEYMAP)/visualizer.c)","") + ifeq ("$(wildcard $(SUBPROJECT_PATH)/visualizer.c)","") + ifeq ("$(wildcard $(KEYBOARD_PATH)/visualizer.c)","") +$(error "visualizer.c" not found") + else + SRC += keyboards/$(KEYBOARD)/visualizer.c + endif + else + SRC += keyboards/$(KEYBOARD)/$(SUBPROJECT)/visualizer.c + endif + else + SRC += keyboards/$(KEYBOARD)/$(SUBPROJECT)/keymaps/$(KEYMAP)/visualizer.c + endif endif ifdef EMULATOR UINCDIR += $(TMK_DIR)/common -endif \ No newline at end of file +endif -- cgit v1.2.3 From 61cdc9aaa462afbcbaf57f2c5991e06924caed0e Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Mon, 26 Jun 2017 18:54:01 -0400 Subject: Allow mod swapping for mod tap (MT) (#1202) * allow mod swapping for mod tap * quick include * fix the mod swapping * make changes consistent with action code * fix bug * re-enable no gui, etc * fix binary comps * solid logic --- quantum/keycode_config.c | 28 ++++++++++++++++++++++++++++ quantum/keycode_config.h | 2 ++ quantum/keymap_common.c | 3 ++- 3 files changed, 32 insertions(+), 1 deletion(-) (limited to 'quantum') diff --git a/quantum/keycode_config.c b/quantum/keycode_config.c index 4f7bc525ec..eb39c8fe00 100644 --- a/quantum/keycode_config.c +++ b/quantum/keycode_config.c @@ -88,3 +88,31 @@ uint16_t keycode_config(uint16_t keycode) { return keycode; } } + +uint8_t mod_config(uint8_t mod) { + keymap_config.raw = eeconfig_read_keymap(); + if (keymap_config.swap_lalt_lgui) { + if ((mod & MOD_RGUI) == MOD_LGUI) { + mod &= ~MOD_LGUI; + mod |= MOD_LALT; + } else if ((mod & MOD_RALT) == MOD_LALT) { + mod &= ~MOD_LALT; + mod |= MOD_LGUI; + } + } + if (keymap_config.swap_ralt_rgui) { + if ((mod & MOD_RGUI) == MOD_RGUI) { + mod &= ~MOD_RGUI; + mod |= MOD_RALT; + } else if ((mod & MOD_RALT) == MOD_RALT) { + mod &= ~MOD_RALT; + mod |= MOD_RGUI; + } + } + if (keymap_config.no_gui) { + mod &= ~MOD_LGUI; + mod &= ~MOD_RGUI; + } + + return mod; +} \ No newline at end of file diff --git a/quantum/keycode_config.h b/quantum/keycode_config.h index 293fefecfb..022f4bd19b 100644 --- a/quantum/keycode_config.h +++ b/quantum/keycode_config.h @@ -16,11 +16,13 @@ #include "eeconfig.h" #include "keycode.h" +#include "action_code.h" #ifndef KEYCODE_CONFIG_H #define KEYCODE_CONFIG_H uint16_t keycode_config(uint16_t keycode); +uint8_t mod_config(uint8_t mod); /* NOTE: Not portable. Bit field order depends on implementation */ typedef union { diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index 9dafc8b516..b1460c53cc 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c @@ -123,7 +123,8 @@ action_t action_for_key(uint8_t layer, keypos_t key) action.code = ACTION_LAYER_TAP_TOGGLE(keycode & 0xFF); break; case QK_MOD_TAP ... QK_MOD_TAP_MAX: - action.code = ACTION_MODS_TAP_KEY((keycode >> 0x8) & 0x1F, keycode & 0xFF); + mod = mod_config((keycode >> 0x8) & 0x1F); + action.code = ACTION_MODS_TAP_KEY(mod, keycode & 0xFF); break; #ifdef BACKLIGHT_ENABLE case BL_0 ... BL_15: -- cgit v1.2.3 From a25dbaad327f834dad6fb572b074bab7be1e1d0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Lindh=C3=A9?= Date: Tue, 27 Jun 2017 14:58:38 +0200 Subject: Create sv_SE Qwerty layout for ErgoDox MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit *NOTE:* it might still be desirable to set the software layout to sv_SE in your OS. Swedish (sv_SE) Qwerty layout for ErgoDox, based on the Default configuration I have tried making this as close of a match I could between the [default ErgoDox EZ configuration](https://ergodox-ez.com/pages/our-firmware) and a standard Swedish Qwerty layout. Notable differences from default: ================================= * There are three special character buttons (acute accent, circumflex/tilde and apostrophe/asterisk) that don't have any buttons to map to naturally. I've put these at other places: * Acute accent (´) can be found in the lower left corner, conveniently placed to reach for making an é. * Apostrophe (') was put in the lower left corner, close to acute accent. * Circumflex (^) and asterisk (*) was placed in the lower right corner. * Tilde (~) and diaeresis (¨) I couldn't find a good place for, so I left those out. I could only get the buttons to produce a single one of the characters. How can I get it to work properly? * The Alt button on right thumb was exchanged for AltGr (RAlt). * I changed the backslash in the numpad (layer 1) for a minus. Thought it was more sensible. * I didn't find a good place for the "<>|" button, so that one was left out. That is a problem that really needs to be resolved. Pipe can be found on layer one, however. --- quantum/keymap_extras/keymap_swedish.h | 52 ++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 quantum/keymap_extras/keymap_swedish.h (limited to 'quantum') diff --git a/quantum/keymap_extras/keymap_swedish.h b/quantum/keymap_extras/keymap_swedish.h new file mode 100644 index 0000000000..dcfad720d0 --- /dev/null +++ b/quantum/keymap_extras/keymap_swedish.h @@ -0,0 +1,52 @@ +/* Copyright 2017 Andreas Lindhé + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef KEYMAP_SWEDISH_H +#define KEYMAP_SWEDISH_H + +#include "keymap_nordic.h" + +// There are slight differrences in the keyboards in the nordic contries + +// Swedish redifinitions from the nordic keyset +#undef NO_AE +#define NO_AE KC_QUOT // ä +#undef NO_CIRC +#define NO_CIRC LSFT(KC_RBRC) // ^ +#undef NO_GRV +#define NO_GRV LSFT(NO_BSLS) // +#undef NO_OSLH +#define NO_OSLH KC_SCLN // ö + +// Additional Swedish keys not defined in the nordic keyset +#define NO_AA KC_LBRC // å +#define NO_ASTR LSFT(KC_BSLS) // * + +// Norwegian unique MAC characters (not vetted for Swedish) +#define NO_ACUT_MAC KC_EQL // = +#define NO_APOS_MAC KC_NUBS // ' +#define NO_AT_MAC KC_BSLS // @ +#define NO_BSLS_MAC ALGR(LSFT(KC_7)) // '\' +#define NO_DLR_MAC LSFT(KC_4) // $ +#define NO_GRV_MAC ALGR(NO_BSLS) // ` +#define NO_GRTR_MAC LSFT(KC_GRV) // > +#define NO_LCBR_MAC ALGR(LSFT(KC_8)) // } +#define NO_LESS_MAC KC_GRV // > +#define NO_PIPE_MAC ALGR(KC_7) // | +#define NO_RCBR_MAC ALGR(LSFT(KC_9)) // } + +#endif + -- cgit v1.2.3 From b2979eba236dcda7928079e8102b521a0c8f57aa Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Tue, 27 Jun 2017 12:55:18 -0400 Subject: Adds parenthesis where they might be needed Addresses #764 --- quantum/quantum_keycodes.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'quantum') diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index c34ecafa51..6038e31c46 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -550,13 +550,13 @@ enum quantum_keycodes { #define OSL(layer) (layer | QK_ONE_SHOT_LAYER) // One-shot mod -#define OSM(mod) (mod | QK_ONE_SHOT_MOD) +#define OSM(mod) ((mod) | QK_ONE_SHOT_MOD) // Layer tap-toggle #define TT(layer) (layer | QK_LAYER_TAP_TOGGLE) // M-od, T-ap - 256 keycode max -#define MT(mod, kc) (kc | QK_MOD_TAP | ((mod & 0x1F) << 8)) +#define MT(mod, kc) (kc | QK_MOD_TAP | (((mod) & 0x1F) << 8)) #define CTL_T(kc) MT(MOD_LCTL, kc) #define LCTL_T(kc) MT(MOD_LCTL, kc) -- cgit v1.2.3 From eabf530a0eaffb5fb7d6ebe375225e2d8b0b559a Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Mon, 26 Jun 2017 22:24:30 -0400 Subject: b5 audio --- quantum/audio/audio.c | 260 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 240 insertions(+), 20 deletions(-) (limited to 'quantum') diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c index 597073611a..f2948f18aa 100644 --- a/quantum/audio/audio.c +++ b/quantum/audio/audio.c @@ -33,17 +33,41 @@ // TIMSK3 - Timer/Counter #3 Interrupt Mask Register // Turn on/off 3A interputs, stopping/enabling the ISR calls -#define ENABLE_AUDIO_COUNTER_3_ISR TIMSK3 |= _BV(OCIE3A) -#define DISABLE_AUDIO_COUNTER_3_ISR TIMSK3 &= ~_BV(OCIE3A) +#ifdef C6_AUDIO + #define ENABLE_AUDIO_COUNTER_3_ISR TIMSK3 |= _BV(OCIE3A) + #define DISABLE_AUDIO_COUNTER_3_ISR TIMSK3 &= ~_BV(OCIE3A) +#endif + +#ifdef B5_AUDIO + #define ENABLE_AUDIO_COUNTER_1_ISR TIMSK1 |= _BV(OCIE1A) + #define DISABLE_AUDIO_COUNTER_1_ISR TIMSK1 &= ~_BV(OCIE1A) +#endif // TCCR3A: Timer/Counter #3 Control Register // Compare Output Mode (COM3An) = 0b00 = Normal port operation, OC3A disconnected from PC6 -#define ENABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A |= _BV(COM3A1); -#define DISABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A &= ~(_BV(COM3A1) | _BV(COM3A0)); + +#ifdef C6_AUDIO + #define ENABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A |= _BV(COM3A1); + #define DISABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A &= ~(_BV(COM3A1) | _BV(COM3A0)); +#endif + +#ifdef B5_AUDIO + #define ENABLE_AUDIO_COUNTER_1_OUTPUT TCCR1A |= _BV(COM1A1); + #define DISABLE_AUDIO_COUNTER_1_OUTPUT TCCR1A &= ~(_BV(COM1A1) | _BV(COM1A0)); +#endif // Fast PWM Mode Controls -#define TIMER_3_PERIOD ICR3 -#define TIMER_3_DUTY_CYCLE OCR3A + +#ifdef C6_AUDIO + #define TIMER_3_PERIOD ICR3 + #define TIMER_3_DUTY_CYCLE OCR3A +#endif + +#ifdef B5_AUDIO + #define TIMER_1_PERIOD ICR1 + #define TIMER_1_DUTY_CYCLE OCR1A +#endif + // ----------------------------------------------------------------------------- @@ -105,16 +129,43 @@ void audio_init() audio_config.raw = eeconfig_read_audio(); // Set port PC6 (OC3A and /OC4A) as output - DDRC |= _BV(PORTC6); - DISABLE_AUDIO_COUNTER_3_ISR; + #ifdef C6_AUDIO + DDRC |= _BV(PORTC6); + #else + DDRC |= _BV(PORTC6); + PORTC &= ~_BV(PORTC6); + #endif + + #ifdef B5_AUDIO + DDRB |= _BV(PORTB5); + #else + DDRB |= _BV(PORTB5); + PORTB &= ~_BV(PORTB5); + #endif + + #ifdef C6_AUDIO + DISABLE_AUDIO_COUNTER_3_ISR; + #endif + + #ifdef B5_AUDIO + DISABLE_AUDIO_COUNTER_1_ISR; + #endif // TCCR3A / TCCR3B: Timer/Counter #3 Control Registers // Compare Output Mode (COM3An) = 0b00 = Normal port operation, OC3A disconnected from PC6 // Waveform Generation Mode (WGM3n) = 0b1110 = Fast PWM Mode 14 (Period = ICR3, Duty Cycle = OCR3A) // Clock Select (CS3n) = 0b010 = Clock / 8 - TCCR3A = (0 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30); - TCCR3B = (1 << WGM33) | (1 << WGM32) | (0 << CS32) | (1 << CS31) | (0 << CS30); + + #ifdef C6_AUDIO + TCCR3A = (0 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30); + TCCR3B = (1 << WGM33) | (1 << WGM32) | (0 << CS32) | (1 << CS31) | (0 << CS30); + #endif + + #ifdef B5_AUDIO + TCCR1A = (0 << COM1A1) | (0 << COM1A0) | (1 << WGM11) | (0 << WGM10); + TCCR1B = (1 << WGM13) | (1 << WGM12) | (0 << CS12) | (1 << CS11) | (0 << CS10); + #endif audio_initialized = true; } @@ -128,8 +179,16 @@ void stop_all_notes() } voices = 0; - DISABLE_AUDIO_COUNTER_3_ISR; - DISABLE_AUDIO_COUNTER_3_OUTPUT; + + #ifdef C6_AUDIO + DISABLE_AUDIO_COUNTER_3_ISR; + DISABLE_AUDIO_COUNTER_3_OUTPUT; + #endif + + #ifdef B5_AUDIO + DISABLE_AUDIO_COUNTER_1_ISR; + DISABLE_AUDIO_COUNTER_1_OUTPUT; + #endif playing_notes = false; playing_note = false; @@ -171,8 +230,14 @@ void stop_note(float freq) voice_place = 0; } if (voices == 0) { - DISABLE_AUDIO_COUNTER_3_ISR; - DISABLE_AUDIO_COUNTER_3_OUTPUT; + #ifdef C6_AUDIO + DISABLE_AUDIO_COUNTER_3_ISR; + DISABLE_AUDIO_COUNTER_3_OUTPUT; + #endif + #ifdef B5_AUDIO + DISABLE_AUDIO_COUNTER_1_ISR; + DISABLE_AUDIO_COUNTER_1_OUTPUT; + #endif frequency = 0; volume = 0; playing_note = false; @@ -200,6 +265,7 @@ float vibrato(float average_freq) { #endif +#ifdef C6_AUDIO ISR(TIMER3_COMPA_vect) { float freq; @@ -328,6 +394,138 @@ ISR(TIMER3_COMPA_vect) playing_note = false; } } +#endif + +#ifdef B5_AUDIO +ISR(TIMER1_COMPA_vect) +{ + float freq; + + if (playing_note) { + if (voices > 0) { + if (polyphony_rate > 0) { + if (voices > 1) { + voice_place %= voices; + if (place++ > (frequencies[voice_place] / polyphony_rate / CPU_PRESCALER)) { + voice_place = (voice_place + 1) % voices; + place = 0.0; + } + } + + #ifdef VIBRATO_ENABLE + if (vibrato_strength > 0) { + freq = vibrato(frequencies[voice_place]); + } else { + freq = frequencies[voice_place]; + } + #else + freq = frequencies[voice_place]; + #endif + } else { + if (glissando) { + if (frequency != 0 && frequency < frequencies[voices - 1] && frequency < frequencies[voices - 1] * pow(2, -440/frequencies[voices - 1]/12/2)) { + frequency = frequency * pow(2, 440/frequency/12/2); + } else if (frequency != 0 && frequency > frequencies[voices - 1] && frequency > frequencies[voices - 1] * pow(2, 440/frequencies[voices - 1]/12/2)) { + frequency = frequency * pow(2, -440/frequency/12/2); + } else { + frequency = frequencies[voices - 1]; + } + } else { + frequency = frequencies[voices - 1]; + } + + #ifdef VIBRATO_ENABLE + if (vibrato_strength > 0) { + freq = vibrato(frequency); + } else { + freq = frequency; + } + #else + freq = frequency; + #endif + } + + if (envelope_index < 65535) { + envelope_index++; + } + + freq = voice_envelope(freq); + + if (freq < 30.517578125) { + freq = 30.52; + } + + TIMER_1_PERIOD = (uint16_t)(((float)F_CPU) / (freq * CPU_PRESCALER)); + TIMER_1_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); + } + } + + if (playing_notes) { + if (note_frequency > 0) { + #ifdef VIBRATO_ENABLE + if (vibrato_strength > 0) { + freq = vibrato(note_frequency); + } else { + freq = note_frequency; + } + #else + freq = note_frequency; + #endif + + if (envelope_index < 65535) { + envelope_index++; + } + freq = voice_envelope(freq); + + TIMER_1_PERIOD = (uint16_t)(((float)F_CPU) / (freq * CPU_PRESCALER)); + TIMER_1_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); + } else { + TIMER_1_PERIOD = 0; + TIMER_1_DUTY_CYCLE = 0; + } + + note_position++; + bool end_of_note = false; + if (TIMER_1_PERIOD > 0) { + end_of_note = (note_position >= (note_length / TIMER_1_PERIOD * 0xFFFF)); + } else { + end_of_note = (note_position >= (note_length * 0x7FF)); + } + + if (end_of_note) { + current_note++; + if (current_note >= notes_count) { + if (notes_repeat) { + current_note = 0; + } else { + DISABLE_AUDIO_COUNTER_1_ISR; + DISABLE_AUDIO_COUNTER_1_OUTPUT; + playing_notes = false; + return; + } + } + if (!note_resting && (notes_rest > 0)) { + note_resting = true; + note_frequency = 0; + note_length = notes_rest; + current_note--; + } else { + note_resting = false; + envelope_index = 0; + note_frequency = (*notes_pointer)[current_note][0]; + note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100); + } + + note_position = 0; + } + } + + if (!audio_config.enable) { + playing_notes = false; + playing_note = false; + } +} +#endif void play_note(float freq, int vol) { @@ -338,7 +536,12 @@ void play_note(float freq, int vol) { } if (audio_config.enable && voices < 8) { - DISABLE_AUDIO_COUNTER_3_ISR; + #ifdef C6_AUDIO + DISABLE_AUDIO_COUNTER_3_ISR; + #endif + #ifdef B5_AUDIO + DISABLE_AUDIO_COUNTER_1_ISR; + #endif // Cancel notes if notes are playing if (playing_notes) @@ -354,8 +557,14 @@ void play_note(float freq, int vol) { voices++; } - ENABLE_AUDIO_COUNTER_3_ISR; - ENABLE_AUDIO_COUNTER_3_OUTPUT; + #ifdef C6_AUDIO + ENABLE_AUDIO_COUNTER_3_ISR; + ENABLE_AUDIO_COUNTER_3_OUTPUT; + #endif + #ifdef B5_AUDIO + ENABLE_AUDIO_COUNTER_1_ISR; + ENABLE_AUDIO_COUNTER_1_OUTPUT; + #endif } } @@ -369,7 +578,12 @@ void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest) if (audio_config.enable) { - DISABLE_AUDIO_COUNTER_3_ISR; + #ifdef C6_AUDIO + DISABLE_AUDIO_COUNTER_3_ISR; + #endif + #ifdef B5_AUDIO + DISABLE_AUDIO_COUNTER_1_ISR; + #endif // Cancel note if a note is playing if (playing_note) @@ -390,8 +604,14 @@ void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest) note_position = 0; - ENABLE_AUDIO_COUNTER_3_ISR; - ENABLE_AUDIO_COUNTER_3_OUTPUT; + #ifdef C6_AUDIO + ENABLE_AUDIO_COUNTER_3_ISR; + ENABLE_AUDIO_COUNTER_3_OUTPUT; + #endif + #ifdef B5_AUDIO + ENABLE_AUDIO_COUNTER_1_ISR; + ENABLE_AUDIO_COUNTER_1_OUTPUT; + #endif } } -- cgit v1.2.3 From bfc73e90cfc6532331d1532e2ff9020d25c96a69 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Mon, 26 Jun 2017 23:13:27 -0400 Subject: working duopholy --- quantum/audio/audio.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 4 deletions(-) (limited to 'quantum') diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c index f2948f18aa..04f3460033 100644 --- a/quantum/audio/audio.c +++ b/quantum/audio/audio.c @@ -75,6 +75,7 @@ int voices = 0; int voice_place = 0; float frequency = 0; +float frequency_alt = 0; int volume = 0; long position = 0; @@ -193,6 +194,7 @@ void stop_all_notes() playing_notes = false; playing_note = false; frequency = 0; + frequency_alt = 0; volume = 0; for (uint8_t i = 0; i < 8; i++) @@ -239,6 +241,7 @@ void stop_note(float freq) DISABLE_AUDIO_COUNTER_1_OUTPUT; #endif frequency = 0; + frequency_alt = 0; volume = 0; playing_note = false; } @@ -268,10 +271,52 @@ float vibrato(float average_freq) { #ifdef C6_AUDIO ISR(TIMER3_COMPA_vect) { - float freq; + float freq, freq_alt = 0; if (playing_note) { if (voices > 0) { + + #ifdef B5_AUDIO + if (voices > 1) { + if (polyphony_rate == 0) { + if (glissando) { + if (frequency_alt != 0 && frequency_alt < frequencies[voices - 2] && frequency_alt < frequencies[voices - 2] * pow(2, -440/frequencies[voices - 2]/12/2)) { + frequency_alt = frequency_alt * pow(2, 440/frequency_alt/12/2); + } else if (frequency_alt != 0 && frequency_alt > frequencies[voices - 2] && frequency_alt > frequencies[voices - 2] * pow(2, 440/frequencies[voices - 2]/12/2)) { + frequency_alt = frequency_alt * pow(2, -440/frequency_alt/12/2); + } else { + frequency_alt = frequencies[voices - 2]; + } + } else { + frequency_alt = frequencies[voices - 2]; + } + + #ifdef VIBRATO_ENABLE + if (vibrato_strength > 0) { + freq_alt = vibrato(frequency_alt); + } else { + freq_alt = frequency_alt; + } + #else + freq_alt = frequency_alt; + #endif + } + + if (envelope_index < 65535) { + envelope_index++; + } + + freq_alt = voice_envelope(freq_alt); + + if (freq_alt < 30.517578125) { + freq_alt = 30.52; + } + + TIMER_1_PERIOD = (uint16_t)(((float)F_CPU) / (freq_alt * CPU_PRESCALER)); + TIMER_1_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq_alt * CPU_PRESCALER)) * note_timbre); + } + #endif + if (polyphony_rate > 0) { if (voices > 1) { voice_place %= voices; @@ -396,10 +441,10 @@ ISR(TIMER3_COMPA_vect) } #endif -#ifdef B5_AUDIO ISR(TIMER1_COMPA_vect) { - float freq; + #if defined(B5_AUDIO) && !defined(C6_AUDIO) + float freq = 0; if (playing_note) { if (voices > 0) { @@ -524,8 +569,8 @@ ISR(TIMER1_COMPA_vect) playing_notes = false; playing_note = false; } -} #endif +} void play_note(float freq, int vol) { @@ -562,8 +607,15 @@ void play_note(float freq, int vol) { ENABLE_AUDIO_COUNTER_3_OUTPUT; #endif #ifdef B5_AUDIO + #ifdef C6_AUDIO + if (voices > 1) { + ENABLE_AUDIO_COUNTER_1_ISR; + ENABLE_AUDIO_COUNTER_1_OUTPUT; + } + #else ENABLE_AUDIO_COUNTER_1_ISR; ENABLE_AUDIO_COUNTER_1_OUTPUT; + #endif #endif } @@ -609,8 +661,10 @@ void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest) ENABLE_AUDIO_COUNTER_3_OUTPUT; #endif #ifdef B5_AUDIO + #ifndef C6_AUDIO ENABLE_AUDIO_COUNTER_1_ISR; ENABLE_AUDIO_COUNTER_1_OUTPUT; + #endif #endif } -- cgit v1.2.3 From b82604dadad81872abdb9fdde18086ee69e66671 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Tue, 27 Jun 2017 14:12:25 -0400 Subject: no glide --- quantum/audio/voices.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'quantum') diff --git a/quantum/audio/voices.c b/quantum/audio/voices.c index 54ebd423b1..94147ccb66 100644 --- a/quantum/audio/voices.c +++ b/quantum/audio/voices.c @@ -44,7 +44,7 @@ float voice_envelope(float frequency) { switch (voice) { case default_voice: - glissando = true; + glissando = false; note_timbre = TIMBRE_50; polyphony_rate = 0; break; -- cgit v1.2.3 From ea7590c8940bc85f8a83bd42b1e01bc1431c104b Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Tue, 27 Jun 2017 14:35:08 -0400 Subject: add new arguements, docs --- quantum/audio/audio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'quantum') diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c index 04f3460033..3192d500f5 100644 --- a/quantum/audio/audio.c +++ b/quantum/audio/audio.c @@ -271,12 +271,13 @@ float vibrato(float average_freq) { #ifdef C6_AUDIO ISR(TIMER3_COMPA_vect) { - float freq, freq_alt = 0; + float freq; if (playing_note) { if (voices > 0) { #ifdef B5_AUDIO + float freq_alt = 0; if (voices > 1) { if (polyphony_rate == 0) { if (glissando) { -- cgit v1.2.3 From 7d28a417c035b66529d7f6d49479fe4c22737134 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Tue, 27 Jun 2017 15:28:13 -0400 Subject: don't let timer1 exist without b5 being enabled --- quantum/audio/audio.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'quantum') diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c index 3192d500f5..c924f2bd58 100644 --- a/quantum/audio/audio.c +++ b/quantum/audio/audio.c @@ -442,6 +442,7 @@ ISR(TIMER3_COMPA_vect) } #endif +#ifdef B5_AUDIO ISR(TIMER1_COMPA_vect) { #if defined(B5_AUDIO) && !defined(C6_AUDIO) @@ -572,6 +573,7 @@ ISR(TIMER1_COMPA_vect) } #endif } +#endif void play_note(float freq, int vol) { -- cgit v1.2.3