1
0
Fork 0

[Keyboard] Update Tetris (#5513)

* Update Tetris

Add a fake row to config the encoder's keycode easily.

* Delete rules.mk

* Update keyboards/tetris/readme.md

Co-Authored-By: YCF <65446+YCF@users.noreply.github.com>

* Update config.h

add #define RGBLIGHT_SLEEP
This commit is contained in:
YouCanFly 2019-04-18 17:37:26 -05:00 committed by Drashna Jaelre
parent a58c66df88
commit 9e3b38425f
8 changed files with 184 additions and 826 deletions

22
keyboards/tetris/config.h Normal file → Executable file
View file

@ -10,17 +10,12 @@
#define PRODUCT Tetris
#define DESCRIPTION Planck mit
#define QMK_ESC_OUTPUT B0
#define QMK_ESC_INPUT D7
#define QMK_LED B7
#define QMK_SPEAKER B5
/* key matrix size */
#define MATRIX_ROWS 4
#define MATRIX_ROWS 5
#define MATRIX_COLS 12
/* key matrix pins */
#define MATRIX_ROW_PINS { B3, B2, B1, B0 }
#define MATRIX_ROW_PINS { B3, B2, B1, B0, E6 }
#define MATRIX_COL_PINS { D7, B4, B6, C6, C7, F6, F7, D4, D2, D3, D5, D6 }
#define UNUSED_PINS
@ -39,19 +34,22 @@
#define NO_ACTION_MACRO
#define NO_ACTION_FUNCTION
#define TAPPING_TERM 200
#ifdef AUDIO_ENABLE
#define B5_AUDIO
#define STARTUP_SONG SONG(ONE_UP_SOUND)
#define NO_MUSIC_MODE
#endif
#if RGBLIGHT_ENABLE
#define NUMBER_OF_ENCODERS 2
#define ENCODERS_PAD_A { D1,F1 }
#define ENCODERS_PAD_B { D0,F0 }
#define RGB_DI_PIN F5
#define RGBLIGHT_ANIMATIONS
#define RGBLIGHT_SLEEP
#define RGBLED_NUM 47
#define RGBLIGHT_HUE_STEP 8
#define RGBLIGHT_SAT_STEP 8
#define RGBLIGHT_VAL_STEP 8
#define RGBLIGHT_EFFECT_KNIGHT_LED_NUM 12
//#define RGBLIGHT_LIMIT_VAL 128
#endif

View file

@ -3,10 +3,10 @@
"url": "",
"maintainer": "qmk",
"width": 12,
"height": 4,
"height": 5,
"layouts": {
"LAYOUT_planck_mit": {
"layout": [{"x":0, "y":0}, {"x":1, "y":0}, {"x":2, "y":0}, {"x":3, "y":0}, {"x":4, "y":0}, {"x":5, "y":0}, {"x":6, "y":0}, {"x":7, "y":0}, {"x":8, "y":0}, {"x":9, "y":0}, {"x":10, "y":0}, {"x":11, "y":0}, {"x":0, "y":1}, {"x":1, "y":1}, {"x":2, "y":1}, {"x":3, "y":1}, {"x":4, "y":1}, {"x":5, "y":1}, {"x":6, "y":1}, {"x":7, "y":1}, {"x":8, "y":1}, {"x":9, "y":1}, {"x":10, "y":1}, {"x":11, "y":1}, {"x":0, "y":2}, {"x":1, "y":2}, {"x":2, "y":2}, {"x":3, "y":2}, {"x":4, "y":2}, {"x":5, "y":2}, {"x":6, "y":2}, {"x":7, "y":2}, {"x":8, "y":2}, {"x":9, "y":2}, {"x":10, "y":2}, {"x":11, "y":2}, {"x":0, "y":3}, {"x":1, "y":3}, {"x":2, "y":3}, {"x":3, "y":3}, {"x":4, "y":3}, {"x":5, "y":3, "w":2}, {"x":7, "y":3}, {"x":8, "y":3}, {"x":9, "y":3}, {"x":10, "y":3}, {"x":11, "y":3}]
"layout": [{"x":0, "y":0}, {"x":1, "y":0}, {"x":2, "y":0}, {"x":3, "y":0}, {"x":4, "y":0}, {"x":5, "y":0}, {"x":6, "y":0}, {"x":7, "y":0}, {"x":8, "y":0}, {"x":9, "y":0}, {"x":10, "y":0}, {"x":11, "y":0}, {"x":0, "y":1}, {"x":1, "y":1}, {"x":2, "y":1}, {"x":3, "y":1}, {"x":4, "y":1}, {"x":5, "y":1}, {"x":6, "y":1}, {"x":7, "y":1}, {"x":8, "y":1}, {"x":9, "y":1}, {"x":10, "y":1}, {"x":11, "y":1}, {"x":0, "y":2}, {"x":1, "y":2}, {"x":2, "y":2}, {"x":3, "y":2}, {"x":4, "y":2}, {"x":5, "y":2}, {"x":6, "y":2}, {"x":7, "y":2}, {"x":8, "y":2}, {"x":9, "y":2}, {"x":10, "y":2}, {"x":11, "y":2}, {"x":0, "y":3}, {"x":1, "y":3}, {"x":2, "y":3}, {"x":3, "y":3}, {"x":4, "y":3}, {"x":5, "y":3, "w":2}, {"x":7, "y":3}, {"x":8, "y":3}, {"x":9, "y":3}, {"x":10, "y":3}, {"x":11, "y":3}, {"x":0, "y":4}, {"x":1, "y":4}, {"x":10, "y":4}, {"x":11, "y":4}]
}
}
}

