mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-02-27 01:56:43 +00:00
Initial commit of Nifty Numpad keyboard
This commit is contained in:
parent
e6187b7876
commit
8c45f66b2b
33
keyboards/nifty_numpad/config.h
Normal file
33
keyboards/nifty_numpad/config.h
Normal file
@ -0,0 +1,33 @@
|
||||
// Copyright 2023 Isaac Rex (@Isaac Rex)
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#define EECONFIG_KB_DATA_SIZE 11
|
||||
|
||||
// Setup for RGB Matrix
|
||||
#define RGB_MATRIX_LED_COUNT 33
|
||||
#define WS2812_DI_PIN GP19
|
||||
|
||||
// RGB Matrix Enabled Effects
|
||||
#define ENABLE_RGB_MATRIX_BAND_PINWHEEL_SAT
|
||||
#define ENABLE_RGB_MATRIX_PIXEL_FLOW
|
||||
#define ENABLE_RGB_MATRIX_CYCLE_ALL
|
||||
#define ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
|
||||
#define ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN
|
||||
#define ENABLE_RGB_MATRIX_BREATHING
|
||||
#define ENABLE_RGB_MATRIX_SOLID_REACTIVE
|
||||
#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE
|
||||
#define ENABLE_RGB_MATRIX_DIGITAL_RAIN
|
||||
|
||||
// RGB Matrix Parameters
|
||||
#define RGB_MATRIX_DEFAULT_MODE RGB_MATRIX_BREATHING // Sets the default mode, if none has been set
|
||||
#define RGB_MATRIX_DEFAULT_SPD 127 // Sets the default animation speed, if none has been set
|
||||
#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 255
|
||||
|
||||
#define RGB_MATRIX_DEFAULT_HUE 0 // Sets the default hue value, if none has been set
|
||||
#define RGB_MATRIX_DEFAULT_SAT 0 // Sets the default saturation value, if none has been set
|
||||
#define RGB_MATRIX_DEFAULT_VAL RGB_MATRIX_MAXIMUM_BRIGHTNESS // Sets the default brightness value, if none has been set
|
||||
|
||||
#define RGB_MATRIX_FRAMEBUFFER_EFFECTS
|
||||
#define RGB_MATRIX_KEYPRESSES
|
65
keyboards/nifty_numpad/info.json
Normal file
65
keyboards/nifty_numpad/info.json
Normal file
@ -0,0 +1,65 @@
|
||||
{
|
||||
"manufacturer": "Isaac Rex",
|
||||
"keyboard_name": "nifty_numpad",
|
||||
"maintainer": "Isaac Rex",
|
||||
"bootloader": "rp2040",
|
||||
"diode_direction": "ROW2COL",
|
||||
"features": {
|
||||
"bootmagic": true,
|
||||
"command": false,
|
||||
"console": false,
|
||||
"extrakey": true,
|
||||
"mousekey": true,
|
||||
"nkro": true
|
||||
},
|
||||
"matrix_pins": {
|
||||
"cols": ["GP17", "GP18", "GP15", "GP13", "GP14", "GP12"],
|
||||
"rows": ["GP20", "GP21", "GP22", "GP23", "GP24", "GP25"]
|
||||
},
|
||||
"processor": "RP2040",
|
||||
"url": "",
|
||||
"usb": {
|
||||
"device_version": "1.0.0",
|
||||
"pid": "0x0000",
|
||||
"vid": "0xFEED"
|
||||
},
|
||||
"layouts": {
|
||||
"LAYOUT_numpad_6x6": {
|
||||
"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": [0, 4], "x": 4, "y": 0},
|
||||
{"matrix": [0, 5], "x": 5, "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": [1, 4], "x": 4, "y": 1},
|
||||
{"matrix": [1, 5], "x": 5, "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": [2, 4], "x": 4, "y": 2},
|
||||
{"matrix": [2, 5], "x": 5, "y": 2, "h": 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},
|
||||
{"matrix": [3, 4], "x": 4, "y": 3},
|
||||
{"matrix": [4, 0], "x": 0, "y": 4},
|
||||
{"matrix": [4, 1], "x": 1, "y": 4},
|
||||
{"matrix": [4, 2], "x": 2, "y": 4},
|
||||
{"matrix": [4, 3], "x": 3, "y": 4},
|
||||
{"matrix": [4, 4], "x": 4, "y": 4},
|
||||
{"matrix": [4, 5], "x": 5, "y": 4, "h": 2},
|
||||
{"matrix": [5, 0], "x": 0, "y": 5},
|
||||
{"matrix": [5, 1], "x": 1, "y": 5},
|
||||
{"matrix": [5, 3], "x": 3, "y": 5, "w": 2},
|
||||
{"matrix": [5, 4], "x": 4, "y": 5}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
276
keyboards/nifty_numpad/keymaps/default/keymap.c
Normal file
276
keyboards/nifty_numpad/keymaps/default/keymap.c
Normal file
@ -0,0 +1,276 @@
|
||||
// Copyright 2021 QMK / NachoxMacho
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include QMK_KEYBOARD_H
|
||||
#include "nifty_numpad.h"
|
||||
#include "quantum.h"
|
||||
|
||||
// Custom String Definitions
|
||||
#define STR_EDIT_GEN "emg"
|
||||
#define STR_EDIT_PLACE "emp"
|
||||
#define STR_EDIT_ETCH "eme"
|
||||
#define STR_EDIT_SHAPE "ems"
|
||||
#define STR_ROUTE "xx"
|
||||
#define STR_SLIDE "dd"
|
||||
#define STR_VIA "vv"
|
||||
#define STR_MEASURE "me"
|
||||
#define STR_SHOW "sh"
|
||||
#define STR_UPDATE_SHAPES "sup"
|
||||
#define STR_ROTATE "rr"
|
||||
#define STR_MIRROR "ff"
|
||||
#define STR_PAM "pam"
|
||||
#define STR_MOVE "mm"
|
||||
|
||||
// Layer Defines
|
||||
#define _LAYER_BL 0
|
||||
#define _LAYER_CAD 1
|
||||
|
||||
#define _LAYER_CAD_LED_INDEX 8
|
||||
|
||||
// Tap Dance Declarations
|
||||
enum {
|
||||
TD_NUM_TOGGLE = 0,
|
||||
TD_EDIT_GEN_TOGGLE,
|
||||
TD_M1,
|
||||
TD_M2,
|
||||
TD_M3,
|
||||
TD_M4,
|
||||
TD_M5,
|
||||
TD_M6,
|
||||
TD_M7,
|
||||
TD_M8,
|
||||
TD_M9,
|
||||
TD_M10,
|
||||
TD_M11,
|
||||
TD_M12,
|
||||
};
|
||||
|
||||
// TD function for 1 tap, toggle layer; 2 taps, press numlock
|
||||
void tap_dance_num_toggle(tap_dance_state_t *state, void *user_data){
|
||||
switch(state->count){
|
||||
case 1:
|
||||
layer_invert(_LAYER_CAD);
|
||||
break;
|
||||
case 2:
|
||||
tap_code16(KC_NUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Tap Dance Definitions
|
||||
tap_dance_action_t tap_dance_actions[] = {
|
||||
[TD_NUM_TOGGLE] = ACTION_TAP_DANCE_FN(tap_dance_num_toggle),
|
||||
|
||||
[TD_M1] = ACTION_TAP_DANCE_DOUBLE(KC_F13, LCTL(KC_F13)),
|
||||
[TD_M2] = ACTION_TAP_DANCE_DOUBLE(KC_F14, LCTL(KC_F14)),
|
||||
[TD_M3] = ACTION_TAP_DANCE_DOUBLE(KC_F15, LCTL(KC_F15)),
|
||||
[TD_M4] = ACTION_TAP_DANCE_DOUBLE(KC_F16, LCTL(KC_F16)),
|
||||
[TD_M5] = ACTION_TAP_DANCE_DOUBLE(KC_F17, LCTL(KC_F17)),
|
||||
[TD_M6] = ACTION_TAP_DANCE_DOUBLE(KC_F18, LCTL(KC_F18)),
|
||||
[TD_M7] = ACTION_TAP_DANCE_DOUBLE(KC_F19, LCTL(KC_F19)),
|
||||
[TD_M8] = ACTION_TAP_DANCE_DOUBLE(KC_F20, LCTL(KC_F20)),
|
||||
[TD_M9] = ACTION_TAP_DANCE_DOUBLE(KC_F21, LCTL(KC_F21)),
|
||||
[TD_M10] = ACTION_TAP_DANCE_DOUBLE(KC_F22, LCTL(KC_F22)),
|
||||
[TD_M11] = ACTION_TAP_DANCE_DOUBLE(KC_F23, LCTL(KC_F23)),
|
||||
[TD_M12] = ACTION_TAP_DANCE_DOUBLE(KC_F24, LCTL(KC_F24))
|
||||
};
|
||||
|
||||
// Setup LED map
|
||||
led_config_t g_led_config = { {
|
||||
// Key Matrix to LED Index
|
||||
{ 0, 1, 2, 3, 4, 5 },
|
||||
{ 6, 7, 8, 9, 10, 11 },
|
||||
{ 12, 13, 14, 15, 16, 17 },
|
||||
{ 18, 19, 20, 21, 22, NO_LED },
|
||||
{ 23, 24, 25, 26, 27, 28 },
|
||||
{ 29, 30, 31, NO_LED, 32, NO_LED }
|
||||
}, {
|
||||
// LED Index to Physical Position
|
||||
{ 0, 0}, { 43, 0}, { 96, 0}, {139, 0}, {181, 0}, {224, 0},
|
||||
{ 0, 17}, { 43, 17}, { 96, 17}, {139, 17}, {181, 17}, {224, 17},
|
||||
{ 0, 29}, { 43, 29}, { 96, 29}, {139, 29}, {181, 29}, {224, 35},
|
||||
{ 0, 41}, { 43, 41}, { 96, 41}, {139, 41}, {181, 41}, { 0, 52},
|
||||
{ 43, 52}, { 96, 52}, {139, 52}, {181, 52}, {224, 58}, { 0, 64},
|
||||
{ 43, 64}, {117, 64}, {181, 64}
|
||||
}, {
|
||||
// LED Index to Flag
|
||||
LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT,
|
||||
LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT,
|
||||
LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT,
|
||||
LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT,
|
||||
LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT,
|
||||
LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT
|
||||
} };
|
||||
|
||||
// Setup keymap
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/*
|
||||
* ┌───┬───┐ ┌───┬───┬───┬───┐
|
||||
* │F13│F19│ │F1 │F2 │F3 │F4 │
|
||||
* └───┴───┘ └───┴───┴───┴───┘
|
||||
* ┌───┬───┐ ┌───┬───┬───┬───┐
|
||||
* │F14│F20│ │Num│ / │ * │ - │
|
||||
* ├───┼───┤ ├───┼───┼───┼───┤
|
||||
* │F15│F21│ │ 7 │ 8 │ 9 │ │
|
||||
* ├───┼───┤ ├───┼───┼───┤ + │
|
||||
* │F16│F22│ │ 4 │ 5 │ 6 │ │
|
||||
* ├───┼───┤ ├───┼───┼───┼───┤
|
||||
* │F17│F23│ │ 1 │ 2 │ 3 │ │
|
||||
* ├───┼───│ ├───┴───┼───┤Ent│
|
||||
* │F18│F24│ │ 0 │ . │ │
|
||||
* └───┴───┘ └───────┴───┴───┘
|
||||
*/
|
||||
[_LAYER_BL] = LAYOUT_numpad_6x6(
|
||||
TD(TD_M1), TD(TD_M12), LT(_LAYER_RGB, KC_F1), KC_F2, KC_F3, KC_F4,
|
||||
TD(TD_M2), TD(TD_M11), TD(TD_NUM_TOGGLE), KC_PSLS, KC_PAST, KC_PMNS,
|
||||
TD(TD_M3), TD(TD_M10), KC_P7, KC_P8, KC_P9, KC_PPLS,
|
||||
TD(TD_M4), TD(TD_M9), KC_P4, KC_P5, KC_P6,
|
||||
TD(TD_M5), TD(TD_M8), KC_P1, KC_P2, KC_P3, KC_PENT,
|
||||
TD(TD_M6), TD(TD_M7), KC_P0, KC_PDOT
|
||||
),
|
||||
|
||||
/*
|
||||
* ┌───┬───┐ ┌───┬───┬───┬───┐
|
||||
* │F13│F19│ │F1 │F2 │F3 │F4 │
|
||||
* └───┴───┘ └───┴───┴───┴───┘
|
||||
* ┌───┬───┐ ┌───┬───┬───┬───┐
|
||||
* │F14│F20│ │Num│ / │ * │ - │
|
||||
* ├───┼───┤ ├───┼───┼───┼───┤
|
||||
* │F15│F21│ │ 7 │ 8 │ 9 │ │
|
||||
* ├───┼───┤ ├───┼───┼───┤ + │
|
||||
* │F16│F22│ │ 4 │ 5 │ 6 │ │
|
||||
* ├───┼───┤ ├───┼───┼───┼───┤
|
||||
* │F17│F23│ │ 1 │ 2 │ 3 │ │
|
||||
* ├───┼───│ ├───┴───┼───┤Ent│
|
||||
* │F18│F24│ │ 0 │ . │ │
|
||||
* └───┴───┘ └───────┴───┴───┘
|
||||
*/
|
||||
[_LAYER_CAD] = LAYOUT_numpad_6x6(
|
||||
_______, _______, EDIT_GEN, EDIT_PLACE, EDIT_ETCH, EDIT_SHAPE,
|
||||
_______, _______, TD(TD_NUM_TOGGLE), _______, _______, _______,
|
||||
_______, _______, ROUTE, SLIDE, VIA, KC_F8,
|
||||
_______, _______, MEASURE, SHOW, UPDATE_SHAPES,
|
||||
_______, _______, ROTATE, MIRROR, PAM, KC_F6,
|
||||
_______, _______, MOVE, KC_F9
|
||||
),
|
||||
|
||||
/*
|
||||
* ┌───┬───┐ ┌───┬───┬───┬───┐
|
||||
* │F13│F19│ │F1 │F2 │F3 │F4 │
|
||||
* └───┴───┘ └───┴───┴───┴───┘
|
||||
* ┌───┬───┐ ┌───┬───┬───┬───┐
|
||||
* │F14│F20│ │Num│ / │ * │ - │
|
||||
* ├───┼───┤ ├───┼───┼───┼───┤
|
||||
* │F15│F21│ │ 7 │ 8 │ 9 │ │
|
||||
* ├───┼───┤ ├───┼───┼───┤ + │
|
||||
* │F16│F22│ │ 4 │ 5 │ 6 │ │
|
||||
* ├───┼───┤ ├───┼───┼───┼───┤
|
||||
* │F17│F23│ │ 1 │ 2 │ 3 │ │
|
||||
* ├───┼───│ ├───┴───┼───┤Ent│
|
||||
* │F18│F24│ │ 0 │ . │ │
|
||||
* └───┴───┘ └───────┴───┴───┘
|
||||
*/
|
||||
[_LAYER_RGB] = LAYOUT_numpad_6x6(
|
||||
_______, _______, _______, RGB_HUI, RGB_SAI, RGB_VAI,
|
||||
_______, _______, _______, RGB_HUD, RGB_SAD, RGB_VAD,
|
||||
_______, _______, _______, RGB_DEF, RGB_IEF, RGB_SPI,
|
||||
_______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, RGB_SPD,
|
||||
_______, _______, _______, _______
|
||||
)
|
||||
};
|
||||
|
||||
// Set the layer toggle key to an indication of the active layer. This is a
|
||||
// bit janky and should be done better, but I'm trying to avoid scope creep.
|
||||
bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
|
||||
if (layer_state_is(_LAYER_CAD) && !rgb_matrix_idle_mode()) {
|
||||
// Get a hue that contrasts with current hue
|
||||
uint8_t hue = rgb_matrix_get_hue() + 127;
|
||||
// Make sure saturation is high enough to distiguish between hues
|
||||
uint8_t sat = 255;
|
||||
uint8_t val = min((uint16_t) rgb_matrix_get_val() + 50, 255);
|
||||
RGB rgb = hsv_to_rgb((HSV) {hue, sat, val});
|
||||
rgb_matrix_set_color(_LAYER_CAD_LED_INDEX, rgb.r, rgb.g, rgb.b);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Process custom keycodes
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
|
||||
switch (keycode) {
|
||||
|
||||
// Custom macro strings for Cadence
|
||||
case EDIT_GEN:
|
||||
if (record->event.pressed) {
|
||||
SEND_STRING(STR_EDIT_GEN);
|
||||
}
|
||||
break;
|
||||
case EDIT_PLACE:
|
||||
if (record->event.pressed) {
|
||||
SEND_STRING(STR_EDIT_PLACE);
|
||||
}
|
||||
break;
|
||||
case EDIT_ETCH:
|
||||
if (record->event.pressed) {
|
||||
SEND_STRING(STR_EDIT_ETCH);
|
||||
}
|
||||
break;
|
||||
case EDIT_SHAPE:
|
||||
if (record->event.pressed) {
|
||||
SEND_STRING(STR_EDIT_SHAPE);
|
||||
}
|
||||
break;
|
||||
case ROUTE:
|
||||
if (record->event.pressed) {
|
||||
SEND_STRING(STR_ROUTE);
|
||||
}
|
||||
break;
|
||||
case SLIDE:
|
||||
if (record->event.pressed) {
|
||||
SEND_STRING(STR_SLIDE);
|
||||
}
|
||||
break;
|
||||
case VIA:
|
||||
if (record->event.pressed) {
|
||||
SEND_STRING(STR_VIA);
|
||||
}
|
||||
break;
|
||||
case MEASURE:
|
||||
if (record->event.pressed) {
|
||||
SEND_STRING(STR_MEASURE);
|
||||
}
|
||||
break;
|
||||
case SHOW:
|
||||
if (record->event.pressed) {
|
||||
SEND_STRING(STR_SHOW);
|
||||
}
|
||||
break;
|
||||
case UPDATE_SHAPES:
|
||||
if (record->event.pressed) {
|
||||
SEND_STRING(STR_UPDATE_SHAPES);
|
||||
}
|
||||
break;
|
||||
case ROTATE:
|
||||
if (record->event.pressed) {
|
||||
SEND_STRING(STR_ROTATE);
|
||||
}
|
||||
break;
|
||||
case MIRROR:
|
||||
if (record->event.pressed) {
|
||||
SEND_STRING(STR_MIRROR);
|
||||
}
|
||||
break;
|
||||
case PAM:
|
||||
if (record->event.pressed) {
|
||||
SEND_STRING(STR_PAM);
|
||||
}
|
||||
break;
|
||||
case MOVE:
|
||||
if (record->event.pressed) {
|
||||
SEND_STRING(STR_MOVE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
};
|
232
keyboards/nifty_numpad/nifty_numpad.c
Normal file
232
keyboards/nifty_numpad/nifty_numpad.c
Normal file
@ -0,0 +1,232 @@
|
||||
/* Copyright 2023 irex
|
||||
*
|
||||
* 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
|
||||
#include "quantum.h"
|
||||
|
||||
typedef struct {
|
||||
uint8_t mode;
|
||||
uint8_t speed;
|
||||
HSV hsv;
|
||||
} rgb_matrix_state_t;
|
||||
|
||||
typedef struct {
|
||||
rgb_matrix_state_t active_rgb_matrix;
|
||||
rgb_matrix_state_t idle_rgb_matrix;
|
||||
} kb_config_t;
|
||||
|
||||
static uint32_t idle_timer = 0;
|
||||
bool rgb_idle_mode = false;
|
||||
bool rgb_idle_edit_mode = false;
|
||||
static rgb_matrix_state_t active_rgb_matrix;
|
||||
static rgb_matrix_state_t idle_rgb_matrix;
|
||||
static kb_config_t config;
|
||||
|
||||
// Returns true if current RGB matrix mode is idle
|
||||
bool rgb_matrix_idle_mode(void){
|
||||
return rgb_idle_mode;
|
||||
}
|
||||
|
||||
// Stores the current mode, HSV, and speed of the RGB matrix into state
|
||||
void rgb_matrix_state_save(rgb_matrix_state_t* state){
|
||||
state->mode = rgb_matrix_get_mode();
|
||||
state->hsv = rgb_matrix_get_hsv();
|
||||
state->speed = rgb_matrix_get_speed();
|
||||
}
|
||||
|
||||
// Restores the mode, HSV, and speed of the RGB matrix from previous state
|
||||
void rgb_matrix_state_restore(rgb_matrix_state_t* state){
|
||||
HSV hsv = state->hsv;
|
||||
rgb_matrix_mode_noeeprom(state->mode);
|
||||
rgb_matrix_sethsv_noeeprom(hsv.h, hsv.s, hsv.v);
|
||||
rgb_matrix_set_speed_noeeprom(state->speed);
|
||||
}
|
||||
|
||||
void matrix_scan_kb(void) {
|
||||
// Check if enough time has passed since last keypress to go into idle mode
|
||||
if ( timer_elapsed32(idle_timer) > RGB_IDLE_TIMEOUT_MS && !rgb_idle_mode ) {
|
||||
rgb_matrix_state_save(&active_rgb_matrix);
|
||||
rgb_idle_mode = true;
|
||||
idle_timer = timer_read32();
|
||||
|
||||
rgb_matrix_state_restore(&idle_rgb_matrix);
|
||||
}
|
||||
|
||||
matrix_scan_user();
|
||||
};
|
||||
|
||||
|
||||
layer_state_t layer_state_set_kb(layer_state_t state) {
|
||||
// Track if the last layer was the RGB edit layer
|
||||
static bool rgb_was_on = false;
|
||||
|
||||
if (IS_LAYER_ON_STATE(state, _LAYER_RGB)) {
|
||||
rgb_was_on = true;
|
||||
}
|
||||
|
||||
// Not in RGB edit layer, but previously were
|
||||
if (!IS_LAYER_ON_STATE(state, _LAYER_RGB) && rgb_was_on) {
|
||||
rgb_was_on = false;
|
||||
if (rgb_idle_edit_mode) {
|
||||
// If we were editing the RGB idle mode, we are done now.
|
||||
// Restore to active mode
|
||||
rgb_idle_edit_mode = false;
|
||||
rgb_matrix_state_restore(&active_rgb_matrix);
|
||||
}
|
||||
// Done changing stuff, save settings in "EEPROM"
|
||||
config.active_rgb_matrix = active_rgb_matrix;
|
||||
config.idle_rgb_matrix = idle_rgb_matrix;
|
||||
eeconfig_update_kb_datablock(&config);
|
||||
}
|
||||
|
||||
return layer_state_set_user(state);
|
||||
}
|
||||
|
||||
// Process custom keycodes
|
||||
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
|
||||
|
||||
// If we were idling and a key was pressed, restore active RGB
|
||||
if (record->event.pressed) {
|
||||
idle_timer = timer_read32();
|
||||
if(rgb_idle_mode){
|
||||
rgb_matrix_state_restore(&active_rgb_matrix);
|
||||
rgb_idle_mode = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch (keycode) {
|
||||
|
||||
// Handle all the RGB settings
|
||||
case RGB_DEF:
|
||||
if (record->event.pressed) {
|
||||
// Change the RGB matrix state to active if editing idle
|
||||
if(rgb_idle_edit_mode) {
|
||||
rgb_matrix_state_restore(&active_rgb_matrix);
|
||||
rgb_idle_edit_mode = false;
|
||||
}
|
||||
rgb_matrix_step_noeeprom();
|
||||
rgb_matrix_state_save(&active_rgb_matrix);
|
||||
}
|
||||
return false;
|
||||
case RGB_IEF:
|
||||
if (record->event.pressed) {
|
||||
// Change the RGB matrix state to idle
|
||||
if(!rgb_idle_edit_mode) {
|
||||
rgb_matrix_state_restore(&idle_rgb_matrix);
|
||||
rgb_idle_edit_mode = true;
|
||||
}
|
||||
else{
|
||||
rgb_matrix_step_noeeprom();
|
||||
rgb_matrix_state_save(&idle_rgb_matrix);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
case RGB_SAI:
|
||||
if (record->event.pressed) {
|
||||
rgb_matrix_increase_sat_noeeprom();
|
||||
rgb_idle_edit_mode ? rgb_matrix_state_save(&idle_rgb_matrix) :
|
||||
rgb_matrix_state_save(&active_rgb_matrix);
|
||||
}
|
||||
return false;
|
||||
case RGB_SAD:
|
||||
if (record->event.pressed) {
|
||||
rgb_matrix_decrease_sat_noeeprom();
|
||||
rgb_idle_edit_mode ? rgb_matrix_state_save(&idle_rgb_matrix) :
|
||||
rgb_matrix_state_save(&active_rgb_matrix);
|
||||
}
|
||||
return false;
|
||||
case RGB_VAI:
|
||||
if (record->event.pressed) {
|
||||
rgb_matrix_increase_val_noeeprom();
|
||||
rgb_idle_edit_mode ? rgb_matrix_state_save(&idle_rgb_matrix) :
|
||||
rgb_matrix_state_save(&active_rgb_matrix);
|
||||
}
|
||||
return false;
|
||||
case RGB_VAD:
|
||||
if (record->event.pressed) {
|
||||
rgb_matrix_decrease_val_noeeprom();
|
||||
rgb_idle_edit_mode ? rgb_matrix_state_save(&idle_rgb_matrix) :
|
||||
rgb_matrix_state_save(&active_rgb_matrix);
|
||||
}
|
||||
return false;
|
||||
case RGB_HUI:
|
||||
if (record->event.pressed) {
|
||||
rgb_matrix_increase_hue_noeeprom();
|
||||
rgb_idle_edit_mode ? rgb_matrix_state_save(&idle_rgb_matrix) :
|
||||
rgb_matrix_state_save(&active_rgb_matrix);
|
||||
}
|
||||
return false;
|
||||
case RGB_HUD:
|
||||
if (record->event.pressed) {
|
||||
rgb_matrix_decrease_hue_noeeprom();
|
||||
rgb_idle_edit_mode ? rgb_matrix_state_save(&idle_rgb_matrix) :
|
||||
rgb_matrix_state_save(&active_rgb_matrix);
|
||||
}
|
||||
return false;
|
||||
case RGB_SPI:
|
||||
if (record->event.pressed) {
|
||||
rgb_matrix_increase_speed_noeeprom();
|
||||
rgb_idle_edit_mode ? rgb_matrix_state_save(&idle_rgb_matrix) :
|
||||
rgb_matrix_state_save(&active_rgb_matrix);
|
||||
}
|
||||
return false;
|
||||
case RGB_SPD:
|
||||
if (record->event.pressed) {
|
||||
rgb_matrix_decrease_speed_noeeprom();
|
||||
rgb_idle_edit_mode ? rgb_matrix_state_save(&idle_rgb_matrix) :
|
||||
rgb_matrix_state_save(&active_rgb_matrix);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return process_record_user(keycode, record);
|
||||
};
|
||||
|
||||
void keyboard_post_init_kb(void) {
|
||||
// Read in the RGB Matrices from before
|
||||
eeconfig_read_kb_datablock(&config);
|
||||
active_rgb_matrix = config.active_rgb_matrix;
|
||||
idle_rgb_matrix = config.idle_rgb_matrix;
|
||||
// Restore the active matrix
|
||||
rgb_matrix_state_restore(&active_rgb_matrix);
|
||||
// Start the idle timer for idle mode
|
||||
idle_timer = timer_read32();
|
||||
|
||||
keyboard_post_init_user();
|
||||
}
|
||||
|
||||
// Setup default EEPROM config values
|
||||
void eeconfig_init_kb_datablock(void){
|
||||
rgb_matrix_state_t default_active_rgb_matrix;
|
||||
rgb_matrix_state_t default_idle_rgb_matrix;
|
||||
|
||||
default_active_rgb_matrix.mode = RGB_MATRIX_GRADIENT_UP_DOWN;
|
||||
default_active_rgb_matrix.hsv = (HSV){127, 255, 100};
|
||||
default_active_rgb_matrix.speed = 127;
|
||||
|
||||
default_idle_rgb_matrix.mode = RGB_MATRIX_BREATHING;
|
||||
default_idle_rgb_matrix.hsv = (HSV){127, 255, 100};
|
||||
default_idle_rgb_matrix.speed = 127;
|
||||
|
||||
config.active_rgb_matrix = default_active_rgb_matrix;
|
||||
config.idle_rgb_matrix = default_idle_rgb_matrix;
|
||||
|
||||
eeconfig_update_kb_datablock(&config);
|
||||
|
||||
#if (EECONFIG_USER_DATA_SIZE) > 0
|
||||
eeconfig_init_user_datablock();
|
||||
#endif
|
||||
}
|
99
keyboards/nifty_numpad/nifty_numpad.h
Normal file
99
keyboards/nifty_numpad/nifty_numpad.h
Normal file
@ -0,0 +1,99 @@
|
||||
/* Copyright 2023 irex
|
||||
*
|
||||
* 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"
|
||||
|
||||
// min/max macros
|
||||
#define max(a,b) \
|
||||
({ \
|
||||
__typeof__ (a) _a = (a); \
|
||||
__typeof__ (b) _b = (b); \
|
||||
_a > _b ? _a : _b; \
|
||||
})
|
||||
|
||||
#define min(a,b) \
|
||||
({ \
|
||||
__typeof__ (a) _a = (a); \
|
||||
__typeof__ (b) _b = (b); \
|
||||
_a < _b ? _a : _b; \
|
||||
})
|
||||
|
||||
// Custom kycode declarations
|
||||
enum custom_keycodes {
|
||||
EDIT_GEN = SAFE_RANGE,
|
||||
EDIT_PLACE,
|
||||
EDIT_ETCH,
|
||||
EDIT_SHAPE,
|
||||
ROUTE,
|
||||
SLIDE,
|
||||
VIA,
|
||||
MEASURE,
|
||||
SHOW,
|
||||
UPDATE_SHAPES,
|
||||
ROTATE,
|
||||
MIRROR,
|
||||
PAM,
|
||||
MOVE,
|
||||
RGB_DEF,
|
||||
RGB_IEF
|
||||
};
|
||||
|
||||
// Layer Defines
|
||||
#define _LAYER_RGB 15
|
||||
|
||||
// Custom Setup
|
||||
#define TAPPING_TERM 200
|
||||
#define RGB_IDLE_TIMEOUT_MS (5*1000)
|
||||
|
||||
/*
|
||||
* ┌───┬───┐ ┌───┬───┬───┬───┐
|
||||
* │F13│F19│ │F1 │F2 │F3 │F4 │
|
||||
* └───┴───┘ └───┴───┴───┴───┘
|
||||
* ┌───┬───┐ ┌───┬───┬───┬───┐
|
||||
* │F14│F20│ │Num│ / │ * │ - │
|
||||
* ├───┼───┤ ├───┼───┼───┼───┤
|
||||
* │F15│F21│ │ 7 │ 8 │ 9 │ │
|
||||
* ├───┼───┤ ├───┼───┼───┤ + │
|
||||
* │F16│F22│ │ 4 │ 5 │ 6 │ │
|
||||
* ├───┼───┤ ├───┼───┼───┼───┤
|
||||
* │F17│F23│ │ 1 │ 2 │ 3 │ │
|
||||
* ├───┼───│ ├───┴───┼───┤Ent│
|
||||
* │F18│F24│ │ 0 │ . │ │
|
||||
* └───┴───┘ └───────┴───┴───┘
|
||||
*/
|
||||
#define XXX KC_NO
|
||||
#define LAYOUT_numpad_6x6( \
|
||||
K00, K01, K02, K03, K04, K05, \
|
||||
K10, K11, K12, K13, K14, K15, \
|
||||
\
|
||||
K20, K21, K22, K23, K24, K25, \
|
||||
K30, K31, K32, K33, K34, \
|
||||
K40, K41, K42, K43, K44, K45, \
|
||||
K50, K51, K52, K54 \
|
||||
) { \
|
||||
{ K00, K01, K02, K03, K04, K05}, \
|
||||
{ K10, K11, K12, K13, K14, K15}, \
|
||||
\
|
||||
{ K20, K21, K22, K23, K24, K25}, \
|
||||
{ K30, K31, K32, K33, K34, XXX}, \
|
||||
{ K40, K41, K42, K43, K44, K45}, \
|
||||
{ K50, K51, K52, XXX, K54, XXX} \
|
||||
}
|
||||
|
||||
// Functions exposed by nifty_numpad.c
|
||||
bool rgb_matrix_idle_mode(void);
|
27
keyboards/nifty_numpad/readme.md
Normal file
27
keyboards/nifty_numpad/readme.md
Normal file
@ -0,0 +1,27 @@
|
||||
# nifty_numpad
|
||||
|
||||

|
||||
|
||||
*A short description of the keyboard/project*
|
||||
|
||||
* Keyboard Maintainer: [Isaac Rex](https://github.com/Isaac Rex)
|
||||
* 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 nifty_numpad:default
|
||||
|
||||
Flashing example for this keyboard:
|
||||
|
||||
make nifty_numpad: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 `QK_BOOT` if it is available
|
4
keyboards/nifty_numpad/rules.mk
Normal file
4
keyboards/nifty_numpad/rules.mk
Normal file
@ -0,0 +1,4 @@
|
||||
TAP_DANCE_ENABLE=yes
|
||||
RGB_MATRIX_ENABLE=yes
|
||||
RGB_MATRIX_DRIVER=WS2812
|
||||
WS2812_DRIVER=vendor
|
Loading…
Reference in New Issue
Block a user