Skip to content

Commit

Permalink
[Keymap] Drashna's Hardware Features Experimentations (#6920)
Browse files Browse the repository at this point in the history
* Change RGBLight pin for Planck Light

Move it to A0, so that the SPI? pins are available for BT hackery

* Add QMK DFU bootloader info

* Add Solenoid

* Disable annoying white LED on bottom

* Enable Solenoid on Corne

* Remove bounds for animations

* Increase debounce for Ergodox EZ to reduce repeat key issues

* Set swap hands key to be a hold-tap key

This way, it's not ANNOYING and doesn't swap the hands inteniontally

* Move MT Alt in Corne keymap

* Re-Add fine tuned control of secrets

* Squash mods to single row

* Add LRA settings to haptic feedback settings for Rev6

* Fix issue with non-Planck EZ keymaps

* Add 40 Percent Nano with Analog Joystick

* Add Collide39 keymap

* Fix OLED printing to be more flavorful

* Fix up Iris GamePad and come cleanup

* Expand OLED char map further

* Add modded characters to keylogger

* Here be dragons

Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com>

* Fix up rules for community layouts

* Some more OLED tweaks

* Add mod mask check function

* Change QMK DFU Audio pin to be correct

* Use manual STM config instead of CTPC for Collide 39
  • Loading branch information
drashna authored Oct 16, 2019
1 parent 7662ee7 commit e3a2134
Show file tree
Hide file tree
Showing 23 changed files with 382 additions and 85 deletions.
111 changes: 111 additions & 0 deletions keyboards/40percentclub/nano/keymaps/drashna/keymap.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#include QMK_KEYBOARD_H
#include "drashna.h"
#include "analog.c"
#include "pointing_device.h"
#include "pincontrol.h"


#define KC_X0 LT(_FN, KC_ESC)

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_QWERTY] = LAYOUT(
KC_VOLU, KC_MPLY, KC_MPRV, RESET,
KC_VOLD, KC_MUTE, KC_MNXT, RESET
),

};

// Joystick
// Set Pins
uint8_t xPin = 8; // VRx / /B4
uint8_t yPin = 7; // VRy // B5
uint8_t swPin = E6; // SW

// Set Parameters
uint16_t minAxisValue = 0;
uint16_t maxAxisValue = 1023;

uint8_t maxCursorSpeed = 2;
uint8_t precisionSpeed = 1;
uint8_t speedRegulator = 20; // Lower Values Create Faster Movement

int8_t xPolarity = 1;
int8_t yPolarity = 1;

uint8_t cursorTimeout = 10;

int16_t xOrigin, yOrigin;

uint16_t lastCursor = 0;

int16_t axisCoordinate(uint8_t pin, uint16_t origin) {
int8_t direction;
int16_t distanceFromOrigin;
int16_t range;

int16_t position = analogRead(pin);

if (origin == position) {
return 0;
} else if (origin > position) {
distanceFromOrigin = origin - position;
range = origin - minAxisValue;
direction = -1;
} else {
distanceFromOrigin = position - origin;
range = maxAxisValue - origin;
direction = 1;
}

float percent = (float)distanceFromOrigin / range;
int16_t coordinate = (int16_t)(percent * 100);
if (coordinate < 0) {
return 0;
} else if (coordinate > 100) {
return 100 * direction;
} else {
return coordinate * direction;
}
}

int8_t axisToMouseComponent(uint8_t pin, int16_t origin, uint8_t maxSpeed, int8_t polarity) {
int coordinate = axisCoordinate(pin, origin);
if (coordinate == 0) {
return 0;
} else {
float percent = (float)coordinate / 100;
if (keyboard_report->mods & MOD_BIT(KC_LSFT)) {
return percent * precisionSpeed * polarity * (abs(coordinate) / speedRegulator);
} else {
return percent * maxCursorSpeed * polarity * (abs(coordinate) / speedRegulator);
}
}
}

void pointing_device_task(void) {
report_mouse_t report = pointing_device_get_report();

// todo read as one vector
if (timer_elapsed(lastCursor) > cursorTimeout) {
lastCursor = timer_read();
report.x = axisToMouseComponent(xPin, xOrigin, maxCursorSpeed, xPolarity);
report.y = axisToMouseComponent(yPin, yOrigin, maxCursorSpeed, yPolarity);
}
//
if (!readPin(swPin)) {
report.buttons |= MOUSE_BTN1;
} else {
report.buttons &= ~MOUSE_BTN1;
}

pointing_device_set_report(report);
pointing_device_send();
}

