diff options
Diffstat (limited to 'keyboards/nullbitsco/tidbit')
-rw-r--r-- | keyboards/nullbitsco/tidbit/config.h | 62 | ||||
-rw-r--r-- | keyboards/nullbitsco/tidbit/info.json | 14 | ||||
-rw-r--r-- | keyboards/nullbitsco/tidbit/keymaps/default/keymap.c | 40 | ||||
-rw-r--r-- | keyboards/nullbitsco/tidbit/keymaps/oled/keymap.c | 58 | ||||
-rw-r--r-- | keyboards/nullbitsco/tidbit/keymaps/oled/rules.mk | 3 | ||||
-rw-r--r-- | keyboards/nullbitsco/tidbit/keymaps/snailmap_lite/keymap.c | 283 | ||||
-rw-r--r-- | keyboards/nullbitsco/tidbit/keymaps/snailmap_lite/rules.mk | 6 | ||||
-rw-r--r-- | keyboards/nullbitsco/tidbit/keymaps/via/keymap.c | 59 | ||||
-rw-r--r-- | keyboards/nullbitsco/tidbit/keymaps/via/rules.mk | 1 | ||||
-rw-r--r-- | keyboards/nullbitsco/tidbit/readme.md | 26 | ||||
-rw-r--r-- | keyboards/nullbitsco/tidbit/rules.mk | 26 | ||||
-rw-r--r-- | keyboards/nullbitsco/tidbit/tidbit.c | 157 | ||||
-rw-r--r-- | keyboards/nullbitsco/tidbit/tidbit.h | 37 |
13 files changed, 772 insertions, 0 deletions
diff --git a/keyboards/nullbitsco/tidbit/config.h b/keyboards/nullbitsco/tidbit/config.h new file mode 100644 index 0000000000..103dabdb96 --- /dev/null +++ b/keyboards/nullbitsco/tidbit/config.h @@ -0,0 +1,62 @@ +/* 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/>. + */ +#pragma once + +#include "config_common.h" + +/* Used to set remote for remote KB if VUSB detect doesn't work. */ +// #define KEYBOARD_REMOTE + +// Workaround for freezing after MacOS sleep +#define USB_SUSPEND_WAKEUP_DELAY 200 + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0x6E61 +#define PRODUCT_ID 0x6064 +#define DEVICE_VER 0x0001 +#define MANUFACTURER nullbits +#define PRODUCT TIDBIT + +/* key matrix size */ +#define MATRIX_ROWS 5 +#define MATRIX_COLS 6 + +/* key matrix pins */ +#define MATRIX_ROW_PINS { B1, E6, D7, C6, D4 } +#define MATRIX_COL_PINS { NO_PIN, NO_PIN, F4, F5, F6, F7 } +#define UNUSED_PINS + +/* COL2ROW or ROW2COL */ +#define DIODE_DIRECTION ROW2COL + +/* Optional SMT LED pins */ +#define RGB_DI_PIN B6 +#define RGBLED_NUM 8 +#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 */ +// Encoders are defined in order. 1: B2 & B3, 2: B4 & B5, 3: D0 & D1, 4: D2 & D3 +#define ENCODERS_PAD_A { B2, B4, D0, D3 } +#define ENCODERS_PAD_B { B3, B5, D1, D2 } diff --git a/keyboards/nullbitsco/tidbit/info.json b/keyboards/nullbitsco/tidbit/info.json new file mode 100644 index 0000000000..5d260cc453 --- /dev/null +++ b/keyboards/nullbitsco/tidbit/info.json @@ -0,0 +1,14 @@ +{ + "keyboard_name": "TIDBIT 19", + "url": "https://nullbits.co/tidbit/", + "layouts": { + "LAYOUT": { + "layout": [ + {"label":"/", "x":3.25, "y":0}, {"label":"*", "x":4.25, "y":0}, {"label":"-", "x":5.25, "y":0}, + {"label":"Enc 1", "x":0, "y":1}, {"label":"Enc 1", "x":1, "y":1}, {"label":"7", "x":2.25, "y":1}, {"label":"8", "x":3.25, "y":1}, {"label":"9", "x":4.25, "y":1}, {"label":"+", "x":5.25, "y":1}, + {"label":"Enc 2", "x":0, "y":2}, {"label":"Enc 2", "x":1, "y":2}, {"label":"4", "x":2.25, "y":2}, {"label":"5", "x":3.25, "y":2}, {"label":"6", "x":4.25, "y":2}, {"label":"+", "x":5.25, "y":2}, + {"label":"Enc 3", "x":0, "y":3}, {"label":"Enc 3", "x":1, "y":3}, {"label":"1", "x":2.25, "y":3}, {"label":"2", "x":3.25, "y":3}, {"label":"3", "x":4.25, "y":3}, {"label":"Enter", "x":5.25, "y":3}, + {"label":"Enc 4", "x":0, "y":4}, {"label":"Enc 4", "x":1, "y":4}, {"label":"0", "x":2.25, "y":4}, {"label":"0", "x":3.25, "y":4}, {"label":".", "x":4.25, "y":4}, {"label":"Enter", "x":5.25, "y":4}] + } + } +} diff --git a/keyboards/nullbitsco/tidbit/keymaps/default/keymap.c b/keyboards/nullbitsco/tidbit/keymaps/default/keymap.c new file mode 100644 index 0000000000..995aff8d69 --- /dev/null +++ b/keyboards/nullbitsco/tidbit/keymaps/default/keymap.c @@ -0,0 +1,40 @@ +/* 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/>. + */ + +#include QMK_KEYBOARD_H + +enum layers { + _BASE = 0, + _FUNC +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_BASE] = LAYOUT( + KC_PSLS, KC_PAST, KC_PMNS, + KC_VOLD, KC_VOLU, KC_P7, KC_P8, KC_P9, KC_PPLS, + KC_MPRV, KC_MNXT, KC_P4, KC_P5, KC_P6, KC_PPLS, + KC_LEFT, KC_RGHT, KC_P1, KC_P2, KC_P3, KC_PENT, + KC_TRNS, KC_TRNS, KC_P0, KC_P0, KC_PDOT, KC_PENT + ), + + [_FUNC] = LAYOUT( + ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___ + ), +}; diff --git a/keyboards/nullbitsco/tidbit/keymaps/oled/keymap.c b/keyboards/nullbitsco/tidbit/keymaps/oled/keymap.c new file mode 100644 index 0000000000..3fbfb638ec --- /dev/null +++ b/keyboards/nullbitsco/tidbit/keymaps/oled/keymap.c @@ -0,0 +1,58 @@ +/* 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/>. + */ + +#include QMK_KEYBOARD_H + +enum layers { + _BASE = 0, + _VIA1, + _VIA2, + _VIA3 +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_BASE] = LAYOUT( + KC_PSLS, KC_PAST, KC_PMNS, + KC_VOLD, KC_VOLU, KC_P7, KC_P8, KC_P9, KC_PPLS, + KC_TRNS, KC_TRNS, KC_P4, KC_P5, KC_P6, KC_PPLS, + KC_TRNS, KC_TRNS, KC_P1, KC_P2, KC_P3, KC_PENT, + KC_TRNS, KC_TRNS, KC_P0, KC_P0, KC_PDOT, KC_PENT + ), + + [_VIA1] = LAYOUT( + ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___ + ), + + [_VIA2] = LAYOUT( + ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___ + ), + + [_VIA3] = LAYOUT( + ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___ + ), +}; diff --git a/keyboards/nullbitsco/tidbit/keymaps/oled/rules.mk b/keyboards/nullbitsco/tidbit/keymaps/oled/rules.mk new file mode 100644 index 0000000000..ef531564fc --- /dev/null +++ b/keyboards/nullbitsco/tidbit/keymaps/oled/rules.mk @@ -0,0 +1,3 @@ +VIA_ENABLE = yes +OLED_ENABLE = yes +OLED_DRIVER = SSD1306 diff --git a/keyboards/nullbitsco/tidbit/keymaps/snailmap_lite/keymap.c b/keyboards/nullbitsco/tidbit/keymaps/snailmap_lite/keymap.c new file mode 100644 index 0000000000..cfe97e30a3 --- /dev/null +++ b/keyboards/nullbitsco/tidbit/keymaps/snailmap_lite/keymap.c @@ -0,0 +1,283 @@ +/* Copyright 2021 dogspace <https://github.com/dogspace> + * + * 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 + +enum layer_names { + _LAY0, + _LAY1, + _LAY2, + _LAY3 +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_LAY0] = LAYOUT( + KC_PSLS, KC_PAST, KC_PMNS, + KC_VOLD, KC_VOLU, KC_P7, KC_P8, KC_P9, KC_PPLS, + KC_TRNS, KC_TRNS, KC_P4, KC_P5, KC_P6, KC_PPLS, + KC_TRNS, KC_TRNS, KC_P1, KC_P2, KC_P3, KC_PENT, + KC_TRNS, KC_TRNS, KC_P0, KC_P0, KC_PDOT, KC_PENT + ), + + [_LAY1] = LAYOUT( + ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___ + ), + + [_LAY2] = LAYOUT( + ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___ + ), + + [_LAY3] = LAYOUT( + ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___ + ), +}; + +#ifdef OLED_ENABLE +/*=========================================== OLED CONFIGURATION ===========================================*/ +#define OLED_ROTATE true // OLED rotation (flip 180* from default orientation) +#define GRAPH_DIRECTION true // Graph movement (true = right to left, false = left to right) +#define GRAPH_TOP_WPM 100.0 // Minimum WPM required to reach the top of the graph +#define GRAPH_REFRESH 1000 // In milliseconds, determines the graph-line frequency +#define ICON_MED_WPM 10 // WPM required to display the medium snail +#define ICON_FAST_WPM 25 // WPM required to display the fast snail + +// Layer names: Should be exactly 5 characters in length if vertical display, or 6 characters if horizontal +#define MA_LAYER_NAME "LAY 0" // Layer _MA name +#define L1_LAYER_NAME "LAY 1" // Layer _L1 name +#define L2_LAYER_NAME "LAY 2" // Layer _L2 name +#define L3_LAYER_NAME "LAY 3" // Layer _L3 name + +#define CAPLCK_STR "CAPLK" // Caps Lock string +#define NUMLCK_STR "NUMLK" // Num Lock string +#define SCRLK_STR "SCRLK" // Scroll Lock string +#define EMPTY_STR " " // Empty string + +/*================================================================================================================*/ + +typedef struct oled_params { + bool first_loop : 1; + uint8_t wpm_icon : 7; + uint16_t timer; + uint8_t wpm_limit; + uint8_t max_wpm; + uint8_t graph_lines[32]; +} oled_params; + +oled_params oled_data; + +void oled_init_data(void) { + // Initialize oled params + oled_data.first_loop = true; + oled_data.wpm_icon = 5; + oled_data.timer = 0; + oled_data.wpm_limit = 20; + oled_data.max_wpm = 0; + + for (int i=0; i<32; i++) { + oled_data.graph_lines[i] = 0; + } +} + +// Set OLED rotation +oled_rotation_t oled_init_user(oled_rotation_t rotation) { + oled_init_data(); + return OLED_ROTATE ? OLED_ROTATION_270 : OLED_ROTATION_90; +} + +// Draw static background image to OLED (keyboard with no bottom row) +static void render_background(void) { + static const char PROGMEM nullbits_n_oled[] = { + 0x00, 0xe0, 0xf0, 0xf0, 0xf8, 0xf8, 0xf0, 0xf0, 0xe0, 0x80, 0x20, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, + 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xe0, 0xe0, 0xe0, 0xc0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, + 0x1f, 0x1f, 0x1f, 0x1f, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfc, 0xf0, 0x00, 0x00, + 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, + 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, + 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, + 0x00, 0x07, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x07, 0x03, 0x00, + }; + oled_write_raw_P(nullbits_n_oled, sizeof(nullbits_n_oled)); +} + +// Toggles pixel on/off, converts horizontal coordinates to vertical equivalent if necessary +static void write_pixel(uint8_t x, uint8_t y, bool onoff) { + oled_write_pixel(y, 127 - x, onoff); +} + +// Write active layer name +static void render_layer_state(void) { + oled_set_cursor(0, 15); + switch (get_highest_layer(layer_state)) { + case _LAY0: + oled_write_P(PSTR(MA_LAYER_NAME), false); + break; + case _LAY1: + oled_write_P(PSTR(L1_LAYER_NAME), false); + break; + case _LAY2: + oled_write_P(PSTR(L2_LAYER_NAME), false); + break; + case _LAY3: + oled_write_P(PSTR(L3_LAYER_NAME), false); + break; + default: + oled_write("ERROR", false); + break; + } +} + +// Update WPM counters +static void render_wpm_counters(uint8_t current_wpm) { + uint8_t cursorposition_cur = 13; + uint8_t cursorposition_max = 14; + + oled_set_cursor(0, cursorposition_cur); + oled_write(get_u8_str(current_wpm, '0'), false); + + if (current_wpm > oled_data.max_wpm) { + oled_data.max_wpm = current_wpm; + oled_data.wpm_limit = oled_data.max_wpm + 20; + oled_set_cursor(0, cursorposition_max); + oled_write(get_u8_str(current_wpm, '0'), false); + } +} + +static void render_led_status(void) { + // Host Keyboard LED Status + uint8_t led_usb_state = host_keyboard_leds(); + oled_set_cursor(0, 8); + oled_write_P(IS_LED_ON(led_usb_state, USB_LED_CAPS_LOCK) ? PSTR(CAPLCK_STR) : PSTR(EMPTY_STR), false); + oled_set_cursor(0, 9); + oled_write_P(IS_LED_ON(led_usb_state, USB_LED_NUM_LOCK) ? PSTR(NUMLCK_STR) : PSTR(EMPTY_STR), false); + oled_set_cursor(0, 10); + oled_write_P(IS_LED_ON(led_usb_state, USB_LED_SCROLL_LOCK) ? PSTR(SCRLK_STR) : PSTR(EMPTY_STR), false); +} + +// Update WPM snail icon +static void render_wpm_icon(uint8_t current_wpm) { + // wpm_icon is used to prevent unnecessary redraw + if ((current_wpm < ICON_MED_WPM) && (oled_data.wpm_icon != 0)) { + oled_data.wpm_icon = 0; + } else if ((current_wpm >= ICON_MED_WPM) && (current_wpm < ICON_FAST_WPM) && (oled_data.wpm_icon != 1)) { + oled_data.wpm_icon = 1; + } else if ((current_wpm >= ICON_FAST_WPM) && (oled_data.wpm_icon != 2)) { + oled_data.wpm_icon = 2; + } else { + return; + } + static const char PROGMEM snails[][2][24] = { + {{0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x20, 0xA0, 0x20, 0x40, 0x40, 0x80, 0x00, 0x00, 0x00, 0x80, 0x40, 0x20, 0x50, 0x88, 0x04, 0x00, 0x00}, + {0x40, 0x60, 0x50, 0x4E, 0x51, 0x64, 0x4A, 0x51, 0x54, 0x49, 0x41, 0x62, 0x54, 0x49, 0x46, 0x41, 0x40, 0x30, 0x09, 0x04, 0x02, 0x01, 0x00, 0x00}}, + {{0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0x40, 0x40, 0x40, 0x80, 0x80, 0x00, 0x00, 0x00, 0x04, 0x98, 0x60, 0x80, 0x00, 0x00, 0x00, 0x00}, + {0x60, 0x50, 0x54, 0x4A, 0x51, 0x64, 0x4A, 0x51, 0x55, 0x49, 0x41, 0x62, 0x54, 0x49, 0x46, 0x41, 0x21, 0x10, 0x0A, 0x08, 0x05, 0x02, 0x00, 0x00}}, + {{0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0x40, 0x40, 0x80, 0x80, 0x10, 0x10, 0x10, 0x20, 0x40, 0x40, 0xC0, 0x80, 0x80, 0x00, 0x00, 0x00}, + {0x60, 0x58, 0x54, 0x62, 0x49, 0x54, 0x52, 0x51, 0x55, 0x49, 0x62, 0x52, 0x4D, 0x45, 0x46, 0x22, 0x21, 0x11, 0x10, 0x0A, 0x08, 0x05, 0x02, 0x00}} + }; + oled_set_cursor(0, 11); + oled_write_raw_P(snails[oled_data.wpm_icon][0], sizeof(snails[oled_data.wpm_icon][0])); + oled_set_cursor(0, 12); + oled_write_raw_P(snails[oled_data.wpm_icon][1], sizeof(snails[oled_data.wpm_icon][1])); +} + +// Update WPM graph +static void render_wpm_graph(uint8_t current_wpm) { + uint8_t line_height = ((current_wpm / GRAPH_TOP_WPM) * 7); + if (line_height > 7) { + line_height = 7; + } + // Count graph line pixels, return if nothing to draw + uint8_t pixel_count = line_height; + for (int i = 0; i < 31; i++) { + pixel_count += oled_data.graph_lines[i]; + } + if (pixel_count == 0) { + return; + } + // Shift array elements left or right depending on GRAPH_DIRECTION pend new graph line + if (GRAPH_DIRECTION) { + for (int i = 0; i < 31; i++) { + oled_data.graph_lines[i] = oled_data.graph_lines[i + 1]; + } + oled_data.graph_lines[31] = line_height; + } else { + for (int i = 31; i > 0; i--) { + oled_data.graph_lines[i] = oled_data.graph_lines[i - 1]; + } + oled_data.graph_lines[0] = line_height; + } + // Draw all graph lines (left to right, bottom to top) + uint16_t draw_count, arrpos; + for (int x = 1; x <= 63; x += 2) { + arrpos = x / 2; + draw_count = oled_data.graph_lines[arrpos]; + for (int y = 31; y >= 25; y--) { + if (draw_count > 0) { + write_pixel(x, y, true); + draw_count--; + } else { + write_pixel(x, y, false); + } + } + } +} + +// Call OLED functions +bool oled_task_user(void) { + // Draw OLED keyboard, prevent redraw + if (oled_data.first_loop) { + render_background(); + oled_data.first_loop = false; + } + // Get current WPM, subtract 25% for accuracy and prevent large jumps caused by simultaneous keypresses + uint8_t current_wpm = get_current_wpm(); + // Write active layer name to display + render_layer_state(); + // Update WPM counters + render_wpm_counters(current_wpm); + // Update WPM snail icon + render_wpm_icon(current_wpm); + // Update LED status + render_led_status(); + // Update WPM graph every graph_refresh milliseconds + if (timer_elapsed(oled_data.timer) > GRAPH_REFRESH) { + render_wpm_graph(current_wpm); + oled_data.timer = timer_read(); + } + return false; +} +#endif + +bool wpm_keycode_user(uint16_t keycode) { + // Count all keycodes on the macropad + return true; +} + diff --git a/keyboards/nullbitsco/tidbit/keymaps/snailmap_lite/rules.mk b/keyboards/nullbitsco/tidbit/keymaps/snailmap_lite/rules.mk new file mode 100644 index 0000000000..1b72fd006a --- /dev/null +++ b/keyboards/nullbitsco/tidbit/keymaps/snailmap_lite/rules.mk @@ -0,0 +1,6 @@ +OLED_ENABLE = yes +WPM_ENABLE = yes +VIA_ENABLE = yes +SPACE_CADET_ENABLE = no +GRAVE_ESC_ENABLE = no +MAGIC_ENABLE = no diff --git a/keyboards/nullbitsco/tidbit/keymaps/via/keymap.c b/keyboards/nullbitsco/tidbit/keymaps/via/keymap.c new file mode 100644 index 0000000000..ad3e18075c --- /dev/null +++ b/keyboards/nullbitsco/tidbit/keymaps/via/keymap.c @@ -0,0 +1,59 @@ +/* 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/>. + */ + +#include QMK_KEYBOARD_H + +enum layers { + _BASE = 0, + _VIA1, + _VIA2, + _VIA3 +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_BASE] = LAYOUT( + KC_PSLS, KC_PAST, KC_PMNS, + KC_VOLD, KC_VOLU, KC_P7, KC_P8, KC_P9, KC_PPLS, + KC_TRNS, KC_TRNS, KC_P4, KC_P5, KC_P6, KC_PPLS, + KC_TRNS, KC_TRNS, KC_P1, KC_P2, KC_P3, KC_PENT, + KC_TRNS, KC_TRNS, KC_P0, KC_P0, KC_PDOT, KC_PENT + ), + + [_VIA1] = LAYOUT( + ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___ + ), + + [_VIA2] = LAYOUT( + ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___ + ), + + [_VIA3] = LAYOUT( + ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___ + ), +}; + diff --git a/keyboards/nullbitsco/tidbit/keymaps/via/rules.mk b/keyboards/nullbitsco/tidbit/keymaps/via/rules.mk new file mode 100644 index 0000000000..036bd6d1c3 --- /dev/null +++ b/keyboards/nullbitsco/tidbit/keymaps/via/rules.mk @@ -0,0 +1 @@ +VIA_ENABLE = yes
\ No newline at end of file diff --git a/keyboards/nullbitsco/tidbit/readme.md b/keyboards/nullbitsco/tidbit/readme.md new file mode 100644 index 0000000000..f2d0d9934b --- /dev/null +++ b/keyboards/nullbitsco/tidbit/readme.md @@ -0,0 +1,26 @@ +# TIDBIT + +![TIDBIT](https://nullbits.co/static/img/tidbit1.jpg) + +A very moddable 19-key numpad kit built by nullbits. [More info at nullbits.co](https://nullbits.co/tidbit/) + +* Keyboard Maintainer: [Jay Greco](https://github.com/jaygreco) +* Hardware Supported: TIDBIT 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. + +## Bootloader + +Enter the bootloader in 2 ways: + +* **Physical reset button**: Briefly press the button on the back of the PCB +* **Keycode in layout**: Press the key mapped to `RESET` if it is available + +Make example for this keyboard (after setting up your build environment): + + make nullbitsco/tidbit: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/tidbit/rules.mk b/keyboards/nullbitsco/tidbit/rules.mk new file mode 100644 index 0000000000..13893a69e2 --- /dev/null +++ b/keyboards/nullbitsco/tidbit/rules.mk @@ -0,0 +1,26 @@ +# MCU name +MCU = atmega32u4 + +# Bootloader selection +BOOTLOADER = atmel-dfu + +# Build Options +# change yes to no to disable +# +BOOTMAGIC_ENABLE = no # Enable Bootmagic Lite +MOUSEKEY_ENABLE = yes # Mouse keys +EXTRAKEY_ENABLE = yes # Audio control and System control +CONSOLE_ENABLE = no # Console for debug +COMMAND_ENABLE = no # Commands for debug and configuration +NKRO_ENABLE = no # Enable N-Key Rollover +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow +AUDIO_ENABLE = no # Audio output +ENCODER_ENABLE = yes +LTO_ENABLE = yes + +# Project specific files +SRC += common/bitc_led.c \ + common/remote_kb.c +QUANTUM_LIB_SRC += i2c_master.c \ + uart.c diff --git a/keyboards/nullbitsco/tidbit/tidbit.c b/keyboards/nullbitsco/tidbit/tidbit.c new file mode 100644 index 0000000000..6e7ef460e5 --- /dev/null +++ b/keyboards/nullbitsco/tidbit/tidbit.c @@ -0,0 +1,157 @@ +/* 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/>. +*/ + +#include QMK_KEYBOARD_H + +typedef struct PACKED { + uint8_t r; + uint8_t c; +} encodermap_t; + +// Map encoders to their respective virtual matrix entry +// Allows for encoder control using VIA +const encodermap_t encoder_map[4][2] = { + {{1, 0}, {1, 1}}, // Encoder 1 matrix location + {{2, 0}, {2, 1}}, // Encoder 2 matrix location + {{3, 0}, {3, 1}}, // Encoder 3 matrix location + {{4, 0}, {4, 1}}, // Encoder 4 matrix location +}; + +bool numlock_set = false; + +#ifdef OLED_ENABLE +oled_rotation_t oled_init_kb(oled_rotation_t rotation) { + return OLED_ROTATION_180; +} + +static void render_logo(void) { + static const char PROGMEM tidbit_oled[] = { + 0x00, 0x0e, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, + 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0x1f, 0x1f, 0x1f, + 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x3e, 0x3e, 0x7e, 0xfc, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xf8, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, + 0x1f, 0x1f, 0x3f, 0x7e, 0xfe, 0xfe, 0xfc, 0xf8, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xfe, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x0e, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, + 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1e, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xc0, + 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, + 0xe0, 0xf0, 0xf0, 0xf8, 0xff, 0xff, 0xbf, 0x1f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x03, + 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x07, 0x07, 0xbf, 0xff, 0xff, 0xff, 0xfe, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x7f, 0xff, 0xff, 0x7f, 0x3f, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, + 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x7f, 0x7f, 0x7f, 0xff, 0xff, 0xf8, 0xf8, 0xf8, + 0xf8, 0xf8, 0xf8, 0x7c, 0x7c, 0x7c, 0x7e, 0x3e, 0x3f, 0x3f, 0x1f, 0x0f, 0x07, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x1f, 0x7f, 0x7f, 0x7f, 0xff, 0xff, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, + 0xf8, 0x7c, 0x7c, 0x7c, 0x7e, 0x3f, 0x3f, 0x1f, 0x1f, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x7f, 0xff, 0xff, 0x7f, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x3f, 0x7f, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + + oled_write_raw_P(tidbit_oled, sizeof(tidbit_oled)); +}; + +bool oled_task_kb(void) { + if (!oled_task_user()) return false; + render_logo(); + return true; +} + +#endif + +static void process_encoder_matrix(encodermap_t pos) { + action_exec((keyevent_t){ + .key = (keypos_t){.row = pos.r, .col = pos.c}, .pressed = true, .time = (timer_read() | 1) /* time should not be 0 */ + }); +#if TAP_CODE_DELAY > 0 + wait_ms(TAP_CODE_DELAY); +#endif + action_exec((keyevent_t){ + .key = (keypos_t){.row = pos.r, .col = pos.c}, .pressed = false, .time = (timer_read() | 1) /* time should not be 0 */ + }); +} + +bool encoder_update_kb(uint8_t index, bool clockwise) { + if (!encoder_update_user(index, clockwise)) return false; + process_encoder_matrix(encoder_map[index][clockwise ? 0 : 1]); + return false; +} + +// Use Bit-C LED to show NUM LOCK status +bool led_update_kb(led_t led_state) { + bool res = led_update_user(led_state); + if (res) { + set_bitc_LED(led_state.num_lock ? LED_DIM : LED_OFF); + } + return res; +} + +bool process_record_kb(uint16_t keycode, keyrecord_t *record) { + process_record_remote_kb(keycode, record); + if (!process_record_user(keycode, record)) return false; + + // Get the current NLCK status & set if not set. + // Only do this once, in case user has a NLCK key + // and wants to disable it later on. + if (!numlock_set && record->event.pressed) { + led_t led_state = host_keyboard_led_state(); + if (!led_state.num_lock) { + register_code(KC_NLCK); + } + numlock_set = true; + } + + switch (keycode) { + case RESET: + if (record->event.pressed) { + set_bitc_LED(LED_DIM); + rgblight_disable_noeeprom(); + #ifdef OLED_ENABLE + oled_off(); + #endif + bootloader_jump(); // jump to bootloader + } + return false; + + default: + break; + } + + return true; +} + +void matrix_init_kb(void) { + set_bitc_LED(LED_OFF); + matrix_init_remote_kb(); + matrix_init_user(); +} + +void matrix_scan_kb(void) { + matrix_scan_remote_kb(); + matrix_scan_user(); +} diff --git a/keyboards/nullbitsco/tidbit/tidbit.h b/keyboards/nullbitsco/tidbit/tidbit.h new file mode 100644 index 0000000000..e4e80107e3 --- /dev/null +++ b/keyboards/nullbitsco/tidbit/tidbit.h @@ -0,0 +1,37 @@ +/* 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/>. + */ +#pragma once + +#define ___ KC_NO + +#include "quantum.h" +#include "common/remote_kb.h" +#include "common/bitc_led.h" + +#define LAYOUT( \ + K01, K02, K03, \ + E1CCW, E1CW, K10, K11, K12, K13, \ + E2CCW, E2CW, K20, K21, K22, K23, \ + E3CCW, E3CW, K30, K31, K32, K33, \ + E4CCW, E4CW, K40, K41, K42, K43 \ +) \ +{ \ + { ___, ___, ___, K01, K02, K03 }, \ + { E1CCW, E1CW, K10, K11, K12, K13 }, \ + { E2CCW, E2CW, K20, K21, K22, K23 }, \ + { E3CCW, E3CW, K30, K31, K32, K33 }, \ + { E4CCW, E4CW, K40, K41, K42, K43 } \ +} |