Skip to content

Commit

Permalink
Add nullbits nibble (#9250)
Browse files Browse the repository at this point in the history
* Add NIBBLE keyboard

* Update VID for VIA compatibility

* Add QMK PR feedback

* Update matrix_init_remote_kb()

* Update with requested changes

Clean up config, makefile rules, and keymap files

* Update with changes for unified ANSI/ISO layout

* Add NO_USB_STARTUP_CHECK note in readme

* Add license info, update with PR changes

-Refactor encoder, via_extras code
-Refactor VIA specific code to live in keymap folder
-Remove non-inclusive naming in remote keyboard.c/h
-Add documentation to remote_keyboard.c
-Add compiler check for vusb_detect for non-avr micros

* Fix print formatter in encoder handler

Co-authored-by: Nick Brassel <nick@tzarc.org>

* Small PR updates

-Remove unneded matrix code from nibble.c
-Clean up include code in nibble_encoder.h

* Update Big LED headerfile

-Declare Big LED functions in header file (derp)

* Update keyboards/nullbitsco/nibble/nibble.c

-Update with drashna's suggested CAPS LED code change

Co-authored-by: Drashna Jaelre <drashna@live.com>

* Update keyboards/nullbitsco/nibble/rules.mk

-Update with drasha's suggested makefile formatting changes

Co-authored-by: Drashna Jaelre <drashna@live.com>

* Fix caps_lock typo

Co-authored-by: Nick Brassel <nick@tzarc.org>
Co-authored-by: Drashna Jaelre <drashna@live.com>
  • Loading branch information
3 people committed Oct 23, 2020
1 parent 8cbaea9 commit 999326a
Show file tree
Hide file tree
Showing 21 changed files with 1,492 additions and 0 deletions.
19 changes: 19 additions & 0 deletions keyboards/nullbitsco/nibble/README.md
Original file line number Diff line number Diff line change
@@ -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).
67 changes: 67 additions & 0 deletions keyboards/nullbitsco/nibble/big_led.c
Original file line number Diff line number Diff line change
@@ -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;
}
}
34 changes: 34 additions & 0 deletions keyboards/nullbitsco/nibble/big_led.h
Original file line number Diff line number Diff line change
@@ -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);
37 changes: 37 additions & 0 deletions keyboards/nullbitsco/nibble/bitc_led.c
Original file line number Diff line number Diff line change
@@ -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;
}
}
29 changes: 29 additions & 0 deletions keyboards/nullbitsco/nibble/bitc_led.h
Original file line number Diff line number Diff line change
@@ -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);
61 changes: 61 additions & 0 deletions keyboards/nullbitsco/nibble/config.h
Original file line number Diff line number Diff line change
@@ -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 }
128 changes: 128 additions & 0 deletions keyboards/nullbitsco/nibble/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
@@ -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();
}
Loading

0 comments on commit 999326a

Please sign in to comment.