void matrix_init_keymap(void) {
// init pin? Is needed?
setPinInputHigh(swPin);
// Account for drift
xOrigin = analogRead(xPin);
yOrigin = analogRead(yPin);
}
5 changes: 5 additions & 0 deletions keyboards/40percentclub/nano/keymaps/drashna/rules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
POINTING_DEVICE_ENABLE = yes
RGBLIGHT_ENABLE = no
CONSOLE_ENABLE = no

BOOTLOADER = qmk-dfu
7 changes: 7 additions & 0 deletions keyboards/c39/keymaps/drashna/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

// place overrides here
#undef MATRIX_COL_PINS
#define MATRIX_COL_PINS { A3, A2, A1, A0, B13, B14, B15, B9, B3, B2, B4, A10, A9 }
#undef MATRIX_ROW_PINS
#define MATRIX_ROW_PINS { B7, B1, B0 }
45 changes: 45 additions & 0 deletions keyboards/c39/keymaps/drashna/keymap.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include QMK_KEYBOARD_H

// Each layer gets a name for readability, which is then used in the keymap matrix below.
// The underscores don't mean anything - you can have a layer called STUFF or any other name.
// Layer names don't all need to be of the same length, obviously, and you can also skip them
// entirely and just use numbers.
#define _QWERTY 0
#define _FN1 1

// Defines for task manager and such
#define CALTDEL LCTL(LALT(KC_DEL))
#define TSKMGR LCTL(LSFT(KC_ESC))

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

/* Qwerty
* ,----------------------------------------------------------------------------. ,-------------.
* | Q | W | E | R | T | Bksp | Y | U | I | O | P | | M1 | M2 |
* |------+------+------+------+------+------+------+------+------+------+------+ |------+------|
* | A | S | D | F | G | Enter| H | J | K | L | ; | | M3 | M4 |
* |------+------+------+------+------+------+------+------+------+------+------+ |------+------|
* | Z | X | C | V | B | FN1 | N | M | , | . | / | | M5 | M6 |
* `----------------------------------------------------------------------------' `-------------'
*/
[_QWERTY] = LAYOUT(
KC_Q, KC_W, KC_E, KC_R, KC_T, KC_BSPC, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_1, KC_2,
KC_A, KC_S, KC_D, KC_F, KC_G, MT(MOD_LSFT, KC_ENT), KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_3, KC_4,
KC_Z, KC_X, KC_C, KC_V, KC_B, LT(_FN1, KC_SPC), KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_5, KC_6
),

/* FN1
* ,----------------------------------------------------------------------------. ,-------------.
* | 1 | 2 | 3 | 4 | 5 | Bksp | 6 | 7 | 8 | 9 | 0 | | M1 | M2 |
* |------+------+------+------+------+------+------+------+------+------+------+ |------+------|
* | 4 | 5 | 6 | + | | Enter| | | | | | | M3 | M4 |
* |------+------+------+------+------+------+------+------+------+------+------+ |------+------|
* | 7 | 8 | 9 | 0 | | FN1 | | | | | | | M5 | M6 |
* `----------------------------------------------------------------------------' `-------------'
*/
[_FN1] = LAYOUT(
KC_1, KC_2, KC_3, KC_4, KC_5, KC_BSPC, KC_6, KC_7, KC_8, KC_9, KC_0, KC_1, KC_2,
KC_4, KC_5, KC_6, KC_PLUS, _______, KC_ENT, _______, _______, _______, _______, _______, KC_3, KC_4,
KC_7, KC_8, KC_9, KC_0, _______, _______, _______, _______, _______, _______, _______, KC_5, KC_6
),
};
3 changes: 3 additions & 0 deletions keyboards/c39/keymaps/drashna/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @drashna's keymap for the C39

HERE BE DRAGONS
18 changes: 18 additions & 0 deletions keyboards/c39/keymaps/drashna/rules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
MCU = STM32F303
BOOTLOADER =

BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration(+1000)
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
CONSOLE_ENABLE = yes # Console for debug(+400)
COMMAND_ENABLE = yes # Commands for debug and configuration
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
NKRO_ENABLE = yes # USB Nkey Rollover
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality on B7 by default
MIDI_ENABLE = no # MIDI controls
UNICODE_ENABLE = yes # Unicode
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
AUDIO_ENABLE = yes # Audio output on port C6
RGBLIGHT_ENABLE = no # RGB Enable / Disable
10 changes: 7 additions & 3 deletions keyboards/crkbd/keymaps/drashna/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# define RGBLIGHT_HUE_STEP 8
# define RGBLIGHT_SAT_STEP 8
# define RGBLIGHT_VAL_STEP 5
# define RGBLIGHT_LIMIT_VAL 150
# define RGBLIGHT_LIMIT_VAL 120
#endif

