]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
several improvements for mitosis:datagrok (#1960)
authorMichael F. Lamb <mike@datagrok.org>
Fri, 3 Nov 2017 15:56:06 +0000 (08:56 -0700)
committerJack Humbert <jack.humb@gmail.com>
Fri, 3 Nov 2017 15:56:06 +0000 (11:56 -0400)
* mitosis/datagrok: reduce features from rules.mk

* mitosis/datagrok: make both layer keys neighbor shift

* mitosis/datagrok: (no-op) tweak some comments

* mitosis/datagrok: set baudrate to 250k

This requires a corresponding change to the mitosis wireless firmware:
https://github.com/reversebias/mitosis/pull/10

* mitosis/datagrok: move design description from code comment to a readme

* mitosis/datagrok: new layout, new shifted keys, efficient LED code

This is experimental, but compiles and seems to work correctly.

* mitosis/datagrok: whoops, move readme.md

* mitosis/datagrok: a minor layout improvement simplifies custom-shifted code

instead of [, .] [? !], using [, ?] [. !] greatly simplifies the code
needed to perform the shifted-key switching. (And keeps , and . on the
same keys that they are under qwerty.)

also: layout improvements for symbols

* mitosis/datagrok: make my code conform to QMK style guidelines

* mitosis/datagrok: TODO note for layout table in README

* mitosis/datagrok: remove led_set_user until i figure out other changes

need to see if the corresponding changes needed in the keyboard-level code
is okay.

* mitosis/datagrok: simpler layer indicator

* mitosis/datagrok: undo change to keyboard baud; make it in my layout dir.

* mitosis/datagrok: apply same punctuation hack to qwerty layer

* mitosis/datagrok: enable qwerty layer toggle

* mitosis/datagrok: update readme

keyboards/mitosis/keymaps/datagrok/config.h [new file with mode: 0644]
keyboards/mitosis/keymaps/datagrok/keymap.c
keyboards/mitosis/keymaps/datagrok/readme.md [new file with mode: 0644]
keyboards/mitosis/keymaps/datagrok/rules.mk [new file with mode: 0644]

diff --git a/keyboards/mitosis/keymaps/datagrok/config.h b/keyboards/mitosis/keymaps/datagrok/config.h
new file mode 100644 (file)
index 0000000..3f303e0
--- /dev/null
@@ -0,0 +1,22 @@
+#ifndef CONFIG_USER_H
+#define CONFIG_USER_H
+
+#include "../../config.h"
+
+// I use a pro micro clocked at 8Mhz. It can't reach 1M baud, so this is the
+// next fastest possible baud without errors. I don't notice any difference in
+// behavior at this slower speed. (So I think it should maybe be the default,
+// to allow a single codebase to support both available flavors of pro micro.)
+// This requires a corresponding change to the wireless module firmware; see
+// https://github.com/reversebias/mitosis/pull/10
+#undef SERIAL_UART_BAUD // avoids redefinition warning
+#define SERIAL_UART_BAUD 250000
+
+// TODO: figure out which of these I can safely enable to reduce firmware size.
+//#define NO_ACTION_LAYER
+//#define NO_ACTION_TAPPING
+//#define NO_ACTION_ONESHOT // can't; errors
+//#define NO_ACTION_MACRO
+//#define NO_ACTION_FUNCTION
+
+#endif
index e4460a9b6941a9c643e69dd050ee1ce75afa54bd..36683fbc5d8905147e1453f8564ea76d38c0762f 100644 (file)
@@ -1,34 +1,12 @@
 #include "mitosis.h"
 
 #include "mitosis.h"
 
-// Arrows in a layer in the home position.
-// Fn+Arrows = PgUp PgDn Home End, which is intuitive for me
-// 
-// Since QWERTY and WORKMAN keep angle brackets together, I wanted to place
-// other enclosing symbols on the same keys. So, 9 and 0 and [ and ] land there
-// in other layers. That informed the numbers placement, which informed the
-// function-key placement.
-//
-// To do:
-// - Improve LED indications (may require modding bluetooth firmware):
-//   - Is any board nonresponsive (which one?)
-//   - Does either board have a low battery?
-// - Use "shifted keys" hack to make programming symbols easier to type
-// - Add "media" keysyms, Insert, PrintScr, Pause/Break
-// - Dynamically toggle QWERTY or other layouts
-// - See if the henkans placement is at all useful for Japanese speakers, or
-//   abuse different keysyms
-// - Overlay a 10key numpad somewhere
-// - Mod a speaker onto my receiver and enable tones
-// - Mod more indicator LEDs onto my receiver
-// - Do something with Num/Caps/Scroll lock?
-// - Improve tri-layer behavior
-
 enum mitosis_layers
 {
 enum mitosis_layers
 {
-    _WORKMAN,
-    _FUNC,
-    _NUMS,
-    _NMFN
+    _xW, // workman
+    _xQ, // qwerty
+    _xS, // symbols
+    _xN, // numbers
+    _xF  // functions
 };
 
 // Fillers to make layering more clear
 };
 
 // Fillers to make layering more clear
@@ -38,67 +16,125 @@ enum mitosis_layers
 #define KC_LMTA KC_LALT // For fun, name the mods like the space cadet keyboard does
 #define KC_RMTA KC_RALT // META
 #define KC_LSUP KC_LGUI // SUPER
 #define KC_LMTA KC_LALT // For fun, name the mods like the space cadet keyboard does
 #define KC_RMTA KC_RALT // META
 #define KC_LSUP KC_LGUI // SUPER
-#define KC_RSUP KC_RGUI // 
+#define KC_RSUP KC_RGUI //
 #define KC_RHYP KC_INT4 // HYPER (actually muhenkan 無変換 and henkan 変換)
 #define KC_LHYP KC_INT5 // or NFER/XFER.
 
 #define KC_RHYP KC_INT4 // HYPER (actually muhenkan 無変換 and henkan 変換)
 #define KC_LHYP KC_INT5 // or NFER/XFER.
 
-// I didn't want to mess about with new keymappings and custom logic etc. to
-// enable tri-state layers like mitosis default does. This layout accomplishes
-// it with a small quirk that triggering both layers then releasing one
-// out-of-order will leave the tri-state triggered. Which doesn't bother me.
+// Momentary tri-state layers. Mitosis default keymap does this too but employs
+// new keymappings and a bunch of conditional code. This simpler keymap
+// accomplishes it, but with a small quirk: triggering both layers then
+// releasing one out-of-order will leave the tri-state triggered until the
+// other is released. Which doesn't bother me.
 
 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
 
 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
-    [_WORKMAN] = {
-        {KC_Q,    KC_D,      KC_R,    KC_W,    KC_B,      KC_J,      KC_F,    KC_U,    KC_P,      KC_SCLN},
-        {KC_A,    KC_S,      KC_H,    KC_T,    KC_G,      KC_Y,      KC_N,    KC_E,    KC_O,      KC_I},
-        {KC_Z,    KC_X,      KC_M,    KC_C,    KC_V,      KC_K,      KC_L,    KC_COMM, KC_DOT,    KC_SLSH},
-        {XXXXXXX, MO(_NUMS), KC_LCTL, KC_LSFT, KC_BSPC,   KC_SPC,    KC_RSFT, KC_RCTL, MO(_NUMS), XXXXXXX},
-        {XXXXXXX, KC_LHYP,   KC_LSUP, KC_LMTA, MO(_FUNC), MO(_FUNC), KC_RMTA, KC_RSUP, KC_RHYP,   XXXXXXX}
-    },
-    [_FUNC] = {
-        {KC_ESC,  _______,   KC_UP,   _______, _______, _______, _______, _______, _______,   KC_QUOT},
-        {KC_TAB,  KC_LEFT,   KC_DOWN, KC_RGHT, _______, _______, _______, _______, _______,   KC_GRV},
-        {_______, _______,   _______, _______, _______, _______, _______, KC_LBRC, KC_RBRC,   KC_BSLS},
-        {XXXXXXX, MO(_NMFN), _______, _______, KC_DEL,  KC_ENT,  _______, _______, MO(_NMFN), XXXXXXX},
-        {XXXXXXX, _______,   _______, _______, ___M___, ___M___, _______, _______, _______,   XXXXXXX},
-    },
-    [_NUMS] = {
-        {_______, _______, _______, _______, _______,   _______,   KC_1,    KC_2,    KC_3,    KC_4},
-        {_______, _______, _______, _______, _______,   _______,   KC_5,    KC_6,    KC_7,    KC_8},
-        {_______, _______, _______, _______, _______,   _______,   KC_MINS, KC_9,    KC_0,    KC_EQL},
-        {XXXXXXX, ___M___, _______, _______, _______,   _______,   _______, _______, ___M___, XXXXXXX},
-        {XXXXXXX, _______, _______, _______, MO(_NMFN), MO(_NMFN), _______, _______, _______, XXXXXXX},
-    },
-    [_NMFN] = {
-        {_______, _______, KC_PGUP, _______, _______, _______, KC_F1,   KC_F2,   KC_F3,   KC_F4},
-        {_______, KC_HOME, KC_PGDN, KC_END,  _______, _______, KC_F5,   KC_F6,   KC_F7,   KC_F8},
-        {_______, _______, _______, _______, _______, _______, KC_F8,   KC_F9,   KC_F10,  KC_F12},
-        {XXXXXXX, ___M___, _______, _______, _______, _______, _______, _______, ___M___, XXXXXXX},
-        {XXXXXXX, _______, _______, _______, ___M___, ___M___, _______, _______, _______, XXXXXXX},
-    },
+  [_xW] = {
+    {KC_Q,    KC_D,    KC_R,    KC_W,    KC_B,    KC_J,    KC_F,    KC_U,    KC_P,    KC_SCLN},
+    {KC_A,    KC_S,    KC_H,    KC_T,    KC_G,    KC_Y,    KC_N,    KC_E,    KC_O,    KC_I},
+    {KC_Z,    KC_X,    KC_M,    KC_C,    KC_V,    KC_K,    KC_L,    KC_COMM, KC_DOT,  KC_QUOT},
+    {XXXXXXX, KC_LSUP, KC_LCTL, MO(_xN), KC_LSFT, KC_RSFT, MO(_xN), KC_RCTL, KC_RSUP, XXXXXXX},
+    {XXXXXXX, KC_LHYP, KC_LMTA, MO(_xS), KC_BSPC, KC_SPC,  MO(_xS), KC_RMTA, KC_RHYP, XXXXXXX}
+  },
+  [_xQ] = {
+    {KC_Q,    KC_W,    KC_E,    KC_R,    KC_T,    KC_Y,    KC_U,    KC_I,    KC_O,    KC_P},
+    {KC_A,    KC_S,    KC_D,    KC_F,    KC_G,    KC_H,    KC_J,    KC_K,    KC_L,    KC_SCLN},
+    {KC_Z,    KC_X,    KC_C,    KC_V,    KC_B,    KC_N,    KC_M,    KC_COMM, KC_DOT,  KC_QUOT},
+    {XXXXXXX, _______, _______, _______, _______, _______, _______, _______, _______, XXXXXXX},
+    {XXXXXXX, _______, _______, _______, _______, _______, _______, _______, _______, XXXXXXX}
+  },
+  [_xS] = {
+    {KC_ESC,  _______, KC_UP,   _______, _______, KC_AT,   KC_HASH, KC_DLR,  KC_PERC, KC_TILD},
+    {KC_TAB,  KC_LEFT, KC_DOWN, KC_RGHT, _______, KC_CIRC, KC_AMPR, KC_PIPE, KC_GRV,  KC_UNDS},
+    {KC_BSLS, KC_RPRN, KC_RCBR, KC_RBRC, KC_RABK, KC_LABK, KC_LBRC, KC_LCBR, KC_LPRN, KC_SLSH},
+    {XXXXXXX, _______, _______, MO(_xF), _______, _______, MO(_xF), _______, _______, XXXXXXX},
+    {XXXXXXX, _______, _______, ___M___, KC_DEL,  KC_ENT,  ___M___, _______, _______, XXXXXXX},
+  },
+  [_xN] = {
+    {_______, _______, _______, _______, _______, KC_PSLS, KC_P7,   KC_P8,   KC_P9,   KC_P0},
+    {_______, _______, _______, _______, _______, KC_PAST, KC_P4,   KC_P5,   KC_P6,   KC_PPLS},
+    {_______, _______, _______, _______, _______, KC_PMNS, KC_P1,   KC_P2,   KC_P3,   KC_PEQL},
+    {XXXXXXX, _______, _______, ___M___, _______, _______, ___M___, _______, _______, XXXXXXX},
+    {XXXXXXX, _______, _______, MO(_xF), _______, KC_PENT, MO(_xF), _______, _______, XXXXXXX},
+  },
+  [_xF] = {
+    {_______, _______, KC_PGUP, _______, KC_VOLU, KC_F13,  KC_F7,   KC_F8,   KC_F9,   KC_F10},
+    {_______, KC_HOME, KC_PGDN, KC_END,  KC_VOLD, KC_F14,  KC_F4,   KC_F5,   KC_F6,   KC_F11},
+    {TG(_xQ), KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_F15,  KC_F1,   KC_F2,   KC_F3,   KC_F12},
+    {XXXXXXX, _______, _______, ___M___, _______, _______, ___M___, _______, _______, XXXXXXX},
+    {XXXXXXX, _______, _______, _______, ___M___, ___M___, _______, _______, _______, XXXXXXX},
+  },
 };
 
 };
 
