~ruther/qmk_firmware

cf9239a88277b0fbdd6de184374c6c84c39d8d8f — sotoba 3 years ago 755731f
[Keyboard] Add Contender (#15403)

Co-authored-by: Ryan <fauxpark@gmail.com>
A keyboards/contender/config.h => keyboards/contender/config.h +148 -0
@@ 0,0 1,148 @@
/*
Copyright 2020 sotoba

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"

/* USB Device descriptor parameter */
#define VENDOR_ID    0xFEED
#define PRODUCT_ID   0xC010
#define DEVICE_VER   0x0001
#define MANUFACTURER sotoba
#define PRODUCT      contender

/* key matrix size */
#define MATRIX_ROWS 6
#define MATRIX_COLS 5

/*
 * Keyboard Matrix Assignments
 *
 * Change this to how you wired your keyboard
 * COLS: AVR pins used for columns, left to right
 * ROWS: AVR pins used for rows, top to bottom
 * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode)
 *                  ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode)
 *
 */
#define MATRIX_ROW_PINS { D4, D3, B5, B7, B4, B2 }
#define MATRIX_COL_PINS { C7, D6, B3, B0, B1 }
#define UNUSED_PINS

/* COL2ROW, ROW2COL */
#define DIODE_DIRECTION COL2ROW

/*
 * Split Keyboard specific options, make sure you have 'SPLIT_KEYBOARD = yes' in your rules.mk, and define SOFT_SERIAL_PIN.
 */
#define SOFT_SERIAL_PIN D0  // or D1, D2, D3, E6

//#define LED_NUM_LOCK_PIN B0
//#define LED_CAPS_LOCK_PIN B1
//#define LED_SCROLL_LOCK_PIN B2
//#define LED_COMPOSE_PIN B3
//#define LED_KANA_PIN B4

//#define BACKLIGHT_PIN B7
//#define BACKLIGHT_LEVELS 3
//#define BACKLIGHT_BREATHING

#define RGB_DI_PIN C6
#define RGBLED_NUM 33
#define RGBLIGHT_LED_MAP { \
   0, 1, 2, 3, \
   7, 6, 5, 4, \
   8, 9, 10, 11, \
   15, 14, 13, 12, \
   16, 17, 18, 19, \
   22, 21, 20, \
   25, 24, 23, 26, 27, 28, 29, 30, 31, 32 }
#define RGBLIGHT_HUE_STEP 8
#define RGBLIGHT_SAT_STEP 8
#define RGBLIGHT_VAL_STEP 8
#define RGBLIGHT_LIMIT_VAL 32 /* The maximum brightness level */
#define RGBLIGHT_SLEEP  /* If defined, the RGB lighting will be switched off when the host goes to 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_STATIC_GRADIENT
#define RGBLIGHT_EFFECT_RGB_TEST
#define RGBLIGHT_EFFECT_ALTERNATING

/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
#define DEBOUNCE 5

/* define if matrix has ghost (lacks anti-ghosting diodes) */
//#define MATRIX_HAS_GHOST

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

/* If defined, GRAVE_ESC will always act as ESC when CTRL is held.
 * This is useful for the Windows task manager shortcut (ctrl+shift+esc).
 */
//#define GRAVE_ESC_CTRL_OVERRIDE

/*
 * Force NKRO
 *
 * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved
 * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the
 * makefile for this to work.)
 *
 * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N)
 * until the next keyboard reset.
 *
 * NKRO may prevent your keystrokes from being detected in the BIOS, but it is
 * fully operational during normal computer usage.
 *
 * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N)
 * or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by
 * bootmagic, NKRO mode will always be enabled until it is toggled again during a
 * power-up.
 *
 */
//#define FORCE_NKRO

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

/* disable these deprecated features by default */
#define NO_ACTION_MACRO
#define NO_ACTION_FUNCTION

/* Bootmagic Lite key configuration */
//#define BOOTMAGIC_LITE_ROW 0
//#define BOOTMAGIC_LITE_COLUMN 0

A keyboards/contender/contender.c => keyboards/contender/contender.c +17 -0
@@ 0,0 1,17 @@
/* Copyright 2020 sotoba
 *
 * 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 "contender.h"

A keyboards/contender/contender.h => keyboards/contender/contender.h +43 -0
@@ 0,0 1,43 @@
/* Copyright 2020 sotoba
 *
 * 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"

/* This is 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.
 */