#ifdef RGB_MATRIX_ENABLE
Expand All @@ -51,7 +51,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended
// # define RGB_MATRIX_LED_PROCESS_LIMIT (DRIVER_LED_TOTAL + 4) / 5 // limits the number of LEDs to process in an animation per task run (increases keyboard responsiveness)
// # define RGB_MATRIX_LED_FLUSH_LIMIT 16 // limits in milliseconds how frequently an animation will update the LEDs. 16 (16ms) is equivalent to limiting to 60fps (increases keyboard responsiveness)
# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255
# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 120 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255
# define RGB_MATRIX_HUE_STEP 8
# define RGB_MATRIX_SAT_STEP 8
# define RGB_MATRIX_VAL_STEP 5
Expand All @@ -60,7 +60,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

#ifdef AUDIO_ENABLE
# define B6_AUDIO
// #define NO_MUSIC_MODE
# define NO_MUSIC_MODE
#endif

#ifdef HAPTIC_ENABLE
# define SOLENOID_PIN B7
#endif

#undef PRODUCT
Expand Down
51 changes: 35 additions & 16 deletions keyboards/crkbd/keymaps/drashna/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,25 @@ extern rgblight_config_t rgblight_config;
static uint32_t oled_timer = 0;
static char keylog_str[6] = {};
static uint16_t log_timer = 0;
static const char code_to_name[60] = {' ', ' ', ' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'R', 'E', 'B', 'T', '_', '-', '=', '[', ']', '\\', '#', ';', '\'', '`', ',', '.', '/', ' ', ' ', ' '};
static const char PROGMEM code_to_name[0xFF] = {
// 0 1 2 3 4 5 6 7 8 9 A B c D E F
' ', ' ', ' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', // 0x
'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', // 1x
'3', '4', '5', '6', '7', '8', '9', '0', 20, 19, 27, 26, 22, '-', '=', '[', // 2x
']','\\', '#', ';','\'', '`', ',', '.', '/', 128, ' ', ' ', ' ', ' ', ' ', ' ', // 3x
' ', ' ', ' ', ' ', ' ', ' ', 'P', 'S', ' ', ' ', ' ', ' ', 16, ' ', ' ', ' ', // 4x
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 5x
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 6x
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 7x
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 8x
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 9x
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Ax
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Bx
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Cx
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Dx
'C', 'S', 'A', 'C', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Ex
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' // Fx
};

void add_keylog(uint16_t keycode);
#endif
Expand All @@ -27,7 +45,7 @@ enum crkbd_keycodes { RGBRST = NEW_SAFE_RANGE };
) \
LAYOUT_wrapper( \
KC_ESC, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, KC_MINS, \
KC_TAB, ALT_T(K11), K12, K13, K14, K15, K16, K17, K18, K19, K1A, RALT_T(KC_QUOT), \
ALT_T(KC_TAB), K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, RALT_T(KC_QUOT), \
OS_LSFT, CTL_T(K21), K22, K23, K24, K25, K26, K27, K28, K29, RCTL_T(K2A), OS_RSFT, \
KC_GRV, KC_SPC, BK_LWER, DL_RAIS, KC_ENT, OS_RGUI \
)
Expand Down Expand Up @@ -107,7 +125,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_MAKE, _________________ADJUST_L1_________________, _________________ADJUST_R1_________________, KC_RESET,
VRSN, _________________ADJUST_L2_________________, _________________ADJUST_R2_________________, EEP_RST,
MG_NKRO, _________________ADJUST_L3_________________, _________________ADJUST_R3_________________, RGB_IDL,
_______, KC_NUKE, _______, _______, TG_MODS, _______
HPT_TOG, KC_NUKE, _______, _______, TG_MODS, HPT_FBK
)
};
// clang-format on
Expand All @@ -131,24 +149,26 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
oled_rotation_t oled_init_user(oled_rotation_t rotation) { return OLED_ROTATION_270; }

void add_keylog(uint16_t keycode) {
if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) {
if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX) || (keycode >= QK_MODS && keycode <= QK_MODS_MAX)) {
keycode = keycode & 0xFF;
} else if (keycode > 0xFF) {
keycode = 0;
}

for (uint8_t i = 4; i > 0; --i) {
keylog_str[i] = keylog_str[i - 1];
}

if (keycode < 60) {
keylog_str[0] = code_to_name[keycode];
if (keycode < (sizeof(code_to_name) / sizeof(char))) {
keylog_str[0] = pgm_read_byte(&code_to_name[keycode]);
}

log_timer = timer_read();
}

void update_log(void) {
if (timer_elapsed(log_timer) > 750) {
add_keylog(0);
//add_keylog(0);
}
}

