aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCole Markham <github@themarkhams.us>2019-02-05 16:56:17 -0600
committerMechMerlin <30334081+mechmerlin@users.noreply.github.com>2019-02-05 14:56:17 -0800
commit0affcc8bc3fbe6ed1f5ef6791a41b459421f0ed8 (patch)
tree3718b15a37f983d61ac19414f16d1f13b89c9ac1
parent5c7a31eae2518b2630f31cf825ecbb08e358ae76 (diff)
downloadqmk_firmware-0affcc8bc3fbe6ed1f5ef6791a41b459421f0ed8.tar.gz
qmk_firmware-0affcc8bc3fbe6ed1f5ef6791a41b459421f0ed8.zip
Add Scarlet Bandana Version IV mark.2 (#3397)
* Add scarlet bandana * updates for scarlet bandana
-rw-r--r--keyboards/scarletbandana/config.h63
-rw-r--r--keyboards/scarletbandana/keymaps/default/config.h24
-rw-r--r--keyboards/scarletbandana/keymaps/default/keymap.c192
-rw-r--r--keyboards/scarletbandana/keymaps/default/readme.md1
-rw-r--r--keyboards/scarletbandana/matrix.c326
-rw-r--r--keyboards/scarletbandana/readme.md31
-rw-r--r--keyboards/scarletbandana/rules.mk69
-rw-r--r--keyboards/scarletbandana/scarletbandana.c102
-rw-r--r--keyboards/scarletbandana/scarletbandana.h43
9 files changed, 851 insertions, 0 deletions
diff --git a/keyboards/scarletbandana/config.h b/keyboards/scarletbandana/config.h
new file mode 100644
index 000000000..7716813dd
--- /dev/null
+++ b/keyboards/scarletbandana/config.h
@@ -0,0 +1,63 @@
1/*
2Copyright 2017 Cole Markham
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 CONFIG_H
19#define CONFIG_H
20
21#include "config_common.h"
22
23/* USB Device descriptor parameter */
24#define VENDOR_ID 0xFEED
25#define PRODUCT_ID 0x6969
26#define DEVICE_VER 0x0001
27#define MANUFACTURER WoodKeys.click
28#define PRODUCT Scarlet Bandana Version IV mark.2
29#define DESCRIPTION What keyboard is that?
30
31/* key matrix size */
32#define MATRIX_ROWS 5
33#define MATRIX_COLS 17
34
35/* COL2ROW, ROW2COL, or CUSTOM_MATRIX */
36#define DIODE_DIRECTION ROW2COL
37
38#ifdef RGBLIGHT_ENABLE
39#define RGB_DI_PIN D3
40#define RGBLIGHT_ANIMATIONS
41#define RGBLED_NUM 8 // Number of LEDs
42#endif
43
44#define MATRIX_ROW_PINS { D4, D6, D7, B4, B5 }
45#define MATRIX_COL_PINS { B2, B3, B7, B1, F5, F4, F6, F7, B0, F0, F1, D0, D1, D2, D5, B6, C7 }
46
47#define QMK_SPEAKER C6
48
49#ifdef AUDIO_ENABLE
50#define C6_AUDIO
51#define STARTUP_SONG SONG(PREONIC_SOUND)
52// Disable music mode to keep the firmware size down
53#define NO_MUSIC_MODE
54#endif
55
56#define DEBOUNCING_DELAY 5
57
58/* key combination for command */
59#define IS_COMMAND() ( \
60 keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
61)
62
63#endif
diff --git a/keyboards/scarletbandana/keymaps/default/config.h b/keyboards/scarletbandana/keymaps/default/config.h
new file mode 100644
index 000000000..97210115b
--- /dev/null
+++ b/keyboards/scarletbandana/keymaps/default/config.h
@@ -0,0 +1,24 @@
1/* Copyright 2017 Cole Markham, WoodKeys.click
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef CONFIG_USER_H
18#define CONFIG_USER_H
19
20#include "../../config.h"
21
22// place overrides here
23
24#endif
diff --git a/keyboards/scarletbandana/keymaps/default/keymap.c b/keyboards/scarletbandana/keymaps/default/keymap.c
new file mode 100644
index 000000000..c67eeab7f
--- /dev/null
+++ b/keyboards/scarletbandana/keymaps/default/keymap.c
@@ -0,0 +1,192 @@
1/* Copyright 2017 Cole Markham
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#include "../../scarletbandana.h"
17
18#ifdef RGBLIGHT_ENABLE
19//Following line allows macro to read current RGB settings
20extern rgblight_config_t rgblight_config;
21#endif
22
23#define _QWERTY 0
24#define _COLEMAK 1
25#define _DVORAK 2
26#define _LOWER 3
27#define _RAISE 4
28#define _ADJUST 16
29
30enum custom_keycodes {
31 QWERTY = SAFE_RANGE,
32 COLEMAK,
33 DVORAK,
34 LOWER,
35 RAISE,
36 ADJUST,
37};
38
39// define variables for reactive RGB
40bool TOG_STATUS = false;
41int RGB_current_mode;
42
43const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
44 [_QWERTY] = KEYMAP(
45 KC_F1, KC_F2, KC_ESC,KC_1,KC_2,KC_3,KC_4,KC_5,KC_6,KC_7,KC_8,KC_9,KC_0,KC_MINS,KC_EQL,KC_BSPC, KC_PGUP,\
46 KC_F3, KC_F4, KC_TAB,KC_Q,KC_W,KC_E,KC_R,KC_T,KC_Y,KC_U,KC_I,KC_O,KC_P,KC_LBRC,KC_RBRC,KC_BSLS, KC_PGDN,\
47 KC_F5, KC_F6, KC_CAPS,KC_A,KC_S,KC_D,KC_F,KC_G,KC_H,KC_J,KC_K,KC_L,KC_SCLN,KC_QUOT,KC_ENT, KC_DEL, KC_HOME,\
48 KC_F7, KC_F8, KC_LSFT,KC_Z,KC_X,KC_C,KC_V,KC_B,KC_N,KC_M,KC_COMM,KC_DOT,KC_SLASH,KC_RSFT,KC_UP,KC_END,\
49 KC_F9, KC_F10, KC_LCTL,KC_LGUI,KC_LALT, RAISE, KC_SPACE, LOWER, KC_RALT,KC_APP,KC_RCTRL,KC_LEFT,KC_DOWN,KC_RIGHT),
50
51 [_RAISE] = KEYMAP(
52 RGB_MOD, _______, _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,\
53 _______, _______, _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,\
54 _______, _______, _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______, _______,\
55 _______, _______, _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,\
56 _______, _______, _______,_______,_______, _______, _______, _______, _______,_______,_______,_______,_______,_______),
57
58 [_LOWER] = KEYMAP(
59 RGB_MOD, _______, _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,\
60 _______, _______, _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,\
61 _______, _______, _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______, _______,\
62 _______, _______, _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,\
63 _______, _______, _______,_______,_______, _______, _______, _______, _______,_______,_______,_______,_______,_______),
64
65 [_ADJUST] = KEYMAP(
66 RESET, _______, _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,\
67 _______, _______, _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,\
68 _______, _______, _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______, _______,\
69 _______, _______, _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,\
70 _______, _______, _______,_______,_______, _______, _______, _______, _______,_______,_______,_______,_______,_______)
71};
72
73const uint16_t PROGMEM fn_actions[] = {
74
75};
76
77// Setting ADJUST layer RGB back to default
78void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
79 if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
80#ifdef RGBLIGHT_ENABLE
81 rgblight_mode(RGB_current_mode);
82#endif
83 layer_on(layer3);
84 } else {
85 layer_off(layer3);
86 }
87}
88
89const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
90{
91 // MACRODOWN only works in this function
92 switch(id) {
93 case 0:
94 if (record->event.pressed) {
95 register_code(KC_RSFT);
96 } else {
97 unregister_code(KC_RSFT);
98 }
99 break;
100 }
101 return MACRO_NONE;
102};
103
104#ifdef AUDIO_ENABLE
105
106 float tone_qwerty[][2] = SONG(QWERTY_SOUND);
107#endif
108
109void matrix_init_user(void) {
110
111}
112
113void matrix_scan_user(void) {
114
115}
116
117bool process_record_user(uint16_t keycode, keyrecord_t *record) {
118 switch (keycode) {
119 case LOWER:
120 if (record->event.pressed) {
121 //not sure how to have keyboard check mode and set it to a variable, so my work around
122 //uses another variable that would be set to true after the first time a reactive key is pressed.
123 if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false
124 } else {
125 TOG_STATUS = !TOG_STATUS;
126#ifdef RGBLIGHT_ENABLE
127 rgblight_mode(16);
128#endif
129 }
130 layer_on(_LOWER);
131 update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
132 } else {
133#ifdef RGBLIGHT_ENABLE
134 rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change
135#endif
136 TOG_STATUS = false;
137 layer_off(_LOWER);
138 update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
139 }
140 return false;
141 break;
142 case RAISE:
143 if (record->event.pressed) {
144 //not sure how to have keyboard check mode and set it to a variable, so my work around
145 //uses another variable that would be set to true after the first time a reactive key is pressed.
146 if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false
147 } else {
148 TOG_STATUS = !TOG_STATUS;
149#ifdef RGBLIGHT_ENABLE
150 rgblight_mode(15);
151#endif
152 }
153 layer_on(_RAISE);
154 update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
155 } else {
156#ifdef RGBLIGHT_ENABLE
157 rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change
158#endif
159 layer_off(_RAISE);
160 TOG_STATUS = false;
161 update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
162 }
163 return false;
164 break;
165 case ADJUST:
166 // FIXME add RGB feedback
167 if (record->event.pressed) {
168 layer_on(_ADJUST);
169 } else {
170 layer_off(_ADJUST);
171 }
172 return false;
173 break;
174 break;
175 //led operations - RGB mode change now updates the RGB_current_mode to allow the right RGB mode to be set after reactive keys are released
176#ifdef RGBLIGHT_ENABLE
177 case RGB_MOD:
178 if (record->event.pressed) {
179 rgblight_mode(RGB_current_mode);
180 rgblight_step();
181 RGB_current_mode = rgblight_config.mode;
182 }
183 return false;
184 break;
185#endif
186 }
187 return true;
188}
189
190void led_set_user(uint8_t usb_led) {
191
192}
diff --git a/keyboards/scarletbandana/keymaps/default/readme.md b/keyboards/scarletbandana/keymaps/default/readme.md
new file mode 100644
index 000000000..c2c281fe3
--- /dev/null
+++ b/keyboards/scarletbandana/keymaps/default/readme.md
@@ -0,0 +1 @@
# The default keymap for scarletbandana
diff --git a/keyboards/scarletbandana/matrix.c b/keyboards/scarletbandana/matrix.c
new file mode 100644
index 000000000..7b7934c9e
--- /dev/null
+++ b/keyboards/scarletbandana/matrix.c
@@ -0,0 +1,326 @@
1/*
2Copyright 2012 Jun Wako <wakojun@gmail.com>
3Copyright 2017 Cole Markham <cole@ccmcomputing.net>
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#if defined(__AVR__)
25#include <avr/io.h>
26#include "pincontrol.h"
27#endif
28#include "wait.h"
29#include "print.h"
30#include "debug.h"
31#include "util.h"
32#include "matrix.h"
33#include "config.h"
34#include "timer.h"
35//#include "audio.h"
36
37#ifndef DEBOUNCING_DELAY
38# define DEBOUNCING_DELAY 5
39#endif
40
41#if (DEBOUNCING_DELAY > 0)
42 static uint16_t debouncing_time;
43 static bool debouncing = false;
44#endif
45
46#if (MATRIX_COLS <= 8)
47# define print_matrix_header() print("\nr/c 01234567\n")
48# define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row))
49# define matrix_bitpop(i) bitpop(matrix[i])
50# define ROW_SHIFTER ((uint8_t)1)
51#elif (MATRIX_COLS <= 16)
52# define print_matrix_header() print("\nr/c 0123456789ABCDEF\n")
53# define print_matrix_row(row) print_bin_reverse16(matrix_get_row(row))
54# define matrix_bitpop(i) bitpop16(matrix[i])
55# define ROW_SHIFTER ((uint16_t)1)
56#elif (MATRIX_COLS <= 32)
57# define print_matrix_header() print("\nr/c 0123456789ABCDEF0123456789ABCDEF\n")
58# define print_matrix_row(row) print_bin_reverse32(matrix_get_row(row))
59# define matrix_bitpop(i) bitpop32(matrix[i])
60# define ROW_SHIFTER ((uint32_t)1)
61#endif
62
63static matrix_row_t matrix_debouncing[MATRIX_ROWS];
64
65static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
66static const uint8_t col_pins[4] = MATRIX_COL_PINS;
67static const uint8_t xcol_pins[MATRIX_COLS - 16] = MATRIX_XCOL_PINS;
68//
69//float init_song[][2] = SONG(QWERTY_SOUND);
70
71/* matrix state(1:on, 0:off) */
72static matrix_row_t matrix[MATRIX_ROWS];
73static matrix_row_t matrix_debouncing[MATRIX_ROWS];
74static void init_rows(void);
75static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col);
76static void unselect_cols(void);
77static void init_cols(void);
78static void select_col(uint8_t col);
79//static void demux_enable(bool enabled);
80
81__attribute__ ((weak))
82void matrix_init_quantum(void) {
83 matrix_init_kb();
84}
85
86__attribute__ ((weak))
87void matrix_scan_quantum(void) {
88 matrix_scan_kb();
89}
90
91__attribute__ ((weak))
92void matrix_init_kb(void) {
93 matrix_init_user();
94}
95
96__attribute__ ((weak))
97void matrix_scan_kb(void) {
98 matrix_scan_user();
99}
100
101__attribute__ ((weak))
102void matrix_init_user(void) {
103}
104
105__attribute__ ((weak))
106void matrix_scan_user(void) {
107}
108
109inline
110uint8_t matrix_rows(void)
111{
112 return MATRIX_ROWS;
113}
114
115inline
116uint8_t matrix_cols(void)
117{
118 return MATRIX_COLS;
119}
120
121void matrix_init(void)
122{
123 debug_enable = true;
124 debug_matrix = true;
125 debug_mouse = true;
126 dprintf("matrix init");
127 // initialize row and col
128 init_cols();
129 init_rows();
130
131
132// PLAY_NOTE_ARRAY(init_song, false, 0);
133
134
135 // initialize matrix state: all keys off
136 for (uint8_t i=0; i < MATRIX_ROWS; i++) {
137 matrix[i] = 0;
138 matrix_debouncing[i] = 0;
139 }
140
141 matrix_init_quantum();
142
143}
144
145uint8_t _matrix_scan(void)
146{
147 // Set col, read rows
148 for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) {
149# if (DEBOUNCING_DELAY > 0)
150 bool matrix_changed = read_rows_on_col(matrix_debouncing, current_col);
151 if (matrix_changed) {
152 debouncing = true;
153 debouncing_time = timer_read();
154 }
155# else
156 read_rows_on_col(matrix, current_col);
157# endif
158
159 }
160
161 // Unselect cols
162 unselect_cols();
163
164# if (DEBOUNCING_DELAY > 0)
165 if (debouncing && (timer_elapsed(debouncing_time) > DEBOUNCING_DELAY)) {
166 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
167 matrix[i] = matrix_debouncing[i];
168 }
169 debouncing = false;
170 }
171# endif
172
173 return 1;
174}
175
176uint8_t matrix_scan(void)
177{
178 uint8_t ret = _matrix_scan();
179 matrix_scan_quantum();
180 return ret;
181}
182
183bool matrix_is_modified(void)
184{
185 if (debouncing) return false;
186 return true;
187}
188
189inline
190bool matrix_is_on(uint8_t row, uint8_t col)
191{
192 return (matrix[row] & ((matrix_row_t)1<<col));
193}
194
195inline
196matrix_row_t matrix_get_row(uint8_t row)
197{
198 return matrix[row];
199}
200
201void matrix_print(void)
202{
203 print("\nr/c 0123456789ABCDEF\n");
204 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
205 phex(row); print(": ");
206 pbin_reverse16(matrix_get_row(row));
207 print("\n");
208 }
209}
210
211uint8_t matrix_key_count(void)
212{
213 uint8_t count = 0;
214 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
215 count += bitpop16(matrix[i]);
216 }
217 return count;
218}
219
220
221static void init_rows(void)
222{
223 for(uint8_t x = 0; x < MATRIX_ROWS; x++) {
224 uint8_t pin = row_pins[x];
225 pinMode(pin, PinDirectionInput);
226 digitalWrite(pin, PinLevelHigh);
227 }
228}
229
230
231static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)
232{
233 bool matrix_changed = false;
234
235 // Select col and wait for col selection to stabilize
236 select_col(current_col);
237 wait_us(30);
238// wait_ms(1000);
239// PLAY_NOTE_ARRAY(init_song, false, 0);
240
241 // For each row...
242 for(uint8_t row_index = 0; row_index < MATRIX_ROWS; row_index++)
243 {
244
245 // Store last value of row prior to reading
246 matrix_row_t last_row_value = current_matrix[row_index];
247
248 // Check row pin state
249 uint8_t pin = row_pins[row_index];
250 if (digitalRead(pin) == 0)
251 {
252 // Pin LO, set col bit
253 current_matrix[row_index] |= (ROW_SHIFTER << current_col);
254 }
255 else
256 {
257 // Pin HI, clear col bit
258 current_matrix[row_index] &= ~(ROW_SHIFTER << current_col);
259 }
260
261 // Determine if the matrix changed state
262 if ((last_row_value != current_matrix[row_index]) && !(matrix_changed))
263 {
264 matrix_changed = true;
265 }
266 }
267
268 return matrix_changed;
269}
270
271static void select_col(uint8_t col)
272{
273 for (uint8_t y = 16; y < MATRIX_COLS; y++) {
274 uint8_t pin = xcol_pins[y-16];
275 if (y == col) {
276 digitalWrite(pin, PinLevelLow);
277 } else {
278 digitalWrite(pin, PinLevelHigh);
279 }
280 }
281 if (col >= 16) {
282// demux_enable(false);
283// digitalWrite(MATRIX_EN_PIN, PinLevelHigh);
284 } else {
285 for(uint8_t x = 0; x < 4; x++) {
286 uint8_t pin = col_pins[x];
287 pinMode(pin, PinDirectionOutput);
288 digitalWrite(pin, (col >> x) & 0x1);
289 }
290// demux_enable(true);
291 digitalWrite(MATRIX_EN_PIN, PinLevelLow);
292 }
293}
294
295static void init_cols(void) {
296 for (uint8_t y = 16; y < MATRIX_COLS; y++) {
297 uint8_t pin = xcol_pins[y-16];
298 pinMode(pin, PinDirectionOutput);
299 }
300 for(uint8_t x = 0; x < 4; x++) {
301 uint8_t pin = col_pins[x];
302 pinMode(pin, PinDirectionOutput);
303 }
304 pinMode(MATRIX_EN_PIN, PinDirectionOutput);
305// digitalWrite(MATRIX_EN_PIN, PinLevelHigh);
306 unselect_cols();
307}
308
309static void unselect_cols(void)
310{
311 for (uint8_t y = 16; y < MATRIX_COLS; y++) {
312 uint8_t pin = xcol_pins[y-16];
313 digitalWrite(pin, PinLevelHigh);
314 }
315// demux_enable(false);
316// digitalWrite(MATRIX_EN_PIN, PinLevelHigh);
317}
318
319//static void demux_enable(uint8_t state)
320//{
321// if (enabled){
322// digitalWrite(F7, PinLevelLow);
323// } else {
324// digitalWrite(F7, PinLevelHigh);
325// }
326//}
diff --git a/keyboards/scarletbandana/readme.md b/keyboards/scarletbandana/readme.md
new file mode 100644
index 000000000..6d5d9b553
--- /dev/null
+++ b/keyboards/scarletbandana/readme.md
@@ -0,0 +1,31 @@
1# Meira
2
3![Miera](https://imgur.com/kF4MFlW)
4
5A 4x12 ortholinear low-profile keyboard.
6
7Keyboard Maintainer: [Cole Markham](https://github.com/colemarkham)
8Hardware Supported: Meira/ProMicro, Meira/FeatherBLE
9Hardware Availability: [WoodKeys.click](https://woodkeys.click/meira)
10
11Two controllers are support: the Pro Micro, and the Adafruit Feather BLE 32u4. Support for each is defined as a hardware revision subfolder in QMK. Main differences include processor frequencies and matrix pinouts.
12
13Make example for this keyboard (after setting up your build environment):
14
15 make meira/promicro:default
16
17or
18
19 make meira/featherble:default
20
21See [build environment setup](https://docs.qmk.fm/build_environment_setup.html) then the [make instructions](https://docs.qmk.fm/make_instructions.html) for more information on generic QMK configuration and setup.
22
23Both the Pro Micro and the Feather BLE use the Catalina bootloader, which is typically programmed using avrdude.
24
25## Matrix
26
27In order to have enough pins for the matrix and other functions, a custom matrix is implemented using a demultiplexer to scan the columns. Since the demux is active low, the diodes must be oriented with the cathode connected to the demux pin. When looking at the bottom of the board with the controller at the top right, the cathode mark on the diode should be toward the left.
28
29## LED Controller
30
31The in-switch LEDs are driven by an ISSI LED controller (IS31FL3731). The micro controller communicates with this chip using I2C. Individual LED control is possible, but currently only general backlighting support is implemented. This functionality is located in lighting.c, issi.c, and TWILib.c. \ No newline at end of file
diff --git a/keyboards/scarletbandana/rules.mk b/keyboards/scarletbandana/rules.mk
new file mode 100644
index 000000000..b6f61d8a4
--- /dev/null
+++ b/keyboards/scarletbandana/rules.mk
@@ -0,0 +1,69 @@
1# MCU name
2#MCU = at90usb1286
3MCU = atmega32u4
4
5# Processor frequency.
6# This will define a symbol, F_CPU, in all source code files equal to the
7# processor frequency in Hz. You can then use this symbol in your source code to
8# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
9# automatically to create a 32-bit value in your source code.
10#
11# This will be an integer division of F_USB below, as it is sourced by
12# F_USB after it has run through any CPU prescalers. Note that this value
13# does not *change* the processor frequency - it should merely be updated to
14# reflect the processor speed set externally so that the code can use accurate
15# software delays.
16F_CPU = 16000000
17
18
19#
20# LUFA specific
21#
22# Target architecture (see library "Board Types" documentation).
23ARCH = AVR8
24
25# Input clock frequency.
26# This will define a symbol, F_USB, in all source code files equal to the
27# input clock frequency (before any prescaling is performed) in Hz. This value may
28# differ from F_CPU if prescaling is used on the latter, and is required as the
29# raw input clock is fed directly to the PLL sections of the AVR for high speed
30# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
31# at the end, this will be done automatically to create a 32-bit value in your
32# source code.
33#
34# If no clock division is performed on the input clock inside the AVR (via the
35# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
36F_USB = $(F_CPU)
37
38# Interrupt driven control endpoint task(+60)
39OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
40
41
42# Boot Section Size in *bytes*
43# Teensy halfKay 512
44# Teensy++ halfKay 1024
45# Atmel DFU loader 4096
46# LUFA bootloader 4096
47# USBaspLoader 2048
48OPT_DEFS += -DBOOTLOADER_SIZE=4096
49
50
51# Build Options
52# change yes to no to disable
53#
54BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
55MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
56EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
57CONSOLE_ENABLE = no # Console for debug(+400)
58COMMAND_ENABLE = no # Commands for debug and configuration
59# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
60SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
61# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
62NKRO_ENABLE = no # USB Nkey Rollover
63MIDI_ENABLE = no # MIDI support (+2400 to 4200, depending on config)
64UNICODE_ENABLE = no # Unicode
65BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
66AUDIO_ENABLE = yes # Audio output on port C6
67RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight. Do not enable this with audio at the same time.
68FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches
69BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality, also set ISSI_ENABLE below for Miera
diff --git a/keyboards/scarletbandana/scarletbandana.c b/keyboards/scarletbandana/scarletbandana.c
new file mode 100644
index 000000000..6926312ec
--- /dev/null
+++ b/keyboards/scarletbandana/scarletbandana.c
@@ -0,0 +1,102 @@
1/* Copyright 2017 Cole Markham, WoodKeys.click
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#include "scarletbandana.h"
17#include <LUFA/Common/Common.h>
18
19#include "quantum.h"
20
21#ifdef AUDIO_ENABLE
22 float tone_startup[][2] = SONG(STARTUP_SOUND);
23 float tone_goodbye[][2] = SONG(GOODBYE_SOUND);
24#endif
25
26
27void shutdown_user(void) {
28 #ifdef AUDIO_ENABLE
29 PLAY_NOTE_ARRAY(tone_goodbye, false, 0);
30 _delay_ms(150);
31 stop_all_notes();
32 #endif
33}
34
35
36void matrix_init_kb(void)
37{
38 // This is required to access the pins in the F-register
39 JTAG_DISABLE();
40 debug_enable=true;
41 print("sb matrix_init_kb\n");
42#ifdef AUDIO_ENABLE
43 _delay_ms(20); // gets rid of tick
44 PLAY_NOTE_ARRAY(tone_startup, false, 0);
45#endif
46
47
48 // put your keyboard start-up code here
49 // runs once when the firmware starts up
50 matrix_init_user();
51}
52
53void matrix_scan_kb(void)
54{
55 matrix_scan_user();
56}
57
58bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
59 // Test code that turns on the switch led for the key that is pressed
60 // set_backlight_by_keymap(record->event.key.col, record->event.key.row);
61 if (keycode == RESET) {
62 reset_keyboard_kb();
63 } else {
64 }
65 return process_record_user(keycode, record);
66}
67
68void led_set_kb(uint8_t usb_led) {
69 // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
70 led_set_user(usb_led);
71}
72
73//void action_function(keyrecord_t *event, uint8_t id, uint8_t opt)
74//{
75//#ifdef AUDIO_ENABLE
76// int8_t sign = 1;
77//#endif
78// if(id == LFK_ESC_TILDE){
79// // Send ~ on shift-esc
80// void (*method)(uint8_t) = (event->event.pressed) ? &add_key : &del_key;
81// uint8_t shifted = get_mods() & (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT));
82// method(shifted ? KC_GRAVE : KC_ESCAPE);
83// send_keyboard_report();
84// }else if(event->event.pressed){
85// switch(id){
86// case LFK_CLEAR:
87// // Go back to default layer
88// layer_clear();
89// break;
90//#ifdef ISSI_ENABLE
91// case LFK_LED_TEST:
92// led_test();
93// break;
94//#endif
95// }
96// }
97//}
98
99void reset_keyboard_kb(){
100 xprintf("programming!\n");
101 reset_keyboard();
102}
diff --git a/keyboards/scarletbandana/scarletbandana.h b/keyboards/scarletbandana/scarletbandana.h
new file mode 100644
index 000000000..77b6afa7a
--- /dev/null
+++ b/keyboards/scarletbandana/scarletbandana.h
@@ -0,0 +1,43 @@
1/* Copyright 2017 Cole Markham
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#ifndef SCARLETBANDANA_H
17#define SCARLETBANDANA_H
18
19#include "quantum.h"
20
21void reset_keyboard_kb(void);
22
23// This a shortcut to help you visually see your layout.
24// The following is an example using the Planck MIT layout
25// The first section contains all of the arguments
26// The second converts the arguments into a two-dimensional array
27#define KEYMAP( \
28 k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, k0c, k0d, k0e, k0f, k0g, \
29 k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b, k1c, k1d, k1e, k1f, k1g, \
30 k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k2b, k2c, k2d, k2e, k2f, k2g, \
31 k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3a, k3b, k3c, k3e, k3f, k3g, \
32 k40, k41, k42, k43, k44, k45, k47, k49, k4a, k4b, k4c, k4e, k4f, k4g \
33) \
34{ \
35 { k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, k0c, k0d, k0e, k0f, k0g }, \
36 { k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b, k1c, k1d, k1e, k1f, k1g }, \
37 { k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k2b, k2c, k2d, k2e, k2f, k2g }, \
38 { k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3a, k3b, k3c, KC_NO, k3e, k3f, k3g }, \
39 { k40, k41, k42, k43, k44, k45, KC_NO, k47, KC_NO, k49, k4a, k4b, k4c, KC_NO, k4e, k4f, k4g } \
40}
41
42#endif
43