From 6384a2abd8d49f80b28f5a7c0045d39d4c3caa1f Mon Sep 17 00:00:00 2001 From: Marko Bakan <47256307+obuwunkunubi@users.noreply.github.com> Date: Thu, 9 Apr 2020 21:45:08 +0200 Subject: [PATCH] [Keyboard] obuwunkunubi/spaget handwired (#8738) * adding my keymap * Update keyboards/handwired/obuwunkunubi/spaget/readme.md * Update keyboards/handwired/obuwunkunubi/spaget/readme.md * Update keyboards/handwired/obuwunkunubi/spaget/keymaps/default/rules.mk * Update rules.mk * Update keyboards/handwired/obuwunkunubi/spaget/spaget.h * Update keyboards/handwired/obuwunkunubi/spaget/spaget.h * Update keyboards/handwired/obuwunkunubi/spaget/info.json * Update keyboards/handwired/obuwunkunubi/spaget/rules.mk * Update rules.mk * Update keyboards/handwired/obuwunkunubi/spaget/spaget.c * Update keyboards/handwired/obuwunkunubi/spaget/keymaps/default/keymap.c * Update keyboards/handwired/obuwunkunubi/spaget/keymaps/default/keymap.c * Update keyboards/handwired/obuwunkunubi/spaget/keymaps/default/keymap.c * Update keyboards/handwired/obuwunkunubi/spaget/keymaps/default/keymap.c * Update keyboards/handwired/obuwunkunubi/spaget/keymaps/default/keymap.c * Update keyboards/handwired/obuwunkunubi/spaget/keymaps/default/keymap.c * Update keyboards/handwired/obuwunkunubi/spaget/keymaps/default/keymap.c * Update keyboards/handwired/obuwunkunubi/spaget/info.json * Update keymap.c * Apply suggestions from code review * Apply suggestions from code review * Update spaget.h * Update keymap.c Updated comments --- .../handwired/obuwunkunubi/spaget/config.h | 74 +++ .../handwired/obuwunkunubi/spaget/info.json | 36 ++ .../spaget/keymaps/default/keymap.c | 435 ++++++++++++++++++ .../spaget/keymaps/default/readme.md | 1 + .../spaget/keymaps/default/rules.mk | 1 + .../handwired/obuwunkunubi/spaget/readme.md | 14 + .../handwired/obuwunkunubi/spaget/rules.mk | 34 ++ .../handwired/obuwunkunubi/spaget/spaget.c | 16 + .../handwired/obuwunkunubi/spaget/spaget.h | 47 ++ 9 files changed, 658 insertions(+) create mode 100644 keyboards/handwired/obuwunkunubi/spaget/config.h create mode 100644 keyboards/handwired/obuwunkunubi/spaget/info.json create mode 100644 keyboards/handwired/obuwunkunubi/spaget/keymaps/default/keymap.c create mode 100644 keyboards/handwired/obuwunkunubi/spaget/keymaps/default/readme.md create mode 100644 keyboards/handwired/obuwunkunubi/spaget/keymaps/default/rules.mk create mode 100644 keyboards/handwired/obuwunkunubi/spaget/readme.md create mode 100644 keyboards/handwired/obuwunkunubi/spaget/rules.mk create mode 100644 keyboards/handwired/obuwunkunubi/spaget/spaget.c create mode 100644 keyboards/handwired/obuwunkunubi/spaget/spaget.h diff --git a/keyboards/handwired/obuwunkunubi/spaget/config.h b/keyboards/handwired/obuwunkunubi/spaget/config.h new file mode 100644 index 0000000000..79c5d2bf16 --- /dev/null +++ b/keyboards/handwired/obuwunkunubi/spaget/config.h @@ -0,0 +1,74 @@ +/* +Copyright 2020 obuwunkunubi + +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 . +*/ + +#pragma once + +#include "config_common.h" + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0x1337 +#define PRODUCT_ID 0x6969 +#define DEVICE_VER 0x0001 +#define MANUFACTURER obuwunkunubi +#define PRODUCT spaget +#define DESCRIPTION numpad with 2 encoders and a screen + +/* key matrix size */ +#define MATRIX_ROWS 6 +#define MATRIX_COLS 4 + +// ROWS: Top to bottom, COLS: Left to right + +#define MATRIX_ROW_PINS { D4, C6, D7, E6, B4, B5 } +#define MATRIX_COL_PINS { B1, B3, B2, B6 } + +/* COL2ROW or ROW2COL */ +#define DIODE_DIRECTION COL2ROW + +/* define if matrix has ghost */ +//#define MATRIX_HAS_GHOST + +/* Set 0 if debouncing isn't needed */ +//#define DEBOUNCE 5 + +/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ +#define LOCKING_SUPPORT_ENABLE + +/* Locking resynchronize hack */ +#define LOCKING_RESYNC_ENABLE + +/* Define encoder pins */ +#define ENCODERS_PAD_A { F5, F7 } // 1a, 2a +#define ENCODERS_PAD_B { F4, F6 } // 1b, 2b + +/* + * Feature disable options + * These options are also useful to firmware size reduction. + */ + +/* disable debug print */ +//#define NO_DEBUG + +/* disable print */ +//#define NO_PRINT + +/* disable action features */ +//#define NO_ACTION_LAYER +//#define NO_ACTION_TAPPING +//#define NO_ACTION_ONESHOT +//#define NO_ACTION_MACRO +//#define NO_ACTION_FUNCTION diff --git a/keyboards/handwired/obuwunkunubi/spaget/info.json b/keyboards/handwired/obuwunkunubi/spaget/info.json new file mode 100644 index 0000000000..4228c9c648 --- /dev/null +++ b/keyboards/handwired/obuwunkunubi/spaget/info.json @@ -0,0 +1,36 @@ +{ + "keyboard_name": "spaget", + "url": "", + "maintainer": "obuwunkunubi", + "width": 4, + "height": 7.5, + "layouts": { + "LAYOUT": { + "layout": [ + {"x":0, "y":0}, + {"x":3, "y":0}, + {"x":0, "y":1.5}, + {"x":1, "y":1.5}, + {"x":2, "y":1.5}, + {"x":3, "y":1.5}, + {"x":0, "y":2.5}, + {"x":1, "y":2.5}, + {"x":2, "y":2.5}, + {"x":3, "y":2.5}, + {"x":0, "y":3.5}, + {"x":1, "y":3.5}, + {"x":2, "y":3.5}, + {"x":0, "y":4.5}, + {"x":1, "y":4.5}, + {"x":2, "y":4.5}, + {"x":3, "y":3.5, "h":2}, + {"x":0, "y":5.5}, + {"x":1, "y":5.5}, + {"x":2, "y":5.5}, + {"x":0, "y":6.5, "w":2}, + {"x":2, "y":6.5}, + {"x":3, "y":5.5, "h":2} + ] + } + } +} diff --git a/keyboards/handwired/obuwunkunubi/spaget/keymaps/default/keymap.c b/keyboards/handwired/obuwunkunubi/spaget/keymaps/default/keymap.c new file mode 100644 index 0000000000..1854894e56 --- /dev/null +++ b/keyboards/handwired/obuwunkunubi/spaget/keymaps/default/keymap.c @@ -0,0 +1,435 @@ +/* Copyright 2020 obuwunkunubi +* +* 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 . +*/ +#include QMK_KEYBOARD_H + +// Defines for shortcut macros +#define KC_CAD LALT(LCTL(KC_DEL)) // CTRL + ALT + DEL +#define KC_CPY LCTL(KC_C) // Copy +#define KC_PST LCTL(KC_V) // Paste +#define KC_AF4 LALT(KC_F4) // ALT + F4 + +enum custom_keycodes { + SELWN = SAFE_RANGE, + SELWP, + EM1, + EM2, + EM3, + EM4, + EM5, + EM6, + EM7, + EM8, + EM9, + MAKE1, + MAKE2, + MAIL1, + MAIL2, + OBUWUN, + DIR +}; + +enum layer_names { + BASE, + ONE, + TWO +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + + /* Keymap BASE: Base Layer + * + * ,---. ,---. + * |NUM| |PLY| + * `---' `---' + * ,---------------. + * |CAL| UP|PRE|NXT| + * |---------------| + * | = | / | * | - | + * |---------------| + * | 7 | 8 | 9 | | + * |------------ + | + * | 4 | 5 | 6 | | + * |---------------| + * | 1 | 2 | 3 | | + * |------------ENT| + * | 0 | . | | + * `---------------' + */ + [BASE] = LAYOUT( \ + KC_NLCK, KC_MPLY, \ + KC_CALC, TO(ONE), KC_MPRV, KC_MNXT, \ + KC_EQL, KC_PSLS, KC_PAST, KC_MINS, \ + KC_P7, KC_P8, KC_P9, \ + KC_P4, KC_P5, KC_P6, KC_PPLS, \ + KC_P1, KC_P2, KC_P3, \ + KC_P0, KC_PDOT, KC_PENT \ + ), + + /* Keymap ONE: Util Layer + * + * ,---. ,---. + * |RST| |CAD| + * `---' `---' + * ,---------------. + * |BAS|TWO|MK1|MK2| + * |---------------| + * |DIR|@1 |@2 |OBU| + * |---------------| + * |SWP|AF4|SWN| | + * |------------PSC| + * |CPY| U |PST| | + * |---------------| + * | L | D | R | | + * |------------ NO| + * | NO | NO| | + * `---------------' + */ + [ONE] = LAYOUT( \ + RESET, KC_CAD, \ + TO(BASE), TO(TWO), MAKE1, MAKE2, \ + DIR, MAIL1, MAIL2, OBUWUN, \ + SELWP, KC_AF4, SELWN, \ + KC_CPY, KC_UP, KC_PST, KC_PSCR, \ + KC_LEFT, KC_DOWN, KC_RGHT, \ + KC_P0, KC_PDOT, KC_PENT \ + ), + + /* Keymap TWO: Emoji Layer + * + * ,---. ,---. + * | NO| | NO| + * `---' `---' + * ,---------------. + * |ONE|BAS| [ | ] | + * |---------------| + * |F13|F14|F15|F16| + * |---------------| + * |EM7|EM8|EM9| | + * |------------ NO| + * |EM4|EM5|EM6| | + * |---------------| + * |EM1|EM2|EM3| | + * |------------ NO| + * | NO | NO| | + * `---------------' + */ + [TWO] = LAYOUT( \ + KC_NO, KC_NO, \ + TO(ONE), TO(BASE), KC_LBRC, KC_RBRC, \ + KC_F13, KC_F14, KC_F15, KC_F16, \ + EM7, EM8, EM9, \ + EM4, EM5, EM6, KC_NO, \ + EM1, EM2, EM3, \ + KC_NO, KC_NO, KC_NO \ + ), + +}; + + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + + case SELWN: // select and copy next word + if (record->event.pressed) { + // when keycode SELWN is pressed + + tap_code16(C(S(KC_RGHT))); + tap_code16(KC_CPY); + return false; break; + + } else { + // when keycode SELWN is released + } + break; + + case SELWP: // select and copy previous word + if (record->event.pressed) { + // when keycode SELWP is pressed + + tap_code16(C(S(KC_LEFT))); + tap_code16(KC_CPY); + return false; break; + + } else { + // when keycode SELWP is released + } + break; + + case MAKE1: + if (record->event.pressed) { + // when keycode MAKE1 is pressed + + send_string("make handwired/obuwunkunubi/spaget:default:avrdude"); + + } else { + // when keycode MAKE1 is released + } + break; + + case MAKE2: + if (record->event.pressed) { + // when keycode MAKE2 is pressed + + send_string("make preonic/rev3:obuwunkunubi:dfu-util"); + + } else { + // when keycode MAKE2 is released + } + break; + + case DIR: + if (record->event.pressed) { + // when keycode DIR is pressed + + send_string("cd /d/Keyboards/qmk/qmk_firmware/"); + + } else { + // when keycode DIR is released + } + break; + + case OBUWUN: + if (record->event.pressed) { + // when keycode OBUWUN is pressed + + send_string("obuwunkunubi"); + + } else { + // when keycode OBUWUN is released + } + break; + + case MAIL1: + if (record->event.pressed) { + // when keycode MAIL1 is pressed + + send_string("marko.bakan7"); + + } else { + // when keycode MAIL1 is released + } + break; + + case MAIL2: + if (record->event.pressed) { + // when keycode MAIL2 is pressed + + send_string("bakan.marko7"); + + } else { + // when keycode MAIL2 is released + } + break; + + case EM1: + if (record->event.pressed) { + // when keycode EM1 is pressed + + send_unicode_string("ʕ•ᴥ•ʔ"); + + } else { + // when keycode EM1 is released + } + break; + + case EM2: + if (record->event.pressed) { + // when keycode EM2 is pressed + + send_unicode_string("༼ つ ◕_◕ ༽つ"); + + } else { + // when keycode EM2 is released + } + break; + + case EM3: + if (record->event.pressed) { + // when keycode EM3 is pressed + + send_unicode_string("( ⌐■_■)"); + + } else { + // when keycode EM3 is released + } + break; + + case EM4: + if (record->event.pressed) { + // when keycode EM4 is pressed + + send_unicode_string("(╯°□°)╯彡 ┻━┻"); + + } else { + // when keycode EM4 is released + } + break; + + case EM5: + if (record->event.pressed) { + // when keycode EM5 is pressed + + send_unicode_string("ಠ_ಠ"); + + } else { + // when keycode EM5 is released + } + break; + + case EM6: + if (record->event.pressed) { + // when keycode EM6 is pressed + + send_unicode_string("( ͡° ͜ʖ ͡°)"); + + } else { + // when keycode EM6 is released + } + break; + + case EM7: + if (record->event.pressed) { + // when keycode EM7 is pressed + + send_unicode_string("(☞゚ヮ゚)☞"); + + } else { + // when keycode EM7 is released + } + break; + + case EM8: + if (record->event.pressed) { + // when keycode EM8 is pressed + + send_unicode_string("(^‿^)"); + + } else { + // when keycode EM8 is released + } + break; + + case EM9: + if (record->event.pressed) { + // when keycode EM9 is pressed + + send_unicode_string("¯\\_(ツ)_/¯"); + + } else { + // when keycode EM9 is released + } + break; + + } + return true; +}; + +// Unicode input mode set to Windows using WinCompose +void matrix_init_user(void) { + set_unicode_input_mode(UC_WINC); +}; +#ifdef OLED_DRIVER_ENABLE +void oled_task_user(void) { + oled_write_P(PSTR(" spaget v1\n\n"), false); + + // Host Keyboard Layer Status + oled_write_P(PSTR("Layer: "), false); + + switch (get_highest_layer(layer_state)) { + case BASE: + oled_write_P(PSTR("Base\n"), false); + break; + case ONE: + oled_write_P(PSTR("Util\n"), false); + break; + case TWO: + oled_write_P(PSTR("Emoji\n"), false); + break; + default: + oled_write_ln_P(PSTR("Undefined"), false); + } + + // Host Keyboard LED Status + led_t led_state = host_keyboard_led_state(); + oled_write_P(PSTR("Lock: "), false); + oled_write_P(led_state.num_lock ? PSTR("NUM ") : PSTR(" "), false); + oled_write_P(led_state.caps_lock ? PSTR("CAPS ") : PSTR(" "), false); + oled_write_P(led_state.scroll_lock ? PSTR("SCROLL ") : PSTR(" "), false); +} +#endif + +void encoder_update_user(uint8_t index, bool clockwise) { + if(IS_LAYER_ON(BASE)) { + if (index == 0) { /* First encoder */ + if (clockwise) { + tap_code(KC_PGDN); + } else { + tap_code(KC_PGUP); + } + } else if (index == 1) { /* Second encoder */ + if (clockwise) { + tap_code(KC_VOLU); + } else { + tap_code(KC_VOLD); + } + } + } + else if(IS_LAYER_ON(ONE)) { + if (index == 0) { /* First encoder */ + if (clockwise) { + tap_code(KC_WH_R); + } else { + tap_code(KC_WH_L); + } + } else if (index == 1) { /* Second encoder */ + if (clockwise) { + tap_code(KC_WH_D); + } else { + tap_code(KC_WH_U); + } + } + } + else if(IS_LAYER_ON(TWO)) { + if (index == 0) { /* First encoder */ + if (clockwise) { + tap_code(KC_DEL); + } else { + tap_code(KC_BSPC); + } + } else if (index == 1) { /* Second encoder */ + if (clockwise) { + tap_code(KC_DOWN); + } else { + tap_code(KC_UP); + } + } + } + else { + if (index == 0) { /* First encoder */ + if (clockwise) { + tap_code(KC_PGDN); + } else { + tap_code(KC_PGUP); + } + } else if (index == 1) { /* Second encoder */ + if (clockwise) { + tap_code(KC_VOLU); + } else { + tap_code(KC_VOLD); + } + } + } +} diff --git a/keyboards/handwired/obuwunkunubi/spaget/keymaps/default/readme.md b/keyboards/handwired/obuwunkunubi/spaget/keymaps/default/readme.md new file mode 100644 index 0000000000..9a453e1f69 --- /dev/null +++ b/keyboards/handwired/obuwunkunubi/spaget/keymaps/default/readme.md @@ -0,0 +1 @@ +# default spaget layout diff --git a/keyboards/handwired/obuwunkunubi/spaget/keymaps/default/rules.mk b/keyboards/handwired/obuwunkunubi/spaget/keymaps/default/rules.mk new file mode 100644 index 0000000000..916b1154bd --- /dev/null +++ b/keyboards/handwired/obuwunkunubi/spaget/keymaps/default/rules.mk @@ -0,0 +1 @@ +# Build Overrides diff --git a/keyboards/handwired/obuwunkunubi/spaget/readme.md b/keyboards/handwired/obuwunkunubi/spaget/readme.md new file mode 100644 index 0000000000..253870a432 --- /dev/null +++ b/keyboards/handwired/obuwunkunubi/spaget/readme.md @@ -0,0 +1,14 @@ +# spaget + +![spaget](https://i.imgur.com/ktlhskZ.jpg) + +A hand wired numpad style QMK macropad, with a 128x32 OLED screen and two rotary encoders. Powered by an Arduino Pro Micro. + +* Keyboard Maintainer: [obuwunkunubi](https://github.com/obuwunkunubi) +* Hardware Supported: spaget v1 + +Make example for this keyboard (after setting up your build environment): + + make handwired/obuwunkunubi/spaget: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/handwired/obuwunkunubi/spaget/rules.mk b/keyboards/handwired/obuwunkunubi/spaget/rules.mk new file mode 100644 index 0000000000..8be738f3ec --- /dev/null +++ b/keyboards/handwired/obuwunkunubi/spaget/rules.mk @@ -0,0 +1,34 @@ +# MCU name +MCU = atmega32u4 + +# Bootloader selection +# Teensy halfkay +# Pro Micro caterina +# Atmel DFU atmel-dfu +# LUFA DFU lufa-dfu +# QMK DFU qmk-dfu +# ATmega32A bootloadHID +# ATmega328P USBasp +BOOTLOADER = caterina + +# Build Options +# comment out to disable the options. +# +BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration +MOUSEKEY_ENABLE = yes # Mouse keys +EXTRAKEY_ENABLE = yes # Audio control and System control +CONSOLE_ENABLE = no # Console for debug +COMMAND_ENABLE = yes # Commands for debug and configuration +NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +RGBLIGHT_ENABLE = no # Enable keyboard underlight functionality +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +MIDI_ENABLE = no # MIDI controls +AUDIO_ENABLE = no +UNICODE_ENABLE = yes # Unicode +BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend +AUDIO_ENABLE = no # Audio output on port C6 + +OLED_DRIVER_ENABLE = yes # Enable OLED display support +ENCODER_ENABLE = yes # Enable encoder support + diff --git a/keyboards/handwired/obuwunkunubi/spaget/spaget.c b/keyboards/handwired/obuwunkunubi/spaget/spaget.c new file mode 100644 index 0000000000..aeb0dc5436 --- /dev/null +++ b/keyboards/handwired/obuwunkunubi/spaget/spaget.c @@ -0,0 +1,16 @@ +/* Copyright 2020 obuwunkunubi + * + * 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 . + */ + #include "spaget.h" diff --git a/keyboards/handwired/obuwunkunubi/spaget/spaget.h b/keyboards/handwired/obuwunkunubi/spaget/spaget.h new file mode 100644 index 0000000000..7d4b9e9dff --- /dev/null +++ b/keyboards/handwired/obuwunkunubi/spaget/spaget.h @@ -0,0 +1,47 @@ +/* Copyright 2020 obuwunkunubi + * + * 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 . + */ +#pragma once + +#include "quantum.h" + +/* This a shortcut to help you visually see your layout. + * + * The first section contains all of the arguments representing the physical + * layout of the board and position of the keys. + * + * The second converts the arguments into a two-dimensional array which + * represents the switch matrix. + */ + +// readability +#define XXX KC_NO + +#define LAYOUT( \ + K23, K43, \ + K00, K01, K02, K03, \ + K10, K11, K12, K13, \ + K20, K21, K22, \ + K30, K31, K32, K33, \ + K40, K41, K42, \ + K51, K52, K53 \ +) { \ + { K00, K01, K02, K03 }, \ + { K10, K11, K12, K13 }, \ + { K20, K21, K22, K23 }, \ + { K30, K31, K32, K33 }, \ + { K40, K41, K42, K43 }, \ + { XXX, K51, K52, K53 } \ +}