diff options
| author | Jack Humbert <jack.humb@gmail.com> | 2015-10-26 14:49:46 -0400 |
|---|---|---|
| committer | Jack Humbert <jack.humb@gmail.com> | 2015-10-26 14:49:46 -0400 |
| commit | 46e7fb2d3ccd699c0a1b1fd9d02860b1f2a44141 (patch) | |
| tree | f0b00f664ecdaf83e30f27baf20780eb5d91c39a /keyboard/planck | |
| parent | ff8d8a50dfbb8502003a5181878c54a71b8c57d5 (diff) | |
| download | qmk_firmware-46e7fb2d3ccd699c0a1b1fd9d02860b1f2a44141.tar.gz qmk_firmware-46e7fb2d3ccd699c0a1b1fd9d02860b1f2a44141.zip | |
quantum separated
Diffstat (limited to 'keyboard/planck')
| -rw-r--r-- | keyboard/planck/Makefile | 19 | ||||
| -rw-r--r-- | keyboard/planck/Makefile.pjrc | 116 | ||||
| -rw-r--r-- | keyboard/planck/analog.c | 53 | ||||
| -rw-r--r-- | keyboard/planck/analog.h | 36 | ||||
| -rw-r--r-- | keyboard/planck/beeps.c | 246 | ||||
| -rw-r--r-- | keyboard/planck/beeps.h | 12 | ||||
| -rw-r--r-- | keyboard/planck/keymap_common.c | 220 | ||||
| -rw-r--r-- | keyboard/planck/keymap_common.h | 115 | ||||
| -rw-r--r-- | keyboard/planck/keymap_french.h | 83 | ||||
| -rw-r--r-- | keyboard/planck/keymap_midi.c | 110 | ||||
| -rw-r--r-- | keyboard/planck/keymap_midi.h | 220 | ||||
| -rw-r--r-- | keyboard/planck/keymap_nordic.h | 59 | ||||
| -rw-r--r-- | keyboard/planck/keymap_spanish.h | 62 | ||||
| -rw-r--r-- | keyboard/planck/keymap_unicode.c | 59 | ||||
| -rw-r--r-- | keyboard/planck/keymaps/keymap_default.c | 3 | ||||
| -rw-r--r-- | keyboard/planck/led.c | 38 | ||||
| -rw-r--r-- | keyboard/planck/matrix.c | 299 | ||||
| -rw-r--r-- | keyboard/planck/matrix_steno.c | 234 | ||||
| -rw-r--r-- | keyboard/planck/planck.c | 29 | ||||
| -rw-r--r-- | keyboard/planck/planck.h | 38 |
20 files changed, 71 insertions, 1980 deletions
diff --git a/keyboard/planck/Makefile b/keyboard/planck/Makefile index 3ac4540e1..643646155 100644 --- a/keyboard/planck/Makefile +++ b/keyboard/planck/Makefile | |||
| @@ -39,7 +39,7 @@ | |||
| 39 | #---------------------------------------------------------------------------- | 39 | #---------------------------------------------------------------------------- |
| 40 | 40 | ||
| 41 | # Target file name (without extension). | 41 | # Target file name (without extension). |
| 42 | TARGET = planck_lufa | 42 | TARGET = planck |
| 43 | 43 | ||
| 44 | 44 | ||
| 45 | # Directory common source filess exist | 45 | # Directory common source filess exist |
| @@ -49,9 +49,7 @@ TOP_DIR = ../.. | |||
| 49 | TARGET_DIR = . | 49 | TARGET_DIR = . |
| 50 | 50 | ||
| 51 | # # project specific files | 51 | # # project specific files |
| 52 | SRC = keymap_common.c \ | 52 | SRC = planck.c \ |
| 53 | matrix.c \ | ||
| 54 | led.c \ | ||
| 55 | backlight.c | 53 | backlight.c |
| 56 | 54 | ||
| 57 | ifdef KEYMAP | 55 | ifdef KEYMAP |
| @@ -128,14 +126,6 @@ MIDI_ENABLE = YES # MIDI controls | |||
| 128 | # UNICODE_ENABLE = YES # Unicode | 126 | # UNICODE_ENABLE = YES # Unicode |
| 129 | BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID | 127 | BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID |
| 130 | 128 | ||
| 131 | ifdef MIDI_ENABLE | ||
| 132 | SRC += keymap_midi.c \ | ||
| 133 | beeps.c | ||
| 134 | endif | ||
| 135 | |||
| 136 | ifdef UNICODE_ENABLE | ||
| 137 | SRC += keymap_unicode.c | ||
| 138 | endif | ||
| 139 | 129 | ||
| 140 | # Optimize size but this may cause error "relocation truncated to fit" | 130 | # Optimize size but this may cause error "relocation truncated to fit" |
| 141 | #EXTRALDFLAGS = -Wl,--relax | 131 | #EXTRALDFLAGS = -Wl,--relax |
| @@ -144,8 +134,5 @@ endif | |||
| 144 | VPATH += $(TARGET_DIR) | 134 | VPATH += $(TARGET_DIR) |
| 145 | VPATH += $(TOP_DIR) | 135 | VPATH += $(TOP_DIR) |
| 146 | 136 | ||
| 147 | include $(TOP_DIR)/protocol/lufa.mk | 137 | include $(TOP_DIR)/quantum.mk |
| 148 | |||
| 149 | include $(TOP_DIR)/common.mk | ||
| 150 | include $(TOP_DIR)/rules.mk | ||
| 151 | 138 | ||
diff --git a/keyboard/planck/Makefile.pjrc b/keyboard/planck/Makefile.pjrc deleted file mode 100644 index be83ba18b..000000000 --- a/keyboard/planck/Makefile.pjrc +++ /dev/null | |||
| @@ -1,116 +0,0 @@ | |||
| 1 | #---------------------------------------------------------------------------- | ||
| 2 | # On command line: | ||
| 3 | # | ||
| 4 | # make all = Make software. | ||
| 5 | # | ||
| 6 | # make clean = Clean out built project files. | ||
| 7 | # | ||
| 8 | # make coff = Convert ELF to AVR COFF. | ||
| 9 | # | ||
| 10 | # make extcoff = Convert ELF to AVR Extended COFF. | ||
| 11 | # | ||
| 12 | # make program = Download the hex file to the device. | ||
| 13 | # Please customize your programmer settings(PROGRAM_CMD) | ||
| 14 | # | ||
| 15 | # make teensy = Download the hex file to the device, using teensy_loader_cli. | ||
| 16 | # (must have teensy_loader_cli installed). | ||
| 17 | # | ||
| 18 | # make dfu = Download the hex file to the device, using dfu-programmer (must | ||
| 19 | # have dfu-programmer installed). | ||
| 20 | # | ||
| 21 | # make flip = Download the hex file to the device, using Atmel FLIP (must | ||
| 22 | # have Atmel FLIP installed). | ||
| 23 | # | ||
| 24 | # make dfu-ee = Download the eeprom file to the device, using dfu-programmer | ||
| 25 | # (must have dfu-programmer installed). | ||
| 26 | # | ||
| 27 | # make flip-ee = Download the eeprom file to the device, using Atmel FLIP | ||
| 28 | # (must have Atmel FLIP installed). | ||
| 29 | # | ||
| 30 | # make debug = Start either simulavr or avarice as specified for debugging, | ||
| 31 | # with avr-gdb or avr-insight as the front end for debugging. | ||
| 32 | # | ||
| 33 | # make filename.s = Just compile filename.c into the assembler code only. | ||
| 34 | # | ||
| 35 | # make filename.i = Create a preprocessed source file for use in submitting | ||
| 36 | # bug reports to the GCC project. | ||
| 37 | # | ||
| 38 | # To rebuild project do "make clean" then "make all". | ||
| 39 | #---------------------------------------------------------------------------- | ||
| 40 | |||
| 41 | # Target file name (without extension). | ||
| 42 | TARGET = gh60_pjrc | ||
| 43 | |||
| 44 | # Directory common source filess exist | ||
| 45 | TOP_DIR = ../.. | ||
| 46 | |||
| 47 | # Directory keyboard dependent files exist | ||
| 48 | TARGET_DIR = . | ||
| 49 | |||
| 50 | # project specific files | ||
| 51 | SRC = keymap_common.c \ | ||
| 52 | matrix.c \ | ||
| 53 | led.c | ||
| 54 | |||
| 55 | ifdef KEYMAP | ||
| 56 | SRC := keymap_$(KEYMAP).c $(SRC) | ||
| 57 | else | ||
| 58 | SRC := keymap_jack.c $(SRC) | ||
| 59 | endif | ||
| 60 | |||
| 61 | CONFIG_H = config.h | ||
| 62 | |||
| 63 | |||
| 64 | # MCU name, you MUST set this to match the board you are using | ||
| 65 | # type "make clean" after changing this, so all files will be rebuilt | ||
| 66 | MCU = atmega32u4 | ||
| 67 | #MCU = at90usb1286 | ||
| 68 | |||
| 69 | |||
| 70 | # Processor frequency. | ||
| 71 | # Normally the first thing your program should do is set the clock prescaler, | ||
| 72 | # so your program will run at the correct speed. You should also set this | ||
| 73 | # variable to same clock speed. The _delay_ms() macro uses this, and many | ||
| 74 | # examples use this variable to calculate timings. Do not add a "UL" here. | ||
| 75 | F_CPU = 16000000 | ||
| 76 | |||
| 77 | |||
| 78 | # Boot Section Size in *bytes* | ||
| 79 | # Teensy halfKay 512 | ||
| 80 | # Atmel DFU loader 4096 | ||
| 81 | # LUFA bootloader 4096 | ||
| 82 | OPT_DEFS += -DBOOTLOADER_SIZE=4096 | ||
| 83 | |||
| 84 | |||
| 85 | # Build Options | ||
| 86 | # comment out to disable the options. | ||
| 87 | # | ||
| 88 | BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) | ||
| 89 | MOUSEKEY_ENABLE = yes # Mouse keys(+5000) | ||
| 90 | EXTRAKEY_ENABLE = yes # Audio control and System control(+600) | ||
| 91 | CONSOLE_ENABLE = yes # Console for debug | ||
| 92 | COMMAND_ENABLE = yes # Commands for debug and configuration | ||
| 93 | SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend | ||
| 94 | NKRO_ENABLE = yes # USB Nkey Rollover(+500) | ||
| 95 | #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support | ||
| 96 | |||
| 97 | |||
| 98 | # Search Path | ||
| 99 | VPATH += $(TARGET_DIR) | ||
| 100 | VPATH += $(TOP_DIR) | ||
| 101 | |||
| 102 | include $(TOP_DIR)/protocol/pjrc.mk | ||
| 103 | include $(TOP_DIR)/common.mk | ||
| 104 | include $(TOP_DIR)/rules.mk | ||
| 105 | |||
| 106 | plain: OPT_DEFS += -DKEYMAP_PLAIN | ||
| 107 | plain: all | ||
| 108 | |||
| 109 | poker: OPT_DEFS += -DKEYMAP_POKER | ||
| 110 | poker: all | ||
| 111 | |||
| 112 | poker_set: OPT_DEFS += -DKEYMAP_POKER_SET | ||
| 113 | poker_set: all | ||
| 114 | |||
| 115 | poker_bit: OPT_DEFS += -DKEYMAP_POKER_BIT | ||
| 116 | poker_bit: all | ||
diff --git a/keyboard/planck/analog.c b/keyboard/planck/analog.c deleted file mode 100644 index 49b84ee0e..000000000 --- a/keyboard/planck/analog.c +++ /dev/null | |||
| @@ -1,53 +0,0 @@ | |||
| 1 | // Simple analog to digitial conversion | ||
| 2 | |||
| 3 | #include <avr/io.h> | ||
| 4 | #include <avr/pgmspace.h> | ||
| 5 | #include <stdint.h> | ||
| 6 | #include "analog.h" | ||
| 7 | |||
| 8 | |||
| 9 | static uint8_t aref = (1<<REFS0); // default to AREF = Vcc | ||
| 10 | |||
| 11 | |||
| 12 | void analogReference(uint8_t mode) | ||
| 13 | { | ||
| 14 | aref = mode & 0xC0; | ||
| 15 | } | ||
| 16 | |||
| 17 | |||
| 18 | // Arduino compatible pin input | ||
| 19 | int16_t analogRead(uint8_t pin) | ||
| 20 | { | ||
| 21 | #if defined(__AVR_ATmega32U4__) | ||
| 22 | static const uint8_t PROGMEM pin_to_mux[] = { | ||
| 23 | 0x00, 0x01, 0x04, 0x05, 0x06, 0x07, | ||
| 24 | 0x25, 0x24, 0x23, 0x22, 0x21, 0x20}; | ||
| 25 | if (pin >= 12) return 0; | ||
| 26 | return adc_read(pgm_read_byte(pin_to_mux + pin)); | ||
| 27 | #elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) | ||
| 28 | if (pin >= 8) return 0; | ||
| 29 | return adc_read(pin); | ||
| 30 | #else | ||
| 31 | return 0; | ||
| 32 | #endif | ||
| 33 | } | ||
| 34 | |||
| 35 | // Mux input | ||
| 36 | int16_t adc_read(uint8_t mux) | ||
| 37 | { | ||
| 38 | #if defined(__AVR_AT90USB162__) | ||
| 39 | return 0; | ||
| 40 | #else | ||
| 41 | uint8_t low; | ||
| 42 | |||
| 43 | ADCSRA = (1<<ADEN) | ADC_PRESCALER; // enable ADC | ||
| 44 | ADCSRB = (1<<ADHSM) | (mux & 0x20); // high speed mode | ||
| 45 | ADMUX = aref | (mux & 0x1F); // configure mux input | ||
| 46 | ADCSRA = (1<<ADEN) | ADC_PRESCALER | (1<<ADSC); // start the conversion | ||
| 47 | while (ADCSRA & (1<<ADSC)) ; // wait for result | ||
| 48 | low = ADCL; // must read LSB first | ||
| 49 | return (ADCH << 8) | low; // must read MSB only once! | ||
| 50 | #endif | ||
| 51 | } | ||
| 52 | |||
| 53 | |||
diff --git a/keyboard/planck/analog.h b/keyboard/planck/analog.h deleted file mode 100644 index 9b95a93be..000000000 --- a/keyboard/planck/analog.h +++ /dev/null | |||
| @@ -1,36 +0,0 @@ | |||
| 1 | #ifndef _analog_h_included__ | ||
| 2 | #define _analog_h_included__ | ||
| 3 | |||
| 4 | #include <stdint.h> | ||
| 5 | |||
| 6 | void analogReference(uint8_t mode); | ||
| 7 | int16_t analogRead(uint8_t pin); | ||
| 8 | int16_t adc_read(uint8_t mux); | ||
| 9 | |||
| 10 | #define ADC_REF_POWER (1<<REFS0) | ||
| 11 | #define ADC_REF_INTERNAL ((1<<REFS1) | (1<<REFS0)) | ||
| 12 | #define ADC_REF_EXTERNAL (0) | ||
| 13 | |||
| 14 | // These prescaler values are for high speed mode, ADHSM = 1 | ||
| 15 | #if F_CPU == 16000000L | ||
| 16 | #define ADC_PRESCALER ((1<<ADPS2) | (1<<ADPS1)) | ||
| 17 | #elif F_CPU == 8000000L | ||
| 18 | #define ADC_PRESCALER ((1<<ADPS2) | (1<<ADPS0)) | ||
| 19 | #elif F_CPU == 4000000L | ||
| 20 | #define ADC_PRESCALER ((1<<ADPS2)) | ||
| 21 | #elif F_CPU == 2000000L | ||
| 22 | #define ADC_PRESCALER ((1<<ADPS1) | (1<<ADPS0)) | ||
| 23 | #elif F_CPU == 1000000L | ||
| 24 | #define ADC_PRESCALER ((1<<ADPS1)) | ||
| 25 | #else | ||
| 26 | #define ADC_PRESCALER ((1<<ADPS0)) | ||
| 27 | #endif | ||
| 28 | |||
| 29 | // some avr-libc versions do not properly define ADHSM | ||
| 30 | #if defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) | ||
| 31 | #if !defined(ADHSM) | ||
| 32 | #define ADHSM (7) | ||
| 33 | #endif | ||
| 34 | #endif | ||
| 35 | |||
| 36 | #endif | ||
diff --git a/keyboard/planck/beeps.c b/keyboard/planck/beeps.c deleted file mode 100644 index 8d1f81f21..000000000 --- a/keyboard/planck/beeps.c +++ /dev/null | |||
| @@ -1,246 +0,0 @@ | |||
| 1 | #include "beeps.h" | ||
| 2 | #include <math.h> | ||
| 3 | #include <avr/pgmspace.h> | ||
| 4 | #include <avr/interrupt.h> | ||
| 5 | #include <avr/io.h> | ||
| 6 | |||
| 7 | #define PI 3.14159265 | ||
| 8 | |||
| 9 | void delay_us(int count) { | ||
| 10 | while(count--) { | ||
| 11 | _delay_us(1); | ||
| 12 | } | ||
| 13 | } | ||
| 14 | |||
| 15 | int voices = 0; | ||
| 16 | double frequency = 0; | ||
| 17 | int volume = 0; | ||
| 18 | int position = 0; | ||
| 19 | |||
| 20 | double frequencies[8] = {0, 0, 0, 0, 0, 0, 0, 0}; | ||
| 21 | int volumes[8] = {0, 0, 0, 0, 0, 0, 0, 0}; | ||
| 22 | bool sliding = false; | ||
| 23 | #define RANGE 1000 | ||
| 24 | volatile int i=0; //elements of the wave | ||
| 25 | |||
| 26 | |||
| 27 | void beeps() { | ||
| 28 | play_notes(); | ||
| 29 | } | ||
| 30 | |||
| 31 | void send_freq(double freq, int vol) { | ||
| 32 | int duty = (((double)F_CPU) / freq); | ||
| 33 | ICR3 = duty; // Set max to the period | ||
| 34 | OCR3A = duty >> (0x10 - vol); // Set compare to half the period | ||
| 35 | } | ||
| 36 | |||
| 37 | void stop_all_notes() { | ||
| 38 | voices = 0; | ||
| 39 | TCCR3A = 0; | ||
| 40 | TCCR3B = 0; | ||
| 41 | frequency = 0; | ||
| 42 | volume = 0; | ||
| 43 | |||
| 44 | for (int i = 0; i < 8; i++) { | ||
| 45 | frequencies[i] = 0; | ||
| 46 | volumes[i] = 0; | ||
| 47 | } | ||
| 48 | } | ||
| 49 | |||
| 50 | void stop_note(double freq) { | ||
| 51 | for (int i = 7; i >= 0; i--) { | ||
| 52 | if (frequencies[i] == freq) { | ||
| 53 | frequencies[i] = 0; | ||
| 54 | volumes[i] = 0; | ||
| 55 | for (int j = i; (j < 7); j++) { | ||
| 56 | frequencies[j] = frequencies[j+1]; | ||
| 57 | frequencies[j+1] = 0; | ||
| 58 | volumes[j] = volumes[j+1]; | ||
| 59 | volumes[j+1] = 0; | ||
| 60 | } | ||
| 61 | } | ||
| 62 | } | ||
| 63 | voices--; | ||
| 64 | if (voices < 0) | ||
| 65 | voices = 0; | ||
| 66 | if (voices == 0) { | ||
| 67 | TCCR3A = 0; | ||
| 68 | TCCR3B = 0; | ||
| 69 | frequency = 0; | ||
| 70 | volume = 0; | ||
| 71 | } else { | ||
| 72 | double freq = frequencies[voices - 1]; | ||
| 73 | int vol = volumes[voices - 1]; | ||
| 74 | if (frequency < freq) { | ||
| 75 | sliding = true; | ||
| 76 | for (double f = frequency; f <= freq; f += ((freq - frequency) / 500.0)) { | ||
| 77 | send_freq(f, vol); | ||
| 78 | } | ||
| 79 | sliding = false; | ||
| 80 | } else if (frequency > freq) { | ||
| 81 | sliding = true; | ||
| 82 | for (double f = frequency; f >= freq; f -= ((frequency - freq) / 500.0)) { | ||
| 83 | send_freq(f, vol); | ||
| 84 | } | ||
| 85 | sliding = false; | ||
| 86 | } | ||
| 87 | send_freq(freq, vol); | ||
| 88 | frequency = freq; | ||
| 89 | volume = vol; | ||
| 90 | } | ||
| 91 | } | ||
| 92 | |||
| 93 | 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 | |||
| 97 | // DDRC |= (1<<6); | ||
| 98 | |||
| 99 | // TCCR3A = (1 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30); | ||
| 100 | // TCCR3B = (1 << WGM33) | (1 << WGM32) | (0 << CS32) | (0 << CS31) | (1 << CS30); | ||
| 101 | |||
| 102 | // ICR3 = 0xFFFF; | ||
| 103 | // OCR3A = (int)((float)wave[i]*ICR3/RANGE); //go to next array element | ||
| 104 | |||
| 105 | |||
| 106 | // cli(); | ||
| 107 | |||
| 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 | |||
| 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 | |||
| 116 | // TCCR3A = (1 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30); | ||
| 117 | // TCCR3B = (0 << WGM33) | (0 << WGM32) | (0 << CS32) | (0 << CS31) | (1 << CS30); | ||
| 118 | |||
| 119 | |||
| 120 | // TCCR1A = (1 << COM1A1) | (0 << COM1A0) | (1 << WGM11) | (0 << WGM10); | ||
| 121 | // TCCR1B = (1 << WGM12) | (0 << CS12) | (0 << CS11) | (1 << CS10); | ||
| 122 | // // SPCR = 0x50; | ||
| 123 | // // SPSR = 0x01; | ||
| 124 | // DDRC |= (1<<6); | ||
| 125 | // // ICR3 = 0xFFFF; | ||
| 126 | // // OCR3A=80; | ||
| 127 | // PORTC |= (1<<6); | ||
| 128 | |||
| 129 | // sei(); | ||
| 130 | } | ||
| 131 | |||
| 132 | // #define highByte(c) ((c >> 8) & 0x00FF) | ||
| 133 | // #define lowByte(c) (c & 0x00FF) | ||
| 134 | |||
| 135 | ISR(TIMER3_COMPA_vect) { | ||
| 136 | |||
| 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 | |||
| 163 | // // pos1 += incr1; | ||
| 164 | // // pos2 += incr2; | ||
| 165 | // // pos3 += incr3; | ||
| 166 | |||
| 167 | // // sample = sinewave[highByte(pos1)] + sinewave[highByte(pos2)] + sinewave[highByte(pos3)]; | ||
| 168 | |||
| 169 | // // OCR3A = sample; | ||
| 170 | |||
| 171 | |||
| 172 | // OCR3A=pgm_read_byte(&sinewave[pos1]); | ||
| 173 | // pos1++; | ||
| 174 | // // PORTC &= ~(1<<6); | ||
| 175 | |||
| 176 | // /* buffered, 1x gain, active mode */ | ||
| 177 | // // SPDR = highByte(sample) | 0x70; | ||
| 178 | // // while (!(SPSR & (1<<SPIF))); | ||
| 179 | |||
| 180 | // // SPDR = lowByte(sample); | ||
| 181 | // // while (!(SPSR & (1<<SPIF))); | ||
| 182 | |||
| 183 | // // PORTC |= (1<<6); | ||
| 184 | } | ||
| 185 | |||
| 186 | void play_note(double freq, int vol) { | ||
| 187 | |||
| 188 | if (freq > 0) { | ||
| 189 | DDRC |= (1<<6); | ||
| 190 | |||
| 191 | TCCR3A = (1 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30); | ||
| 192 | TCCR3B = (1 << WGM33) | (1 << WGM32) | (0 << CS32) | (1 << CS31) | (0 << CS30); | ||
| 193 | |||
| 194 | if (frequency != 0) { | ||
| 195 | if (frequency < freq) { | ||
| 196 | for (double f = frequency; f <= freq; f += ((freq - frequency) / 500.0)) { | ||
| 197 | send_freq(f, vol); | ||
| 198 | } | ||
| 199 | } else if (frequency > freq) { | ||
| 200 | for (double f = frequency; f >= freq; f -= ((frequency - freq) / 500.0)) { | ||
| 201 | send_freq(f, vol); | ||
| 202 | } | ||
| 203 | } | ||
| 204 | } | ||
| 205 | send_freq(freq, vol); | ||
| 206 | frequency = freq; | ||
| 207 | volume = vol; | ||
| 208 | |||
| 209 | frequencies[voices] = frequency; | ||
| 210 | volumes[voices] = volume; | ||
| 211 | voices++; | ||
| 212 | } | ||
| 213 | // ICR3 = 0xFFFF; | ||
| 214 | // for (int i = 0; i < 10000; i++) { | ||
| 215 | // OCR3A = round((sin(i*freq)*.5)+.5)*0xFFFF; | ||
| 216 | // // _delay_us(50); | ||
| 217 | // } | ||
| 218 | |||
| 219 | // TCCR3A = 0; | ||
| 220 | // TCCR3B = 0; | ||
| 221 | } | ||
| 222 | |||
| 223 | // void note(int x, float length) { | ||
| 224 | // DDRC |= (1<<6); | ||
| 225 | // int t = (int)(440*pow(2,-x/12.0)); // starting note | ||
| 226 | // for (int y = 0; y < length*1000/t; y++) { // note length | ||
| 227 | // PORTC |= (1<<6); | ||
| 228 | // delay_us(t); | ||
| 229 | // PORTC &= ~(1<<6); | ||
| 230 | // delay_us(t); | ||
| 231 | // } | ||
| 232 | // PORTC &= ~(1<<6); | ||
| 233 | // } | ||
| 234 | |||
| 235 | // void true_note(float x, float y, float length) { | ||
| 236 | // for (uint32_t i = 0; i < length * 50; i++) { | ||
| 237 | // uint32_t v = (uint32_t) (round(sin(PI*2*i*640000*pow(2, x/12.0))*.5+1 + sin(PI*2*i*640000*pow(2, y/12.0))*.5+1) / 2 * pow(2, 8)); | ||
| 238 | // for (int u = 0; u < 8; u++) { | ||
| 239 | // if (v & (1 << u) && !(PORTC&(1<<6))) | ||
| 240 | // PORTC |= (1<<6); | ||
| 241 | // else if (PORTC&(1<<6)) | ||
| 242 | // PORTC &= ~(1<<6); | ||
| 243 | // } | ||
| 244 | // } | ||
| 245 | // PORTC &= ~(1<<6); | ||
| 246 | // } \ No newline at end of file | ||
diff --git a/keyboard/planck/beeps.h b/keyboard/planck/beeps.h deleted file mode 100644 index 378983c60..000000000 --- a/keyboard/planck/beeps.h +++ /dev/null | |||
| @@ -1,12 +0,0 @@ | |||
| 1 | #include <stdint.h> | ||
| 2 | #include <stdbool.h> | ||
| 3 | #include <avr/io.h> | ||
| 4 | #include <util/delay.h> | ||
| 5 | |||
| 6 | void note(int x, float length); | ||
| 7 | void beeps(); | ||
| 8 | void true_note(float x, float y, float length); | ||
| 9 | void play_note(double freq, int vol); | ||
| 10 | void stop_note(double freq); | ||
| 11 | void stop_all_notes(); | ||
| 12 | void init_notes(); \ No newline at end of file | ||
diff --git a/keyboard/planck/keymap_common.c b/keyboard/planck/keymap_common.c deleted file mode 100644 index 93e91c792..000000000 --- a/keyboard/planck/keymap_common.c +++ /dev/null | |||
| @@ -1,220 +0,0 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2012,2013 Jun Wako <wakojun@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #include "keymap_common.h" | ||
| 19 | #include "report.h" | ||
| 20 | #include "keycode.h" | ||
| 21 | #include "action_layer.h" | ||
| 22 | #include "action.h" | ||
| 23 | #include "action_macro.h" | ||
| 24 | #include "debug.h" | ||
| 25 | #include "backlight.h" | ||
| 26 | #include "keymap_midi.h" | ||
| 27 | |||
| 28 | static action_t keycode_to_action(uint16_t keycode); | ||
| 29 | |||
| 30 | /* converts key to action */ | ||
| 31 | action_t action_for_key(uint8_t layer, keypos_t key) | ||
| 32 | { | ||
| 33 | // 16bit keycodes - important | ||
| 34 | uint16_t keycode = keymap_key_to_keycode(layer, key); | ||
| 35 | |||
| 36 | if (keycode >= 0x0100 && keycode < 0x2000) { | ||
| 37 | // Has a modifier | ||
| 38 | action_t action; | ||
| 39 | // Split it up | ||
| 40 | action.code = ACTION_MODS_KEY(keycode >> 8, keycode & 0xFF); | ||
| 41 | return action; | ||
| 42 | } else if (keycode >= 0x2000 && keycode < 0x3000) { | ||
| 43 | // Is a shortcut for function layer, pull last 12bits | ||
| 44 | return keymap_func_to_action(keycode & 0xFFF); | ||
| 45 | } else if (keycode >= 0x3000 && keycode < 0x4000) { | ||
| 46 | action_t action; | ||
| 47 | action.code = ACTION_MACRO(keycode & 0xFF); | ||
| 48 | return action; | ||
| 49 | } else if (keycode >= BL_0 & keycode <= BL_15) { | ||
| 50 | action_t action; | ||
| 51 | action.code = ACTION_BACKLIGHT_LEVEL(keycode & 0x000F); | ||
| 52 | return action; | ||
| 53 | } else if (keycode == BL_DEC) { | ||
| 54 | action_t action; | ||
| 55 | action.code = ACTION_BACKLIGHT_DECREASE(); | ||
| 56 | return action; | ||
| 57 | } else if (keycode == BL_INC) { | ||
| 58 | action_t action; | ||
| 59 | action.code = ACTION_BACKLIGHT_INCREASE(); | ||
| 60 | return action; | ||
| 61 | } else if (keycode == BL_TOGG) { | ||
| 62 | action_t action; | ||
| 63 | action.code = ACTION_BACKLIGHT_TOGGLE(); | ||
| 64 | return action; | ||
| 65 | } else if (keycode == BL_STEP) { | ||
| 66 | action_t action; | ||
| 67 | action.code = ACTION_BACKLIGHT_STEP(); | ||
| 68 | return action; | ||
| 69 | } else if (keycode == RESET) { | ||
| 70 | bootloader_jump(); | ||
| 71 | return; | ||
| 72 | } else if (keycode == DEBUG) { | ||
| 73 | print("\nDEBUG: enabled.\n"); | ||
| 74 | debug_enable = true; | ||
| 75 | return; | ||
| 76 | } else if (keycode >= 0x6000 && keycode < 0x7000) { | ||
| 77 | action_t action; | ||
| 78 | action.code = ACTION_FUNCTION_OPT(keycode & 0xFF, (keycode & 0x0F00) >> 8); | ||
| 79 | return action; | ||
| 80 | } else if (keycode >= 0x8000) { | ||
| 81 | action_t action; | ||
| 82 | uint16_t unicode = keycode & ~(0x8000); | ||
| 83 | action.code = ACTION_FUNCTION_OPT(unicode & 0xFF, (unicode & 0xFF00) >> 8); | ||
| 84 | return action; | ||
| 85 | } | ||
| 86 | |||
| 87 | switch (keycode) { | ||
| 88 | case KC_FN0 ... KC_FN31: | ||
| 89 | return keymap_fn_to_action(keycode); | ||
| 90 | #ifdef BOOTMAGIC_ENABLE | ||
| 91 | case KC_CAPSLOCK: | ||
| 92 | case KC_LOCKING_CAPS: | ||
| 93 | if (keymap_config.swap_control_capslock || keymap_config.capslock_to_control) { | ||
| 94 | return keycode_to_action(KC_LCTL); | ||
| 95 | } | ||
| 96 | return keycode_to_action(keycode); | ||
| 97 | case KC_LCTL: | ||
| 98 | if (keymap_config.swap_control_capslock) { | ||
| 99 | return keycode_to_action(KC_CAPSLOCK); | ||
| 100 | } | ||
| 101 | return keycode_to_action(KC_LCTL); | ||
| 102 | case KC_LALT: | ||
| 103 | if (keymap_config.swap_lalt_lgui) { | ||
| 104 | if (keymap_config.no_gui) { | ||
| 105 | return keycode_to_action(ACTION_NO); | ||
| 106 | } | ||
| 107 | return keycode_to_action(KC_LGUI); | ||
| 108 | } | ||
| 109 | return keycode_to_action(KC_LALT); | ||
| 110 | case KC_LGUI: | ||
| 111 | if (keymap_config.swap_lalt_lgui) { | ||
| 112 | return keycode_to_action(KC_LALT); | ||
| 113 | } | ||
| 114 | if (keymap_config.no_gui) { | ||
| 115 | return keycode_to_action(ACTION_NO); | ||
| 116 | } | ||
| 117 | return keycode_to_action(KC_LGUI); | ||
| 118 | case KC_RALT: | ||
| 119 | if (keymap_config.swap_ralt_rgui) { | ||
| 120 | if (keymap_config.no_gui) { | ||
| 121 | return keycode_to_action(ACTION_NO); | ||
| 122 | } | ||
| 123 | return keycode_to_action(KC_RGUI); | ||
| 124 | } | ||
| 125 | return keycode_to_action(KC_RALT); | ||
| 126 | case KC_RGUI: | ||
| 127 | if (keymap_config.swap_ralt_rgui) { | ||
| 128 | return keycode_to_action(KC_RALT); | ||
| 129 | } | ||
| 130 | if (keymap_config.no_gui) { | ||
| 131 | return keycode_to_action(ACTION_NO); | ||
| 132 | } | ||
| 133 | return keycode_to_action(KC_RGUI); | ||
| 134 | case KC_GRAVE: | ||
| 135 | if (keymap_config.swap_grave_esc) { | ||
| 136 | return keycode_to_action(KC_ESC); | ||
| 137 | } | ||
| 138 | return keycode_to_action(KC_GRAVE); | ||
| 139 | case KC_ESC: | ||
| 140 | if (keymap_config.swap_grave_esc) { | ||
| 141 | return keycode_to_action(KC_GRAVE); | ||
| 142 | } | ||
| 143 | return keycode_to_action(KC_ESC); | ||
| 144 | case KC_BSLASH: | ||
| 145 | if (keymap_config.swap_backslash_backspace) { | ||
| 146 | return keycode_to_action(KC_BSPACE); | ||
| 147 | } | ||
| 148 | return keycode_to_action(KC_BSLASH); | ||
| 149 | case KC_BSPACE: | ||
| 150 | if (keymap_config.swap_backslash_backspace) { | ||
| 151 | return keycode_to_action(KC_BSLASH); | ||
| 152 | } | ||
| 153 | return keycode_to_action(KC_BSPACE); | ||
| 154 | #endif | ||
| 155 | default: | ||
| 156 | return keycode_to_action(keycode); | ||
| 157 | } | ||
| 158 | } | ||
| 159 | |||
| 160 | |||
| 161 | /* Macro */ | ||
| 162 | __attribute__ ((weak)) | ||
| 163 | const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) | ||
| 164 | { | ||
| 165 | return MACRO_NONE; | ||
| 166 | } | ||
| 167 | |||
| 168 | /* Function */ | ||
| 169 | __attribute__ ((weak)) | ||
| 170 | void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) | ||
| 171 | { | ||
| 172 | } | ||
| 173 | |||
| 174 | /* translates keycode to action */ | ||
| 175 | static action_t keycode_to_action(uint16_t keycode) | ||
| 176 | { | ||
| 177 | action_t action; | ||
| 178 | switch (keycode) { | ||
| 179 | case KC_A ... KC_EXSEL: | ||
| 180 | case KC_LCTRL ... KC_RGUI: | ||
| 181 | action.code = ACTION_KEY(keycode); | ||
| 182 | break; | ||
| 183 | case KC_SYSTEM_POWER ... KC_SYSTEM_WAKE: | ||
| 184 | action.code = ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(keycode)); | ||
| 185 | break; | ||
| 186 | case KC_AUDIO_MUTE ... KC_WWW_FAVORITES: | ||
| 187 | action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode)); | ||
| 188 | break; | ||
| 189 | case KC_MS_UP ... KC_MS_ACCEL2: | ||
| 190 | action.code = ACTION_MOUSEKEY(keycode); | ||
| 191 | break; | ||
| 192 | case KC_TRNS: | ||
| 193 | action.code = ACTION_TRANSPARENT; | ||
| 194 | break; | ||
| 195 | default: | ||
| 196 | action.code = ACTION_NO; | ||
| 197 | break; | ||
| 198 | } | ||
| 199 | return action; | ||
| 200 | } | ||
| 201 | |||
| 202 | |||
| 203 | /* translates key to keycode */ | ||
| 204 | uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key) | ||
| 205 | { | ||
| 206 | // Read entire word (16bits) | ||
| 207 | return pgm_read_word(&keymaps[(layer)][(key.row)][(key.col)]); | ||
| 208 | } | ||
| 209 | |||
| 210 | /* translates Fn keycode to action */ | ||
| 211 | action_t keymap_fn_to_action(uint16_t keycode) | ||
| 212 | { | ||
| 213 | return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) }; | ||
| 214 | } | ||
| 215 | |||
| 216 | action_t keymap_func_to_action(uint16_t keycode) | ||
| 217 | { | ||
| 218 | // For FUNC without 8bit limit | ||
| 219 | return (action_t){ .code = pgm_read_word(&fn_actions[(int)keycode]) }; | ||
| 220 | } | ||
diff --git a/keyboard/planck/keymap_common.h b/keyboard/planck/keymap_common.h deleted file mode 100644 index 21908a2be..000000000 --- a/keyboard/planck/keymap_common.h +++ /dev/null | |||
| @@ -1,115 +0,0 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2012,2013 Jun Wako <wakojun@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #ifndef KEYMAP_H | ||
| 19 | #define KEYMAP_H | ||
| 20 | |||
| 21 | #include <stdint.h> | ||
| 22 | #include <stdbool.h> | ||
| 23 | #include "action.h" | ||
| 24 | #include <avr/pgmspace.h> | ||
| 25 | #include "keycode.h" | ||
| 26 | #include "keymap.h" | ||
| 27 | #include "action_macro.h" | ||
| 28 | #include "report.h" | ||
| 29 | #include "host.h" | ||
| 30 | // #include "print.h" | ||
| 31 | #include "debug.h" | ||
| 32 | |||
| 33 | #ifdef BOOTMAGIC_ENABLE | ||
| 34 | /* NOTE: Not portable. Bit field order depends on implementation */ | ||
| 35 | typedef union { | ||
| 36 | uint16_t raw; | ||
| 37 | struct { | ||
| 38 | bool swap_control_capslock:1; | ||
| 39 | bool capslock_to_control:1; | ||
| 40 | bool swap_lalt_lgui:1; | ||
| 41 | bool swap_ralt_rgui:1; | ||
| 42 | bool no_gui:1; | ||
| 43 | bool swap_grave_esc:1; | ||
| 44 | bool swap_backslash_backspace:1; | ||
| 45 | bool nkro:1; | ||
| 46 | }; | ||
| 47 | } keymap_config_t; | ||
| 48 | keymap_config_t keymap_config; | ||
| 49 | #endif | ||
| 50 | |||
| 51 | |||
| 52 | /* translates key to keycode */ | ||
| 53 | uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key); | ||
| 54 | |||
| 55 | /* translates Fn keycode to action */ | ||
| 56 | action_t keymap_fn_to_action(uint16_t keycode); | ||
| 57 | |||
| 58 | /* translates Fn keycode to action */ | ||
| 59 | action_t keymap_func_to_action(uint16_t keycode); | ||
| 60 | |||
| 61 | extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; | ||
| 62 | extern const uint16_t fn_actions[]; | ||
| 63 | |||
| 64 | // Ability to use mods in layouts | ||
| 65 | #define LCTL(kc) kc | 0x0100 | ||
| 66 | #define LSFT(kc) kc | 0x0200 | ||
| 67 | #define LALT(kc) kc | 0x0400 | ||
| 68 | #define LGUI(kc) kc | 0x0800 | ||
| 69 | #define RCTL(kc) kc | 0x1100 | ||
| 70 | #define RSFT(kc) kc | 0x1200 | ||
| 71 | #define RALT(kc) kc | 0x1400 | ||
| 72 | #define RGUI(kc) kc | 0x1800 | ||
| 73 | |||
| 74 | // Alias for function layers than expand past FN31 | ||
| 75 | #define FUNC(kc) kc | 0x2000 | ||
| 76 | |||
| 77 | // Aliases | ||
| 78 | #define S(kc) LSFT(kc) | ||
| 79 | #define F(kc) FUNC(kc) | ||
| 80 | |||
| 81 | #define M(kc) kc | 0x3000 | ||
| 82 | |||
| 83 | #define MACRODOWN(...) (record->event.pressed ? MACRO(__VA_ARGS__) : MACRO_NONE) | ||
| 84 | |||
| 85 | #define BL_ON 0x4009 | ||
| 86 | #define BL_OFF 0x4000 | ||
| 87 | #define BL_0 0x4000 | ||
| 88 | #define BL_1 0x4001 | ||
| 89 | #define BL_2 0x4002 | ||
| 90 | #define BL_3 0x4003 | ||
| 91 | #define BL_4 0x4004 | ||
| 92 | #define BL_5 0x4005 | ||
| 93 | #define BL_6 0x4006 | ||
| 94 | #define BL_7 0x4007 | ||
| 95 | #define BL_8 0x4008 | ||
| 96 | #define BL_9 0x4009 | ||
| 97 | #define BL_10 0x400A | ||
| 98 | #define BL_11 0x400B | ||
| 99 | #define BL_12 0x400C | ||
| 100 | #define BL_13 0x400D | ||
| 101 | #define BL_14 0x400E | ||
| 102 | #define BL_15 0x400F | ||
| 103 | #define BL_DEC 0x4010 | ||
| 104 | #define BL_INC 0x4011 | ||
| 105 | #define BL_TOGG 0x4012 | ||
| 106 | #define BL_STEP 0x4013 | ||
| 107 | |||
| 108 | #define RESET 0x5000 | ||
| 109 | #define DEBUG 0x5001 | ||
| 110 | |||
| 111 | #define MIDI(n) (n | 0x6000) | ||
| 112 | |||
| 113 | #define UNI(n) (n | 0x8000) | ||
| 114 | |||
| 115 | #endif | ||
diff --git a/keyboard/planck/keymap_french.h b/keyboard/planck/keymap_french.h deleted file mode 100644 index ccfaed8f0..000000000 --- a/keyboard/planck/keymap_french.h +++ /dev/null | |||
| @@ -1,83 +0,0 @@ | |||
| 1 | #ifndef KEYMAP_FRENCH_H | ||
| 2 | #define KEYMAP_FRENCH_H | ||
| 3 | |||
| 4 | #include "keymap_common.h" | ||
| 5 | |||
| 6 | // Alt gr | ||
| 7 | #define ALGR(kc) kc | 0x1400 | ||
| 8 | #define NO_ALGR KC_RALT | ||
| 9 | |||
| 10 | // Normal characters | ||
| 11 | #define FR_SUP2 KC_GRV | ||
| 12 | #define FR_AMP KC_1 | ||
| 13 | #define FR_EACU KC_2 | ||
| 14 | #define FR_QUOT KC_3 | ||
| 15 | #define FR_APOS KC_4 | ||
| 16 | #define FR_LPRN KC_5 | ||
| 17 | #define FR_MINS KC_6 | ||
| 18 | #define FR_EGRV KC_7 | ||
| 19 | #define FR_UNDS KC_8 | ||
| 20 | #define FR_CCED KC_9 | ||
| 21 | #define FR_AGRV KC_0 | ||
| 22 | #define FR_RPRN KC_MINS | ||
| 23 | #define FR_EQL KC_EQL | ||
| 24 | |||
| 25 | #define FR_A KC_Q | ||
| 26 | #define FR_Z KC_W | ||
| 27 | #define FR_CIRC KC_LBRC | ||
| 28 | #define FR_DLR KC_RBRC | ||
| 29 | |||
| 30 | #define FR_Q KC_A | ||
| 31 | #define FR_M KC_SCLN | ||
| 32 | #define FR_UGRV KC_QUOT | ||
| 33 | #define FR_ASTR KC_NUHS | ||
| 34 | |||
| 35 | #define FR_LESS KC_NUBS | ||
| 36 | #define FR_W KC_Z | ||
| 37 | #define FR_COMM KC_M | ||
| 38 | #define FR_SCLN KC_COMM | ||
| 39 | #define FR_COLN KC_DOT | ||
| 40 | #define FR_EXLM KC_SLSH | ||
| 41 | |||
| 42 | // Shifted characters | ||
| 43 | #define FR_1 LSFT(KC_1) | ||
| 44 | #define FR_2 LSFT(KC_2) | ||
| 45 | #define FR_3 LSFT(KC_3) | ||
| 46 | #define FR_4 LSFT(KC_4) | ||
| 47 | #define FR_5 LSFT(KC_5) | ||
| 48 | #define FR_6 LSFT(KC_6) | ||
| 49 | #define FR_7 LSFT(KC_7) | ||
| 50 | #define FR_8 LSFT(KC_8) | ||
| 51 | #define FR_9 LSFT(KC_9) | ||
| 52 | #define FR_0 LSFT(KC_0) | ||
| 53 | #define FR_OVRR LSFT(FR_RPRN) | ||
| 54 | #define FR_PLUS LSFT(FR_EQL) | ||
| 55 | |||
| 56 | #define FR_UMLT LSFT(FR_CIRC) | ||
| 57 | #define FR_PND LSFT(FR_DLR) | ||
| 58 | #define FR_PERC LSFT(FR_UGRV) | ||
| 59 | #define FR_MU LSFT(FR_ASTR) | ||
| 60 | |||
| 61 | #define FR_GRTR LSFT(FR_LESS) | ||
| 62 | #define FR_QUES LSFT(FR_COMM) | ||
| 63 | #define FR_DOT LSFT(FR_SCLN) | ||
| 64 | #define FR_SLSH LSFT(FR_COLN) | ||
| 65 | #define FR_SECT LSFT(FR_EXLM) | ||
| 66 | |||
| 67 | // Alt Gr-ed characters | ||
| 68 | #define FR_TILD ALGR(KC_2) | ||
| 69 | #define FR_HASH ALGR(KC_3) | ||
| 70 | #define FR_LCBR ALGR(KC_4) | ||
| 71 | #define FR_LBRC ALGR(KC_5) | ||
| 72 | #define FR_PIPE ALGR(KC_6) | ||
| 73 | #define FR_GRV ALGR(KC_7) | ||
| 74 | #define FR_BSLS ALGR(KC_8) | ||
| 75 | #define FR_CIRC ALGR(KC_9) | ||
| 76 | #define FR_AT ALGR(KC_0) | ||
| 77 | #define FR_RBRC ALGR(FR_RPRN) | ||
| 78 | #define FR_LCBR ALGR(FR_EQL) | ||
| 79 | |||
| 80 | #define FR_EURO ALGR(KC_E) | ||
| 81 | #define FR_BULT ALGR(FR_DLR) | ||
| 82 | |||
| 83 | #endif \ No newline at end of file | ||
diff --git a/keyboard/planck/keymap_midi.c b/keyboard/planck/keymap_midi.c deleted file mode 100644 index b7eba3ab7..000000000 --- a/keyboard/planck/keymap_midi.c +++ /dev/null | |||
| @@ -1,110 +0,0 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2015 Jack Humbert <jack.humb@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #include "keymap_common.h" | ||
| 19 | #include "keymap_midi.h" | ||
| 20 | #include <lufa.h> | ||
| 21 | |||
| 22 | uint8_t starting_note = 0x0C; | ||
| 23 | int offset = 7; | ||
| 24 | |||
| 25 | void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) | ||
| 26 | { | ||
| 27 | if (id != 0) { | ||
| 28 | if (record->event.pressed) { | ||
| 29 | midi_send_noteon(&midi_device, opt, (id & 0xFF), 127); | ||
| 30 | } else { | ||
| 31 | midi_send_noteoff(&midi_device, opt, (id & 0xFF), 127); | ||
| 32 | } | ||
| 33 | } | ||
| 34 | |||
| 35 | if (record->event.key.col == (MATRIX_COLS - 1) && record->event.key.row == (MATRIX_ROWS - 1)) { | ||
| 36 | if (record->event.pressed) { | ||
| 37 | 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); | ||
| 39 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
| 40 | midi_send_cc(&midi_device, 1, 0x7B, 0); | ||
| 41 | midi_send_cc(&midi_device, 2, 0x7B, 0); | ||
| 42 | midi_send_cc(&midi_device, 3, 0x7B, 0); | ||
| 43 | midi_send_cc(&midi_device, 4, 0x7B, 0); | ||
| 44 | return; | ||
| 45 | } 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))); | ||
| 47 | stop_all_notes(); | ||
| 48 | return; | ||
| 49 | } | ||
| 50 | } | ||
| 51 | if (record->event.key.col == (MATRIX_COLS - 2) && record->event.key.row == (MATRIX_ROWS - 1)) { | ||
| 52 | if (record->event.pressed) { | ||
| 53 | 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); | ||
| 55 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
| 56 | midi_send_cc(&midi_device, 1, 0x7B, 0); | ||
| 57 | midi_send_cc(&midi_device, 2, 0x7B, 0); | ||
| 58 | midi_send_cc(&midi_device, 3, 0x7B, 0); | ||
| 59 | midi_send_cc(&midi_device, 4, 0x7B, 0); | ||
| 60 | return; | ||
| 61 | } 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))); | ||
| 63 | stop_all_notes(); | ||
| 64 | return; | ||
| 65 | } | ||
| 66 | } | ||
| 67 | |||
| 68 | if (record->event.key.col == (MATRIX_COLS - 3) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) { | ||
| 69 | offset++; | ||
| 70 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
| 71 | midi_send_cc(&midi_device, 1, 0x7B, 0); | ||
| 72 | midi_send_cc(&midi_device, 2, 0x7B, 0); | ||
| 73 | midi_send_cc(&midi_device, 3, 0x7B, 0); | ||
| 74 | midi_send_cc(&midi_device, 4, 0x7B, 0); | ||
| 75 | stop_all_notes(); | ||
| 76 | 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); | ||
| 78 | _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))); | ||
| 80 | _delay_us(8000); | ||
| 81 | } | ||
| 82 | return; | ||
| 83 | } | ||
| 84 | if (record->event.key.col == (MATRIX_COLS - 4) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) { | ||
| 85 | offset--; | ||
| 86 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
| 87 | midi_send_cc(&midi_device, 1, 0x7B, 0); | ||
| 88 | midi_send_cc(&midi_device, 2, 0x7B, 0); | ||
| 89 | midi_send_cc(&midi_device, 3, 0x7B, 0); | ||
| 90 | midi_send_cc(&midi_device, 4, 0x7B, 0); | ||
| 91 | stop_all_notes(); | ||
| 92 | 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); | ||
| 94 | _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))); | ||
| 96 | _delay_us(8000); | ||
| 97 | } | ||
| 98 | return; | ||
| 99 | } | ||
| 100 | |||
| 101 | if (record->event.pressed) { | ||
| 102 | // 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); | ||
| 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); | ||
| 105 | } else { | ||
| 106 | // 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); | ||
| 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))); | ||
| 109 | } | ||
| 110 | } \ No newline at end of file | ||
diff --git a/keyboard/planck/keymap_midi.h b/keyboard/planck/keymap_midi.h deleted file mode 100644 index c5917f884..000000000 --- a/keyboard/planck/keymap_midi.h +++ /dev/null | |||
| @@ -1,220 +0,0 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2015 Jack Humbert <jack.humb@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #ifndef KEYMAP_MIDI_H | ||
| 19 | #define KEYMAP_MIDI_H | ||
| 20 | |||
| 21 | #define MIDI 0x6000 | ||
| 22 | #define MIDI12 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000 | ||
| 23 | |||
| 24 | #define CHNL(note, channel) (note + (channel << 8)) | ||
| 25 | |||
| 26 | #define SCALE (int []){ 0 + (12*0), 2 + (12*0), 4 + (12*0), 5 + (12*0), 7 + (12*0), 9 + (12*0), 11 + (12*0), \ | ||
| 27 | 0 + (12*1), 2 + (12*1), 4 + (12*1), 5 + (12*1), 7 + (12*1), 9 + (12*1), 11 + (12*1), \ | ||
| 28 | 0 + (12*2), 2 + (12*2), 4 + (12*2), 5 + (12*2), 7 + (12*2), 9 + (12*2), 11 + (12*2), \ | ||
| 29 | 0 + (12*3), 2 + (12*3), 4 + (12*3), 5 + (12*3), 7 + (12*3), 9 + (12*3), 11 + (12*3), \ | ||
| 30 | 0 + (12*4), 2 + (12*4), 4 + (12*4), 5 + (12*4), 7 + (12*4), 9 + (12*4), 11 + (12*4), } | ||
| 31 | |||
| 32 | #define N_CN1 (0x600C + (12 * -1) + 0 ) | ||
| 33 | #define N_CN1S (0x600C + (12 * -1) + 1 ) | ||
| 34 | #define N_DN1F (0x600C + (12 * -1) + 1 ) | ||
| 35 | #define N_DN1 (0x600C + (12 * -1) + 2 ) | ||
| 36 | #define N_DN1S (0x600C + (12 * -1) + 3 ) | ||
| 37 | #define N_EN1F (0x600C + (12 * -1) + 3 ) | ||
| 38 | #define N_EN1 (0x600C + (12 * -1) + 4 ) | ||
| 39 | #define N_FN1 (0x600C + (12 * -1) + 5 ) | ||
| 40 | #define N_FN1S (0x600C + (12 * -1) + 6 ) | ||
| 41 | #define N_GN1F (0x600C + (12 * -1) + 6 ) | ||
| 42 | #define N_GN1 (0x600C + (12 * -1) + 7 ) | ||
| 43 | #define N_GN1S (0x600C + (12 * -1) + 8 ) | ||
| 44 | #define N_AN1F (0x600C + (12 * -1) + 8 ) | ||
| 45 | #define N_AN1 (0x600C + (12 * -1) + 9 ) | ||
| 46 | #define N_AN1S (0x600C + (12 * -1) + 10) | ||
| 47 | #define N_BN1F (0x600C + (12 * -1) + 10) | ||
| 48 | #define N_BN1 (0x600C + (12 * -1) + 11) | ||
| 49 | #define N_C0 (0x600C + (12 * 0) + 0 ) | ||
| 50 | #define N_C0S (0x600C + (12 * 0) + 1 ) | ||
| 51 | #define N_D0F (0x600C + (12 * 0) + 1 ) | ||
| 52 | #define N_D0 (0x600C + (12 * 0) + 2 ) | ||
| 53 | #define N_D0S (0x600C + (12 * 0) + 3 ) | ||
| 54 | #define N_E0F (0x600C + (12 * 0) + 3 ) | ||
| 55 | #define N_E0 (0x600C + (12 * 0) + 4 ) | ||
| 56 | #define N_F0 (0x600C + (12 * 0) + 5 ) | ||
| 57 | #define N_F0S (0x600C + (12 * 0) + 6 ) | ||
| 58 | #define N_G0F (0x600C + (12 * 0) + 6 ) | ||
| 59 | #define N_G0 (0x600C + (12 * 0) + 7 ) | ||
| 60 | #define N_G0S (0x600C + (12 * 0) + 8 ) | ||
| 61 | #define N_A0F (0x600C + (12 * 0) + 8 ) | ||
| 62 | #define N_A0 (0x600C + (12 * 0) + 9 ) | ||
| 63 | #define N_A0S (0x600C + (12 * 0) + 10) | ||
| 64 | #define N_B0F (0x600C + (12 * 0) + 10) | ||
| 65 | #define N_B0 (0x600C + (12 * 0) + 11) | ||
| 66 | #define N_C1 (0x600C + (12 * 1) + 0 ) | ||
| 67 | #define N_C1S (0x600C + (12 * 1) + 1 ) | ||
| 68 | #define N_D1F (0x600C + (12 * 1) + 1 ) | ||
| 69 | #define N_D1 (0x600C + (12 * 1) + 2 ) | ||
| 70 | #define N_D1S (0x600C + (12 * 1) + 3 ) | ||
| 71 | #define N_E1F (0x600C + (12 * 1) + 3 ) | ||
| 72 | #define N_E1 (0x600C + (12 * 1) + 4 ) | ||
| 73 | #define N_F1 (0x600C + (12 * 1) + 5 ) | ||
| 74 | #define N_F1S (0x600C + (12 * 1) + 6 ) | ||
| 75 | #define N_G1F (0x600C + (12 * 1) + 6 ) | ||
| 76 | #define N_G1 (0x600C + (12 * 1) + 7 ) | ||
| 77 | #define N_G1S (0x600C + (12 * 1) + 8 ) | ||
| 78 | #define N_A1F (0x600C + (12 * 1) + 8 ) | ||
| 79 | #define N_A1 (0x600C + (12 * 1) + 9 ) | ||
| 80 | #define N_A1S (0x600C + (12 * 1) + 10) | ||
| 81 | #define N_B1F (0x600C + (12 * 1) + 10) | ||
| 82 | #define N_B1 (0x600C + (12 * 1) + 11) | ||
| 83 | #define N_C2 (0x600C + (12 * 2) + 0 ) | ||
| 84 | #define N_C2S (0x600C + (12 * 2) + 1 ) | ||
| 85 | #define N_D2F (0x600C + (12 * 2) + 1 ) | ||
| 86 | #define N_D2 (0x600C + (12 * 2) + 2 ) | ||
| 87 | #define N_D2S (0x600C + (12 * 2) + 3 ) | ||
| 88 | #define N_E2F (0x600C + (12 * 2) + 3 ) | ||
| 89 | #define N_E2 (0x600C + (12 * 2) + 4 ) | ||
| 90 | #define N_F2 (0x600C + (12 * 2) + 5 ) | ||
| 91 | #define N_F2S (0x600C + (12 * 2) + 6 ) | ||
| 92 | #define N_G2F (0x600C + (12 * 2) + 6 ) | ||
| 93 | #define N_G2 (0x600C + (12 * 2) + 7 ) | ||
| 94 | #define N_G2S (0x600C + (12 * 2) + 8 ) | ||
| 95 | #define N_A2F (0x600C + (12 * 2) + 8 ) | ||
| 96 | #define N_A2 (0x600C + (12 * 2) + 9 ) | ||
| 97 | #define N_A2S (0x600C + (12 * 2) + 10) | ||
| 98 | #define N_B2F (0x600C + (12 * 2) + 10) | ||
| 99 | #define N_B2 (0x600C + (12 * 2) + 11) | ||
| 100 | #define N_C3 (0x600C + (12 * 3) + 0 ) | ||
| 101 | #define N_C3S (0x600C + (12 * 3) + 1 ) | ||
| 102 | #define N_D3F (0x600C + (12 * 3) + 1 ) | ||
| 103 | #define N_D3 (0x600C + (12 * 3) + 2 ) | ||
| 104 | #define N_D3S (0x600C + (12 * 3) + 3 ) | ||
| 105 | #define N_E3F (0x600C + (12 * 3) + 3 ) | ||
| 106 | #define N_E3 (0x600C + (12 * 3) + 4 ) | ||
| 107 | #define N_F3 (0x600C + (12 * 3) + 5 ) | ||
| 108 | #define N_F3S (0x600C + (12 * 3) + 6 ) | ||
| 109 | #define N_G3F (0x600C + (12 * 3) + 6 ) | ||
| 110 | #define N_G3 (0x600C + (12 * 3) + 7 ) | ||
| 111 | #define N_G3S (0x600C + (12 * 3) + 8 ) | ||
| 112 | #define N_A3F (0x600C + (12 * 3) + 8 ) | ||
| 113 | #define N_A3 (0x600C + (12 * 3) + 9 ) | ||
| 114 | #define N_A3S (0x600C + (12 * 3) + 10) | ||
| 115 | #define N_B3F (0x600C + (12 * 3) + 10) | ||
| 116 | #define N_B3 (0x600C + (12 * 3) + 11) | ||
| 117 | #define N_C4 (0x600C + (12 * 4) + 0 ) | ||
| 118 | #define N_C4S (0x600C + (12 * 4) + 1 ) | ||
| 119 | #define N_D4F (0x600C + (12 * 4) + 1 ) | ||
| 120 | #define N_D4 (0x600C + (12 * 4) + 2 ) | ||
| 121 | #define N_D4S (0x600C + (12 * 4) + 3 ) | ||
| 122 | #define N_E4F (0x600C + (12 * 4) + 3 ) | ||
| 123 | #define N_E4 (0x600C + (12 * 4) + 4 ) | ||
| 124 | #define N_F4 (0x600C + (12 * 4) + 5 ) | ||
| 125 | #define N_F4S (0x600C + (12 * 4) + 6 ) | ||
| 126 | #define N_G4F (0x600C + (12 * 4) + 6 ) | ||
| 127 | #define N_G4 (0x600C + (12 * 4) + 7 ) | ||
| 128 | #define N_G4S (0x600C + (12 * 4) + 8 ) | ||
| 129 | #define N_A4F (0x600C + (12 * 4) + 8 ) | ||
| 130 | #define N_A4 (0x600C + (12 * 4) + 9 ) | ||
| 131 | #define N_A4S (0x600C + (12 * 4) + 10) | ||
| 132 | #define N_B4F (0x600C + (12 * 4) + 10) | ||
| 133 | #define N_B4 (0x600C + (12 * 4) + 11) | ||
| 134 | #define N_C5 (0x600C + (12 * 5) + 0 ) | ||
| 135 | #define N_C5S (0x600C + (12 * 5) + 1 ) | ||
| 136 | #define N_D5F (0x600C + (12 * 5) + 1 ) | ||
| 137 | #define N_D5 (0x600C + (12 * 5) + 2 ) | ||
| 138 | #define N_D5S (0x600C + (12 * 5) + 3 ) | ||
| 139 | #define N_E5F (0x600C + (12 * 5) + 3 ) | ||
| 140 | #define N_E5 (0x600C + (12 * 5) + 4 ) | ||
| 141 | #define N_F5 (0x600C + (12 * 5) + 5 ) | ||
| 142 | #define N_F5S (0x600C + (12 * 5) + 6 ) | ||
| 143 | #define N_G5F (0x600C + (12 * 5) + 6 ) | ||
| 144 | #define N_G5 (0x600C + (12 * 5) + 7 ) | ||
| 145 | #define N_G5S (0x600C + (12 * 5) + 8 ) | ||
| 146 | #define N_A5F (0x600C + (12 * 5) + 8 ) | ||
| 147 | #define N_A5 (0x600C + (12 * 5) + 9 ) | ||
| 148 | #define N_A5S (0x600C + (12 * 5) + 10) | ||
| 149 | #define N_B5F (0x600C + (12 * 5) + 10) | ||
| 150 | #define N_B5 (0x600C + (12 * 5) + 11) | ||
| 151 | #define N_C6 (0x600C + (12 * 6) + 0 ) | ||
| 152 | #define N_C6S (0x600C + (12 * 6) + 1 ) | ||
| 153 | #define N_D6F (0x600C + (12 * 6) + 1 ) | ||
| 154 | #define N_D6 (0x600C + (12 * 6) + 2 ) | ||
| 155 | #define N_D6S (0x600C + (12 * 6) + 3 ) | ||
| 156 | #define N_E6F (0x600C + (12 * 6) + 3 ) | ||
| 157 | #define N_E6 (0x600C + (12 * 6) + 4 ) | ||
| 158 | #define N_F6 (0x600C + (12 * 6) + 5 ) | ||
| 159 | #define N_F6S (0x600C + (12 * 6) + 6 ) | ||
| 160 | #define N_G6F (0x600C + (12 * 6) + 6 ) | ||
| 161 | #define N_G6 (0x600C + (12 * 6) + 7 ) | ||
| 162 | #define N_G6S (0x600C + (12 * 6) + 8 ) | ||
| 163 | #define N_A6F (0x600C + (12 * 6) + 8 ) | ||
| 164 | #define N_A6 (0x600C + (12 * 6) + 9 ) | ||
| 165 | #define N_A6S (0x600C + (12 * 6) + 10) | ||
| 166 | #define N_B6F (0x600C + (12 * 6) + 10) | ||
| 167 | #define N_B6 (0x600C + (12 * 6) + 11) | ||
| 168 | #define N_C7 (0x600C + (12 * 7) + 0 ) | ||
| 169 | #define N_C7S (0x600C + (12 * 7) + 1 ) | ||
| 170 | #define N_D7F (0x600C + (12 * 7) + 1 ) | ||
| 171 | #define N_D7 (0x600C + (12 * 7) + 2 ) | ||
| 172 | #define N_D7S (0x600C + (12 * 7) + 3 ) | ||
| 173 | #define N_E7F (0x600C + (12 * 7) + 3 ) | ||
| 174 | #define N_E7 (0x600C + (12 * 7) + 4 ) | ||
| 175 | #define N_F7 (0x600C + (12 * 7) + 5 ) | ||
| 176 | #define N_F7S (0x600C + (12 * 7) + 6 ) | ||
| 177 | #define N_G7F (0x600C + (12 * 7) + 6 ) | ||
| 178 | #define N_G7 (0x600C + (12 * 7) + 7 ) | ||
| 179 | #define N_G7S (0x600C + (12 * 7) + 8 ) | ||
| 180 | #define N_A7F (0x600C + (12 * 7) + 8 ) | ||
| 181 | #define N_A7 (0x600C + (12 * 7) + 9 ) | ||
| 182 | #define N_A7S (0x600C + (12 * 7) + 10) | ||
| 183 | #define N_B7F (0x600C + (12 * 7) + 10) | ||
| 184 | #define N_B7 (0x600C + (12 * 7) + 11) | ||
| 185 | #define N_C8 (0x600C + (12 * 8) + 0 ) | ||
| 186 | #define N_C8S (0x600C + (12 * 8) + 1 ) | ||
| 187 | #define N_D8F (0x600C + (12 * 8) + 1 ) | ||
| 188 | #define N_D8 (0x600C + (12 * 8) + 2 ) | ||
| 189 | #define N_D8S (0x600C + (12 * 8) + 3 ) | ||
| 190 | #define N_E8F (0x600C + (12 * 8) + 3 ) | ||
| 191 | #define N_E8 (0x600C + (12 * 8) + 4 ) | ||
| 192 | #define N_F8 (0x600C + (12 * 8) + 5 ) | ||
| 193 | #define N_F8S (0x600C + (12 * 8) + 6 ) | ||
| 194 | #define N_G8F (0x600C + (12 * 8) + 6 ) | ||
| 195 | #define N_G8 (0x600C + (12 * 8) + 7 ) | ||
| 196 | #define N_G8S (0x600C + (12 * 8) + 8 ) | ||
| 197 | #define N_A8F (0x600C + (12 * 8) + 8 ) | ||
| 198 | #define N_A8 (0x600C + (12 * 8) + 9 ) | ||
| 199 | #define N_A8S (0x600C + (12 * 8) + 10) | ||
| 200 | #define N_B8F (0x600C + (12 * 8) + 10) | ||
| 201 | #define N_B8 (0x600C + (12 * 8) + 11) | ||
| 202 | #define N_C8 (0x600C + (12 * 8) + 0 ) | ||
| 203 | #define N_C8S (0x600C + (12 * 8) + 1 ) | ||
| 204 | #define N_D8F (0x600C + (12 * 8) + 1 ) | ||
| 205 | #define N_D8 (0x600C + (12 * 8) + 2 ) | ||
| 206 | #define N_D8S (0x600C + (12 * 8) + 3 ) | ||
| 207 | #define N_E8F (0x600C + (12 * 8) + 3 ) | ||
| 208 | #define N_E8 (0x600C + (12 * 8) + 4 ) | ||
| 209 | #define N_F8 (0x600C + (12 * 8) + 5 ) | ||
| 210 | #define N_F8S (0x600C + (12 * 8) + 6 ) | ||
| 211 | #define N_G8F (0x600C + (12 * 8) + 6 ) | ||
| 212 | #define N_G8 (0x600C + (12 * 8) + 7 ) | ||
| 213 | #define N_G8S (0x600C + (12 * 8) + 8 ) | ||
| 214 | #define N_A8F (0x600C + (12 * 8) + 8 ) | ||
| 215 | #define N_A8 (0x600C + (12 * 8) + 9 ) | ||
| 216 | #define N_A8S (0x600C + (12 * 8) + 10) | ||
| 217 | #define N_B8F (0x600C + (12 * 8) + 10) | ||
| 218 | #define N_B8 (0x600C + (12 * 8) + 11) | ||
| 219 | |||
| 220 | #endif \ No newline at end of file | ||
diff --git a/keyboard/planck/keymap_nordic.h b/keyboard/planck/keymap_nordic.h deleted file mode 100644 index 02a704216..000000000 --- a/keyboard/planck/keymap_nordic.h +++ /dev/null | |||
| @@ -1,59 +0,0 @@ | |||
| 1 | #ifndef KEYMAP_NORDIC_H | ||
| 2 | #define KEYMAP_NORDIC_H | ||
| 3 | |||
| 4 | #include "keymap_common.h" | ||
| 5 | |||
| 6 | // Alt gr | ||
| 7 | #define ALGR(kc) kc | 0x1400 | ||
| 8 | #define NO_ALGR KC_RALT | ||
| 9 | |||
| 10 | // Normal characters | ||
| 11 | #define NO_HALF KC_GRV | ||
| 12 | #define NO_PLUS KC_MINS | ||
| 13 | #define NO_ACUT KC_EQL | ||
| 14 | |||
| 15 | #define NO_AM KC_LBRC | ||
| 16 | #define NO_QUOT KC_RBRC | ||
| 17 | #define NO_AE KC_SCLN | ||
| 18 | #define NO_OSLH KC_QUOT | ||
| 19 | #define NO_APOS KC_NUHS | ||
| 20 | |||
| 21 | #define NO_LESS KC_NUBS | ||
| 22 | #define NO_MINS KC_SLSH | ||
| 23 | |||
| 24 | // Shifted characters | ||
| 25 | #define NO_SECT LSFT(NO_HALF) | ||
| 26 | #define NO_QUO2 LSFT(KC_2) | ||
| 27 | #define NO_BULT LSFT(KC_4) | ||
| 28 | #define NO_AMP LSFT(KC_6) | ||
| 29 | #define NO_SLSH LSFT(KC_7) | ||
| 30 | #define NO_LPRN LSFT(KC_8) | ||
| 31 | #define NO_RPRN LSFT(KC_9) | ||
| 32 | #define NO_EQL LSFT(KC_0) | ||
| 33 | #define NO_QUES LSFT(NO_PLUS) | ||
| 34 | #define NO_GRV LSFT(NO_ACUT) | ||
| 35 | |||
| 36 | #define NO_CIRC LSFT(NO_QUOT) | ||
| 37 | |||
| 38 | #define NO_GRTR LSFT(NO_LESS) | ||
| 39 | #define NO_SCLN LSFT(KC_COMM) | ||
| 40 | #define NO_COLN LSFT(KC_DOT) | ||
| 41 | #define NO_UNDS LSFT(NO_MINS) | ||
| 42 | |||
| 43 | // Alt Gr-ed characters | ||
| 44 | #define NO_AT ALGR(KC_2) | ||
| 45 | #define NO_PND ALGR(KC_3) | ||
| 46 | #define NO_DLR ALGR(KC_4) | ||
| 47 | #define NO_LCBR ALGR(KC_7) | ||
| 48 | #define NO_LBRC ALGR(KC_8) | ||
| 49 | #define NO_RBRC ALGR(KC_9) | ||
| 50 | #define NO_RCBR ALGR(KC_0) | ||
| 51 | #define NO_PIPE ALGR(NO_ACUT) | ||
| 52 | |||
| 53 | #define NO_EURO ALGR(KC_E) | ||
| 54 | #define NO_TILD ALGR(NO_QUOT) | ||
| 55 | |||
| 56 | #define NO_BSLS ALGR(NO_LESS) | ||
| 57 | #define NO_MU ALGR(KC_M) | ||
| 58 | |||
| 59 | #endif \ No newline at end of file | ||
diff --git a/keyboard/planck/keymap_spanish.h b/keyboard/planck/keymap_spanish.h deleted file mode 100644 index 7f980afbc..000000000 --- a/keyboard/planck/keymap_spanish.h +++ /dev/null | |||
| @@ -1,62 +0,0 @@ | |||
| 1 | #ifndef KEYMAP_SPANISH_H | ||
| 2 | #define KEYMAP_SPANISH_H | ||
| 3 | |||
| 4 | #include "keymap_common.h" | ||
| 5 | |||
| 6 | // Alt gr | ||
| 7 | #define ALGR(kc) kc | 0x1400 | ||
| 8 | #define NO_ALGR KC_RALT | ||
| 9 | |||
| 10 | // Normal characters | ||
| 11 | #define ES_OVRR KC_GRV | ||
| 12 | #define ES_APOS KC_MINS | ||
| 13 | #define ES_IEXL KC_EQL | ||
| 14 | |||
| 15 | #define ES_GRV KC_LBRC | ||
| 16 | #define ES_PLUS KC_RBRC | ||
| 17 | |||
| 18 | #define ES_NTIL KC_SCLN | ||
| 19 | #define ES_ACUT KC_QUOT | ||
| 20 | #define ES_CCED KC_NUHS | ||
| 21 | |||
| 22 | #define ES_LESS KC_NUBS | ||
| 23 | #define ES_MINS KC_SLSH | ||
| 24 | |||
| 25 | // Shifted characters | ||
| 26 | #define ES_ASML LSFT(ES_OVRR) | ||
| 27 | #define ES_QUOT LSFT(KC_2) | ||
| 28 | #define ES_OVDT LSFT(KC_3) | ||
| 29 | #define ES_AMPR LSFT(KC_6) | ||
| 30 | #define ES_SLSH LSFT(KC_7) | ||
| 31 | #define ES_LPRN LSFT(KC_8) | ||
| 32 | #define ES_RPRN LSFT(KC_9) | ||
| 33 | #define ES_EQL LSFT(KC_0) | ||
| 34 | #define ES_QUES LSFT(ES_APOS) | ||
| 35 | #define ES_IQUE LSFT(ES_IEXL) | ||
| 36 | |||
| 37 | #define ES_CIRC LSFT(ES_GRV) | ||
| 38 | #define ES_ASTR LSFT(ES_PLUS) | ||
| 39 | |||
| 40 | #define ES_UMLT LSFT(ES_GRV) | ||
| 41 | |||
| 42 | #define ES_GRTR LSFT(ES_LESS) | ||
| 43 | #define ES_SCLN LSFT(ES_COMM) | ||
| 44 | #define ES_COLN LSFT(ES_DOT) | ||
| 45 | #define ES_UNDS LSFT(ES_MINS) | ||
| 46 | |||
| 47 | // Alt Gr-ed characters | ||
| 48 | #define ES_BSLS ALGR(ES_OVRR) | ||
| 49 | #define ES_PIPE ALGR(KC_1) | ||
| 50 | #define ES_AT ALGR(KC_2) | ||
| 51 | #define ES_HASH ALGR(KC_3) | ||
| 52 | #define ES_TILD ALGR(KC_4) | ||
| 53 | #define ES_EURO ALGR(KC_5) | ||
| 54 | #define ES_NOT ALGR(KC_6) | ||
| 55 | |||
| 56 | #define ES_LBRC ALGR(ES_GRV) | ||
| 57 | #define ES_RBRC ALGR(ES_PLUS) | ||
| 58 | |||
| 59 | #define ES_LCBR ALGR(ES_ACUT) | ||
| 60 | #define ES_RCRB ALGR(ES_CCED) | ||
| 61 | |||
| 62 | #endif \ No newline at end of file | ||
diff --git a/keyboard/planck/keymap_unicode.c b/keyboard/planck/keymap_unicode.c deleted file mode 100644 index a9357edec..000000000 --- a/keyboard/planck/keymap_unicode.c +++ /dev/null | |||
| @@ -1,59 +0,0 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2015 Jack Humbert <jack.humb@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #include "keymap_common.h" | ||
| 19 | |||
| 20 | uint16_t hextokeycode(int hex) { | ||
| 21 | if (hex == 0x0) { | ||
| 22 | return KC_0; | ||
| 23 | } else if (hex < 0xA) { | ||
| 24 | return KC_1 + (hex - 0x1); | ||
| 25 | } else { | ||
| 26 | return KC_A + (hex - 0xA); | ||
| 27 | } | ||
| 28 | } | ||
| 29 | |||
| 30 | void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) | ||
| 31 | { | ||
| 32 | |||
| 33 | if (record->event.pressed) { | ||
| 34 | uint16_t unicode = (opt << 8) | id; | ||
| 35 | register_code(KC_LALT); | ||
| 36 | |||
| 37 | register_code(hextokeycode((unicode & 0xF000) >> 12)); | ||
| 38 | unregister_code(hextokeycode((unicode & 0xF000) >> 12)); | ||
| 39 | register_code(hextokeycode((unicode & 0x0F00) >> 8)); | ||
| 40 | unregister_code(hextokeycode((unicode & 0x0F00) >> 8)); | ||
| 41 | register_code(hextokeycode((unicode & 0x00F0) >> 4)); | ||
| 42 | unregister_code(hextokeycode((unicode & 0x00F0) >> 4)); | ||
| 43 | register_code(hextokeycode((unicode & 0x000F))); | ||
| 44 | unregister_code(hextokeycode((unicode & 0x000F))); | ||
| 45 | |||
| 46 | /* Test 'a' */ | ||
| 47 | // register_code(hextokeycode(0x0)); | ||
| 48 | // unregister_code(hextokeycode(0x0)); | ||
| 49 | // register_code(hextokeycode(0x0)); | ||
| 50 | // unregister_code(hextokeycode(0x0)); | ||
| 51 | // register_code(hextokeycode(0x6)); | ||
| 52 | // unregister_code(hextokeycode(0x6)); | ||
| 53 | // register_code(hextokeycode(0x1)); | ||
| 54 | // unregister_code(hextokeycode(0x1)); | ||
| 55 | |||
| 56 | unregister_code(KC_LALT); | ||
| 57 | } | ||
| 58 | return; | ||
| 59 | } \ No newline at end of file | ||
diff --git a/keyboard/planck/keymaps/keymap_default.c b/keyboard/planck/keymaps/keymap_default.c index 3670be338..edfc21d0a 100644 --- a/keyboard/planck/keymaps/keymap_default.c +++ b/keyboard/planck/keymaps/keymap_default.c | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #include "keymap_common.h" | 1 | #include "planck.h" |
| 2 | #include "backlight.h" | 2 | #include "backlight.h" |
| 3 | #include "debug.h" | ||
| 4 | 3 | ||
| 5 | #define QWERTY_LAYER 0 | 4 | #define QWERTY_LAYER 0 |
| 6 | #define COLEMAK_LAYER 1 | 5 | #define COLEMAK_LAYER 1 |
diff --git a/keyboard/planck/led.c b/keyboard/planck/led.c deleted file mode 100644 index 2c0574660..000000000 --- a/keyboard/planck/led.c +++ /dev/null | |||
| @@ -1,38 +0,0 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2012 Jun Wako <wakojun@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #include <avr/io.h> | ||
| 19 | #include "stdint.h" | ||
| 20 | #include "led.h" | ||
| 21 | |||
| 22 | |||
| 23 | void led_set(uint8_t usb_led) | ||
| 24 | { | ||
| 25 | // // Using PE6 Caps Lock LED | ||
| 26 | // if (usb_led & (1<<USB_LED_CAPS_LOCK)) | ||
| 27 | // { | ||
| 28 | // // Output high. | ||
| 29 | // DDRE |= (1<<6); | ||
| 30 | // PORTE |= (1<<6); | ||
| 31 | // } | ||
| 32 | // else | ||
| 33 | // { | ||
| 34 | // // Output low. | ||
| 35 | // DDRE &= ~(1<<6); | ||
| 36 | // PORTE &= ~(1<<6); | ||
| 37 | // } | ||
| 38 | } | ||
diff --git a/keyboard/planck/matrix.c b/keyboard/planck/matrix.c deleted file mode 100644 index 12a158543..000000000 --- a/keyboard/planck/matrix.c +++ /dev/null | |||
| @@ -1,299 +0,0 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2012 Jun Wako | ||
| 3 | Generated by planckkeyboard.com (2014 Jack Humbert) | ||
| 4 | |||
| 5 | This program is free software: you can redistribute it and/or modify | ||
| 6 | it under the terms of the GNU General Public License as published by | ||
| 7 | the Free Software Foundation, either version 2 of the License, or | ||
| 8 | (at your option) any later version. | ||
| 9 | |||
| 10 | This program is distributed in the hope that it will be useful, | ||
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | GNU General Public License for more details. | ||
| 14 | |||
| 15 | You should have received a copy of the GNU General Public License | ||
| 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 17 | */ | ||
| 18 | |||
| 19 | /* | ||
| 20 | * scan matrix | ||
| 21 | */ | ||
| 22 | #include <stdint.h> | ||
| 23 | #include <stdbool.h> | ||
| 24 | #include <avr/io.h> | ||
| 25 | #include <util/delay.h> | ||
| 26 | #include "print.h" | ||
| 27 | #include "debug.h" | ||
| 28 | #include "util.h" | ||
| 29 | #include "matrix.h" | ||
| 30 | |||
| 31 | #ifndef DEBOUNCE | ||
| 32 | # define DEBOUNCE 10 | ||
| 33 | #endif | ||
| 34 | static uint8_t debouncing = DEBOUNCE; | ||
| 35 | |||
| 36 | /* matrix state(1:on, 0:off) */ | ||
| 37 | static matrix_row_t matrix[MATRIX_ROWS]; | ||
| 38 | static matrix_row_t matrix_debouncing[MATRIX_ROWS]; | ||
| 39 | |||
| 40 | #if DIODE_DIRECTION == ROW2COL | ||
| 41 | static matrix_row_t matrix_reversed[MATRIX_COLS]; | ||
| 42 | static matrix_row_t matrix_reversed_debouncing[MATRIX_COLS]; | ||
| 43 | #endif | ||
| 44 | |||
| 45 | static matrix_row_t read_cols(void); | ||
| 46 | static void init_cols(void); | ||
| 47 | static void unselect_rows(void); | ||
| 48 | static void select_row(uint8_t row); | ||
| 49 | |||
| 50 | inline | ||
| 51 | uint8_t matrix_rows(void) | ||
| 52 | { | ||
| 53 | return MATRIX_ROWS; | ||
| 54 | } | ||
| 55 | |||
| 56 | inline | ||
| 57 | uint8_t matrix_cols(void) | ||
| 58 | { | ||
| 59 | return MATRIX_COLS; | ||
| 60 | } | ||
| 61 | |||
| 62 | void matrix_init(void) | ||
| 63 | { | ||
| 64 | // To use PORTF disable JTAG with writing JTD bit twice within four cycles. | ||
| 65 | MCUCR |= (1<<JTD); | ||
| 66 | MCUCR |= (1<<JTD); | ||
| 67 | |||
| 68 | #ifdef BACKLIGHT_ENABLE | ||
| 69 | backlight_init_ports(); | ||
| 70 | #endif | ||
| 71 | |||
| 72 | // Turn status LED on | ||
| 73 | DDRE |= (1<<6); | ||
| 74 | PORTE |= (1<<6); | ||
| 75 | |||
| 76 | // initialize row and col | ||
| 77 | unselect_rows(); | ||
| 78 | init_cols(); | ||
| 79 | |||
| 80 | // initialize matrix state: all keys off | ||
| 81 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { | ||
| 82 | matrix[i] = 0; | ||
| 83 | matrix_debouncing[i] = 0; | ||
| 84 | } | ||
| 85 | } | ||
| 86 | |||
| 87 | |||
| 88 | uint8_t matrix_scan(void) | ||
| 89 | { | ||
| 90 | #if DIODE_DIRECTION == COL2ROW | ||
| 91 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 92 | select_row(i); | ||
| 93 | _delay_us(30); // without this wait read unstable value. | ||
| 94 | matrix_row_t cols = read_cols(); | ||
| 95 | if (matrix_debouncing[i] != cols) { | ||
| 96 | matrix_debouncing[i] = cols; | ||
| 97 | if (debouncing) { | ||
| 98 | debug("bounce!: "); debug_hex(debouncing); debug("\n"); | ||
| 99 | } | ||
| 100 | debouncing = DEBOUNCE; | ||
| 101 | } | ||
| 102 | unselect_rows(); | ||
| 103 | } | ||
| 104 | |||
| 105 | if (debouncing) { | ||
| 106 | if (--debouncing) { | ||
| 107 | _delay_ms(1); | ||
| 108 | } else { | ||
| 109 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 110 | matrix[i] = matrix_debouncing[i]; | ||
| 111 | } | ||
| 112 | } | ||
| 113 | } | ||
| 114 | #else | ||
| 115 | for (uint8_t i = 0; i < MATRIX_COLS; i++) { | ||
| 116 | select_row(i); | ||
| 117 | _delay_us(30); // without this wait read unstable value. | ||
| 118 | matrix_row_t rows = read_cols(); | ||
| 119 | if (matrix_reversed_debouncing[i] != rows) { | ||
| 120 | matrix_reversed_debouncing[i] = rows; | ||
| 121 | if (debouncing) { | ||
| 122 | debug("bounce!: "); debug_hex(debouncing); debug("\n"); | ||
| 123 | } | ||
| 124 | debouncing = DEBOUNCE; | ||
| 125 | } | ||
| 126 | unselect_rows(); | ||
| 127 | } | ||
| 128 | |||
| 129 | if (debouncing) { | ||
| 130 | if (--debouncing) { | ||
| 131 | _delay_ms(1); | ||
| 132 | } else { | ||
| 133 | for (uint8_t i = 0; i < MATRIX_COLS; i++) { | ||
| 134 | matrix_reversed[i] = matrix_reversed_debouncing[i]; | ||
| 135 | } | ||
| 136 | } | ||
| 137 | } | ||
| 138 | for (uint8_t y = 0; y < MATRIX_ROWS; y++) { | ||
| 139 | matrix_row_t row = 0; | ||
| 140 | for (uint8_t x = 0; x < MATRIX_COLS; x++) { | ||
| 141 | row |= ((matrix_reversed[x] & (1<<y)) >> y) << x; | ||
| 142 | } | ||
| 143 | matrix[y] = row; | ||
| 144 | } | ||
| 145 | #endif | ||
| 146 | |||
| 147 | return 1; | ||
| 148 | } | ||
| 149 | |||
| 150 | bool matrix_is_modified(void) | ||
| 151 | { | ||
| 152 | if (debouncing) return false; | ||
| 153 | return true; | ||
| 154 | } | ||
| 155 | |||
| 156 | inline | ||
| 157 | bool matrix_is_on(uint8_t row, uint8_t col) | ||
| 158 | { | ||
| 159 | return (matrix[row] & ((matrix_row_t)1<col)); | ||
| 160 | } | ||
| 161 | |||
| 162 | inline | ||
| 163 | matrix_row_t matrix_get_row(uint8_t row) | ||
| 164 | { | ||
| 165 | return matrix[row]; | ||
| 166 | } | ||
| 167 | |||
| 168 | void matrix_print(void) | ||
| 169 | { | ||
| 170 | print("\nr/c 0123456789ABCDEF\n"); | ||
| 171 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
| 172 | phex(row); print(": "); | ||
| 173 | pbin_reverse16(matrix_get_row(row)); | ||
| 174 | print("\n"); | ||
| 175 | } | ||
| 176 | } | ||
| 177 | |||
| 178 | uint8_t matrix_key_count(void) | ||
| 179 | { | ||
| 180 | uint8_t count = 0; | ||
| 181 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 182 | count += bitpop16(matrix[i]); | ||
| 183 | } | ||
| 184 | return count; | ||
| 185 | } | ||
| 186 | |||
| 187 | static void init_cols(void) | ||
| 188 | { | ||
| 189 | int B = 0, C = 0, D = 0, E = 0, F = 0; | ||
| 190 | |||
| 191 | #if DIODE_DIRECTION == COL2ROW | ||
| 192 | for(int x = 0; x < MATRIX_COLS; x++) { | ||
| 193 | int col = COLS[x]; | ||
| 194 | #else | ||
| 195 | for(int x = 0; x < MATRIX_ROWS; x++) { | ||
| 196 | int col = ROWS[x]; | ||
| 197 | #endif | ||
| 198 | if ((col & 0xF0) == 0x20) { | ||
| 199 | B |= (1<<(col & 0x0F)); | ||
| 200 | } else if ((col & 0xF0) == 0x30) { | ||
| 201 | C |= (1<<(col & 0x0F)); | ||
| 202 | } else if ((col & 0xF0) == 0x40) { | ||
| 203 | D |= (1<<(col & 0x0F)); | ||
| 204 | } else if ((col & 0xF0) == 0x50) { | ||
| 205 | E |= (1<<(col & 0x0F)); | ||
| 206 | } else if ((col & 0xF0) == 0x60) { | ||
| 207 | F |= (1<<(col & 0x0F)); | ||
| 208 | } | ||
| 209 | } | ||
| 210 | DDRB &= ~(B); PORTB |= (B); | ||
| 211 | DDRC &= ~(C); PORTC |= (C); | ||
| 212 | DDRD &= ~(D); PORTD |= (D); | ||
| 213 | DDRE &= ~(E); PORTE |= (E); | ||
| 214 | DDRF &= ~(F); PORTF |= (F); | ||
| 215 | } | ||
| 216 | |||
| 217 | static matrix_row_t read_cols(void) | ||
| 218 | { | ||
| 219 | matrix_row_t result = 0; | ||
| 220 | |||
| 221 | #if DIODE_DIRECTION == COL2ROW | ||
| 222 | for(int x = 0; x < MATRIX_COLS; x++) { | ||
| 223 | int col = COLS[x]; | ||
| 224 | #else | ||
| 225 | for(int x = 0; x < MATRIX_ROWS; x++) { | ||
| 226 | int col = ROWS[x]; | ||
| 227 | #endif | ||
| 228 | |||
| 229 | if ((col & 0xF0) == 0x20) { | ||
| 230 | result |= (PINB&(1<<(col & 0x0F)) ? 0 : (1<<x)); | ||
| 231 | } else if ((col & 0xF0) == 0x30) { | ||
| 232 | result |= (PINC&(1<<(col & 0x0F)) ? 0 : (1<<x)); | ||
| 233 | } else if ((col & 0xF0) == 0x40) { | ||
| 234 | result |= (PIND&(1<<(col & 0x0F)) ? 0 : (1<<x)); | ||
| 235 | } else if ((col & 0xF0) == 0x50) { | ||
| 236 | result |= (PINE&(1<<(col & 0x0F)) ? 0 : (1<<x)); | ||
| 237 | } else if ((col & 0xF0) == 0x60) { | ||
| 238 | result |= (PINF&(1<<(col & 0x0F)) ? 0 : (1<<x)); | ||
| 239 | } | ||
| 240 | } | ||
| 241 | return result; | ||
| 242 | } | ||
| 243 | |||
| 244 | static void unselect_rows(void) | ||
| 245 | { | ||
| 246 | int B = 0, C = 0, D = 0, E = 0, F = 0; | ||
| 247 | |||
| 248 | #if DIODE_DIRECTION == COL2ROW | ||
| 249 | for(int x = 0; x < MATRIX_ROWS; x++) { | ||
| 250 | int row = ROWS[x]; | ||
| 251 | #else | ||
| 252 | for(int x = 0; x < MATRIX_COLS; x++) { | ||
| 253 | int row = COLS[x]; | ||
| 254 | #endif | ||
| 255 | if ((row & 0xF0) == 0x20) { | ||
| 256 | B |= (1<<(row & 0x0F)); | ||
| 257 | } else if ((row & 0xF0) == 0x30) { | ||
| 258 | C |= (1<<(row & 0x0F)); | ||
| 259 | } else if ((row & 0xF0) == 0x40) { | ||
| 260 | D |= (1<<(row & 0x0F)); | ||
| 261 | } else if ((row & 0xF0) == 0x50) { | ||
| 262 | E |= (1<<(row & 0x0F)); | ||
| 263 | } else if ((row & 0xF0) == 0x60) { | ||
| 264 | F |= (1<<(row & 0x0F)); | ||
| 265 | } | ||
| 266 | } | ||
| 267 | DDRB &= ~(B); PORTB |= (B); | ||
| 268 | DDRC &= ~(C); PORTC |= (C); | ||
| 269 | DDRD &= ~(D); PORTD |= (D); | ||
| 270 | DDRE &= ~(E); PORTE |= (E); | ||
| 271 | DDRF &= ~(F); PORTF |= (F); | ||
| 272 | } | ||
| 273 | |||
| 274 | static void select_row(uint8_t row) | ||
| 275 | { | ||
| 276 | |||
| 277 | #if DIODE_DIRECTION == COL2ROW | ||
| 278 | int row_pin = ROWS[row]; | ||
| 279 | #else | ||
| 280 | int row_pin = COLS[row]; | ||
| 281 | #endif | ||
| 282 | |||
| 283 | if ((row_pin & 0xF0) == 0x20) { | ||
| 284 | DDRB |= (1<<(row_pin & 0x0F)); | ||
| 285 | PORTB &= ~(1<<(row_pin & 0x0F)); | ||
| 286 | } else if ((row_pin & 0xF0) == 0x30) { | ||
| 287 | DDRC |= (1<<(row_pin & 0x0F)); | ||
| 288 | PORTC &= ~(1<<(row_pin & 0x0F)); | ||
| 289 | } else if ((row_pin & 0xF0) == 0x40) { | ||
| 290 | DDRD |= (1<<(row_pin & 0x0F)); | ||
| 291 | PORTD &= ~(1<<(row_pin & 0x0F)); | ||
| 292 | } else if ((row_pin & 0xF0) == 0x50) { | ||
| 293 | DDRE |= (1<<(row_pin & 0x0F)); | ||
| 294 | PORTE &= ~(1<<(row_pin & 0x0F)); | ||
| 295 | } else if ((row_pin & 0xF0) == 0x60) { | ||
| 296 | DDRF |= (1<<(row_pin & 0x0F)); | ||
| 297 | PORTF &= ~(1<<(row_pin & 0x0F)); | ||
| 298 | } | ||
| 299 | } \ No newline at end of file | ||
diff --git a/keyboard/planck/matrix_steno.c b/keyboard/planck/matrix_steno.c deleted file mode 100644 index 98ef55ed6..000000000 --- a/keyboard/planck/matrix_steno.c +++ /dev/null | |||
| @@ -1,234 +0,0 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2012 Jun Wako | ||
| 3 | Generated by planckkeyboard.com (2014 Jack Humbert) | ||
| 4 | |||
| 5 | This program is free software: you can redistribute it and/or modify | ||
| 6 | it under the terms of the GNU General Public License as published by | ||
| 7 | the Free Software Foundation, either version 2 of the License, or | ||
| 8 | (at your option) any later version. | ||
| 9 | |||
| 10 | This program is distributed in the hope that it will be useful, | ||
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | GNU General Public License for more details. | ||
| 14 | |||
| 15 | You should have received a copy of the GNU General Public License | ||
| 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 17 | */ | ||
| 18 | |||
| 19 | /* | ||
| 20 | * scan matrix | ||
| 21 | */ | ||
| 22 | #include <stdint.h> | ||
| 23 | #include <stdbool.h> | ||
| 24 | #include <avr/io.h> | ||
| 25 | #include <util/delay.h> | ||
| 26 | #include "print.h" | ||
| 27 | #include "debug.h" | ||
| 28 | #include "util.h" | ||
| 29 | #include "matrix.h" | ||
| 30 | |||
| 31 | #ifndef DEBOUNCE | ||
| 32 | # define DEBOUNCE 10 | ||
| 33 | #endif | ||
| 34 | static uint8_t debouncing = DEBOUNCE; | ||
| 35 | |||
| 36 | /* matrix state(1:on, 0:off) */ | ||
| 37 | static matrix_row_t matrix[MATRIX_ROWS]; | ||
| 38 | static matrix_row_t matrix_debouncing[MATRIX_ROWS]; | ||
| 39 | |||
| 40 | static matrix_row_t read_cols(void); | ||
| 41 | static void init_cols(void); | ||
| 42 | static void unselect_rows(void); | ||
| 43 | static void select_row(uint8_t row); | ||
| 44 | |||
| 45 | inline | ||
| 46 | uint8_t matrix_rows(void) | ||
| 47 | { | ||
| 48 | return MATRIX_ROWS; | ||
| 49 | } | ||
| 50 | |||
| 51 | inline | ||
| 52 | uint8_t matrix_cols(void) | ||
| 53 | { | ||
| 54 | return MATRIX_COLS; | ||
| 55 | } | ||
| 56 | |||
| 57 | void matrix_init(void) | ||
| 58 | { | ||
| 59 | // To use PORTF disable JTAG with writing JTD bit twice within four cycles. | ||
| 60 | MCUCR |= (1<<JTD); | ||
| 61 | MCUCR |= (1<<JTD); | ||
| 62 | |||
| 63 | backlight_init_ports(); | ||
| 64 | |||
| 65 | // Turn status LED on | ||
| 66 | DDRE |= (1<<6); | ||
| 67 | PORTE |= (1<<6); | ||
| 68 | |||
| 69 | // initialize row and col | ||
| 70 | unselect_rows(); | ||
| 71 | init_cols(); | ||
| 72 | |||
| 73 | // initialize matrix state: all keys off | ||
| 74 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { | ||
| 75 | matrix[i] = 0; | ||
| 76 | matrix_debouncing[i] = 0; | ||
| 77 | } | ||
| 78 | } | ||
| 79 | |||
| 80 | |||
| 81 | uint8_t matrix_scan(void) | ||
| 82 | { | ||
| 83 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 84 | select_row(i); | ||
| 85 | _delay_us(30); // without this wait read unstable value. | ||
| 86 | matrix_row_t cols = read_cols(); | ||
| 87 | if (matrix_debouncing[i] != cols) { | ||
| 88 | matrix_debouncing[i] = cols; | ||
| 89 | if (debouncing) { | ||
| 90 | debug("bounce!: "); debug_hex(debouncing); debug("\n"); | ||
| 91 | } | ||
| 92 | debouncing = DEBOUNCE; | ||
| 93 | } | ||
| 94 | unselect_rows(); | ||
| 95 | } | ||
| 96 | |||
| 97 | if (debouncing) { | ||
| 98 | if (--debouncing) { | ||
| 99 | _delay_ms(1); | ||
| 100 | } else { | ||
| 101 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 102 | matrix[i] = matrix_debouncing[i]; | ||
| 103 | } | ||
| 104 | } | ||
| 105 | } | ||
| 106 | |||
| 107 | return 1; | ||
| 108 | } | ||
| 109 | |||
| 110 | bool matrix_is_modified(void) | ||
| 111 | { | ||
| 112 | if (debouncing) return false; | ||
| 113 | return true; | ||
| 114 | } | ||
| 115 | |||
| 116 | inline | ||
| 117 | bool matrix_is_on(uint8_t row, uint8_t col) | ||
| 118 | { | ||
| 119 | return (matrix[row] & ((matrix_row_t)1<col)); | ||
| 120 | } | ||
| 121 | |||
| 122 | inline | ||
| 123 | matrix_row_t matrix_get_row(uint8_t row) | ||
| 124 | { | ||
| 125 | return matrix[row]; | ||
| 126 | } | ||
| 127 | |||
| 128 | void matrix_print(void) | ||
| 129 | { | ||
| 130 | print("\nr/c 0123456789ABCDEF\n"); | ||
| 131 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
| 132 | phex(row); print(": "); | ||
| 133 | pbin_reverse16(matrix_get_row(row)); | ||
| 134 | print("\n"); | ||
| 135 | } | ||
| 136 | } | ||
| 137 | |||
| 138 | uint8_t matrix_key_count(void) | ||
| 139 | { | ||
| 140 | uint8_t count = 0; | ||
| 141 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 142 | count += bitpop16(matrix[i]); | ||
| 143 | } | ||
| 144 | return count; | ||
| 145 | } | ||
| 146 | |||
| 147 | static void init_cols(void) | ||
| 148 | { | ||
| 149 | int B = 0, C = 0, D = 0, E = 0, F = 0; | ||
| 150 | for(int x = 0; x < MATRIX_COLS; x++) { | ||
| 151 | int col = COLS[x]; | ||
| 152 | if ((col & 0xF0) == 0x20) { | ||
| 153 | B |= (1<<(col & 0x0F)); | ||
| 154 | } else if ((col & 0xF0) == 0x30) { | ||
| 155 | C |= (1<<(col & 0x0F)); | ||
| 156 | } else if ((col & 0xF0) == 0x40) { | ||
| 157 | D |= (1<<(col & 0x0F)); | ||
| 158 | } else if ((col & 0xF0) == 0x50) { | ||
| 159 | E |= (1<<(col & 0x0F)); | ||
| 160 | } else if ((col & 0xF0) == 0x60) { | ||
| 161 | F |= (1<<(col & 0x0F)); | ||
| 162 | } | ||
| 163 | } | ||
| 164 | DDRB &= ~(B); PORTB |= (B); | ||
| 165 | DDRC &= ~(C); PORTC |= (C); | ||
| 166 | DDRD &= ~(D); PORTD |= (D); | ||
| 167 | DDRE &= ~(E); PORTE |= (E); | ||
| 168 | DDRF &= ~(F); PORTF |= (F); | ||
| 169 | } | ||
| 170 | |||
| 171 | static matrix_row_t read_cols(void) | ||
| 172 | { | ||
| 173 | matrix_row_t result = 0; | ||
| 174 | for(int x = 0; x < MATRIX_COLS; x++) { | ||
| 175 | int col = COLS[x]; | ||
| 176 | if ((col & 0xF0) == 0x20) { | ||
| 177 | result |= (PINB&(1<<(col & 0x0F)) ? 0 : (1<<x)); | ||
| 178 | } else if ((col & 0xF0) == 0x30) { | ||
| 179 | result |= (PINC&(1<<(col & 0x0F)) ? 0 : (1<<x)); | ||
| 180 | } else if ((col & 0xF0) == 0x40) { | ||
| 181 | result |= (PIND&(1<<(col & 0x0F)) ? 0 : (1<<x)); | ||
| 182 | } else if ((col & 0xF0) == 0x50) { | ||
| 183 | result |= (PINE&(1<<(col & 0x0F)) ? 0 : (1<<x)); | ||
| 184 | } else if ((col & 0xF0) == 0x60) { | ||
| 185 | result |= (PINF&(1<<(col & 0x0F)) ? 0 : (1<<x)); | ||
| 186 | } | ||
| 187 | } | ||
| 188 | return result; | ||
| 189 | } | ||
| 190 | |||
| 191 | static void unselect_rows(void) | ||
| 192 | { | ||
| 193 | int B = 0, C = 0, D = 0, E = 0, F = 0; | ||
| 194 | for(int x = 0; x < MATRIX_ROWS; x++) { | ||
| 195 | int row = ROWS[x]; | ||
| 196 | if ((row & 0xF0) == 0x20) { | ||
| 197 | B |= (1<<(row & 0x0F)); | ||
| 198 | } else if ((row & 0xF0) == 0x30) { | ||
| 199 | C |= (1<<(row & 0x0F)); | ||
| 200 | } else if ((row & 0xF0) == 0x40) { | ||
| 201 | D |= (1<<(row & 0x0F)); | ||
| 202 | } else if ((row & 0xF0) == 0x50) { | ||
| 203 | E |= (1<<(row & 0x0F)); | ||
| 204 | } else if ((row & 0xF0) == 0x60) { | ||
| 205 | F |= (1<<(row & 0x0F)); | ||
| 206 | } | ||
| 207 | } | ||
| 208 | DDRB &= ~(B); PORTB |= (B); | ||
| 209 | DDRC &= ~(C); PORTC |= (C); | ||
| 210 | DDRD &= ~(D); PORTD |= (D); | ||
| 211 | DDRE &= ~(E); PORTE |= (E); | ||
| 212 | DDRF &= ~(F); PORTF |= (F); | ||
| 213 | } | ||
| 214 | |||
| 215 | static void select_row(uint8_t row) | ||
| 216 | { | ||
| 217 | int row_pin = ROWS[row]; | ||
| 218 | if ((row_pin & 0xF0) == 0x20) { | ||
| 219 | DDRB |= (1<<(row_pin & 0x0F)); | ||
| 220 | PORTB &= ~(1<<(row_pin & 0x0F)); | ||
| 221 | } else if ((row_pin & 0xF0) == 0x30) { | ||
| 222 | DDRC |= (1<<(row_pin & 0x0F)); | ||
| 223 | PORTC &= ~(1<<(row_pin & 0x0F)); | ||
| 224 | } else if ((row_pin & 0xF0) == 0x40) { | ||
| 225 | DDRD |= (1<<(row_pin & 0x0F)); | ||
| 226 | PORTD &= ~(1<<(row_pin & 0x0F)); | ||
| 227 | } else if ((row_pin & 0xF0) == 0x50) { | ||
| 228 | DDRE |= (1<<(row_pin & 0x0F)); | ||
| 229 | PORTE &= ~(1<<(row_pin & 0x0F)); | ||
| 230 | } else if ((row_pin & 0xF0) == 0x60) { | ||
| 231 | DDRF |= (1<<(row_pin & 0x0F)); | ||
| 232 | PORTF &= ~(1<<(row_pin & 0x0F)); | ||
| 233 | } | ||
| 234 | } \ No newline at end of file | ||
diff --git a/keyboard/planck/planck.c b/keyboard/planck/planck.c new file mode 100644 index 000000000..9809a824c --- /dev/null +++ b/keyboard/planck/planck.c | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | #include "planck.h" | ||
| 2 | |||
| 3 | void * matrix_init_user(void) { | ||
| 4 | |||
| 5 | }; | ||
| 6 | |||
| 7 | void * matrix_scan_user(void) { | ||
| 8 | |||
| 9 | }; | ||
| 10 | |||
| 11 | void *matrix_init_kb(void) { | ||
| 12 | #ifdef BACKLIGHT_ENABLE | ||
| 13 | backlight_init_ports(); | ||
| 14 | #endif | ||
| 15 | |||
| 16 | // Turn status LED on | ||
| 17 | DDRE |= (1<<6); | ||
| 18 | PORTE |= (1<<6); | ||
| 19 | |||
| 20 | if (matrix_init_user) { | ||
| 21 | (*matrix_init_user)(); | ||
| 22 | } | ||
| 23 | }; | ||
| 24 | |||
| 25 | void *matrix_scan_kb(void) { | ||
| 26 | if (matrix_scan_user) { | ||
| 27 | (*matrix_scan_user)(); | ||
| 28 | } | ||
| 29 | }; \ No newline at end of file | ||
diff --git a/keyboard/planck/planck.h b/keyboard/planck/planck.h new file mode 100644 index 000000000..4e59aef56 --- /dev/null +++ b/keyboard/planck/planck.h | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | #ifndef PLANCK_H | ||
| 2 | #define PLANCK_H | ||
| 3 | |||
| 4 | #include "matrix.h" | ||
| 5 | #include "keymap_common.h" | ||
| 6 | #include "backlight.h" | ||
| 7 | #include <stddef.h> | ||
| 8 | |||
| 9 | #define PLANCK_MIT( \ | ||
| 10 | k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, \ | ||
| 11 | k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b, \ | ||
| 12 | k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k2b, \ | ||
| 13 | k30, k31, k32, k33, k34, k35, k37, k38, k39, k3a, k3b \ | ||
| 14 | ) \ | ||
| 15 | { \ | ||
| 16 | { k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b }, \ | ||
| 17 | { k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b }, \ | ||
| 18 | { k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k2b }, \ | ||
| 19 | { k30, k31, k32, k33, k34, k35, k35, k37, k38, k39, k3a, k3b } \ | ||
| 20 | } | ||
| 21 | |||
| 22 | #define PLANCK_GRID( \ | ||
| 23 | k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, \ | ||
| 24 | k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b, \ | ||
| 25 | k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k2b, \ | ||
| 26 | k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3a, k3b \ | ||
| 27 | ) \ | ||
| 28 | { \ | ||
| 29 | { k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b }, \ | ||
| 30 | { k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b }, \ | ||
| 31 | { k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k2b }, \ | ||
| 32 | { k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3a, k3b } \ | ||
| 33 | } | ||
| 34 | |||
| 35 | void * matrix_init_user(void); | ||
| 36 | void * matrix_scan_user(void); | ||
| 37 | |||
| 38 | #endif \ No newline at end of file | ||
