Skip to content

Commit

Permalink
[Keyboard] Add nullbits SNAP keyboard (#18916)
Browse files Browse the repository at this point in the history
Co-authored-by: Ryan <fauxpark@gmail.com>
  • Loading branch information
jaygreco and fauxpark committed Apr 2, 2023
1 parent 5687fc7 commit 27e6e27
Show file tree
Hide file tree
Showing 32 changed files with 2,842 additions and 0 deletions.
87 changes: 87 additions & 0 deletions keyboards/nullbitsco/snap/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/* Copyright 2021 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/>.
*/
// clang-format off
#pragma once

/* 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

// Workarounds for sleep/wake issues
#define USB_SUSPEND_WAKEUP_DELAY 250

// NOTE: There is a bug in AVR deep sleep, which
// causes the MCU to stop responding in some cases.
// Disabling the watchdog prevents the MCU from entering
// power down, while still turning off LEDs, audio, etc.
// See qmk_firmware/issues/20087 for background
#undef WDT_vect

/* split config */
// #define SPLIT_USB_DETECT // Enable if you have issues with USB
#define SOFT_SERIAL_PIN E6
#define SPLIT_HAND_PIN B6
#define DISABLE_SYNC_TIMER
#define SPLIT_HAND_PIN_LOW_IS_LEFT

/* key matrix size */
#define MATRIX_ROWS 12
#define MATRIX_COLS 9
#define MATRIX_MUX_COLS 3

/*
* Keyboard Matrix Assignments
* The snap uses a demultiplexer for the cols.
* to free up more IOs for awesomeness!
* See matrix.c for more details.
*/
// Left side
#define MATRIX_ROW_PINS { D4, C6, D7, F4, B4, B5 }
#define MATRIX_COL_MUX_PINS { F7, F6, F5 }

//Right side
#define MATRIX_ROW_PINS_RIGHT { F4, F5, F6, F7, B1, B3 }
#define MATRIX_COL_MUX_PINS_RIGHT { D7, C6, D4 }
#define MATRIX_EXT_PIN_RIGHT B6

/* Optional SMT LED pins */
#define RGB_DI_PIN B2
#define RGBLED_NUM 10
#define RGBLED_SPLIT { 5, 5 }
#define RGBLIGHT_LED_MAP { 8, 9, 0, 1, 2, 6, 7, 3, 4, 5 }
#define RGBLIGHT_SLEEP
#define RGBLIGHT_EFFECT_BREATHING
#define RGBLIGHT_EFFECT_RAINBOW_MOOD
#define RGBLIGHT_EFFECT_RAINBOW_SWIRL
#define RGBLIGHT_EFFECT_SNAKE
#define RGBLIGHT_EFFECT_KNIGHT
#define RGBLIGHT_EFFECT_CHRISTMAS
#define RGBLIGHT_EFFECT_STATIC_GRADIENT
#define RGBLIGHT_EFFECT_RGB_TEST
#define RGBLIGHT_EFFECT_ALTERNATING
#define RGBLIGHT_EFFECT_TWINKLE

/* Optional encoder pins */
#define ENCODERS_PAD_A { B3 }
#define ENCODERS_PAD_B { B1 }
#define ENCODERS_PAD_A_RIGHT { B4 }
#define ENCODERS_PAD_B_RIGHT { B5 }

/* Optional speaker pin */
#define AUDIO_PIN B6

/* Optional split transactions */
#define SPLIT_OLED_ENABLE
24 changes: 24 additions & 0 deletions keyboards/nullbitsco/snap/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"keyboard_name": "SNAP",
"manufacturer": "nullbits",
"url": "https://nullbits.co/snap/",
"usb": {
"vid": "0x6E61",
"pid": "0x6063",
"device_version": "0.0.1"
},
"debounce": 10,
"processor": "atmega32u4",
"bootloader": "atmel-dfu",
"layouts": {
"LAYOUT_all": {
"layout": [{"label":"Esc", "x":1, "y":0}, {"label":"F1", "x":2, "y":0}, {"label":"F2", "x":3, "y":0}, {"label":"F3", "x":4, "y":0}, {"label":"F4", "x":5, "y":0}, {"label":"F5", "x":6, "y":0}, {"label":"F6", "x":7, "y":0}, {"label":"F7", "x":8, "y":0}, {"label":"F8", "x":9, "y":0}, {"label":"F9", "x":10, "y":0}, {"label":"F10", "x":11, "y":0}, {"label":"F11", "x":12, "y":0}, {"label":"F12", "x":13, "y":0}, {"label":"PrtSc", "x":14, "y":0}, {"label":"Pause", "x":15, "y":0}, {"label":"M", "x":0, "y":1}, {"label":"~", "x":1, "y":1}, {"label":"!", "x":2, "y":1}, {"label":"@", "x":3, "y":1}, {"label":"#", "x":4, "y":1}, {"label":"$", "x":5, "y":1}, {"label":"%", "x":6, "y":1}, {"label":"^", "x":7, "y":1}, {"label":"&", "x":8, "y":1}, {"label":"*", "x":9, "y":1}, {"label":"(", "x":10, "y":1}, {"label":")", "x":11, "y":1}, {"label":"_", "x":12, "y":1}, {"label":"+", "x":13, "y":1}, {"label":"Bksp1", "x":14, "y":1}, {"label":"Bksp2", "x":15, "y":1}, {"label":"Home", "x":16, "y":1}, {"label":"M", "x":0, "y":2}, {"label":"Tab", "x":1, "y":2, "w":1.5}, {"label":"Q", "x":2.5, "y":2}, {"label":"W", "x":3.5, "y":2}, {"label":"E", "x":4.5, "y":2}, {"label":"R", "x":5.5, "y":2}, {"label":"T", "x":6.5, "y":2}, {"label":"Y", "x":7.5, "y":2}, {"label":"U", "x":8.5, "y":2}, {"label":"I", "x":9.5, "y":2}, {"label":"O", "x":10.5, "y":2}, {"label":"P", "x":11.5, "y":2}, {"label":"{", "x":12.5, "y":2}, {"label":"}", "x":13.5, "y":2}, {"label":"|", "x":14.5, "y":2, "w":1.5}, {"label":"End", "x":16, "y":2}, {"label":"M", "x":0, "y":3}, {"label":"Caps Lock", "x":1, "y":3, "w":1.75}, {"label":"A", "x":2.75, "y":3}, {"label":"S", "x":3.75, "y":3}, {"label":"D", "x":4.75, "y":3}, {"label":"F", "x":5.75, "y":3}, {"label":"G", "x":6.75, "y":3}, {"label":"H", "x":7.75, "y":3}, {"label":"J", "x":8.75, "y":3}, {"label":"K", "x":9.75, "y":3}, {"label":"L", "x":10.75, "y":3}, {"label":":", "x":11.75, "y":3}, {"label":"\"", "x":12.75, "y":3}, {"label":"Enter", "x":13.75, "y":3, "w":2.25}, {"label":"Page Up", "x":16, "y":3}, {"label":"M", "x":0, "y":4}, {"label":"Shift", "x":1, "y":4, "w":1.25}, {"label":"#", "x":2.25, "y":4}, {"label":"Z", "x":3.25, "y":4}, {"label":"X", "x":4.25, "y":4}, {"label":"C", "x":5.25, "y":4}, {"label":"V", "x":6.25, "y":4}, {"label":"B", "x":7.25, "y":4}, {"label":"N", "x":8.25, "y":4}, {"label":"M", "x":9.25, "y":4}, {"label":"<", "x":10.25, "y":4}, {"label":">", "x":11.25, "y":4}, {"label":"?", "x":12.25, "y":4}, {"label":"Shift", "x":13.25, "y":4, "w":1.75}, {"label":"\u2191", "x":15, "y":4}, {"label":"Page Down", "x":16, "y":4}, {"label":"M", "x":0, "y":5}, {"label":"Ctrl", "x":1, "y":5, "w":1.25}, {"label":"Win", "x":2.25, "y":5, "w":1.25}, {"label":"Alt", "x":3.5, "y":5, "w":1.25}, {"label":"Fn", "x":4.75, "y":5, "w":1.25}, {"label":"Space", "x":6, "y":5, "w":2.25}, {"label":"Space", "x":8.25, "y":5, "w":2.75}, {"label":"Alt", "x":11, "y":5}, {"label":"Fn", "x":12, "y":5}, {"label":"Ctrl", "x":13, "y":5}, {"label":"\u2190", "x":14, "y":5}, {"label":"\u2193", "x":15, "y":5}, {"label":"\u2192", "x":16, "y":5}]
},
"LAYOUT_ansi": {
"layout": [{"label":"Esc", "x":1, "y":0}, {"label":"F1", "x":2, "y":0}, {"label":"F2", "x":3, "y":0}, {"label":"F3", "x":4, "y":0}, {"label":"F4", "x":5, "y":0}, {"label":"F5", "x":6, "y":0}, {"label":"F6", "x":7, "y":0}, {"label":"F7", "x":8, "y":0}, {"label":"F8", "x":9, "y":0}, {"label":"F9", "x":10, "y":0}, {"label":"F10", "x":11, "y":0}, {"label":"F11", "x":12, "y":0}, {"label":"F12", "x":13, "y":0}, {"label":"PrtSc", "x":14, "y":0}, {"label":"Pause", "x":15, "y":0}, {"label":"M", "x":0, "y":1}, {"label":"~", "x":1, "y":1}, {"label":"!", "x":2, "y":1}, {"label":"@", "x":3, "y":1}, {"label":"#", "x":4, "y":1}, {"label":"$", "x":5, "y":1}, {"label":"%", "x":6, "y":1}, {"label":"^", "x":7, "y":1}, {"label":"&", "x":8, "y":1}, {"label":"*", "x":9, "y":1}, {"label":"(", "x":10, "y":1}, {"label":")", "x":11, "y":1}, {"label":"_", "x":12, "y":1}, {"label":"+", "x":13, "y":1}, {"label":"Bksp", "x":14, "y":1, "w":2}, {"label":"Home", "x":16, "y":1}, {"label":"M", "x":0, "y":2}, {"label":"Tab", "x":1, "y":2, "w":1.5}, {"label":"Q", "x":2.5, "y":2}, {"label":"W", "x":3.5, "y":2}, {"label":"E", "x":4.5, "y":2}, {"label":"R", "x":5.5, "y":2}, {"label":"T", "x":6.5, "y":2}, {"label":"Y", "x":7.5, "y":2}, {"label":"U", "x":8.5, "y":2}, {"label":"I", "x":9.5, "y":2}, {"label":"O", "x":10.5, "y":2}, {"label":"P", "x":11.5, "y":2}, {"label":"{", "x":12.5, "y":2}, {"label":"}", "x":13.5, "y":2}, {"label":"|", "x":14.5, "y":2, "w":1.5}, {"label":"End", "x":16, "y":2}, {"label":"M", "x":0, "y":3}, {"label":"Caps Lock", "x":1, "y":3, "w":1.75}, {"label":"A", "x":2.75, "y":3}, {"label":"S", "x":3.75, "y":3}, {"label":"D", "x":4.75, "y":3}, {"label":"F", "x":5.75, "y":3}, {"label":"G", "x":6.75, "y":3}, {"label":"H", "x":7.75, "y":3}, {"label":"J", "x":8.75, "y":3}, {"label":"K", "x":9.75, "y":3}, {"label":"L", "x":10.75, "y":3}, {"label":":", "x":11.75, "y":3}, {"label":"\"", "x":12.75, "y":3}, {"label":"Enter", "x":13.75, "y":3, "w":2.25}, {"label":"Page Up", "x":16, "y":3}, {"label":"M", "x":0, "y":4}, {"label":"Shift", "x":1, "y":4, "w":2.25}, {"label":"Z", "x":3.25, "y":4}, {"label":"X", "x":4.25, "y":4}, {"label":"C", "x":5.25, "y":4}, {"label":"V", "x":6.25, "y":4}, {"label":"B", "x":7.25, "y":4}, {"label":"N", "x":8.25, "y":4}, {"label":"M", "x":9.25, "y":4}, {"label":"<", "x":10.25, "y":4}, {"label":">", "x":11.25, "y":4}, {"label":"?", "x":12.25, "y":4}, {"label":"Shift", "x":13.25, "y":4, "w":1.75}, {"label":"\u2191", "x":15, "y":4}, {"label":"Page Down", "x":16, "y":4}, {"label":"M", "x":0, "y":5}, {"label":"Ctrl", "x":1, "y":5, "w":1.25}, {"label":"Win", "x":2.25, "y":5, "w":1.25}, {"label":"Alt", "x":3.5, "y":5, "w":1.25}, {"label":"Fn", "x":4.75, "y":5, "w":1.25}, {"label":"Space", "x":6, "y":5, "w":2.25}, {"label":"Space", "x":8.25, "y":5, "w":2.75}, {"label":"Alt", "x":11, "y":5}, {"label":"Fn", "x":12, "y":5}, {"label":"Ctrl", "x":13, "y":5}, {"label":"\u2190", "x":14, "y":5}, {"label":"\u2193", "x":15, "y":5}, {"label":"\u2192", "x":16, "y":5}]
},
"LAYOUT_iso": {
"layout": [{"label":"Esc", "x":1, "y":0}, {"label":"F1", "x":2, "y":0}, {"label":"F2", "x":3, "y":0}, {"label":"F3", "x":4, "y":0}, {"label":"F4", "x":5, "y":0}, {"label":"F5", "x":6, "y":0}, {"label":"F6", "x":7, "y":0}, {"label":"F7", "x":8, "y":0}, {"label":"F8", "x":9, "y":0}, {"label":"F9", "x":10, "y":0}, {"label":"F10", "x":11, "y":0}, {"label":"F11", "x":12, "y":0}, {"label":"F12", "x":13, "y":0}, {"label":"PrtSc", "x":14, "y":0}, {"label":"Pause", "x":15, "y":0}, {"label":"M", "x":0, "y":1}, {"label":"~", "x":1, "y":1}, {"label":"!", "x":2, "y":1}, {"label":"@", "x":3, "y":1}, {"label":"#", "x":4, "y":1}, {"label":"$", "x":5, "y":1}, {"label":"%", "x":6, "y":1}, {"label":"^", "x":7, "y":1}, {"label":"&", "x":8, "y":1}, {"label":"*", "x":9, "y":1}, {"label":"(", "x":10, "y":1}, {"label":")", "x":11, "y":1}, {"label":"_", "x":12, "y":1}, {"label":"+", "x":13, "y":1}, {"label":"Bksp", "x":14, "y":1, "w":2}, {"label":"Home", "x":16, "y":1}, {"label":"M", "x":0, "y":2}, {"label":"Tab", "x":1, "y":2, "w":1.5}, {"label":"Q", "x":2.5, "y":2}, {"label":"W", "x":3.5, "y":2}, {"label":"E", "x":4.5, "y":2}, {"label":"R", "x":5.5, "y":2}, {"label":"T", "x":6.5, "y":2}, {"label":"Y", "x":7.5, "y":2}, {"label":"U", "x":8.5, "y":2}, {"label":"I", "x":9.5, "y":2}, {"label":"O", "x":10.5, "y":2}, {"label":"P", "x":11.5, "y":2}, {"label":"{", "x":12.5, "y":2}, {"label":"}", "x":13.5, "y":2}, {"label":"Enter", "x":14.75, "y":2, "w":1.25, "h":2}, {"label":"End", "x":16, "y":2}, {"label":"M", "x":0, "y":3}, {"label":"Caps Lock", "x":1, "y":3, "w":1.75}, {"label":"A", "x":2.75, "y":3}, {"label":"S", "x":3.75, "y":3}, {"label":"D", "x":4.75, "y":3}, {"label":"F", "x":5.75, "y":3}, {"label":"G", "x":6.75, "y":3}, {"label":"H", "x":7.75, "y":3}, {"label":"J", "x":8.75, "y":3}, {"label":"K", "x":9.75, "y":3}, {"label":"L", "x":10.75, "y":3}, {"label":":", "x":11.75, "y":3}, {"label":"\"", "x":12.75, "y":3}, {"label":"\"", "x":13.75, "y":3}, {"label":"Page Up", "x":16, "y":3}, {"label":"M", "x":0, "y":4}, {"label":"Shift", "x":1, "y":4, "w":1.25}, {"label":"#", "x":2.25, "y":4}, {"label":"Z", "x":3.25, "y":4}, {"label":"X", "x":4.25, "y":4}, {"label":"C", "x":5.25, "y":4}, {"label":"V", "x":6.25, "y":4}, {"label":"B", "x":7.25, "y":4}, {"label":"N", "x":8.25, "y":4}, {"label":"M", "x":9.25, "y":4}, {"label":"<", "x":10.25, "y":4}, {"label":">", "x":11.25, "y":4}, {"label":"?", "x":12.25, "y":4}, {"label":"Shift", "x":13.25, "y":4, "w":1.75}, {"label":"\u2191", "x":15, "y":4}, {"label":"Page Down", "x":16, "y":4}, {"label":"M", "x":0, "y":5}, {"label":"Ctrl", "x":1, "y":5, "w":1.25}, {"label":"Win", "x":2.25, "y":5, "w":1.25}, {"label":"Alt", "x":3.5, "y":5, "w":1.25}, {"label":"Fn", "x":4.75, "y":5, "w":1.25}, {"label":"Space", "x":6, "y":5, "w":2.25}, {"label":"Space", "x":8.25, "y":5, "w":2.75}, {"label":"Alt", "x":11, "y":5}, {"label":"Fn", "x":12, "y":5}, {"label":"Ctrl", "x":13, "y":5}, {"label":"\u2190", "x":14, "y":5}, {"label":"\u2193", "x":15, "y":5}, {"label":"\u2192", "x":16, "y":5}]
}
}
}
121 changes: 121 additions & 0 deletions keyboards/nullbitsco/snap/keymaps/bongo_reactive/bongo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/* Copyright 2021 Chris Tanaka <https://github.com/christanaka>
*
* 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 "bongo_graphics.h"
#include QMK_KEYBOARD_H

#define _IDLE_FRAMES 5
#define _PREP_FRAMES 1
#define _TAP_FRAMES 2
#define _ANIM_BYTES 512 // Number of bytes in array (max is 1024)
#define _IDLE_FRAME_DURATION 175
#define _TAP_FRAME_DURATION 75
#define _PREP_TIMEOUT 750

enum anim_states
{
Idle,
Prep,
Tap
};

static uint8_t anim_state = Idle;
static uint8_t anim_duration = _IDLE_FRAME_DURATION;
static uint32_t anim_timer = 0;

static uint8_t idle_frame = 0;
static uint8_t tap_frame = 0;

static uint32_t prep_timer = 0;

// Decompress and write a precompressed bitmap frame to the OLED.
// Documentation and python compression script available at:
// https://github.com/nullbitsco/squeez-o
#ifdef USE_OLED_BITMAP_COMPRESSION
static void oled_write_compressed_P(const char* input_block_map, const char* input_block_list) {
uint16_t block_index = 0;
for (uint16_t i = 0; i < NUM_OLED_BYTES; i++) {
uint8_t bit = i % 8;
uint8_t map_index = i / 8;
uint8_t _block_map = (uint8_t)pgm_read_byte_near(input_block_map + map_index);
uint8_t nonzero_byte = (_block_map & (1 << bit));
if (nonzero_byte) {
const char data = (const char)pgm_read_byte_near(input_block_list + block_index++);
oled_write_raw_byte(data, i);
} else {
const char data = (const char)0x00;
oled_write_raw_byte(data, i);
}
}
}
#endif

static void animate(uint8_t x, uint8_t y) {
oled_set_cursor(x, y);

// Update frame
switch (anim_state) {
case Idle:
idle_frame = (idle_frame + 1) % _IDLE_FRAMES;
#ifdef USE_OLED_BITMAP_COMPRESSION
oled_write_compressed_P(idle_block_map[abs(1 - idle_frame)], idle[abs(1 - idle_frame)]);
#else
oled_write_raw_P(idle[abs(1 - idle_frame)], sizeof(idle[abs(1 - idle_frame)]));
#endif
break;
case Prep:
#ifdef USE_OLED_BITMAP_COMPRESSION
oled_write_compressed_P(prep_block_map[0], prep[0]);
#else
oled_write_raw_P(prep[0], sizeof(prep[0]));
#endif
break;
case Tap:
tap_frame = (tap_frame + 1) % _TAP_FRAMES;
#ifdef USE_OLED_BITMAP_COMPRESSION
oled_write_compressed_P(tap_block_map[abs(1 - tap_frame)], tap[abs(1 - tap_frame)]);
#else
oled_write_raw_P(tap[abs(1 - tap_frame)], sizeof(tap[abs(1 - tap_frame)]));
#endif
break;
default:
break;
}
}

void bongo_render(uint8_t x, uint8_t y) {
if (timer_elapsed32(anim_timer) > anim_duration) {
anim_timer = timer_read32();
animate(x, y);
}

if (anim_state == Prep && timer_elapsed32(prep_timer) > _PREP_TIMEOUT) {
anim_state = Idle;
anim_duration = _IDLE_FRAME_DURATION;
}
}

void bongo_process_record(keyrecord_t *record) {
if (record->event.pressed) {
anim_state = Tap;
anim_duration = _TAP_FRAME_DURATION;
} else {
if (anim_state == Tap) {
anim_state = Prep;
prep_timer = timer_read32();
}
}
}
Loading

0 comments on commit 27e6e27

Please sign in to comment.