+// This is a hack to place <question mark> on <shift-comma> and <exclaimation
+// mark> on <shift-period>, when using an operating system configured for a
+// US/qwerty layout.
+bool comm_shifted = false;
+bool ques_shifted = false;
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+  uint8_t shifted;
+  uint16_t s_keycode;
+  bool *k_shifted;
+
+  switch (keycode) {
+    case KC_COMM:
+      s_keycode = KC_SLSH;
+      k_shifted = &comm_shifted;
+      break;
+    case KC_DOT:
+      s_keycode = KC_1;
+      k_shifted = &ques_shifted;
+      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;
+  }
+}
+
+// Set the bits of A selected by MASK to the corresponding bits of B
+#define setbits(A, B, MASK) A = (A & (B | ~MASK)) | (B & MASK)
 void matrix_scan_user(void) {
 void matrix_scan_user(void) {
-    uint8_t layer = biton32(layer_state);
+  //
+  // Bit #            7     6     5     4     3     2     1     0
+  // layer_state: [     |     |     | _xF | _xN | _xS | _xQ | _xW ]
+  // usb_led      [     |     |     |kana |cmps |scrl |caps | num ]
+  // PORTB:       [  NC |  10 |   9 |   8 |  14 |  16 |  15 |rxled]
+  // PORTC:       [  NC |   5 |     |     |     |     |     |     ]
+  // PORTD:       [   6 |  NC |txled|   4 | tx* | rx* | grn | p29 ]
+  // PORTE:       [     |   7 |     |     |     |     |     |     ]
+  // PORTF:       [  a0 |  a1 | red | blu |     |     |  NC |  NC ]
+  //
+  // PD0 is connected to the pairing switch and p29 on the wireless module.
+  // PF0,PF1,PB7,PC7,PD6 are not broken out by the pro micro board. I don't understand why.
+  // PB1-PB6,PD4,PD5,PD6,PF6,PF7 are not connected to the Mitosis receiver
+  // board. Each may be connected to an LED by way of a resistor (4.7k to
+  // match the others) for a total of 14 additional indicators.
 
 
-    switch (layer) {
-        case _WORKMAN:
-            red_led_off;
-            grn_led_off;
-            break;
-        case _FUNC:
-            red_led_off;
-            grn_led_on;
-            break;
-        case _NUMS:
-            red_led_on;
-            grn_led_off;
-            break;
-        case _NMFN:
-            red_led_on;
-            grn_led_on;
-            break;
-        default:
-            break;
-    }
-};
+  // A simple (but technically inaccurate) model of the momentary layer state:
+  // Fn1 key makes _xS active; indicator = red
+  // Fn2 key makes _xN active; indicator = blue
+  // Both keys make _xF active; indicator = purple
+  // Toggling QWERTY mode makes indicator include green, so (red/blue/purple becomes yellow/cyan/white)
+
+  // negated because for ports 0=LED on.
+  uint32_t portf_bits = ~(layer_state|layer_state<<1|(layer_state&0b100)<<3);
+  setbits(PORTF, portf_bits, 0b00110000);
+  setbits(PORTD, ~layer_state, 0b00000010);
+}
+
+// vim: set sw=2 et:
diff --git a/keyboards/mitosis/keymaps/datagrok/readme.md b/keyboards/mitosis/keymaps/datagrok/readme.md
new file mode 100644 (file)
index 0000000..a5b7b6c
--- /dev/null
@@ -0,0 +1,74 @@
+![mitosis:datagrok layout image](https://i.imgur.com/Lt0t0nq.png)
+
+[Keyboard layout editor source](http://www.keyboard-layout-editor.com/#/gists/e1a6a7a480fd4984c0bed38ee35f6c4f)
+
+# a layout for the Mitosis
+
+- Emphasis on momentary modifiers, all usable from either hand, arranged
+  symmetrically, but distinguishable left/right by the OS. Shift, Fn1
+  ("Lower"), Fn2 ("Raise"), Super ("Windows"), Meta ("Alt"), Hyper.
+
+- Fn1 and Fn2 are used to momentary-enable (like a shift key) one of three layers:
+
+    - Fn1 (Red): Symbols layer
+    - Fn2 (Blue): Numbers layer
+    - Both: Functions layer
+
+- The base layer is a slight variant of [Workman][]. QWERTY may be toggled-on.
+
+- Paired programming symbols (braces, brackets, parentheses) are arranged
+  symmetrically in the symbols layer. `?` and `!` are moved to take the place
+  of `<` and `>`.
+
+- No OS keymap modification required.
+
+## Design notes
+
+- **I use an 8Mhz Pro Micro.** If you want to use this keymap with the standard
+  16Mhz Pro Micro specified in the Mitosis design:
+
+    - Remove the lines in `rules.mk` mentioning `F_CPU` and `F_USB`.
+    - Remove the lines in `config.h` mentioning `SERIAL_UART_BAUD`.
+
+- I'm learning a new key placement, so might as well go all out and use an
+  optimal non-QWERTY layout.
+
+- I like the way Workman feels and some of its advantages over Colemak.
+  Unfortunately, it was designed using a weighting system based on a standard
+  column-staggered keyboard so is probably not as optimal as one could achieve
+  on an ergonomic board like the Mitosis.
+
+- Arrows in the home position (on a layer). Mod+Arrows = PgUp/PgDn/Home/End,
+  which is intuitive for me
+
+### Abandoned ideas
+
+- ~~"Since QWERTY and Workman keep angle brackets together, place other
+  enclosing symbols on the same keys. This informs the numbers placement,
+  which informs the function-key placement."~~
+
+    - I tried this and it was bad. I don't like having to pick the right
+      modifier to get the right flavor of bracket. Instead, now, one modifier
+      activates a symbols layer where all brackets are easily accessible.
+
+- Space/Enter to the left of layer select for Enter doesn't work well; I always
+  trigger space first.
+
+- I used to have Blue layer on ring finger, but that was too hard to use in
+  conjunction with shift.
+
+## To do
+
+- Improve LED indications (may require modding bluetooth firmware):
+    - Is any board nonresponsive (which one?)
+    - Does either board have a low battery?
+- Add Insert, PrintScr, Pause/Break
+- Make QWERTY base layer for people who customize layout in software? Store
+  default base layer in eeprom?
+- See if the henkans placement is at all useful for Japanese speakers, or abuse
+  different keysyms
+- Mod a speaker onto my receiver and enable tones
+- Implement "layer lock" key
+- Improve tri-layer behavior
+
+[Workman]: https://viralintrospection.wordpress.com/2010/09/06/a-different-philosophy-in-designing-keyboard-layouts/
diff --git a/keyboards/mitosis/keymaps/datagrok/rules.mk b/keyboards/mitosis/keymaps/datagrok/rules.mk
new file mode 100644 (file)
index 0000000..7678072
--- /dev/null
@@ -0,0 +1,15 @@
+# I use an 8Mhz Pro Micro
+F_CPU = 8000000
+# Necessary, with above change?
+F_USB = $(F_CPU)
+
+BOOTMAGIC_ENABLE = no  # Virtual DIP switch configuration(+1000)
+MOUSEKEY_ENABLE = no   # 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
+UNICODE_ENABLE = no    # Unicode
+BACKLIGHT_ENABLE = no  # Enable keyboard backlight functionality
+BLUETOOTH_ENABLE = no  # Enable Bluetooth with the Adafruit EZ-Key HID
+MIDI_ENABLE = no       # MIDI controls
+# vim: set ts=8 noet: