Browse Source

macrocat firmware 0.0.1

pull/17490/head
Dongruixuan Li 1 year ago
parent
commit
9322b3aa64
No known key found for this signature in database GPG Key ID: 84CED2EE655B596F
7 changed files with 223 additions and 0 deletions
  1. +16
    -0
      keyboards/macrocat/config.h
  2. +48
    -0
      keyboards/macrocat/info.json
  3. +31
    -0
      keyboards/macrocat/keymaps/default/keymap.c
  4. +82
    -0
      keyboards/macrocat/macrocat.c
  5. +6
    -0
      keyboards/macrocat/macrocat.h
  6. +27
    -0
      keyboards/macrocat/readme.md
  7. +13
    -0
      keyboards/macrocat/rules.mk

+ 16
- 0
keyboards/macrocat/config.h View File

@ -0,0 +1,16 @@
// Copyright 2022 catmunch (@catmunch)
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "config_common.h"
/* rotary encoder */
#define ENCODERS_PAD_A { D3 }
#define ENCODERS_PAD_B { D2 }
#define ENCODER_SWITCH B7
#define VENDOR_ID 0x2022
#define PRODUCT_ID 0x8086
#define MANUFACTURER CatMunch
#define PRODUCT MacroCat Keyboard

+ 48
- 0
keyboards/macrocat/info.json View File

@ -0,0 +1,48 @@
{
"manufacturer": "Catmunch",
"keyboard_name": "MacroCat Keyboard",
"maintainer": "Catmunch",
"bootloader": "atmel-dfu",
"diode_direction": "COL2ROW",
"features": {
"bootmagic": true,
"command": false,
"console": false,
"extrakey": true,
"mousekey": true,
"nkro": true
},
"matrix_pins": {
"cols": ["B5", "B6", "C6", "C7"],
"rows": ["D4", "D6", "D7", "B4"]
},
"processor": "atmega32u4",
"url": "https://github.com/catmunch/macrocat",
"usb": {
"device_version": "0.0.1",
"pid": "0x8086",
"vid": "0x2022"
},
"layouts": {
"LAYOUT_numpad_4x4": {
"layout": [
{ "matrix": [0, 0], "x": 0, "y": 0 },
{ "matrix": [0, 1], "x": 1, "y": 0 },
{ "matrix": [0, 2], "x": 2, "y": 0 },
{ "matrix": [0, 3], "x": 3, "y": 0 },
{ "matrix": [1, 0], "x": 0, "y": 1 },
{ "matrix": [1, 1], "x": 1, "y": 1 },
{ "matrix": [1, 2], "x": 2, "y": 1 },
{ "matrix": [1, 3], "x": 3, "y": 1 },
{ "matrix": [2, 0], "x": 0, "y": 2 },
{ "matrix": [2, 1], "x": 1, "y": 2 },
{ "matrix": [2, 2], "x": 2, "y": 2 },
{ "matrix": [2, 3], "x": 3, "y": 2 },
{ "matrix": [3, 0], "x": 0, "y": 3 },
{ "matrix": [3, 1], "x": 1, "y": 3 },
{ "matrix": [3, 2], "x": 2, "y": 3 },
{ "matrix": [3, 3], "x": 3, "y": 3 }
]
}
}
}

+ 31
- 0
keyboards/macrocat/keymaps/default/keymap.c View File

@ -0,0 +1,31 @@
// Copyright 2022 catmunch (@catmunch)
// SPDX-License-Identifier: GPL-2.0-or-later
#include QMK_KEYBOARD_H
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = {
{KC_PPLS, KC_P9, KC_P8, KC_P7},
{KC_PMNS, KC_P6, KC_P5, KC_P4},
{KC_PDOT, KC_P3, KC_P2, KC_P1},
{KC_PENT, KC_SPACE, KC_P0, MO(1)}
},
[1] = {
{KC_PAST, KC_NO, KC_NO, KC_NO},
{KC_PSLS, LSFT(KC_9), KC_UP, LSFT(KC_0)},
{KC_COMM, KC_LEFT, KC_DOWN,KC_RIGHT},
{KC_TAB, KC_SPACE, KC_P0, KC_TRNS}
},
[2] = {
{KC_NO, KC_NO, KC_NO, KC_NO},
{KC_NO, KC_NO, KC_NO, KC_NO},
{KC_NO, KC_NO, KC_NO, KC_NO},
{KC_NO, KC_NO, KC_NO, KC_NO}
},
[3] = {
{KC_NO, KC_NO, KC_NO, KC_NO},
{KC_NO, KC_NO, KC_NO, KC_NO},
{KC_NO, KC_NO, KC_NO, KC_NO},
{KC_NO, KC_NO, KC_NO, KC_NO}
}
};