930
keyboards/tetris/keymaps/default/keymap.c Normal file → Executable file
View file

@ -1,828 +1,186 @@
#include QMK_KEYBOARD_H
#ifdef AUDIO_ENABLE
float tone_caps[][2] = SONG( CAPS_LOCK_ON_SOUND );
float tone_taps[][2] = SONG( E__NOTE( _A6 ) );
#endif
#define _BASE 0
#define _CODE 1
#define _NAVI 2
#define _FUNC 3
#define _SYMB 4
#define _NUMB 5
#define _MARO 6
#define _RGB 7
#define _ADJUST 8
#define _GAME 9
/* RGB colors */
#define RGB_Layer_1_Base_Color 0, 128, 0
#define RGB_Layer_2_Base_Color 0,0,0
#define RGB_Layer_3_Base_Color 0,0,0
#define RGB_Layer_4_Base_Color 0,0,0
#define RGB_Layer_5_Base_Color 0,0,0
#define RGB_Layer_6_Base_Color 64, 0, 64
#define RGB_Layer_7_Base_Color 0, 0,0
#define RGB_Layer_8_Base_Color 0,0,0
#define RGB_Layer_9_Base_Color 0,0,0
#define RGB_Caps_Color 6,50,50
#define RGB_TAP_On_Color 0,128,0
#define RGB_TAP_Off_Color 128,0,0
#define RGB_TAP_Base_Color 0,0,0
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT_planck_mit(
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_ENT,
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_UP,
KC_LCTL, KC_LGUI, KC_LALT, KC_LBRC, KC_MINS, LT(1, KC_SPC), KC_EQL, KC_RBRC, KC_LEFT, KC_DOWN, KC_RGHT,
KC_VOLD, KC_VOLU, KC_PGDN, KC_PGUP),
[1] = LAYOUT_planck_mit(
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_BSPC, KC_TRNS, KC_DEL, KC_TRNS, KC_TRNS, KC_BSLS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
};
extern rgblight_config_t rgblight_config;
bool NUMLAY_STATUS = false;
int RGB_LAYER0_mode = 6;
bool RGB_TAP_STATE = false;
static uint8_t current_layer = 0;
static bool has_layer_changed = true;
static bool save_rgbmode = true;
static bool caps = false;
/* Tap Dance function */
void dance_cln_finished( qk_tap_dance_state_t* state, void* user_data )
{
if ( state->count == 1 )
{
register_code( KC_LSFT );
} else {
layer_on( _SYMB );
#ifdef AUDIO_ENABLE
PLAY_SONG( tone_taps );
#endif
}
}
void dance_cln_reset( qk_tap_dance_state_t* state, void* user_data )
{
if ( state->count == 1 )
{
unregister_code( KC_LSFT );
}else {
uint8_t layer = biton32( layer_state );
if ( layer == _SYMB )
{
layer_off( _SYMB );
rgblight_mode( RGB_LAYER0_mode );
}
}
}
enum my_keycodes {
RGB_TAP = SAFE_RANGE,
KC_00
};
/* Tap Dance Declarations */
enum {
TD_Mute_Next = 0,
TD_SFT,
TD_LBRC,
TD_RBRC
};
/* Tap Dance Definitions */
qk_tap_dance_action_t tap_dance_actions[] = {
[TD_Mute_Next] = ACTION_TAP_DANCE_DOUBLE( KC_MUTE, KC_MNXT )
,[TD_SFT] = ACTION_TAP_DANCE_FN_ADVANCED( NULL, dance_cln_finished, dance_cln_reset )
,[TD_LBRC] = ACTION_TAP_DANCE_DOUBLE( KC_LBRC, KC_LCBR )
,[TD_RBRC] = ACTION_TAP_DANCE_DOUBLE( KC_RBRC, KC_RCBR )
};
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* BASE - QWERTY
* ,-----------------------------------------------------------------------------------.
* | Tab | Q | W | E | R | T | Y | U | I | O | P | BS |
* |------+------+------+------+------+-------------+------+------+------+------+------|
* shift + Esc = ~ --> | Esc | A | S | D | F | G | H | J | K | L | ; | Enter| <-- shift + Enter = "
* |------+------+------+------+------+------|------+------+------+------+------+------|
* | Shift| Z | X | C | V | B | N | M | , | . | / | Mute |
* |------+------+------+------+------+------+------+------+------+------+------+------| <-- tap: 1.Mute 2.Next
* | Ctrl | GUI | Alt | [ | - | Space | = | ] | Fx | \ | Del |
* `-----------------------------------------------------------------------------------'
*/
[_BASE] = LAYOUT_planck_mit(
LT( _ADJUST,KC_TAB), KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
LT( _NUMB,KC_ESC), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, LT( _RGB, KC_L ), KC_SCLN, KC_ENT,
TD( TD_SFT ), KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_UP, TD( TD_Mute_Next ),
KC_LCTL, KC_LGUI, KC_LALT, TD( TD_LBRC ), LT( _NAVI, KC_MINS ), LT( _CODE, KC_SPC ), LT( _FUNC, KC_EQL ), TD( TD_RBRC ), KC_LEFT, KC_DOWN, KC_RGHT ),
/* Code
* ,-----------------------------------------------------------------------------------.
* | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp |
* |------+------+------+------+------+-------------+------+------+------+------+------|
* | ` | < | [ | { | ( | & | Left | Down | Up | Down | ; | ' |
* |------+------+------+------+------+------|------+------+------+------+------+------|
* | | > | ] | } | ) | | | | | , | . | / | Play |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | [ | BkSp | ======= | Del | ] | | \ | |
* `-----------------------------------------------------------------------------------'
*/
[_CODE] = LAYOUT_planck_mit( /* 1 - Code */
_______, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______,
KC_GRV, KC_LABK, KC_LBRC, KC_LCBR, KC_LPRN, KC_AMPR, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, _______, KC_QUOT,
_______, KC_RABK, KC_RBRC, KC_RCBR, KC_RPRN, KC_PIPE, XXXXXXX, XXXXXXX, _______, _______, KC_SLSH, KC_MPLY,
_______, _______, _______, KC_LBRC, KC_BSPC, _______, KC_DEL, KC_RBRC, _______, KC_BSLS, _______ ),
/* Navi
* ,-----------------------------------------------------------------------------------.
* | | | | PgUp | | | | |Insert| |Prtsc | |
* |------+------+------+------+------+-------------+------+------+------+------+------|
* | ~ | | Home | PgDn | End | | | | |SrcLck| | |
* |------+------+------+------+------+------|------+------+------+------+------+------|
* | | | | | | Break| | | | | PgUp | |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | | Home | PgDn | End |
* `-----------------------------------------------------------------------------------'
*/
[_NAVI] = LAYOUT_planck_mit(
_______, XXXXXXX, XXXXXXX, KC_PGUP, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_INS, XXXXXXX, KC_PSCR, _______,
KC_TILD, XXXXXXX, KC_HOME, KC_PGDN, KC_END, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_SLCK, _______, _______,
_______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_PAUS, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_PGUP, _______,
_______, _______, _______, _______, _______, _______, _______, _______, KC_HOME, KC_PGDN, KC_END ),
/* Func
* ,-----------------------------------------------------------------------------------.
* | | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | |
* |------+------+------+------+------+-------------+------+------+------+------+------|
* | | F11 | F12 | | | | | | | | | |
* |------+------+------+------+------+------|------+------+------+------+------+------|
* | | | | | | | | | | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | | | | |
* `-----------------------------------------------------------------------------------'
*/
[_FUNC] = LAYOUT_planck_mit(
_______ , KC_F1, KC_F2 , KC_F3, KC_F4, KC_F5, KC_F6 , KC_F7, KC_F8, KC_F9, KC_F10, _______,
_______ , KC_F12, KC_F12 , XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _______,
_______ , XXXXXXX, XXXXXXX , XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _______,
_______ , _______, _______ , _______, _______, _______, _______ , _______, _______, _______, _______ ),
/* Symb - double tap shift
* ,-----------------------------------------------------------------------------------.
* | | | ! | @ | # | $ | % | ^ | & | * | ( | ) | |
* |------+------+------+------+------+-------------+------+------+------+------+------|
* | | | | | | | | | | | : | " |
* |------+------+------+------+------+------|------+------+------+------+------+------|
* | | | | | | | | | < | > | ? | |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | { | _ | | + | } | | | |
* `-----------------------------------------------------------------------------------'
*/
[_SYMB] = LAYOUT_planck_mit(
KC_PIPE, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______,
KC_TILD, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_COLN, KC_DQUO,
_______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_LABK, KC_RABK, KC_QUES, _______,
_______, _______, _______, KC_LCBR, KC_UNDS, _______, KC_PLUS, KC_RCBR, _______, KC_PIPE, _______ ),
/* Number
* ,-----------------------------------------------------------------------------------.
* | | + | - | | | | | 7 | 8 | 9 | | |
* |------+------+------+------+------+-------------+------+------+------+------+------|
* | | * | / | = | | | | 4 | 5 | 6 | | |
* |------+------+------+------+------+------|------+------+------+------+------+------|
* | | | | | | | | 1 | 2 | 3 | |Layer0|
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | 0 | 00 | . | | |
* `-----------------------------------------------------------------------------------'
*/
[_NUMB] = LAYOUT_planck_mit( /* 5 - Numpad */
_______, KC_PPLS, KC_PMNS, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_7, KC_8, KC_9, XXXXXXX, _______,
_______, KC_PAST, KC_PSLS, KC_EQL, XXXXXXX, XXXXXXX, XXXXXXX, KC_4, KC_5, KC_6, XXXXXXX, _______,
_______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_1, KC_2, KC_3, XXXXXXX, TO( 0 ),
_______, _______, _______, _______, _______, XXXXXXX, KC_0, KC_00, KC_DOT, XXXXXXX, _______ ),
/* MARO Empty
* ,-----------------------------------------------------------------------------------.
* | | | | | | | | | | | | |
* |------+------+------+------+------+-------------+------+------+------+------+------|
* | | | | | | | | | | | | |
* |------+------+------+------+------+------|------+------+------+------+------+------|
* | | | | | | | | | | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | | | | |
* `-----------------------------------------------------------------------------------'
*/
[_MARO] = LAYOUT_planck_mit(
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ ),
/* RGB
* ,-----------------------------------------------------------------------------------.
* | | | | | | _TAP | | | | | | |
* |------+------+------+------+------+-------------+------+------+------+------+------|
* | MOD | M_R | M_SW | M_K | M_X | M_G | | | | | | |
* |------+------+------+------+------+------|------+------+------+------+------+------|
* | HUI | SAI | VAI | | | | | | | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | HUD | SAD | VAD | | | RGB_TOG | | | | | |
* `-----------------------------------------------------------------------------------'
*/
[_RGB] = LAYOUT_planck_mit(
_______, _______, _______, _______, _______, RGB_TAP, _______, _______, _______, _______, _______, _______,
RGB_MOD, RGB_M_R, RGB_M_SW, RGB_M_K, RGB_M_X, RGB_M_G, _______, _______, _______, _______, _______, _______,
RGB_HUI, RGB_SAI, RGB_VAI, _______, _______, _______, _______, _______, _______, _______, _______, _______,
RGB_HUD, RGB_SAD, RGB_VAD, _______, _______, RGB_TOG, _______, _______, _______, _______, _______ ),
/* Func
* ,-----------------------------------------------------------------------------------.
* | | | | | | | | | | |Layer0| Rest |
* |------+------+------+------+------+-------------+------+------+------+------+------|
* | Caps | | | | | Game | | | | | | |
* |------+------+------+------+------+------|------+------+------+------+------+------|
* | | | | | | | Numb | Music| | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | | | | |
* `-----------------------------------------------------------------------------------'
*/
[_ADJUST] = LAYOUT_planck_mit(
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, TO( 0 ), RESET ,
KC_CAPS, _______, _______, _______, _______, TO(_GAME), _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, TO(_NUMB), MU_TOG, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ ),
[_GAME] = LAYOUT_planck_mit(
XXXXXXX,KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, XXXXXXX,
XXXXXXX,KC_Q, KC_W, KC_E, KC_R, KC_T, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
XXXXXXX,KC_LCTL, KC_A, KC_S, KC_D, KC_B, KC_N, KC_M, XXXXXXX, XXXXXXX, KC_UP, TO( 0 ),
XXXXXXX,KC_LSFT, KC_Z, KC_X, KC_C, KC_SPC, XXXXXXX, XXXXXXX, KC_LEFT, KC_DOWN, KC_RGHT ),
};
/* Encoder */
static uint8_t encoder_state = 0;
static int8_t encoder_value = 0;
static int8_t encoder_LUT[] = { 0, -1, 1, 0, 1, 0, 0, -1, -1, 0, 0, 1, 0, 1, -1, 0 };
/* Timer */
static uint16_t TAP_RGB_timer;
uint16_t i = 0;
uint16_t j = 0;
static uint16_t RGB_encoder_timer;
static uint16_t RGB_encoder_timer2;
static uint8_t RGB_encoder_dir = 0;
/* Encoder state RGB_display */
static uint8_t RGB_encoder_count=6;
static bool RGB_encoder_bool = false;
const uint8_t RGBLED_RAINBOW_MOOD_INTERVALS[] PROGMEM = {
30,
5,
-5
};
/* RGB tap HUE */
static uint16_t Type_Hue=270;
void matrix_init_user( void )
{
wait_ms( 200 );
/* Encoder init */
encoder_state = PIND & 0x3;
/* Timer init */
void matrix_init_user(void) {
RGB_encoder_timer = timer_read();
TAP_RGB_timer= timer_read();
RGB_encoder_timer2 = timer_read();
}
void matrix_scan_user( void )
{
/* Layer */
void matrix_scan_user(void) {
uint8_t layer = biton32(layer_state);
/* Encoder */
encoder_state <<= 2;
encoder_state |= (PIND & 0x3);
encoder_value += encoder_LUT[encoder_state & 0xF];
/* Encoder state RGB display */
if (RGB_encoder_bool){
if (timer_elapsed(RGB_encoder_timer) > 2500) {
RGB_encoder_bool=false;
if (RGB_TAP_STATE) {
rgblight_mode( 1 );
rgblight_setrgb( RGB_TAP_Base_Color );
if (RGB_encoder_dir != 0) {
if (timer_elapsed(RGB_encoder_timer) > 1400) {
RGB_encoder_dir = 0;
rgblight_mode(RGB_LAYER0_mode);
} else {
rgblight_mode( RGB_LAYER0_mode );
}
}
}
/* Display the Caps state */
if (caps==true){
rgblight_setrgb_at(RGB_Caps_Color,12);
}
/* Start of Encoder clockwise */
if ( encoder_value >= 4 ) {
/* Start of Encoder state RGB_display */
if (!RGB_encoder_bool){
RGB_encoder_timer=timer_read();
RGB_encoder_bool=true;
RGB_encoder_count=5;
rgblight_mode(1);
rgblight_setrgb( 0,0,0 );
}else if (RGB_encoder_bool && timer_elapsed(RGB_encoder_timer) < 800) {
RGB_encoder_timer=timer_read();
RGB_encoder_count-=1;
if (RGB_encoder_count>5 || RGB_encoder_count<1){
RGB_encoder_count=5;
if (timer_elapsed(RGB_encoder_timer2) > 700) {
rgblight_setrgb(0, 0, 0);
RGB_encoder_timer2 = timer_read();
}
if (timer_elapsed(RGB_encoder_timer2) > 80) {
if (RGB_encoder_dir == 1) {
rgblight_setrgb_at(128, 128, 0, 19);
} else {
rgblight_setrgb_at(128, 128, 0, 16);
}
}
rgblight_setrgb_at(0,255,0,5);
if (RGB_encoder_count<1) {RGB_encoder_count=1;}
switch (RGB_encoder_count) {
case 5:
rgblight_setrgb_at(0, 255, 0,4);
break;
case 4:
rgblight_setrgb_at(0, 255, 0,3);
break;
case 3:
rgblight_setrgb_at(0, 255, 0,2);
break;
case 2:
rgblight_setrgb_at(0, 255, 0,1);
break;
case 1:
rgblight_setrgb_at(0, 255, 0,0);
break;
if (timer_elapsed(RGB_encoder_timer2) > 180) {
if (RGB_encoder_dir == 1) {
rgblight_setrgb_at(160, 160, 0, 8);
} else {
rgblight_setrgb_at(160, 160, 0, 3);
}
}
if (timer_elapsed(RGB_encoder_timer2) > 280) {
if (RGB_encoder_dir == 1) {
rgblight_setrgb_at(192, 192, 0, 9);
} else {
rgblight_setrgb_at(192, 192, 0, 2);
}
}
if (timer_elapsed(RGB_encoder_timer2) > 400) {
if (RGB_encoder_dir == 1) {
rgblight_setrgb_at(224, 224, 0, 10);
} else {
rgblight_setrgb_at(224, 224, 0, 1);
}
}
/* End of Encoder state RGB_display */
/* Start of Set Encoder Keycode */
switch ( layer )
{
case 0:
tap_code( KC_VOLD );
break;
case _CODE:
tap_code( KC_LEFT );
break;
case _RGB:
rgblight_decrease_val();
break;
case _NUMB:
tap_code( KC_LEFT );
break;
case _MARO:
tap_code( KC_UP );
break;
default:
tap_code( KC_VOLD );
}
/* End of Set Encoder Keycode */
}
/* End of Encoder clockwise */
/* Start of Encoder anti-clockwise */
if ( encoder_value <= -4 )
{
/* Start of Encoder state RGB_display */
if (!RGB_encoder_bool){
RGB_encoder_timer=timer_read();
RGB_encoder_bool=true;
RGB_encoder_count=6;
rgblight_mode(1);
rgblight_setrgb( 0,0,0 );
}else if (RGB_encoder_bool && timer_elapsed(RGB_encoder_timer) < 800) {
RGB_encoder_timer=timer_read();
RGB_encoder_count+=1;
if (RGB_encoder_count<6 || RGB_encoder_count> 10){
RGB_encoder_count=6;
rgblight_setrgb(0, 0, 0);
}
}
rgblight_setrgb_at(0, 0,255,6);
if (RGB_encoder_count>11) {
RGB_encoder_count=11;
}
switch (RGB_encoder_count) {
case 6:
rgblight_setrgb_at(0, 0,255,7);
break;
case 7:
rgblight_setrgb_at(0, 0,255,8);
break;
case 8:
rgblight_setrgb_at(0, 0,255,9);
break;
case 9:
rgblight_setrgb_at(0, 0,255,10);
break;
case 10:
rgblight_setrgb_at(0, 0,128,11);
break;
}
/* End of Encoder state RGB_display */
/* Start of Set Encoder Keycode */
switch ( layer )
{
case 0:
tap_code( KC_VOLU );
break;
case _CODE:
tap_code( KC_RGHT );
break;
case _RGB:
rgblight_increase_val();
break;
case _NUMB:
tap_code( KC_RGHT );
break;
case _MARO:
tap_code( KC_DOWN );
break;
default:
tap_code( KC_VOLU );
}
/* End of Set Encoder Keycode */
}
/* End of Encoder anti-clockwise */
encoder_value %= 4;
/* Start of RGB with Layer change */
/* Save the Layer0 RGB state */
if ( save_rgbmode == true ) {
if (RGB_TAP_STATE==false)
{
RGB_LAYER0_mode = rgblight_config.mode;
}
}
save_rgbmode = false;
/* When the layer is changed */
if ( layer != current_layer && caps == false) {
/* layer rgb */
if (layer != current_layer) {
has_layer_changed = true;
current_layer = layer; /* update layer information */
current_layer = layer;
}
/* Check for layer change, and apply color if its changed since last check */
if ( has_layer_changed )
{
/* change backlight based on layer. These should be numbers or whatever you defined the layers as */
switch ( layer )
{
case 0:
/* if the key tap RGB effect is enable */
if (RGB_TAP_STATE==true){
rgblight_mode(1);
rgblight_setrgb( RGB_TAP_Base_Color );
}
else{
if (has_layer_changed) {
if (layer == 0) {
rgblight_mode(RGB_LAYER0_mode);
} else {
rgblight_mode(1);
for (i = 0; i < 48; i++) {
(i > 41) ? (j = i - 1) : (j = i);
uint16_t kc = keymap_key_to_keycode(layer, (keypos_t) {.row = 0, .col = i
});
if (kc == KC_TRNS) {
setrgb(5, 5, 5, (LED_TYPE * ) & led[j]); /* TRNS color 0-255*/
} else if (kc == KC_NO) {
setrgb(0, 0, 0, (LED_TYPE * ) & led[j]); /* NO color 0-255*/
} else {
if (layer == 1) {
setrgb(128, 64, 0, (LED_TYPE * ) & led[j]); /* 1 layer 0-255*/
} else if (layer == 2) {
setrgb(0, 64, 128, (LED_TYPE * ) & led[j]); /* 2*/
} else if (layer == 3) {
setrgb(64, 128, 0, (LED_TYPE * ) & led[j]); /* 3*/
} else if (layer == 4) {
setrgb(0, 128, 64, (LED_TYPE * ) & led[j]); /* 4*/
} else if (layer == 5) {
setrgb(128, 0, 128, (LED_TYPE * ) & led[j]); /* 5*/
} else if (layer == 6) {
setrgb(128, 0, 128, (LED_TYPE * ) & led[j]); /* 6*/
} else if (layer == 7) {
setrgb(128, 128, 0, (LED_TYPE * ) & led[j]); /* 7*/
} else if (layer == 8) {
setrgb(0, 128, 128, (LED_TYPE * ) & led[j]); /* 8*/
} else if (layer == 9) {
setrgb(128, 192, 64, (LED_TYPE * ) & led[j]); /* 9*/
} else if (layer == 10) {
setrgb(64, 192, 128, (LED_TYPE * ) & led[j]); /* 10*/
} else if (layer == 11) {
setrgb(128, 64, 192, (LED_TYPE * ) & led[j]); /* 11*/
} else if (layer == 12) {
setrgb(64, 128, 192, (LED_TYPE * ) & led[j]); /* 12*/
} else if (layer == 13) {
setrgb(128, 192, 0, (LED_TYPE * ) & led[j]); /* 13*/
} else if (layer == 14) {
setrgb(192, 0, 128, (LED_TYPE * ) & led[j]); /* 14*/
} else if (layer == 15) {
setrgb(0, 192, 128, (LED_TYPE * ) & led[j]); /* 15*/
}
break;
case _CODE: //1
/* Save Layer0 RGB state */
RGB_LAYER0_mode = rgblight_config.mode;
/* set all the RGB color under the switch */
rgblight_mode( 1 );
rgblight_setrgb(RGB_Layer_1_Base_Color);
/* set each of the RGB led color under the switch */
rgblight_setrgb_at(64, 64, 64,1); // Q
rgblight_setrgb_at(64, 64, 64,2); // W
rgblight_setrgb_at(64, 64, 64,3); // E
rgblight_setrgb_at(64, 64, 64,4); // R
rgblight_setrgb_at(64, 64, 64,5); // T
rgblight_setrgb_at(64, 64, 64,6); // Y
rgblight_setrgb_at(64, 64, 64,7); // U
rgblight_setrgb_at(64, 64, 64,8); // I
rgblight_setrgb_at(64, 64, 64,9); // O
rgblight_setrgb_at(64, 64, 64,10); // P
rgblight_setrgb_at(64, 0, 0,40); // -
rgblight_setrgb_at(64, 0, 0,42); // =
break;
case _NAVI: //2
RGB_LAYER0_mode = rgblight_config.mode;
rgblight_mode( 1 );
rgblight_setrgb(RGB_Layer_2_Base_Color);
rgblight_setrgb_at(64, 0, 64,3);
rgblight_setrgb_at(64, 0, 64,14);
rgblight_setrgb_at(64, 0, 64,15);
rgblight_setrgb_at(64, 0, 64,16);
rgblight_setrgb_at(64, 64, 0,8);
rgblight_setrgb_at(64, 64, 0,10);
rgblight_setrgb_at(64, 64, 0,21);
rgblight_setrgb_at(64, 64, 0,29);
rgblight_setrgb_at(64, 0, 0,11);
rgblight_setrgb_at(0, 0, 64,34);
rgblight_setrgb_at(0, 0, 64,44);
rgblight_setrgb_at(0, 0, 64,45);
rgblight_setrgb_at(0, 0, 64,46);
break;
case _FUNC: //3
RGB_LAYER0_mode = rgblight_config.mode;
rgblight_mode( 1 );
rgblight_setrgb(RGB_Layer_3_Base_Color);
rgblight_setrgb_at(0, 0, 64,1);
rgblight_setrgb_at(0, 0, 64,2);
rgblight_setrgb_at(0, 0, 64,3);
rgblight_setrgb_at(0, 0, 64,4);
rgblight_setrgb_at(0, 0, 64,5);
rgblight_setrgb_at(0, 0, 64,6);
rgblight_setrgb_at(0, 0, 64,7);
rgblight_setrgb_at(0, 0, 64,8);
rgblight_setrgb_at(0, 0, 64,9);
rgblight_setrgb_at(0, 0, 64,10);
rgblight_setrgb_at(0, 0, 64,13);
rgblight_setrgb_at(0, 0, 64,14);
break;
case _SYMB: //4
RGB_LAYER0_mode = rgblight_config.mode;
rgblight_mode( 1 );
rgblight_setrgb(RGB_Layer_4_Base_Color);
rgblight_setrgb_at(0, 64, 64,1);
rgblight_setrgb_at(0, 64, 64,2);
rgblight_setrgb_at(0, 64, 64,3);
rgblight_setrgb_at(0, 64, 64,4);
rgblight_setrgb_at(0, 64, 64,5);
rgblight_setrgb_at(0, 64, 64,6);
rgblight_setrgb_at(0, 64, 64,7);
rgblight_setrgb_at(0, 64, 64,8);
rgblight_setrgb_at(0, 64, 64,9);
rgblight_setrgb_at(0, 64, 64,10);
rgblight_setrgb_at(0, 64, 64,12);
rgblight_setrgb_at(0, 64, 64,22);
rgblight_setrgb_at(0, 64, 64,23);
rgblight_setrgb_at(0, 64, 64,32);
rgblight_setrgb_at(0, 64, 64,33);
rgblight_setrgb_at(0, 64, 64,34);
rgblight_setrgb_at(0, 64, 64,39);
rgblight_setrgb_at(0, 64, 64,40);
rgblight_setrgb_at(0, 64, 64,42);
rgblight_setrgb_at(0, 64, 64,43);
break;
case _NUMB: //5
RGB_LAYER0_mode = rgblight_config.mode;
rgblight_mode( 1 );
rgblight_setrgb(RGB_Layer_5_Base_Color);
rgblight_setrgb_at(0,64,0,1);
rgblight_setrgb_at(0,64,0,2);
rgblight_setrgb_at(0,64,0,13);
rgblight_setrgb_at(0,64,0,14);
rgblight_setrgb_at(0,64,64,15);
rgblight_setrgb_at(64,64,64,7);
rgblight_setrgb_at(64,64,64,8);
rgblight_setrgb_at(64,64,64,9);
rgblight_setrgb_at(64,64,64,19);
rgblight_setrgb_at(64,64,64,20);
rgblight_setrgb_at(64,64,64,21);
rgblight_setrgb_at(64,64,64,31);
rgblight_setrgb_at(64,64,64,32);
rgblight_setrgb_at(64,64,64,33);
rgblight_setrgb_at(64,64,64,42);
rgblight_setrgb_at(64,64,64,43);
rgblight_setrgb_at(0,128,0,44);
break;
case _MARO: //6
RGB_LAYER0_mode = rgblight_config.mode;
rgblight_mode( 1 );
rgblight_setrgb(RGB_Layer_6_Base_Color);
break;
case _RGB: //7
RGB_LAYER0_mode = rgblight_config.mode;
rgblight_mode( 1 );
rgblight_setrgb(RGB_Layer_7_Base_Color);
rgblight_setrgb_at(1,143,225,0);
rgblight_setrgb_at(39,21,107,1);
rgblight_setrgb_at(208,0,0,2);
rgblight_setrgb_at(64,64,64,21);
break;
case _ADJUST: //8
RGB_LAYER0_mode = rgblight_config.mode;
rgblight_mode( 1 );
rgblight_setrgb(RGB_Layer_8_Base_Color);
rgblight_setrgb_at(0,64,0,10);
rgblight_setrgb_at(64,0,0,11);
rgblight_setrgb_at(0,64,0,17);
rgblight_setrgb_at(0,64,0,30);
rgblight_setrgb_at(6,50,50,12);
break;
case _GAME: //9
RGB_LAYER0_mode = rgblight_config.mode;
rgblight_mode( 1 );
rgblight_setrgb(RGB_Layer_9_Base_Color);
rgblight_setrgb_at(0,0,64,15);
rgblight_setrgb_at(0,0,64,26);
rgblight_setrgb_at(0,0,64,27);
rgblight_setrgb_at(0,0,64,28);
rgblight_setrgb_at(64,0,0,35);
break;
default:
rgblight_mode( RGB_LAYER0_mode );
}
}
rgblight_set();
}
has_layer_changed = false;
}
/* End of RGB with Layer change */
} // End of matrix_scan_user
/* shift + enter = " fromhttps://github.com/qmk/qmk_firmware/blob/e899cb8940da04fa2610604f0aab417db7fac119/keyboards/mitosis/keymaps/datagrok/keymap.c */
bool comm_shifted = false;
bool ques_shifted = false;
static uint8_t key_index = 0;
uint8_t shifted;
uint16_t s_keycode;
bool *k_shifted;
/* end of layer rgb */
}
bool process_record_user(uint16_t keycode, keyrecord_t * record) {
/* Start of key tap RGB effect */
if ( RGB_TAP_STATE ==true ) {
key_index=(record->event.key.col)+(record->event.key.row)*12;
/* Change the Hue of the RGB color with the type speed */
if (timer_elapsed(TAP_RGB_timer) >10000){
TAP_RGB_timer=timer_read();
Type_Hue=270;
}else if (timer_elapsed(TAP_RGB_timer) >1000){
Type_Hue+=30;
if (Type_Hue>270) {
Type_Hue=270;}
}else{
TAP_RGB_timer=timer_read();
Type_Hue-=10;
if (Type_Hue<10) {
Type_Hue=10;}
}
if (key_index>42){ //fix the RGB index of the MIT layout position
key_index=key_index-1;
}
if ( record->event.pressed ) {
rgblight_sethsv_at(Type_Hue,255,255,key_index);
} else {
rgblight_setrgb_at(RGB_TAP_Base_Color,key_index);
}
}
/* End of key tap RGB effect */
switch ( keycode )
{
/* save the RGB state when set the new */
case RGB_M_R:
save_rgbmode = true;
break;
case RGB_M_SW:
save_rgbmode = true;
break;
case RGB_M_X:
save_rgbmode = true;
break;
case RGB_M_G:
save_rgbmode = true;
break;
case RGB_MODE_KNIGHT:
save_rgbmode = true;
break;
/* Define a New Keycode: double zero */
case KC_00:
if (record->event.pressed) {
// Do something when pressed
} else {
tap_code( KC_0 ); // send 0
tap_code( KC_0 ); // send 0 twice without macro
}
return false; // Skip all further processing of this key
/* when the REST key is pressed the 'R' key will RED,the "Bottom Left"(esc of qmk-dfu) will be GREEN */
case RESET:
rgblight_mode( 1 );
rgblight_setrgb( 0, 0, 0 );
rgblight_setrgb_at(128, 0, 0,4); // R
rgblight_setrgb_at(6, 128, 24,36); // Bottom Left key
break;
/* Define a New Keycode: key tap RGB effect toggle */
case RGB_TAP:
if ( !(record->event.pressed)) {
/* If enable,the 'On' key will be green */
if (RGB_TAP_STATE) {
RGB_TAP_STATE=false;
rgblight_mode( 1 );
rgblight_setrgb( RGB_TAP_Base_Color );
rgblight_setrgb_at(RGB_TAP_Off_Color,16); // O - on
}else{
/* If disenable,the 'oFf' key will be red */
RGB_TAP_STATE=true;
rgblight_mode( 1 );
rgblight_setrgb( RGB_TAP_Base_Color );
rgblight_setrgb_at(RGB_TAP_On_Color,9); // F - off
}
}
break;
/* special shift keys */
case KC_ENT:
s_keycode = KC_QUOT;
k_shifted = &ques_shifted;
break;
case KC_UP:
s_keycode = KC_SLSH;
k_shifted = &ques_shifted;
break;
case KC_DOWN:
s_keycode = KC_BSLS;
k_shifted = &ques_shifted;
switch (keycode) {
case RGB_MOD:
RGB_LAYER0_mode = rgblight_config.mode;
break;
default:
return (true);
}
shifted = get_mods() & (MOD_BIT( KC_LSHIFT ) | MOD_BIT( KC_RSHIFT ) );
/* Keydown. If shift is currently pressed, register its alternate keycode. */
if ( record->event.pressed && shifted )
{
*k_shifted = true;
register_code( s_keycode );
return(false);
/*
* Keyup. If shift was pressed back when the key was pressed, unregister
* its alternate keycode.
*/
} else if ( !(record->event.pressed) && *k_shifted ) {
*k_shifted = false;
unregister_code( s_keycode );
return(false);
/* Otherwise, behave as normal. */
} else {
return (true);
}
} // End ofprocess_record_user
void led_set_user( uint8_t usb_led )
{
static uint8_t old_usb_led = 0;
wait_ms( 10 ); /* gets rid of tick */
if ( (usb_led & (1 << USB_LED_CAPS_LOCK) ) && !(old_usb_led & (1 << USB_LED_CAPS_LOCK) ) ) {
/* CAPS on */
caps= true;
rgblight_setrgb( 0,0,0 );
rgblight_setrgb_at(RGB_Caps_Color,12); // caps key
#ifdef AUDIO_ENABLE
PLAY_SONG( tone_caps );
#endif
}else if ( !(usb_led & (1 << USB_LED_CAPS_LOCK) ) && (old_usb_led & (1 << USB_LED_CAPS_LOCK) ) ) {
/* CAPS off */
caps= false;
if (RGB_TAP_STATE==false){
rgblight_mode( RGB_LAYER0_mode );
void encoder_update_user(uint8_t index, bool clockwise) {
RGB_encoder_timer = timer_read();
RGB_encoder_timer2 = timer_read();
uint8_t layer = biton32(layer_state);
if (clockwise) {
RGB_encoder_dir = 1;
} else {
rgblight_mode(1);
rgblight_setrgb( 0,0,0 );
RGB_encoder_dir = -1;
}
if (index == 0) /* Right encoder */ {
if (clockwise) {
register_code(keymap_key_to_keycode(layer, (keypos_t) {.row = 4, .col = 11
}));
unregister_code(keymap_key_to_keycode(layer, (keypos_t) {.row = 4, .col = 11
}));
} else {
register_code(keymap_key_to_keycode(layer, (keypos_t) {.row = 4, .col = 10
}));
unregister_code(keymap_key_to_keycode(layer, (keypos_t) {.row = 4, .col = 10
}));
}
} else if (index == 1) /* Left encoder */ {
if (clockwise) {
register_code(keymap_key_to_keycode(layer, (keypos_t) {.row = 4, .col = 1
}));
unregister_code(keymap_key_to_keycode(layer, (keypos_t) {.row = 4, .col = 1
}));
} else {
register_code(keymap_key_to_keycode(layer, (keypos_t) {.row = 4, .col = 0
}));
unregister_code(keymap_key_to_keycode(layer, (keypos_t) {.row = 4, .col = 0
}));
}
}
#ifdef AUDIO_ENABLE
PLAY_SONG( tone_caps );
#endif
}
old_usb_led = usb_led;
} // End of led_set_user

View file

@ -1 +0,0 @@
TAP_DANCE_ENABLE = yes

View file

@ -2,6 +2,8 @@ Tetris
===
A compact 40% (12x4) ortholinear keyboard (Planck Mit layout) with per switch RGB and encoder made by Fengz.
Fake keys on the 5th row are for configuring the encoder's keycode.
![TetrisPhoto](https://i.imgur.com/quwEY0f.jpg)
More: [Imgur](https://imgur.com/gallery/Azq2zUm).

13
keyboards/tetris/rules.mk Normal file → Executable file
View file

@ -36,26 +36,25 @@ F_USB = $(F_CPU)
# Interrupt driven control endpoint task(+60)
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
# Boot Section Size in *bytes*
#OPT_DEFS += -DBOOTLOADER_SIZE=4096
BOOTLOADER =qmk-dfu
# Build Options
# comment out to disable the options.
#
BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
MOUSEKEY_ENABLE = no # Mouse keys(+4700)
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
CONSOLE_ENABLE = no # Console for debug(+400)
COMMAND_ENABLE = no # Commands for debug and configuration
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
AUDIO_ENABLE = no
AUDIO_ENABLE = yes
RGBLIGHT_ENABLE = yes
TAP_DANCE_ENABLE = no
EXTRAFLAGS += -flto # Make the hex smaller
LAYOUTS = planck_mit
EXTRAFLAGS = -flto
ENCODER_ENABLE = yes

2
keyboards/tetris/tetris.c Normal file → Executable file
View file

@ -1 +1 @@
#include "tetris.h"
#include QMK_KEYBOARD_H

6
keyboards/tetris/tetris.h Normal file → Executable file
View file

@ -7,12 +7,14 @@
K000, K001, K002, K003, K004, K005, K006, K007, K008, K009, K010, K011, \
K100, K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, K111, \
K200, K201, K202, K203, K204, K205, K206, K207, K208, K209, K210, K211, \
K300, K301, K302, K303, K304, K305, K307, K308, K309, K310, K311 \
K300, K301, K302, K303, K304, K305, K307, K308, K309, K310, K311, \
K400, K401, K410, K411 \
) { \
{ K000, K001, K002, K003, K004, K005, K006, K007, K008, K009, K010, K011 }, \
{ K100, K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, K111 }, \
{ K200, K201, K202, K203, K204, K205, K206, K207, K208, K209, K210, K211 }, \
{ K300, K301, K302, K303, K304, K305, KC_NO, K307, K308, K309, K310, K311 } \
{ K300, K301, K302, K303, K304, K305, KC_NO, K307, K308, K309, K310, K311 }, \
{ K400, K401, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, K410, K411 } \
}
#endif