diff options
Diffstat (limited to 'keyboards/iris')
-rw-r--r-- | keyboards/iris/keymaps/mtdjr/config.h | 42 | ||||
-rw-r--r-- | keyboards/iris/keymaps/mtdjr/keymap.c | 307 | ||||
-rw-r--r-- | keyboards/iris/keymaps/mtdjr/rules.mk | 7 |
3 files changed, 356 insertions, 0 deletions
diff --git a/keyboards/iris/keymaps/mtdjr/config.h b/keyboards/iris/keymaps/mtdjr/config.h new file mode 100644 index 0000000000..0e8938775f --- /dev/null +++ b/keyboards/iris/keymaps/mtdjr/config.h @@ -0,0 +1,42 @@ +/* +Copyright 2017 Danny Nguyen <danny@hexwire.com> + +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/>. +*/ + +#ifndef CONFIG_USER_H +#define CONFIG_USER_H + +#include "config_common.h" + +/* Use I2C or Serial, not both */ + +#define USE_SERIAL +//#define USE_I2C + +/* Select hand configuration */ + +#define MASTER_LEFT +#define TAPPING_TERM 250 +// #define MASTER_RIGHT +// #define EE_HANDS + +// #undef RGBLED_NUM +// #define RGBLIGHT_ANIMATIONS +// #define RGBLED_NUM 12 +// #define RGBLIGHT_HUE_STEP 8 +// #define RGBLIGHT_SAT_STEP 8 +// #define RGBLIGHT_VAL_STEP 8 + +#endif diff --git a/keyboards/iris/keymaps/mtdjr/keymap.c b/keyboards/iris/keymaps/mtdjr/keymap.c new file mode 100644 index 0000000000..ba95d16b23 --- /dev/null +++ b/keyboards/iris/keymaps/mtdjr/keymap.c @@ -0,0 +1,307 @@ +#include "iris.h" +#include "action_layer.h" +#include "eeconfig.h" +#include "action_macro.h" +#include <timer.h> +#include "pincontrol.h" + +extern keymap_config_t keymap_config; + +#define _QWERTY 0 +#define _LOWER 1 +#define _RAISE 2 +#define _SUPER 3 +#define _ADJUST 16 +#define SOLENOID_DEFAULT_DWELL 12 +#define SOLENOID_MAX_DWELL 100 +#define SOLENOID_MIN_DWELL 4 +#define SOLENOID_PIN C6 + + +bool solenoid_enabled = false; +bool solenoid_on = false; +bool solenoid_buzz = false; +bool solenoid_buzzing = false; +uint16_t solenoid_start = 0; +uint8_t solenoid_dwell = SOLENOID_DEFAULT_DWELL; + + +void solenoid_buzz_on(void) { + solenoid_buzz = true; +} + +void solenoid_buzz_off(void) { + solenoid_buzz = false; +} + +void solenoid_dwell_minus(void) { + if (solenoid_dwell > 0) solenoid_dwell--; +} + +void solenoid_dwell_plus(void) { + if (solenoid_dwell < SOLENOID_MAX_DWELL) solenoid_dwell++; +} + +void solenoid_toggle(void) { + solenoid_enabled = !solenoid_enabled; +} + +void solenoid_stop(void) { + digitalWrite(SOLENOID_PIN, PinLevelLow); + solenoid_on = false; + solenoid_buzzing = false; +} + +void solenoid_fire(void) { + if (!solenoid_enabled) return; + + if (!solenoid_buzz && solenoid_on) return; + if (solenoid_buzz && solenoid_buzzing) return; + + solenoid_on = true; + solenoid_buzzing = true; + solenoid_start = timer_read(); + digitalWrite(SOLENOID_PIN, PinLevelHigh); +} + +void solenoid_check(void) { + uint16_t elapsed = 0; + + if (!solenoid_on) return; + + elapsed = timer_elapsed(solenoid_start); + + //Check if it's time to finish this solenoid click cycle + if (elapsed > solenoid_dwell) { + solenoid_stop(); + return; + } + + //Check whether to buzz the solenoid on and off + if (solenoid_buzz) { + if (elapsed / SOLENOID_MIN_DWELL % 2 == 0){ + if (!solenoid_buzzing) { + solenoid_buzzing = true; + digitalWrite(SOLENOID_PIN, PinLevelHigh); + } + } + else { + if (solenoid_buzzing) { + solenoid_buzzing = false; + digitalWrite(SOLENOID_PIN, PinLevelLow); + } + } + } +} + +void solenoid_setup(void) { + pinMode(SOLENOID_PIN, PinDirectionOutput); +} + +void matrix_init_user(void) { + solenoid_setup(); +} + +void matrix_scan_user(void) { + solenoid_check(); +} + + +enum custom_keycodes { + QWERTY = SAFE_RANGE, + LOWER, + RAISE, + SUPER, + ADJUST, + SOL_TOG, + SOLENOID_DWELL_MINUS, + SOLENOID_DWELL_PLUS, + SOLENOID_BUZZ_ON, + SOLENOID_BUZZ_OFF, + TD_ESC = 0, +}; + +#define KC_ KC_TRNS +#define _______ KC_TRNS + +#define KC_LOWR LOWER +#define KC_RASE RAISE +#define KC_SUPR SUPER +#define KC_RST RESET +#define KC_BL_S BL_STEP +#define KC_EXC TD(TD_ESC) +#define SOLTOG SOLENOID_TOG + +// Macro Declarations +#define UM_ROOT M(0) +#define UM_PPLY M(1) +#define UM_PSEF M(2) +#define KC_XCPY M(3) +#define KC_XINS M(4) +#define UM_CAD M(5) + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + + [_QWERTY] = LAYOUT_kc( + //,----+----+----+----+----+----. ,----+----+----+----+----+----. + EXC , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 ,BSPC, + //|----+----+----+----+----+----| |----+----+----+----+----+----| + TAB , Q , W , E , R , T , Y , U , I , O , P ,QUOT, + //|----+----+----+----+----+----| |----+----+----+----+----+----| + LSFT, A , S , D , F , G , H , J , K , L ,SCLN,ENT , + //|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----| + EQL, Z , X , C , V , B ,LGUI, LALT, N , M ,COMM,DOT ,SLSH,MINS, + //`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----' + LCTL,RASE,SPC , SPC ,LOWR,SUPR + // `----+----+----' `----+----+----' + ), + + [_LOWER] = LAYOUT_kc( + //,----+----+----+----+----+----. ,----+----+----+----+----+----. + , , , , , , , , ,LCBR,RCBR,DEL , + //|----+----+----+----+----+----| |----+----+----+----+----+----| + , , , , , , , , UP , , ,PIPE, + //|----+----+----+----+----+----| |----+----+----+----+----+----| + , , , , , , ,LEFT,DOWN,RGHT, , , + //|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----| + , , , , , , , , ,HOME, ,END , ,EQL , + //`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----' + , , , , , + // `----+----+----' `----+----+----' + ), + + [_RAISE] = LAYOUT_kc( + //,----+----+----+----+----+----. ,----+----+----+----+----+----. + , F1 , F2 , F3 , F4 , , , , ,LBRC,RBRC,DEL , + //|----+----+----+----+----+----| |----+----+----+----+----+----| + , F5 , F6 , F7 , F8 , , , , , , ,BSLS, + //|----+----+----+----+----+----| |----+----+----+----+----+----| + , F9 ,F10 ,F11 ,F12 , , , , , , , , + //|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----| + , , ,XCPY,XINS, , , , , , , , ,PLUS, + //`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----' + , , , , , + // `----+----+----' `----+----+----' + ), + + [_SUPER] = LAYOUT( + //,--------+--------+--------+--------+--------+--------. ,--------+--------+--------+--------+--------+--------. + SOL_TOG, UM_ROOT, UM_PPLY, UM_PSEF, _______, _______, _______, _______, _______, _______, _______, _______, + //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| + _______, _______, _______, _______, _______, _______, _______, KC_LBRC, _______, _______, _______, _______, + //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, UM_CAD , + //|--------+--------+--------+--------+--------+--------+--------. ,--------|--------+--------+--------+--------+--------+--------| + _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MUTE, KC_VOLD, KC_VOLU, KC_MNXT, KC_MPLY, + //`--------+--------+--------+----+---+--------+--------+--------/ \--------+--------+--------+---+----+--------+--------+--------' + _______, _______, _______, _______, _______, _______ + // `--------+--------+--------' `--------+--------+--------' +) + +}; + +void persistent_default_layer_set(uint16_t default_layer) { + eeconfig_update_default_layer(default_layer); + default_layer_set(default_layer); +} + +qk_tap_dance_action_t tap_dance_actions[] = { + //Tap once for grave accent, twice for ESC + [TD_ESC] = ACTION_TAP_DANCE_DOUBLE(KC_GRV, KC_ESC) +}; + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + if (record->event.pressed) { + solenoid_fire(); + } + switch (keycode) { + case QWERTY: + if (record->event.pressed) { + persistent_default_layer_set(1UL<<_QWERTY); + } + return false; + break; + case LOWER: + if (record->event.pressed) { + layer_on(_LOWER); + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } else { + layer_off(_LOWER); + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } + return false; + break; + case RAISE: + if (record->event.pressed) { + layer_on(_RAISE); + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } else { + layer_off(_RAISE); + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } + return false; + break; + case SUPER: + if (record->event.pressed) { + layer_on(_SUPER); + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } else { + layer_off(_SUPER); + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } + return false; + break; + case SOLTOG: + if (record->event.pressed) { + solenoid_toggle(); + } + break; + case SOLENOID_DWELL_MINUS: + if (record->event.pressed) { + solenoid_dwell_minus(); + } + break; + case SOLENOID_DWELL_PLUS: + if (record->event.pressed) { + solenoid_dwell_plus(); + } + break; + case SOLENOID_BUZZ_ON: + if (record->event.pressed) { + solenoid_buzz_on(); + } + break; + case SOLENOID_BUZZ_OFF: + if (record->event.pressed) { + solenoid_buzz_off(); + } + break; + } + return true; +}; + +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { + if (record->event.pressed) { + switch(id) { + case 0: + SEND_STRING("sudo su -\n"); + return false; break; + case 1: + SEND_STRING("puppet apply /etc/puppetlabs/code/environments/production/manifests/site.pp\n"); + return false; break; + case 2: + SEND_STRING("ps -ef | grep "); + return false; break; + case 3: + return MACRO(D(LCTL), T(INS), U(LCTL), END); + break; + case 4: + return MACRO(D(LSFT), T(INS), U(LSFT), END); + break; + case 5: + return MACRO(D(LCTL), D(RALT), T(DEL), END); + break; + } + } + return MACRO_NONE; +}; diff --git a/keyboards/iris/keymaps/mtdjr/rules.mk b/keyboards/iris/keymaps/mtdjr/rules.mk new file mode 100644 index 0000000000..7c19013e5b --- /dev/null +++ b/keyboards/iris/keymaps/mtdjr/rules.mk @@ -0,0 +1,7 @@ +RGBLIGHT_ENABLE = no +BACKLIGHT_ENABLE = no +TAP_DANCE_ENABLE = no + +ifndef QUANTUM_DIR + include ../../../../Makefile +endif |