#define LAYOUT( \
      k00, k01, k02, k03, \
      k10, k11, k12, k13, \
      k20, k21, k22, k23, \
    k30, k31, k32, k33, k34, \
    k40, k41, k42, k43, k44, \
    k50, k51, k52, k53 \
) { \
    { KC_NO, k00, k01, k02, k03 }, \
    { KC_NO, k10, k11, k12, k13 }, \
    { KC_NO, k20, k21, k22, k23 }, \
    { k30, k31, k32, k33, k34 }, \
    { k40, k41, k42, k43, k44 }, \
    { k50, k51, k52, k53, KC_NO } \
}

A keyboards/contender/info.json => keyboards/contender/info.json +37 -0
@@ 0,0 1,37 @@
{
    "keyboard_name": "contender",
    "url": "https://github.com/sotoba/contender",
    "maintainer": "sotoba",
    "layouts": {
        "LAYOUT": {
            "layout": [
              {"label":"Esc", "x":1, "y":0},
              {"label":"Tab", "x":2, "y":0},
              {"label":"Shift", "x":3, "y":0},
              {"label":"Back", "x":4, "y":0},
              {"label":"Num", "x":1, "y":1.25},
              {"label":"/", "x":2, "y":1.25},
              {"label":"*", "x":3, "y":1.25},
              {"label":"=", "x":4, "y":1.25},
              {"label":"7", "x":1, "y":2.25},
              {"label":"8", "x":2, "y":2.25},
              {"label":"9", "x":3, "y":2.25},
              {"label":"-", "x":4, "y":2.25},
              {"label":"fn","x":0, "y":3.25},
              {"label":"4", "x":1, "y":3.25},
              {"label":"5", "x":2, "y":3.25},
              {"label":"6", "x":3, "y":3.25},
              {"label":"+", "x":4, "y":3.25},
              {"label":"RGB","x":0, "y":4.25},
              {"label":"1", "x":1, "y":4.25},
              {"label":"2", "x":2, "y":4.25},
              {"label":"3", "x":3, "y":4.25},
              {"label":"Enter", "x":4, "y":4.25, "h":2},
              {"label":"TG","x":0, "y":5.25},
              {"label":"0", "x":1, "y":5.25},
              {"label":"00", "x":2, "y":5.25},
              {"label":".", "x":3, "y":5.25}
            ]
        }
    }
}

A keyboards/contender/keymaps/default/config.h => keyboards/contender/keymaps/default/config.h +19 -0
@@ 0,0 1,19 @@
/*
Copyright 2020 sotoba

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

#define RGBLIGHT_LAYERS
#define RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF

A keyboards/contender/keymaps/default/keymap.c => keyboards/contender/keymaps/default/keymap.c +111 -0
@@ 0,0 1,111 @@
/* Copyright 2020 sotoba
 *
 * 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

// Defines names for use in layer keycodes and the keymap
enum layer_names {
    _BASE,
    _UNRULY,
    _FUNCTION
};

// Defines the keycodes used by our macros in process_record_user
enum custom_keycodes {
    DOUBLE_ZERO = SAFE_RANGE
};

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* Base */
    [_BASE] = LAYOUT(
                           KC_ESCAPE,   KC_LSFT,      KC_TAB,          KC_BSPACE,
                           KC_NLCK,     KC_KP_SLASH,  KC_KP_ASTERISK,  KC_EQUAL,
                           KC_KP_7,     KC_KP_8,      KC_KP_9,         KC_KP_MINUS,
      MO(_FUNCTION),       KC_KP_4,     KC_KP_5,      KC_KP_6,         KC_KP_PLUS,
      RGB_TOG,             KC_KP_1,     KC_KP_2,      KC_KP_3,         KC_KP_ENTER,
      TG(_UNRULY),         KC_KP_0,     DOUBLE_ZERO,  KC_KP_DOT
    ),
    /* Lightning */
    [_UNRULY] = LAYOUT(
                           KC_ESCAPE,   KC_LSFT,      KC_TAB,          KC_BSPACE,
                           KC_NLCK,     KC_KP_SLASH,  KC_KP_ASTERISK,  KC_EQUAL,
                           KC_KP_7,     KC_KP_8,      KC_KP_9,         KC_KP_MINUS,
      KC_TRNS,             KC_KP_4,     KC_KP_5,      KC_KP_6,         KC_KP_PLUS,
      KC_TRNS,             KC_KP_1,     KC_KP_2,      KC_KP_3,         KC_KP_ENTER,
      KC_TRNS,             KC_KP_0,     DOUBLE_ZERO,  KC_KP_DOT
    ),
    /* Function */
    [_FUNCTION] = LAYOUT(
                           RESET,       KC_NO,        KC_NO,           KC_NO,
                           KC_NO,       KC_NO,        KC_NO,           KC_NO,
                           KC_NO,       KC_NO,        KC_NO,           KC_NO,
      KC_TRNS,             RGB_RMOD,    RGB_MOD,      KC_NO,           KC_NO,
      KC_TRNS,             RGB_HUI,     RGB_SAI,      RGB_VAI,         KC_NO,
      KC_TRNS,             RGB_HUD,     RGB_SAD,      RGB_VAD
    )
};

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
    switch (keycode) {
        case DOUBLE_ZERO:
            if (record->event.pressed) {
                // when keycode DOUBLE_ZERO is pressed
                SEND_STRING("00");
            }
            break;
    }
    return true;
}

