diff options
Diffstat (limited to 'users')
-rw-r--r-- | users/mtdjr/config.h | 7 | ||||
-rw-r--r-- | users/mtdjr/mtdjr.c | 137 | ||||
-rw-r--r-- | users/mtdjr/mtdjr.h | 76 | ||||
-rw-r--r-- | users/mtdjr/readme.md | 14 | ||||
-rw-r--r-- | users/mtdjr/rules.mk | 2 | ||||
-rw-r--r-- | users/mtdjr/solenoid.h | 103 |
6 files changed, 339 insertions, 0 deletions
diff --git a/users/mtdjr/config.h b/users/mtdjr/config.h new file mode 100644 index 000000000..9769ebc18 --- /dev/null +++ b/users/mtdjr/config.h @@ -0,0 +1,7 @@ +#ifndef USERSPACE_CONFIG_H +#define USERSPACE_CONFIG_H + +// Put normal config.h settings here: +#define TAPPING_TERM 250 + +#endif // !USERSPACE_CONFIG_H diff --git a/users/mtdjr/mtdjr.c b/users/mtdjr/mtdjr.c new file mode 100644 index 000000000..da4f57047 --- /dev/null +++ b/users/mtdjr/mtdjr.c @@ -0,0 +1,137 @@ +#include "mtdjr.h" + +#ifdef SOLENOID_ENABLE + #include "solenoid.h" + + void solenoid_buzz_on(void); + void solenoid_buzz_off(void); + void solenoid_dwell_minus(void); + void solenoid_dwell_plus(void); + void solenoid_toggle(void); + void solenoid_stop(void); + void solenoid_fire(void); + void solenoid_check(void); + void solenoid_setup(void); + void matrix_init_user(void); + void matrix_scan_user(void); +#endif + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + #ifdef SOLENOID_ENABLE + if (record->event.pressed) { + solenoid_fire(); + } + #endif + switch (keycode) { + case QWERTY: + if (record->event.pressed) { + set_single_persistent_default_layer(_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 ADJUST: + if (record->event.pressed) { + layer_on(_ADJUST); + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } else { + layer_off(_ADJUST); + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } + return false; + break; + case SOLENOID_TOG: + #ifdef SOLENOID_ENABLE + if (record->event.pressed) { + solenoid_toggle(); + } + #endif + break; + case SOLENOID_DWELL_MINUS: + #ifdef SOLENOID_ENABLE + if (record->event.pressed) { + solenoid_dwell_minus(); + } + #endif + break; + case SOLENOID_DWELL_PLUS: + #ifdef SOLENOID_ENABLE + if (record->event.pressed) { + solenoid_dwell_plus(); + } + #endif + break; + case SOLENOID_BUZZ_ON: + #ifdef SOLENOID_ENABLE + if (record->event.pressed) { + solenoid_buzz_on(); + } + #endif + break; + case SOLENOID_BUZZ_OFF: + #ifdef SOLENOID_ENABLE + if (record->event.pressed) { + solenoid_buzz_off(); + } + #endif + break; + } + return true; +}; + + +//Tap Dance Definitions +qk_tap_dance_action_t tap_dance_actions[] = { + [TD_ESC] = ACTION_TAP_DANCE_DOUBLE(KC_GRV, KC_ESC), + [TD_ALTLOCK] = ACTION_TAP_DANCE_DOUBLE(KC_RALT, LGUI(KC_L)), + [TD_ENDLOCK] = ACTION_TAP_DANCE_DOUBLE(KC_END, LGUI(KC_L)), + //[TD_PRNT] = ACTION_TAP_DANCE_DOUBLE(PRINT, PRINT_SEL) +}; + +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: // control + insert + return MACRO(D(LCTL), T(INS), U(LCTL), END); + break; + case 4: // shift + insert + return MACRO(D(LSFT), T(INS), U(LSFT), END); + break; + case 5: // control + alt + delete + return MACRO(D(LCTL), D(RALT), T(DEL), U(LCTL), U(LALT), END); + break; + case 6: // lgui + L + return MACRO(D(LGUI), T(L), U(LGUI), END); + break; + } + } + return MACRO_NONE; +}; diff --git a/users/mtdjr/mtdjr.h b/users/mtdjr/mtdjr.h new file mode 100644 index 000000000..012a35610 --- /dev/null +++ b/users/mtdjr/mtdjr.h @@ -0,0 +1,76 @@ +#ifndef USERSPACE +#define USERSPACE + +#include "quantum.h" + +#define _QWERTY 0 +#define _LOWER 1 +#define _RAISE 2 +#define _SUPER 3 +#define _ADJUST 16 + +enum user_layers { + QWERTY = SAFE_RANGE, + LOWER, + RAISE, + SUPER, + ADJUST, +}; + +enum user_tapdance { + TD_ENDLOCK, + TD_ALTLOCK, + TD_ESC, +}; + +enum user_solenoid { + SOLENOID_TOG, + SOLENOID_DWELL_MINUS, + SOLENOID_DWELL_PLUS, + SOLENOID_BUZZ_ON, + SOLENOID_BUZZ_OFF, +}; + +#define KC_STOG SOLENOID_TOG +#define KC_SDM SOLENOID_DWELL_MINUS +#define KC_SDP SOLENOID_DWELL_PLUS +#define KC_SBON SOLENOID_BUZZ_ON +#define KC_SBOF SOLENOID_BUZZ_OFF + +#define KC_ KC_TRNS +#define _______ KC_TRNS +#define XXXXXXX KC_NO +#define KC_xxxx KC_NO + +#define KC_LOWR LOWER +#define KC_RASE RAISE +#define KC_SUPR SUPER +#define KC_RST RESET + +// TapDance Keycodes +#define KC_EXC TD_ESC + +// Macro Declarations +#define KC_ROOT M(0) +#define KC_PPLY M(1) +#define KC_PSEF M(2) +#define KC_XCPY M(3) +#define KC_XINS M(4) +#define KC_CAD M(5) +#define UM_LOCK M(6) + +// RGB and Backlighting +#define KC_RGB RGB_TOG +#define KC_RHUI RGB_HUI +#define KC_RHUD RGB_HUD +#define KC_RSAI RGB_SAI +#define KC_RSAD RGB_SAD +#define KC_RVAI RGB_VAI +#define KC_RVAD RGB_VAD +#define KC_BLT BL_TOGG +#define KC_BLS BL_STEP +#define KC_BLI BL_INC +#define KC_BLD BL_DEC + + +#endif diff --git a/users/mtdjr/readme.md b/users/mtdjr/readme.md new file mode 100644 index 000000000..e795ee23a --- /dev/null +++ b/users/mtdjr/readme.md @@ -0,0 +1,14 @@ +Copyright 2018 @mtdjr + +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/>. diff --git a/users/mtdjr/rules.mk b/users/mtdjr/rules.mk new file mode 100644 index 000000000..6eec4b5b8 --- /dev/null +++ b/users/mtdjr/rules.mk @@ -0,0 +1,2 @@ +SRC += mtdjr.c +TAP_DANCE_ENABLE = yes diff --git a/users/mtdjr/solenoid.h b/users/mtdjr/solenoid.h new file mode 100644 index 000000000..38066f4c3 --- /dev/null +++ b/users/mtdjr/solenoid.h @@ -0,0 +1,103 @@ +#ifndef SOLENOID_H +#define SOLENOID_H + +#include <timer.h> +#include "pincontrol.h" + +#define SOLENOID_DEFAULT_DWELL 12 +#define SOLENOID_MAX_DWELL 100 +#define SOLENOID_MIN_DWELL 4 +#ifndef SOLENOID_ACTIVE + #define SOLENOID_ACTIVE false +#endif +//#define SOLENOID_PIN F6 + +bool solenoid_enabled = SOLENOID_ACTIVE; +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(); +} + +#endif |