aboutsummaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
Diffstat (limited to 'quantum')
-rw-r--r--quantum/analog.c53
-rw-r--r--quantum/analog.h36
-rw-r--r--quantum/beeps.c246
-rw-r--r--quantum/beeps.h12
-rw-r--r--quantum/keymap_common.c226
-rw-r--r--quantum/keymap_common.h121
-rw-r--r--quantum/keymap_extras/keymap_colemak.h74
-rw-r--r--quantum/keymap_extras/keymap_dvorak.h72
-rw-r--r--quantum/keymap_extras/keymap_french.h83
-rw-r--r--quantum/keymap_extras/keymap_nordic.h59
-rw-r--r--quantum/keymap_extras/keymap_spanish.h62
-rw-r--r--quantum/keymap_extras/keymap_uk.h36
-rw-r--r--quantum/keymap_midi.c110
-rw-r--r--quantum/keymap_midi.h220
-rw-r--r--quantum/keymap_unicode.c59
-rw-r--r--quantum/led.c38
-rw-r--r--quantum/matrix.c301
17 files changed, 1808 insertions, 0 deletions
diff --git a/quantum/analog.c b/quantum/analog.c
new file mode 100644
index 000000000..49b84ee0e
--- /dev/null
+++ b/quantum/analog.c
@@ -0,0 +1,53 @@
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
9static uint8_t aref = (1<<REFS0); // default to AREF = Vcc
10
11
12void analogReference(uint8_t mode)
13{
14 aref = mode & 0xC0;
15}
16
17
18// Arduino compatible pin input
19int16_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
36int16_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/quantum/analog.h b/quantum/analog.h
new file mode 100644
index 000000000..9b95a93be
--- /dev/null
+++ b/quantum/analog.h
@@ -0,0 +1,36 @@
1#ifndef _analog_h_included__
2#define _analog_h_included__
3
4#include <stdint.h>
5
6void analogReference(uint8_t mode);
7int16_t analogRead(uint8_t pin);
8int16_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/quantum/beeps.c b/quantum/beeps.c
new file mode 100644
index 000000000..8d1f81f21
--- /dev/null
+++ b/quantum/beeps.c
@@ -0,0 +1,246 @@
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
9void delay_us(int count) {
10 while(count--) {
11 _delay_us(1);
12 }
13}
14
15int voices = 0;
16double frequency = 0;
17int volume = 0;
18int position = 0;
19
20double frequencies[8] = {0, 0, 0, 0, 0, 0, 0, 0};
21int volumes[8] = {0, 0, 0, 0, 0, 0, 0, 0};
22bool sliding = false;
23#define RANGE 1000
24volatile int i=0; //elements of the wave
25
26
27void beeps() {
28 play_notes();
29}
30
31void 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
37void 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
50void 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
93void 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
135ISR(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
186void 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/quantum/beeps.h b/quantum/beeps.h
new file mode 100644
index 000000000..378983c60
--- /dev/null
+++ b/quantum/beeps.h
@@ -0,0 +1,12 @@
1#include <stdint.h>
2#include <stdbool.h>
3#include <avr/io.h>
4#include <util/delay.h>
5
6void note(int x, float length);
7void beeps();
8void true_note(float x, float y, float length);
9void play_note(double freq, int vol);
10void stop_note(double freq);
11void stop_all_notes();
12void init_notes(); \ No newline at end of file
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c
new file mode 100644
index 000000000..66cf2883c
--- /dev/null
+++ b/quantum/keymap_common.c
@@ -0,0 +1,226 @@
1/*
2Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along 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
28static action_t keycode_to_action(uint16_t keycode);
29
30/* converts key to action */
31action_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 >= 0x5000 && keycode < 0x6000) {
77 int when = (keycode >> 0x9) & 0x3;
78 int layer = keycode & 0xFF;
79 action_t action;
80 action.code = ACTION_LAYER_SET(layer, when);
81 return action;
82 } else if (keycode >= 0x6000 && keycode < 0x7000) {
83 action_t action;
84 action.code = ACTION_FUNCTION_OPT(keycode & 0xFF, (keycode & 0x0F00) >> 8);
85 return action;
86 } else if (keycode >= 0x8000) {
87 action_t action;
88 uint16_t unicode = keycode & ~(0x8000);
89 action.code = ACTION_FUNCTION_OPT(unicode & 0xFF, (unicode & 0xFF00) >> 8);
90 return action;
91 }
92
93 switch (keycode) {
94 case KC_FN0 ... KC_FN31:
95 return keymap_fn_to_action(keycode);
96#ifdef BOOTMAGIC_ENABLE
97 case KC_CAPSLOCK:
98 case KC_LOCKING_CAPS:
99 if (keymap_config.swap_control_capslock || keymap_config.capslock_to_control) {
100 return keycode_to_action(KC_LCTL);
101 }
102 return keycode_to_action(keycode);
103 case KC_LCTL:
104 if (keymap_config.swap_control_capslock) {
105 return keycode_to_action(KC_CAPSLOCK);
106 }
107 return keycode_to_action(KC_LCTL);
108 case KC_LALT:
109 if (keymap_config.swap_lalt_lgui) {
110 if (keymap_config.no_gui) {
111 return keycode_to_action(ACTION_NO);
112 }
113 return keycode_to_action(KC_LGUI);
114 }
115 return keycode_to_action(KC_LALT);
116 case KC_LGUI:
117 if (keymap_config.swap_lalt_lgui) {
118 return keycode_to_action(KC_LALT);
119 }
120 if (keymap_config.no_gui) {
121 return keycode_to_action(ACTION_NO);
122 }
123 return keycode_to_action(KC_LGUI);
124 case KC_RALT:
125 if (keymap_config.swap_ralt_rgui) {
126 if (keymap_config.no_gui) {
127 return keycode_to_action(ACTION_NO);
128 }
129 return keycode_to_action(KC_RGUI);
130 }
131 return keycode_to_action(KC_RALT);
132 case KC_RGUI:
133 if (keymap_config.swap_ralt_rgui) {
134 return keycode_to_action(KC_RALT);
135 }
136 if (keymap_config.no_gui) {
137 return keycode_to_action(ACTION_NO);
138 }
139 return keycode_to_action(KC_RGUI);
140 case KC_GRAVE:
141 if (keymap_config.swap_grave_esc) {
142 return keycode_to_action(KC_ESC);
143 }
144 return keycode_to_action(KC_GRAVE);
145 case KC_ESC:
146 if (keymap_config.swap_grave_esc) {
147 return keycode_to_action(KC_GRAVE);
148 }
149 return keycode_to_action(KC_ESC);
150 case KC_BSLASH:
151 if (keymap_config.swap_backslash_backspace) {
152 return keycode_to_action(KC_BSPACE);
153 }
154 return keycode_to_action(KC_BSLASH);
155 case KC_BSPACE:
156 if (keymap_config.swap_backslash_backspace) {
157 return keycode_to_action(KC_BSLASH);
158 }
159 return keycode_to_action(KC_BSPACE);
160#endif
161 default:
162 return keycode_to_action(keycode);
163 }
164}
165
166
167/* Macro */
168__attribute__ ((weak))
169const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
170{
171 return MACRO_NONE;
172}
173
174/* Function */
175__attribute__ ((weak))
176void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
177{
178}
179
180/* translates keycode to action */
181static action_t keycode_to_action(uint16_t keycode)
182{
183 action_t action;
184 switch (keycode) {
185 case KC_A ... KC_EXSEL:
186 case KC_LCTRL ... KC_RGUI:
187 action.code = ACTION_KEY(keycode);
188 break;
189 case KC_SYSTEM_POWER ... KC_SYSTEM_WAKE:
190 action.code = ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(keycode));
191 break;
192 case KC_AUDIO_MUTE ... KC_WWW_FAVORITES:
193 action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode));
194 break;
195 case KC_MS_UP ... KC_MS_ACCEL2:
196 action.code = ACTION_MOUSEKEY(keycode);
197 break;
198 case KC_TRNS:
199 action.code = ACTION_TRANSPARENT;
200 break;
201 default:
202 action.code = ACTION_NO;
203 break;
204 }
205 return action;
206}
207
208
209/* translates key to keycode */
210uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
211{
212 // Read entire word (16bits)
213 return pgm_read_word(&keymaps[(layer)][(key.row)][(key.col)]);
214}
215
216/* translates Fn keycode to action */
217action_t keymap_fn_to_action(uint16_t keycode)
218{
219 return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) };
220}
221
222action_t keymap_func_to_action(uint16_t keycode)
223{
224 // For FUNC without 8bit limit
225 return (action_t){ .code = pgm_read_word(&fn_actions[(int)keycode]) };
226}
diff --git a/quantum/keymap_common.h b/quantum/keymap_common.h
new file mode 100644
index 000000000..091f7d8f3
--- /dev/null
+++ b/quantum/keymap_common.h
@@ -0,0 +1,121 @@
1/*
2Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along 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 */
35typedef 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;
48keymap_config_t keymap_config;
49#endif
50
51
52/* translates key to keycode */
53uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key);
54
55/* translates Fn keycode to action */
56action_t keymap_fn_to_action(uint16_t keycode);
57
58/* translates Fn keycode to action */
59action_t keymap_func_to_action(uint16_t keycode);
60
61extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
62extern 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// ON_PRESS = 1
112// ON_RELEASE = 2
113// ON_BOTH = 3
114#define TO(layer, when) (layer | 0x5100 | (when << 0x9))
115
116#define MIDI(n) (n | 0x6000)
117
118#define UNI(n) (n | 0x8000)
119
120
121#endif
diff --git a/quantum/keymap_extras/keymap_colemak.h b/quantum/keymap_extras/keymap_colemak.h
new file mode 100644
index 000000000..c8066ea66
--- /dev/null
+++ b/quantum/keymap_extras/keymap_colemak.h
@@ -0,0 +1,74 @@
1#ifndef KEYMAP_COLEMAK_H
2#define KEYMAP_COLEMAK_H
3
4#include "keymap_common.h"
5// For software implementation of colemak
6#define CM_Q KC_Q
7#define CM_W KC_W
8#define CM_F KC_E
9#define CM_P KC_R
10#define CM_G KC_T
11#define CM_J KC_Y
12#define CM_L KC_U
13#define CM_U KC_I
14#define CM_Y KC_O
15#define CM_SCLN KC_P
16
17#define CM_A KC_A
18#define CM_R KC_S
19#define CM_S KC_D
20#define CM_T KC_F
21#define CM_D KC_G
22#define CM_H KC_H
23#define CM_N KC_J
24#define CM_E KC_K
25#define CM_I KC_L
26#define CM_O KC_SCLN
27
28#define CM_Z KC_Z
29#define CM_X KC_X
30#define CM_C KC_C
31#define CM_V KC_V
32#define CM_B KC_B
33#define CM_K KC_N
34#define CM_M KC_M
35#define CM_COMM KC_COMM
36#define CM_DOT KC_DOT
37#define CM_SLSH KC_SLSH
38
39// Make it easy to support these in macros
40// TODO: change macro implementation so these aren't needed
41#define KC_CM_Q CM_Q
42#define KC_CM_W CM_W
43#define KC_CM_F CM_F
44#define KC_CM_P CM_P
45#define KC_CM_G CM_G
46#define KC_CM_J CM_J
47#define KC_CM_L CM_L
48#define KC_CM_U CM_U
49#define KC_CM_Y CM_Y
50#define KC_CM_SCLN CM_SCLN
51
52#define KC_CM_A CM_A
53#define KC_CM_R CM_R
54#define KC_CM_S CM_S
55#define KC_CM_T CM_T
56#define KC_CM_D CM_D
57#define KC_CM_H CM_H
58#define KC_CM_N CM_N
59#define KC_CM_E CM_E
60#define KC_CM_I CM_I
61#define KC_CM_O CM_O
62
63#define KC_CM_Z CM_Z
64#define KC_CM_X CM_X
65#define KC_CM_C CM_C
66#define KC_CM_V CM_V
67#define KC_CM_B CM_B
68#define KC_CM_K CM_K
69#define KC_CM_M CM_M
70#define KC_CM_COMM CM_COMM
71#define KC_CM_DOT CM_DOT
72#define KC_CM_SLSH CM_SLSH
73
74#endif
diff --git a/quantum/keymap_extras/keymap_dvorak.h b/quantum/keymap_extras/keymap_dvorak.h
new file mode 100644
index 000000000..d172e0019
--- /dev/null
+++ b/quantum/keymap_extras/keymap_dvorak.h
@@ -0,0 +1,72 @@
1#ifndef KEYMAP_DVORAK_H
2#define KEYMAP_DVORAK_H
3
4#include "keymap_common.h"
5
6// Normal characters
7#define DV_GRV KC_GRV
8#define DV_1 KC_1
9#define DV_2 KC_2
10#define DV_3 KC_3
11#define DV_4 KC_4
12#define DV_5 KC_5
13#define DV_6 KC_6
14#define DV_7 KC_7
15#define DV_8 KC_8
16#define DV_9 KC_9
17#define DV_0 KC_0
18#define DV_LBRC KC_MINS
19#define DV_RBRC KC_EQL
20
21#define DV_QUOT KC_Q
22#define DV_COMM KC_W
23#define DV_DOT KC_E
24#define DV_P KC_R
25#define DV_Y KC_T
26#define DV_F KC_Y
27#define DV_G KC_U
28#define DV_C KC_I
29#define DV_R KC_O
30#define DV_L KC_P
31#define DV_SLSH KC_LBRC
32#define DV_EQL KC_RBRC
33
34#define DV_A KC_A
35#define DV_O KC_S
36#define DV_E KC_D
37#define DV_U KC_F
38#define DV_I KC_G
39#define DV_D KC_H
40#define DV_H KC_J
41#define DV_T KC_K
42#define DV_N KC_L
43#define DV_S KC_SCLN
44#define DV_MINS KC_QUOT
45
46#define DV_SCLN KC_Z
47#define DV_Q KC_X
48#define DV_J KC_C
49#define DV_K KC_V
50#define DV_X KC_B
51#define DV_B KC_N
52#define DV_M KC_M
53#define DV_W KC_COMM
54#define DV_V KC_DOT
55#define DV_Z KC_SLSH
56
57// Shifted characters
58#define DV_TILD LSFT(DV_GRV)
59#define DV_EXLM LSFT(DV_1)
60#define DV_AT LSFT(DV_2)
61#define DV_HASH LSFT(DV_3)
62#define DV_DLR LSFT(DV_4)
63#define DV_PERC LSFT(DV_5)
64#define DV_CIRC LSFT(DV_6)
65#define DV_AMPR LSFT(DV_7)
66#define DV_ASTR LSFT(DV_8)
67#define DV_LPRN LSFT(DV_9)
68#define DV_RPRN LSFT(DV_0)
69#define DV_LCBR LSFT(DV_LBRC)
70#define DV_RCBR LSFT(DV_RBRC)
71
72#endif \ No newline at end of file
diff --git a/quantum/keymap_extras/keymap_french.h b/quantum/keymap_extras/keymap_french.h
new file mode 100644
index 000000000..ccfaed8f0
--- /dev/null
+++ b/quantum/keymap_extras/keymap_french.h
@@ -0,0 +1,83 @@
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/quantum/keymap_extras/keymap_nordic.h b/quantum/keymap_extras/keymap_nordic.h
new file mode 100644
index 000000000..02a704216
--- /dev/null
+++ b/quantum/keymap_extras/keymap_nordic.h
@@ -0,0 +1,59 @@
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/quantum/keymap_extras/keymap_spanish.h b/quantum/keymap_extras/keymap_spanish.h
new file mode 100644
index 000000000..7f980afbc
--- /dev/null
+++ b/quantum/keymap_extras/keymap_spanish.h
@@ -0,0 +1,62 @@
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/quantum/keymap_extras/keymap_uk.h b/quantum/keymap_extras/keymap_uk.h
new file mode 100644
index 000000000..5b4bd3c0d
--- /dev/null
+++ b/quantum/keymap_extras/keymap_uk.h
@@ -0,0 +1,36 @@
1#ifndef KEYMAP_UK_H
2#define KEYMAP_UK_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 UK_HASH KC_NUHS
12
13#define UK_BSLS KC_NUBS
14
15// Shifted characters
16#define UK_NOT LSFT(KC_GRV)
17#define UK_QUOT LSFT(KC_2)
18#define UK_PND LSFT(KC_3)
19
20#define UK_AT LSFT(KC_QUOT)
21#define UK_TILD LSFT(KC_NUHS)
22
23#define UK_PIPE LSFT(KC_NUBS)
24
25// Alt Gr-ed characters
26#define UK_BRKP ALGR(KC_GRV)
27#define UK_EURO ALGR(KC_4)
28
29#define UK_EACT ALGR(KC_E)
30#define UK_UACT ALGR(KC_U)
31#define UK_IACT ALGR(KC_I)
32#define UK_OACT ALGR(KC_O)
33
34#define UK_AACT ALGR(KC_A)
35
36#endif \ No newline at end of file
diff --git a/quantum/keymap_midi.c b/quantum/keymap_midi.c
new file mode 100644
index 000000000..b7eba3ab7
--- /dev/null
+++ b/quantum/keymap_midi.c
@@ -0,0 +1,110 @@
1/*
2Copyright 2015 Jack Humbert <jack.humb@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along 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
22uint8_t starting_note = 0x0C;
23int offset = 7;
24
25void 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/quantum/keymap_midi.h b/quantum/keymap_midi.h
new file mode 100644
index 000000000..c5917f884
--- /dev/null
+++ b/quantum/keymap_midi.h
@@ -0,0 +1,220 @@
1/*
2Copyright 2015 Jack Humbert <jack.humb@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along 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/quantum/keymap_unicode.c b/quantum/keymap_unicode.c
new file mode 100644
index 000000000..a9357edec
--- /dev/null
+++ b/quantum/keymap_unicode.c
@@ -0,0 +1,59 @@
1/*
2Copyright 2015 Jack Humbert <jack.humb@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include "keymap_common.h"
19
20uint16_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
30void 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/quantum/led.c b/quantum/led.c
new file mode 100644
index 000000000..2c0574660
--- /dev/null
+++ b/quantum/led.c
@@ -0,0 +1,38 @@
1/*
2Copyright 2012 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along 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
23void 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/quantum/matrix.c b/quantum/matrix.c
new file mode 100644
index 000000000..97642a4a4
--- /dev/null
+++ b/quantum/matrix.c
@@ -0,0 +1,301 @@
1/*
2Copyright 2012 Jun Wako
3Generated by planckkeyboard.com (2014 Jack Humbert)
4
5This program is free software: you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by
7the Free Software Foundation, either version 2 of the License, or
8(at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along 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
34static uint8_t debouncing = DEBOUNCE;
35
36/* matrix state(1:on, 0:off) */
37static matrix_row_t matrix[MATRIX_ROWS];
38static 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
45static matrix_row_t read_cols(void);
46static void init_cols(void);
47static void unselect_rows(void);
48static void select_row(uint8_t row);
49
50inline
51uint8_t matrix_rows(void)
52{
53 return MATRIX_ROWS;
54}
55
56inline
57uint8_t matrix_cols(void)
58{
59 return MATRIX_COLS;
60}
61
62void 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
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 if (matrix_init_kb) {
80 (*matrix_init_kb)();
81 }
82}
83
84
85uint8_t matrix_scan(void)
86{
87
88#if DIODE_DIRECTION == COL2ROW
89 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
90 select_row(i);
91 _delay_us(30); // without this wait read unstable value.
92 matrix_row_t cols = read_cols();
93 if (matrix_debouncing[i] != cols) {
94 matrix_debouncing[i] = cols;
95 if (debouncing) {
96 debug("bounce!: "); debug_hex(debouncing); debug("\n");
97 }
98 debouncing = DEBOUNCE;
99 }
100 unselect_rows();
101 }
102
103 if (debouncing) {
104 if (--debouncing) {
105 _delay_ms(1);
106 } else {
107 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
108 matrix[i] = matrix_debouncing[i];
109 }
110 }
111 }
112#else
113 for (uint8_t i = 0; i < MATRIX_COLS; i++) {
114 select_row(i);
115 _delay_us(30); // without this wait read unstable value.
116 matrix_row_t rows = read_cols();
117 if (matrix_reversed_debouncing[i] != rows) {
118 matrix_reversed_debouncing[i] = rows;
119 if (debouncing) {
120 debug("bounce!: "); debug_hex(debouncing); debug("\n");
121 }
122 debouncing = DEBOUNCE;
123 }
124 unselect_rows();
125 }
126
127 if (debouncing) {
128 if (--debouncing) {
129 _delay_ms(1);
130 } else {
131 for (uint8_t i = 0; i < MATRIX_COLS; i++) {
132 matrix_reversed[i] = matrix_reversed_debouncing[i];
133 }
134 }
135 }
136 for (uint8_t y = 0; y < MATRIX_ROWS; y++) {
137 matrix_row_t row = 0;
138 for (uint8_t x = 0; x < MATRIX_COLS; x++) {
139 row |= ((matrix_reversed[x] & (1<<y)) >> y) << x;
140 }
141 matrix[y] = row;
142 }
143#endif
144
145 if (matrix_scan_kb) {
146 (*matrix_scan_kb)();
147 }
148
149 return 1;
150}
151
152bool matrix_is_modified(void)
153{
154 if (debouncing) return false;
155 return true;
156}
157
158inline
159bool matrix_is_on(uint8_t row, uint8_t col)
160{
161 return (matrix[row] & ((matrix_row_t)1<col));
162}
163
164inline
165matrix_row_t matrix_get_row(uint8_t row)
166{
167 return matrix[row];
168}
169
170void matrix_print(void)
171{
172 print("\nr/c 0123456789ABCDEF\n");
173 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
174 phex(row); print(": ");
175 pbin_reverse16(matrix_get_row(row));
176 print("\n");
177 }
178}
179
180uint8_t matrix_key_count(void)
181{
182 uint8_t count = 0;
183 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
184 count += bitpop16(matrix[i]);
185 }
186 return count;
187}
188
189static void init_cols(void)
190{
191 int B = 0, C = 0, D = 0, E = 0, F = 0;
192
193#if DIODE_DIRECTION == COL2ROW
194 for(int x = 0; x < MATRIX_COLS; x++) {
195 int col = COLS[x];
196#else
197 for(int x = 0; x < MATRIX_ROWS; x++) {
198 int col = ROWS[x];
199#endif
200 if ((col & 0xF0) == 0x20) {
201 B |= (1<<(col & 0x0F));
202 } else if ((col & 0xF0) == 0x30) {
203 C |= (1<<(col & 0x0F));
204 } else if ((col & 0xF0) == 0x40) {
205 D |= (1<<(col & 0x0F));
206 } else if ((col & 0xF0) == 0x50) {
207 E |= (1<<(col & 0x0F));
208 } else if ((col & 0xF0) == 0x60) {
209 F |= (1<<(col & 0x0F));
210 }
211 }
212 DDRB &= ~(B); PORTB |= (B);
213 DDRC &= ~(C); PORTC |= (C);
214 DDRD &= ~(D); PORTD |= (D);
215 DDRE &= ~(E); PORTE |= (E);
216 DDRF &= ~(F); PORTF |= (F);
217}
218
219static matrix_row_t read_cols(void)
220{
221 matrix_row_t result = 0;
222
223#if DIODE_DIRECTION == COL2ROW
224 for(int x = 0; x < MATRIX_COLS; x++) {
225 int col = COLS[x];
226#else
227 for(int x = 0; x < MATRIX_ROWS; x++) {
228 int col = ROWS[x];
229#endif
230
231 if ((col & 0xF0) == 0x20) {
232 result |= (PINB&(1<<(col & 0x0F)) ? 0 : (1<<x));
233 } else if ((col & 0xF0) == 0x30) {
234 result |= (PINC&(1<<(col & 0x0F)) ? 0 : (1<<x));
235 } else if ((col & 0xF0) == 0x40) {
236 result |= (PIND&(1<<(col & 0x0F)) ? 0 : (1<<x));
237 } else if ((col & 0xF0) == 0x50) {
238 result |= (PINE&(1<<(col & 0x0F)) ? 0 : (1<<x));
239 } else if ((col & 0xF0) == 0x60) {
240 result |= (PINF&(1<<(col & 0x0F)) ? 0 : (1<<x));
241 }
242 }
243 return result;
244}
245
246static void unselect_rows(void)
247{
248 int B = 0, C = 0, D = 0, E = 0, F = 0;
249
250#if DIODE_DIRECTION == COL2ROW
251 for(int x = 0; x < MATRIX_ROWS; x++) {
252 int row = ROWS[x];
253#else
254 for(int x = 0; x < MATRIX_COLS; x++) {
255 int row = COLS[x];
256#endif
257 if ((row & 0xF0) == 0x20) {
258 B |= (1<<(row & 0x0F));
259 } else if ((row & 0xF0) == 0x30) {
260 C |= (1<<(row & 0x0F));
261 } else if ((row & 0xF0) == 0x40) {
262 D |= (1<<(row & 0x0F));
263 } else if ((row & 0xF0) == 0x50) {
264 E |= (1<<(row & 0x0F));
265 } else if ((row & 0xF0) == 0x60) {
266 F |= (1<<(row & 0x0F));
267 }
268 }
269 DDRB &= ~(B); PORTB |= (B);
270 DDRC &= ~(C); PORTC |= (C);
271 DDRD &= ~(D); PORTD |= (D);
272 DDRE &= ~(E); PORTE |= (E);
273 DDRF &= ~(F); PORTF |= (F);
274}
275
276static void select_row(uint8_t row)
277{
278
279#if DIODE_DIRECTION == COL2ROW
280 int row_pin = ROWS[row];
281#else
282 int row_pin = COLS[row];
283#endif
284
285 if ((row_pin & 0xF0) == 0x20) {
286 DDRB |= (1<<(row_pin & 0x0F));
287 PORTB &= ~(1<<(row_pin & 0x0F));
288 } else if ((row_pin & 0xF0) == 0x30) {
289 DDRC |= (1<<(row_pin & 0x0F));
290 PORTC &= ~(1<<(row_pin & 0x0F));
291 } else if ((row_pin & 0xF0) == 0x40) {
292 DDRD |= (1<<(row_pin & 0x0F));
293 PORTD &= ~(1<<(row_pin & 0x0F));
294 } else if ((row_pin & 0xF0) == 0x50) {
295 DDRE |= (1<<(row_pin & 0x0F));
296 PORTE &= ~(1<<(row_pin & 0x0F));
297 } else if ((row_pin & 0xF0) == 0x60) {
298 DDRF |= (1<<(row_pin & 0x0F));
299 PORTF &= ~(1<<(row_pin & 0x0F));
300 }
301} \ No newline at end of file