#ifdef RGBLIGHT_LAYERS
const rgblight_segment_t PROGMEM num_layer[] = RGBLIGHT_LAYER_SEGMENTS(
    {26, 7, HSV_SPRINGGREEN}
);

const rgblight_segment_t PROGMEM unruly_layer[] = RGBLIGHT_LAYER_SEGMENTS(
    {0, 4, HSV_OFF},
    {4, 2, HSV_WHITE},
    {6, 2, HSV_PURPLE},
    {8, 2, HSV_RED},
    {10, 2, HSV_BLUE},
    {12, 2, HSV_YELLOW},
    {14, 2, HSV_GREEN},
    {16, 3, HSV_ORANGE},
    {19, 1, HSV_OFF},
    {20, 3, HSV_PINK},
    {23, 10, HSV_GREEN}
);

const rgblight_segment_t* const PROGMEM rgb_layers[] = RGBLIGHT_LAYERS_LIST(
    num_layer,
    unruly_layer
);

void keyboard_post_init_user(void) {
    // Enable the LED layers
    rgblight_layers = rgb_layers;
}

layer_state_t layer_state_set_user(layer_state_t state) {
    rgblight_set_layer_state(1, layer_state_cmp(state, _UNRULY));
    return state;
}

bool led_update_user(led_t led_state) {
    rgblight_set_layer_state(0, led_state.num_lock);
    return true;
}

#endif

A keyboards/contender/keymaps/default/readme.md => keyboards/contender/keymaps/default/readme.md +1 -0
@@ 0,0 1,1 @@
# The default keymap for contender

A keyboards/contender/readme.md => keyboards/contender/readme.md +26 -0
@@ 0,0 1,26 @@
# contender

![](https://i.imgur.com/JME6nwB.jpg)

A number pad for hardboot.

* Keyboard Maintainer: [sotoba](https://github.com/sotoba)
* Hardware Supported: Contender PCB
* Hardware Availability: [BOOTH: stupa-devices](https://stupa-devices.booth.pm/)

Make example for this keyboard (after setting up your build environment):

    make contender:default

Flashing example for this keyboard:

    make contender:default:flash

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).

## 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

A keyboards/contender/rules.mk => keyboards/contender/rules.mk +19 -0
@@ 0,0 1,19 @@
# MCU name
MCU = atmega32u2

# Bootloader selection
BOOTLOADER = atmel-dfu

# Build Options
#   change yes to no to disable
#
BOOTMAGIC_ENABLE = yes      # 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
# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
NKRO_ENABLE = no            # USB Nkey Rollover
BACKLIGHT_ENABLE = no       # Enable keyboard backlight functionality
RGBLIGHT_ENABLE = yes        # Enable keyboard RGB underglow
AUDIO_ENABLE = no           # Audio output