summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--keyboards/nullbitsco/nibble/README.md19
-rw-r--r--keyboards/nullbitsco/nibble/big_led.c67
-rw-r--r--keyboards/nullbitsco/nibble/big_led.h34
-rw-r--r--keyboards/nullbitsco/nibble/bitc_led.c37
-rw-r--r--keyboards/nullbitsco/nibble/bitc_led.h29
-rw-r--r--keyboards/nullbitsco/nibble/config.h61
-rw-r--r--keyboards/nullbitsco/nibble/keymaps/default/keymap.c128
-rw-r--r--keyboards/nullbitsco/nibble/keymaps/iso/keymap.c128
-rw-r--r--keyboards/nullbitsco/nibble/keymaps/via/config.h21
-rw-r--r--keyboards/nullbitsco/nibble/keymaps/via/keymap.c164
-rw-r--r--keyboards/nullbitsco/nibble/keymaps/via/nibble_encoder.c133
-rw-r--r--keyboards/nullbitsco/nibble/keymaps/via/nibble_encoder.h50
-rw-r--r--keyboards/nullbitsco/nibble/keymaps/via/rules.mk4
-rw-r--r--keyboards/nullbitsco/nibble/keymaps/via/via_extras.c129
-rw-r--r--keyboards/nullbitsco/nibble/keymaps/via/via_extras.h39
-rw-r--r--keyboards/nullbitsco/nibble/matrix.c95
-rw-r--r--keyboards/nullbitsco/nibble/nibble.c26
-rw-r--r--keyboards/nullbitsco/nibble/nibble.h63
-rw-r--r--keyboards/nullbitsco/nibble/remote_kb.c177
-rw-r--r--keyboards/nullbitsco/nibble/remote_kb.h53
-rw-r--r--keyboards/nullbitsco/nibble/rules.mk35
21 files changed, 1492 insertions, 0 deletions
diff --git a/keyboards/nullbitsco/nibble/README.md b/keyboards/nullbitsco/nibble/README.md
new file mode 100644
index 0000000000..92825847d6
--- /dev/null
+++ b/keyboards/nullbitsco/nibble/README.md
@@ -0,0 +1,19 @@
+# NIBBLE
+
+![NIBBLE](https://nullbits.co/static/img/nibble1.jpg)
+
+A unique, tweakable 65% keyboard kit built by nullbits. [More info at nullbits.co](https://nullbits.co/nibble/)
+
+* Keyboard Maintainer: [Jay Greco](https://github.com/jaygreco)
+* Hardware Supported: NIBBLE Rev1, Pro Micro comaptible MCUs.
+* Hardware Availability: [nullbits.co](https://nullbits.co/)
+
+Note: If you are seeing issues with MacOS and keyboard hangs after sleep, make sure `NO_USB_STARTUP_CHECK = yes` is set in your rules.mk.
+
+Adds experimental "Remote Keyboard" functionality, which forwards keystrokes from an external macropad, keyboard, or numpad over UART/TRRS, removing the need for an additional USB connection.
+
+Make example for this keyboard (after setting up your build environment):
+
+ make nullbitsco/nibble:default
+
+See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).
diff --git a/keyboards/nullbitsco/nibble/big_led.c b/keyboards/nullbitsco/nibble/big_led.c
new file mode 100644
index 0000000000..eb0d0a5071
--- /dev/null
+++ b/keyboards/nullbitsco/nibble/big_led.c
@@ -0,0 +1,67 @@
+/* Copyright 2020 Jay Greco
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include "big_led.h"
+
+void set_big_LED_r(uint8_t mode) {
+ switch(mode) {
+ case LED_ON:
+ setPinOutput(BIG_LED_R_PIN);
+ writePin(BIG_LED_R_PIN, GPIO_STATE_HIGH);
+ break;
+
+ case LED_OFF:
+ setPinOutput(BIG_LED_R_PIN);
+ writePin(BIG_LED_R_PIN, GPIO_STATE_LOW);
+ break;
+
+ default:
+ break;
+ }
+}
+
+void set_big_LED_g(uint8_t mode) {
+ switch(mode) {
+ case LED_ON:
+ setPinOutput(BIG_LED_G_PIN);
+ writePin(BIG_LED_G_PIN, GPIO_STATE_HIGH);
+ break;
+
+ case LED_OFF:
+ setPinOutput(BIG_LED_G_PIN);
+ writePin(BIG_LED_G_PIN, GPIO_STATE_LOW);
+ break;
+
+ default:
+ break;
+ }
+}
+
+void set_big_LED_b(uint8_t mode) {
+ switch(mode) {
+ case LED_ON:
+ setPinOutput(BIG_LED_B_PIN);
+ writePin(BIG_LED_B_PIN, GPIO_STATE_HIGH);
+ break;
+
+ case LED_OFF:
+ setPinOutput(BIG_LED_B_PIN);
+ writePin(BIG_LED_B_PIN, GPIO_STATE_LOW);
+ break;
+
+ default:
+ break;
+ }
+} \ No newline at end of file
diff --git a/keyboards/nullbitsco/nibble/big_led.h b/keyboards/nullbitsco/nibble/big_led.h
new file mode 100644
index 0000000000..113aaaf106
--- /dev/null
+++ b/keyboards/nullbitsco/nibble/big_led.h
@@ -0,0 +1,34 @@
+/* Copyright 2020 Jay Greco
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#pragma once
+
+#include "quantum.h"
+
+/* Optional big LED pins */
+#define BIG_LED_R_PIN D7
+#define BIG_LED_G_PIN C6
+#define BIG_LED_B_PIN D0
+
+#define LED_ON 2
+#define LED_OFF 0
+
+#define GPIO_STATE_LOW 0
+#define GPIO_STATE_HIGH 1
+
+void
+ set_big_LED_r(uint8_t mode),
+ set_big_LED_g(uint8_t mode),
+ set_big_LED_b(uint8_t mode); \ No newline at end of file
diff --git a/keyboards/nullbitsco/nibble/bitc_led.c b/keyboards/nullbitsco/nibble/bitc_led.c
new file mode 100644
index 0000000000..60ffeea278
--- /dev/null
+++ b/keyboards/nullbitsco/nibble/bitc_led.c
@@ -0,0 +1,37 @@
+/* Copyright 2020 Jay Greco
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include "bitc_led.h"
+
+void set_bitc_LED(uint8_t mode) {
+ switch(mode) {
+ case LED_ON:
+ setPinOutput(PIN_LED);
+ writePin(PIN_LED, GPIO_STATE_HIGH);
+ break;
+
+ case LED_DIM:
+ setPinInput(PIN_LED);
+ break;
+
+ case LED_OFF:
+ setPinOutput(PIN_LED);
+ writePin(PIN_LED, GPIO_STATE_LOW);
+ break;
+
+ default:
+ break;
+ }
+} \ No newline at end of file
diff --git a/keyboards/nullbitsco/nibble/bitc_led.h b/keyboards/nullbitsco/nibble/bitc_led.h
new file mode 100644
index 0000000000..b3552a7d19
--- /dev/null
+++ b/keyboards/nullbitsco/nibble/bitc_led.h
@@ -0,0 +1,29 @@
+/* Copyright 2020 Jay Greco
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#pragma once
+
+#include "quantum.h"
+
+#define LED_ON 2
+#define LED_DIM 1
+#define LED_OFF 0
+
+#define GPIO_STATE_LOW 0
+#define GPIO_STATE_HIGH 1
+
+#define PIN_LED F0
+
+void set_bitc_LED(uint8_t mode); \ No newline at end of file
diff --git a/keyboards/nullbitsco/nibble/config.h b/keyboards/nullbitsco/nibble/config.h
new file mode 100644
index 0000000000..3e0adce454
--- /dev/null
+++ b/keyboards/nullbitsco/nibble/config.h
@@ -0,0 +1,61 @@
+/* Copyright 2020 Jay Greco
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#pragma once
+
+#include "config_common.h"
+
+/* Used to set host for remote KB if VUSB detect doesn't work. */
+// #define KEYBOARD_HOST // Force host mode
+// #define KEYBOARD_REMOTE // Force remote mode
+
+// Workaround for freezing after MacOS sleep
+#define NO_USB_STARTUP_CHECK
+
+/* USB Device descriptor parameter */
+#define VENDOR_ID 0x6E61
+#define PRODUCT_ID 0x6060
+
+#define DEVICE_VER 0x0001
+#define MANUFACTURER nullbits
+#define PRODUCT NIBBLE
+
+/* key matrix size */
+#define MATRIX_ROWS 5
+#define MATRIX_COLS 16
+#define MATRIX_MUX_COLS 4
+
+/* Set 0 if debouncing isn't needed */
+#define DEBOUNCE 10
+
+/*
+ * Keyboard Matrix Assignments
+ * The nibble uses a demultiplexer for the cols.
+ * to free up more IOs for awesomeness!
+ * See matrix.c for more details.
+*/
+#define MATRIX_ROW_PINS { B1, B3, B2, B6, D4 }
+#define MATRIX_COL_MUX_PINS { F4, F5, F6, F7 }
+#define MATRIX_COL_PINS { }
+
+/* Optional SMT LED pins */
+#define RGB_DI_PIN E6
+#define RGBLED_NUM 10
+#define RGBLIGHT_ANIMATIONS
+#define RGBLIGHT_SLEEP
+
+/* Optional encoder pins */
+#define ENCODERS_PAD_A { B5 }
+#define ENCODERS_PAD_B { B4 } \ No newline at end of file
diff --git a/keyboards/nullbitsco/nibble/keymaps/default/keymap.c b/keyboards/nullbitsco/nibble/keymaps/default/keymap.c
new file mode 100644
index 0000000000..6d453e7067
--- /dev/null
+++ b/keyboards/nullbitsco/nibble/keymaps/default/keymap.c
@@ -0,0 +1,128 @@
+/* Copyright 2020 Jay Greco
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include QMK_KEYBOARD_H
+
+#define _MA 0
+#define _FN 1
+
+enum custom_keycodes {
+ KC_CUST = SAFE_RANGE,
+};
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+ [_MA] = LAYOUT_ansi(
+ 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_TILD,
+ KC_F13, 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_DEL,
+ KC_F14, 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_PGUP,
+ KC_F15, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_PGDN,
+ KC_F16, KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, MO(_FN), KC_RALT, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT
+ ),
+ [_FN] = LAYOUT_ansi(
+ RESET, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_HOME, KC_INS,
+ RGB_TOG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
+ ),
+
+};
+
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+ // Send keystrokes to host keyboard, if connected (see readme)
+ process_record_remote_kb(keycode, record);
+ switch(keycode) {
+ case KC_CUST: //custom macro
+ if (record->event.pressed) {
+ }
+ break;
+
+ case RM_1: //remote macro 1
+ if (record->event.pressed) {
+ }
+ break;
+
+ case RM_2: //remote macro 2
+ if (record->event.pressed) {
+ }
+ break;
+
+ case RM_3: //remote macro 3
+ if (record->event.pressed) {
+ }
+ break;
+
+ case RM_4: //remote macro 4
+ if (record->event.pressed) {
+ }
+ break;
+
+ }
+return true;
+}
+
+// RGB config, for changing RGB settings on non-VIA firmwares
+void change_RGB(bool clockwise) {
+ bool shift = get_mods() & MOD_MASK_SHIFT;
+ bool alt = get_mods() & MOD_MASK_ALT;
+ bool ctrl = get_mods() & MOD_MASK_CTRL;
+
+ if (clockwise) {
+ if (alt) {
+ rgblight_increase_hue();
+ } else if (ctrl) {
+ rgblight_increase_val();
+ } else if (shift) {
+ rgblight_increase_sat();
+ } else {
+ rgblight_step();
+ }
+
+ } else {
+ if (alt) {
+ rgblight_decrease_hue();
+ } else if (ctrl) {
+ rgblight_decrease_val();
+ } else if (shift) {
+ rgblight_decrease_sat();
+ } else {
+ rgblight_step_reverse();
+ }
+ }
+}
+
+void encoder_update_kb(uint8_t index, bool clockwise) {
+ if (layer_state_is(1)) {
+ //change RGB settings
+ change_RGB(clockwise);
+ }
+ else {
+ if (clockwise) {
+ tap_code(KC_VOLU);
+ } else {
+ tap_code(KC_VOLD);
+ }
+ }
+}
+
+void matrix_init_user(void) {
+ // Initialize remote keyboard, if connected (see readme)
+ matrix_init_remote_kb();
+}
+
+void matrix_scan_user(void) {
+ // Scan and parse keystrokes from remote keyboard, if connected (see readme)
+ matrix_scan_remote_kb();
+} \ No newline at end of file
diff --git a/keyboards/nullbitsco/nibble/keymaps/iso/keymap.c b/keyboards/nullbitsco/nibble/keymaps/iso/keymap.c
new file mode 100644
index 0000000000..46f246d6ee
--- /dev/null
+++ b/keyboards/nullbitsco/nibble/keymaps/iso/keymap.c
@@ -0,0 +1,128 @@
+/* Copyright 2020 Jay Greco
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include QMK_KEYBOARD_H
+
+#define _MA 0
+#define _FN 1
+
+enum custom_keycodes {
+ KC_CUST = SAFE_RANGE,
+};
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+ [_MA] = LAYOUT_iso(
+ 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_TILD,
+ KC_F13, 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_DEL,
+ KC_F14, 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_NUHS, KC_ENT, KC_PGUP,
+ KC_F15, KC_LSFT, KC_NUBS, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_PGDN,
+ KC_F16, KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, MO(_FN), KC_RALT, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT
+ ),
+ [_FN] = LAYOUT_iso(
+ RESET, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_HOME, KC_INS,
+ RGB_TOG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
+ ),
+
+};
+
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+ // Send keystrokes to host keyboard, if connected (see readme)
+ process_record_remote_kb(keycode, record);
+ switch(keycode) {
+ case KC_CUST: //custom macro
+ if (record->event.pressed) {
+ }
+ break;
+
+ case RM_1: //remote macro 1
+ if (record->event.pressed) {
+ }
+ break;
+
+ case RM_2: //remote macro 2
+ if (record->event.pressed) {
+ }
+ break;
+
+ case RM_3: //remote macro 3
+ if (record->event.pressed) {
+ }
+ break;
+
+ case RM_4: //remote macro 4
+ if (record->event.pressed) {
+ }
+ break;
+
+ }
+return true;
+}
+
+// RGB config, for changing RGB settings on non-VIA firmwares
+void change_RGB(bool clockwise) {
+ bool shift = get_mods() & MOD_MASK_SHIFT;
+ bool alt = get_mods() & MOD_MASK_ALT;
+ bool ctrl = get_mods() & MOD_MASK_CTRL;
+
+ if (clockwise) {
+ if (alt) {
+ rgblight_increase_hue();
+ } else if (ctrl) {
+ rgblight_increase_val();
+ } else if (shift) {
+ rgblight_increase_sat();
+ } else {
+ rgblight_step();
+ }
+
+ } else {
+ if (alt) {
+ rgblight_decrease_hue();
+ } else if (ctrl) {
+ rgblight_decrease_val();
+ } else if (shift) {
+ rgblight_decrease_sat();
+ } else {
+ rgblight_step_reverse();
+ }
+ }
+}
+
+void encoder_update_kb(uint8_t index, bool clockwise) {
+ if (layer_state_is(1)) {
+ //change RGB settings
+ change_RGB(clockwise);
+ }
+ else {
+ if (clockwise) {
+ tap_code(KC_VOLU);
+ } else {
+ tap_code(KC_VOLD);
+ }
+ }
+}
+
+void matrix_init_user(void) {
+ // Initialize remote keyboard, if connected (see readme)
+ matrix_init_remote_kb();
+}
+
+void matrix_scan_user(void) {
+ // Scan and parse keystrokes from remote keyboard, if connected (see readme)
+ matrix_scan_remote_kb();
+} \ No newline at end of file
diff --git a/keyboards/nullbitsco/nibble/keymaps/via/config.h b/keyboards/nullbitsco/nibble/keymaps/via/config.h
new file mode 100644
index 0000000000..961e2aed1a
--- /dev/null
+++ b/keyboards/nullbitsco/nibble/keymaps/via/config.h
@@ -0,0 +1,21 @@
+/* Copyright 2020 Jay Greco
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+// Custom config starts after VIA's EEPROM usage,
+// dynamic keymaps start after this.
+// Custom config Usage:
+// 1 for enabled encoder modes (1 byte)
+// 6 for 3x custom encoder settings, left, right, and press (18 bytes)
+#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 19 \ No newline at end of file
diff --git a/keyboards/nullbitsco/nibble/keymaps/via/keymap.c b/keyboards/nullbitsco/nibble/keymaps/via/keymap.c
new file mode 100644
index 0000000000..1e1b0c0369
--- /dev/null
+++ b/keyboards/nullbitsco/nibble/keymaps/via/keymap.c
@@ -0,0 +1,164 @@
+/* Copyright 2020 Jay Greco
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include QMK_KEYBOARD_H
+#include "via_extras.h"
+
+#define _BASE 0
+#define _VIA1 1
+#define _VIA2 2
+#define _VIA3 3
+
+#define KC_DISC_MUTE KC_F23
+#define KC_DISC_DEAF KC_F24
+#define NUM_CUST_KEYCODES (_NUM_CUST_KCS - SAFE_RANGE)
+#define VIA_KEYCODE_RANGE 0x5F80
+
+enum custom_keycodes {
+ PROG = SAFE_RANGE,
+ DISC_MUTE,
+ DISC_DEAF,
+ SUPER_ALT_TAB,
+ _NUM_CUST_KCS,
+};
+
+// Macro variables
+bool is_alt_tab_active = false;
+uint16_t alt_tab_timer = 0;
+bool muted = false;
+bool deafened = false;
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+ [_BASE] = LAYOUT_all(
+ KC_NUBS, KC_GESC, 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_HOME,
+ KC_F13, 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_DEL,
+ KC_F14, 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_PGUP,
+ KC_F15, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_PGDN,
+ KC_F16, KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, MO(_VIA1), KC_RALT, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT
+ ),
+
+ [_VIA1] = LAYOUT_all(
+ _______, RESET, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_HOME, KC_INS,
+ RGB_TOG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, KC_MPRV, KC_MPLY, KC_MNXT
+ ),
+
+ [_VIA2] = LAYOUT_all(
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
+ ),
+
+ [_VIA3] = LAYOUT_all(
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
+ ),
+
+};
+
+void map_via_keycode(uint16_t * keycode) {
+ if (abs(*keycode - VIA_KEYCODE_RANGE) < NUM_CUST_KEYCODES) { //make into macro?
+ dprintf("VIA custom keycode found, mapping to QMK keycode.\n");
+ uint16_t new_keycode = (*keycode - VIA_KEYCODE_RANGE) + SAFE_RANGE;
+ dprintf("VIA KC: %u QMK KC: %u\n", *keycode, new_keycode);
+ *keycode = new_keycode;
+ }
+}
+
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+ map_via_keycode(&keycode);
+ // Send keystrokes to host keyboard, if connected (see readme)
+ process_record_remote_kb(keycode, record);
+ switch(keycode) {
+ case PROG:
+ if (record->event.pressed) {
+ rgblight_disable_noeeprom();
+ bootloader_jump();
+ }
+ break;
+
+ case DISC_MUTE:
+ if (record->event.pressed) {
+ tap_code(KC_DISC_MUTE);
+ if (!rgblight_is_enabled()) break;
+
+ if (muted) {
+ rgblight_enable_noeeprom();
+ } else {
+ rgblight_timer_disable();
+ uint8_t val = rgblight_get_val();
+ rgblight_sethsv_range(255, 255, val, 0, 1);
+ }
+ muted = !muted;
+ }
+ break;
+
+ case DISC_DEAF:
+ if (record->event.pressed) {
+ tap_code(KC_DISC_DEAF);
+ if (!rgblight_is_enabled()) break;
+
+ if (deafened) {
+ rgblight_enable_noeeprom();
+ } else {
+ rgblight_timer_disable();
+ uint8_t val = rgblight_get_val();
+ rgblight_sethsv_range(255, 255, val, 0, RGBLED_NUM-1);
+ }
+ deafened = !deafened;
+ }
+ break;
+
+ case SUPER_ALT_TAB:
+ if (record->event.pressed) {
+ if (!is_alt_tab_active) {
+ is_alt_tab_active = true;
+ register_code(KC_LALT);
+ }
+ alt_tab_timer = timer_read();
+ register_code(KC_TAB);
+ } else {
+ unregister_code(KC_TAB);
+ }
+ break;
+
+ default:
+ break;
+ }
+return true;
+}
+
+void matrix_init_user(void) {
+ // Initialize remote keyboard, if connected (see readme)
+ matrix_init_remote_kb();
+}
+
+void matrix_scan_user(void) {
+ // Scan and parse keystrokes from remote keyboard, if connected (see readme)
+ matrix_scan_remote_kb();
+ if (is_alt_tab_active) {
+ if (timer_elapsed(alt_tab_timer) > 1000) {
+ unregister_code(KC_LALT);
+ is_alt_tab_active = false;
+ }
+ }
+} \ No newline at end of file
diff --git a/keyboards/nullbitsco/nibble/keymaps/via/nibble_encoder.c b/keyboards/nullbitsco/nibble/keymaps/via/nibble_encoder.c
new file mode 100644
index 0000000000..bdea1869c2
--- /dev/null
+++ b/keyboards/nullbitsco/nibble/keymaps/via/nibble_encoder.c
@@ -0,0 +1,133 @@
+/* Copyright 2020 Jay Greco
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include "nibble_encoder.h"
+
+uint8_t encoder_value = 0x20,
+ encoder_mode = ENC_MODE_VOLUME,
+ enabled_encoder_modes = 0x1F;
+
+uint16_t retrieve_custom_encoder_config(uint8_t encoder_idx, uint8_t behavior) {
+#ifdef DYNAMIC_KEYMAP_ENABLE
+ void* addr = (void*)(EEPROM_CUSTOM_ENCODER + (encoder_idx * 6) + (behavior * 2));
+ uint16_t keycode = eeprom_read_byte(addr) << 8;
+ keycode |= eeprom_read_byte(addr + 1);
+ return keycode;
+#else
+ return 0;
+#endif
+}
+
+void set_custom_encoder_config(uint8_t encoder_idx, uint8_t behavior, uint16_t new_code) {
+#ifdef DYNAMIC_KEYMAP_ENABLE
+ void* addr = (void*)(EEPROM_CUSTOM_ENCODER + (encoder_idx * 6) + (behavior * 2));
+ eeprom_update_byte(addr, (uint8_t)(new_code >> 8));
+ eeprom_update_byte(addr + 1, (uint8_t)(new_code & 0xFF));
+#endif
+}
+
+void pre_encoder_mode_change(void) {
+ dprintf("Changing encoder mode: %u\n", encoder_mode);
+}
+
+void post_encoder_mode_change(void) {
+ dprintf("Encoder mode: %u\n", encoder_mode);
+}
+
+//???
+void change_encoder_mode(bool clockwise) {
+ pre_encoder_mode_change();
+ if(enabled_encoder_modes == 0){
+ enabled_encoder_modes = 0x1F;
+ }
+ do {
+ if(!clockwise){
+ if (encoder_mode == 0){
+ encoder_mode = _NUM_ENCODER_MODES - 1;
+ } else{
+ encoder_mode = encoder_mode - 1;
+ }
+ } else {
+ encoder_mode = (encoder_mode + 1) % _NUM_ENCODER_MODES;
+ }
+ } while(((1 << encoder_mode) & enabled_encoder_modes) == 0);
+ post_encoder_mode_change();
+}
+
+uint16_t handle_encoder_cw(void) {
+ dprintf("Encoder mode: %u\n", encoder_mode);
+ uint16_t mapped_code = 0;
+ switch(encoder_mode){
+ default:
+ break;
+ case ENC_MODE_VOLUME:
+ mapped_code = KC_VOLU;
+ break;
+ case ENC_MODE_MEDIA:
+ mapped_code = KC_MEDIA_NEXT_TRACK;
+ break;
+ case ENC_MODE_SCROLL:
+ mapped_code = KC_WH_D;
+ break;
+ case ENC_MODE_BACKLIGHT:
+ mapped_code = RGB_VAI;
+ break;
+#ifdef DYNAMIC_KEYMAP_ENABLE
+ case ENC_MODE_CUSTOM0:
+ mapped_code = retrieve_custom_encoder_config(0, ENC_CUSTOM_CW);
+ break;
+ case ENC_MODE_CUSTOM1:
+ mapped_code = retrieve_custom_encoder_config(1, ENC_CUSTOM_CW);
+ break;
+ case ENC_MODE_CUSTOM2:
+ mapped_code = retrieve_custom_encoder_config(2, ENC_CUSTOM_CW);
+ break;
+#endif
+ }
+ return mapped_code;
+}
+
+uint16_t handle_encoder_ccw(void) {
+ dprintf("Encoder mode: %u\n", encoder_mode);
+ uint16_t mapped_code = 0;
+ switch(encoder_mode){
+ default:
+ break;
+ case ENC_MODE_VOLUME:
+ mapped_code = KC_VOLD;
+ break;
+ case ENC_MODE_MEDIA:
+ mapped_code = KC_MEDIA_PREV_TRACK;
+ break;
+ case ENC_MODE_SCROLL:
+ mapped_code = KC_WH_U;
+ break;
+ case ENC_MODE_BACKLIGHT:
+ mapped_code = RGB_VAD;
+ break;
+#ifdef DYNAMIC_KEYMAP_ENABLE
+ case ENC_MODE_CUSTOM0:
+ mapped_code = retrieve_custom_encoder_config(0, ENC_CUSTOM_CCW);
+ break;
+ case ENC_MODE_CUSTOM1:
+ mapped_code = retrieve_custom_encoder_config(1, ENC_CUSTOM_CCW);
+ break;
+ case ENC_MODE_CUSTOM2:
+ mapped_code = retrieve_custom_encoder_config(2, ENC_CUSTOM_CCW);
+ break;
+#endif
+ }
+ return mapped_code;
+}
diff --git a/keyboards/nullbitsco/nibble/keymaps/via/nibble_encoder.h b/keyboards/nullbitsco/nibble/keymaps/via/nibble_encoder.h
new file mode 100644
index 0000000000..fc1e61434b
--- /dev/null
+++ b/keyboards/nullbitsco/nibble/keymaps/via/nibble_encoder.h
@@ -0,0 +1,50 @@
+/* Copyright 2020 Jay Greco
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#pragma once
+
+#include QMK_KEYBOARD_H
+#include "eeprom.h"
+
+#define EEPROM_ENABLED_ENCODER_MODES (VIA_EEPROM_CUSTOM_CONFIG_ADDR)
+#define EEPROM_CUSTOM_ENCODER (VIA_EEPROM_CUSTOM_CONFIG_ADDR+1)
+
+enum encoder_modes {
+ ENC_MODE_VOLUME,
+ ENC_MODE_MEDIA,
+ ENC_MODE_SCROLL,
+ ENC_MODE_BRIGHTNESS,
+ ENC_MODE_BACKLIGHT,
+ ENC_MODE_CUSTOM0,
+ ENC_MODE_CUSTOM1,
+ ENC_MODE_CUSTOM2,
+ _NUM_ENCODER_MODES,
+};
+
+enum custom_encoder_behavior {
+ ENC_CUSTOM_CW = 0,
+ ENC_CUSTOM_CCW,
+ ENC_CUSTOM_PRESS
+};
+
+uint16_t
+ retrieve_custom_encoder_config(uint8_t encoder_idx, uint8_t behavior),
+ handle_encoder_cw(void),
+ handle_encoder_ccw(void);
+
+void set_custom_encoder_config(uint8_t encoder_idx, uint8_t behavior, uint16_t new_code),
+ pre_encoder_mode_change(void),
+ post_encoder_mode_change(void),
+ change_encoder_mode(bool clockwise); \ No newline at end of file
diff --git a/keyboards/nullbitsco/nibble/keymaps/via/rules.mk b/keyboards/nullbitsco/nibble/keymaps/via/rules.mk
new file mode 100644
index 0000000000..ee197efc02
--- /dev/null
+++ b/keyboards/nullbitsco/nibble/keymaps/via/rules.mk
@@ -0,0 +1,4 @@
+VIA_ENABLE = yes
+
+SRC += keymaps/via/nibble_encoder.c
+SRC += keymaps/via/via_extras.c \ No newline at end of file
diff --git a/keyboards/nullbitsco/nibble/keymaps/via/via_extras.c b/keyboards/nullbitsco/nibble/keymaps/via/via_extras.c
new file mode 100644
index 0000000000..067296b76b
--- /dev/null
+++ b/keyboards/nullbitsco/nibble/keymaps/via/via_extras.c
@@ -0,0 +1,129 @@
+/* Copyright 2020 Jay Greco
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "via_extras.h"
+
+// Encoder Behavior
+extern uint8_t encoder_value;
+extern uint8_t encoder_mode;
+extern uint8_t enabled_encoder_modes;
+
+void raw_hid_receive_kb( uint8_t *data, uint8_t length )
+{
+ uint8_t *command_id = &(data[0]);
+ uint8_t *command_data = &(data[1]);
+ dprintf("raw hid recv! command_id: %u\n",*command_id);
+ switch ( *command_id )
+ {
+ case id_get_keyboard_value:
+ {
+ switch( command_data[0])
+ {
+ case id_encoder_modes:
+ {
+ command_data[1] = enabled_encoder_modes;
+ dprintf("[read] enabled_encoder_modes: %u\n", enabled_encoder_modes);
+ }
+ break;
+
+ case id_encoder_custom:
+ {
+ uint8_t custom_encoder_idx = command_data[1];
+ uint16_t keycode = retrieve_custom_encoder_config(custom_encoder_idx, ENC_CUSTOM_CW);
+ command_data[2] = keycode >> 8;
+ command_data[3] = keycode & 0xFF;
+ keycode = retrieve_custom_encoder_config(custom_encoder_idx, ENC_CUSTOM_CCW);
+ command_data[4] = keycode >> 8;
+ command_data[5] = keycode & 0xFF;
+ keycode = retrieve_custom_encoder_config(custom_encoder_idx, ENC_CUSTOM_PRESS);
+ command_data[6] = keycode >> 8;
+ command_data[7] = keycode & 0xFF;
+ }
+ break;
+
+ default:
+ {
+ *command_id = id_unhandled;
+ }
+ break;
+ }
+ }
+ break;
+ case id_set_keyboard_value:
+ {
+ switch(command_data[0]){
+ case id_encoder_modes:
+ {
+ enabled_encoder_modes = command_data[1];
+ dprintf("[write] enabled_encoder_modes: %u\n", enabled_encoder_modes);
+ eeprom_update_byte((uint8_t*)EEPROM_ENABLED_ENCODER_MODES, enabled_encoder_modes);
+ }
+ break;
+
+ case id_encoder_custom:
+ {
+ uint8_t custom_encoder_idx = command_data[1];
+ uint8_t encoder_behavior = command_data[2];
+ uint16_t keycode = (command_data[3] << 8) | command_data[4];
+ set_custom_encoder_config(custom_encoder_idx, encoder_behavior, keycode);
+ }
+ break;
+
+ default:
+ {
+ *command_id = id_unhandled;
+ }
+ break;
+ }
+ }
+ break;
+
+ default:
+ {
+ // Unhandled message.
+ *command_id = id_unhandled;
+ }
+ break;
+ }
+}
+
+void encoder_update_kb(uint8_t index, bool clockwise) {
+ if (layer_state_is(1)) {
+ change_encoder_mode(clockwise);
+ return;
+ }
+ uint16_t mapped_code = 0;
+ if (clockwise) {
+ mapped_code = handle_encoder_cw();
+ } else {
+ mapped_code = handle_encoder_ccw();
+ }
+ if(mapped_code != 0){
+ tap_code16(mapped_code);
+ }
+}
+
+void custom_config_load(void){
+#ifdef DYNAMIC_KEYMAP_ENABLE
+ enabled_encoder_modes = eeprom_read_byte((uint8_t*)EEPROM_ENABLED_ENCODER_MODES);
+#endif
+}
+
+void via_init_kb(void)
+{
+ dprintf("VIA is enabled.\n");
+ custom_config_load();
+}
diff --git a/keyboards/nullbitsco/nibble/keymaps/via/via_extras.h b/keyboards/nullbitsco/nibble/keymaps/via/via_extras.h
new file mode 100644
index 0000000000..83c3c13128
--- /dev/null
+++ b/keyboards/nullbitsco/nibble/keymaps/via/via_extras.h
@@ -0,0 +1,39 @@
+/* Copyright 2020 Jay Greco
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#pragma once
+
+#include "nibble_encoder.h"
+#include "via.h"
+#include "raw_hid.h"
+#include "dynamic_keymap.h"
+#include "tmk_core/common/eeprom.h"
+
+enum nibble_keyboard_value_id {
+ id_encoder_modes = 0x80,
+ id_unused_mode_1,
+ id_encoder_custom,
+ id_unused_mode_2
+};
+
+// Encoder Behavior
+extern uint8_t encoder_value,
+ encoder_mode,
+ enabled_encoder_modes;
+
+void raw_hid_receive_kb(uint8_t *data, uint8_t length),
+ encoder_update_kb(uint8_t index, bool clockwise),
+ custom_config_load(void),
+ via_init_kb(void); \ No newline at end of file
diff --git a/keyboards/nullbitsco/nibble/matrix.c b/keyboards/nullbitsco/nibble/matrix.c
new file mode 100644
index 0000000000..8ec9da2844
--- /dev/null
+++ b/keyboards/nullbitsco/nibble/matrix.c
@@ -0,0 +1,95 @@
+/* Copyright 2020 Jay Greco
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include "quantum.h"
+
+#define COL_SHIFTER ((uint32_t)1)
+
+// Column pins
+static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
+static const uint8_t col_pins[MATRIX_MUX_COLS] = MATRIX_COL_MUX_PINS;
+
+// Internal functions
+
+static void init_pins(void) {
+ // Set cols to outputs, low
+ for (uint8_t pin = 0; pin < MATRIX_MUX_COLS; pin++) {
+ setPinOutput(col_pins[pin]);
+ }
+
+ // Unselect cols
+ for (uint8_t bit = 0; bit < MATRIX_MUX_COLS; bit++) {
+ writePinLow(col_pins[bit]);
+ }
+
+ // Set rows to input, pullup
+ for (uint8_t pin = 0; pin < MATRIX_ROWS; pin++) {
+ setPinInputHigh(row_pins[pin]);
+ }
+}
+
+static void select_col(uint8_t col)
+{
+ for (uint8_t bit = 0; bit < MATRIX_MUX_COLS; bit++) {
+ uint8_t state = (col & (0b1 << bit)) >> bit;
+ writePin(col_pins[bit], state);
+ }
+}
+
+static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)
+{
+ bool matrix_changed = false;
+ select_col(current_col);
+ wait_us(5);
+
+ // Read each row sequentially
+ for(uint8_t row_index = 0; row_index < MATRIX_ROWS; row_index++)
+ {
+ matrix_row_t last_row_value = current_matrix[row_index];
+
+ if (!readPin(row_pins[row_index]))
+ {
+ current_matrix[row_index] |= (COL_SHIFTER << current_col);
+ }
+ else
+ {
+ current_matrix[row_index] &= ~(COL_SHIFTER << current_col);
+ }
+
+ if ((last_row_value != current_matrix[row_index]) && !(matrix_changed))
+ {
+ matrix_changed = true;
+ }
+ }
+
+ return matrix_changed;
+}
+
+// Matrix scan functions
+
+void matrix_init_custom(void) {
+ init_pins();
+}
+
+bool matrix_scan_custom(matrix_row_t current_matrix[]) {
+ bool changed = false;
+
+ //Set col, read rows
+ for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) {
+ changed |= read_rows_on_col(current_matrix, current_col);
+ }
+
+ return (uint8_t)changed;
+} \ No newline at end of file
diff --git a/keyboards/nullbitsco/nibble/nibble.c b/keyboards/nullbitsco/nibble/nibble.c
new file mode 100644
index 0000000000..409edd44a0
--- /dev/null
+++ b/keyboards/nullbitsco/nibble/nibble.c
@@ -0,0 +1,26 @@
+/* Copyright 2020 Jay Greco
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include QMK_KEYBOARD_H
+#include "bitc_led.h"
+
+// Use Bit-C LED to show CAPS LOCK status
+bool led_update_kb(led_t led_state) {
+ bool res = led_update_user(led_state);
+ if (res) {
+ set_bitc_LED(led_state.caps_lock ? LED_DIM : LED_OFF);
+ }
+ return res;
+}
diff --git a/keyboards/nullbitsco/nibble/nibble.h b/keyboards/nullbitsco/nibble/nibble.h
new file mode 100644
index 0000000000..9744ae745c
--- /dev/null
+++ b/keyboards/nullbitsco/nibble/nibble.h
@@ -0,0 +1,63 @@
+/* Copyright 2020 Jay Greco
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#pragma once
+
+#define ___ KC_NO
+
+#include "quantum.h"
+#include "remote_kb.h"
+
+#define LAYOUT_all( \
+ K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K0E, K0F, K0G, \
+ K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, K1F, K1G, \
+ K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2F, K2G, \
+ K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, K3F, K3G, \
+ K41, K42, K43, K44, K47, K4A, K4B, K4C, K4D, K4F, K4G \
+) { \
+ {K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K0E, K0F, K0G}, \
+ {K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, K1F, K1G}, \
+ {K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, ___, K2F, K2G}, \
+ {K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, ___, K3F, K3G}, \
+ {K41, K42, K43, K44, ___, ___, K47, ___, ___, K4A, K4B, K4C, K4D, ___, K4F, K4G}, \
+}
+
+#define LAYOUT_ansi( \
+ K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K0E, K0F, K0G, \
+ K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, K1F, K1G, \
+ K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2F, K2G, \
+ K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, K3F, K3G, \
+ K41, K42, K43, K44, K47, K4A, K4B, K4C, K4D, K4F, K4G \
+) { \
+ {___, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K0E, K0F, K0G}, \
+ {K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, K1F, K1G}, \
+ {K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, ___, K2F, K2G}, \
+ {K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, ___, K3F, K3G}, \
+ {K41, K42, K43, K44, ___, ___, K47, ___, ___, K4A, K4B, K4C, K4D, ___, K4F, K4G}, \
+}
+
+#define LAYOUT_iso( \
+ K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K0E, K0F, K0G, \
+ K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, K1G, \
+ K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K1F, K2F, K2G, \
+ K31, K32, K01, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, K3F, K3G, \
+ K41, K42, K43, K44, K47, K4A, K4B, K4C, K4D, K4F, K4G \
+) { \
+ {K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K0E, K0F, K0G}, \
+ {K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, K1F, K1G}, \
+ {K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, ___, K2F, K2G}, \
+ {K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, ___, K3F, K3G}, \
+ {K41, K42, K43, K44, ___, ___, K47, ___, ___, K4A, K4B, K4C, K4D, ___, K4F, K4G}, \
+}
diff --git a/keyboards/nullbitsco/nibble/remote_kb.c b/keyboards/nullbitsco/nibble/remote_kb.c
new file mode 100644
index 0000000000..2e36f5f22e
--- /dev/null
+++ b/keyboards/nullbitsco/nibble/remote_kb.c
@@ -0,0 +1,177 @@
+/* Copyright 2020 Jay Greco
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+Remote keyboard is an experimental feature that allows for connecting another
+keyboard, macropad, numpad, or accessory without requiring an additional USB connection.
+The "remote keyboard" forwards its keystrokes using UART serial over TRRS. Dynamic VUSB
+detect allows the keyboard automatically switch to host or remote mode depending on
+which is connected to the USB port.
+
+Possible functionality includes the ability to send data from the host to the remote using
+a reverse link, allowing for LED sync, configuration, and more data sharing between devices.
+This will require a new communication protocol, as the current one is limited.
+*/
+
+#include "remote_kb.h"
+
+uint8_t
+ msg[UART_MSG_LEN],
+ msg_idx = 0;
+
+bool
+ is_host = true;
+
+// Private functions
+
+static bool vbus_detect(void) {
+ #if defined(__AVR_ATmega32U4__)
+ //returns true if VBUS is present, false otherwise.
+ USBCON |= (1 << OTGPADE); //enables VBUS pad
+ _delay_us(10);
+ return (USBSTA & (1<<VBUS)); //checks state of VBUS
+ #else
+ #error vbus_detect is not implemented for this architecure!
+ #endif
+}
+
+static uint8_t chksum8(const unsigned char *buf, size_t len) {
+ unsigned int sum;
+ for (sum = 0 ; len != 0 ; len--)
+ sum += *(buf++);
+ return (uint8_t)sum;
+}
+
+static void send_msg(uint16_t keycode, bool pressed) {
+ msg[IDX_PREAMBLE] = UART_PREAMBLE;
+ msg[IDX_KCLSB] = (keycode & 0xFF);
+ msg[IDX_KCMSB] = (keycode >> 8) & 0xFF;
+ msg[IDX_PRESSED] = pressed;
+ msg[IDX_CHECKSUM] = chksum8(msg, UART_MSG_LEN-1);
+
+ for (int i=0; i<UART_MSG_LEN; i++) {
+ uart_putchar(msg[i]);
+ }
+}
+
+static void print_message_buffer(void) {
+ for (int i=0; i<UART_MSG_LEN; i++) {
+ dprintf("msg[%u]: %u\n", i, msg[i]);
+ }
+}
+
+static void process_uart(void) {
+ uint8_t chksum = chksum8(msg, UART_MSG_LEN-1);
+ if (msg[IDX_PREAMBLE] != UART_PREAMBLE || msg[IDX_CHECKSUM] != chksum) {
+ dprintf("UART checksum mismatch!\n");
+ print_message_buffer();
+ dprintf("calc checksum: %u\n", chksum);
+ } else {
+ uint16_t keycode = (uint16_t)msg[IDX_KCLSB] | ((uint16_t)msg[IDX_KCMSB] << 8);
+ bool pressed = (bool)msg[IDX_PRESSED];
+ if (IS_RM_KC(keycode)) {
+ keyrecord_t record;
+ record.event.pressed = pressed;
+ if (pressed) dprintf("Remote macro: press [%u]\n", keycode);
+ else dprintf("Remote macro: release [%u]\n", keycode);
+ process_record_user(keycode, &record);
+ } else {
+ if (pressed) {
+ dprintf("Remote: press [%u]\n", keycode);
+ register_code(keycode);
+ } else {
+ dprintf("Remote: release [%u]\n", keycode);
+ unregister_code(keycode);
+ }
+ }
+ }
+}
+
+static void get_msg(void) {
+ while (uart_available()) {
+ msg[msg_idx] = uart_getchar();
+ dprintf("idx: %u, recv: %u\n", msg_idx, msg[msg_idx]);
+ if (msg_idx == 0 && (msg[msg_idx] != UART_PREAMBLE)) {
+ dprintf("Byte sync error!\n");
+ msg_idx = 0;
+ } else if (msg_idx == (UART_MSG_LEN-1)) {
+ process_uart();
+ msg_idx = 0;
+ } else {
+ msg_idx++;
+ }
+ }
+}
+
+static void handle_host_incoming(void) {
+ get_msg();
+}
+
+static void handle_host_outgoing(void) {
+ // for future reverse link use
+}
+
+static void handle_remote_incoming(void) {
+ // for future reverse link use
+}
+
+static void handle_remote_outgoing(uint16_t keycode, keyrecord_t *record) {
+ if (IS_HID_KC(keycode) || IS_RM_KC(keycode)) {
+ dprintf("Remote: send [%u]\n", keycode);
+ send_msg(keycode, record->event.pressed);
+ }
+}
+
+// Public functions
+
+void matrix_init_remote_kb(void) {
+ uart_init(SERIAL_UART_BAUD);
+ is_host = vbus_detect();
+}
+
+void process_record_remote_kb(uint16_t keycode, keyrecord_t *record) {
+ #if defined (KEYBOARD_HOST)
+ handle_host_outgoing();
+
+ #elif defined(KEYBOARD_REMOTE)
+ handle_remote_outgoing(keycode, record);
+
+ #else //auto check with VBUS
+ if (is_host) {
+ handle_host_outgoing();
+ }
+ else {
+ handle_remote_outgoing(keycode, record);
+ }
+ #endif
+}
+
+void matrix_scan_remote_kb(void) {
+ #if defined(KEYBOARD_HOST)
+ handle_host_incoming();
+
+ #elif defined (KEYBOARD_REMOTE)
+ handle_remote_incoming();
+
+ #else //auto check with VBUS
+ if (is_host) {
+ handle_host_incoming();
+ }
+ else {
+ handle_remote_incoming();
+ }
+ #endif
+}
diff --git a/keyboards/nullbitsco/nibble/remote_kb.h b/keyboards/nullbitsco/nibble/remote_kb.h
new file mode 100644
index 0000000000..e2b24655b5
--- /dev/null
+++ b/keyboards/nullbitsco/nibble/remote_kb.h
@@ -0,0 +1,53 @@
+/* Copyright 2020 Jay Greco
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#pragma once
+
+#include "quantum.h"
+#include "tmk_core/common/uart.h"
+
+#define SERIAL_UART_BAUD 153600 //low error rate for 32u4 @ 16MHz
+
+#define UART_PREAMBLE 0x69
+#define UART_MSG_LEN 5
+#define UART_NULL 0
+
+#define IDX_PREAMBLE 0
+#define IDX_KCLSB 1
+#define IDX_KCMSB 2
+#define IDX_PRESSED 3
+#define IDX_CHECKSUM 4
+
+#define IS_HID_KC(x) ((x > 0) && (x < 0xFF))
+#define IS_RM_KC(x) ((x >= RM_BASE) && (x <= 0xFFFF))
+
+#define RM_BASE 0xFFFF-16
+enum remote_macros {
+ RM_1 = RM_BASE,
+ RM_2, RM_3,
+ RM_4, RM_5,
+ RM_6, RM_7,
+ RM_8, RM_9,
+ RM_10, RM_11,
+ RM_12, RM_13,
+ RM_14, RM_15,
+};
+
+
+// Public functions
+void
+ matrix_init_remote_kb(void),
+ process_record_remote_kb(uint16_t keycode, keyrecord_t *record),
+ matrix_scan_remote_kb(void); \ No newline at end of file
diff --git a/keyboards/nullbitsco/nibble/rules.mk b/keyboards/nullbitsco/nibble/rules.mk
new file mode 100644
index 0000000000..683e290866
--- /dev/null
+++ b/keyboards/nullbitsco/nibble/rules.mk
@@ -0,0 +1,35 @@
+# MCU name
+MCU = atmega32u4
+
+# Interrupt driven control endpoint task(+60)
+OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
+
+# Bootloader selection
+BOOTLOADER = atmel-dfu
+
+# Build Options
+# change yes to no to disable
+#
+BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration
+MOUSEKEY_ENABLE = no # Mouse keys
+EXTRAKEY_ENABLE = yes # Audio control and System control
+CONSOLE_ENABLE = no # Console for debug
+COMMAND_ENABLE = no # Commands for debug and configuration
+SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
+NKRO_ENABLE = yes # USB Nkey Rollover
+BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
+RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow
+MIDI_ENABLE = no # MIDI support
+BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
+AUDIO_ENABLE = no # Audio output on port C6
+FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches
+ENCODER_ENABLE = yes # Use rotary encoder
+LTO_ENABLE = yes # Link-time optimization
+CUSTOM_MATRIX = lite # Lite custom matrix
+
+# Project specific files
+SRC += matrix.c \
+ bitc_led.c \
+ big_led.c \
+ remote_kb.c \
+ tmk_core/common/uart.c