diff options
| -rw-r--r-- | keyboard/ergodox_ez/keymaps/keymap_generated.c | 78 | ||||
| -rw-r--r-- | keyboard/ergodox_ez/keymaps/keymap_jack.c | 69 | ||||
| -rw-r--r-- | keyboard/planck/Makefile | 4 | ||||
| -rw-r--r-- | keyboard/planck/keymaps/keymap_eric.c | 42 | ||||
| -rw-r--r-- | keyboard/planck/keymaps/keymap_lock.c | 10 | ||||
| -rw-r--r-- | keyboard/planck/planck.c | 29 | ||||
| -rw-r--r-- | keyboard/planck/planck.h | 5 | ||||
| -rw-r--r-- | quantum/beeps.c | 231 | ||||
| -rw-r--r-- | quantum/beeps.h | 2 | ||||
| -rw-r--r-- | quantum/keymap_midi.c | 21 | ||||
| -rw-r--r-- | quantum/keymap_midi.h | 2 | ||||
| -rw-r--r-- | quantum/wave.h | 265 | ||||
| -rw-r--r-- | tmk_core/common/avr/timer.c | 18 |
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 | |||
| 5 | const 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 | \ | ||
| 14 | KC_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 | \ | ||
| 20 | KC_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 | \ | ||
| 26 | KC_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 | |||
| 32 | const uint16_t PROGMEM fn_actions[] = { | ||
| 33 | [1] = ACTION_LAYER_TAP_TOGGLE(SYMB) // FN1 - Momentary Layer 1 (Symbols) | ||
| 34 | }; | ||
| 35 | |||
| 36 | const 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. | ||
| 52 | void * matrix_init_user(void) { | ||
| 53 | |||
| 54 | }; | ||
| 55 | |||
| 56 | // Runs constantly in the background, in a loop. | ||
| 57 | void * 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 | ||
| 10 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | 10 | const 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 | ||
| 118 | KEYMAP( | ||
| 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 |
| 125 | BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality | 125 | # BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality |
| 126 | # MIDI_ENABLE = YES # MIDI controls | 126 | MIDI_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 | |||
| 3 | const 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 | |||
| 40 | const 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 | |||
| 9 | void delay_us(int count) { | 18 | void 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) { | |||
| 15 | int voices = 0; | 24 | int voices = 0; |
| 16 | double frequency = 0; | 25 | double frequency = 0; |
| 17 | int volume = 0; | 26 | int volume = 0; |
| 18 | int position = 0; | 27 | long position = 0; |
| 19 | 28 | ||
| 20 | double frequencies[8] = {0, 0, 0, 0, 0, 0, 0, 0}; | 29 | double frequencies[8] = {0, 0, 0, 0, 0, 0, 0, 0}; |
| 21 | int volumes[8] = {0, 0, 0, 0, 0, 0, 0, 0}; | 30 | int 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 |
| 24 | volatile int i=0; //elements of the wave | 33 | volatile 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 | ||
| 27 | void beeps() { | 49 | void beeps() { |
| 28 | play_notes(); | 50 | play_notes(); |
| @@ -36,8 +58,7 @@ void send_freq(double freq, int vol) { | |||
| 36 | 58 | ||
| 37 | void stop_all_notes() { | 59 | void 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 | ||
| 50 | void stop_note(double freq) { | 71 | void 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 | ||
| 93 | void init_notes() { | 115 | void 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) | 166 | int max = 0xFF; |
| 133 | // #define lowByte(c) (c & 0x00FF) | 167 | float sum = 0; |
| 168 | int value = 128; | ||
| 169 | float place = 0; | ||
| 134 | 170 | ||
| 135 | ISR(TIMER3_COMPA_vect) { | 171 | ISR(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 */ | 221 | ISR(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 | ||
| 186 | void play_note(double freq, int vol) { | 229 | void 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); | |||
| 9 | void play_note(double freq, int vol); | 9 | void play_note(double freq, int vol); |
| 10 | void stop_note(double freq); | 10 | void stop_note(double freq); |
| 11 | void stop_all_notes(); | 11 | void stop_all_notes(); |
| 12 | void init_notes(); \ No newline at end of file | 12 | void 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 | ||
| 22 | uint8_t starting_note = 0x0C; | 21 | uint8_t starting_note = 0x0C; |
| 23 | int offset = 7; | 22 | int 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 | |||
| 7 | const uint8_t sinewave[] PROGMEM= //2048 values | ||
| 8 | { | ||
| 9 | 0x80,0x80,0x80,0x81,0x81,0x81,0x82,0x82, | ||
| 10 | 0x83,0x83,0x83,0x84,0x84,0x85,0x85,0x85, | ||
| 11 | 0x86,0x86,0x87,0x87,0x87,0x88,0x88,0x88, | ||
| 12 | 0x89,0x89,0x8a,0x8a,0x8a,0x8b,0x8b,0x8c, | ||
| 13 | 0x8c,0x8c,0x8d,0x8d,0x8e,0x8e,0x8e,0x8f, | ||
| 14 | 0x8f,0x8f,0x90,0x90,0x91,0x91,0x91,0x92, | ||
| 15 | 0x92,0x93,0x93,0x93,0x94,0x94,0x95,0x95, | ||
| 16 | 0x95,0x96,0x96,0x96,0x97,0x97,0x98,0x98, | ||
| 17 | 0x98,0x99,0x99,0x9a,0x9a,0x9a,0x9b,0x9b, | ||
| 18 | 0x9b,0x9c,0x9c,0x9d,0x9d,0x9d,0x9e,0x9e, | ||
| 19 | 0x9e,0x9f,0x9f,0xa0,0xa0,0xa0,0xa1,0xa1, | ||
| 20 | 0xa2,0xa2,0xa2,0xa3,0xa3,0xa3,0xa4,0xa4, | ||
| 21 | 0xa5,0xa5,0xa5,0xa6,0xa6,0xa6,0xa7,0xa7, | ||
| 22 | 0xa7,0xa8,0xa8,0xa9,0xa9,0xa9,0xaa,0xaa, | ||
| 23 | 0xaa,0xab,0xab,0xac,0xac,0xac,0xad,0xad, | ||
| 24 | 0xad,0xae,0xae,0xae,0xaf,0xaf,0xb0,0xb0, | ||
| 25 | 0xb0,0xb1,0xb1,0xb1,0xb2,0xb2,0xb2,0xb3, | ||
| 26 | 0xb3,0xb4,0xb4,0xb4,0xb5,0xb5,0xb5,0xb6, | ||
| 27 | 0xb6,0xb6,0xb7,0xb7,0xb7,0xb8,0xb8,0xb8, | ||
| 28 | 0xb9,0xb9,0xba,0xba,0xba,0xbb,0xbb,0xbb, | ||
| 29 | 0xbc,0xbc,0xbc,0xbd,0xbd,0xbd,0xbe,0xbe, | ||
| 30 | 0xbe,0xbf,0xbf,0xbf,0xc0,0xc0,0xc0,0xc1, | ||
| 31 | 0xc1,0xc1,0xc2,0xc2,0xc2,0xc3,0xc3,0xc3, | ||
| 32 | 0xc4,0xc4,0xc4,0xc5,0xc5,0xc5,0xc6,0xc6, | ||
| 33 | 0xc6,0xc7,0xc7,0xc7,0xc8,0xc8,0xc8,0xc9, | ||
| 34 | 0xc9,0xc9,0xca,0xca,0xca,0xcb,0xcb,0xcb, | ||
| 35 | 0xcb,0xcc,0xcc,0xcc,0xcd,0xcd,0xcd,0xce, | ||
| 36 | 0xce,0xce,0xcf,0xcf,0xcf,0xcf,0xd0,0xd0, | ||
| 37 | 0xd0,0xd1,0xd1,0xd1,0xd2,0xd2,0xd2,0xd2, | ||
| 38 | 0xd3,0xd3,0xd3,0xd4,0xd4,0xd4,0xd5,0xd5, | ||
| 39 | 0xd5,0xd5,0xd6,0xd6,0xd6,0xd7,0xd7,0xd7, | ||
| 40 | 0xd7,0xd8,0xd8,0xd8,0xd9,0xd9,0xd9,0xd9, | ||
| 41 | 0xda,0xda,0xda,0xda,0xdb,0xdb,0xdb,0xdc, | ||
| 42 | 0xdc,0xdc,0xdc,0xdd,0xdd,0xdd,0xdd,0xde, | ||
| 43 | 0xde,0xde,0xde,0xdf,0xdf,0xdf,0xe0,0xe0, | ||
| 44 | 0xe0,0xe0,0xe1,0xe1,0xe1,0xe1,0xe2,0xe2, | ||
| 45 | 0xe2,0xe2,0xe3,0xe3,0xe3,0xe3,0xe4,0xe4, | ||
| 46 | 0xe4,0xe4,0xe4,0xe5,0xe5,0xe5,0xe5,0xe6, | ||
| 47 | 0xe6,0xe6,0xe6,0xe7,0xe7,0xe7,0xe7,0xe8, | ||
| 48 | 0xe8,0xe8,0xe8,0xe8,0xe9,0xe9,0xe9,0xe9, | ||
| 49 | 0xea,0xea,0xea,0xea,0xea,0xeb,0xeb,0xeb, | ||
| 50 | 0xeb,0xeb,0xec,0xec,0xec,0xec,0xec,0xed, | ||
| 51 | 0xed,0xed,0xed,0xed,0xee,0xee,0xee,0xee, | ||
| 52 | 0xee,0xef,0xef,0xef,0xef,0xef,0xf0,0xf0, | ||
| 53 | 0xf0,0xf0,0xf0,0xf0,0xf1,0xf1,0xf1,0xf1, | ||
| 54 | 0xf1,0xf2,0xf2,0xf2,0xf2,0xf2,0xf2,0xf3, | ||
| 55 | 0xf3,0xf3,0xf3,0xf3,0xf3,0xf4,0xf4,0xf4, | ||
| 56 | 0xf4,0xf4,0xf4,0xf5,0xf5,0xf5,0xf5,0xf5, | ||
| 57 | 0xf5,0xf5,0xf6,0xf6,0xf6,0xf6,0xf6,0xf6, | ||
| 58 | 0xf6,0xf7,0xf7,0xf7,0xf7,0xf7,0xf7,0xf7, | ||
| 59 | 0xf8,0xf8,0xf8,0xf8,0xf8,0xf8,0xf8,0xf8, | ||
| 60 | 0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9, | ||
| 61 | 0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa, | ||
| 62 | 0xfa,0xfa,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb, | ||
| 63 | 0xfb,0xfb,0xfb,0xfb,0xfc,0xfc,0xfc,0xfc, | ||
| 64 | 0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc, | ||
| 65 | 0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd, | ||
| 66 | 0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfe,0xfe, | ||
| 67 | 0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe, | ||
| 68 | 0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe, | ||
| 69 | 0xfe,0xfe,0xfe,0xfe,0xff,0xff,0xff,0xff, | ||
| 70 | 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, | ||
| 71 | 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, | ||
| 72 | 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, | ||
| 73 | 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, | ||
| 74 | 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, | ||
| 75 | 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, | ||
| 76 | 0xff,0xff,0xff,0xff,0xff,0xfe,0xfe,0xfe, | ||
| 77 | 0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe, | ||
| 78 | 0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe, | ||
| 79 | 0xfe,0xfe,0xfe,0xfd,0xfd,0xfd,0xfd,0xfd, | ||
| 80 | 0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd, | ||
| 81 | 0xfd,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc, | ||
| 82 | 0xfc,0xfc,0xfc,0xfc,0xfc,0xfb,0xfb,0xfb, | ||
| 83 | 0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfa, | ||
| 84 | 0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa, | ||
| 85 | 0xfa,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9, | ||
| 86 | 0xf9,0xf8,0xf8,0xf8,0xf8,0xf8,0xf8,0xf8, | ||
| 87 | 0xf8,0xf7,0xf7,0xf7,0xf7,0xf7,0xf7,0xf7, | ||
| 88 | 0xf6,0xf6,0xf6,0xf6,0xf6,0xf6,0xf6,0xf5, | ||
| 89 | 0xf5,0xf5,0xf5,0xf5,0xf5,0xf5,0xf4,0xf4, | ||
| 90 | 0xf4,0xf4,0xf4,0xf4,0xf3,0xf3,0xf3,0xf3, | ||
| 91 | 0xf3,0xf3,0xf2,0xf2,0xf2,0xf2,0xf2,0xf2, | ||
| 92 | 0xf1,0xf1,0xf1,0xf1,0xf1,0xf0,0xf0,0xf0, | ||
| 93 | 0xf0,0xf0,0xf0,0xef,0xef,0xef,0xef,0xef, | ||
| 94 | 0xee,0xee,0xee,0xee,0xee,0xed,0xed,0xed, | ||
| 95 | 0xed,0xed,0xec,0xec,0xec,0xec,0xec,0xeb, | ||
| 96 | 0xeb,0xeb,0xeb,0xeb,0xea,0xea,0xea,0xea, | ||
| 97 | 0xea,0xe9,0xe9,0xe9,0xe9,0xe8,0xe8,0xe8, | ||
| 98 | 0xe8,0xe8,0xe7,0xe7,0xe7,0xe7,0xe6,0xe6, | ||
| 99 | 0xe6,0xe6,0xe5,0xe5,0xe5,0xe5,0xe4,0xe4, | ||
| 100 | 0xe4,0xe4,0xe4,0xe3,0xe3,0xe3,0xe3,0xe2, | ||
| 101 | 0xe2,0xe2,0xe2,0xe1,0xe1,0xe1,0xe1,0xe0, | ||
| 102 | 0xe0,0xe0,0xe0,0xdf,0xdf,0xdf,0xde,0xde, | ||
| 103 | 0xde,0xde,0xdd,0xdd,0xdd,0xdd,0xdc,0xdc, | ||
| 104 | 0xdc,0xdc,0xdb,0xdb,0xdb,0xda,0xda,0xda, | ||
| 105 | 0xda,0xd9,0xd9,0xd9,0xd9,0xd8,0xd8,0xd8, | ||
| 106 | 0xd7,0xd7,0xd7,0xd7,0xd6,0xd6,0xd6,0xd5, | ||
| 107 | 0xd5,0xd5,0xd5,0xd4,0xd4,0xd4,0xd3,0xd3, | ||
| 108 | 0xd3,0xd2,0xd2,0xd2,0xd2,0xd1,0xd1,0xd1, | ||
| 109 | 0xd0,0xd0,0xd0,0xcf,0xcf,0xcf,0xcf,0xce, | ||
| 110 | 0xce,0xce,0xcd,0xcd,0xcd,0xcc,0xcc,0xcc, | ||
| 111 | 0xcb,0xcb,0xcb,0xcb,0xca,0xca,0xca,0xc9, | ||
| 112 | 0xc9,0xc9,0xc8,0xc8,0xc8,0xc7,0xc7,0xc7, | ||
| 113 | 0xc6,0xc6,0xc6,0xc5,0xc5,0xc5,0xc4,0xc4, | ||
| 114 | 0xc4,0xc3,0xc3,0xc3,0xc2,0xc2,0xc2,0xc1, | ||
| 115 | 0xc1,0xc1,0xc0,0xc0,0xc0,0xbf,0xbf,0xbf, | ||
| 116 | 0xbe,0xbe,0xbe,0xbd,0xbd,0xbd,0xbc,0xbc, | ||
| 117 | 0xbc,0xbb,0xbb,0xbb,0xba,0xba,0xba,0xb9, | ||
| 118 | 0xb9,0xb8,0xb8,0xb8,0xb7,0xb7,0xb7,0xb6, | ||
| 119 | 0xb6,0xb6,0xb5,0xb5,0xb5,0xb4,0xb4,0xb4, | ||
| 120 | 0xb3,0xb3,0xb2,0xb2,0xb2,0xb1,0xb1,0xb1, | ||
| 121 | 0xb0,0xb0,0xb0,0xaf,0xaf,0xae,0xae,0xae, | ||
| 122 | 0xad,0xad,0xad,0xac,0xac,0xac,0xab,0xab, | ||
| 123 | 0xaa,0xaa,0xaa,0xa9,0xa9,0xa9,0xa8,0xa8, | ||
| 124 | 0xa7,0xa7,0xa7,0xa6,0xa6,0xa6,0xa5,0xa5, | ||
| 125 | 0xa5,0xa4,0xa4,0xa3,0xa3,0xa3,0xa2,0xa2, | ||
| 126 | 0xa2,0xa1,0xa1,0xa0,0xa0,0xa0,0x9f,0x9f, | ||
| 127 | 0x9e,0x9e,0x9e,0x9d,0x9d,0x9d,0x9c,0x9c, | ||
| 128 | 0x9b,0x9b,0x9b,0x9a,0x9a,0x9a,0x99,0x99, | ||
| 129 | 0x98,0x98,0x98,0x97,0x97,0x96,0x96,0x96, | ||
| 130 | 0x95,0x95,0x95,0x94,0x94,0x93,0x93,0x93, | ||
| 131 | 0x92,0x92,0x91,0x91,0x91,0x90,0x90,0x8f, | ||
| 132 | 0x8f,0x8f,0x8e,0x8e,0x8e,0x8d,0x8d,0x8c, | ||
| 133 | 0x8c,0x8c,0x8b,0x8b,0x8a,0x8a,0x8a,0x89, | ||
| 134 | 0x89,0x88,0x88,0x88,0x87,0x87,0x87,0x86, | ||
| 135 | 0x86,0x85,0x85,0x85,0x84,0x84,0x83,0x83, | ||
| 136 | 0x83,0x82,0x82,0x81,0x81,0x81,0x80,0x80, | ||
| 137 | 0x80,0x7f,0x7f,0x7e,0x7e,0x7e,0x7d,0x7d, | ||
| 138 | 0x7c,0x7c,0x7c,0x7b,0x7b,0x7a,0x7a,0x7a, | ||
| 139 | 0x79,0x79,0x78,0x78,0x78,0x77,0x77,0x77, | ||
| 140 | 0x76,0x76,0x75,0x75,0x75,0x74,0x74,0x73, | ||
| 141 | 0x73,0x73,0x72,0x72,0x71,0x71,0x71,0x70, | ||
| 142 | 0x70,0x70,0x6f,0x6f,0x6e,0x6e,0x6e,0x6d, | ||
| 143 | 0x6d,0x6c,0x6c,0x6c,0x6b,0x6b,0x6a,0x6a, | ||
| 144 | 0x6a,0x69,0x69,0x69,0x68,0x68,0x67,0x67, | ||
| 145 | 0x67,0x66,0x66,0x65,0x65,0x65,0x64,0x64, | ||
| 146 | 0x64,0x63,0x63,0x62,0x62,0x62,0x61,0x61, | ||
| 147 | 0x61,0x60,0x60,0x5f,0x5f,0x5f,0x5e,0x5e, | ||
| 148 | 0x5d,0x5d,0x5d,0x5c,0x5c,0x5c,0x5b,0x5b, | ||
| 149 | 0x5a,0x5a,0x5a,0x59,0x59,0x59,0x58,0x58, | ||
| 150 | 0x58,0x57,0x57,0x56,0x56,0x56,0x55,0x55, | ||
| 151 | 0x55,0x54,0x54,0x53,0x53,0x53,0x52,0x52, | ||
| 152 | 0x52,0x51,0x51,0x51,0x50,0x50,0x4f,0x4f, | ||
| 153 | 0x4f,0x4e,0x4e,0x4e,0x4d,0x4d,0x4d,0x4c, | ||
| 154 | 0x4c,0x4b,0x4b,0x4b,0x4a,0x4a,0x4a,0x49, | ||
| 155 | 0x49,0x49,0x48,0x48,0x48,0x47,0x47,0x47, | ||
| 156 | 0x46,0x46,0x45,0x45,0x45,0x44,0x44,0x44, | ||
| 157 | 0x43,0x43,0x43,0x42,0x42,0x42,0x41,0x41, | ||
| 158 | 0x41,0x40,0x40,0x40,0x3f,0x3f,0x3f,0x3e, | ||
| 159 | 0x3e,0x3e,0x3d,0x3d,0x3d,0x3c,0x3c,0x3c, | ||
| 160 | 0x3b,0x3b,0x3b,0x3a,0x3a,0x3a,0x39,0x39, | ||
| 161 | 0x39,0x38,0x38,0x38,0x37,0x37,0x37,0x36, | ||
| 162 | 0x36,0x36,0x35,0x35,0x35,0x34,0x34,0x34, | ||
| 163 | 0x34,0x33,0x33,0x33,0x32,0x32,0x32,0x31, | ||
| 164 | 0x31,0x31,0x30,0x30,0x30,0x30,0x2f,0x2f, | ||
| 165 | 0x2f,0x2e,0x2e,0x2e,0x2d,0x2d,0x2d,0x2d, | ||
| 166 | 0x2c,0x2c,0x2c,0x2b,0x2b,0x2b,0x2a,0x2a, | ||
| 167 | 0x2a,0x2a,0x29,0x29,0x29,0x28,0x28,0x28, | ||
| 168 | 0x28,0x27,0x27,0x27,0x26,0x26,0x26,0x26, | ||
| 169 | 0x25,0x25,0x25,0x25,0x24,0x24,0x24,0x23, | ||
| 170 | 0x23,0x23,0x23,0x22,0x22,0x22,0x22,0x21, | ||
| 171 | 0x21,0x21,0x21,0x20,0x20,0x20,0x1f,0x1f, | ||
| 172 | 0x1f,0x1f,0x1e,0x1e,0x1e,0x1e,0x1d,0x1d, | ||
| 173 | 0x1d,0x1d,0x1c,0x1c,0x1c,0x1c,0x1b,0x1b, | ||
| 174 | 0x1b,0x1b,0x1b,0x1a,0x1a,0x1a,0x1a,0x19, | ||
| 175 | 0x19,0x19,0x19,0x18,0x18,0x18,0x18,0x17, | ||
| 176 | 0x17,0x17,0x17,0x17,0x16,0x16,0x16,0x16, | ||
| 177 | 0x15,0x15,0x15,0x15,0x15,0x14,0x14,0x14, | ||
| 178 | 0x14,0x14,0x13,0x13,0x13,0x13,0x13,0x12, | ||
| 179 | 0x12,0x12,0x12,0x12,0x11,0x11,0x11,0x11, | ||
| 180 | 0x11,0x10,0x10,0x10,0x10,0x10,0xf,0xf, | ||
| 181 | 0xf,0xf,0xf,0xf,0xe,0xe,0xe,0xe, | ||
| 182 | 0xe,0xd,0xd,0xd,0xd,0xd,0xd,0xc, | ||
| 183 | 0xc,0xc,0xc,0xc,0xc,0xb,0xb,0xb, | ||
| 184 | 0xb,0xb,0xb,0xa,0xa,0xa,0xa,0xa, | ||
| 185 | 0xa,0xa,0x9,0x9,0x9,0x9,0x9,0x9, | ||
| 186 | 0x9,0x8,0x8,0x8,0x8,0x8,0x8,0x8, | ||
| 187 | 0x7,0x7,0x7,0x7,0x7,0x7,0x7,0x7, | ||
| 188 | 0x6,0x6,0x6,0x6,0x6,0x6,0x6,0x6, | ||
| 189 | 0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5, | ||
| 190 | 0x5,0x5,0x4,0x4,0x4,0x4,0x4,0x4, | ||
| 191 | 0x4,0x4,0x4,0x4,0x3,0x3,0x3,0x3, | ||
| 192 | 0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3, | ||
| 193 | 0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2, | ||
| 194 | 0x2,0x2,0x2,0x2,0x2,0x2,0x1,0x1, | ||
| 195 | 0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1, | ||
| 196 | 0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1, | ||
| 197 | 0x1,0x1,0x1,0x1,0x0,0x0,0x0,0x0, | ||
| 198 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | ||
| 199 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | ||
| 200 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | ||
| 201 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | ||
| 202 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | ||
| 203 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | ||
| 204 | 0x0,0x0,0x0,0x0,0x0,0x1,0x1,0x1, | ||
| 205 | 0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1, | ||
| 206 | 0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1, | ||
| 207 | 0x1,0x1,0x1,0x2,0x2,0x2,0x2,0x2, | ||
| 208 | 0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2, | ||
| 209 | 0x2,0x3,0x3,0x3,0x3,0x3,0x3,0x3, | ||
| 210 | 0x3,0x3,0x3,0x3,0x3,0x4,0x4,0x4, | ||
| 211 | 0x4,0x4,0x4,0x4,0x4,0x4,0x4,0x5, | ||
| 212 | 0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5, | ||
| 213 | 0x5,0x6,0x6,0x6,0x6,0x6,0x6,0x6, | ||
| 214 | 0x6,0x7,0x7,0x7,0x7,0x7,0x7,0x7, | ||
| 215 | 0x7,0x8,0x8,0x8,0x8,0x8,0x8,0x8, | ||
| 216 | 0x9,0x9,0x9,0x9,0x9,0x9,0x9,0xa, | ||
| 217 | 0xa,0xa,0xa,0xa,0xa,0xa,0xb,0xb, | ||
| 218 | 0xb,0xb,0xb,0xb,0xc,0xc,0xc,0xc, | ||
| 219 | 0xc,0xc,0xd,0xd,0xd,0xd,0xd,0xd, | ||
| 220 | 0xe,0xe,0xe,0xe,0xe,0xf,0xf,0xf, | ||
| 221 | 0xf,0xf,0xf,0x10,0x10,0x10,0x10,0x10, | ||
| 222 | 0x11,0x11,0x11,0x11,0x11,0x12,0x12,0x12, | ||
| 223 | 0x12,0x12,0x13,0x13,0x13,0x13,0x13,0x14, | ||
| 224 | 0x14,0x14,0x14,0x14,0x15,0x15,0x15,0x15, | ||
| 225 | 0x15,0x16,0x16,0x16,0x16,0x17,0x17,0x17, | ||
| 226 | 0x17,0x17,0x18,0x18,0x18,0x18,0x19,0x19, | ||
| 227 | 0x19,0x19,0x1a,0x1a,0x1a,0x1a,0x1b,0x1b, | ||
| 228 | 0x1b,0x1b,0x1b,0x1c,0x1c,0x1c,0x1c,0x1d, | ||
| 229 | 0x1d,0x1d,0x1d,0x1e,0x1e,0x1e,0x1e,0x1f, | ||
| 230 | 0x1f,0x1f,0x1f,0x20,0x20,0x20,0x21,0x21, | ||
| 231 | 0x21,0x21,0x22,0x22,0x22,0x22,0x23,0x23, | ||
| 232 | 0x23,0x23,0x24,0x24,0x24,0x25,0x25,0x25, | ||
| 233 | 0x25,0x26,0x26,0x26,0x26,0x27,0x27,0x27, | ||
| 234 | 0x28,0x28,0x28,0x28,0x29,0x29,0x29,0x2a, | ||
| 235 | 0x2a,0x2a,0x2a,0x2b,0x2b,0x2b,0x2c,0x2c, | ||
| 236 | 0x2c,0x2d,0x2d,0x2d,0x2d,0x2e,0x2e,0x2e, | ||
| 237 | 0x2f,0x2f,0x2f,0x30,0x30,0x30,0x30,0x31, | ||
| 238 | 0x31,0x31,0x32,0x32,0x32,0x33,0x33,0x33, | ||
| 239 | 0x34,0x34,0x34,0x34,0x35,0x35,0x35,0x36, | ||
| 240 | 0x36,0x36,0x37,0x37,0x37,0x38,0x38,0x38, | ||
| 241 | 0x39,0x39,0x39,0x3a,0x3a,0x3a,0x3b,0x3b, | ||
| 242 | 0x3b,0x3c,0x3c,0x3c,0x3d,0x3d,0x3d,0x3e, | ||
| 243 | 0x3e,0x3e,0x3f,0x3f,0x3f,0x40,0x40,0x40, | ||
| 244 | 0x41,0x41,0x41,0x42,0x42,0x42,0x43,0x43, | ||
| 245 | 0x43,0x44,0x44,0x44,0x45,0x45,0x45,0x46, | ||
| 246 | 0x46,0x47,0x47,0x47,0x48,0x48,0x48,0x49, | ||
| 247 | 0x49,0x49,0x4a,0x4a,0x4a,0x4b,0x4b,0x4b, | ||
| 248 | 0x4c,0x4c,0x4d,0x4d,0x4d,0x4e,0x4e,0x4e, | ||
| 249 | 0x4f,0x4f,0x4f,0x50,0x50,0x51,0x51,0x51, | ||
| 250 | 0x52,0x52,0x52,0x53,0x53,0x53,0x54,0x54, | ||
| 251 | 0x55,0x55,0x55,0x56,0x56,0x56,0x57,0x57, | ||
| 252 | 0x58,0x58,0x58,0x59,0x59,0x59,0x5a,0x5a, | ||
| 253 | 0x5a,0x5b,0x5b,0x5c,0x5c,0x5c,0x5d,0x5d, | ||
| 254 | 0x5d,0x5e,0x5e,0x5f,0x5f,0x5f,0x60,0x60, | ||
| 255 | 0x61,0x61,0x61,0x62,0x62,0x62,0x63,0x63, | ||
| 256 | 0x64,0x64,0x64,0x65,0x65,0x65,0x66,0x66, | ||
| 257 | 0x67,0x67,0x67,0x68,0x68,0x69,0x69,0x69, | ||
| 258 | 0x6a,0x6a,0x6a,0x6b,0x6b,0x6c,0x6c,0x6c, | ||
| 259 | 0x6d,0x6d,0x6e,0x6e,0x6e,0x6f,0x6f,0x70, | ||
| 260 | 0x70,0x70,0x71,0x71,0x71,0x72,0x72,0x73, | ||
| 261 | 0x73,0x73,0x74,0x74,0x75,0x75,0x75,0x76, | ||
| 262 | 0x76,0x77,0x77,0x77,0x78,0x78,0x78,0x79, | ||
| 263 | 0x79,0x7a,0x7a,0x7a,0x7b,0x7b,0x7c,0x7c, | ||
| 264 | 0x7c,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; | |||
| 29 | void timer_init(void) | 29 | void 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 | ||
| 52 | inline | 52 | inline |
| @@ -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?) |
| 114 | ISR(TIMER0_COMPA_vect) | 114 | ISR(TIMER1_COMPA_vect) |
| 115 | { | 115 | { |
| 116 | timer_count++; | 116 | timer_count++; |
| 117 | } | 117 | } |
