bluetooth
This commit is contained in:
parent
40148c430e
commit
c966e7982c
20 changed files with 2329 additions and 319 deletions
|
@ -121,15 +121,16 @@ EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
|
|||
CONSOLE_ENABLE = yes # Console for debug(+400)
|
||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
|
||||
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
||||
# SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
||||
# NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
|
||||
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
|
||||
MIDI_ENABLE = YES # MIDI controls
|
||||
# MIDI_ENABLE = YES # MIDI controls
|
||||
# UNICODE_ENABLE = YES # Unicode
|
||||
# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID
|
||||
|
||||
ifdef MIDI_ENABLE
|
||||
SRC += keymap_midi.c \
|
||||
beeps.c
|
||||
SRC += keymap_midi.c
|
||||
# beeps.c
|
||||
endif
|
||||
|
||||
ifdef UNICODE_ENABLE
|
||||
|
@ -143,7 +144,18 @@ endif
|
|||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TOP_DIR)
|
||||
|
||||
include $(TOP_DIR)/protocol/lufa.mk
|
||||
|
||||
|
||||
ifdef BLUETOOTH_ENABLE
|
||||
BLUEFRUIT_TRACE_SERIAL=true
|
||||
|
||||
include $(TOP_DIR)/protocol.mk
|
||||
include $(TOP_DIR)/protocol/bluefruit.mk
|
||||
include $(TOP_DIR)/protocol.mk
|
||||
else
|
||||
include $(TOP_DIR)/protocol/lufa.mk
|
||||
endif
|
||||
|
||||
include $(TOP_DIR)/common.mk
|
||||
include $(TOP_DIR)/rules.mk
|
||||
|
||||
|
|
|
@ -58,16 +58,83 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
|
||||
)
|
||||
|
||||
#ifdef BLUETOOTH_ENABLE
|
||||
#ifdef __AVR_ATmega32U4__
|
||||
#define SERIAL_UART_BAUD 9600
|
||||
#define SERIAL_UART_DATA UDR1
|
||||
#define SERIAL_UART_UBRR ((F_CPU/(16UL*SERIAL_UART_BAUD))-1)
|
||||
#define SERIAL_UART_RXD_VECT USART1_RX_vect
|
||||
#define SERIAL_UART_TXD_READY (UCSR1A&(1<<UDRE1))
|
||||
#define SERIAL_UART_INIT() do { \
|
||||
UBRR1L = (uint8_t) SERIAL_UART_UBRR; /* baud rate */ \
|
||||
UBRR1H = (uint8_t) (SERIAL_UART_UBRR>>8); /* baud rate */ \
|
||||
UCSR1B = (1<<TXEN1); /* TX: enable */ \
|
||||
UCSR1C = (0<<UPM11) | (0<<UPM10) | /* parity: none(00), even(01), odd(11) */ \
|
||||
(0<<UCSZ12) | (1<<UCSZ11) | (1<<UCSZ10); /* data-8bit(011) */ \
|
||||
sei(); \
|
||||
} while(0)
|
||||
#else
|
||||
# error "USART configuration is needed."
|
||||
#endif
|
||||
|
||||
|
||||
// I'm fairly sure these aren't needed, but oh well - Jack
|
||||
|
||||
/*
|
||||
* PS/2 Interrupt configuration
|
||||
*/
|
||||
#ifdef PS2_USE_INT
|
||||
/* uses INT1 for clock line(ATMega32U4) */
|
||||
#define PS2_CLOCK_PORT PORTD
|
||||
#define PS2_CLOCK_PIN PIND
|
||||
#define PS2_CLOCK_DDR DDRD
|
||||
#define PS2_CLOCK_BIT 1
|
||||
|
||||
#define PS2_DATA_PORT PORTD
|
||||
#define PS2_DATA_PIN PIND
|
||||
#define PS2_DATA_DDR DDRD
|
||||
#define PS2_DATA_BIT 0
|
||||
|
||||
#define PS2_INT_INIT() do { \
|
||||
EICRA |= ((1<<ISC11) | \
|
||||
(0<<ISC10)); \
|
||||
} while (0)
|
||||
#define PS2_INT_ON() do { \
|
||||
EIMSK |= (1<<INT1); \
|
||||
} while (0)
|
||||
#define PS2_INT_OFF() do { \
|
||||
EIMSK &= ~(1<<INT1); \
|
||||
} while (0)
|
||||
#define PS2_INT_VECT INT1_vect
|
||||
#endif
|
||||
|
||||
/*
|
||||
* PS/2 Busywait configuration
|
||||
*/
|
||||
#ifdef PS2_USE_BUSYWAIT
|
||||
#define PS2_CLOCK_PORT PORTD
|
||||
#define PS2_CLOCK_PIN PIND
|
||||
#define PS2_CLOCK_DDR DDRD
|
||||
#define PS2_CLOCK_BIT 1
|
||||
|
||||
#define PS2_DATA_PORT PORTD
|
||||
#define PS2_DATA_PIN PIND
|
||||
#define PS2_DATA_DDR DDRD
|
||||
#define PS2_DATA_BIT 0
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Feature disable options
|
||||
* These options are also useful to firmware size reduction.
|
||||
*/
|
||||
|
||||
/* disable debug print */
|
||||
#define NO_DEBUG
|
||||
// #define NO_DEBUG
|
||||
|
||||
/* disable print */
|
||||
#define NO_PRINT
|
||||
// #define NO_PRINT
|
||||
|
||||
/* disable action features */
|
||||
//#define NO_ACTION_LAYER
|
||||
|
|
|
@ -35,7 +35,7 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
|
|||
if (record->event.key.col == (MATRIX_COLS - 1) && record->event.key.row == (MATRIX_ROWS - 1)) {
|
||||
if (record->event.pressed) {
|
||||
starting_note++;
|
||||
// play_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[0 + offset])/12.0+(MATRIX_ROWS - 1)), 0xC);
|
||||
play_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[0 + offset])/12.0+(MATRIX_ROWS - 1)), 0xC);
|
||||
midi_send_cc(&midi_device, 0, 0x7B, 0);
|
||||
midi_send_cc(&midi_device, 1, 0x7B, 0);
|
||||
midi_send_cc(&midi_device, 2, 0x7B, 0);
|
||||
|
@ -43,15 +43,15 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
|
|||
midi_send_cc(&midi_device, 4, 0x7B, 0);
|
||||
return;
|
||||
} else {
|
||||
// stop_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[0 + offset])/12.0+(MATRIX_ROWS - 1)));
|
||||
// stop_all_notes();
|
||||
stop_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[0 + offset])/12.0+(MATRIX_ROWS - 1)));
|
||||
stop_all_notes();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (record->event.key.col == (MATRIX_COLS - 2) && record->event.key.row == (MATRIX_ROWS - 1)) {
|
||||
if (record->event.pressed) {
|
||||
starting_note--;
|
||||
// play_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[0 + offset])/12.0+(MATRIX_ROWS - 1)), 0xC);
|
||||
play_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[0 + offset])/12.0+(MATRIX_ROWS - 1)), 0xC);
|
||||
midi_send_cc(&midi_device, 0, 0x7B, 0);
|
||||
midi_send_cc(&midi_device, 1, 0x7B, 0);
|
||||
midi_send_cc(&midi_device, 2, 0x7B, 0);
|
||||
|
@ -59,8 +59,8 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
|
|||
midi_send_cc(&midi_device, 4, 0x7B, 0);
|
||||
return;
|
||||
} else {
|
||||
// stop_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[0 + offset])/12.0+(MATRIX_ROWS - 1)));
|
||||
// stop_all_notes();
|
||||
stop_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[0 + offset])/12.0+(MATRIX_ROWS - 1)));
|
||||
stop_all_notes();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -72,13 +72,13 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
|
|||
midi_send_cc(&midi_device, 2, 0x7B, 0);
|
||||
midi_send_cc(&midi_device, 3, 0x7B, 0);
|
||||
midi_send_cc(&midi_device, 4, 0x7B, 0);
|
||||
// stop_all_notes();
|
||||
// for (int i = 0; i <= 7; i++) {
|
||||
// play_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[i + offset])/12.0+(MATRIX_ROWS - 1)), 0xC);
|
||||
// _delay_us(80000);
|
||||
// stop_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[i + offset])/12.0+(MATRIX_ROWS - 1)));
|
||||
// _delay_us(8000);
|
||||
// }
|
||||
stop_all_notes();
|
||||
for (int i = 0; i <= 7; i++) {
|
||||
play_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[i + offset])/12.0+(MATRIX_ROWS - 1)), 0xC);
|
||||
_delay_us(80000);
|
||||
stop_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[i + offset])/12.0+(MATRIX_ROWS - 1)));
|
||||
_delay_us(8000);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (record->event.key.col == (MATRIX_COLS - 4) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) {
|
||||
|
@ -88,23 +88,23 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
|
|||
midi_send_cc(&midi_device, 2, 0x7B, 0);
|
||||
midi_send_cc(&midi_device, 3, 0x7B, 0);
|
||||
midi_send_cc(&midi_device, 4, 0x7B, 0);
|
||||
// stop_all_notes();
|
||||
// for (int i = 0; i <= 7; i++) {
|
||||
// play_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[i + offset])/12.0+(MATRIX_ROWS - 1)), 0xC);
|
||||
// _delay_us(80000);
|
||||
// stop_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[i + offset])/12.0+(MATRIX_ROWS - 1)));
|
||||
// _delay_us(8000);
|
||||
// }
|
||||
stop_all_notes();
|
||||
for (int i = 0; i <= 7; i++) {
|
||||
play_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[i + offset])/12.0+(MATRIX_ROWS - 1)), 0xC);
|
||||
_delay_us(80000);
|
||||
stop_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[i + offset])/12.0+(MATRIX_ROWS - 1)));
|
||||
_delay_us(8000);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (record->event.pressed) {
|
||||
// midi_send_noteon(&midi_device, record->event.key.row, starting_note + SCALE[record->event.key.col], 127);
|
||||
midi_send_noteon(&midi_device, 0, (starting_note + SCALE[record->event.key.col + offset])+12*(MATRIX_ROWS - record->event.key.row), 127);
|
||||
// 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);
|
||||
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);
|
||||
} else {
|
||||
// midi_send_noteoff(&midi_device, record->event.key.row, starting_note + SCALE[record->event.key.col], 127);
|
||||
midi_send_noteoff(&midi_device, 0, (starting_note + SCALE[record->event.key.col + offset])+12*(MATRIX_ROWS - record->event.key.row), 127);
|
||||
// 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)));
|
||||
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)));
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
#include "backlight.h"
|
||||
#include "action_layer.h"
|
||||
#include "keymap_midi.h"
|
||||
#include "beeps.h"
|
||||
#include <avr/boot.h>
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[0] = { /* Qwerty */
|
||||
|
@ -53,6 +53,16 @@ const uint16_t PROGMEM fn_actions[] = {
|
|||
|
||||
};
|
||||
|
||||
uint16_t hextokeycode(int hex) {
|
||||
if (hex == 0x0) {
|
||||
return KC_0;
|
||||
} else if (hex < 0xA) {
|
||||
return KC_1 + (hex - 0x1);
|
||||
} else {
|
||||
return KC_A + (hex - 0xA);
|
||||
}
|
||||
}
|
||||
|
||||
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
|
||||
{
|
||||
// MACRODOWN only works in this function
|
||||
|
@ -64,6 +74,35 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
|
|||
backlight_set(BACKLIGHT_LEVELS);
|
||||
default_layer_and(0);
|
||||
default_layer_or((1<<5));
|
||||
|
||||
uint8_t low = boot_lock_fuse_bits_get(0x0000);
|
||||
uint8_t high = boot_lock_fuse_bits_get(0x0003);
|
||||
uint8_t ext = boot_lock_fuse_bits_get(0x0002);
|
||||
uint8_t lock = boot_lock_fuse_bits_get(0x0001);
|
||||
|
||||
register_code(hextokeycode((low & 0xF0) >> 4));
|
||||
unregister_code(hextokeycode((low & 0xF0) >> 4));
|
||||
register_code(hextokeycode((low & 0x0F)));
|
||||
unregister_code(hextokeycode((low & 0x0F)));
|
||||
|
||||
|
||||
register_code(hextokeycode((high & 0xF0) >> 4));
|
||||
unregister_code(hextokeycode((high & 0xF0) >> 4));
|
||||
register_code(hextokeycode((high & 0x0F)));
|
||||
unregister_code(hextokeycode((high & 0x0F)));
|
||||
|
||||
|
||||
register_code(hextokeycode((ext & 0xF0) >> 4));
|
||||
unregister_code(hextokeycode((ext & 0xF0) >> 4));
|
||||
register_code(hextokeycode((ext & 0x0F)));
|
||||
unregister_code(hextokeycode((ext & 0x0F)));
|
||||
|
||||
|
||||
register_code(hextokeycode((lock & 0xF0) >> 4));
|
||||
unregister_code(hextokeycode((lock & 0xF0) >> 4));
|
||||
register_code(hextokeycode((lock & 0x0F)));
|
||||
unregister_code(hextokeycode((lock & 0x0F)));
|
||||
|
||||
// note(0+12, 20);
|
||||
// note(0+24, 20);
|
||||
} else {
|
||||
|
|
1796
keyboard/planck/planck_with_bootloader.hex
Executable file
1796
keyboard/planck/planck_with_bootloader.hex
Executable file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue