From 20696a9efef4455f1589e6b37ed2177120a92161 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Fri, 14 Jul 2017 11:11:35 +0300 Subject: Fix building of multiple test directories --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b429200fe8..5ed757dc29 100644 --- a/Makefile +++ b/Makefile @@ -419,7 +419,7 @@ define BUILD_TEST MAKE_TARGET := $2 COMMAND := $1 MAKE_CMD := $$(MAKE) -r -R -C $(ROOT_DIR) -f build_test.mk $$(MAKE_TARGET) - MAKE_VARS := TEST=$$(TEST_NAME) FULL_TESTS=$$(FULL_TESTS) + MAKE_VARS := TEST=$$(TEST_NAME) FULL_TESTS="$$(FULL_TESTS)" MAKE_MSG := $$(MSG_MAKE_TEST) $$(eval $$(call BUILD)) ifneq ($$(MAKE_TARGET),clean) -- cgit v1.2.3 From a5b0f4de35608431f235f3da0a4e087db6671300 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Thu, 20 Jul 2017 15:40:42 +0300 Subject: Add SRC and OPT_DEFS when building tests --- build_full_test.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build_full_test.mk b/build_full_test.mk index 94356d5752..170020b968 100644 --- a/build_full_test.mk +++ b/build_full_test.mk @@ -21,12 +21,13 @@ $(TEST)_SRC= \ $(TEST_PATH)/keymap.c \ $(TMK_COMMON_SRC) \ $(QUANTUM_SRC) \ + $(SRC) \ tests/test_common/matrix.c \ tests/test_common/test_driver.cpp \ tests/test_common/keyboard_report_util.cpp \ tests/test_common/test_fixture.cpp $(TEST)_SRC += $(patsubst $(ROOTDIR)/%,%,$(wildcard $(TEST_PATH)/*.cpp)) -$(TEST)_DEFS=$(TMK_COMMON_DEFS) +$(TEST)_DEFS=$(TMK_COMMON_DEFS) $(OPT_DEFS) $(TEST)_CONFIG=$(TEST_PATH)/config.h VPATH+=$(TOP_DIR)/tests/test_common \ No newline at end of file -- cgit v1.2.3 From 30efce5584a8a78ab01a9861a41a92cf7828ec3c Mon Sep 17 00:00:00 2001 From: Maarten Dekkers Date: Sun, 16 Jul 2017 20:18:14 +0200 Subject: Changes to own keymap --- keyboards/tada68/keymaps/maartenwut/keymap.c | 52 ++++++++-------------------- 1 file changed, 15 insertions(+), 37 deletions(-) diff --git a/keyboards/tada68/keymaps/maartenwut/keymap.c b/keyboards/tada68/keymaps/maartenwut/keymap.c index d1e63a6b31..8ddd6e3056 100755 --- a/keyboards/tada68/keymaps/maartenwut/keymap.c +++ b/keyboards/tada68/keymaps/maartenwut/keymap.c @@ -30,15 +30,6 @@ #define LSHIFT OSM(MOD_LSFT) #define SPACE LT(_AR, KC_SPC) -#define MACRO_BREATH_TOGGLE 13 -#define MACRO_BREATH_SPEED_INC 14 -#define MACRO_BREATH_SPEED_DEC 15 -#define MACRO_BREATH_DEFAULT 16 -#define M_BRTOG M(MACRO_BREATH_TOGGLE) -#define M_BSPDU M(MACRO_BREATH_SPEED_INC) -#define M_BSPDD M(MACRO_BREATH_SPEED_DEC) -#define M_BDFLT M(MACRO_BREATH_DEFAULT) - static uint16_t key_timer; enum emoticons { @@ -76,7 +67,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * |----------------------------------------------------------------| * | |MsL|MsD|MsR| |_GA| | | | | | | |Hme | * |----------------------------------------------------------------| - * | | |BL-|BL+|BL |BR-|BR+|BR | |VoU|VoD|Mut| |MwU|End | + * | | | | | | | | | |VoU|VoD|Mut| |MwU|End | * |----------------------------------------------------------------| * | | | | | | | |MwL|MwD|MwR | * `----------------------------------------------------------------' @@ -84,13 +75,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_FL] = KEYMAP_ANSI( KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, RESET, KC_PSCR, \ TRNS, KC_BTN1, KC_MS_U, KC_BTN2, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TO(_LO), \ - TRNS, KC_MS_L, KC_MS_D, KC_MS_R, TRNS, TG(_GA), TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, KC_HOME, \ - TRNS, TRNS, BL_DEC, BL_INC, BL_TOGG, M_BSPDD, M_BSPDU, M_BRTOG, TRNS, KC_VOLD, KC_VOLU, KC_MUTE, TRNS, KC_WH_U, KC_END, \ + TRNS, KC_MS_L, KC_MS_D, KC_MS_R, TRNS, TG(_GA), TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, KC_HOME, \ + TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, KC_VOLD, KC_VOLU, KC_MUTE, TRNS, KC_WH_U, KC_END, \ TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, KC_WH_L, KC_WH_D, KC_WH_R), /* Keymap _AR: Arrow layer * ,----------------------------------------------------------------. - * | | | | | | | | | | | | | | | | + * |~` | F1|F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10|F11|F12| | | * |----------------------------------------------------------------| * |Lenny| | | | | | | | | | | | | | | * |----------------------------------------------------------------| @@ -102,7 +93,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * `----------------------------------------------------------------' */ [_AR] = KEYMAP_ANSI( - TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, \ + KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, TRNS, TRNS, \ LENNY, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, \ DWNHRT, TRNS, TRNS, TRNS, TRNS, TRNS, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, TRNS, TRNS, TRNS, TRNS, \ SHRUG, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, \ @@ -408,29 +399,16 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { } } break; - case MACRO_BREATH_TOGGLE: - if (record->event.pressed) { - breathing_toggle(); - } - break; - - case MACRO_BREATH_SPEED_INC: - if (record->event.pressed) { - breathing_speed_inc(1); - } - break; - - case MACRO_BREATH_SPEED_DEC: - if (record->event.pressed) { - breathing_speed_dec(1); - } - break; - - case MACRO_BREATH_DEFAULT: - if (record->event.pressed) { - breathing_defaults(); - } - break; } return MACRO_NONE; }; + +void led_set_user(uint8_t usb_led) { + if (usb_led & (1< Date: Sun, 16 Jul 2017 21:35:39 +0200 Subject: Added some user customization --- keyboards/tada68/tada68.c | 1 + 1 file changed, 1 insertion(+) diff --git a/keyboards/tada68/tada68.c b/keyboards/tada68/tada68.c index 24f89048cb..e4fab98101 100755 --- a/keyboards/tada68/tada68.c +++ b/keyboards/tada68/tada68.c @@ -27,4 +27,5 @@ void led_set_kb(uint8_t usb_led) { // Turn capslock off PORTB |= (1<<2); } + led_set_user(usb_led); } -- cgit v1.2.3 From f379f05c1eea25bf86e06858348690b856f223f6 Mon Sep 17 00:00:00 2001 From: rootuseralpha Date: Wed, 19 Jul 2017 18:54:14 -0500 Subject: Create test --- keyboards/roadkit/keymaps/singlesBrent/test | 1 + 1 file changed, 1 insertion(+) create mode 100644 keyboards/roadkit/keymaps/singlesBrent/test diff --git a/keyboards/roadkit/keymaps/singlesBrent/test b/keyboards/roadkit/keymaps/singlesBrent/test new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/keyboards/roadkit/keymaps/singlesBrent/test @@ -0,0 +1 @@ + -- cgit v1.2.3 From e5f606558e3ec8ec9b969584aaaf528308042c16 Mon Sep 17 00:00:00 2001 From: rootuseralpha Date: Wed, 19 Jul 2017 18:54:40 -0500 Subject: Add files via upload --- keyboards/roadkit/keymaps/singlesBrent/Makefile | 22 +++ keyboards/roadkit/keymaps/singlesBrent/config.h | 16 ++ keyboards/roadkit/keymaps/singlesBrent/keymap.c | 239 +++++++++++++++++++++++ keyboards/roadkit/keymaps/singlesBrent/readme.md | 3 + 4 files changed, 280 insertions(+) create mode 100644 keyboards/roadkit/keymaps/singlesBrent/Makefile create mode 100644 keyboards/roadkit/keymaps/singlesBrent/config.h create mode 100644 keyboards/roadkit/keymaps/singlesBrent/keymap.c create mode 100644 keyboards/roadkit/keymaps/singlesBrent/readme.md diff --git a/keyboards/roadkit/keymaps/singlesBrent/Makefile b/keyboards/roadkit/keymaps/singlesBrent/Makefile new file mode 100644 index 0000000000..b61d6cca2c --- /dev/null +++ b/keyboards/roadkit/keymaps/singlesBrent/Makefile @@ -0,0 +1,22 @@ +# Build Options +# change to "no" to disable the options, or define them in the Makefile in +# the appropriate keymap folder that will get included automatically +# +BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) +MOUSEKEY_ENABLE = yes # Mouse keys(+4700) +EXTRAKEY_ENABLE = yes # Audio control and System control(+450) +CONSOLE_ENABLE = no # Console for debug(+400) +COMMAND_ENABLE = yes # Commands for debug and configuration +NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality +MIDI_ENABLE = no # MIDI controls +AUDIO_ENABLE = no # Audio output on port C6 +UNICODE_ENABLE = no # Unicode +BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID +RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend +TAP_DANCE_ENABLE = yes # Enable Tap Dance functionality + +ifndef QUANTUM_DIR + include ../../../../Makefile +endif \ No newline at end of file diff --git a/keyboards/roadkit/keymaps/singlesBrent/config.h b/keyboards/roadkit/keymaps/singlesBrent/config.h new file mode 100644 index 0000000000..fe2424ae67 --- /dev/null +++ b/keyboards/roadkit/keymaps/singlesBrent/config.h @@ -0,0 +1,16 @@ +#ifndef CONFIG_USER_H +#define CONFIG_USER_H + +#include "../../config.h" + +// place overrides here +#define TAPPING_TERM 175 + +#ifdef BACKLIGHT_ENABLE + #define BACKLIGHT_PIN B5 + #define BACKLIGHT_LEVELS 3 + #define BACKLIGHT_ON_STATE 0 + backlight_set(3); +#endif + +#endif \ No newline at end of file diff --git a/keyboards/roadkit/keymaps/singlesBrent/keymap.c b/keyboards/roadkit/keymaps/singlesBrent/keymap.c new file mode 100644 index 0000000000..e4333bd551 --- /dev/null +++ b/keyboards/roadkit/keymaps/singlesBrent/keymap.c @@ -0,0 +1,239 @@ +#include "roadkit.h" +#include "action_layer.h" +#include "eeconfig.h" +//#ifdef BACKLIGHT_ENABLE +// #include "backlight.h" +//#endif + +extern keymap_config_t keymap_config; + +// Each layer gets a name for readability, which is then used in the keymap matrix below. +// The underscores don't mean anything - you can have a layer called STUFF or any other name. +// Layer names don't all need to be of the same length, obviously, and you can also skip them +// entirely and just use numbers. + +#define _NP 0 +#define _L1 1 +#define _L2 2 +#define _L3 3 + +// Macro name shortcuts +#define NUMPAD M(_NP) +#define LAYER1 M(_L1) +#define LAYER2 M(_L2) +#define LAYER3 M(_L3) + +// Fillers to make layering more clear +#define _______ KC_TRNS +#define XXXXXXX KC_NO + +//Tap Dance Declarations + +enum { + + TD_EQUAL_NP = 0, + TD_KP_PLUS_L1, + TD_DOT_L2, + TD_0_L3 + +}; + +//Tap Dance Definitions + + + //TD equal to turn on layer NP +void _td_equal_tg_finished (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + register_code(KC_EQUAL); + } else if (state->count == 2) { + backlight_set(3); + layer_on(_NP); + layer_off(_L1); + layer_off(_L2); + layer_off(_L3); + } +} + +void _td_equal_tg_reset (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + unregister_code(KC_EQUAL); + } +} + + + //TD kp plus to toggle layer 1 +void _td_kp_plus_tg_finished (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + register_code(KC_KP_PLUS); + } else if (state->count == 2) { +// layer_invert(_L1); + backlight_set(2); + layer_on(_L1); + layer_off(_L2); + layer_off(_L3); + } +} + +void _td_kp_plus_tg_reset (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + unregister_code(KC_KP_PLUS); + } +} + + + //TD dot to toggle layer 2 +void _td_dot_tg_finished (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + register_code(KC_DOT); + } else if (state->count == 2) { + backlight_set(1); + layer_on(_L2); + layer_off(_L1); + layer_off(_L3); + } +} + +void _td_dot_tg_reset (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + unregister_code(KC_DOT); + } +} + + //TD 0 to toggle layer 3 +void _td_0_tg_finished (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + register_code(KC_0); + } else if (state->count == 2) { + backlight_set(0); + layer_on(_L3); + layer_off(_L1); + layer_off(_L2); + } +} + +void _td_0_tg_reset (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + unregister_code(KC_0); + } +} + +//TD Actions +qk_tap_dance_action_t tap_dance_actions[] = { + [TD_EQUAL_NP] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, _td_equal_tg_finished, _td_equal_tg_reset), + [TD_KP_PLUS_L1] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, _td_kp_plus_tg_finished, _td_kp_plus_tg_reset), + [TD_DOT_L2] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, _td_dot_tg_finished, _td_dot_tg_reset), + [TD_0_L3] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, _td_0_tg_finished, _td_0_tg_reset) +}; + + + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + +/* Numberpad + * ,-----------------------. + * | 7 | 8 | 9 | / | + * |-----`-----`-----`-----| + * | 4 | 5 | 6 | * | + * |-----`-----`-----`-----| + * | 1 | 2 | 3 | - | + * |-----`-----`-----`-----| + * | 0 | . | + | = | + * `-----`-----`-----`-----' + * Tapdances: + * | L3 | L2 | L1 | NP | + * `-----`-----`-----`-----' + */ + [_NP] = /* Numpad */ + SINGLES_KEYMAP(KC_7, KC_8, KC_9, KC_SLASH, \ + KC_4, KC_5, KC_6, KC_KP_ASTERISK, \ + KC_1, KC_2, KC_3, KC_MINUS, \ + TD(TD_0_L3), TD(TD_DOT_L2), TD(TD_KP_PLUS_L1), TD(TD_EQUAL_NP)), + +/* L1 + * ,-----------------------. + * | Esc |Bksp |Home |PgUp | + * |-----`-----`-----`-----| + * | Tab | Up | End |PgDn | + * |-----`-----`-----`-----| + * |Left |Down |Right|Enter| + * |-----`-----`-----`-----| + * | 0 | . | + | = | + * `-----`-----`-----`-----' + */ + [_L1] = /* LAYER 1 */ + SINGLES_KEYMAP(KC_ESCAPE, KC_BSPACE, KC_HOME, KC_PGUP, \ + KC_TAB, KC_UP, KC_END, KC_PGDOWN, \ + KC_LEFT, KC_DOWN, KC_RIGHT, KC_KP_ENTER, \ + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + +/* L2 + * ,-----------------------. + * |Sleep|LClik|RClik|VolUp| + * |-----`-----`-----`-----| + * |AltF4| F11 |WinTb|VolDn| + * |-----`-----`-----`-----| + * |PrvTk|Play |NxtTk|Mute | + * |-----`-----`-----`-----| + * | 0 | . | + | = | + * `-----`-----`-----`-----' + */ + [_L2] = /* LAYER 2 */ + SINGLES_KEYMAP(KC_SYSTEM_SLEEP, KC_MS_BTN1, KC_MS_BTN2, KC_AUDIO_VOL_UP, \ + LALT(KC_F4), KC_F11, LGUI(KC_TAB), KC_AUDIO_VOL_DOWN, \ + KC_MEDIA_PREV_TRACK, KC_MEDIA_PLAY_PAUSE, KC_MEDIA_NEXT_TRACK, KC_AUDIO_MUTE, \ + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + + +/* L3 needs cut, copy, paste, undo, again (redo), find, calc, www back, www forward, F5 + * ,-----------------------. + * |WBack|WHome|WFor | F5 | + * |-----`-----`-----`-----| + * |Calc |Undo |Redo |WSrch| + * |-----`-----`-----`-----| + * | Cut |Copy |Paste|Find | + * |-----`-----`-----`-----| + * | 0 | . | + | = | + * `-----`-----`-----`-----' + */ + [_L3] = /* LAYER 3 */ + SINGLES_KEYMAP(KC_WWW_BACK, KC_WWW_HOME, KC_WWW_FORWARD, KC_F5, \ + KC_CALCULATOR, LCTL(KC_Z), LCTL(KC_Y), KC_WWW_SEARCH, \ + LCTL(KC_X), LCTL(KC_C), LCTL(KC_V), LCTL(KC_F), \ + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), +}; + +const uint16_t PROGMEM fn_actions[] = { + +}; + +void persistent_default_layer_set(uint16_t default_layer) { + eeconfig_update_default_layer(default_layer); + default_layer_set(default_layer); +} + +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + switch(id) { + case _L3: + if (record->event.pressed) { + persistent_default_layer_set(1UL<<_L3); + } + break; + case _L2: + if (record->event.pressed) { + persistent_default_layer_set(1UL<<_L2); + } + break; + case _L1: + if (record->event.pressed) { + persistent_default_layer_set(1UL<<_L1); + } + break; + case _NP: + if (record->event.pressed) { + persistent_default_layer_set(1UL<<_NP); + } + break; + } + return MACRO_NONE; +}; \ No newline at end of file diff --git a/keyboards/roadkit/keymaps/singlesBrent/readme.md b/keyboards/roadkit/keymaps/singlesBrent/readme.md new file mode 100644 index 0000000000..fdef3baa2e --- /dev/null +++ b/keyboards/roadkit/keymaps/singlesBrent/readme.md @@ -0,0 +1,3 @@ +# The singles keymap for roadkit + +This keymap has a base layer with numpad functionality, and then a second layer with some additional keys. The user is encouraged to develop their own keymap using this as a starting point. -- cgit v1.2.3 From 4627cab49dc980336e5c4c39fd9ec64fa9993501 Mon Sep 17 00:00:00 2001 From: rootuseralpha Date: Wed, 19 Jul 2017 18:55:13 -0500 Subject: Delete test --- keyboards/roadkit/keymaps/singlesBrent/test | 1 - 1 file changed, 1 deletion(-) delete mode 100644 keyboards/roadkit/keymaps/singlesBrent/test diff --git a/keyboards/roadkit/keymaps/singlesBrent/test b/keyboards/roadkit/keymaps/singlesBrent/test deleted file mode 100644 index 8b13789179..0000000000 --- a/keyboards/roadkit/keymaps/singlesBrent/test +++ /dev/null @@ -1 +0,0 @@ - -- cgit v1.2.3 From 4d665a99aebaf99a33ac0c7e467470940349b99b Mon Sep 17 00:00:00 2001 From: rootuseralpha Date: Thu, 20 Jul 2017 09:37:16 -0500 Subject: Add files via upload --- keyboards/roadkit/keymaps/singlesBrent/config.h | 1 - keyboards/roadkit/keymaps/singlesBrent/keymap.c | 22 +++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/keyboards/roadkit/keymaps/singlesBrent/config.h b/keyboards/roadkit/keymaps/singlesBrent/config.h index fe2424ae67..45bd44c0be 100644 --- a/keyboards/roadkit/keymaps/singlesBrent/config.h +++ b/keyboards/roadkit/keymaps/singlesBrent/config.h @@ -10,7 +10,6 @@ #define BACKLIGHT_PIN B5 #define BACKLIGHT_LEVELS 3 #define BACKLIGHT_ON_STATE 0 - backlight_set(3); #endif #endif \ No newline at end of file diff --git a/keyboards/roadkit/keymaps/singlesBrent/keymap.c b/keyboards/roadkit/keymaps/singlesBrent/keymap.c index e4333bd551..c915651d07 100644 --- a/keyboards/roadkit/keymaps/singlesBrent/keymap.c +++ b/keyboards/roadkit/keymaps/singlesBrent/keymap.c @@ -1,9 +1,6 @@ #include "roadkit.h" #include "action_layer.h" #include "eeconfig.h" -//#ifdef BACKLIGHT_ENABLE -// #include "backlight.h" -//#endif extern keymap_config_t keymap_config; @@ -27,6 +24,13 @@ extern keymap_config_t keymap_config; #define _______ KC_TRNS #define XXXXXXX KC_NO +void matrix_init_user(void) { + backlight_init(); + backlight_set(3); +} + + + //Tap Dance Declarations enum { @@ -144,9 +148,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * `-----`-----`-----`-----' */ [_NP] = /* Numpad */ - SINGLES_KEYMAP(KC_7, KC_8, KC_9, KC_SLASH, \ - KC_4, KC_5, KC_6, KC_KP_ASTERISK, \ - KC_1, KC_2, KC_3, KC_MINUS, \ + SINGLES_KEYMAP(KC_7, KC_8, KC_9, KC_SLASH, \ + KC_4, KC_5, KC_6, KC_KP_ASTERISK, \ + KC_1, KC_2, KC_3, KC_MINUS, \ TD(TD_0_L3), TD(TD_DOT_L2), TD(TD_KP_PLUS_L1), TD(TD_EQUAL_NP)), /* L1 @@ -162,9 +166,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { */ [_L1] = /* LAYER 1 */ SINGLES_KEYMAP(KC_ESCAPE, KC_BSPACE, KC_HOME, KC_PGUP, \ - KC_TAB, KC_UP, KC_END, KC_PGDOWN, \ - KC_LEFT, KC_DOWN, KC_RIGHT, KC_KP_ENTER, \ - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + KC_TAB, KC_UP, KC_END, KC_PGDOWN, \ + KC_LEFT, KC_DOWN, KC_RIGHT, KC_KP_ENTER, \ + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), /* L2 * ,-----------------------. -- cgit v1.2.3 From 8deb405292774e14c96a313d5f3d5572f289ef7e Mon Sep 17 00:00:00 2001 From: rootuseralpha Date: Thu, 20 Jul 2017 15:57:02 -0500 Subject: Add files via upload --- keyboards/roadkit/keymaps/singlesBrent/keymap.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/keyboards/roadkit/keymaps/singlesBrent/keymap.c b/keyboards/roadkit/keymaps/singlesBrent/keymap.c index c915651d07..de765f976b 100644 --- a/keyboards/roadkit/keymaps/singlesBrent/keymap.c +++ b/keyboards/roadkit/keymaps/singlesBrent/keymap.c @@ -25,8 +25,7 @@ extern keymap_config_t keymap_config; #define XXXXXXX KC_NO void matrix_init_user(void) { - backlight_init(); - backlight_set(3); + backlight_level(4); } @@ -148,7 +147,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * `-----`-----`-----`-----' */ [_NP] = /* Numpad */ - SINGLES_KEYMAP(KC_7, KC_8, KC_9, KC_SLASH, \ + SINGLES_KEYMAP(KC_7, BL_STEP, KC_9, KC_SLASH, \ KC_4, KC_5, KC_6, KC_KP_ASTERISK, \ KC_1, KC_2, KC_3, KC_MINUS, \ TD(TD_0_L3), TD(TD_DOT_L2), TD(TD_KP_PLUS_L1), TD(TD_EQUAL_NP)), -- cgit v1.2.3 From e26283e9e58600344b6bd1f222fee748077580d8 Mon Sep 17 00:00:00 2001 From: rootuseralpha Date: Thu, 20 Jul 2017 16:06:21 -0500 Subject: Update keymap.c --- keyboards/roadkit/keymaps/singlesBrent/keymap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/keyboards/roadkit/keymaps/singlesBrent/keymap.c b/keyboards/roadkit/keymaps/singlesBrent/keymap.c index de765f976b..85e66c8c33 100644 --- a/keyboards/roadkit/keymaps/singlesBrent/keymap.c +++ b/keyboards/roadkit/keymaps/singlesBrent/keymap.c @@ -147,7 +147,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * `-----`-----`-----`-----' */ [_NP] = /* Numpad */ - SINGLES_KEYMAP(KC_7, BL_STEP, KC_9, KC_SLASH, \ + SINGLES_KEYMAP(KC_7, KC_8, KC_9, KC_SLASH, \ KC_4, KC_5, KC_6, KC_KP_ASTERISK, \ KC_1, KC_2, KC_3, KC_MINUS, \ TD(TD_0_L3), TD(TD_DOT_L2), TD(TD_KP_PLUS_L1), TD(TD_EQUAL_NP)), @@ -239,4 +239,4 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) break; } return MACRO_NONE; -}; \ No newline at end of file +}; -- cgit v1.2.3 From 8edb67b08242f2ab641d7e658a0a7adb579bbae2 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Fri, 21 Jul 2017 19:05:13 -0400 Subject: fix line-endings --- keyboards/roadkit/keymaps/singlesBrent/config.h | 28 +- keyboards/roadkit/keymaps/singlesBrent/keymap.c | 484 +++++++++++------------ keyboards/roadkit/keymaps/singlesBrent/readme.md | 6 +- 3 files changed, 259 insertions(+), 259 deletions(-) diff --git a/keyboards/roadkit/keymaps/singlesBrent/config.h b/keyboards/roadkit/keymaps/singlesBrent/config.h index 45bd44c0be..57468e122a 100644 --- a/keyboards/roadkit/keymaps/singlesBrent/config.h +++ b/keyboards/roadkit/keymaps/singlesBrent/config.h @@ -1,15 +1,15 @@ -#ifndef CONFIG_USER_H -#define CONFIG_USER_H - -#include "../../config.h" - -// place overrides here -#define TAPPING_TERM 175 - -#ifdef BACKLIGHT_ENABLE - #define BACKLIGHT_PIN B5 - #define BACKLIGHT_LEVELS 3 - #define BACKLIGHT_ON_STATE 0 -#endif - +#ifndef CONFIG_USER_H +#define CONFIG_USER_H + +#include "../../config.h" + +// place overrides here +#define TAPPING_TERM 175 + +#ifdef BACKLIGHT_ENABLE + #define BACKLIGHT_PIN B5 + #define BACKLIGHT_LEVELS 3 + #define BACKLIGHT_ON_STATE 0 +#endif + #endif \ No newline at end of file diff --git a/keyboards/roadkit/keymaps/singlesBrent/keymap.c b/keyboards/roadkit/keymaps/singlesBrent/keymap.c index 85e66c8c33..13197346a9 100644 --- a/keyboards/roadkit/keymaps/singlesBrent/keymap.c +++ b/keyboards/roadkit/keymaps/singlesBrent/keymap.c @@ -1,242 +1,242 @@ -#include "roadkit.h" -#include "action_layer.h" -#include "eeconfig.h" - -extern keymap_config_t keymap_config; - -// Each layer gets a name for readability, which is then used in the keymap matrix below. -// The underscores don't mean anything - you can have a layer called STUFF or any other name. -// Layer names don't all need to be of the same length, obviously, and you can also skip them -// entirely and just use numbers. - -#define _NP 0 -#define _L1 1 -#define _L2 2 -#define _L3 3 - -// Macro name shortcuts -#define NUMPAD M(_NP) -#define LAYER1 M(_L1) -#define LAYER2 M(_L2) -#define LAYER3 M(_L3) - -// Fillers to make layering more clear -#define _______ KC_TRNS -#define XXXXXXX KC_NO - -void matrix_init_user(void) { - backlight_level(4); -} - - - -//Tap Dance Declarations - -enum { - - TD_EQUAL_NP = 0, - TD_KP_PLUS_L1, - TD_DOT_L2, - TD_0_L3 - -}; - -//Tap Dance Definitions - - - //TD equal to turn on layer NP -void _td_equal_tg_finished (qk_tap_dance_state_t *state, void *user_data) { - if (state->count == 1) { - register_code(KC_EQUAL); - } else if (state->count == 2) { - backlight_set(3); - layer_on(_NP); - layer_off(_L1); - layer_off(_L2); - layer_off(_L3); - } -} - -void _td_equal_tg_reset (qk_tap_dance_state_t *state, void *user_data) { - if (state->count == 1) { - unregister_code(KC_EQUAL); - } -} - - - //TD kp plus to toggle layer 1 -void _td_kp_plus_tg_finished (qk_tap_dance_state_t *state, void *user_data) { - if (state->count == 1) { - register_code(KC_KP_PLUS); - } else if (state->count == 2) { -// layer_invert(_L1); - backlight_set(2); - layer_on(_L1); - layer_off(_L2); - layer_off(_L3); - } -} - -void _td_kp_plus_tg_reset (qk_tap_dance_state_t *state, void *user_data) { - if (state->count == 1) { - unregister_code(KC_KP_PLUS); - } -} - - - //TD dot to toggle layer 2 -void _td_dot_tg_finished (qk_tap_dance_state_t *state, void *user_data) { - if (state->count == 1) { - register_code(KC_DOT); - } else if (state->count == 2) { - backlight_set(1); - layer_on(_L2); - layer_off(_L1); - layer_off(_L3); - } -} - -void _td_dot_tg_reset (qk_tap_dance_state_t *state, void *user_data) { - if (state->count == 1) { - unregister_code(KC_DOT); - } -} - - //TD 0 to toggle layer 3 -void _td_0_tg_finished (qk_tap_dance_state_t *state, void *user_data) { - if (state->count == 1) { - register_code(KC_0); - } else if (state->count == 2) { - backlight_set(0); - layer_on(_L3); - layer_off(_L1); - layer_off(_L2); - } -} - -void _td_0_tg_reset (qk_tap_dance_state_t *state, void *user_data) { - if (state->count == 1) { - unregister_code(KC_0); - } -} - -//TD Actions -qk_tap_dance_action_t tap_dance_actions[] = { - [TD_EQUAL_NP] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, _td_equal_tg_finished, _td_equal_tg_reset), - [TD_KP_PLUS_L1] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, _td_kp_plus_tg_finished, _td_kp_plus_tg_reset), - [TD_DOT_L2] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, _td_dot_tg_finished, _td_dot_tg_reset), - [TD_0_L3] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, _td_0_tg_finished, _td_0_tg_reset) -}; - - - -const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - -/* Numberpad - * ,-----------------------. - * | 7 | 8 | 9 | / | - * |-----`-----`-----`-----| - * | 4 | 5 | 6 | * | - * |-----`-----`-----`-----| - * | 1 | 2 | 3 | - | - * |-----`-----`-----`-----| - * | 0 | . | + | = | - * `-----`-----`-----`-----' - * Tapdances: - * | L3 | L2 | L1 | NP | - * `-----`-----`-----`-----' - */ - [_NP] = /* Numpad */ - SINGLES_KEYMAP(KC_7, KC_8, KC_9, KC_SLASH, \ - KC_4, KC_5, KC_6, KC_KP_ASTERISK, \ - KC_1, KC_2, KC_3, KC_MINUS, \ - TD(TD_0_L3), TD(TD_DOT_L2), TD(TD_KP_PLUS_L1), TD(TD_EQUAL_NP)), - -/* L1 - * ,-----------------------. - * | Esc |Bksp |Home |PgUp | - * |-----`-----`-----`-----| - * | Tab | Up | End |PgDn | - * |-----`-----`-----`-----| - * |Left |Down |Right|Enter| - * |-----`-----`-----`-----| - * | 0 | . | + | = | - * `-----`-----`-----`-----' - */ - [_L1] = /* LAYER 1 */ - SINGLES_KEYMAP(KC_ESCAPE, KC_BSPACE, KC_HOME, KC_PGUP, \ - KC_TAB, KC_UP, KC_END, KC_PGDOWN, \ - KC_LEFT, KC_DOWN, KC_RIGHT, KC_KP_ENTER, \ - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), - -/* L2 - * ,-----------------------. - * |Sleep|LClik|RClik|VolUp| - * |-----`-----`-----`-----| - * |AltF4| F11 |WinTb|VolDn| - * |-----`-----`-----`-----| - * |PrvTk|Play |NxtTk|Mute | - * |-----`-----`-----`-----| - * | 0 | . | + | = | - * `-----`-----`-----`-----' - */ - [_L2] = /* LAYER 2 */ - SINGLES_KEYMAP(KC_SYSTEM_SLEEP, KC_MS_BTN1, KC_MS_BTN2, KC_AUDIO_VOL_UP, \ - LALT(KC_F4), KC_F11, LGUI(KC_TAB), KC_AUDIO_VOL_DOWN, \ - KC_MEDIA_PREV_TRACK, KC_MEDIA_PLAY_PAUSE, KC_MEDIA_NEXT_TRACK, KC_AUDIO_MUTE, \ - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), - - -/* L3 needs cut, copy, paste, undo, again (redo), find, calc, www back, www forward, F5 - * ,-----------------------. - * |WBack|WHome|WFor | F5 | - * |-----`-----`-----`-----| - * |Calc |Undo |Redo |WSrch| - * |-----`-----`-----`-----| - * | Cut |Copy |Paste|Find | - * |-----`-----`-----`-----| - * | 0 | . | + | = | - * `-----`-----`-----`-----' - */ - [_L3] = /* LAYER 3 */ - SINGLES_KEYMAP(KC_WWW_BACK, KC_WWW_HOME, KC_WWW_FORWARD, KC_F5, \ - KC_CALCULATOR, LCTL(KC_Z), LCTL(KC_Y), KC_WWW_SEARCH, \ - LCTL(KC_X), LCTL(KC_C), LCTL(KC_V), LCTL(KC_F), \ - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), -}; - -const uint16_t PROGMEM fn_actions[] = { - -}; - -void persistent_default_layer_set(uint16_t default_layer) { - eeconfig_update_default_layer(default_layer); - default_layer_set(default_layer); -} - -const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) -{ - switch(id) { - case _L3: - if (record->event.pressed) { - persistent_default_layer_set(1UL<<_L3); - } - break; - case _L2: - if (record->event.pressed) { - persistent_default_layer_set(1UL<<_L2); - } - break; - case _L1: - if (record->event.pressed) { - persistent_default_layer_set(1UL<<_L1); - } - break; - case _NP: - if (record->event.pressed) { - persistent_default_layer_set(1UL<<_NP); - } - break; - } - return MACRO_NONE; -}; +#include "roadkit.h" +#include "action_layer.h" +#include "eeconfig.h" + +extern keymap_config_t keymap_config; + +// Each layer gets a name for readability, which is then used in the keymap matrix below. +// The underscores don't mean anything - you can have a layer called STUFF or any other name. +// Layer names don't all need to be of the same length, obviously, and you can also skip them +// entirely and just use numbers. + +#define _NP 0 +#define _L1 1 +#define _L2 2 +#define _L3 3 + +// Macro name shortcuts +#define NUMPAD M(_NP) +#define LAYER1 M(_L1) +#define LAYER2 M(_L2) +#define LAYER3 M(_L3) + +// Fillers to make layering more clear +#define _______ KC_TRNS +#define XXXXXXX KC_NO + +void matrix_init_user(void) { + backlight_level(4); +} + + + +//Tap Dance Declarations + +enum { + + TD_EQUAL_NP = 0, + TD_KP_PLUS_L1, + TD_DOT_L2, + TD_0_L3 + +}; + +//Tap Dance Definitions + + + //TD equal to turn on layer NP +void _td_equal_tg_finished (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + register_code(KC_EQUAL); + } else if (state->count == 2) { + backlight_set(3); + layer_on(_NP); + layer_off(_L1); + layer_off(_L2); + layer_off(_L3); + } +} + +void _td_equal_tg_reset (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + unregister_code(KC_EQUAL); + } +} + + + //TD kp plus to toggle layer 1 +void _td_kp_plus_tg_finished (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + register_code(KC_KP_PLUS); + } else if (state->count == 2) { +// layer_invert(_L1); + backlight_set(2); + layer_on(_L1); + layer_off(_L2); + layer_off(_L3); + } +} + +void _td_kp_plus_tg_reset (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + unregister_code(KC_KP_PLUS); + } +} + + + //TD dot to toggle layer 2 +void _td_dot_tg_finished (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + register_code(KC_DOT); + } else if (state->count == 2) { + backlight_set(1); + layer_on(_L2); + layer_off(_L1); + layer_off(_L3); + } +} + +void _td_dot_tg_reset (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + unregister_code(KC_DOT); + } +} + + //TD 0 to toggle layer 3 +void _td_0_tg_finished (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + register_code(KC_0); + } else if (state->count == 2) { + backlight_set(0); + layer_on(_L3); + layer_off(_L1); + layer_off(_L2); + } +} + +void _td_0_tg_reset (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + unregister_code(KC_0); + } +} + +//TD Actions +qk_tap_dance_action_t tap_dance_actions[] = { + [TD_EQUAL_NP] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, _td_equal_tg_finished, _td_equal_tg_reset), + [TD_KP_PLUS_L1] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, _td_kp_plus_tg_finished, _td_kp_plus_tg_reset), + [TD_DOT_L2] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, _td_dot_tg_finished, _td_dot_tg_reset), + [TD_0_L3] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, _td_0_tg_finished, _td_0_tg_reset) +}; + + + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + +/* Numberpad + * ,-----------------------. + * | 7 | 8 | 9 | / | + * |-----`-----`-----`-----| + * | 4 | 5 | 6 | * | + * |-----`-----`-----`-----| + * | 1 | 2 | 3 | - | + * |-----`-----`-----`-----| + * | 0 | . | + | = | + * `-----`-----`-----`-----' + * Tapdances: + * | L3 | L2 | L1 | NP | + * `-----`-----`-----`-----' + */ + [_NP] = /* Numpad */ + SINGLES_KEYMAP(KC_7, KC_8, KC_9, KC_SLASH, \ + KC_4, KC_5, KC_6, KC_KP_ASTERISK, \ + KC_1, KC_2, KC_3, KC_MINUS, \ + TD(TD_0_L3), TD(TD_DOT_L2), TD(TD_KP_PLUS_L1), TD(TD_EQUAL_NP)), + +/* L1 + * ,-----------------------. + * | Esc |Bksp |Home |PgUp | + * |-----`-----`-----`-----| + * | Tab | Up | End |PgDn | + * |-----`-----`-----`-----| + * |Left |Down |Right|Enter| + * |-----`-----`-----`-----| + * | 0 | . | + | = | + * `-----`-----`-----`-----' + */ + [_L1] = /* LAYER 1 */ + SINGLES_KEYMAP(KC_ESCAPE, KC_BSPACE, KC_HOME, KC_PGUP, \ + KC_TAB, KC_UP, KC_END, KC_PGDOWN, \ + KC_LEFT, KC_DOWN, KC_RIGHT, KC_KP_ENTER, \ + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + +/* L2 + * ,-----------------------. + * |Sleep|LClik|RClik|VolUp| + * |-----`-----`-----`-----| + * |AltF4| F11 |WinTb|VolDn| + * |-----`-----`-----`-----| + * |PrvTk|Play |NxtTk|Mute | + * |-----`-----`-----`-----| + * | 0 | . | + | = | + * `-----`-----`-----`-----' + */ + [_L2] = /* LAYER 2 */ + SINGLES_KEYMAP(KC_SYSTEM_SLEEP, KC_MS_BTN1, KC_MS_BTN2, KC_AUDIO_VOL_UP, \ + LALT(KC_F4), KC_F11, LGUI(KC_TAB), KC_AUDIO_VOL_DOWN, \ + KC_MEDIA_PREV_TRACK, KC_MEDIA_PLAY_PAUSE, KC_MEDIA_NEXT_TRACK, KC_AUDIO_MUTE, \ + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + + +/* L3 needs cut, copy, paste, undo, again (redo), find, calc, www back, www forward, F5 + * ,-----------------------. + * |WBack|WHome|WFor | F5 | + * |-----`-----`-----`-----| + * |Calc |Undo |Redo |WSrch| + * |-----`-----`-----`-----| + * | Cut |Copy |Paste|Find | + * |-----`-----`-----`-----| + * | 0 | . | + | = | + * `-----`-----`-----`-----' + */ + [_L3] = /* LAYER 3 */ + SINGLES_KEYMAP(KC_WWW_BACK, KC_WWW_HOME, KC_WWW_FORWARD, KC_F5, \ + KC_CALCULATOR, LCTL(KC_Z), LCTL(KC_Y), KC_WWW_SEARCH, \ + LCTL(KC_X), LCTL(KC_C), LCTL(KC_V), LCTL(KC_F), \ + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), +}; + +const uint16_t PROGMEM fn_actions[] = { + +}; + +void persistent_default_layer_set(uint16_t default_layer) { + eeconfig_update_default_layer(default_layer); + default_layer_set(default_layer); +} + +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + switch(id) { + case _L3: + if (record->event.pressed) { + persistent_default_layer_set(1UL<<_L3); + } + break; + case _L2: + if (record->event.pressed) { + persistent_default_layer_set(1UL<<_L2); + } + break; + case _L1: + if (record->event.pressed) { + persistent_default_layer_set(1UL<<_L1); + } + break; + case _NP: + if (record->event.pressed) { + persistent_default_layer_set(1UL<<_NP); + } + break; + } + return MACRO_NONE; +}; diff --git a/keyboards/roadkit/keymaps/singlesBrent/readme.md b/keyboards/roadkit/keymaps/singlesBrent/readme.md index fdef3baa2e..48ea4a8b35 100644 --- a/keyboards/roadkit/keymaps/singlesBrent/readme.md +++ b/keyboards/roadkit/keymaps/singlesBrent/readme.md @@ -1,3 +1,3 @@ -# The singles keymap for roadkit - -This keymap has a base layer with numpad functionality, and then a second layer with some additional keys. The user is encouraged to develop their own keymap using this as a starting point. +# The singles keymap for roadkit + +This keymap has a base layer with numpad functionality, and then a second layer with some additional keys. The user is encouraged to develop their own keymap using this as a starting point. -- cgit v1.2.3 From 6a3c66776cb10888b24400526241b46deeb051a8 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Thu, 20 Jul 2017 23:57:11 -0400 Subject: clean-up planck and preonic keymaps, move audio stuff around --- keyboards/planck/keymaps/default/config.h | 10 +++ keyboards/planck/keymaps/default/keymap.c | 100 +++++++---------------------- keyboards/preonic/keymaps/default/config.h | 10 +++ keyboards/preonic/keymaps/default/keymap.c | 95 ++++++--------------------- quantum/audio/audio.c | 14 ++++ quantum/audio/audio.h | 2 +- quantum/audio/song_list.h | 42 ++++++++++-- quantum/config_common.h | 2 + quantum/process_keycode/process_music.c | 20 ++++-- quantum/quantum.c | 47 +++++++++++++- quantum/quantum.h | 3 + quantum/quantum_keycodes.h | 4 ++ 12 files changed, 184 insertions(+), 165 deletions(-) diff --git a/keyboards/planck/keymaps/default/config.h b/keyboards/planck/keymaps/default/config.h index 4c61581993..1ce547b949 100644 --- a/keyboards/planck/keymaps/default/config.h +++ b/keyboards/planck/keymaps/default/config.h @@ -15,6 +15,16 @@ */ #define MIDI_BASIC +#ifdef AUDIO_ENABLE + #define STARTUP_SONG SONG(PLANCK_SOUND) + // #define STARTUP_SONG SONG(NO_SOUND) + + #define DEFAULT_LAYER_SONGS { SONG(QWERTY_SOUND), \ + SONG(COLEMAK_SOUND), \ + SONG(DVORAK_SOUND) \ + } +#endif + /* enable advanced MIDI features: - MIDI notes can be added to the keymap - Octave shift and transpose diff --git a/keyboards/planck/keymaps/default/keymap.c b/keyboards/planck/keymaps/default/keymap.c index 61275cb26a..ddb93c8857 100644 --- a/keyboards/planck/keymaps/default/keymap.c +++ b/keyboards/planck/keymaps/default/keymap.c @@ -1,20 +1,28 @@ -// This is the canonical layout file for the Quantum project. If you want to add another keyboard, -// this is the style you want to emulate. +/* Copyright 2015-2017 Jack Humbert + * + * 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 . + */ #include "planck.h" #include "action_layer.h" +#include "eeconfig.h" #ifdef AUDIO_ENABLE #include "audio.h" #endif -#include "eeconfig.h" extern keymap_config_t keymap_config; -// Each layer gets a name for readability, which is then used in the keymap matrix below. -// The underscores don't mean anything - you can have a layer called STUFF or any other name. -// Layer names don't all need to be of the same length, obviously, and you can also skip them -// entirely and just use numbers. - enum planck_layers { _QWERTY, _COLEMAK, @@ -36,10 +44,6 @@ enum planck_keycodes { EXT_PLV }; -// Fillers to make layering more clear -#define _______ KC_TRNS -#define XXXXXXX KC_NO - const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* Qwerty @@ -173,50 +177,27 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { }; #ifdef AUDIO_ENABLE - -float tone_startup[][2] = SONG(STARTUP_SOUND); -float tone_qwerty[][2] = SONG(QWERTY_SOUND); -float tone_dvorak[][2] = SONG(DVORAK_SOUND); -float tone_colemak[][2] = SONG(COLEMAK_SOUND); -float tone_plover[][2] = SONG(PLOVER_SOUND); -float tone_plover_gb[][2] = SONG(PLOVER_GOODBYE_SOUND); -float music_scale[][2] = SONG(MUSIC_SCALE_SOUND); - -float tone_goodbye[][2] = SONG(GOODBYE_SOUND); + float plover_song[][2] = SONG(PLOVER_SOUND); + float plover_gb_song[][2] = SONG(PLOVER_GOODBYE_SOUND); #endif - -void persistent_default_layer_set(uint16_t default_layer) { - eeconfig_update_default_layer(default_layer); - default_layer_set(default_layer); -} - bool process_record_user(uint16_t keycode, keyrecord_t *record) { switch (keycode) { case QWERTY: if (record->event.pressed) { - #ifdef AUDIO_ENABLE - PLAY_NOTE_ARRAY(tone_qwerty, false, 0); - #endif - persistent_default_layer_set(1UL<<_QWERTY); + set_single_persistent_default_layer(_QWERTY); } return false; break; case COLEMAK: if (record->event.pressed) { - #ifdef AUDIO_ENABLE - PLAY_NOTE_ARRAY(tone_colemak, false, 0); - #endif - persistent_default_layer_set(1UL<<_COLEMAK); + set_single_persistent_default_layer(_COLEMAK); } return false; break; case DVORAK: if (record->event.pressed) { - #ifdef AUDIO_ENABLE - PLAY_NOTE_ARRAY(tone_dvorak, false, 0); - #endif - persistent_default_layer_set(1UL<<_DVORAK); + set_single_persistent_default_layer(_DVORAK); } return false; break; @@ -255,7 +236,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { #ifdef AUDIO_ENABLE stop_all_notes(); - PLAY_NOTE_ARRAY(tone_plover, false, 0); + PLAY_SONG(plover_song); #endif layer_off(_RAISE); layer_off(_LOWER); @@ -273,7 +254,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { case EXT_PLV: if (record->event.pressed) { #ifdef AUDIO_ENABLE - PLAY_NOTE_ARRAY(tone_plover_gb, false, 0); + PLAY_SONG(plover_gb_song); #endif layer_off(_PLOVER); } @@ -281,37 +262,4 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { break; } return true; -} - -void matrix_init_user(void) { - #ifdef AUDIO_ENABLE - startup_user(); - #endif -} - -#ifdef AUDIO_ENABLE - -void startup_user() -{ - _delay_ms(20); // gets rid of tick - PLAY_NOTE_ARRAY(tone_startup, false, 0); -} - -void shutdown_user() -{ - PLAY_NOTE_ARRAY(tone_goodbye, false, 0); - _delay_ms(150); - stop_all_notes(); -} - -void music_on_user(void) -{ - music_scale_user(); -} - -void music_scale_user(void) -{ - PLAY_NOTE_ARRAY(music_scale, false, 0); -} - -#endif +} \ No newline at end of file diff --git a/keyboards/preonic/keymaps/default/config.h b/keyboards/preonic/keymaps/default/config.h index 4c61581993..1ce547b949 100644 --- a/keyboards/preonic/keymaps/default/config.h +++ b/keyboards/preonic/keymaps/default/config.h @@ -15,6 +15,16 @@ */ #define MIDI_BASIC +#ifdef AUDIO_ENABLE + #define STARTUP_SONG SONG(PLANCK_SOUND) + // #define STARTUP_SONG SONG(NO_SOUND) + + #define DEFAULT_LAYER_SONGS { SONG(QWERTY_SOUND), \ + SONG(COLEMAK_SOUND), \ + SONG(DVORAK_SOUND) \ + } +#endif + /* enable advanced MIDI features: - MIDI notes can be added to the keymap - Octave shift and transpose diff --git a/keyboards/preonic/keymaps/default/keymap.c b/keyboards/preonic/keymaps/default/keymap.c index 2516a726bd..a05117c9e6 100644 --- a/keyboards/preonic/keymaps/default/keymap.c +++ b/keyboards/preonic/keymaps/default/keymap.c @@ -1,3 +1,19 @@ +/* Copyright 2015-2017 Jack Humbert + * + * 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 . + */ + #include "preonic.h" #include "action_layer.h" #include "eeconfig.h" @@ -5,11 +21,6 @@ #include "audio.h" #endif -// Each layer gets a name for readability, which is then used in the keymap matrix below. -// The underscores don't mean anything - you can have a layer called STUFF or any other name. -// Layer names don't all need to be of the same length, obviously, and you can also skip them -// entirely and just use numbers. - enum preonic_layers { _QWERTY, _COLEMAK, @@ -28,10 +39,6 @@ enum preonic_keycodes { BACKLIT }; -// Fillers to make layering more clear -#define _______ KC_TRNS -#define XXXXXXX KC_NO - const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* Qwerty @@ -163,54 +170,23 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { }; -#ifdef AUDIO_ENABLE -float tone_startup[][2] = { - {NOTE_B5, 20}, - {NOTE_B6, 8}, - {NOTE_DS6, 20}, - {NOTE_B6, 8} -}; - -float tone_qwerty[][2] = SONG(QWERTY_SOUND); -float tone_dvorak[][2] = SONG(DVORAK_SOUND); -float tone_colemak[][2] = SONG(COLEMAK_SOUND); - -float tone_goodbye[][2] = SONG(GOODBYE_SOUND); - -float music_scale[][2] = SONG(MUSIC_SCALE_SOUND); -#endif - -void persistent_default_layer_set(uint16_t default_layer) { - eeconfig_update_default_layer(default_layer); - default_layer_set(default_layer); -} - bool process_record_user(uint16_t keycode, keyrecord_t *record) { switch (keycode) { case QWERTY: if (record->event.pressed) { - #ifdef AUDIO_ENABLE - PLAY_NOTE_ARRAY(tone_qwerty, false, 0); - #endif - persistent_default_layer_set(1UL<<_QWERTY); + set_single_persistent_default_layer(_QWERTY); } return false; break; case COLEMAK: if (record->event.pressed) { - #ifdef AUDIO_ENABLE - PLAY_NOTE_ARRAY(tone_colemak, false, 0); - #endif - persistent_default_layer_set(1UL<<_COLEMAK); + set_single_persistent_default_layer(_COLEMAK); } return false; break; case DVORAK: if (record->event.pressed) { - #ifdef AUDIO_ENABLE - PLAY_NOTE_ARRAY(tone_dvorak, false, 0); - #endif - persistent_default_layer_set(1UL<<_DVORAK); + set_single_persistent_default_layer(_DVORAK); } return false; break; @@ -248,36 +224,3 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } return true; }; - -void matrix_init_user(void) { - #ifdef AUDIO_ENABLE - startup_user(); - #endif -} - -#ifdef AUDIO_ENABLE - -void startup_user() -{ - _delay_ms(20); // gets rid of tick - PLAY_NOTE_ARRAY(tone_startup, false, 0); -} - -void shutdown_user() -{ - PLAY_NOTE_ARRAY(tone_goodbye, false, 0); - _delay_ms(150); - stop_all_notes(); -} - -void music_on_user(void) -{ - music_scale_user(); -} - -void music_scale_user(void) -{ - PLAY_NOTE_ARRAY(music_scale, false, 0); -} - -#endif diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c index c924f2bd58..5b85630932 100644 --- a/quantum/audio/audio.c +++ b/quantum/audio/audio.c @@ -13,6 +13,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + #include #include //#include @@ -119,9 +120,17 @@ audio_config_t audio_config; uint16_t envelope_index = 0; bool glissando = true; +#ifndef STARTUP_SONG + #define STARTUP_SONG SONG(STARTUP_SOUND) +#endif +float startup_song[][2] = STARTUP_SONG; + void audio_init() { + if (audio_initialized) + return; + // Check EEPROM if (!eeconfig_is_enabled()) { @@ -169,6 +178,11 @@ void audio_init() #endif audio_initialized = true; + + if (audio_config.enable) { + PLAY_NOTE_ARRAY(startup_song, false, LEGATO); + } + } void stop_all_notes() diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h index 27fdc2ab63..ad3abeb78a 100644 --- a/quantum/audio/audio.h +++ b/quantum/audio/audio.h @@ -99,7 +99,7 @@ void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest) // The global float array for the song must be used here. #define NOTE_ARRAY_SIZE(x) ((int16_t)(sizeof(x) / (sizeof(x[0])))) #define PLAY_NOTE_ARRAY(note_array, note_repeat, note_rest_style) play_notes(¬e_array, NOTE_ARRAY_SIZE((note_array)), (note_repeat), (note_rest_style)); - +#define PLAY_SONG(song) PLAY_NOTE_ARRAY(song, false, STACCATO) bool is_playing_notes(void); diff --git a/quantum/audio/song_list.h b/quantum/audio/song_list.h index db2d1a94cd..6960bee6da 100644 --- a/quantum/audio/song_list.h +++ b/quantum/audio/song_list.h @@ -18,9 +18,7 @@ #ifndef SONG_LIST_H #define SONG_LIST_H -#define COIN_SOUND \ - E__NOTE(_A5 ),\ - HD_NOTE(_E6 ), +#define NO_SOUND #define ODE_TO_JOY \ Q__NOTE(_E4), Q__NOTE(_E4), Q__NOTE(_F4), Q__NOTE(_G4), \ @@ -55,18 +53,29 @@ E__NOTE(_CS4), E__NOTE(_B4), QD_NOTE(_AS4), \ E__NOTE(_AS4), E__NOTE(_AS4), QD_NOTE(_B4), +#define STARTUP_SOUND \ + E__NOTE(_E6), \ + E__NOTE(_A6), \ + ED_NOTE(_E7), + #define GOODBYE_SOUND \ E__NOTE(_E7), \ E__NOTE(_A6), \ ED_NOTE(_E6), -#define STARTUP_SOUND \ +#define PLANCK_SOUND \ ED_NOTE(_E7 ), \ E__NOTE(_CS7), \ E__NOTE(_E6 ), \ E__NOTE(_A6 ), \ M__NOTE(_CS7, 20), +#define PREONIC_SOUND \ + M__NOTE(_B5, 20), \ + E__NOTE(_B6), \ + M__NOTE(_DS6, 20), \ + E__NOTE(_B6), + #define QWERTY_SOUND \ E__NOTE(_GS6 ), \ E__NOTE(_A6 ), \ @@ -107,7 +116,8 @@ S__NOTE(_REST), \ ED_NOTE(_E7 ), -#define MUSIC_SCALE_SOUND \ + +#define MUSIC_ON_SOUND \ E__NOTE(_A5 ), \ E__NOTE(_B5 ), \ E__NOTE(_CS6), \ @@ -117,6 +127,18 @@ E__NOTE(_GS6), \ E__NOTE(_A6 ), +#define MUSIC_SCALE_SOUND MUSIC_ON_SOUND + +#define MUSIC_OFF_SOUND \ + E__NOTE(_A6 ), \ + E__NOTE(_GS6 ), \ + E__NOTE(_FS6), \ + E__NOTE(_E6 ), \ + E__NOTE(_D6 ), \ + E__NOTE(_CS6), \ + E__NOTE(_B5), \ + E__NOTE(_A5 ), + #define CAPS_LOCK_ON_SOUND \ E__NOTE(_A3), \ E__NOTE(_B3), @@ -141,6 +163,16 @@ E__NOTE(_E5), \ E__NOTE(_D5), +#define AG_NORM_SOUND \ + E__NOTE(_A5), \ + E__NOTE(_A5), + +#define AG_SWAP_SOUND \ + SD_NOTE(_B5), \ + SD_NOTE(_A5), \ + SD_NOTE(_B5), \ + SD_NOTE(_A5), + #define UNICODE_WINDOWS \ E__NOTE(_B5), \ S__NOTE(_E6), diff --git a/quantum/config_common.h b/quantum/config_common.h index c88e02d918..4c6a702af4 100644 --- a/quantum/config_common.h +++ b/quantum/config_common.h @@ -100,4 +100,6 @@ #define API_SYSEX_MAX_SIZE 32 +#include "song_list.h" + #endif diff --git a/quantum/process_keycode/process_music.c b/quantum/process_keycode/process_music.c index 217dca2807..c01740a7f4 100644 --- a/quantum/process_keycode/process_music.c +++ b/quantum/process_keycode/process_music.c @@ -39,6 +39,15 @@ static uint8_t music_sequence_position = 0; static uint16_t music_sequence_timer = 0; static uint16_t music_sequence_interval = 100; +#ifndef MUSIC_ON_SONG + #define MUSIC_ON_SONG SONG(MUSIC_ON_SOUND) +#endif +#ifndef MUSIC_OFF_SONG + #define MUSIC_OFF_SONG SONG(MUSIC_OFF_SOUND) +#endif +float music_on_song[][2] = MUSIC_ON_SONG; +float music_off_song[][2] = MUSIC_OFF_SONG; + static void music_noteon(uint8_t note) { #ifdef AUDIO_ENABLE process_audio_noteon(note); @@ -79,12 +88,9 @@ bool process_music(uint16_t keycode, keyrecord_t *record) { } if (keycode == MU_TOG && record->event.pressed) { - if (music_activated) - { + if (music_activated) { music_off(); - } - else - { + } else { music_on(); } return false; @@ -175,12 +181,14 @@ void music_toggle(void) { void music_on(void) { music_activated = 1; + PLAY_SONG(music_on_song); music_on_user(); } void music_off(void) { - music_activated = 0; music_all_notes_off(); + music_activated = 0; + PLAY_SONG(music_off_song); } void matrix_scan_music(void) { diff --git a/quantum/quantum.c b/quantum/quantum.c index 36e586d316..31a6fc7133 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -30,6 +30,28 @@ extern backlight_config_t backlight_config; #include "fauxclicky.h" #endif +#ifdef AUDIO_ENABLE + #ifndef GOODBYE_SONG + #define GOODBYE_SONG SONG(GOODBYE_SOUND) + #endif + #ifndef AG_NORM_SONG + #define AG_NORM_SONG SONG(AG_NORM_SOUND) + #endif + #ifndef AG_SWAP_SONG + #define AG_SWAP_SONG SONG(AG_SWAP_SOUND) + #endif + #ifndef DEFAULT_LAYER_SONGS + #define DEFAULT_LAYER_SONGS { SONG(QWERTY_SOUND), \ + SONG(COLEMAK_SOUND) \ + SONG(DVORAK_SOUND) \ + } + #endif + float goodbye_song[][2] = GOODBYE_SONG; + float ag_norm_song[][2] = AG_NORM_SONG; + float ag_swap_song[][2] = AG_SWAP_SONG; + float default_layer_songs[][16][2] = DEFAULT_LAYER_SONGS; +#endif + static void do_code16 (uint16_t code, void (*f) (uint8_t)) { switch (code) { case QK_MODS ... QK_MODS_MAX: @@ -116,9 +138,15 @@ void reset_keyboard(void) { clear_keyboard(); #if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_ENABLE_BASIC)) music_all_notes_off(); + uint16_t timer_start = timer_read(); + PLAY_SONG(goodbye_song); shutdown_user(); -#endif + while(timer_elapsed(timer_start) < 250) + wait_ms(1); + stop_all_notes(); +#else wait_ms(250); +#endif #ifdef CATERINA_BOOTLOADER *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific #endif @@ -351,6 +379,9 @@ bool process_record_quantum(keyrecord_t *record) { case MAGIC_SWAP_ALT_GUI: keymap_config.swap_lalt_lgui = true; keymap_config.swap_ralt_rgui = true; + #ifdef AUDIO_ENABLE + PLAY_SONG(ag_swap_song); + #endif break; case MAGIC_UNSWAP_CONTROL_CAPSLOCK: keymap_config.swap_control_capslock = false; @@ -379,6 +410,9 @@ bool process_record_quantum(keyrecord_t *record) { case MAGIC_UNSWAP_ALT_GUI: keymap_config.swap_lalt_lgui = false; keymap_config.swap_ralt_rgui = false; + #ifdef AUDIO_ENABLE + PLAY_SONG(ag_norm_song); + #endif break; case MAGIC_TOGGLE_NKRO: keymap_config.nkro = !keymap_config.nkro; @@ -521,6 +555,14 @@ void send_string_with_delay(const char *str, uint8_t interval) { } } +void set_single_persistent_default_layer(uint8_t default_layer) { + #ifdef AUDIO_ENABLE + PLAY_SONG(default_layer_songs[default_layer]); + #endif + eeconfig_update_default_layer(1U< Date: Fri, 21 Jul 2017 01:02:32 -0400 Subject: start updating audio docs --- docs/modding_your_keyboard.md | 3 ++- quantum/quantum.c | 5 +---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/modding_your_keyboard.md b/docs/modding_your_keyboard.md index 44e6e6e72a..30ff4f91af 100644 --- a/docs/modding_your_keyboard.md +++ b/docs/modding_your_keyboard.md @@ -41,7 +41,8 @@ Wherein we bind predefined songs (from [quantum/audio/song_list.h](https://githu So now you have something called `tone_plover` for example. How do you make it play the Plover tune, then? If you look further down the keymap, you'll see this: ``` -PLAY_NOTE_ARRAY(tone_plover, false, 0); // Signature is: Song name, repeat, rest style +PLAY_NOTE_ARRAY(tone_plover, false, LEGATO); // song name, repeat, rest style +PLAY_SONG(tone_plover); // song name (repeat is false, rest is STACCATO) ``` This is inside one of the macros. So when that macro executes, your keyboard plays that particular chime. diff --git a/quantum/quantum.c b/quantum/quantum.c index 31a6fc7133..b76a114186 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -41,10 +41,7 @@ extern backlight_config_t backlight_config; #define AG_SWAP_SONG SONG(AG_SWAP_SOUND) #endif #ifndef DEFAULT_LAYER_SONGS - #define DEFAULT_LAYER_SONGS { SONG(QWERTY_SOUND), \ - SONG(COLEMAK_SOUND) \ - SONG(DVORAK_SOUND) \ - } + #define DEFAULT_LAYER_SONGS { } #endif float goodbye_song[][2] = GOODBYE_SONG; float ag_norm_song[][2] = AG_NORM_SONG; -- cgit v1.2.3 From fd664fe85b4d6e8a849ae47be5e29857fa3a24a5 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Fri, 21 Jul 2017 09:45:02 -0400 Subject: escape song playing in music --- quantum/process_keycode/process_music.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/quantum/process_keycode/process_music.c b/quantum/process_keycode/process_music.c index c01740a7f4..ec2287df1b 100644 --- a/quantum/process_keycode/process_music.c +++ b/quantum/process_keycode/process_music.c @@ -39,14 +39,16 @@ static uint8_t music_sequence_position = 0; static uint16_t music_sequence_timer = 0; static uint16_t music_sequence_interval = 100; -#ifndef MUSIC_ON_SONG - #define MUSIC_ON_SONG SONG(MUSIC_ON_SOUND) -#endif -#ifndef MUSIC_OFF_SONG - #define MUSIC_OFF_SONG SONG(MUSIC_OFF_SOUND) +#ifdef AUDIO_ENABLE + #ifndef MUSIC_ON_SONG + #define MUSIC_ON_SONG SONG(MUSIC_ON_SOUND) + #endif + #ifndef MUSIC_OFF_SONG + #define MUSIC_OFF_SONG SONG(MUSIC_OFF_SOUND) + #endif + float music_on_song[][2] = MUSIC_ON_SONG; + float music_off_song[][2] = MUSIC_OFF_SONG; #endif -float music_on_song[][2] = MUSIC_ON_SONG; -float music_off_song[][2] = MUSIC_OFF_SONG; static void music_noteon(uint8_t note) { #ifdef AUDIO_ENABLE @@ -181,14 +183,18 @@ void music_toggle(void) { void music_on(void) { music_activated = 1; - PLAY_SONG(music_on_song); + #ifdef AUDIO_ENABLE + PLAY_SONG(music_on_song); + #endif music_on_user(); } void music_off(void) { music_all_notes_off(); music_activated = 0; - PLAY_SONG(music_off_song); + #ifdef AUDIO_ENABLE + PLAY_SONG(music_off_song); + #endif } void matrix_scan_music(void) { -- cgit v1.2.3 From f40ded78947e63c10d97266901d257179aaf49d9 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Fri, 21 Jul 2017 10:38:43 -0400 Subject: relocate keymap's useful tools --- keyboards/kc60/keymaps/workman-dead/keymap.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/keyboards/kc60/keymaps/workman-dead/keymap.c b/keyboards/kc60/keymaps/workman-dead/keymap.c index 9e3b9bb656..36e1c6506d 100644 --- a/keyboards/kc60/keymaps/workman-dead/keymap.c +++ b/keyboards/kc60/keymaps/workman-dead/keymap.c @@ -6,9 +6,6 @@ #define _FUN 3 #define _MS 4 -#define _______ KC_NO -#define XXXXXXX KC_TRNS - #define _DK_ACT 0 #define _DK_REL 1 #define _KC_COMS 2 -- cgit v1.2.3 From 92ccc9a7b8ac856966147be48e24ce652c160386 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Fri, 21 Jul 2017 12:58:48 -0400 Subject: use automatic rests with songs (no more rest styles) --- quantum/audio/audio.c | 39 +++++++++++++++++++++++++-------------- quantum/audio/audio.h | 8 +++++--- quantum/audio/musical_notes.h | 7 ------- 3 files changed, 30 insertions(+), 24 deletions(-) diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c index 5b85630932..baa364eec2 100644 --- a/quantum/audio/audio.c +++ b/quantum/audio/audio.c @@ -99,7 +99,6 @@ uint16_t note_position = 0; float (* notes_pointer)[][2]; uint16_t notes_count; bool notes_repeat; -float notes_rest; bool note_resting = false; uint8_t current_note = 0; @@ -180,7 +179,7 @@ void audio_init() audio_initialized = true; if (audio_config.enable) { - PLAY_NOTE_ARRAY(startup_song, false, LEGATO); + PLAY_SONG(startup_song); } } @@ -416,9 +415,12 @@ ISR(TIMER3_COMPA_vect) note_position++; bool end_of_note = false; if (TIMER_3_PERIOD > 0) { - end_of_note = (note_position >= (note_length / TIMER_3_PERIOD * 0xFFFF)); + if (!note_resting) + end_of_note = (note_position >= (note_length / TIMER_3_PERIOD * 0xFFFF - 1)); + else + end_of_note = (note_position >= (note_length)); } else { - end_of_note = (note_position >= (note_length * 0x7FF)); + end_of_note = (note_position >= (note_length)); } if (end_of_note) { @@ -433,11 +435,16 @@ ISR(TIMER3_COMPA_vect) return; } } - if (!note_resting && (notes_rest > 0)) { + if (!note_resting) { note_resting = true; - note_frequency = 0; - note_length = notes_rest; current_note--; + if ((*notes_pointer)[current_note][0] == (*notes_pointer)[current_note + 1][0]) { + note_frequency = 0; + note_length = 1; + } else { + note_frequency = (*notes_pointer)[current_note][0]; + note_length = 1; + } } else { note_resting = false; envelope_index = 0; @@ -548,9 +555,9 @@ ISR(TIMER1_COMPA_vect) note_position++; bool end_of_note = false; if (TIMER_1_PERIOD > 0) { - end_of_note = (note_position >= (note_length / TIMER_1_PERIOD * 0xFFFF)); + end_of_note = (note_position >= (note_length / TIMER_1_PERIOD * 0xFFFF - 1)); } else { - end_of_note = (note_position >= (note_length * 0x7FF)); + end_of_note = (note_position >= (note_length)); } if (end_of_note) { @@ -565,11 +572,16 @@ ISR(TIMER1_COMPA_vect) return; } } - if (!note_resting && (notes_rest > 0)) { + if (!note_resting) { note_resting = true; - note_frequency = 0; - note_length = notes_rest; current_note--; + if ((*notes_pointer)[current_note][0] == (*notes_pointer)[current_note + 1][0]) { + note_frequency = 0; + note_length = 1; + } else { + note_frequency = (*notes_pointer)[current_note][0]; + note_length = 1; + } } else { note_resting = false; envelope_index = 0; @@ -638,7 +650,7 @@ void play_note(float freq, int vol) { } -void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest) +void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat) { if (!audio_initialized) { @@ -663,7 +675,6 @@ void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest) notes_pointer = np; notes_count = n_count; notes_repeat = n_repeat; - notes_rest = n_rest; place = 0; current_note = 0; diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h index ad3abeb78a..e29770e3b8 100644 --- a/quantum/audio/audio.h +++ b/quantum/audio/audio.h @@ -86,7 +86,7 @@ void play_sample(uint8_t * s, uint16_t l, bool r); void play_note(float freq, int vol); void stop_note(float freq); void stop_all_notes(void); -void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest); +void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat); #define SCALE (int8_t []){ 0 + (12*0), 2 + (12*0), 4 + (12*0), 5 + (12*0), 7 + (12*0), 9 + (12*0), 11 + (12*0), \ 0 + (12*1), 2 + (12*1), 4 + (12*1), 5 + (12*1), 7 + (12*1), 9 + (12*1), 11 + (12*1), \ @@ -98,8 +98,10 @@ void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest) // length. This works around the limitation of C's sizeof operation on pointers. // The global float array for the song must be used here. #define NOTE_ARRAY_SIZE(x) ((int16_t)(sizeof(x) / (sizeof(x[0])))) -#define PLAY_NOTE_ARRAY(note_array, note_repeat, note_rest_style) play_notes(¬e_array, NOTE_ARRAY_SIZE((note_array)), (note_repeat), (note_rest_style)); -#define PLAY_SONG(song) PLAY_NOTE_ARRAY(song, false, STACCATO) +#define PLAY_NOTE_ARRAY(note_array, note_repeat, deprecated_arg) play_notes(¬e_array, NOTE_ARRAY_SIZE((note_array)), (note_repeat)); \ + _Pragma ("message \"'PLAY_NOTE_ARRAY' macro is deprecated\"") +#define PLAY_SONG(note_array) play_notes(¬e_array, NOTE_ARRAY_SIZE((note_array)), false); +#define PLAY_LOOP(note_array) play_notes(¬e_array, NOTE_ARRAY_SIZE((note_array)), true); bool is_playing_notes(void); diff --git a/quantum/audio/musical_notes.h b/quantum/audio/musical_notes.h index a3aaa2f199..647b695640 100644 --- a/quantum/audio/musical_notes.h +++ b/quantum/audio/musical_notes.h @@ -51,12 +51,6 @@ #define ED_NOTE(n) EIGHTH_DOT_NOTE(n) #define SD_NOTE(n) SIXTEENTH_DOT_NOTE(n) -// Note Styles -// Staccato makes sure there is a rest between each note. Think: TA TA TA -// Legato makes notes flow together. Think: TAAA -#define STACCATO 0.01 -#define LEGATO 0 - // Note Timbre // Changes how the notes sound #define TIMBRE_12 0.125 @@ -65,7 +59,6 @@ #define TIMBRE_75 0.750 #define TIMBRE_DEFAULT TIMBRE_50 - // Notes - # = Octave #define NOTE_REST 0.00 -- cgit v1.2.3 From f407f3e8deea433ae4bca61f17d8ed8ed208bb27 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Fri, 21 Jul 2017 13:18:36 -0400 Subject: remove unneccesary headers --- docs/modding_your_keyboard.md | 22 +++++++++++++++------- keyboards/planck/keymaps/default/keymap.c | 4 ---- keyboards/preonic/keymaps/default/keymap.c | 4 ---- quantum/audio/audio.c | 5 ++++- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/docs/modding_your_keyboard.md b/docs/modding_your_keyboard.md index 30ff4f91af..29b0b3b0fb 100644 --- a/docs/modding_your_keyboard.md +++ b/docs/modding_your_keyboard.md @@ -1,12 +1,23 @@ ## Audio output from a speaker -Your keyboard can make sounds! If you've got a Planck, Preonic, or basically any keyboard that allows access to the C6 or B5 port (`#define C6_AUDIO` and `#define B5_AUDIO`), you can hook up a simple speaker and make it beep. You can use those beeps to indicate layer transitions, modifiers, special keys, or just to play some funky 8bit tunes. +Your keyboard can make sounds! If you've got a Planck, Preonic, or basically any keyboard that allows access to the C6 or B5 port (`#define C6_AUDIO` and/or `#define B5_AUDIO`), you can hook up a simple speaker and make it beep. You can use those beeps to indicate layer transitions, modifiers, special keys, or just to play some funky 8bit tunes. -The audio code lives in [quantum/audio/audio.h](https://github.com/qmk/qmk_firmware/blob/master/quantum/audio/audio.h) and in the other files in the audio directory. It's enabled by default on the Planck [stock keymap](https://github.com/qmk/qmk_firmware/blob/master/keyboards/planck/keymaps/default/keymap.c). Here are the important bits: +If you add this to your `rules.mk`: ``` -#include "audio.h" +AUDIO_ENABLE = yes +``` + +there's a couple different sounds that will automatically be enabled without any other configuration: + + +If you want to implement something custom, you can + +``` +#ifdef AUDIO_ENABLE + #include "audio.h" +#endif ``` Then, lower down the file: @@ -41,14 +52,11 @@ Wherein we bind predefined songs (from [quantum/audio/song_list.h](https://githu So now you have something called `tone_plover` for example. How do you make it play the Plover tune, then? If you look further down the keymap, you'll see this: ``` -PLAY_NOTE_ARRAY(tone_plover, false, LEGATO); // song name, repeat, rest style -PLAY_SONG(tone_plover); // song name (repeat is false, rest is STACCATO) +PLAY_SONG(tone_plover); // song name ``` This is inside one of the macros. So when that macro executes, your keyboard plays that particular chime. -"Rest style" in the method signature above (the last parameter) specifies if there's a rest (a moment of silence) between the notes. - ## Music mode The music mode maps your columns to a chromatic scale, and your rows to octaves. This works best with ortholinear keyboards, but can be made to work with others. All keycodes less than `0xFF` get blocked, so you won't type while playing notes - if you have special keys/mods, those will still work. A work-around for this is to jump to a different layer with KC_NOs before (or after) enabling music mode. diff --git a/keyboards/planck/keymaps/default/keymap.c b/keyboards/planck/keymaps/default/keymap.c index ddb93c8857..34a011b0c9 100644 --- a/keyboards/planck/keymaps/default/keymap.c +++ b/keyboards/planck/keymaps/default/keymap.c @@ -16,10 +16,6 @@ #include "planck.h" #include "action_layer.h" -#include "eeconfig.h" -#ifdef AUDIO_ENABLE - #include "audio.h" -#endif extern keymap_config_t keymap_config; diff --git a/keyboards/preonic/keymaps/default/keymap.c b/keyboards/preonic/keymaps/default/keymap.c index a05117c9e6..491f4ae850 100644 --- a/keyboards/preonic/keymaps/default/keymap.c +++ b/keyboards/preonic/keymaps/default/keymap.c @@ -16,10 +16,6 @@ #include "preonic.h" #include "action_layer.h" -#include "eeconfig.h" -#ifdef AUDIO_ENABLE - #include "audio.h" -#endif enum preonic_layers { _QWERTY, diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c index baa364eec2..8e8570d26c 100644 --- a/quantum/audio/audio.c +++ b/quantum/audio/audio.c @@ -555,7 +555,10 @@ ISR(TIMER1_COMPA_vect) note_position++; bool end_of_note = false; if (TIMER_1_PERIOD > 0) { - end_of_note = (note_position >= (note_length / TIMER_1_PERIOD * 0xFFFF - 1)); + if (!note_resting) + end_of_note = (note_position >= (note_length / TIMER_1_PERIOD * 0xFFFF - 1)); + else + end_of_note = (note_position >= (note_length)); } else { end_of_note = (note_position >= (note_length)); } -- cgit v1.2.3 From 9abbbe70890ee0a0c619411c76a2c7b82b1b49d5 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Fri, 21 Jul 2017 13:30:57 -0400 Subject: update audio documentation --- docs/modding_your_keyboard.md | 59 +++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 36 deletions(-) diff --git a/docs/modding_your_keyboard.md b/docs/modding_your_keyboard.md index 29b0b3b0fb..ab40bdf93c 100644 --- a/docs/modding_your_keyboard.md +++ b/docs/modding_your_keyboard.md @@ -1,61 +1,48 @@ ## Audio output from a speaker -Your keyboard can make sounds! If you've got a Planck, Preonic, or basically any keyboard that allows access to the C6 or B5 port (`#define C6_AUDIO` and/or `#define B5_AUDIO`), you can hook up a simple speaker and make it beep. You can use those beeps to indicate layer transitions, modifiers, special keys, or just to play some funky 8bit tunes. +Your keyboard can make sounds! If you've got a Planck, Preonic, or basically any AVR keyboard that allows access to the C6 or B5 port (`#define C6_AUDIO` and/or `#define B5_AUDIO`), you can hook up a simple speaker and make it beep. You can use those beeps to indicate layer transitions, modifiers, special keys, or just to play some funky 8bit tunes. -If you add this to your `rules.mk`: +If you add `AUDIO_ENABLE = yes` to your `rules.mk`, there's a couple different sounds that will automatically be enabled without any other configuration: ``` -AUDIO_ENABLE = yes +STARTUP_SONG // plays when the keyboard starts up (audio.c) +GOODBYE_SONG // plays when you press the RESET key (quantum.c) +AG_NORM_SONG // plays when you press AG_NORM (quantum.c) +AG_SWAP_SONG // plays when you press AG_SWAP (quantum.c) +MUSIC_ON_SONG // plays when music mode is activated (process_music.c) +MUSIC_OFF_SONG // plays when music mode is deactivated (process_music.c) ``` -there's a couple different sounds that will automatically be enabled without any other configuration: +You can override the default songs by doing something like this in your `config.h`: - -If you want to implement something custom, you can - -``` +```c #ifdef AUDIO_ENABLE - #include "audio.h" + #define STARTUP_SONG SONG(STARTUP_SOUND) #endif ``` -Then, lower down the file: - -``` -float tone_startup[][2] = { - ED_NOTE(_E7 ), - E__NOTE(_CS7), - E__NOTE(_E6 ), - E__NOTE(_A6 ), - M__NOTE(_CS7, 20) -}; -``` - -This is how you write a song. Each of these lines is a note, so we have a little ditty composed of five notes here. +A full list of sounds can be found in [quantum/audio/song_list.h](https://github.com/qmk/qmk_firmware/blob/master/quantum/audio/song_list.h) - feel free to add your own to this list! All available notes can be seen in [quantum/audio/musical_notes.h](https://github.com/qmk/qmk_firmware/blob/master/quantum/audio/musical_notes.h). -Then, we have this chunk: +To play a custom sound at a particular time, you can define a song like this (near the top of the file): +```c +float my_song[][2] = SONG(QWERTY_SOUND); ``` -float tone_qwerty[][2] = SONG(QWERTY_SOUND); -float tone_dvorak[][2] = SONG(DVORAK_SOUND); -float tone_colemak[][2] = SONG(COLEMAK_SOUND); -float tone_plover[][2] = SONG(PLOVER_SOUND); -float tone_plover_gb[][2] = SONG(PLOVER_GOODBYE_SOUND); -float music_scale[][2] = SONG(MUSIC_SCALE_SOUND); -float goodbye[][2] = SONG(GOODBYE_SOUND); -``` +And then play your song like this: -Wherein we bind predefined songs (from [quantum/audio/song_list.h](https://github.com/qmk/qmk_firmware/blob/master/quantum/audio/song_list.h)) into named variables. This is one optimization that helps save on memory: These songs only take up memory when you reference them in your keymap, because they're essentially all preprocessor directives. +```c +PLAY_SONG(my_song); +``` -So now you have something called `tone_plover` for example. How do you make it play the Plover tune, then? If you look further down the keymap, you'll see this: +Alternatively, you can play it in a loop like this: -``` -PLAY_SONG(tone_plover); // song name +```c +PLAY_LOOP(my_song); ``` -This is inside one of the macros. So when that macro executes, your keyboard plays that particular chime. +It's advised that you wrap all audio features in `#ifdef AUDIO_ENABLE` / `#endif` to avoid causing problems when audio isn't built into the keyboard. ## Music mode -- cgit v1.2.3 From 415d38ba9ee20424ce354ed5f8e590fae58b863f Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Sat, 22 Jul 2017 00:14:26 -0400 Subject: adds music mode, music mode songs, music mask --- keyboards/planck/keymaps/default/config.h | 23 +++--- keyboards/planck/keymaps/default/keymap.c | 2 +- keyboards/preonic/keymaps/default/config.h | 23 +++--- keyboards/preonic/keymaps/default/keymap.c | 2 +- quantum/audio/audio.h | 4 +- quantum/audio/song_list.h | 32 ++++++++ quantum/process_keycode/process_audio.c | 16 ++-- quantum/process_keycode/process_music.c | 127 ++++++++++++++++++----------- quantum/process_keycode/process_music.h | 9 ++ quantum/quantum_keycodes.h | 3 + 10 files changed, 164 insertions(+), 77 deletions(-) diff --git a/keyboards/planck/keymaps/default/config.h b/keyboards/planck/keymaps/default/config.h index 1ce547b949..b406e2fed9 100644 --- a/keyboards/planck/keymaps/default/config.h +++ b/keyboards/planck/keymaps/default/config.h @@ -3,6 +3,18 @@ #include "../../config.h" +#ifdef AUDIO_ENABLE + #define STARTUP_SONG SONG(PLANCK_SOUND) + // #define STARTUP_SONG SONG(NO_SOUND) + + #define DEFAULT_LAYER_SONGS { SONG(QWERTY_SOUND), \ + SONG(COLEMAK_SOUND), \ + SONG(DVORAK_SOUND) \ + } +#endif + +#define MUSIC_MASK (keycode != KC_NO) + /* * MIDI options */ @@ -13,18 +25,9 @@ /* enable basic MIDI features: - MIDI notes can be sent when in Music mode is on */ + #define MIDI_BASIC -#ifdef AUDIO_ENABLE - #define STARTUP_SONG SONG(PLANCK_SOUND) - // #define STARTUP_SONG SONG(NO_SOUND) - - #define DEFAULT_LAYER_SONGS { SONG(QWERTY_SOUND), \ - SONG(COLEMAK_SOUND), \ - SONG(DVORAK_SOUND) \ - } -#endif - /* enable advanced MIDI features: - MIDI notes can be added to the keymap - Octave shift and transpose diff --git a/keyboards/planck/keymaps/default/keymap.c b/keyboards/planck/keymaps/default/keymap.c index 34a011b0c9..f71a2b59b9 100644 --- a/keyboards/planck/keymaps/default/keymap.c +++ b/keyboards/planck/keymaps/default/keymap.c @@ -164,7 +164,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { */ [_ADJUST] = { {_______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL }, - {_______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, PLOVER, _______}, + {_______, _______, MU_MOD, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, PLOVER, _______}, {_______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, _______, _______, _______, _______, _______}, {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______} } diff --git a/keyboards/preonic/keymaps/default/config.h b/keyboards/preonic/keymaps/default/config.h index 1ce547b949..003fd259c5 100644 --- a/keyboards/preonic/keymaps/default/config.h +++ b/keyboards/preonic/keymaps/default/config.h @@ -3,6 +3,18 @@ #include "../../config.h" +#ifdef AUDIO_ENABLE + #define STARTUP_SONG SONG(PLANCK_SOUND) + // #define STARTUP_SONG SONG(NO_SOUND) + + #define DEFAULT_LAYER_SONGS { SONG(QWERTY_SOUND), \ + SONG(COLEMAK_SOUND), \ + SONG(DVORAK_SOUND) \ + } +#endif + +#define MUSIC_MASK (keycode != KC_NO) + /* * MIDI options */ @@ -13,17 +25,8 @@ /* enable basic MIDI features: - MIDI notes can be sent when in Music mode is on */ -#define MIDI_BASIC - -#ifdef AUDIO_ENABLE - #define STARTUP_SONG SONG(PLANCK_SOUND) - // #define STARTUP_SONG SONG(NO_SOUND) - #define DEFAULT_LAYER_SONGS { SONG(QWERTY_SOUND), \ - SONG(COLEMAK_SOUND), \ - SONG(DVORAK_SOUND) \ - } -#endif +#define MIDI_BASIC /* enable advanced MIDI features: - MIDI notes can be added to the keymap diff --git a/keyboards/preonic/keymaps/default/keymap.c b/keyboards/preonic/keymaps/default/keymap.c index 491f4ae850..01f40542ca 100644 --- a/keyboards/preonic/keymaps/default/keymap.c +++ b/keyboards/preonic/keymaps/default/keymap.c @@ -158,7 +158,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_ADJUST] = { {KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12}, {_______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL}, - {_______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______}, + {_______, _______, MU_MOD, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______}, {_______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, _______, _______, _______, _______, _______}, {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______} } diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h index e29770e3b8..79e0da2295 100644 --- a/quantum/audio/audio.h +++ b/quantum/audio/audio.h @@ -100,8 +100,8 @@ void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat); #define NOTE_ARRAY_SIZE(x) ((int16_t)(sizeof(x) / (sizeof(x[0])))) #define PLAY_NOTE_ARRAY(note_array, note_repeat, deprecated_arg) play_notes(¬e_array, NOTE_ARRAY_SIZE((note_array)), (note_repeat)); \ _Pragma ("message \"'PLAY_NOTE_ARRAY' macro is deprecated\"") -#define PLAY_SONG(note_array) play_notes(¬e_array, NOTE_ARRAY_SIZE((note_array)), false); -#define PLAY_LOOP(note_array) play_notes(¬e_array, NOTE_ARRAY_SIZE((note_array)), true); +#define PLAY_SONG(note_array) play_notes(¬e_array, NOTE_ARRAY_SIZE((note_array)), false) +#define PLAY_LOOP(note_array) play_notes(¬e_array, NOTE_ARRAY_SIZE((note_array)), true) bool is_playing_notes(void); diff --git a/quantum/audio/song_list.h b/quantum/audio/song_list.h index 6960bee6da..f355d371bd 100644 --- a/quantum/audio/song_list.h +++ b/quantum/audio/song_list.h @@ -139,6 +139,38 @@ E__NOTE(_B5), \ E__NOTE(_A5 ), +#define VOICE_CHANGE_SOUND \ + Q__NOTE(_A5 ), \ + Q__NOTE(_CS6), \ + Q__NOTE(_E6 ), \ + Q__NOTE(_A6 ), + +#define CHROMATIC_SOUND \ + Q__NOTE(_A5 ), \ + Q__NOTE(_AS5 ), \ + Q__NOTE(_B5), \ + Q__NOTE(_C6 ), \ + Q__NOTE(_CS6 ), + +#define MAJOR_SOUND \ + Q__NOTE(_A5 ), \ + Q__NOTE(_B5 ), \ + Q__NOTE(_CS6), \ + Q__NOTE(_D6 ), \ + Q__NOTE(_E6 ), + +#define GUITAR_SOUND \ + Q__NOTE(_E5 ), \ + Q__NOTE(_A5), \ + Q__NOTE(_D6 ), \ + Q__NOTE(_G6 ), + +#define VIOLIN_SOUND \ + Q__NOTE(_G5 ), \ + Q__NOTE(_D6), \ + Q__NOTE(_A6 ), \ + Q__NOTE(_E7 ), + #define CAPS_LOCK_ON_SOUND \ E__NOTE(_A3), \ E__NOTE(_B3), diff --git a/quantum/process_keycode/process_audio.c b/quantum/process_keycode/process_audio.c index 0b6380ed39..eb74796fa7 100644 --- a/quantum/process_keycode/process_audio.c +++ b/quantum/process_keycode/process_audio.c @@ -1,6 +1,11 @@ #include "audio.h" #include "process_audio.h" +#ifndef VOICE_CHANGE_SONG + #define VOICE_CHANGE_SONG SONG(VOICE_CHANGE_SOUND) +#endif +float voice_change_song[][2] = VOICE_CHANGE_SONG; + static float compute_freq_for_midi_note(uint8_t note) { // https://en.wikipedia.org/wiki/MIDI_tuning_standard @@ -20,12 +25,9 @@ bool process_audio(uint16_t keycode, keyrecord_t *record) { } if (keycode == AU_TOG && record->event.pressed) { - if (is_audio_on()) - { + if (is_audio_on()) { audio_off(); - } - else - { + } else { audio_on(); } return false; @@ -33,13 +35,13 @@ bool process_audio(uint16_t keycode, keyrecord_t *record) { if (keycode == MUV_IN && record->event.pressed) { voice_iterate(); - music_scale_user(); + PLAY_SONG(voice_change_song); return false; } if (keycode == MUV_DE && record->event.pressed) { voice_deiterate(); - music_scale_user(); + PLAY_SONG(voice_change_song); return false; } diff --git a/quantum/process_keycode/process_music.c b/quantum/process_keycode/process_music.c index ec2287df1b..63841d1e87 100644 --- a/quantum/process_keycode/process_music.c +++ b/quantum/process_keycode/process_music.c @@ -27,6 +27,7 @@ bool music_activated = false; uint8_t music_starting_note = 0x0C; int music_offset = 7; +uint8_t music_mode = MUSIC_MODE_CHROMATIC; // music sequencer static bool music_sequence_recording = false; @@ -46,10 +47,32 @@ static uint16_t music_sequence_interval = 100; #ifndef MUSIC_OFF_SONG #define MUSIC_OFF_SONG SONG(MUSIC_OFF_SOUND) #endif + #ifndef CHROMATIC_SONG + #define CHROMATIC_SONG SONG(CHROMATIC_SOUND) + #endif + #ifndef GUITAR_SONG + #define GUITAR_SONG SONG(GUITAR_SOUND) + #endif + #ifndef VIOLIN_SONG + #define VIOLIN_SONG SONG(VIOLIN_SOUND) + #endif + #ifndef MAJOR_SONG + #define MAJOR_SONG SONG(MAJOR_SOUND) + #endif + float music_mode_songs[NUMBER_OF_MODES][5][2] = { + CHROMATIC_SONG, + GUITAR_SONG, + VIOLIN_SONG, + MAJOR_SONG + }; float music_on_song[][2] = MUSIC_ON_SONG; float music_off_song[][2] = MUSIC_OFF_SONG; #endif +#ifndef MUSIC_MASK + #define MUSIC_MASK keycode < 0xFF +#endif + static void music_noteon(uint8_t note) { #ifdef AUDIO_ENABLE process_audio_noteon(note); @@ -98,59 +121,63 @@ bool process_music(uint16_t keycode, keyrecord_t *record) { return false; } - if (music_activated) { + if (keycode == MU_MOD && record->event.pressed) { + music_mode_cycle(); + return false; + } - if (keycode == KC_LCTL && record->event.pressed) { // Start recording - music_all_notes_off(); - music_sequence_recording = true; - music_sequence_recorded = false; - music_sequence_playing = false; - music_sequence_count = 0; - return false; - } + if (music_activated) { + if (record->event.pressed) { + if (keycode == KC_LCTL) { // Start recording + music_all_notes_off(); + music_sequence_recording = true; + music_sequence_recorded = false; + music_sequence_playing = false; + music_sequence_count = 0; + return false; + } - if (keycode == KC_LALT && record->event.pressed) { // Stop recording/playing - music_all_notes_off(); - if (music_sequence_recording) { // was recording - music_sequence_recorded = true; + if (keycode == KC_LALT) { // Stop recording/playing + music_all_notes_off(); + if (music_sequence_recording) { // was recording + music_sequence_recorded = true; + } + music_sequence_recording = false; + music_sequence_playing = false; + return false; } - music_sequence_recording = false; - music_sequence_playing = false; - return false; - } - if (keycode == KC_LGUI && record->event.pressed && music_sequence_recorded) { // Start playing - music_all_notes_off(); - music_sequence_recording = false; - music_sequence_playing = true; - music_sequence_position = 0; - music_sequence_timer = 0; - return false; - } + if (keycode == KC_LGUI && music_sequence_recorded) { // Start playing + music_all_notes_off(); + music_sequence_recording = false; + music_sequence_playing = true; + music_sequence_position = 0; + music_sequence_timer = 0; + return false; + } - if (keycode == KC_UP) { - if (record->event.pressed) - music_sequence_interval-=10; - return false; - } + if (keycode == KC_UP) { + music_sequence_interval-=10; + return false; + } - if (keycode == KC_DOWN) { - if (record->event.pressed) - music_sequence_interval+=10; - return false; + if (keycode == KC_DOWN) { + music_sequence_interval+=10; + return false; + } } - #define MUSIC_MODE_GUITAR - - #ifdef MUSIC_MODE_CHROMATIC - uint8_t note = (music_starting_note + record->event.key.col + music_offset - 3)+12*(MATRIX_ROWS - record->event.key.row); - #elif defined(MUSIC_MODE_GUITAR) - uint8_t note = (music_starting_note + record->event.key.col + music_offset + 32)+5*(MATRIX_ROWS - record->event.key.row); - #elif defined(MUSIC_MODE_VIOLIN) - uint8_t note = (music_starting_note + record->event.key.col + music_offset + 32)+7*(MATRIX_ROWS - record->event.key.row); - #else - uint8_t note = (music_starting_note + SCALE[record->event.key.col + music_offset] - 3)+12*(MATRIX_ROWS - record->event.key.row); - #endif + uint8_t note; + if (music_mode == MUSIC_MODE_CHROMATIC) + note = (music_starting_note + record->event.key.col + music_offset - 3)+12*(MATRIX_ROWS - record->event.key.row); + else if (music_mode == MUSIC_MODE_GUITAR) + note = (music_starting_note + record->event.key.col + music_offset + 32)+5*(MATRIX_ROWS - record->event.key.row); + else if (music_mode == MUSIC_MODE_VIOLIN) + note = (music_starting_note + record->event.key.col + music_offset + 32)+7*(MATRIX_ROWS - record->event.key.row); + else if (music_mode == MUSIC_MODE_MAJOR) + note = (music_starting_note + SCALE[record->event.key.col + music_offset] - 3)+12*(MATRIX_ROWS - record->event.key.row); + else + note = music_starting_note; if (record->event.pressed) { music_noteon(note); @@ -162,7 +189,7 @@ bool process_music(uint16_t keycode, keyrecord_t *record) { music_noteoff(note); } - if (keycode < 0xFF) // ignores all normal keycodes, but lets RAISE, LOWER, etc through + if (MUSIC_MASK) return false; } @@ -197,6 +224,14 @@ void music_off(void) { #endif } +void music_mode_cycle(void) { + music_all_notes_off(); + music_mode = (music_mode + 1) % NUMBER_OF_MODES; + #ifdef AUDIO_ENABLE + PLAY_SONG(music_mode_songs[music_mode]); + #endif +} + void matrix_scan_music(void) { if (music_sequence_playing) { if ((music_sequence_timer == 0) || (timer_elapsed(music_sequence_timer) > music_sequence_interval)) { diff --git a/quantum/process_keycode/process_music.h b/quantum/process_keycode/process_music.h index 8dfbf041f4..ee027197c2 100644 --- a/quantum/process_keycode/process_music.h +++ b/quantum/process_keycode/process_music.h @@ -21,6 +21,14 @@ #if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC)) +enum music_modes { + MUSIC_MODE_CHROMATIC, + MUSIC_MODE_GUITAR, + MUSIC_MODE_VIOLIN, + MUSIC_MODE_MAJOR, + NUMBER_OF_MODES +}; + bool process_music(uint16_t keycode, keyrecord_t *record); bool is_music_on(void); @@ -31,6 +39,7 @@ void music_off(void); void music_on_user(void); void music_scale_user(void); void music_all_notes_off(void); +void music_mode_cycle(void); void matrix_scan_music(void); diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index c863b887af..06ab6d18db 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -132,6 +132,9 @@ enum quantum_keycodes { MU_OFF, MU_TOG, + // Music mode cycle + MU_MOD, + // Music voice iterate MUV_IN, MUV_DE, -- cgit v1.2.3 From 6bdf7482b151446c8b4e442de6fadb1395dc4dae Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Sat, 22 Jul 2017 17:12:02 -0400 Subject: update audio/music documentation --- docs/modding_your_keyboard.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/modding_your_keyboard.md b/docs/modding_your_keyboard.md index ab40bdf93c..5613bf5253 100644 --- a/docs/modding_your_keyboard.md +++ b/docs/modding_your_keyboard.md @@ -12,6 +12,10 @@ AG_NORM_SONG // plays when you press AG_NORM (quantum.c) AG_SWAP_SONG // plays when you press AG_SWAP (quantum.c) MUSIC_ON_SONG // plays when music mode is activated (process_music.c) MUSIC_OFF_SONG // plays when music mode is deactivated (process_music.c) +CHROMATIC_SONG // plays when the chromatic music mode is selected (process_music.c) +GUITAR_SONG // plays when the guitar music mode is selected (process_music.c) +VIOLIN_SONG // plays when the violin music mode is selected (process_music.c) +MAJOR_SONG // plays when the major music mode is selected (process_music.c) ``` You can override the default songs by doing something like this in your `config.h`: @@ -55,6 +59,11 @@ Keycodes available: * `MU_ON` - Turn music mode on * `MU_OFF` - Turn music mode off * `MU_TOG` - Toggle music mode +* `MU_MOD` - Cycle through the music modes: + * `CHROMATIC_MODE` - Chromatic scale, row changes the octave + * `GUITAR_MODE` - Chromatic scale, but the row changes the string (+5 st) + * `VIOLIN_MODE` - Chromatic scale, but the row changes the string (+7 st) + * `MAJOR_MODE` - Major scale In music mode, the following keycodes work differently, and don't pass through: @@ -64,6 +73,12 @@ In music mode, the following keycodes work differently, and don't pass through: * `KC_UP` - speed-up playback * `KC_DOWN` - slow-down playback +By default, `MUSIC_MASK` is set to `keycode < 0xFF` which means keycodes less than `0xFF` are turned into notes, and don't output anything. You can change this by defining this in your `config.h` like this: + + #define MUSIC_MASK keycode != KC_NO + +Which will capture all keycodes - be careful, this will get you stuck in music mode until you restart your keyboard! + ## MIDI functionalty This is still a WIP, but check out `quantum/keymap_midi.c` to see what's happening. Enable from the Makefile. -- cgit v1.2.3 From a543ad4c1d2c9782b779d63e3eef8d39370441af Mon Sep 17 00:00:00 2001 From: Joe Wasson Date: Sun, 23 Jul 2017 12:09:24 -0700 Subject: Fix minor formatting issue. --- docs/custom_quantum_functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/custom_quantum_functions.md b/docs/custom_quantum_functions.md index c017c0cdb3..10a718431c 100644 --- a/docs/custom_quantum_functions.md +++ b/docs/custom_quantum_functions.md @@ -36,7 +36,7 @@ enum my_keycodes { ## Programming The Behavior Of Any Keycode -When you want to override the behavior of an existing key, or define the behavior for a new key, you should use the `process_record_kb()' and `process_record_user()` functions. These are called by QMK during key processing before the actual key event is handled. If these functions return `true` QMK will process the keycodes as usual. That can be handy for extending the functionality of a key rather than replacing it. If these functions return `false` QMK will skip the normal key handling, and it will be up you to send any key up or down events that are required. +When you want to override the behavior of an existing key, or define the behavior for a new key, you should use the `process_record_kb()` and `process_record_user()` functions. These are called by QMK during key processing before the actual key event is handled. If these functions return `true` QMK will process the keycodes as usual. That can be handy for extending the functionality of a key rather than replacing it. If these functions return `false` QMK will skip the normal key handling, and it will be up you to send any key up or down events that are required. These function are called every time a key is pressed or released. -- cgit v1.2.3 From cefc09ae7dd88cd6b92412881888404da1abdfcb Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Mon, 24 Jul 2017 12:44:03 -0400 Subject: adds option for alt pitch standards --- docs/modding_your_keyboard.md | 4 ++++ quantum/process_keycode/process_audio.c | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/modding_your_keyboard.md b/docs/modding_your_keyboard.md index 5613bf5253..a58fbd52b2 100644 --- a/docs/modding_your_keyboard.md +++ b/docs/modding_your_keyboard.md @@ -79,6 +79,10 @@ By default, `MUSIC_MASK` is set to `keycode < 0xFF` which means keycodes less th Which will capture all keycodes - be careful, this will get you stuck in music mode until you restart your keyboard! +The pitch standard (`PITCH_STANDARD_A`) is 440.0f by default - to change this, add something like this to your `config.h`: + + #define PITCH_STANDARD_A 432.0f + ## MIDI functionalty This is still a WIP, but check out `quantum/keymap_midi.c` to see what's happening. Enable from the Makefile. diff --git a/quantum/process_keycode/process_audio.c b/quantum/process_keycode/process_audio.c index eb74796fa7..32057ae8dc 100644 --- a/quantum/process_keycode/process_audio.c +++ b/quantum/process_keycode/process_audio.c @@ -6,10 +6,14 @@ #endif float voice_change_song[][2] = VOICE_CHANGE_SONG; +#ifndef PITCH_STANDARD_A + #define PITCH_STANDARD_A 440.0f +#endif + static float compute_freq_for_midi_note(uint8_t note) { // https://en.wikipedia.org/wiki/MIDI_tuning_standard - return pow(2.0, (note - 69) / 12.0) * 440.0f; + return pow(2.0, (note - 69) / 12.0) * PITCH_STANDARD_A; } bool process_audio(uint16_t keycode, keyrecord_t *record) { -- cgit v1.2.3