Expand Down Expand Up @@ -197,19 +217,18 @@ void render_layer_state(void) {
void render_keylock_status(uint8_t led_usb_state) {
oled_write_P(PSTR("Lock:"), false);
oled_write_P(PSTR(" "), false);
oled_write_P(PSTR("NUM "), led_usb_state & (1 << USB_LED_NUM_LOCK));
oled_write_P(PSTR(" "), false);
oled_write_P(PSTR("CAPS"), led_usb_state & (1 << USB_LED_CAPS_LOCK));
oled_write_P(PSTR(" "), false);
oled_write_P(PSTR("SCRL"), led_usb_state & (1 << USB_LED_SCROLL_LOCK));
oled_write_P(PSTR("N"), led_usb_state & (1 << USB_LED_NUM_LOCK));
oled_write_P(PSTR("C"), led_usb_state & (1 << USB_LED_CAPS_LOCK));
oled_write_ln_P(PSTR("S"), led_usb_state & (1 << USB_LED_SCROLL_LOCK));
}

void render_mod_status(uint8_t modifiers) {
oled_write_P(PSTR("Mods:"), false);
oled_write_P(PSTR(" SHFT"), (modifiers & MOD_MASK_SHIFT));
oled_write_P(PSTR(" CTRL"), (modifiers & MOD_MASK_CTRL));
oled_write_P(PSTR(" ALT "), (modifiers & MOD_MASK_ALT));
oled_write_P(PSTR(" GUI "), (modifiers & MOD_MASK_GUI));
oled_write_P(PSTR(" "), false);
oled_write_P(PSTR("S"), (modifiers & MOD_MASK_SHIFT));
oled_write_P(PSTR("C"), (modifiers & MOD_MASK_CTRL));
oled_write_P(PSTR("A"), (modifiers & MOD_MASK_ALT));
oled_write_P(PSTR("G"), (modifiers & MOD_MASK_GUI));
}

void render_bootmagic_status(void) {
Expand Down
1 change: 1 addition & 0 deletions keyboards/crkbd/keymaps/drashna/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight.
SWAP_HANDS_ENABLE = no # Enable one-hand typing
RGB_MATRIX_ENABLE = WS2812

HAPTIC_ENABLE = SOLENOID
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend

Expand Down
4 changes: 2 additions & 2 deletions keyboards/keebio/iris/keymaps/drashna/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
),

[_GAMEPAD] = LAYOUT_wrapper(
KC_ESC, KC_NO, KC_1, KC_2, KC_3, KC_P, _______, _______, _______, _______, _______, _______,
KC_ESC, KC_NO, KC_1, KC_2, KC_3, KC_4, _______, _______, _______, _______, _______, _______,
KC_F1, KC_K, KC_Q, KC_W, KC_E, KC_R, _______, _______, _______, _______, _______, _______,
KC_TAB, KC_G, KC_A, KC_S, KC_D, KC_F, _______, _______, _______, _______, _______, _______,
KC_LCTL, KC_LSFT, KC_Z, KC_X, KC_C, KC_H, TG_GAME, _______, _______, _______, _______, _______, _______, _______,
LOWER, KC_V, KC_SPC, _______, _______, _______
KC_GRV, KC_V, KC_SPC, _______, _______, _______
),


Expand Down
13 changes: 8 additions & 5 deletions keyboards/keebio/iris/keymaps/drashna_lp/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "../drashna/config.h"

#ifdef RGBLIGHT_ENABLE
# undef RGBLED_NUM
# define RGBLED_NUM 16 // Number of LEDs
# undef RGBLED_SPLIT
# define RGBLED_SPLIT { 8, 8 }
# undef RGBLED_NUM
# define RGBLED_NUM 16 // Number of LEDs
# undef RGBLED_SPLIT
# define RGBLED_SPLIT \
{ 8, 8 }
#endif

#undef PRODUCT
#ifdef KEYBOARD_keebio_iris_rev2
# define PRODUCT Drashna Hacked Iris LP Rev.2 (Backlit)
# define PRODUCT Drashna Hacked Iris LP Rev .2(Backlit)
#endif

#undef SHFT_LED1
Expand All @@ -46,3 +47,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define ALT_LED1 7
#undef GUI_LED1
#define GUI_LED1 8

#define DRASHNA_LP
2 changes: 1 addition & 1 deletion layouts/community/ergodox/drashna/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
#define PRODUCT DrashnaDox - Hacked ErgoDox EZ Shine

#undef DEBOUNCE
#define DEBOUNCE 15
#define DEBOUNCE 30

#define TAPPING_TERM_PER_KEY
Loading

0 comments on commit e3a2134

Please sign in to comment.