aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--keyboard/ergodox_ez/keymaps/keymap_generated.c78
-rw-r--r--keyboard/ergodox_ez/keymaps/keymap_jack.c69
-rw-r--r--keyboard/planck/Makefile4
-rw-r--r--keyboard/planck/keymaps/keymap_eric.c42
-rw-r--r--keyboard/planck/keymaps/keymap_lock.c10
-rw-r--r--keyboard/planck/planck.c29
-rw-r--r--keyboard/planck/planck.h5
-rw-r--r--quantum/beeps.c231
-rw-r--r--quantum/beeps.h2
-rw-r--r--quantum/keymap_midi.c21
-rw-r--r--quantum/keymap_midi.h2
-rw-r--r--quantum/wave.h265
-rw-r--r--tmk_core/common/avr/timer.c18
13 files changed, 593 insertions, 183 deletions
diff --git a/keyboard/ergodox_ez/keymaps/keymap_generated.c b/keyboard/ergodox_ez/keymaps/keymap_generated.c
new file mode 100644
index 000000000..54fd3059f
--- /dev/null
+++ b/keyboard/ergodox_ez/keymaps/keymap_generated.c
@@ -0,0 +1,78 @@
1#include "ergodox_ez.h"
2#include "debug.h"
3#include "action_layer.h"
4
5const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
6
7// If it accepts an argument (i.e, is a function), it doesn't need KC_.
8// Otherwise, it needs KC_*
9
10#define SYMB 0
11
12[0] = KEYMAP( \
13\
14KC_KP_EQUAL, KC_1, KC_2, KC_3, KC_4, KC_5, KC_LEFT, KC_DELETE, KC_Q, KC_W, KC_E, KC_R, KC_T, TG(1), KC_BSPACE, KC_A, KC_S, KC_D, KC_F, KC_G, KC_LSHIFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TAB, KC_LEFT, KC_RIGHT, KC_TRANSPARENT, KC_LGUI, KC_HOME, KC_SPACE, KC_BSPACE, KC_END, KC_RIGHT, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINUS, TG(1), KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLASH, KC_H, KC_J, KC_K, KC_L, KC_SCOLON, KC_QUOTE, KC_TRANSPARENT, KC_N, KC_M, KC_COMMA, KC_DOT, KC_LCTRL, KC_LSHIFT, KC_UP, KC_DOWN, KC_LBRACKET, KC_RBRACKET, KC_TRANSPARENT, KC_LALT, KC_ESCAPE, KC_PGUP, KC_PGDOWN, KC_TAB, KC_ENTER \
15\
16),
17
18[1] = KEYMAP( \
19\
20KC_TRANSPARENT, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_TRANSPARENT, KC_UP, KC_KP_7, KC_KP_8, KC_KP_9, KC_KP_ASTERISK, KC_F12, KC_DOWN, KC_KP_4, KC_KP_5, KC_KP_6, KC_KP_PLUS, KC_TRANSPARENT, KC_TRANSPARENT, , KC_KP_1, KC_KP_2, KC_KP_3, KC_KP_SLASH, KC_TRANSPARENT, KC_TRANSPARENT, KC_KP_DOT, KC_KP_0, KC_KP_EQUAL, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT \
21\
22),
23
24[2] = KEYMAP( \
25\
26KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_MS_UP, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_MS_LEFT, KC_MS_DOWN, KC_MS_RIGHT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_MS_BTN3, KC_MS_BTN2, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_MEDIA_PLAY_PAUSE, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_MEDIA_PREV_TRACK, KC_MEDIA_NEXT_TRACK, KC_TRANSPARENT, KC_TRANSPARENT, KC_AUDIO_VOL_UP, KC_AUDIO_VOL_DOWN, KC_AUDIO_MUTE, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT \
27\
28),
29
30};
31
32const uint16_t PROGMEM fn_actions[] = {
33 [1] = ACTION_LAYER_TAP_TOGGLE(SYMB) // FN1 - Momentary Layer 1 (Symbols)
34};
35
36const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
37{
38 // MACRODOWN only works in this function
39 switch(id) {
40 case 0:
41 if (record->event.pressed) {
42 register_code(KC_RSFT);
43 } else {
44 unregister_code(KC_RSFT);
45 }
46 break;
47 }
48 return MACRO_NONE;
49};
50
51// Runs just one time when the keyboard initializes.
52void * matrix_init_user(void) {
53
54};
55
56// Runs constantly in the background, in a loop.
57void * matrix_scan_user(void) {
58
59 uint8_t layer = biton32(layer_state);
60
61 ergodox_board_led_off();
62 ergodox_right_led_1_off();
63 ergodox_right_led_2_off();
64 ergodox_right_led_3_off();
65 switch (layer) {
66 // TODO: Make this relevant to the ErgoDox EZ.
67 case 1:
68 ergodox_right_led_1_on();
69 break;
70 case 2:
71 ergodox_right_led_2_on();
72 break;
73 default:
74 // none
75 break;
76 }
77
78};
diff --git a/keyboard/ergodox_ez/keymaps/keymap_jack.c b/keyboard/ergodox_ez/keymaps/keymap_jack.c
index 2677a3d8f..f8f73a1af 100644
--- a/keyboard/ergodox_ez/keymaps/keymap_jack.c
+++ b/keyboard/ergodox_ez/keymaps/keymap_jack.c
@@ -8,29 +8,6 @@
8#define MDIA 2 // media keys 8#define MDIA 2 // media keys
9 9
10const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 10const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
11/* Keymap 0: Basic layer
12 *
13 * ,--------------------------------------------------. ,--------------------------------------------------.
14 * | = | 1 | 2 | 3 | 4 | 5 | LEFT | | RIGHT| 6 | 7 | 8 | 9 | 0 | - |
15 * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
16 * | Del | Q | W | E | R | T | L1 | | L1 | Y | U | I | O | P | \ |
17 * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
18 * | BkSp | A | S | D | F | G |------| |------| H | J | K | L |; / L2| ' |
19 * |--------+------+------+------+------+------| Hyper| | Meh |------+------+------+------+------+--------|
20 * | LShift |Z/Ctrl| X | C | V | B | | | | N | M | , | . |//Ctrl| RShift |
21 * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
22 * |Grv/L1| '" |AltShf| Left | Right| | Up | Down | [ | ] | ~L1 |
23 * `----------------------------------' `----------------------------------'
24 * ,-------------. ,-------------.
25 * | App | LGui | | Alt |Ctrl/Esc|
26 * ,------|------|------| |------+--------+------.
27 * | | | Home | | PgUp | | |
28 * | Space|Backsp|------| |------| Tab |Enter |
29 * | |ace | End | | PgDn | | |
30 * `--------------------' `----------------------'
31 */
32// If it accepts an argument (i.e, is a function), it doesn't need KC_.
33// Otherwise, it needs KC_*
34[BASE] = KEYMAP( // layer 0 : default 11[BASE] = KEYMAP( // layer 0 : default
35 // left hand 12 // left hand
36 KC_NO, KC_1, KC_2, KC_3, KC_4, KC_5, KC_NO, 13 KC_NO, KC_1, KC_2, KC_3, KC_4, KC_5, KC_NO,
@@ -51,28 +28,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
51 KC_PGUP, 28 KC_PGUP,
52 KC_PGDN, KC_SPC,KC_SPC 29 KC_PGDN, KC_SPC,KC_SPC
53 ), 30 ),
54/* Keymap 1: Symbol Layer
55 *
56 * ,--------------------------------------------------. ,--------------------------------------------------.
57 * | | F1 | F2 | F3 | F4 | F5 | | | | F6 | F7 | F8 | F9 | F10 | F11 |
58 * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
59 * | | ! | @ | { | } | | | | | | Up | 7 | 8 | 9 | * | F12 |
60 * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
61 * | | # | $ | ( | ) | ` |------| |------| Down | 4 | 5 | 6 | + | |
62 * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
63 * | | % | ^ | [ | ] | ~ | | | | & | 1 | 2 | 3 | \ | |
64 * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
65 * | | | | | | | | . | 0 | = | |
66 * `----------------------------------' `----------------------------------'
67 * ,-------------. ,-------------.
68 * | | | | | |
69 * ,------|------|------| |------+------+------.
70 * | | | | | | | |
71 * | | |------| |------| | |
72 * | | | | | | | |
73 * `--------------------' `--------------------'
74 */
75// SYMBOLS
76[SYMB] = KEYMAP( 31[SYMB] = KEYMAP(
77 // left hand 32 // left hand
78 KC_TRNS,KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_TRNS, 33 KC_TRNS,KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_TRNS,
@@ -93,29 +48,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
93 KC_TRNS, 48 KC_TRNS,
94 KC_TRNS, KC_TRNS, KC_TRNS 49 KC_TRNS, KC_TRNS, KC_TRNS
95), 50),
96/* Keymap 2: Media and mouse keys 51[MDIA] = KEYMAP(
97 *
98 * ,--------------------------------------------------. ,--------------------------------------------------.
99 * | | | | | | | | | | | | | | | |
100 * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
101 * | | | | MsUp | | | | | | | | | | | |
102 * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
103 * | | |MsLeft|MsDown|MsRght| |------| |------| | | | | | Play |
104 * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
105 * | | | | | | | | | | | | Prev | Next | | |
106 * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
107 * | | | | Lclk | Rclk | |VolUp |VolDn | Mute | | |
108 * `----------------------------------' `----------------------------------'
109 * ,-------------. ,-------------.
110 * | | | | | |
111 * ,------|------|------| |------+------+------.
112 * | | | | | | |Brwser|
113 * | | |------| |------| |Back |
114 * | | | | | | | |
115 * `--------------------' `--------------------'
116 */
117// MEDIA AND MOUSE
118KEYMAP(
119 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, 52 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
120 KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_TRNS, 53 KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_TRNS,
121 KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, 54 KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5,
diff --git a/keyboard/planck/Makefile b/keyboard/planck/Makefile
index 485c5f77f..fdf8c1640 100644
--- a/keyboard/planck/Makefile
+++ b/keyboard/planck/Makefile
@@ -122,8 +122,8 @@ COMMAND_ENABLE = yes # Commands for debug and configuration
122# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE 122# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
123# SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend 123# SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
124# NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work 124# NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
125BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality 125# BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
126# MIDI_ENABLE = YES # MIDI controls 126MIDI_ENABLE = YES # MIDI controls
127# UNICODE_ENABLE = YES # Unicode 127# UNICODE_ENABLE = YES # Unicode
128# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID 128# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID
129 129
diff --git a/keyboard/planck/keymaps/keymap_eric.c b/keyboard/planck/keymaps/keymap_eric.c
new file mode 100644
index 000000000..ffeec5f80
--- /dev/null
+++ b/keyboard/planck/keymaps/keymap_eric.c
@@ -0,0 +1,42 @@
1#include "planck.h"
2
3const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
4 [0] = {
5 {KC_BSLS, S(KC_SLSH), KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_SLSH},
6 {TG(1), KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_MINS},
7 {KC_LGUI, KC_QUOT, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_RGUI},
8 {KC_LCBR, KC_LCTL, KC_LALT, LT(1, TG(2)), KC_SPC, KC_TAB, KC_ENT, KC_BSPC, LT(1, TG(3)), KC_RALT, KC_RCTL, KC_RCBR}
9 },
10
11 [1] = {
12 {KC_PIPE, KC_COLN, KC_LBRC, KC_RBRC, S(KC_P), S(KC_Y), S(KC_F), S(KC_G), S(KC_C), S(KC_R), S(KC_L), KC_AMPR},
13 {KC_TRNS, S(KC_A), S(KC_O), S(KC_E), S(KC_U), S(KC_I), S(KC_D), S(KC_H), S(KC_T), S(KC_N), S(KC_S), KC_GRV},
14 {KC_TRNS, KC_SCLN, S(KC_Q), S(KC_J), S(KC_K), S(KC_X), S(KC_B), S(KC_M), S(KC_W), S(KC_V), S(KC_Z), KC_TRNS},
15 {S(KC_COMM), KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, S(KC_DOT)}
16 },
17
18 [2] = {
19 {KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_NO},
20 {KC_NO, KC_F11, KC_F12, KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, KC_F18, KC_F19, KC_F20, KC_NO},
21 {KC_TRNS, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_TRNS},
22 {KC_NO, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_NO}
23 },
24
25 [3] = {
26 {KC_EXLM, KC_7, KC_5, KC_3, KC_1, KC_9, KC_0, KC_2, KC_4, KC_6, KC_8, KC_EQL},
27 {TG(4), KC_NO, KC_PGUP, KC_HOME, KC_INSERT, KC_NO, KC_NO, BL_DEC, KC_UP, BL_INC, KC_NO, KC_NO},
28 {KC_TRNS, KC_NO, KC_PGDN, KC_END, KC_DELETE, KC_NO, KC_NO, KC_LEFT, KC_DOWN, KC_RGHT, KC_NO, KC_TRNS},
29 {KC_NO, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_NO}
30 },
31
32 [4] = {
33 {KC_TILD, KC_HASH, KC_LPRN, KC_RPRN, S(KC_QUOT), KC_PERC, KC_UNDS, KC_CIRC, KC_DLR, KC_AT, KC_ASTR, KC_PLUS},
34 {KC_TRNS, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO},
35 {KC_TRNS, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_TRNS},
36 {KC_NO, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_NO}
37 }
38};
39
40const uint16_t PROGMEM fn_actions[] = {
41
42}; \ No newline at end of file
diff --git a/keyboard/planck/keymaps/keymap_lock.c b/keyboard/planck/keymaps/keymap_lock.c
index cc9be55f6..c2bf0b7d8 100644
--- a/keyboard/planck/keymaps/keymap_lock.c
+++ b/keyboard/planck/keymaps/keymap_lock.c
@@ -1,5 +1,5 @@
1#include "keymap_common.h" 1#include "keymap_common.h"
2#include "backlight.h" 2// #include "backlight.h"
3#include "action_layer.h" 3#include "action_layer.h"
4#include "keymap_midi.h" 4#include "keymap_midi.h"
5#include <avr/boot.h> 5#include <avr/boot.h>
@@ -71,7 +71,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
71 if (record->event.pressed) { 71 if (record->event.pressed) {
72 // play_note(440, 20); 72 // play_note(440, 20);
73 // register_code(KC_RSFT); 73 // register_code(KC_RSFT);
74 backlight_set(BACKLIGHT_LEVELS); 74 // backlight_set(BACKLIGHT_LEVELS);
75 default_layer_and(0); 75 default_layer_and(0);
76 default_layer_or((1<<5)); 76 default_layer_or((1<<5));
77 77
@@ -106,9 +106,9 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
106 // note(0+12, 20); 106 // note(0+12, 20);
107 // note(0+24, 20); 107 // note(0+24, 20);
108 } else { 108 } else {
109 // unregister_code(KC_RSFT); 109 unregister_code(KC_RSFT);
110 // stop_note(); 110 // stop_all_notes();
111 backlight_set(0); 111 // backlight_set(0);
112 default_layer_and(0); 112 default_layer_and(0);
113 default_layer_or(0); 113 default_layer_or(0);
114 // note(0+24, 20); 114 // note(0+24, 20);
diff --git a/keyboard/planck/planck.c b/keyboard/planck/planck.c
index b62862af0..a986bd881 100644
--- a/keyboard/planck/planck.c
+++ b/keyboard/planck/planck.c
@@ -19,6 +19,35 @@ void * matrix_init_kb(void) {
19 DDRE |= (1<<6); 19 DDRE |= (1<<6);
20 PORTE |= (1<<6); 20 PORTE |= (1<<6);
21 21
22 init_notes();
23
24 // play_note(((double)261.6*32)*pow(2.0,(36)/12.0), 0xF);
25 // _delay_ms(50);
26
27 // play_note(((double)261.6*32)*pow(2.0,(48)/12.0), 0xF);
28 // _delay_ms(25);
29 // stop_note(((double)261.6*32)*pow(2.0,(48)/12.0));
30
31 // play_note(((double)261.6*32)*pow(2.0,(48)/12.0), 0xF);
32 // _delay_ms(25);
33 // stop_note(((double)261.6*32)*pow(2.0,(48)/12.0));
34
35
36 // stop_note(((double)261.6*32)*pow(2.0,(36)/12.0));
37
38
39 // play_note(((double)261.6*32)*pow(2.0,(62)/12.0), 0xF);
40 // _delay_ms(50);
41 // stop_note(((double)261.6*32)*pow(2.0,(62)/12.0));
42
43
44 // play_note(((double)261.6*32)*pow(2.0,(64)/12.0), 0xF);
45 // _delay_ms(50);
46 // stop_note(((double)261.6*32)*pow(2.0,(64)/12.0));
47
48
49
50
22 if (matrix_init_user) { 51 if (matrix_init_user) {
23 (*matrix_init_user)(); 52 (*matrix_init_user)();
24 } 53 }
diff --git a/keyboard/planck/planck.h b/keyboard/planck/planck.h
index 4e59aef56..32c08f3b0 100644
--- a/keyboard/planck/planck.h
+++ b/keyboard/planck/planck.h
@@ -3,8 +3,11 @@
3 3
4#include "matrix.h" 4#include "matrix.h"
5#include "keymap_common.h" 5#include "keymap_common.h"
6#include "backlight.h" 6// #include "backlight.h"
7#include <stddef.h> 7#include <stddef.h>
8#ifdef MIDI_ENABLE
9 #include <keymap_midi.h>
10#endif
8 11
9#define PLANCK_MIT( \ 12#define PLANCK_MIT( \
10 k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, \ 13 k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, \
diff --git a/quantum/beeps.c b/quantum/beeps.c
index 8d1f81f21..edcc84aca 100644
--- a/quantum/beeps.c
+++ b/quantum/beeps.c
@@ -1,11 +1,20 @@
1#include "beeps.h" 1#include <stdio.h>
2#include <string.h>
2#include <math.h> 3#include <math.h>
3#include <avr/pgmspace.h> 4#include <avr/pgmspace.h>
4#include <avr/interrupt.h> 5#include <avr/interrupt.h>
5#include <avr/io.h> 6#include <avr/io.h>
6 7
8#include "beeps.h"
9#include "keymap_common.h"
10#include "wave.h"
11
7#define PI 3.14159265 12#define PI 3.14159265
8 13
14#define SAMPLE_DIVIDER 70
15#define SAMPLE_RATE (2000000.0/SAMPLE_DIVIDER/256)
16// Resistor value of 1/ (2 * PI * 10nF * (2000000 hertz / SAMPLE_DIVIDER / 10)) for 10nF cap
17
9void delay_us(int count) { 18void delay_us(int count) {
10 while(count--) { 19 while(count--) {
11 _delay_us(1); 20 _delay_us(1);
@@ -15,7 +24,7 @@ void delay_us(int count) {
15int voices = 0; 24int voices = 0;
16double frequency = 0; 25double frequency = 0;
17int volume = 0; 26int volume = 0;
18int position = 0; 27long position = 0;
19 28
20double frequencies[8] = {0, 0, 0, 0, 0, 0, 0, 0}; 29double frequencies[8] = {0, 0, 0, 0, 0, 0, 0, 0};
21int volumes[8] = {0, 0, 0, 0, 0, 0, 0, 0}; 30int volumes[8] = {0, 0, 0, 0, 0, 0, 0, 0};
@@ -23,6 +32,19 @@ bool sliding = false;
23#define RANGE 1000 32#define RANGE 1000
24volatile int i=0; //elements of the wave 33volatile int i=0; //elements of the wave
25 34
35// uint8_t sine[128];
36// uint8_t tri[128];
37// uint8_t squ[128];
38// uint8_t* sine_start;
39// uint8_t* sine_end;
40// uint8_t* tri_start;
41// uint8_t* tri_end;
42
43// uint8_t* s_start;
44// uint8_t* s_end;
45// uint8_t* s_ptr;
46
47
26 48
27void beeps() { 49void beeps() {
28 play_notes(); 50 play_notes();
@@ -36,8 +58,7 @@ void send_freq(double freq, int vol) {
36 58
37void stop_all_notes() { 59void stop_all_notes() {
38 voices = 0; 60 voices = 0;
39 TCCR3A = 0; 61 TIMSK0 &= ~_BV(OCIE0A);
40 TCCR3B = 0;
41 frequency = 0; 62 frequency = 0;
42 volume = 0; 63 volume = 0;
43 64
@@ -48,6 +69,7 @@ void stop_all_notes() {
48} 69}
49 70
50void stop_note(double freq) { 71void stop_note(double freq) {
72 freq = freq / SAMPLE_RATE;
51 for (int i = 7; i >= 0; i--) { 73 for (int i = 7; i >= 0; i--) {
52 if (frequencies[i] == freq) { 74 if (frequencies[i] == freq) {
53 frequencies[i] = 0; 75 frequencies[i] = 0;
@@ -64,151 +86,176 @@ void stop_note(double freq) {
64 if (voices < 0) 86 if (voices < 0)
65 voices = 0; 87 voices = 0;
66 if (voices == 0) { 88 if (voices == 0) {
67 TCCR3A = 0; 89 TIMSK0 &= ~_BV(OCIE0A);
68 TCCR3B = 0;
69 frequency = 0; 90 frequency = 0;
70 volume = 0; 91 volume = 0;
71 } else { 92 } else {
72 double freq = frequencies[voices - 1]; 93 double freq = frequencies[voices - 1];
73 int vol = volumes[voices - 1]; 94 int vol = volumes[voices - 1];
95 double starting_f = frequency;
74 if (frequency < freq) { 96 if (frequency < freq) {
75 sliding = true; 97 sliding = true;
76 for (double f = frequency; f <= freq; f += ((freq - frequency) / 500.0)) { 98 for (double f = starting_f; f <= freq; f += ((freq - starting_f) / 500.0)) {
77 send_freq(f, vol); 99 frequency = f;
78 } 100 }
79 sliding = false; 101 sliding = false;
80 } else if (frequency > freq) { 102 } else if (frequency > freq) {
81 sliding = true; 103 sliding = true;
82 for (double f = frequency; f >= freq; f -= ((frequency - freq) / 500.0)) { 104 for (double f = starting_f; f >= freq; f -= ((starting_f - freq) / 500.0)) {
83 send_freq(f, vol); 105 frequency = f;
84 } 106 }
85 sliding = false; 107 sliding = false;
86 } 108 }
87 send_freq(freq, vol); 109 // send_freq(freq, vol);
88 frequency = freq; 110 frequency = freq;
89 volume = vol; 111 volume = vol;
90 } 112 }
91} 113}
92 114
93void init_notes() { 115void init_notes() {
94 // TCCR1A = (1 << COM1A1) | (0 << COM1A0) | (1 << WGM11) | (1 << WGM10);
95 // TCCR1B = (1 << COM1B1) | (0 << COM1A0) | (1 << WGM13) | (1 << WGM12) | (0 << CS12) | (0 << CS11) | (1 << CS10);
96 116
97 // DDRC |= (1<<6); 117 // for(int i = 0; i < 128; i++) {
118 // sine[i] = sin(i * PI / 64) * 128 + 128;
119 // tri[i] = 256 - abs((i - 64) * 4);
120 // }
121 // sine_start = &sine;
122 // sine_end = &sine + 128;
123 // tri_start = &tri;
124 // tri_end = &tri + 128;
98 125
99 // TCCR3A = (1 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30); 126 // new
100 // TCCR3B = (1 << WGM33) | (1 << WGM32) | (0 << CS32) | (0 << CS31) | (1 << CS30);
101 127
102 // ICR3 = 0xFFFF;
103 // OCR3A = (int)((float)wave[i]*ICR3/RANGE); //go to next array element
104 128
129 PLLFRQ = _BV(PDIV2);
130 PLLCSR = _BV(PLLE);
131 while(!(PLLCSR & _BV(PLOCK)));
132 PLLFRQ |= _BV(PLLTM0); /* PCK 48MHz */
133
134 /* Init a fast PWM on Timer4 */
135 TCCR4A = _BV(COM4A0) | _BV(PWM4A); /* Clear OC4A on Compare Match */
136 TCCR4B = _BV(CS40); /* No prescaling => f = PCK/256 = 187500Hz */
137 OCR4A = 0;
105 138
106 // cli(); 139 /* Enable the OC4A output */
140 DDRC |= _BV(PORTC6);
107 141
108 // /* Enable interrupt on timer2 == 127, with clk/8 prescaler. At 16MHz,
109 // this gives a timer interrupt at 15625Hz. */
110 // TIMSK3 = (1 << OCIE3A);
111 142
112 // /* clear/reset timer on match */
113 // // TCCR3A = 1<<WGM31 | 0<<WGM30; CTC mode, reset on match
114 // // TCCR3B = 0<<CS32 | 1<<CS31 | 0<<CS30; /* clk, /8 prescaler */
115 143
116 // TCCR3A = (1 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30); 144 /* First disable the timer overflow interrupt while we're configuring */
117 // TCCR3B = (0 << WGM33) | (0 << WGM32) | (0 << CS32) | (0 << CS31) | (1 << CS30); 145 // TIMSK0 &= ~(1<<TOIE0);
146
147 // /* Configure timer4 in normal mode (pure counting, no PWM etc.) */
148 // TCCR0A &= ~((1<<WGM01) | (1<<WGM00));
149 // TCCR0B &= ~(1<<WGM02);
118 150
151 // /* Disable Compare Match A interrupt enable (only want overflow) */
152 // TIMSK0 &= ~(1<<OCIE0A);
153
154 // TCCR0B |= (1<<CS01); // Set bits
155 // TCCR0B &= ~(1<<CS00) | ~(1<<CS02); // Clear bit
156
157 // /* Save value globally for later reload in ISR */
158 // tcnt0 = 45 - 1;
119 159
120 // TCCR1A = (1 << COM1A1) | (0 << COM1A0) | (1 << WGM11) | (0 << WGM10); 160 // /* Finally load end enable the timer */
121 // TCCR1B = (1 << WGM12) | (0 << CS12) | (0 << CS11) | (1 << CS10); 161 // TCNT0 = tcnt0;
122 // // SPCR = 0x50; 162 // TIMSK0 |= (1<<TOIE0);
123 // // SPSR = 0x01;
124 // DDRC |= (1<<6);
125 // // ICR3 = 0xFFFF;
126 // // OCR3A=80;
127 // PORTC |= (1<<6);
128 163
129 // sei();
130} 164}
131 165
132// #define highByte(c) ((c >> 8) & 0x00FF) 166int max = 0xFF;
133// #define lowByte(c) (c & 0x00FF) 167float sum = 0;
168int value = 128;
169float place = 0;
134 170
135ISR(TIMER3_COMPA_vect) { 171ISR(TIMER0_COMPA_vect) {
136 172
137 if (ICR3 > 0 && !sliding) {
138 switch (position) {
139 case 0: {
140 int duty = (((double)F_CPU) / (frequency));
141 ICR3 = duty; // Set max to the period
142 OCR3A = duty >> 1; // Set compare to half the period
143 break;
144 }
145 case 1: {
146 int duty = (((double)F_CPU) / (frequency*2));
147 ICR3 = duty; // Set max to the period
148 OCR3A = duty >> 1; // Set compare to half the period
149 break;
150 }
151 case 2: {
152 int duty = (((double)F_CPU) / (frequency*3));
153 ICR3 = duty; // Set max to the period
154 OCR3A = duty >> 1; // Set compare to half the period
155 break;
156 }
157 }
158 position = (position + 1) % 3;
159 }
160// /* OCR2A has been cleared, per TCCR2A above */
161// // OCR3A = 127;
162 173
163// // pos1 += incr1;
164// // pos2 += incr2;
165// // pos3 += incr3;
166 174
167// // sample = sinewave[highByte(pos1)] + sinewave[highByte(pos2)] + sinewave[highByte(pos3)]; 175 // value = *(sine_start+=(long)frequencies[0]);
176 // OCR4A = value;
177 // if (sine_start >= sine_end) {
178 // sine_start = &sine[(sine_start - sine_end) % 128];
179 // }
168 180
169// // OCR3A = sample;
170 181
182 // OCR4A = pgm_read_byte(sine_start);
183 // // sine_start = &sine[(sine_start - &sine[0] + (int)frequencies[0]) % 128];
184 // sine_start += (int)frequencies[0];
185 // if (sine_start >= sine_end) {
186 // sine_start = &sine[(sine_start - sine_end) % 128];
187 // }
188
189 // OCR4A = pgm_read_byte(s_ptr);
190 // s_ptr = s_start + (uint8_t)place;
191 // OCR4A = pgm_read_byte(s_ptr);
192
193
194 // SINE
195 OCR4A = pgm_read_byte(&sinewave[(uint16_t)place]);
196
197 // SQUARE
198 // if (((int)place) >= 1024){
199 // OCR4A = 0xFF;
200 // } else {
201 // OCR4A = 0x00;
202 // }
203
204 // SAWTOOTH
205 // OCR4A = (int)place / 4;
206
207 // TRIANGLE
208 // if (((int)place) >= 1024) {
209 // OCR4A = (int)place / 2;
210 // } else {
211 // OCR4A = 2048 - (int)place / 2;
212 // }
213
214 place += frequency;
215 if (place >= SINE_LENGTH)
216 place -= SINE_LENGTH;
217
218}
171 219
172// OCR3A=pgm_read_byte(&sinewave[pos1]);
173// pos1++;
174// // PORTC &= ~(1<<6);
175 220
176// /* buffered, 1x gain, active mode */ 221ISR(TIMER0_COMPB_vect)
177// // SPDR = highByte(sample) | 0x70; 222{
178// // while (!(SPSR & (1<<SPIF)));
179 223
180// // SPDR = lowByte(sample); 224 /* Disable the interrupt */
181// // while (!(SPSR & (1<<SPIF))); 225 TIMSK0 &= ~_BV(OCIE0B);
182 226
183// // PORTC |= (1<<6);
184} 227}
185 228
186void play_note(double freq, int vol) { 229void play_note(double freq, int vol) {
187 230
231 freq = freq / SAMPLE_RATE;
188 if (freq > 0) { 232 if (freq > 0) {
189 DDRC |= (1<<6);
190 233
191 TCCR3A = (1 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30); 234 // TCCR3A = (1 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (1 << WGM30);
192 TCCR3B = (1 << WGM33) | (1 << WGM32) | (0 << CS32) | (1 << CS31) | (0 << CS30); 235 // TCCR3B = (0 << WGM33) | (1 << WGM32) | (0 << CS32) | (0 << CS31) | (1 << CS30);
193 236
237 // TIMSK3 = 0x0;
194 if (frequency != 0) { 238 if (frequency != 0) {
239 double starting_f = frequency;
195 if (frequency < freq) { 240 if (frequency < freq) {
196 for (double f = frequency; f <= freq; f += ((freq - frequency) / 500.0)) { 241 for (double f = starting_f; f <= freq; f += ((freq - starting_f) / 500.0)) {
197 send_freq(f, vol); 242 frequency = f;
198 } 243 }
199 } else if (frequency > freq) { 244 } else if (frequency > freq) {
200 for (double f = frequency; f >= freq; f -= ((frequency - freq) / 500.0)) { 245 for (double f = starting_f; f >= freq; f -= ((starting_f - freq) / 500.0)) {
201 send_freq(f, vol); 246 frequency = f;
202 } 247 }
203 } 248 }
204 } 249 }
205 send_freq(freq, vol); 250 // send_freq(freq, vol);
206 frequency = freq; 251 frequency = freq;
207 volume = vol; 252 volume = vol;
208 253
209 frequencies[voices] = frequency; 254 frequencies[voices] = frequency;
210 volumes[voices] = volume; 255 volumes[voices] = volume;
211 voices++; 256 voices++;
257 // position = 0;
258 // TCNT0 = 0;
212 } 259 }
213 // ICR3 = 0xFFFF; 260 // ICR3 = 0xFFFF;
214 // for (int i = 0; i < 10000; i++) { 261 // for (int i = 0; i < 10000; i++) {
@@ -218,6 +265,18 @@ void play_note(double freq, int vol) {
218 265
219 // TCCR3A = 0; 266 // TCCR3A = 0;
220 // TCCR3B = 0; 267 // TCCR3B = 0;
268
269
270 TIMSK0 &= ~_BV(OCIE0A) | ~_BV(OCIE0B);
271
272 TCCR0A = _BV(WGM01);
273 TCCR0B = _BV(CS01);
274 OCR0A = SAMPLE_DIVIDER - 1;
275 OCR0B = 1;
276
277 TIMSK0 |= _BV(OCIE0A);
278 // sei();
279
221} 280}
222 281
223// void note(int x, float length) { 282// void note(int x, float length) {
diff --git a/quantum/beeps.h b/quantum/beeps.h
index 378983c60..a7fcf6c23 100644
--- a/quantum/beeps.h
+++ b/quantum/beeps.h
@@ -9,4 +9,4 @@ void true_note(float x, float y, float length);
9void play_note(double freq, int vol); 9void play_note(double freq, int vol);
10void stop_note(double freq); 10void stop_note(double freq);
11void stop_all_notes(); 11void stop_all_notes();
12void init_notes(); \ No newline at end of file 12void init_notes();
diff --git a/quantum/keymap_midi.c b/quantum/keymap_midi.c
index b7eba3ab7..3a1408e22 100644
--- a/quantum/keymap_midi.c
+++ b/quantum/keymap_midi.c
@@ -17,7 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18#include "keymap_common.h" 18#include "keymap_common.h"
19#include "keymap_midi.h" 19#include "keymap_midi.h"
20#include <lufa.h>
21 20
22uint8_t starting_note = 0x0C; 21uint8_t starting_note = 0x0C;
23int offset = 7; 22int offset = 7;
@@ -35,7 +34,7 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
35 if (record->event.key.col == (MATRIX_COLS - 1) && record->event.key.row == (MATRIX_ROWS - 1)) { 34 if (record->event.key.col == (MATRIX_COLS - 1) && record->event.key.row == (MATRIX_ROWS - 1)) {
36 if (record->event.pressed) { 35 if (record->event.pressed) {
37 starting_note++; 36 starting_note++;
38 play_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[0 + offset])/12.0+(MATRIX_ROWS - 1)), 0xC); 37 play_note(((double)261.626)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[0 + offset])/12.0+(MATRIX_ROWS - 1)), 0xC);
39 midi_send_cc(&midi_device, 0, 0x7B, 0); 38 midi_send_cc(&midi_device, 0, 0x7B, 0);
40 midi_send_cc(&midi_device, 1, 0x7B, 0); 39 midi_send_cc(&midi_device, 1, 0x7B, 0);
41 midi_send_cc(&midi_device, 2, 0x7B, 0); 40 midi_send_cc(&midi_device, 2, 0x7B, 0);
@@ -43,7 +42,7 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
43 midi_send_cc(&midi_device, 4, 0x7B, 0); 42 midi_send_cc(&midi_device, 4, 0x7B, 0);
44 return; 43 return;
45 } else { 44 } else {
46 stop_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[0 + offset])/12.0+(MATRIX_ROWS - 1))); 45 stop_note(((double)261.626)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[0 + offset])/12.0+(MATRIX_ROWS - 1)));
47 stop_all_notes(); 46 stop_all_notes();
48 return; 47 return;
49 } 48 }
@@ -51,7 +50,7 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
51 if (record->event.key.col == (MATRIX_COLS - 2) && record->event.key.row == (MATRIX_ROWS - 1)) { 50 if (record->event.key.col == (MATRIX_COLS - 2) && record->event.key.row == (MATRIX_ROWS - 1)) {
52 if (record->event.pressed) { 51 if (record->event.pressed) {
53 starting_note--; 52 starting_note--;
54 play_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[0 + offset])/12.0+(MATRIX_ROWS - 1)), 0xC); 53 play_note(((double)261.626)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[0 + offset])/12.0+(MATRIX_ROWS - 1)), 0xC);
55 midi_send_cc(&midi_device, 0, 0x7B, 0); 54 midi_send_cc(&midi_device, 0, 0x7B, 0);
56 midi_send_cc(&midi_device, 1, 0x7B, 0); 55 midi_send_cc(&midi_device, 1, 0x7B, 0);
57 midi_send_cc(&midi_device, 2, 0x7B, 0); 56 midi_send_cc(&midi_device, 2, 0x7B, 0);
@@ -59,7 +58,7 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
59 midi_send_cc(&midi_device, 4, 0x7B, 0); 58 midi_send_cc(&midi_device, 4, 0x7B, 0);
60 return; 59 return;
61 } else { 60 } else {
62 stop_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[0 + offset])/12.0+(MATRIX_ROWS - 1))); 61 stop_note(((double)261.626)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[0 + offset])/12.0+(MATRIX_ROWS - 1)));
63 stop_all_notes(); 62 stop_all_notes();
64 return; 63 return;
65 } 64 }
@@ -74,9 +73,9 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
74 midi_send_cc(&midi_device, 4, 0x7B, 0); 73 midi_send_cc(&midi_device, 4, 0x7B, 0);
75 stop_all_notes(); 74 stop_all_notes();
76 for (int i = 0; i <= 7; i++) { 75 for (int i = 0; i <= 7; i++) {
77 play_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[i + offset])/12.0+(MATRIX_ROWS - 1)), 0xC); 76 play_note(((double)261.626)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[i + offset])/12.0+(MATRIX_ROWS - 1)), 0xC);
78 _delay_us(80000); 77 _delay_us(80000);
79 stop_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[i + offset])/12.0+(MATRIX_ROWS - 1))); 78 stop_note(((double)261.626)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[i + offset])/12.0+(MATRIX_ROWS - 1)));
80 _delay_us(8000); 79 _delay_us(8000);
81 } 80 }
82 return; 81 return;
@@ -90,9 +89,9 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
90 midi_send_cc(&midi_device, 4, 0x7B, 0); 89 midi_send_cc(&midi_device, 4, 0x7B, 0);
91 stop_all_notes(); 90 stop_all_notes();
92 for (int i = 0; i <= 7; i++) { 91 for (int i = 0; i <= 7; i++) {
93 play_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[i + offset])/12.0+(MATRIX_ROWS - 1)), 0xC); 92 play_note(((double)261.626)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[i + offset])/12.0+(MATRIX_ROWS - 1)), 0xC);
94 _delay_us(80000); 93 _delay_us(80000);
95 stop_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[i + offset])/12.0+(MATRIX_ROWS - 1))); 94 stop_note(((double)261.626)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[i + offset])/12.0+(MATRIX_ROWS - 1)));
96 _delay_us(8000); 95 _delay_us(8000);
97 } 96 }
98 return; 97 return;
@@ -101,10 +100,10 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
101 if (record->event.pressed) { 100 if (record->event.pressed) {
102 // midi_send_noteon(&midi_device, record->event.key.row, starting_note + SCALE[record->event.key.col], 127); 101 // midi_send_noteon(&midi_device, record->event.key.row, starting_note + SCALE[record->event.key.col], 127);
103 midi_send_noteon(&midi_device, 0, (starting_note + SCALE[record->event.key.col + offset])+12*(MATRIX_ROWS - record->event.key.row), 127); 102 midi_send_noteon(&midi_device, 0, (starting_note + SCALE[record->event.key.col + offset])+12*(MATRIX_ROWS - record->event.key.row), 127);
104 play_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)), 0xF); 103 play_note(((double)261.626)*pow(2.0, 0.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)), 0xF);
105 } else { 104 } else {
106 // midi_send_noteoff(&midi_device, record->event.key.row, starting_note + SCALE[record->event.key.col], 127); 105 // midi_send_noteoff(&midi_device, record->event.key.row, starting_note + SCALE[record->event.key.col], 127);
107 midi_send_noteoff(&midi_device, 0, (starting_note + SCALE[record->event.key.col + offset])+12*(MATRIX_ROWS - record->event.key.row), 127); 106 midi_send_noteoff(&midi_device, 0, (starting_note + SCALE[record->event.key.col + offset])+12*(MATRIX_ROWS - record->event.key.row), 127);
108 stop_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row))); 107 stop_note(((double)261.626)*pow(2.0, 0.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)));
109 } 108 }
110} \ No newline at end of file 109} \ No newline at end of file
diff --git a/quantum/keymap_midi.h b/quantum/keymap_midi.h
index c5917f884..a89420ce2 100644
--- a/quantum/keymap_midi.h
+++ b/quantum/keymap_midi.h
@@ -18,6 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
18#ifndef KEYMAP_MIDI_H 18#ifndef KEYMAP_MIDI_H
19#define KEYMAP_MIDI_H 19#define KEYMAP_MIDI_H
20 20
21#include <lufa.h>
22
21#define MIDI 0x6000 23#define MIDI 0x6000
22#define MIDI12 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000 24#define MIDI12 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000
23 25
diff --git a/quantum/wave.h b/quantum/wave.h
new file mode 100644
index 000000000..6ebc34851
--- /dev/null
+++ b/quantum/wave.h
@@ -0,0 +1,265 @@
1#include <avr/io.h>
2#include <avr/interrupt.h>
3#include <avr/pgmspace.h>
4
5#define SINE_LENGTH 2048
6
7const uint8_t sinewave[] PROGMEM= //2048 values
8{
90x80,0x80,0x80,0x81,0x81,0x81,0x82,0x82,
100x83,0x83,0x83,0x84,0x84,0x85,0x85,0x85,
110x86,0x86,0x87,0x87,0x87,0x88,0x88,0x88,
120x89,0x89,0x8a,0x8a,0x8a,0x8b,0x8b,0x8c,
130x8c,0x8c,0x8d,0x8d,0x8e,0x8e,0x8e,0x8f,
140x8f,0x8f,0x90,0x90,0x91,0x91,0x91,0x92,
150x92,0x93,0x93,0x93,0x94,0x94,0x95,0x95,
160x95,0x96,0x96,0x96,0x97,0x97,0x98,0x98,
170x98,0x99,0x99,0x9a,0x9a,0x9a,0x9b,0x9b,
180x9b,0x9c,0x9c,0x9d,0x9d,0x9d,0x9e,0x9e,
190x9e,0x9f,0x9f,0xa0,0xa0,0xa0,0xa1,0xa1,
200xa2,0xa2,0xa2,0xa3,0xa3,0xa3,0xa4,0xa4,
210xa5,0xa5,0xa5,0xa6,0xa6,0xa6,0xa7,0xa7,
220xa7,0xa8,0xa8,0xa9,0xa9,0xa9,0xaa,0xaa,
230xaa,0xab,0xab,0xac,0xac,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,0xea,0xea,0xea,0xeb,0xeb,0xeb,
500xeb,0xeb,0xec,0xec,0xec,0xec,0xec,0xed,
510xed,0xed,0xed,0xed,0xee,0xee,0xee,0xee,
520xee,0xef,0xef,0xef,0xef,0xef,0xf0,0xf0,
530xf0,0xf0,0xf0,0xf0,0xf1,0xf1,0xf1,0xf1,
540xf1,0xf2,0xf2,0xf2,0xf2,0xf2,0xf2,0xf3,
550xf3,0xf3,0xf3,0xf3,0xf3,0xf4,0xf4,0xf4,
560xf4,0xf4,0xf4,0xf5,0xf5,0xf5,0xf5,0xf5,
570xf5,0xf5,0xf6,0xf6,0xf6,0xf6,0xf6,0xf6,
580xf6,0xf7,0xf7,0xf7,0xf7,0xf7,0xf7,0xf7,
590xf8,0xf8,0xf8,0xf8,0xf8,0xf8,0xf8,0xf8,
600xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,
610xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,
620xfa,0xfa,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,
630xfb,0xfb,0xfb,0xfb,0xfc,0xfc,0xfc,0xfc,
640xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,
650xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,
660xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfe,0xfe,
670xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,
680xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,
690xfe,0xfe,0xfe,0xfe,0xff,0xff,0xff,0xff,
700xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
710xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
720xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
730xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
740xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
750xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
760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0x9f,0x9f,
1270x9e,0x9e,0x9e,0x9d,0x9d,0x9d,0x9c,0x9c,
1280x9b,0x9b,0x9b,0x9a,0x9a,0x9a,0x99,0x99,
1290x98,0x98,0x98,0x97,0x97,0x96,0x96,0x96,
1300x95,0x95,0x95,0x94,0x94,0x93,0x93,0x93,
1310x92,0x92,0x91,0x91,0x91,0x90,0x90,0x8f,
1320x8f,0x8f,0x8e,0x8e,0x8e,0x8d,0x8d,0x8c,
1330x8c,0x8c,0x8b,0x8b,0x8a,0x8a,0x8a,0x89,
1340x89,0x88,0x88,0x88,0x87,0x87,0x87,0x86,
1350x86,0x85,0x85,0x85,0x84,0x84,0x83,0x83,
1360x83,0x82,0x82,0x81,0x81,0x81,0x80,0x80,
1370x80,0x7f,0x7f,0x7e,0x7e,0x7e,0x7d,0x7d,
1380x7c,0x7c,0x7c,0x7b,0x7b,0x7a,0x7a,0x7a,
1390x79,0x79,0x78,0x78,0x78,0x77,0x77,0x77,
1400x76,0x76,0x75,0x75,0x75,0x74,0x74,0x73,
1410x73,0x73,0x72,0x72,0x71,0x71,0x71,0x70,
1420x70,0x70,0x6f,0x6f,0x6e,0x6e,0x6e,0x6d,
1430x6d,0x6c,0x6c,0x6c,0x6b,0x6b,0x6a,0x6a,
1440x6a,0x69,0x69,0x69,0x68,0x68,0x67,0x67,
1450x67,0x66,0x66,0x65,0x65,0x65,0x64,0x64,
1460x64,0x63,0x63,0x62,0x62,0x62,0x61,0x61,
1470x61,0x60,0x60,0x5f,0x5f,0x5f,0x5e,0x5e,
1480x5d,0x5d,0x5d,0x5c,0x5c,0x5c,0x5b,0x5b,
1490x5a,0x5a,0x5a,0x59,0x59,0x59,0x58,0x58,
1500x58,0x57,0x57,0x56,0x56,0x56,0x55,0x55,
1510x55,0x54,0x54,0x53,0x53,0x53,0x52,0x52,
1520x52,0x51,0x51,0x51,0x50,0x50,0x4f,0x4f,
1530x4f,0x4e,0x4e,0x4e,0x4d,0x4d,0x4d,0x4c,
1540x4c,0x4b,0x4b,0x4b,0x4a,0x4a,0x4a,0x49,
1550x49,0x49,0x48,0x48,0x48,0x47,0x47,0x47,
1560x46,0x46,0x45,0x45,0x45,0x44,0x44,0x44,
1570x43,0x43,0x43,0x42,0x42,0x42,0x41,0x41,
1580x41,0x40,0x40,0x40,0x3f,0x3f,0x3f,0x3e,
1590x3e,0x3e,0x3d,0x3d,0x3d,0x3c,0x3c,0x3c,
1600x3b,0x3b,0x3b,0x3a,0x3a,0x3a,0x39,0x39,
1610x39,0x38,0x38,0x38,0x37,0x37,0x37,0x36,
1620x36,0x36,0x35,0x35,0x35,0x34,0x34,0x34,
1630x34,0x33,0x33,0x33,0x32,0x32,0x32,0x31,
1640x31,0x31,0x30,0x30,0x30,0x30,0x2f,0x2f,
1650x2f,0x2e,0x2e,0x2e,0x2d,0x2d,0x2d,0x2d,
1660x2c,0x2c,0x2c,0x2b,0x2b,0x2b,0x2a,0x2a,
1670x2a,0x2a,0x29,0x29,0x29,0x28,0x28,0x28,
1680x28,0x27,0x27,0x27,0x26,0x26,0x26,0x26,
1690x25,0x25,0x25,0x25,0x24,0x24,0x24,0x23,
1700x23,0x23,0x23,0x22,0x22,0x22,0x22,0x21,
1710x21,0x21,0x21,0x20,0x20,0x20,0x1f,0x1f,
1720x1f,0x1f,0x1e,0x1e,0x1e,0x1e,0x1d,0x1d,
1730x1d,0x1d,0x1c,0x1c,0x1c,0x1c,0x1b,0x1b,
1740x1b,0x1b,0x1b,0x1a,0x1a,0x1a,0x1a,0x19,
1750x19,0x19,0x19,0x18,0x18,0x18,0x18,0x17,
1760x17,0x17,0x17,0x17,0x16,0x16,0x16,0x16,
1770x15,0x15,0x15,0x15,0x15,0x14,0x14,0x14,
1780x14,0x14,0x13,0x13,0x13,0x13,0x13,0x12,
1790x12,0x12,0x12,0x12,0x11,0x11,0x11,0x11,
1800x11,0x10,0x10,0x10,0x10,0x10,0xf,0xf,
1810xf,0xf,0xf,0xf,0xe,0xe,0xe,0xe,
1820xe,0xd,0x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5,0x5,0x5,0x5,0x5,
2130x5,0x6,0x6,0x6,0x6,0x6,0x6,0x6,
2140x6,0x7,0x7,0x7,0x7,0x7,0x7,0x7,
2150x7,0x8,0x8,0x8,0x8,0x8,0x8,0x8,
2160x9,0x9,0x9,0x9,0x9,0x9,0x9,0xa,
2170xa,0xa,0xa,0xa,0xa,0xa,0xb,0xb,
2180xb,0xb,0xb,0xb,0xc,0xc,0xc,0xc,
2190xc,0xc,0xd,0xd,0xd,0xd,0xd,0xd,
2200xe,0xe,0xe,0xe,0xe,0xf,0xf,0xf,
2210xf,0xf,0xf,0x10,0x10,0x10,0x10,0x10,
2220x11,0x11,0x11,0x11,0x11,0x12,0x12,0x12,
2230x12,0x12,0x13,0x13,0x13,0x13,0x13,0x14,
2240x14,0x14,0x14,0x14,0x15,0x15,0x15,0x15,
2250x15,0x16,0x16,0x16,0x16,0x17,0x17,0x17,
2260x17,0x17,0x18,0x18,0x18,0x18,0x19,0x19,
2270x19,0x19,0x1a,0x1a,0x1a,0x1a,0x1b,0x1b,
2280x1b,0x1b,0x1b,0x1c,0x1c,0x1c,0x1c,0x1d,
2290x1d,0x1d,0x1d,0x1e,0x1e,0x1e,0x1e,0x1f,
2300x1f,0x1f,0x1f,0x20,0x20,0x20,0x21,0x21,
2310x21,0x21,0x22,0x22,0x22,0x22,0x23,0x23,
2320x23,0x23,0x24,0x24,0x24,0x25,0x25,0x25,
2330x25,0x26,0x26,0x26,0x26,0x27,0x27,0x27,
2340x28,0x28,0x28,0x28,0x29,0x29,0x29,0x2a,
2350x2a,0x2a,0x2a,0x2b,0x2b,0x2b,0x2c,0x2c,
2360x2c,0x2d,0x2d,0x2d,0x2d,0x2e,0x2e,0x2e,
2370x2f,0x2f,0x2f,0x30,0x30,0x30,0x30,0x31,
2380x31,0x31,0x32,0x32,0x32,0x33,0x33,0x33,
2390x34,0x34,0x34,0x34,0x35,0x35,0x35,0x36,
2400x36,0x36,0x37,0x37,0x37,0x38,0x38,0x38,
2410x39,0x39,0x39,0x3a,0x3a,0x3a,0x3b,0x3b,
2420x3b,0x3c,0x3c,0x3c,0x3d,0x3d,0x3d,0x3e,
2430x3e,0x3e,0x3f,0x3f,0x3f,0x40,0x40,0x40,
2440x41,0x41,0x41,0x42,0x42,0x42,0x43,0x43,
2450x43,0x44,0x44,0x44,0x45,0x45,0x45,0x46,
2460x46,0x47,0x47,0x47,0x48,0x48,0x48,0x49,
2470x49,0x49,0x4a,0x4a,0x4a,0x4b,0x4b,0x4b,
2480x4c,0x4c,0x4d,0x4d,0x4d,0x4e,0x4e,0x4e,
2490x4f,0x4f,0x4f,0x50,0x50,0x51,0x51,0x51,
2500x52,0x52,0x52,0x53,0x53,0x53,0x54,0x54,
2510x55,0x55,0x55,0x56,0x56,0x56,0x57,0x57,
2520x58,0x58,0x58,0x59,0x59,0x59,0x5a,0x5a,
2530x5a,0x5b,0x5b,0x5c,0x5c,0x5c,0x5d,0x5d,
2540x5d,0x5e,0x5e,0x5f,0x5f,0x5f,0x60,0x60,
2550x61,0x61,0x61,0x62,0x62,0x62,0x63,0x63,
2560x64,0x64,0x64,0x65,0x65,0x65,0x66,0x66,
2570x67,0x67,0x67,0x68,0x68,0x69,0x69,0x69,
2580x6a,0x6a,0x6a,0x6b,0x6b,0x6c,0x6c,0x6c,
2590x6d,0x6d,0x6e,0x6e,0x6e,0x6f,0x6f,0x70,
2600x70,0x70,0x71,0x71,0x71,0x72,0x72,0x73,
2610x73,0x73,0x74,0x74,0x75,0x75,0x75,0x76,
2620x76,0x77,0x77,0x77,0x78,0x78,0x78,0x79,
2630x79,0x7a,0x7a,0x7a,0x7b,0x7b,0x7c,0x7c,
2640x7c,0x7d,0x7d,0x7e,0x7e,0x7e,0x7f,0x7f
265}; \ No newline at end of file
diff --git a/tmk_core/common/avr/timer.c b/tmk_core/common/avr/timer.c
index 292b41c3a..1a695a9aa 100644
--- a/tmk_core/common/avr/timer.c
+++ b/tmk_core/common/avr/timer.c
@@ -29,24 +29,24 @@ volatile uint32_t timer_count = 0;
29void timer_init(void) 29void timer_init(void)
30{ 30{
31 // Timer0 CTC mode 31 // Timer0 CTC mode
32 TCCR0A = 0x02; 32 TCCR1A = 0x02;
33 33
34#if TIMER_PRESCALER == 1 34#if TIMER_PRESCALER == 1
35 TCCR0B = 0x01; 35 TCCR1B = 0x01;
36#elif TIMER_PRESCALER == 8 36#elif TIMER_PRESCALER == 8
37 TCCR0B = 0x02; 37 TCCR1B = 0x02;
38#elif TIMER_PRESCALER == 64 38#elif TIMER_PRESCALER == 64
39 TCCR0B = 0x03; 39 TCCR1B = 0x03;
40#elif TIMER_PRESCALER == 256 40#elif TIMER_PRESCALER == 256
41 TCCR0B = 0x04; 41 TCCR1B = 0x04;
42#elif TIMER_PRESCALER == 1024 42#elif TIMER_PRESCALER == 1024
43 TCCR0B = 0x05; 43 TCCR1B = 0x05;
44#else 44#else
45# error "Timer prescaler value is NOT vaild." 45# error "Timer prescaler value is NOT vaild."
46#endif 46#endif
47 47
48 OCR0A = TIMER_RAW_TOP; 48 OCR1A = TIMER_RAW_TOP;
49 TIMSK0 = (1<<OCIE0A); 49 TIMSK1 = (1<<OCIE1A);
50} 50}
51 51
52inline 52inline
@@ -111,7 +111,7 @@ uint32_t timer_elapsed32(uint32_t last)
111} 111}
112 112
113// excecuted once per 1ms.(excess for just timer count?) 113// excecuted once per 1ms.(excess for just timer count?)
114ISR(TIMER0_COMPA_vect) 114ISR(TIMER1_COMPA_vect)
115{ 115{
116 timer_count++; 116 timer_count++;
117} 117}