Skip to content

Commit

Permalink
[Keyboard] Improvements for the Torn keyboard (qmk#11268)
Browse files Browse the repository at this point in the history
* Add bongo cat animation

* Map all keys on base layer

... to make it easier to test newly built keyboards. The encoders
are optional and can be placed in different locations.

* Fix Torn in QMK configurator

This removes additional variables defined in the keymap.c file, so
that the default firmware can be compiled by the configurator.

Co-authored-by: Richard Titmuss <richardt@spotify.com>
  • Loading branch information
rtitmuss and Richard Titmuss authored Jan 14, 2021
1 parent 73235e7 commit 523c831
Show file tree
Hide file tree
Showing 7 changed files with 434 additions and 87 deletions.
379 changes: 379 additions & 0 deletions keyboards/torn/bongocat.c

Large diffs are not rendered by default.

16 changes: 1 addition & 15 deletions keyboards/torn/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_QUOT,
KC_GRV, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_LBRC,
KC_BSLS, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RBRC ,
_______, KC_LCTL, S_BSPC, R_DEL, G_ENT, L_SPC, KC_RALT, _______
R_DEL, KC_LCTL, S_BSPC, R_DEL, G_ENT, L_SPC, KC_RALT, G_ENT
),

/* Lower
Expand Down Expand Up @@ -103,17 +103,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
)

};

const uint16_t PROGMEM encoder_keymaps[][2][2] = {
[_QWERTY] = { { C(S(KC_TAB)), C(KC_TAB) }, { KC_PGDN, KC_PGUP } },
[_LOWER] = { { C(KC_LEFT), C(KC_RGHT) }, { KC__VOLDOWN, KC__VOLUP } },
[_RAISE] = { { KC_TRNS, KC_TRNS }, { G(KC_TAB), G(S(KC_TAB)) } },
[_ADJUST] = { { KC_TRNS, KC_TRNS }, { KC_TRNS, KC_TRNS } },
};
// clang-format on

layer_state_t layer_state_set_user(layer_state_t state) {
torn_set_led(0, IS_LAYER_ON_STATE(state, _RAISE));
torn_set_led(1, IS_LAYER_ON_STATE(state, _LOWER));
return state;
}
2 changes: 1 addition & 1 deletion keyboards/torn/keymaps/via/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_QUOT,
KC_GRV, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_LBRC,
KC_BSLS, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RBRC ,
_______, KC_LCTL, S_BSPC, R_DEL, G_ENT, L_SPC, KC_RALT, _______
R_DEL, KC_LCTL, S_BSPC, R_DEL, G_ENT, L_SPC, KC_RALT, G_ENT
),

/* Lower
Expand Down
6 changes: 4 additions & 2 deletions keyboards/torn/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
ENCODER_ENABLE = yes # Enable rotary encoder
OLED_DRIVER_ENABLE = yes
WPM_ENABLE = yes
CUSTOM_MATRIX = lite

SRC += matrix.c \
bongocat.c \
mcp23018.c \
torn_encoder.c \
torn_oled.c
torn_encoder.c

QUANTUM_LIB_SRC += i2c_master.c
37 changes: 37 additions & 0 deletions keyboards/torn/torn.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,40 @@ void torn_set_led(uint8_t led, bool state) {
uint8_t iodir = 0b11111000 | led_state[0] << 2 | led_state[1] << 1 | led_state[2];
mcp23018_writeReg(IODIRB, &iodir, 1);
}

// clang-format off
const char PROGMEM bongocat_logo[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xf8, 0x98, 0x98, 0x98, 0x98, 0x98, 0x18, 0x18, 0x98,
0x98, 0x98, 0x98, 0x98, 0xf8, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x80, 0xc0, 0x60, 0x30, 0x30, 0x18, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98,
0x18, 0x30, 0x30, 0x60, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xf8, 0xf8, 0x18, 0x18, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x18, 0x38,
0x70, 0xe0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xf8, 0xf8, 0x38, 0x70, 0xe0, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xf8, 0xf8, 0x18, 0x18, 0xf8, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0xff, 0xff, 0x00, 0x00, 0xff,
0xff, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xf8, 0xfe, 0x07, 0x01, 0xf0, 0xfc, 0x0e, 0x03, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x03, 0x03, 0x0e, 0xfc, 0xf0, 0x01, 0x07, 0xfe, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xc1, 0xc1, 0xc1, 0x63, 0x3f, 0x1c,
0xc0, 0xe1, 0x7f, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0x00, 0x00, 0xf8, 0xf1, 0xe3, 0xc7, 0x8e, 0x1c, 0x38, 0x70, 0xe0, 0xc0, 0x80, 0x00,
0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff,
0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0f, 0x3f, 0x70, 0xc0, 0x87, 0x1f, 0x38, 0x60, 0x60, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0,
0x60, 0x60, 0x38, 0x1f, 0x87, 0xc0, 0xf0, 0x7f, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xfe, 0xfe, 0x0e, 0x3c, 0x78, 0xe2, 0xc7, 0x1f,
0x39, 0xe0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x01, 0x03, 0x07, 0x0e, 0x1c, 0x38, 0x71, 0xe3, 0xc7,
0x8f, 0x1f, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0c, 0x0c, 0x0f,
0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x06, 0x06, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
0x0c, 0x06, 0x06, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0c, 0x0c, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x01, 0x07, 0x0f,
0x0c, 0x0c, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0f, 0x0f, 0x0c, 0x0c, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x03, 0x07, 0x0e, 0x0c, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// clang-format on
18 changes: 12 additions & 6 deletions keyboards/torn/torn_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,24 @@ static int8_t encoder_LUT[] = {0, -1, 1, 0, 1, 0, 0, -1, -1, 0, 0, 1, 0, 1, -1,
static uint8_t encoder_state = 0;
static int8_t encoder_pulses = 0;

extern const uint16_t PROGMEM encoder_keymaps[][2][2];
__attribute__((weak)) extern const uint16_t PROGMEM encoder_keymaps[][2][2];

const uint16_t encoder_default[2][2] = { { KC_PGDN, KC_PGUP }, { KC__VOLDOWN, KC__VOLUP } };

/**
* Tap on encoder updates using the encoder keymap
*/
void encoder_update_kb(uint8_t index, bool clockwise) {
int layer = get_highest_layer(layer_state);

uint16_t code;
do {
code = pgm_read_word(&encoder_keymaps[layer--][index][clockwise]);
} while (code == KC_TRNS);

if (encoder_keymaps) {
int layer = get_highest_layer(layer_state);
do {
code = pgm_read_word(&encoder_keymaps[layer--][index][clockwise]);
} while (code == KC_TRNS);
} else {
code = encoder_default[index][clockwise];
}

tap_code16(code);
}
Expand Down
63 changes: 0 additions & 63 deletions keyboards/torn/torn_oled.c

This file was deleted.

0 comments on commit 523c831

Please sign in to comment.