+ 82
- 0
keyboards/macrocat/macrocat.c View File

@ -0,0 +1,82 @@
// Copyright 2022 catmunch (@catmunch)
// SPDX-License-Identifier: GPL-2.0-or-later
#include "macrocat.h"
static bool encoder_pressed = 0;
static bool encoder_switched_layer = 0;
static uint32_t encoder_last_release_time = 0;
static uint32_t encoder_press_combo = 0;
static uint8_t current_layer = 0;
void encoder_single_click(void) {
tap_code(KC_MPLY);
}
void encoder_double_click(void) {
tap_code(KC_MNXT);
}
void encoder_triple_click(void) {
tap_code(KC_MPRV);
}
void matrix_init_kb() {
setPinInputHigh(ENCODER_SWITCH);
}
void matrix_scan_kb() {
matrix_scan_user();
if (readPin(ENCODER_SWITCH)) {
if (encoder_pressed) { // release switch
encoder_pressed = 0;
encoder_press_combo += 1;
encoder_last_release_time = timer_read32();
}
if (encoder_press_combo && timer_elapsed(encoder_last_release_time) > 300) {
// combo timeout
if (encoder_switched_layer) { // switch layer
encoder_switched_layer = 0;
} else { // click
switch (encoder_press_combo) {
case 1:
encoder_single_click();
break;
case 2:
encoder_double_click();
break;
default:
encoder_triple_click();
}
}
encoder_press_combo = 0;
encoder_last_release_time = 0;
}
} else {
if (!encoder_pressed) { // press switch
encoder_pressed = 1;
}
}
}
bool encoder_update_kb(uint8_t index, bool clockwise) {
if (!encoder_update_user(index, clockwise)) {
return false;
}
if (clockwise) {
if (encoder_pressed) {
if (current_layer < 3) {
current_layer += 1;
layer_move(current_layer);
}
encoder_switched_layer = 1;
} else {
tap_code(KC_VOLU);
}
} else {
if (encoder_pressed) {
if (current_layer > 0) {
current_layer -= 1;
layer_move(current_layer);
}
encoder_switched_layer = 1;
} else {
tap_code(KC_VOLD);
}
}
return false;
}

+ 6
- 0
keyboards/macrocat/macrocat.h View File

@ -0,0 +1,6 @@
// Copyright 2022 catmunch (@catmunch)
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "quantum.h"

+ 27
- 0
keyboards/macrocat/readme.md View File

@ -0,0 +1,27 @@
# macrocat
![macrocat](imgur.com image replace me!)
*A short description of the keyboard/project*
* Keyboard Maintainer: [catmunch](https://github.com/catmunch)
* Hardware Supported: *The PCBs, controllers supported*
* Hardware Availability: *Links to where you can find this hardware*
Make example for this keyboard (after setting up your build environment):
make macrocat:default
Flashing example for this keyboard:
make macrocat: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 3 ways:
* **Bootmagic reset**: Hold down the key at (0,0) in the matrix (usually the top left key or Escape) and plug in the keyboard
* **Physical reset button**: Briefly press the button on the back of the PCB - some may have pads you must short instead
* **Keycode in layout**: Press the key mapped to `RESET` if it is available

+ 13
- 0
keyboards/macrocat/rules.mk View File

@ -0,0 +1,13 @@
# MCU name
MCU = atmega32u4
# Bootloader selection
BOOTLOADER = qmk-dfu
# Build Options
# change yes to no to disable
#
ENCODER_ENABLE = yes
VIA_ENABLE = yes
RAW_ENABLE = yes
DYNAMIC_KEYMAP_ENABLE = yes

Loading…
Cancel
Save