aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormtdjr <mtdjr@users.noreply.github.com>2018-05-31 11:30:05 -0400
committerDrashna Jaelre <drashna@live.com>2018-05-31 08:30:05 -0700
commitee9a7aba396160929604aca54a23ad5534d59940 (patch)
treef4fbbde03ed548a68fd56bec5c6baf8cf217f180
parent21ad968ac14b177a7c97d34106c4d6201912627f (diff)
downloadqmk_firmware-ee9a7aba396160929604aca54a23ad5534d59940.tar.gz
qmk_firmware-ee9a7aba396160929604aca54a23ad5534d59940.zip
add not-so-minidox handwire keyboard (#3061)
* add not-so-minidox handwire keyboard * corrected keymap * multiple adjustments to not_so_minidox keyboard * remove I2C master left define * update default layer set function * move solenoid code into userspace * minor adjustments to config.h * update keymaps to utilize userspace * move features and config to userspace, correct build issue * correct solenoid pin * adjust defaults for solenoid pin and enable * default solenoid to on for not_so_minidox * disable RGBLIGHT_SLEEP for xd75 * tweaking solenoid enable/disable in userspace and keymaps
-rw-r--r--keyboards/handwired/not_so_minidox/config.h84
-rw-r--r--keyboards/handwired/not_so_minidox/i2c.c162
-rw-r--r--keyboards/handwired/not_so_minidox/i2c.h49
-rw-r--r--keyboards/handwired/not_so_minidox/keymaps/default/keymap.c121
-rw-r--r--keyboards/handwired/not_so_minidox/keymaps/mtdjr/config.h11
-rw-r--r--keyboards/handwired/not_so_minidox/keymaps/mtdjr/keymap.c56
-rw-r--r--keyboards/handwired/not_so_minidox/keymaps/mtdjr/rules.mk1
-rw-r--r--keyboards/handwired/not_so_minidox/matrix.c307
-rw-r--r--keyboards/handwired/not_so_minidox/not_so_minidox.c1
-rw-r--r--keyboards/handwired/not_so_minidox/not_so_minidox.h42
-rw-r--r--keyboards/handwired/not_so_minidox/readme.md71
-rw-r--r--keyboards/handwired/not_so_minidox/rules.mk71
-rw-r--r--keyboards/handwired/not_so_minidox/serial.c228
-rw-r--r--keyboards/handwired/not_so_minidox/serial.h26
-rw-r--r--keyboards/handwired/not_so_minidox/split_util.c84
-rw-r--r--keyboards/handwired/not_so_minidox/split_util.h20
-rw-r--r--keyboards/iris/keymaps/mtdjr/config.h5
-rw-r--r--keyboards/iris/keymaps/mtdjr/keymap.c278
-rw-r--r--keyboards/iris/keymaps/mtdjr/rules.mk1
-rw-r--r--keyboards/lets_split/keymaps/mtdjr/config.h4
-rw-r--r--keyboards/lets_split/keymaps/mtdjr/keymap.c263
-rw-r--r--keyboards/lets_split/keymaps/mtdjr/rules.mk1
-rw-r--r--keyboards/tada68/keymaps/mtdjr/keymap.c57
-rw-r--r--keyboards/xd75/keymaps/mtdjr/config.h3
-rw-r--r--keyboards/xd75/keymaps/mtdjr/keymap.c108
-rw-r--r--users/mtdjr/config.h7
-rw-r--r--users/mtdjr/mtdjr.c137
-rw-r--r--users/mtdjr/mtdjr.h76
-rw-r--r--users/mtdjr/readme.md14
-rw-r--r--users/mtdjr/rules.mk2
-rw-r--r--users/mtdjr/solenoid.h103
31 files changed, 1796 insertions, 597 deletions
diff --git a/keyboards/handwired/not_so_minidox/config.h b/keyboards/handwired/not_so_minidox/config.h
new file mode 100644
index 000000000..3c0af7bf7
--- /dev/null
+++ b/keyboards/handwired/not_so_minidox/config.h
@@ -0,0 +1,84 @@
1/*
2Copyright 2012 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#ifndef CONFIG_H
19#define CONFIG_H
20
21#include "config_common.h"
22
23/* USB Device descriptor parameter */
24#define VENDOR_ID 0xFEED
25#define PRODUCT_ID 0x3060
26#define DEVICE_VER 0x0001
27#define MANUFACTURER mtdjr
28#define PRODUCT Not So MiniDox
29#define DESCRIPTION A larger version of the MiniDox
30
31/* key matrix size */
32// Rows are doubled-up
33#define MATRIX_ROWS 8
34#define MATRIX_COLS 6
35
36/* COL2ROW or ROW2COL */
37#define DIODE_DIRECTION COL2ROW
38
39// wiring of each half
40#define MATRIX_ROW_PINS { D7, E6, B4, B5 }
41#define MATRIX_COL_PINS { B6, B2, B3, B1, F7, D4 }
42
43#define USE_SERIAL
44
45//#define EE_HANDS
46
47#define MASTER_LEFT
48//#define MASTER_RIGHT
49
50/* define if matrix has ghost */
51//#define MATRIX_HAS_GHOST
52
53/* number of backlight levels */
54// #define BACKLIGHT_LEVELS 3
55
56/* Set 0 if debouncing isn't needed */
57#define DEBOUNCING_DELAY 5
58
59/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
60#define LOCKING_SUPPORT_ENABLE
61/* Locking resynchronize hack */
62#define LOCKING_RESYNC_ENABLE
63
64/* key combination for command */
65#define IS_COMMAND() ( \
66 keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
67)
68
69/* disable debug print */
70//#define NO_DEBUG
71
72/* disable print */
73//#define NO_PRINT
74
75/* disable action features */
76//#define NO_ACTION_LAYER
77//#define NO_ACTION_TAPPING
78//#define NO_ACTION_ONESHOT
79//#define NO_ACTION_MACRO
80//#define NO_ACTION_FUNCTION
81
82
83
84#endif
diff --git a/keyboards/handwired/not_so_minidox/i2c.c b/keyboards/handwired/not_so_minidox/i2c.c
new file mode 100644
index 000000000..084c890c4
--- /dev/null
+++ b/keyboards/handwired/not_so_minidox/i2c.c
@@ -0,0 +1,162 @@
1#include <util/twi.h>
2#include <avr/io.h>
3#include <stdlib.h>
4#include <avr/interrupt.h>
5#include <util/twi.h>
6#include <stdbool.h>
7#include "i2c.h"
8
9#ifdef USE_I2C
10
11// Limits the amount of we wait for any one i2c transaction.
12// Since were running SCL line 100kHz (=> 10μs/bit), and each transactions is
13// 9 bits, a single transaction will take around 90μs to complete.
14//
15// (F_CPU/SCL_CLOCK) => # of μC cycles to transfer a bit
16// poll loop takes at least 8 clock cycles to execute
17#define I2C_LOOP_TIMEOUT (9+1)*(F_CPU/SCL_CLOCK)/8
18
19#define BUFFER_POS_INC() (slave_buffer_pos = (slave_buffer_pos+1)%SLAVE_BUFFER_SIZE)
20
21volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE];
22
23static volatile uint8_t slave_buffer_pos;
24static volatile bool slave_has_register_set = false;
25
26// Wait for an i2c operation to finish
27inline static
28void i2c_delay(void) {
29 uint16_t lim = 0;
30 while(!(TWCR & (1<<TWINT)) && lim < I2C_LOOP_TIMEOUT)
31 lim++;
32
33 // easier way, but will wait slightly longer
34 // _delay_us(100);
35}
36
37// Setup twi to run at 100kHz
38void i2c_master_init(void) {
39 // no prescaler
40 TWSR = 0;
41 // Set TWI clock frequency to SCL_CLOCK. Need TWBR>10.
42 // Check datasheets for more info.
43 TWBR = ((F_CPU/SCL_CLOCK)-16)/2;
44}
45
46// Start a transaction with the given i2c slave address. The direction of the
47// transfer is set with I2C_READ and I2C_WRITE.
48// returns: 0 => success
49// 1 => error
50uint8_t i2c_master_start(uint8_t address) {
51 TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTA);
52
53 i2c_delay();
54
55 // check that we started successfully
56 if ( (TW_STATUS != TW_START) && (TW_STATUS != TW_REP_START))
57 return 1;
58
59 TWDR = address;
60 TWCR = (1<<TWINT) | (1<<TWEN);
61
62 i2c_delay();
63
64 if ( (TW_STATUS != TW_MT_SLA_ACK) && (TW_STATUS != TW_MR_SLA_ACK) )
65 return 1; // slave did not acknowledge
66 else
67 return 0; // success
68}
69
70
71// Finish the i2c transaction.
72void i2c_master_stop(void) {
73 TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO);
74
75 uint16_t lim = 0;
76 while(!(TWCR & (1<<TWSTO)) && lim < I2C_LOOP_TIMEOUT)
77 lim++;
78}
79
80// Write one byte to the i2c slave.
81// returns 0 => slave ACK
82// 1 => slave NACK
83uint8_t i2c_master_write(uint8_t data) {
84 TWDR = data;
85 TWCR = (1<<TWINT) | (1<<TWEN);
86
87 i2c_delay();
88
89 // check if the slave acknowledged us
90 return (TW_STATUS == TW_MT_DATA_ACK) ? 0 : 1;
91}
92
93// Read one byte from the i2c slave. If ack=1 the slave is acknowledged,
94// if ack=0 the acknowledge bit is not set.
95// returns: byte read from i2c device
96uint8_t i2c_master_read(int ack) {
97 TWCR = (1<<TWINT) | (1<<TWEN) | (ack<<TWEA);
98
99 i2c_delay();
100 return TWDR;
101}
102
103void i2c_reset_state(void) {
104 TWCR = 0;
105}
106
107void i2c_slave_init(uint8_t address) {
108 TWAR = address << 0; // slave i2c address
109 // TWEN - twi enable
110 // TWEA - enable address acknowledgement
111 // TWINT - twi interrupt flag
112 // TWIE - enable the twi interrupt
113 TWCR = (1<<TWIE) | (1<<TWEA) | (1<<TWINT) | (1<<TWEN);
114}
115
116ISR(TWI_vect);
117
118ISR(TWI_vect) {
119 uint8_t ack = 1;
120 switch(TW_STATUS) {
121 case TW_SR_SLA_ACK:
122 // this device has been addressed as a slave receiver
123 slave_has_register_set = false;
124 break;
125
126 case TW_SR_DATA_ACK:
127 // this device has received data as a slave receiver
128 // The first byte that we receive in this transaction sets the location
129 // of the read/write location of the slaves memory that it exposes over
130 // i2c. After that, bytes will be written at slave_buffer_pos, incrementing
131 // slave_buffer_pos after each write.
132 if(!slave_has_register_set) {
133 slave_buffer_pos = TWDR;
134 // don't acknowledge the master if this memory loctaion is out of bounds
135 if ( slave_buffer_pos >= SLAVE_BUFFER_SIZE ) {
136 ack = 0;
137 slave_buffer_pos = 0;
138 }
139 slave_has_register_set = true;
140 } else {
141 i2c_slave_buffer[slave_buffer_pos] = TWDR;
142 BUFFER_POS_INC();
143 }
144 break;
145
146 case TW_ST_SLA_ACK:
147 case TW_ST_DATA_ACK:
148 // master has addressed this device as a slave transmitter and is
149 // requesting data.
150 TWDR = i2c_slave_buffer[slave_buffer_pos];
151 BUFFER_POS_INC();
152 break;
153
154 case TW_BUS_ERROR: // something went wrong, reset twi state
155 TWCR = 0;
156 default:
157 break;
158 }
159 // Reset everything, so we are ready for the next TWI interrupt
160 TWCR |= (1<<TWIE) | (1<<TWINT) | (ack<<TWEA) | (1<<TWEN);
161}
162#endif
diff --git a/keyboards/handwired/not_so_minidox/i2c.h b/keyboards/handwired/not_so_minidox/i2c.h
new file mode 100644
index 000000000..c15b6bc50
--- /dev/null
+++ b/keyboards/handwired/not_so_minidox/i2c.h
@@ -0,0 +1,49 @@
1#ifndef I2C_H
2#define I2C_H
3
4#include <stdint.h>
5
6#ifndef F_CPU
7#define F_CPU 16000000UL
8#endif
9
10#define I2C_READ 1
11#define I2C_WRITE 0
12
13#define I2C_ACK 1
14#define I2C_NACK 0
15
16#define SLAVE_BUFFER_SIZE 0x10
17
18// i2c SCL clock frequency
19#define SCL_CLOCK 400000L
20
21extern volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE];
22
23void i2c_master_init(void);
24uint8_t i2c_master_start(uint8_t address);
25void i2c_master_stop(void);
26uint8_t i2c_master_write(uint8_t data);
27uint8_t i2c_master_read(int);
28void i2c_reset_state(void);
29void i2c_slave_init(uint8_t address);
30
31
32static inline unsigned char i2c_start_read(unsigned char addr) {
33 return i2c_master_start((addr << 1) | I2C_READ);
34}
35
36static inline unsigned char i2c_start_write(unsigned char addr) {
37 return i2c_master_start((addr << 1) | I2C_WRITE);
38}
39
40// from SSD1306 scrips
41extern unsigned char i2c_rep_start(unsigned char addr);
42extern void i2c_start_wait(unsigned char addr);
43extern unsigned char i2c_readAck(void);
44extern unsigned char i2c_readNak(void);
45extern unsigned char i2c_read(unsigned char ack);
46
47#define i2c_read(ack) (ack) ? i2c_readAck() : i2c_readNak();
48
49#endif
diff --git a/keyboards/handwired/not_so_minidox/keymaps/default/keymap.c b/keyboards/handwired/not_so_minidox/keymaps/default/keymap.c
new file mode 100644
index 000000000..8ea36198a
--- /dev/null
+++ b/keyboards/handwired/not_so_minidox/keymaps/default/keymap.c
@@ -0,0 +1,121 @@
1#include QMK_KEYBOARD_H
2
3extern keymap_config_t keymap_config;
4
5// Each layer gets a name for readability, which is then used in the keymap matrix below.
6// The underscores don't mean anything - you can have a layer called STUFF or any other name.
7// Layer names don't all need to be of the same length, obviously, and you can also skip them
8// entirely and just use numbers.
9#define _QWERTY 0
10#define _LOWER 1
11#define _RAISE 2
12#define _ADJUST 16
13
14enum custom_keycodes {
15 QWERTY = SAFE_RANGE,
16 LOWER,
17 RAISE,
18 ADJUST,
19};
20
21// Fillers to make layering more clear
22#define _______ KC_TRNS
23#define XXXXXXX KC_NO
24
25#define KC_LOWR LOWER
26#define KC_RASE RAISE
27#define KC_RST RESET
28#define KC_CAD LCTL(LALT(KC_DEL))
29
30const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
31
32 [_QWERTY] = LAYOUT(
33// ,-------+-------+-------+-------+-------+-------. ,-------+-------+-------+-------+-------+-------.
34 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P,KC_BSPC,
35// |-------+-------+-------+-------+-------+-------. ,-------+-------+-------+-------+-------+-------|
36 KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L,KC_SCLN,KC_QUOT,
37// |-------+-------+-------+-------+-------+-------. ,-------+-------+-------+-------+-------+-------|
38 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M,KC_COMM, KC_DOT,KC_SLSH, KC_ENT,
39// '-------+-------+-------+-------+-------+-------. ,-------+-------+-------+-------+-------+-------'
40 KC_LGUI,KC_LOWR, KC_SPC, KC_SPC,KC_RASE,KC_RALT
41 // `-------+-------+-------` `-------+-------+-------`
42 ),
43
44 [_LOWER] = LAYOUT(
45// ,-------+-------+-------+-------+-------+-------. ,-------+-------+-------+-------+-------+-------.
46 KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL,
47// |-------+-------+-------+-------+-------+-------. ,-------+-------+-------+-------+-------+-------|
48 _______,_______,_______,_______,_______,_______, _______,_______,_______,KC_LCBR,KC_RCBR,KC_BSLS,
49// |-------+-------+-------+-------+-------+-------. ,-------+-------+-------+-------+-------+-------|
50 _______,_______,_______,_______,_______,_______, _______,_______,_______,_______,_______,_______,
51// '-------+-------+-------+-------+-------+-------. ,-------+-------+-------+-------+-------+-------'
52 _______,_______,_______, _______,_______,_______
53 // `-------+-------+-------` `-------+-------+-------`
54 ),
55
56 [_RAISE] = LAYOUT(
57 // ,-------+-------+-------+-------+-------+-------. ,-------+-------+-------+-------+-------+-------.
58 KC_GRV,KC_EXLM, KC_AT,KC_HASH, KC_DLR,KC_PERC, KC_CIRC,KC_AMPR,KC_ASTR,KC_LPRN,KC_RPRN, KC_DEL,
59 // |-------+-------+-------+-------+-------+-------. ,-------+-------+-------+-------+-------+-------|
60 _______,_______,_______,_______,KC_MINS, KC_EQL, _______, KC_UP,_______,KC_LBRC,KC_RBRC,KC_PIPE,
61 // |-------+-------+-------+-------+-------+-------. ,-------+-------+-------+-------+-------+-------|
62 _______,_______,_______,_______,_______,_______, KC_LEFT,KC_DOWN,KC_RGHT,_______,_______,_______,
63 // '-------+-------+-------+-------+-------+-------. ,-------+-------+-------+-------+-------+-------'
64 _______,_______,_______, _______,_______,_______
65 // `-------+-------+-------` `-------+-------+-------`
66 ),
67 [_ADJUST] = LAYOUT(
68// ,-------+-------+-------+-------+-------+-------. ,-------+-------+-------+-------+-------+-------.
69 _______,_______,_______,_______, KC_RST,_______, _______,_______,_______,_______,_______, KC_CAD,
70// |-------+-------+-------+-------+-------+-------. ,-------+-------+-------+-------+-------+-------|
71 _______,_______,_______,_______,_______,_______, _______,_______,_______,_______,_______,_______,
72// |-------+-------+-------+-------+-------+-------. ,-------+-------+-------+-------+-------+-------|
73 _______,_______,_______,_______,_______,_______, _______,_______,_______,_______,_______,_______,
74// '-------+-------+-------+-------+-------+-------. ,-------+-------+-------+-------+-------+-------'
75 _______,_______,_______, _______,_______,_______
76 // `-------+-------+-------` `-------+-------+-------`
77 )
78};
79
80
81bool process_record_user(uint16_t keycode, keyrecord_t *record) {
82 switch (keycode) {
83 case QWERTY:
84 if (record->event.pressed) {
85 set_single_persistent_default_layer(_QWERTY);
86 }
87 return false;
88 break;
89 case LOWER:
90 if (record->event.pressed) {
91 layer_on(_LOWER);
92 update_tri_layer(_LOWER, _RAISE, _ADJUST);
93 } else {
94 layer_off(_LOWER);
95 update_tri_layer(_LOWER, _RAISE, _ADJUST);
96 }
97 return false;
98 break;
99 case RAISE:
100 if (record->event.pressed) {
101 layer_on(_RAISE);
102 update_tri_layer(_LOWER, _RAISE, _ADJUST);
103 } else {
104 layer_off(_RAISE);
105 update_tri_layer(_LOWER, _RAISE, _ADJUST);
106 }
107 return false;
108 break;
109 case ADJUST:
110 if (record->event.pressed) {
111 layer_on(_ADJUST);
112 update_tri_layer(_LOWER, _RAISE, _ADJUST);
113 } else {
114 layer_off(_ADJUST);
115 update_tri_layer(_LOWER, _RAISE, _ADJUST);
116 }
117 return false;
118 break;
119 }
120 return true;
121}
diff --git a/keyboards/handwired/not_so_minidox/keymaps/mtdjr/config.h b/keyboards/handwired/not_so_minidox/keymaps/mtdjr/config.h
new file mode 100644
index 000000000..fa6151e10
--- /dev/null
+++ b/keyboards/handwired/not_so_minidox/keymaps/mtdjr/config.h
@@ -0,0 +1,11 @@
1#ifndef CONFIG_USER_H
2#define CONFIG_USER_H
3
4#include QMK_KEYBOARD_CONFIG_H
5
6#define SOLENOID_ENABLE
7#define SOLENOID_PIN F6
8#undef SOLENOID_ACTIVE
9#define SOLENOID_ACTIVE true
10
11#endif
diff --git a/keyboards/handwired/not_so_minidox/keymaps/mtdjr/keymap.c b/keyboards/handwired/not_so_minidox/keymaps/mtdjr/keymap.c
new file mode 100644
index 000000000..01c64d870
--- /dev/null
+++ b/keyboards/handwired/not_so_minidox/keymaps/mtdjr/keymap.c
@@ -0,0 +1,56 @@
1#include QMK_KEYBOARD_H
2#include "mtdjr.h"
3
4extern keymap_config_t keymap_config;
5
6#define KC_LOCK TD(TD_ALTLOCK)
7
8const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
9
10 [_QWERTY] = LAYOUT_kc(
11 // ,----+-----+-----+-----+-----+-----, ,----+-----+-----+-----+-----+-----,
12 TAB, Q, W, E, R, T, Y, U, I, O, P, BSPC,
13 // |----+-----+-----+-----+-----+-----| |----+-----+-----+-----+-----+-----|
14 LCTL, A, S, D, F, G, H, J, K, L, SCLN, QUOT,
15 // |----+-----+-----+-----+-----+-----| |----+-----+-----+-----+-----+-----|
16 LSFT, Z, X, C, V, B, N, M, COMM, DOT, SLSH, ENT,
17 // |----+-----+-----+-----+-----+-----|-, ,-|----+-----+-----+-----+-----+-----|
18 LGUI, LOWR, SPC, SPC, RASE, LOCK
19 // `----+-----+-----` `----+-----+-----`
20 ),
21
22 [_LOWER] = LAYOUT_kc(
23 // ,----+-----+-----+-----+-----+-----, ,----+-----+-----+-----+-----+-----,
24 ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, DEL,
25 // |----+-----+-----+-----+-----+-----| |----+-----+-----+-----+-----+-----|
26 , , , , , , , , , LCBR, RCBR, BSLS,
27 // |----+-----+-----+-----+-----+-----| |----+-----+-----+-----+-----+-----|
28 , , , XCPY, XINS, , , , , , , ,
29 // |----+-----+-----+-----+-----+-----|-, ,-|----+-----+-----+-----+-----+-----|
30 , , , , ,
31 // `----+-----+-----` `----+-----+-----`
32 ),
33
34 [_RAISE] = LAYOUT_kc(
35 // ,----+-----+-----+-----+-----+-----, ,----+-----+-----+-----+-----+-----,
36 GRV, EXLM, AT, HASH, DLR, PERC, CIRC, AMPR, ASTR, LPRN, RPRN, DEL,
37 // |----+-----+-----+-----+-----+-----| |----+-----+-----+-----+-----+-----|
38 , , , , MINS, EQL, , , UP, LBRC, RBRC, PIPE,
39 // |----+-----+-----+-----+-----+-----| |----+-----+-----+-----+-----+-----|
40 , , , , , , , LEFT, DOWN, RGHT, , ,
41 // |----+-----+-----+-----+-----+-----|-, ,-|----+-----+-----+-----+-----+-----|
42 , , , , ,
43 // `----+-----+-----` `----+-----+-----`
44 ),
45 [_ADJUST] = LAYOUT_kc(
46 // ,----+-----+-----+-----+-----+-----, ,----+-----+-----+-----+-----+-----,
47 STOG, xxxx, xxxx, xxxx, RST, xxxx, ROOT, PPLY, PSEF, xxxx, xxxx, CAD,
48 // |----+-----+-----+-----+-----+-----| |----+-----+-----+-----+-----+-----|
49 SDM, SDP, SBOF, SBON, xxxx, xxxx, xxxx, xxxx, xxxx, xxxx, xxxx, xxxx,
50 // |----+-----+-----+-----+-----+-----| |----+-----+-----+-----+-----+-----|
51 xxxx, xxxx, xxxx, xxxx, xxxx, xxxx, xxxx, xxxx, xxxx, xxxx, xxxx, xxxx,
52 // |----+-----+-----+-----+-----+-----|-, ,-|----+-----+-----+-----+-----+-----|
53 xxxx, , xxxx, xxxx, , xxxx
54 // `----+-----+-----` `----+-----+-----`
55 )
56};
diff --git a/keyboards/handwired/not_so_minidox/keymaps/mtdjr/rules.mk b/keyboards/handwired/not_so_minidox/keymaps/mtdjr/rules.mk
new file mode 100644
index 000000000..e5ddcae8d
--- /dev/null
+++ b/keyboards/handwired/not_so_minidox/keymaps/mtdjr/rules.mk
@@ -0,0 +1 @@
TAP_DANCE_ENABLE = yes
diff --git a/keyboards/handwired/not_so_minidox/matrix.c b/keyboards/handwired/not_so_minidox/matrix.c
new file mode 100644
index 000000000..27a38dca0
--- /dev/null
+++ b/keyboards/handwired/not_so_minidox/matrix.c
@@ -0,0 +1,307 @@
1/*
2Copyright 2012 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18/*
19 * scan matrix
20 */
21#include <stdint.h>
22#include <stdbool.h>
23#include <avr/io.h>
24#include <avr/wdt.h>
25#include <avr/interrupt.h>
26#include <util/delay.h>
27#include "print.h"
28#include "debug.h"
29#include "util.h"
30#include "matrix.h"
31#include "split_util.h"
32#include "pro_micro.h"
33#include "config.h"
34
35#ifdef USE_I2C
36# include "i2c.h"
37#else // USE_SERIAL
38# include "serial.h"
39#endif
40
41#ifndef DEBOUNCE
42# define DEBOUNCE 5
43#endif
44
45#define ERROR_DISCONNECT_COUNT 5
46
47static uint8_t debouncing = DEBOUNCE;
48static const int ROWS_PER_HAND = MATRIX_ROWS/2;
49static uint8_t error_count = 0;
50
51static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
52static const uint8_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
53
54/* matrix state(1:on, 0:off) */
55static matrix_row_t matrix[MATRIX_ROWS];
56static matrix_row_t matrix_debouncing[MATRIX_ROWS];
57
58static matrix_row_t read_cols(void);
59static void init_cols(void);
60static void unselect_rows(void);
61static void select_row(uint8_t row);
62
63
64__attribute__ ((weak))
65void matrix_init_kb(void) {
66 matrix_init_user();
67}
68
69__attribute__ ((weak))
70void matrix_scan_kb(void) {
71 matrix_scan_user();
72}
73
74__attribute__ ((weak))
75void matrix_init_user(void) {
76}
77
78__attribute__ ((weak))
79void matrix_scan_user(void) {
80}
81
82inline
83uint8_t matrix_rows(void)
84{
85 return MATRIX_ROWS;
86}
87
88inline
89uint8_t matrix_cols(void)
90{
91 return MATRIX_COLS;
92}
93
94void matrix_init(void)
95{
96 debug_enable = true;
97 debug_matrix = true;
98 debug_mouse = true;
99 // initialize row and col
100 unselect_rows();
101 init_cols();
102
103 TX_RX_LED_INIT;
104
105 // initialize matrix state: all keys off
106 for (uint8_t i=0; i < MATRIX_ROWS; i++) {
107 matrix[i] = 0;
108 matrix_debouncing[i] = 0;
109 }
110
111 matrix_init_quantum();
112}
113
114uint8_t _matrix_scan(void)
115{
116 // Right hand is stored after the left in the matirx so, we need to offset it
117 int offset = isLeftHand ? 0 : (ROWS_PER_HAND);
118
119 for (uint8_t i = 0; i < ROWS_PER_HAND; i++) {
120 select_row(i);
121 _delay_us(30); // without this wait read unstable value.
122 matrix_row_t cols = read_cols();
123 if (matrix_debouncing[i+offset] != cols) {
124 matrix_debouncing[i+offset] = cols;
125 debouncing = DEBOUNCE;
126 }
127 unselect_rows();
128 }
129
130 if (debouncing) {
131 if (--debouncing) {
132 _delay_ms(1);
133 } else {
134 for (uint8_t i = 0; i < ROWS_PER_HAND; i++) {
135 matrix[i+offset] = matrix_debouncing[i+offset];
136 }
137 }
138 }
139
140 return 1;
141}
142
143#ifdef USE_I2C
144
145// Get rows from other half over i2c
146int i2c_transaction(void) {
147 int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
148
149 int err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_WRITE);
150 if (err) goto i2c_error;
151
152 // start of matrix stored at 0x00
153 err = i2c_master_write(0x00);
154 if (err) goto i2c_error;
155
156 // Start read
157 err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_READ);
158 if (err) goto i2c_error;
159
160 if (!err) {
161 int i;
162 for (i = 0; i < ROWS_PER_HAND-1; ++i) {
163 matrix[slaveOffset+i] = i2c_master_read(I2C_ACK);
164 }
165 matrix[slaveOffset+i] = i2c_master_read(I2C_NACK);
166 i2c_master_stop();
167 } else {
168i2c_error: // the cable is disconnceted, or something else went wrong
169 i2c_reset_state();
170 return err;
171 }
172
173 return 0;
174}
175
176#else // USE_SERIAL
177
178int serial_transaction(void) {
179 int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
180
181 if (serial_update_buffers()) {
182 return 1;
183 }
184
185 for (int i = 0; i < ROWS_PER_HAND; ++i) {
186 matrix[slaveOffset+i] = serial_slave_buffer[i];
187 }
188 return 0;
189}
190#endif
191
192uint8_t matrix_scan(void)
193{
194 int ret = _matrix_scan();
195
196
197
198#ifdef USE_I2C
199 if( i2c_transaction() ) {
200#else // USE_SERIAL
201 if( serial_transaction() ) {
202#endif
203 // turn on the indicator led when halves are disconnected
204 TXLED1;
205
206 error_count++;
207
208 if (error_count > ERROR_DISCONNECT_COUNT) {
209 // reset other half if disconnected
210 int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
211 for (int i = 0; i < ROWS_PER_HAND; ++i) {
212 matrix[slaveOffset+i] = 0;
213 }
214 }
215 } else {
216 // turn off the indicator led on no error
217 TXLED0;
218 error_count = 0;
219 }
220 matrix_scan_quantum();
221 return ret;
222}
223
224void matrix_slave_scan(void) {
225 _matrix_scan();
226
227 int offset = (isLeftHand) ? 0 : (MATRIX_ROWS / 2);
228
229#ifdef USE_I2C
230 for (int i = 0; i < ROWS_PER_HAND; ++i) {
231 /* i2c_slave_buffer[i] = matrix[offset+i]; */
232 i2c_slave_buffer[i] = matrix[offset+i];
233 }
234#else // USE_SERIAL
235 for (int i = 0; i < ROWS_PER_HAND; ++i) {
236 serial_slave_buffer[i] = matrix[offset+i];
237 }
238#endif
239}
240
241bool matrix_is_modified(void)
242{
243 if (debouncing) return false;
244 return true;
245}
246
247inline
248bool matrix_is_on(uint8_t row, uint8_t col)
249{
250 return (matrix[row] & ((matrix_row_t)1<<col));
251}
252
253inline
254matrix_row_t matrix_get_row(uint8_t row)
255{
256 return matrix[row];
257}
258
259void matrix_print(void)
260{
261 print("\nr/c 0123456789ABCDEF\n");
262 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
263 phex(row); print(": ");
264 pbin_reverse16(matrix_get_row(row));
265 print("\n");
266 }
267}
268
269uint8_t matrix_key_count(void)
270{
271 uint8_t count = 0;
272 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
273 count += bitpop16(matrix[i]);
274 }
275 return count;
276}
277
278static void init_cols(void)
279{
280 for(int x = 0; x < MATRIX_COLS; x++) {
281 _SFR_IO8((col_pins[x] >> 4) + 1) &= ~_BV(col_pins[x] & 0xF);
282 _SFR_IO8((col_pins[x] >> 4) + 2) |= _BV(col_pins[x] & 0xF);
283 }
284}
285
286static matrix_row_t read_cols(void)
287{
288 matrix_row_t result = 0;
289 for(int x = 0; x < MATRIX_COLS; x++) {
290 result |= (_SFR_IO8(col_pins[x] >> 4) & _BV(col_pins[x] & 0xF)) ? 0 : (1 << x);
291 }
292 return result;
293}
294
295static void unselect_rows(void)
296{
297 for(int x = 0; x < ROWS_PER_HAND; x++) {
298 _SFR_IO8((row_pins[x] >> 4) + 1) &= ~_BV(row_pins[x] & 0xF);
299 _SFR_IO8((row_pins[x] >> 4) + 2) |= _BV(row_pins[x] & 0xF);
300 }
301}
302
303static void select_row(uint8_t row)
304{
305 _SFR_IO8((row_pins[row] >> 4) + 1) |= _BV(row_pins[row] & 0xF);
306 _SFR_IO8((row_pins[row] >> 4) + 2) &= ~_BV(row_pins[row] & 0xF);
307}
diff --git a/keyboards/handwired/not_so_minidox/not_so_minidox.c b/keyboards/handwired/not_so_minidox/not_so_minidox.c
new file mode 100644
index 000000000..898c9eaca
--- /dev/null
+++ b/keyboards/handwired/not_so_minidox/not_so_minidox.c
@@ -0,0 +1 @@
#include "not_so_minidox.h" \ No newline at end of file
diff --git a/keyboards/handwired/not_so_minidox/not_so_minidox.h b/keyboards/handwired/not_so_minidox/not_so_minidox.h
new file mode 100644
index 000000000..05e7bc491
--- /dev/null
+++ b/keyboards/handwired/not_so_minidox/not_so_minidox.h
@@ -0,0 +1,42 @@
1#ifndef NOSOTMINIDOX_H
2#define NOSOTMINIDOX_H
3
4
5#include "quantum.h"
6
7#define LAYOUT( \
8 L00, L01, L02, L03, L04, L05, R05, R04, R03, R02, R01, R00, \
9 L10, L11, L12, L13, L14, L15, R15, R14, R13, R12, R11, R10, \
10 L20, L21, L22, L23, L24, L25, R25, R24, R23, R22, R21, R20, \
11 LT1, LT2, LT3, RT3, RT2, RT1 \
12 ) \
13 { \
14 { L00, L01, L02, L03, L04, L05 }, \
15 { L10, L11, L12, L13, L14, L15 }, \
16 { L20, L21, L22, L23, L24, L25 }, \
17 { KC_NO, KC_NO, KC_NO, LT1, LT2, LT3 }, \
18 { R00, R01, R02, R03, R04, R05 }, \
19 { R10, R11, R12, R13, R14, R15 }, \
20 { R20, R21, R22, R23, R24, R25 }, \
21 { KC_NO, KC_NO, KC_NO, RT1, RT2, RT3 }, \
22 }
23
24// Used to create a keymap using only KC_ prefixed keys
25#define LAYOUT_kc( \
26 L00, L01, L02, L03, L04, L05, R05, R04, R03, R02, R01, R00, \
27 L10, L11, L12, L13, L14, L15, R15, R14, R13, R12, R11, R10, \
28 L20, L21, L22, L23, L24, L25, R25, R24, R23, R22, R21, R20, \
29 LT1, LT2, LT3, RT3, RT2, RT1 \
30 ) \
31 { \
32 { KC_##L00, KC_##L01, KC_##L02, KC_##L03, KC_##L04, KC_##L05 }, \
33 { KC_##L10, KC_##L11, KC_##L12, KC_##L13, KC_##L14, KC_##L15 }, \
34 { KC_##L20, KC_##L21, KC_##L22, KC_##L23, KC_##L24, KC_##L25 }, \
35 { KC_NO, KC_NO, KC_NO, KC_##LT1, KC_##LT2, KC_##LT3 }, \
36 { KC_##R00, KC_##R01, KC_##R02, KC_##R03, KC_##R04, KC_##R05 }, \
37 { KC_##R10, KC_##R11, KC_##R12, KC_##R13, KC_##R14, KC_##R15 }, \
38 { KC_##R20, KC_##R21, KC_##R22, KC_##R23, KC_##R24, KC_##R25 }, \
39 { KC_NO, KC_NO, KC_NO, KC_##RT1, KC_##RT2, KC_##RT3 }, \
40 }
41
42#endif
diff --git a/keyboards/handwired/not_so_minidox/readme.md b/keyboards/handwired/not_so_minidox/readme.md
new file mode 100644
index 000000000..fbfa7b7be
--- /dev/null
+++ b/keyboards/handwired/not_so_minidox/readme.md
@@ -0,0 +1,71 @@
1not_so_minidox
2=====
3
4![not_so_minidox]()
5
6A slightly larger version of the MiniDox
7
8Keyboard Maintainer: mtdjr
9Hardware Supported: None yet/ProMicro
10
11Make example for this keyboard (after setting up your build environment):
12
13 make not_so_minidox/rev1:default
14
15See [build environment setup](https://docs.qmk.fm/build_environment_setup.html) then the [make instructions](https://docs.qmk.fm/make_instructions.html) for more information.
16
17Flashing
18-------
19Note: Most of this is copied from the Let's Split readme, because it is awesome
20
21From the root directory run `make PROJECT:KEYMAP:avrdude` for automatic serial port resolution and flashing.
22Example: `make not_so_minidox/rev1:default:avrdude`
23
24Choosing which board to plug the USB cable into (choosing Master)
25--------
26Because the two boards are identical, the firmware has logic to differentiate the left and right board.
27
28It uses two strategies to figure things out: look at the EEPROM (memory on the chip) or looks if the current board has the usb cable.
29
30The EEPROM approach requires additional setup (flashing the eeeprom) but allows you to swap the usb cable to either side.
31
32The USB cable approach is easier to setup and if you just want the usb cable on the left board, you do not need to do anything extra.
33
34### Setting the left hand as master
35If you always plug the usb cable into the left board, nothing extra is needed as this is the default. Comment out `EE_HANDS` and comment out `I2C_MASTER_RIGHT` or `MASTER_RIGHT` if for some reason it was set.
36
37### Setting the right hand as master
38If you always plug the usb cable into the right board, add an extra flag to your `config.h`
39```
40 #define MASTER_RIGHT
41```
42
43### Setting EE_hands to use either hands as master
44If you define `EE_HANDS` in your `config.h`, you will need to set the
45EEPROM for the left and right halves.
46
47The EEPROM is used to store whether the
48half is left handed or right handed. This makes it so that the same firmware
49file will run on both hands instead of having to flash left and right handed
50versions of the firmware to each half. To flash the EEPROM file for the left
51half run:
52```
53avrdude -p atmega32u4 -P $(COM_PORT) -c avr109 -U eeprom:w:eeprom-lefthand.eep
54// or the equivalent in dfu-programmer
55
56```
57and similarly for right half
58```
59avrdude -p atmega32u4 -P $(COM_PORT) -c avr109 -U eeprom:w:eeprom-righhand.eep
60// or the equivalent in dfu-programmer
61```
62
63NOTE: replace `$(COM_PORT)` with the port of your device (e.g. `/dev/ttyACM0`)
64
65After you have flashed the EEPROM, you then need to set `EE_HANDS` in your config.h, rebuild the hex files and reflash.
66
67Note that you need to program both halves, but you have the option of using
68different keymaps for each half. You could program the left half with a QWERTY
69layout and the right half with a Colemak layout using bootmagic's default layout option.
70Then if you connect the left half to a computer by USB the keyboard will use QWERTY and Colemak when the
71right half is connected.
diff --git a/keyboards/handwired/not_so_minidox/rules.mk b/keyboards/handwired/not_so_minidox/rules.mk
new file mode 100644
index 000000000..fe4cc014e
--- /dev/null
+++ b/keyboards/handwired/not_so_minidox/rules.mk
@@ -0,0 +1,71 @@
1SRC += matrix.c \
2 i2c.c \
3 split_util.c \
4 serial.c
5
6# MCU name
7#MCU = at90usb1287
8MCU = atmega32u4
9
10# Processor frequency.
11# This will define a symbol, F_CPU, in all source code files equal to the
12# processor frequency in Hz. You can then use this symbol in your source code to
13# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
14# automatically to create a 32-bit value in your source code.
15#
16# This will be an integer division of F_USB below, as it is sourced by
17# F_USB after it has run through any CPU prescalers. Note that this value
18# does not *change* the processor frequency - it should merely be updated to
19# reflect the processor speed set externally so that the code can use accurate
20# software delays.
21F_CPU = 16000000
22
23#
24# LUFA specific
25#
26# Target architecture (see library "Board Types" documentation).
27ARCH = AVR8
28
29# Input clock frequency.
30# This will define a symbol, F_USB, in all source code files equal to the
31# input clock frequency (before any prescaling is performed) in Hz. This value may
32# differ from F_CPU if prescaling is used on the latter, and is required as the
33# raw input clock is fed directly to the PLL sections of the AVR for high speed
34# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
35# at the end, this will be done automatically to create a 32-bit value in your
36# source code.
37#
38# If no clock division is performed on the input clock inside the AVR (via the
39# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
40F_USB = $(F_CPU)
41
42# Bootloader
43# This definition is optional, and if your keyboard supports multiple bootloaders of
44# different sizes, comment this out, and the correct address will be loaded
45# automatically (+60). See bootloader.mk for all options.
46BOOTLOADER = caterina
47
48# Interrupt driven control endpoint task(+60)
49OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
50
51# Build Options
52# change to "no" to disable the options, or define them in the Makefile in
53# the appropriate keymap folder that will get included automatically
54#
55BOOTMAGIC_ENABLE ?= no # Virtual DIP switch configuration(+1000)
56MOUSEKEY_ENABLE ?= yes # Mouse keys(+4700)
57EXTRAKEY_ENABLE ?= no # Audio control and System control(+450)
58CONSOLE_ENABLE ?= no # Console for debug(+400)
59COMMAND_ENABLE ?= yes # Commands for debug and configuration
60NKRO_ENABLE ?= no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
61BACKLIGHT_ENABLE ?= no # Enable keyboard backlight functionality
62MIDI_ENABLE ?= no # MIDI controls
63AUDIO_ENABLE ?= no # Audio output on port C6
64UNICODE_ENABLE ?= no # Unicode
65BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID
66RGBLIGHT_ENABLE ?= no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time.
67USE_I2C ?= no
68# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
69SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend
70
71CUSTOM_MATRIX = yes
diff --git a/keyboards/handwired/not_so_minidox/serial.c b/keyboards/handwired/not_so_minidox/serial.c
new file mode 100644
index 000000000..74bcbb6bf
--- /dev/null
+++ b/keyboards/handwired/not_so_minidox/serial.c
@@ -0,0 +1,228 @@
1/*
2 * WARNING: be careful changing this code, it is very timing dependent
3 */
4
5#ifndef F_CPU
6#define F_CPU 16000000
7#endif
8
9#include <avr/io.h>
10#include <avr/interrupt.h>
11#include <util/delay.h>
12#include <stdbool.h>
13#include "serial.h"
14
15#ifndef USE_I2C
16
17// Serial pulse period in microseconds. Its probably a bad idea to lower this
18// value.
19#define SERIAL_DELAY 24
20
21uint8_t volatile serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH] = {0};
22uint8_t volatile serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH] = {0};
23
24#define SLAVE_DATA_CORRUPT (1<<0)
25volatile uint8_t status = 0;
26
27inline static
28void serial_delay(void) {
29 _delay_us(SERIAL_DELAY);
30}
31
32inline static
33void serial_output(void) {
34 SERIAL_PIN_DDR |= SERIAL_PIN_MASK;
35}
36
37// make the serial pin an input with pull-up resistor
38inline static
39void serial_input(void) {
40 SERIAL_PIN_DDR &= ~SERIAL_PIN_MASK;
41 SERIAL_PIN_PORT |= SERIAL_PIN_MASK;
42}
43
44inline static
45uint8_t serial_read_pin(void) {
46 return !!(SERIAL_PIN_INPUT & SERIAL_PIN_MASK);
47}
48
49inline static
50void serial_low(void) {
51 SERIAL_PIN_PORT &= ~SERIAL_PIN_MASK;
52}
53
54inline static
55void serial_high(void) {
56 SERIAL_PIN_PORT |= SERIAL_PIN_MASK;
57}
58
59void serial_master_init(void) {
60 serial_output();
61 serial_high();
62}
63
64void serial_slave_init(void) {
65 serial_input();
66
67 // Enable INT0
68 EIMSK |= _BV(INT0);
69 // Trigger on falling edge of INT0
70 EICRA &= ~(_BV(ISC00) | _BV(ISC01));
71}
72
73// Used by the master to synchronize timing with the slave.
74static
75void sync_recv(void) {
76 serial_input();
77 // This shouldn't hang if the slave disconnects because the
78 // serial line will float to high if the slave does disconnect.
79 while (!serial_read_pin());
80 serial_delay();
81}
82
83// Used by the slave to send a synchronization signal to the master.
84static
85void sync_send(void) {
86 serial_output();
87
88 serial_low();
89 serial_delay();
90
91 serial_high();
92}
93
94// Reads a byte from the serial line
95static
96uint8_t serial_read_byte(void) {
97 uint8_t byte = 0;
98 serial_input();
99 for ( uint8_t i = 0; i < 8; ++i) {
100 byte = (byte << 1) | serial_read_pin();
101 serial_delay();
102 _delay_us(1);
103 }
104
105 return byte;
106}
107
108// Sends a byte with MSB ordering
109static
110void serial_write_byte(uint8_t data) {
111 uint8_t b = 8;
112 serial_output();
113 while( b-- ) {
114 if(data & (1 << b)) {
115 serial_high();
116 } else {
117 serial_low();
118 }
119 serial_delay();
120 }
121}
122
123// interrupt handle to be used by the slave device
124ISR(SERIAL_PIN_INTERRUPT) {
125 sync_send();
126
127 uint8_t checksum = 0;
128 for (int i = 0; i < SERIAL_SLAVE_BUFFER_LENGTH; ++i) {
129 serial_write_byte(serial_slave_buffer[i]);
130 sync_send();
131 checksum += serial_slave_buffer[i];
132 }
133 serial_write_byte(checksum);
134 sync_send();
135
136 // wait for the sync to finish sending
137 serial_delay();
138
139 // read the middle of pulses
140 _delay_us(SERIAL_DELAY/2);
141
142 uint8_t checksum_computed = 0;
143 for (int i = 0; i < SERIAL_MASTER_BUFFER_LENGTH; ++i) {
144 serial_master_buffer[i] = serial_read_byte();
145 sync_send();
146 checksum_computed += serial_master_buffer[i];
147 }
148 uint8_t checksum_received = serial_read_byte();
149 sync_send();
150
151 serial_input(); // end transaction
152
153 if ( checksum_computed != checksum_received ) {
154 status |= SLAVE_DATA_CORRUPT;
155 } else {
156 status &= ~SLAVE_DATA_CORRUPT;
157 }
158}
159
160inline
161bool serial_slave_DATA_CORRUPT(void) {
162 return status & SLAVE_DATA_CORRUPT;
163}
164
165// Copies the serial_slave_buffer to the master and sends the
166// serial_master_buffer to the slave.
167//
168// Returns:
169// 0 => no error
170// 1 => slave did not respond
171int serial_update_buffers(void) {
172 // this code is very time dependent, so we need to disable interrupts
173 cli();
174
175 // signal to the slave that we want to start a transaction
176 serial_output();
177 serial_low();
178 _delay_us(1);
179
180 // wait for the slaves response
181 serial_input();
182 serial_high();
183 _delay_us(SERIAL_DELAY);
184
185 // check if the slave is present
186 if (serial_read_pin()) {
187 // slave failed to pull the line low, assume not present
188 sei();
189 return 1;
190 }
191
192 // if the slave is present syncronize with it
193 sync_recv();
194
195 uint8_t checksum_computed = 0;
196 // receive data from the slave
197 for (int i = 0; i < SERIAL_SLAVE_BUFFER_LENGTH; ++i) {
198 serial_slave_buffer[i] = serial_read_byte();
199 sync_recv();
200 checksum_computed += serial_slave_buffer[i];
201 }
202 uint8_t checksum_received = serial_read_byte();
203 sync_recv();
204
205 if (checksum_computed != checksum_received) {
206 sei();
207 return 1;
208 }
209
210 uint8_t checksum = 0;
211 // send data to the slave
212 for (int i = 0; i < SERIAL_MASTER_BUFFER_LENGTH; ++i) {
213 serial_write_byte(serial_master_buffer[i]);
214 sync_recv();
215 checksum += serial_master_buffer[i];
216 }
217 serial_write_byte(checksum);
218 sync_recv();
219
220 // always, release the line when not in use
221 serial_output();
222 serial_high();
223
224 sei();
225 return 0;
226}
227
228#endif
diff --git a/keyboards/handwired/not_so_minidox/serial.h b/keyboards/handwired/not_so_minidox/serial.h
new file mode 100644
index 000000000..15fe4db7b
--- /dev/null
+++ b/keyboards/handwired/not_so_minidox/serial.h
@@ -0,0 +1,26 @@
1#ifndef MY_SERIAL_H
2#define MY_SERIAL_H
3
4#include "config.h"
5#include <stdbool.h>
6
7/* TODO: some defines for interrupt setup */
8#define SERIAL_PIN_DDR DDRD
9#define SERIAL_PIN_PORT PORTD
10#define SERIAL_PIN_INPUT PIND
11#define SERIAL_PIN_MASK _BV(PD0)
12#define SERIAL_PIN_INTERRUPT INT0_vect
13
14#define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2
15#define SERIAL_MASTER_BUFFER_LENGTH 1
16
17// Buffers for master - slave communication
18extern volatile uint8_t serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH];
19extern volatile uint8_t serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH];
20
21void serial_master_init(void);
22void serial_slave_init(void);
23int serial_update_buffers(void);
24bool serial_slave_data_corrupt(void);
25
26#endif
diff --git a/keyboards/handwired/not_so_minidox/split_util.c b/keyboards/handwired/not_so_minidox/split_util.c
new file mode 100644
index 000000000..39639c3b4
--- /dev/null
+++ b/keyboards/handwired/not_so_minidox/split_util.c
@@ -0,0 +1,84 @@
1#include <avr/io.h>
2#include <avr/wdt.h>
3#include <avr/power.h>
4#include <avr/interrupt.h>
5#include <util/delay.h>
6#include <avr/eeprom.h>
7#include "split_util.h"
8#include "matrix.h"
9#include "keyboard.h"
10#include "config.h"
11
12#ifdef USE_I2C
13# include "i2c.h"
14#else
15# include "serial.h"
16#endif
17
18volatile bool isLeftHand = true;
19
20static void setup_handedness(void) {
21 #ifdef EE_HANDS
22 isLeftHand = eeprom_read_byte(EECONFIG_HANDEDNESS);
23 #else
24 // I2C_MASTER_RIGHT is deprecated, use MASTER_RIGHT instead, since this works for both serial and i2c
25 #if defined(I2C_MASTER_RIGHT) || defined(MASTER_RIGHT)
26 isLeftHand = !has_usb();
27 #else
28 isLeftHand = has_usb();
29 #endif
30 #endif
31}
32
33static void keyboard_master_setup(void) {
34#ifdef USE_I2C
35 i2c_master_init();
36#ifdef SSD1306OLED
37 matrix_master_OLED_init ();
38#endif
39#else
40 serial_master_init();
41#endif
42}
43
44static void keyboard_slave_setup(void) {
45#ifdef USE_I2C
46 i2c_slave_init(SLAVE_I2C_ADDRESS);
47#else
48 serial_slave_init();
49#endif
50}
51
52bool has_usb(void) {
53 USBCON |= (1 << OTGPADE); //enables VBUS pad
54 _delay_us(5);
55 return (USBSTA & (1<<VBUS)); //checks state of VBUS
56}
57
58void split_keyboard_setup(void) {
59 setup_handedness();
60
61 if (has_usb()) {
62 keyboard_master_setup();
63 } else {
64 keyboard_slave_setup();
65 }
66 sei();
67}
68
69void keyboard_slave_loop(void) {
70 matrix_init();
71
72 while (1) {
73 matrix_slave_scan();
74 }
75}
76
77// this code runs before the usb and keyboard is initialized
78void matrix_setup(void) {
79 split_keyboard_setup();
80
81 if (!has_usb()) {
82 keyboard_slave_loop();
83 }
84}
diff --git a/keyboards/handwired/not_so_minidox/split_util.h b/keyboards/handwired/not_so_minidox/split_util.h
new file mode 100644
index 000000000..595a0659e
--- /dev/null
+++ b/keyboards/handwired/not_so_minidox/split_util.h
@@ -0,0 +1,20 @@
1#ifndef SPLIT_KEYBOARD_UTIL_H
2#define SPLIT_KEYBOARD_UTIL_H
3
4#include <stdbool.h>
5#include "eeconfig.h"
6
7#define SLAVE_I2C_ADDRESS 0x32
8
9extern volatile bool isLeftHand;
10
11// slave version of matix scan, defined in matrix.c
12void matrix_slave_scan(void);
13
14void split_keyboard_setup(void);
15bool has_usb(void);
16void keyboard_slave_loop(void);
17
18void matrix_master_OLED_init (void);
19
20#endif
diff --git a/keyboards/iris/keymaps/mtdjr/config.h b/keyboards/iris/keymaps/mtdjr/config.h
index 0e8938775..28109d3ab 100644
--- a/keyboards/iris/keymaps/mtdjr/config.h
+++ b/keyboards/iris/keymaps/mtdjr/config.h
@@ -20,6 +20,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
20 20
21#include "config_common.h" 21#include "config_common.h"
22 22
23#define SOLENOID_ENABLE
24#define SOLENOID_PIN C6
25
23/* Use I2C or Serial, not both */ 26/* Use I2C or Serial, not both */
24 27
25#define USE_SERIAL 28#define USE_SERIAL
@@ -28,7 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
28/* Select hand configuration */ 31/* Select hand configuration */
29 32
30#define MASTER_LEFT 33#define MASTER_LEFT
31#define TAPPING_TERM 250 34
32// #define MASTER_RIGHT 35// #define MASTER_RIGHT
33// #define EE_HANDS 36// #define EE_HANDS
34 37
diff --git a/keyboards/iris/keymaps/mtdjr/keymap.c b/keyboards/iris/keymaps/mtdjr/keymap.c
index ba95d16b2..d6e3ec05e 100644
--- a/keyboards/iris/keymaps/mtdjr/keymap.c
+++ b/keyboards/iris/keymaps/mtdjr/keymap.c
@@ -1,145 +1,8 @@
1#include "iris.h" 1#include QMK_KEYBOARD_H
2#include "action_layer.h" 2#include "mtdjr.h"
3#include "eeconfig.h"
4#include "action_macro.h"
5#include <timer.h>
6#include "pincontrol.h"
7 3
8extern keymap_config_t keymap_config; 4extern keymap_config_t keymap_config;
9 5
10#define _QWERTY 0
11#define _LOWER 1
12#define _RAISE 2
13#define _SUPER 3
14#define _ADJUST 16
15#define SOLENOID_DEFAULT_DWELL 12
16#define SOLENOID_MAX_DWELL 100
17#define SOLENOID_MIN_DWELL 4
18#define SOLENOID_PIN C6
19
20
21bool solenoid_enabled = false;
22bool solenoid_on = false;
23bool solenoid_buzz = false;
24bool solenoid_buzzing = false;
25uint16_t solenoid_start = 0;
26uint8_t solenoid_dwell = SOLENOID_DEFAULT_DWELL;
27
28
29void solenoid_buzz_on(void) {
30 solenoid_buzz = true;
31}
32
33void solenoid_buzz_off(void) {
34 solenoid_buzz = false;
35}
36
37void solenoid_dwell_minus(void) {
38 if (solenoid_dwell > 0) solenoid_dwell--;
39}
40
41void solenoid_dwell_plus(void) {
42 if (solenoid_dwell < SOLENOID_MAX_DWELL) solenoid_dwell++;
43}
44
45void solenoid_toggle(void) {
46 solenoid_enabled = !solenoid_enabled;
47}
48
49void solenoid_stop(void) {
50 digitalWrite(SOLENOID_PIN, PinLevelLow);
51 solenoid_on = false;
52 solenoid_buzzing = false;
53}
54
55void solenoid_fire(void) {
56 if (!solenoid_enabled) return;
57
58 if (!solenoid_buzz && solenoid_on) return;
59 if (solenoid_buzz && solenoid_buzzing) return;
60
61 solenoid_on = true;
62 solenoid_buzzing = true;
63 solenoid_start = timer_read();
64 digitalWrite(SOLENOID_PIN, PinLevelHigh);
65}
66
67void solenoid_check(void) {
68 uint16_t elapsed = 0;
69
70 if (!solenoid_on) return;
71
72 elapsed = timer_elapsed(solenoid_start);
73
74 //Check if it's time to finish this solenoid click cycle
75 if (elapsed > solenoid_dwell) {
76 solenoid_stop();
77 return;
78 }
79
80 //Check whether to buzz the solenoid on and off
81 if (solenoid_buzz) {
82 if (elapsed / SOLENOID_MIN_DWELL % 2 == 0){
83 if (!solenoid_buzzing) {
84 solenoid_buzzing = true;
85 digitalWrite(SOLENOID_PIN, PinLevelHigh);
86 }
87 }
88 else {
89 if (solenoid_buzzing) {
90 solenoid_buzzing = false;
91 digitalWrite(SOLENOID_PIN, PinLevelLow);
92 }
93 }
94 }
95}
96
97void solenoid_setup(void) {
98 pinMode(SOLENOID_PIN, PinDirectionOutput);
99}
100
101void matrix_init_user(void) {
102 solenoid_setup();
103}
104
105void matrix_scan_user(void) {
106 solenoid_check();
107}
108
109
110enum custom_keycodes {
111 QWERTY = SAFE_RANGE,
112 LOWER,
113 RAISE,
114 SUPER,
115 ADJUST,
116 SOL_TOG,
117 SOLENOID_DWELL_MINUS,
118 SOLENOID_DWELL_PLUS,
119 SOLENOID_BUZZ_ON,
120 SOLENOID_BUZZ_OFF,
121 TD_ESC = 0,
122};
123
124#define KC_ KC_TRNS
125#define _______ KC_TRNS
126
127#define KC_LOWR LOWER
128#define KC_RASE RAISE
129#define KC_SUPR SUPER
130#define KC_RST RESET
131#define KC_BL_S BL_STEP
132#define KC_EXC TD(TD_ESC)
133#define SOLTOG SOLENOID_TOG
134
135// Macro Declarations
136#define UM_ROOT M(0)
137#define UM_PPLY M(1)
138#define UM_PSEF M(2)
139#define KC_XCPY M(3)
140#define KC_XINS M(4)
141#define UM_CAD M(5)
142
143const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 6const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
144 7
145 [_QWERTY] = LAYOUT_kc( 8 [_QWERTY] = LAYOUT_kc(
@@ -152,7 +15,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
152 //|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----| 15 //|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
153 EQL, Z , X , C , V , B ,LGUI, LALT, N , M ,COMM,DOT ,SLSH,MINS, 16 EQL, Z , X , C , V , B ,LGUI, LALT, N , M ,COMM,DOT ,SLSH,MINS,
154 //`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----' 17 //`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----'
155 LCTL,RASE,SPC , SPC ,LOWR,SUPR 18 LCTL,RASE,SPC , SPC ,LOWR,xxxx
156 // `----+----+----' `----+----+----' 19 // `----+----+----' `----+----+----'
157 ), 20 ),
158 21
@@ -178,130 +41,23 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
178 //|----+----+----+----+----+----| |----+----+----+----+----+----| 41 //|----+----+----+----+----+----| |----+----+----+----+----+----|
179 , F9 ,F10 ,F11 ,F12 , , , , , , , , 42 , F9 ,F10 ,F11 ,F12 , , , , , , , ,
180 //|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----| 43 //|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
181 , , ,XCPY,XINS, , , , , , , , ,PLUS, 44 , , ,XCPY,XINS, , , , , , , , , ,
182 //`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----' 45 //`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----'
183 , , , , , 46 , , , , ,
184 // `----+----+----' `----+----+----' 47 // `----+----+----' `----+----+----'
185 ), 48 ),
186 49
187 [_SUPER] = LAYOUT( 50 [_ADJUST] = LAYOUT_kc(
188 //,--------+--------+--------+--------+--------+--------. ,--------+--------+--------+--------+--------+--------. 51 //,----+----+----+----+----+----. ,----+----+----+----+----+----.
189 SOL_TOG, UM_ROOT, UM_PPLY, UM_PSEF, _______, _______, _______, _______, _______, _______, _______, _______, 52 STOG,ROOT,PPLY,PSEF,xxxx,xxxx, xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,
190 //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| 53 //|----+----+----+----+----+----| |----+----+----+----+----+----|
191 _______, _______, _______, _______, _______, _______, _______, KC_LBRC, _______, _______, _______, _______, 54 xxxx,xxxx,xxxx,xxxx,xxxx,xxxx, xxxx,xxxx,xxxx,xxxx,xxxx,BSLS,
192 //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| 55 //|----+----+----+----+----+----| |----+----+----+----+----+----|
193 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, UM_CAD , 56 xxxx,xxxx,xxxx,xxxx,xxxx,xxxx, xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,
194 //|--------+--------+--------+--------+--------+--------+--------. ,--------|--------+--------+--------+--------+--------+--------| 57 //|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
195 _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MUTE, KC_VOLD, KC_VOLU, KC_MNXT, KC_MPLY, 58 xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx, xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,
196 //`--------+--------+--------+----+---+--------+--------+--------/ \--------+--------+--------+---+----+--------+--------+--------' 59 //`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----'
197 _______, _______, _______, _______, _______, _______ 60 xxxx, ,xxxx, xxxx, ,
198 // `--------+--------+--------' `--------+--------+--------' 61 // `----+----+----' `----+----+----'
199) 62 )
200
201};
202
203void persistent_default_layer_set(uint16_t default_layer) {
204 eeconfig_update_default_layer(default_layer);
205 default_layer_set(default_layer);
206}
207
208qk_tap_dance_action_t tap_dance_actions[] = {
209 //Tap once for grave accent, twice for ESC
210 [TD_ESC] = ACTION_TAP_DANCE_DOUBLE(KC_GRV, KC_ESC)
211};
212
213bool process_record_user(uint16_t keycode, keyrecord_t *record) {
214 if (record->event.pressed) {
215 solenoid_fire();
216 }
217 switch (keycode) {
218 case QWERTY:
219 if (record->event.pressed) {
220 persistent_default_layer_set(1UL<<_QWERTY);
221 }
222 return false;
223 break;
224 case LOWER:
225 if (record->event.pressed) {
226 layer_on(_LOWER);
227 update_tri_layer(_LOWER, _RAISE, _ADJUST);
228 } else {
229 layer_off(_LOWER);
230 update_tri_layer(_LOWER, _RAISE, _ADJUST);
231 }
232 return false;
233 break;
234 case RAISE:
235 if (record->event.pressed) {
236 layer_on(_RAISE);
237 update_tri_layer(_LOWER, _RAISE, _ADJUST);
238 } else {
239 layer_off(_RAISE);
240 update_tri_layer(_LOWER, _RAISE, _ADJUST);
241 }
242 return false;
243 break;
244 case SUPER:
245 if (record->event.pressed) {
246 layer_on(_SUPER);
247 update_tri_layer(_LOWER, _RAISE, _ADJUST);
248 } else {
249 layer_off(_SUPER);
250 update_tri_layer(_LOWER, _RAISE, _ADJUST);
251 }
252 return false;
253 break;
254 case SOLTOG:
255 if (record->event.pressed) {
256 solenoid_toggle();
257 }
258 break;
259 case SOLENOID_DWELL_MINUS:
260 if (record->event.pressed) {
261 solenoid_dwell_minus();
262 }
263 break;
264 case SOLENOID_DWELL_PLUS:
265 if (record->event.pressed) {
266 solenoid_dwell_plus();
267 }
268 break;
269 case SOLENOID_BUZZ_ON:
270 if (record->event.pressed) {
271 solenoid_buzz_on();
272 }
273 break;
274 case SOLENOID_BUZZ_OFF:
275 if (record->event.pressed) {
276 solenoid_buzz_off();
277 }
278 break;
279 }
280 return true;
281};
282
283const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
284 if (record->event.pressed) {
285 switch(id) {
286 case 0:
287 SEND_STRING("sudo su -\n");
288 return false; break;
289 case 1:
290 SEND_STRING("puppet apply /etc/puppetlabs/code/environments/production/manifests/site.pp\n");
291 return false; break;
292 case 2:
293 SEND_STRING("ps -ef | grep ");
294 return false; break;
295 case 3:
296 return MACRO(D(LCTL), T(INS), U(LCTL), END);
297 break;
298 case 4:
299 return MACRO(D(LSFT), T(INS), U(LSFT), END);
300 break;
301 case 5:
302 return MACRO(D(LCTL), D(RALT), T(DEL), END);
303 break;
304 }
305 }
306 return MACRO_NONE;
307}; 63};
diff --git a/keyboards/iris/keymaps/mtdjr/rules.mk b/keyboards/iris/keymaps/mtdjr/rules.mk
index 7c19013e5..c5e16f136 100644
--- a/keyboards/iris/keymaps/mtdjr/rules.mk
+++ b/keyboards/iris/keymaps/mtdjr/rules.mk
@@ -1,6 +1,5 @@
1RGBLIGHT_ENABLE = no 1RGBLIGHT_ENABLE = no
2BACKLIGHT_ENABLE = no 2BACKLIGHT_ENABLE = no
3TAP_DANCE_ENABLE = no
4 3
5ifndef QUANTUM_DIR 4ifndef QUANTUM_DIR
6 include ../../../../Makefile 5 include ../../../../Makefile
diff --git a/keyboards/lets_split/keymaps/mtdjr/config.h b/keyboards/lets_split/keymaps/mtdjr/config.h
index 761e9e175..2b5a19365 100644
--- a/keyboards/lets_split/keymaps/mtdjr/config.h
+++ b/keyboards/lets_split/keymaps/mtdjr/config.h
@@ -23,11 +23,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
23 23
24#include "../../config.h" 24#include "../../config.h"
25 25
26#define SOLENOID_ENABLE
27#define SOLENOID_PIN F4
28
26/* Use I2C or Serial, not both */ 29/* Use I2C or Serial, not both */
27 30
28// #define USE_SERIAL 31// #define USE_SERIAL
29 #define USE_I2C 32 #define USE_I2C
30 #define TAPPING_TERM 250
31/* Select hand configuration */ 33/* Select hand configuration */
32 34
33// #define MASTER_LEFT 35// #define MASTER_LEFT
diff --git a/keyboards/lets_split/keymaps/mtdjr/keymap.c b/keyboards/lets_split/keymaps/mtdjr/keymap.c
index 4846772ed..72476c700 100644
--- a/keyboards/lets_split/keymaps/mtdjr/keymap.c
+++ b/keyboards/lets_split/keymaps/mtdjr/keymap.c
@@ -1,194 +1,81 @@
1#include "lets_split.h" 1#include QMK_KEYBOARD_H
2#include "action_layer.h" 2#include "mtdjr.h"
3#include "eeconfig.h"
4#include "action_macro.h"
5 3
6extern keymap_config_t keymap_config; 4extern keymap_config_t keymap_config;
7 5
8// Each layer gets a name for readability, which is then used in the keymap matrix below.
9// The underscores don't mean anything - you can have a layer called STUFF or any other name.
10// Layer names don't all need to be of the same length, obviously, and you can also skip them
11// entirely and just use numbers.
12#define _QWERTY 0
13#define _LOWER 1
14#define _RAISE 2
15#define _ADJUST 16
16
17enum custom_keycodes {
18 QWERTY = SAFE_RANGE,
19 LOWER,
20 RAISE,
21 ADJUST,
22 TD_ESC = 0
23};
24
25// Fillers to make layering more clear
26#define _______ KC_TRNS
27#define XXXXXXX KC_NO
28
29
30// Macro Declarations
31#define UM_ROOT M(0)
32#define UM_PPLY M(1)
33#define UM_COPY M(2)
34#define UM_INSR M(3)
35#define UM_PSEF M(4)
36
37 6
38const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 7const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
39 8
40 /* Qwerty 9 /* Qwerty
41 * ,-----------------------------------------. ,-----------------------------------------. 10 * ,-----------------------------------------. ,-----------------------------------------.
42 * | Tab | Q | W | E | R | T | | Y | U | I | O | P | Bksp | 11 * | Tab | Q | W | E | R | T | | Y | U | I | O | P | Bksp |
43 * |------+------+------+------+------+------| |------+------+------+------+------+------| 12 * |------+------+------+------+------+------| |------+------+------+------+------+------|
44 * |Esc/~ | A | S | D | F | G | | H | J | K | L | ; | '/" | 13 * |Esc/~ | A | S | D | F | G | | H | J | K | L | ; | '/" |
45 * |------+------+------+------+------+------| |------+------+------+------+------+------| 14 * |------+------+------+------+------+------| |------+------+------+------+------+------|
46 * | Shift| Z | X | C | V | B | | N | M | , | . | / |Enter | 15 * | Shift| Z | X | C | V | B | | N | M | , | . | / |Enter |
47 * |------+------+------+------+------+------| |------+------+------+------+------+------| 16 * |------+------+------+------+------+------| |------+------+------+------+------+------|
48 * |Adjust| Ctrl | Alt | GUI |Lower |Space | |Space |Raise | Left | Up | Down |Right | 17 * |Adjust| Ctrl | Alt | GUI |Lower |Space | |Space |Raise | Left | Up | Down |Right |
49 * `-----------------------------------------' '-----------------------------------------' 18 * `-----------------------------------------' '-----------------------------------------'
50 */ 19 */
51[_QWERTY] = LAYOUT( \ 20 [_QWERTY] = LAYOUT( \
52 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \ 21 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \
53 TD(TD_ESC), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \ 22 KC_EXC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \
54 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \ 23 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \
55 ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_UP, KC_DOWN, KC_RGHT \ 24 ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_UP, KC_DOWN, KC_RGHT \
56), 25 ),
57 26
58 /* Lower 27 /* Lower
59 * ,-----------------------------------------. ,-----------------------------------------. 28 * ,-----------------------------------------. ,-----------------------------------------.
60 * | ~ | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Bksp | 29 * | ~ | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Bksp |
61 * |------+------+------+------+------+------| |------+------+------+------+------+------| 30 * |------+------+------+------+------+------| |------+------+------+------+------+------|
62 * | | | [ | ] | { | } | | | 4 | 5 | 6 | * | \ | 31 * | | | [ | ] | { | } | | | 4 | 5 | 6 | * | \ |
63 * |------+------+------+------+------+------| |------+------+------+------+------+------| 32 * |------+------+------+------+------+------| |------+------+------+------+------+------|
64 * |Shift | | | copy |insert| | | | 1 | 2 | 3 | + | - | 33 * |Shift | | | copy |insert| | | | 1 | 2 | 3 | + | - |
65 * |------+------+------+------+------+------| |------+------+------+------+------+------| 34 * |------+------+------+------+------+------| |------+------+------+------+------+------|
66 * |Adjust| Ctrl | Alt | GUI |Lower |Space | |Space |Raise | 0 | . | = | _ | 35 * |Adjust| Ctrl | Alt | GUI |Lower |Space | |Space |Raise | 0 | . | = | _ |
67 * `-----------------------------------------' '-----------------------------------------' 36 * `-----------------------------------------' '-----------------------------------------'
68 */ 37 */
69[_LOWER] = LAYOUT( \ 38 [_LOWER] = LAYOUT( \
70 KC_TILD, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______, \ 39 KC_TILD, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______, \
71 XXXXXXX, XXXXXXX, KC_LBRC, KC_RBRC, KC_LCBR, KC_RCBR, XXXXXXX, KC_4, KC_5, KC_6, KC_ASTR, KC_BSLS, \ 40 XXXXXXX, XXXXXXX, KC_LBRC, KC_RBRC, KC_LCBR, KC_RCBR, XXXXXXX, KC_4, KC_5, KC_6, KC_ASTR, KC_BSLS, \
72 _______, XXXXXXX, XXXXXXX, UM_COPY, UM_INSR, XXXXXXX, XXXXXXX, KC_1, KC_2, KC_3, KC_PLUS, KC_MINS, \ 41 _______, XXXXXXX, XXXXXXX, KC_XCPY, KC_XINS, XXXXXXX, XXXXXXX, KC_1, KC_2, KC_3, KC_PLUS, KC_MINS, \
73 _______, _______, _______, _______, _______, _______, _______, _______, KC_0, KC_DOT, KC_EQL, KC_UNDS \ 42 _______, _______, _______, _______, _______, _______, _______, _______, KC_0, KC_DOT, KC_EQL, KC_UNDS \
74), 43 ),
75 44
76 45
77/* Raise 46 /* Raise
78 * ,-----------------------------------------. ,-----------------------------------------. 47 * ,-----------------------------------------. ,-----------------------------------------.
79 * | ` | ! | @ | # | $ | % | | ^ | & | * | ( | ) | Bksp | 48 * | ` | ! | @ | # | $ | % | | ^ | & | * | ( | ) | Bksp |
80 * |------+------+------+------+------+------| |------+------+------+------+------+------| 49 * |------+------+------+------+------+------| |------+------+------+------+------+------|
81 * | | | | | | | | | | | | \ | | | 50 * | | | | | | | | | | | | \ | | |
82 * |------+------+------+------+------+------| |------+------+------+------+------+------| 51 * |------+------+------+------+------+------| |------+------+------+------+------+------|
83 * |Shift | | | | | | | | | | | | | 52 * |Shift | | | | | | | | | | | | |
84 * |------+------+------+------+------+------| |------+------+------+------+------+------| 53 * |------+------+------+------+------+------| |------+------+------+------+------+------|
85 * |Adjust| Ctrl | Alt | GUI |Lower |Space | |Space |Raise | Next | Vol- | Vol+ | Play | 54 * |Adjust| Ctrl | Alt | GUI |Lower |Space | |Space |Raise | Next | Vol- | Vol+ | Play |
86 * `-----------------------------------------' '-----------------------------------------' 55 * `-----------------------------------------' '-----------------------------------------'
87 */ 56 */
88[_RAISE] = LAYOUT( \ 57 [_RAISE] = LAYOUT( \
89 KC_GRV, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______, \ 58 KC_GRV, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______, \
90 XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_BSLS, KC_PIPE,\ 59 XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_BSLS, KC_PIPE,\
91 _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, 60 _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
92 _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \ 61 _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
93), 62 ),
94 63
95 /* Adjust (Lower + Raise) 64 /* Adjust (Lower + Raise)
96 * ,-----------------------------------------. ,-----------------------------------------. 65 * ,-----------------------------------------. ,-----------------------------------------.
97 * | | Reset| | | | | | ROOT | PPLY | PSEF | | | Del | 66 * | | Reset| | | | | | ROOT | PPLY | PSEF | | | Del |
98 * |------+------+------+------+------+------| |------+------+------+------+------+------| 67 * |------+------+------+------+------+------| |------+------+------+------+------+------|
99 * | | | |Aud on|Audoff| | | F1 | F2 | F3 | F4 | F5 | F6 | 68 * | | | |Aud on|Audoff| | | F1 | F2 | F3 | F4 | F5 | F6 |
100 * |------+------+------+------+------+------| |------+------+------+------+------+------| 69 * |------+------+------+------+------+------| |------+------+------+------+------+------|
101 * | | UNDO | CUT | COPY |PASTE | | | F7 | F8 | F9 | F10 | F11 | F12 | 70 * | | UNDO | CUT | COPY |PASTE | | | F7 | F8 | F9 | F10 | F11 | F12 |
102 * |------+------+------+------+------+------| |------+------+------+------+------+------| 71 * |------+------+------+------+------+------| |------+------+------+------+------+------|
103 * | | | | | | | | | | Home | | | End | 72 * | | | | | | | | | | Home | | | End |
104 * `-----------------------------------------' '-----------------------------------------' 73 * `-----------------------------------------' '-----------------------------------------'
105 */ 74 */
106[_ADJUST] = LAYOUT( \ 75 [_ADJUST] = LAYOUT( \
107 _______, UM_ROOT, UM_PPLY, UM_PSEF, _______, _______, RESET, _______, _______, _______, _______, KC_DEL, \ 76 KC_STOG, KC_ROOT, KC_PPLY, KC_PSEF, _______, _______, RESET, _______, _______, _______, _______, KC_DEL, \
108 _______, _______, _______, AU_ON, AU_OFF, _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, \ 77 _______, _______, _______, AU_ON, AU_OFF, _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, \
109 _______, KC_UNDO, KC_CUT, UM_COPY, UM_INSR, _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, \ 78 _______, KC_UNDO, KC_CUT, KC_XCPY, KC_XINS, _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, \
110 _______, _______, _______, _______, _______, _______, _______, _______, KC_HOME, _______, _______, KC_END \ 79 _______, _______, _______, _______, _______, _______, _______, _______, KC_HOME, _______, _______, KC_END \
111) 80 )
112 81}; \ No newline at end of file
113
114};
115
116#ifdef AUDIO_ENABLE
117float tone_qwerty[][2] = SONG(QWERTY_SOUND);
118#endif
119
120void persistent_default_layer_set(uint16_t default_layer) {
121 eeconfig_update_default_layer(default_layer);
122 default_layer_set(default_layer);
123}
124
125qk_tap_dance_action_t tap_dance_actions[] = {
126 //Tap once for nothing, twice for ESC
127 [TD_ESC] = ACTION_TAP_DANCE_DOUBLE(KC_NO, KC_ESC)
128};
129
130bool process_record_user(uint16_t keycode, keyrecord_t *record) {
131 switch (keycode) {
132 case QWERTY:
133 if (record->event.pressed) {
134 #ifdef AUDIO_ENABLE
135 PLAY_SONG(tone_qwerty);
136 #endif
137 persistent_default_layer_set(1UL<<_QWERTY);
138 }
139 return false;
140 break;
141 case LOWER:
142 if (record->event.pressed) {
143 layer_on(_LOWER);
144 update_tri_layer(_LOWER, _RAISE, _ADJUST);
145 } else {
146 layer_off(_LOWER);
147 update_tri_layer(_LOWER, _RAISE, _ADJUST);
148 }
149 return false;
150 break;
151 case RAISE:
152 if (record->event.pressed) {
153 layer_on(_RAISE);
154 update_tri_layer(_LOWER, _RAISE, _ADJUST);
155 } else {
156 layer_off(_RAISE);
157 update_tri_layer(_LOWER, _RAISE, _ADJUST);
158 }
159 return false;
160 break;
161 case ADJUST:
162 if (record->event.pressed) {
163 layer_on(_ADJUST);
164 } else {
165 layer_off(_ADJUST);
166 }
167 return false;
168 break;
169 }
170 return true;
171};
172
173const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
174 if (record->event.pressed) {
175 switch(id) {
176 case 0:
177 SEND_STRING("sudo su -\n");
178 return false; break;
179 case 1:
180 SEND_STRING("puppet apply /etc/puppetlabs/code/environments/production/manifests/site.pp\n");
181 return false; break;
182 case 2:
183 return MACRO(D(LCTL), T(INS), U(LCTL), END);
184 break;
185 case 3:
186 return MACRO(D(LSFT), T(INS), U(LSFT), END);
187 break;
188 case 4:
189 SEND_STRING("ps -ef | grep ");
190 return false; break;
191 }
192 }
193 return MACRO_NONE;
194};
diff --git a/keyboards/lets_split/keymaps/mtdjr/rules.mk b/keyboards/lets_split/keymaps/mtdjr/rules.mk
index f0ed9e8dc..457a3d01d 100644
--- a/keyboards/lets_split/keymaps/mtdjr/rules.mk
+++ b/keyboards/lets_split/keymaps/mtdjr/rules.mk
@@ -1,4 +1,3 @@
1TAP_DANCE_ENABLE = yes
2ifndef QUANTUM_DIR 1ifndef QUANTUM_DIR
3 include ../../../../Makefile 2 include ../../../../Makefile
4endif 3endif
diff --git a/keyboards/tada68/keymaps/mtdjr/keymap.c b/keyboards/tada68/keymaps/mtdjr/keymap.c
index 1b1f6ad4f..d24bbf956 100644
--- a/keyboards/tada68/keymaps/mtdjr/keymap.c
+++ b/keyboards/tada68/keymaps/mtdjr/keymap.c
@@ -1,22 +1,5 @@
1#include "tada68.h" 1#include QMK_KEYBOARD_H
2#include "action_macro.h" 2#include "mtdjr.h"
3
4// Each layer gets a name for readability, which is then used in the keymap matrix below.
5// The underscores don't mean anything - you can have a layer called STUFF or any other name.
6// Layer names don't all need to be of the same length, obviously, and you can also skip them
7// entirely and just use numbers.
8#define _BL 0
9#define _FL 1
10
11// Macro Declarations
12#define UM_ROOT M(0)
13#define UM_PPLY M(1)
14#define UM_PSEF M(2)
15#define UM_XCPY M(3)
16#define UM_XINS M(4)
17#define UM_CAD M(5)
18
19#define _______ KC_TRNS
20 3
21const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 4const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
22 /* Keymap _BL: (Base Layer) Default Layer 5 /* Keymap _BL: (Base Layer) Default Layer
@@ -32,12 +15,12 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
32 * |Ctrl|Alt |Gui | Space |Alt| FN|Ctrl|Lef|Dow|Rig | 15 * |Ctrl|Alt |Gui | Space |Alt| FN|Ctrl|Lef|Dow|Rig |
33 * `----------------------------------------------------------------' 16 * `----------------------------------------------------------------'
34 */ 17 */
35[_BL] = KEYMAP_ANSI( 18[_QWERTY] = KEYMAP_ANSI(
36 KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_INS, \ 19 KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_INS, \
37 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC,KC_BSLS, KC_DEL, \ 20 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC,KC_BSLS, KC_DEL, \
38 KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGUP, \ 21 KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGUP, \
39 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_RSFT,KC_UP, KC_PGDN, \ 22 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_RSFT,KC_UP, KC_PGDN, \
40 KC_LCTL,KC_LALT,KC_LGUI, KC_SPC, KC_RALT,MO(_FL), KC_RCTRL, KC_LEFT,KC_DOWN, KC_RGHT), 23 KC_LCTL,KC_LALT,KC_LGUI, KC_SPC, KC_RALT,KC_LOWR, KC_RCTRL, KC_LEFT,KC_DOWN, KC_RGHT),
41 24
42 /* Keymap _FL: Function Layer 25 /* Keymap _FL: Function Layer
43 * ,----------------------------------------------------------------. 26 * ,----------------------------------------------------------------.
@@ -52,36 +35,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
52 * | | | | | | | |MsL|MsD|MsR | 35 * | | | | | | | |MsL|MsD|MsR |
53 * `----------------------------------------------------------------' 36 * `----------------------------------------------------------------'
54 */ 37 */
55[_FL] = KEYMAP_ANSI( 38[_LOWER] = KEYMAP_ANSI(
56 _______, KC_F1 , KC_F2 , KC_F3 , KC_F4 , KC_F5 , KC_F6 , KC_F7 , KC_F8 , KC_F9 , KC_F10, KC_F11, KC_F12, KC_DEL, KC_GRV, \ 39 _______, KC_F1 , KC_F2 , KC_F3 , KC_F4 , KC_F5 , KC_F6 , KC_F7 , KC_F8 , KC_F9 , KC_F10, KC_F11, KC_F12, KC_DEL, KC_GRV, \
57 _______,UM_ROOT,UM_PPLY,UM_PSEF,_______,_______,_______,_______,_______,_______,KC_PSCR,_______,_______,_______, KC_HOME, \ 40 _______,KC_ROOT,KC_PPLY,KC_PSEF,_______,_______,_______,_______,_______,_______,KC_PSCR,_______,_______,_______, KC_HOME, \
58 _______,BL_DEC ,BL_TOGG,BL_INC,BL_BRTG,_______,_______,_______,_______,_______,_______,_______, _______, KC_END, \ 41 _______,BL_DEC ,BL_TOGG,BL_INC,BL_BRTG,_______,_______,_______,_______,_______,_______,_______, _______, KC_END, \
59 _______,_______ ,_______,UM_XCPY,UM_XINS,_______,KC_MPLY,KC_MNXT,KC_MUTE,KC_VOLD,KC_VOLU,KC_BTN1,KC_MS_U,KC_BTN2, \ 42 _______,_______ ,_______,KC_XCPY,KC_XINS,_______,KC_MPLY,KC_MNXT,KC_MUTE,KC_VOLD,KC_VOLU,KC_BTN1,KC_MS_U,KC_BTN2, \
60 _______,_______,_______, _______, _______,_______,_______,KC_MS_L,KC_MS_D,KC_MS_R), 43 _______,_______,_______, _______, _______,_______,_______,KC_MS_L,KC_MS_D,KC_MS_R),
61}; 44};
62
63const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
64 if (record->event.pressed) {
65 switch(id) {
66 case 0:
67 SEND_STRING("sudo su -\n");
68 return false; break;
69 case 1:
70 SEND_STRING("puppet apply /etc/puppetlabs/code/environments/production/manifests/site.pp\n");
71 return false; break;
72 case 2:
73 SEND_STRING("ps -ef | grep ");
74 return false; break;
75 case 3:
76 return MACRO(D(LCTL), T(INS), U(LCTL), END);
77 break;
78 case 4:
79 return MACRO(D(LSFT), T(INS), U(LSFT), END);
80 break;
81 case 5:
82 return MACRO(D(LCTL), D(RALT), T(DEL), END);
83 break;
84 }
85 }
86 return MACRO_NONE;
87};
diff --git a/keyboards/xd75/keymaps/mtdjr/config.h b/keyboards/xd75/keymaps/mtdjr/config.h
index aadcaa387..7e2227c87 100644
--- a/keyboards/xd75/keymaps/mtdjr/config.h
+++ b/keyboards/xd75/keymaps/mtdjr/config.h
@@ -20,7 +20,8 @@
20#include "../../config.h" 20#include "../../config.h"
21 21
22// place overrides here 22// place overrides here
23#define RGBLIGHT_SLEEP 23#undef MANUFACTURER
24#undef DESCRIPTION
24#define MANUFACTURER mtdjr 25#define MANUFACTURER mtdjr
25#define PRODUCT XD75 26#define PRODUCT XD75
26#define DESCRIPTION XD75Re 27#define DESCRIPTION XD75Re
diff --git a/keyboards/xd75/keymaps/mtdjr/keymap.c b/keyboards/xd75/keymaps/mtdjr/keymap.c
index 696c82ae4..28d4b4961 100644
--- a/keyboards/xd75/keymaps/mtdjr/keymap.c
+++ b/keyboards/xd75/keymaps/mtdjr/keymap.c
@@ -1,68 +1,13 @@
1/* Copyright 2017 Wunder 1#include QMK_KEYBOARD_H
2 * 2#include "mtdjr.h"
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#include "xd75.h"
17#include "action_layer.h"
18 3
19 4#define KC_LOCK TD(TD_ENDLOCK)
20enum custom_keycodes {
21 // TD_ESC = 0,
22 TD_LOCK = 0,
23};
24
25// Layers
26#define _QWERTY 0
27#define _LOWER 1
28#define _RAISE 2
29
30
31
32// Shortcuts
33#define KC_____ KC_NO
34#define KC_ KC_TRNS
35#define KC_RST RESET
36#define KC_RASE MO(_RAISE)
37#define KC_LOWR MO(_LOWER)
38
39// RGB and Backlighting
40#define KC_RGB RGB_TOG
41#define KC_RHUI RGB_HUI
42#define KC_RHUD RGB_HUD
43#define KC_RSAI RGB_SAI
44#define KC_RSAD RGB_SAD
45#define KC_RVAI RGB_VAI
46#define KC_RVAD RGB_VAD
47#define KC_BLT BL_TOGG
48#define KC_BLS BL_STEP
49#define KC_BLI BL_INC
50#define KC_BLD BL_DEC
51
52// Tapdance
53//#define KC_EXC TD(TD_ESC)
54#define KC_LOCK TD(TD_LOCK)
55
56// Macros
57#define KC_ROOT M(0)
58#define KC_PPLY M(1)
59#define KC_PSEF M(2)
60 5
61const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 6const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
62 7
63 [_QWERTY] = KC_KEYMAP( 8 [_QWERTY] = KC_KEYMAP(
64// .--------------------------------------------------------------------------. 9// .--------------------------------------------------------------------------.
65 ESC, 1 , 2 , 3 , 4 , 5 ,PGUP,PSCR,PGDN, 6 , 7 , 8 , 9 , 0 ,BSPC, 10 EXC, 1 , 2 , 3 , 4 , 5 ,PGUP,xxxx,PGDN, 6 , 7 , 8 , 9 , 0 ,BSPC,
66// |----+----+----+----+----+----+----+----+----+----+----+----+----+----+----| 11// |----+----+----+----+----+----+----+----+----+----+----+----+----+----+----|
67 TAB, Q , W , E , R , T , INS,BSLS, DEL, Y , U , I , O , P ,QUOT, 12 TAB, Q , W , E , R , T , INS,BSLS, DEL, Y , U , I , O , P ,QUOT,
68// |----+----+----+----+----+----+----+----+----+----+----+----+----+----+----| 13// |----+----+----+----+----+----+----+----+----+----+----+----+----+----+----|
@@ -70,44 +15,39 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
70// |----+----+----+----+----+----+----+----+----+----+----+----+----+----+----| 15// |----+----+----+----+----+----+----+----+----+----+----+----+----+----+----|
71 LSFT, Z , X , C , V , B ,LBRC,MINS,RBRC, N , M ,COMM, DOT,SLSH,RSFT, 16 LSFT, Z , X , C , V , B ,LBRC,MINS,RBRC, N , M ,COMM, DOT,SLSH,RSFT,
72// |----+----+----+----+----+----+----+----+----+----+----+----+----+----+----| 17// |----+----+----+----+----+----+----+----+----+----+----+----+----+----+----|
73 LOWR,LCTL,LALT,LGUI,____, SPC,RASE, GRV,LOWR, SPC,____,LEFT,DOWN,UP ,RGHT 18 LOWR,LCTL,LALT,LGUI,xxxx, SPC, SPC,RASE,SPC, SPC,xxxx,LEFT,DOWN,UP ,RGHT
74// '----+----+----+----+----+----+----+----+----+----+----+----+----+----+----' 19// '----+----+----+----+----+----+----+----+----+----+----+----+----+----+----'
75), 20),
76 21
77 [_LOWER] = KC_KEYMAP( 22 [_LOWER] = KC_KEYMAP(
78// .--------------------------------------------------------------------------. 23// .--------------------------------------------------------------------------.
79 ____, F1, F2, F3, F4, F5, F6,____, F7, F8, F9, F10, F11, F12,____, 24 xxxx, F1, F2, F3, F4, F5, F6,xxxx, F7, F8, F9, F10, F11, F12, DEL,
80// |----+----+----+----+----+----+----+----+----+----+----+----+----+----+----| 25// |----+----+----+----+----+----+----+----+----+----+----+----+----+----+----|
81 ____,ROOT,PPLY,PSEF,____,____,____,____,____,____,____,____,____,____,____, 26 xxxx,ROOT,PPLY,PSEF,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,
82// |----+----+----+----+----+----+----+----+----+----+----+----+----+----+----| 27// |----+----+----+----+----+----+----+----+----+----+----+----+----+----+----|
83 ____,____,____,____,____,____,____,____,____,____,____,____,____,____,____, 28 xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,
84// |----+----+----+----+----+----+----+----+----+----+----+----+----+----+----| 29// |----+----+----+----+----+----+----+----+----+----+----+----+----+----+----|
85 ____,____,____,____,____,____,____,____,____,____,____,____,____,____,MUTE, 30 xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,MUTE,
86// |----+----+----+----+----+----+----+----+----+----+----+----+----+----+----| 31// |----+----+----+----+----+----+----+----+----+----+----+----+----+----+----|
87 ,____,____,____,____,____, ,____, ,MPLY,____,MPRV,VOLD,VOLU,MNXT 32 ,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx, ,xxxx,MPLY,xxxx,MPRV,VOLD,VOLU,MNXT
88// '----+----+----+----+----+----+----+----+----+----+----+----+----+----+----' 33// '----+----+----+----+----+----+----+----+----+----+----+----+----+----+----'
89), 34),
90 35
91[_RAISE] = KC_KEYMAP( 36[_RAISE] = KC_KEYMAP(
92// .--------------------------------------------------------------------------. 37// .--------------------------------------------------------------------------.
93 ____,____,____,____,____,____,____,____,____,____,____,____,____,____,____, 38 xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,
94// |----+----+----+----+----+----+----+----+----+----+----+----+----+----+----| 39// |----+----+----+----+----+----+----+----+----+----+----+----+----+----+----|
95 ____,____,____,____, RST,____,____,____,____,____,____,____,____,____,____, 40 xxxx,xxxx,xxxx,xxxx, RST,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,
96// |----+----+----+----+----+----+----+----+----+----+----+----+----+----+----| 41// |----+----+----+----+----+----+----+----+----+----+----+----+----+----+----|
97 CAPS,____,____,____,____,____,____, BLI,____,____,____,____,____,____,____, 42 CAPS,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx, BLI,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,
98// |----+----+----+----+----+----+----+----+----+----+----+----+----+----+----| 43// |----+----+----+----+----+----+----+----+----+----+----+----+----+----+----|
99 RGB,RHUI,RHUD,RSAI,RSAD,RVAI,RVAD, BLD,____,____,____,____,BTN1,BTN2,____, 44 RGB,RHUI,RHUD,RSAI,RSAD,RVAI,RVAD, BLD,xxxx,xxxx,xxxx,xxxx,BTN1,BTN2,xxxx,
100// |----+----+----+----+----+----+----+----+----+----+----+----+----+----+----| 45// |----+----+----+----+----+----+----+----+----+----+----+----+----+----+----|
101 ,____,____,____,____,____, ,____, ,____,____,MS_L,MS_D,MS_U,MS_R 46 ,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx, ,xxxx,xxxx,xxxx,MS_L,MS_D,MS_U,MS_R
102// '----+----+----+----+----+----+----+----+----+----+----+----+----+----+----' 47// '----+----+----+----+----+----+----+----+----+----+----+----+----+----+----'
103) 48)
104}; 49};
105 50
106qk_tap_dance_action_t tap_dance_actions[] = {
107 //Tap once for left ctrl, twice for ESC
108 //[TD_ESC] = ACTION_TAP_DANCE_DOUBLE(KC_LCTL, KC_ESC),
109 [TD_LOCK] = ACTION_TAP_DANCE_DOUBLE(KC_END, LGUI(KC_L))
110};
111void led_set_user(uint8_t usb_led) { 51void led_set_user(uint8_t usb_led) {
112 if (usb_led & (1<<USB_LED_CAPS_LOCK)) { 52 if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
113 capslock_led_on(); 53 capslock_led_on();
@@ -115,21 +55,3 @@ void led_set_user(uint8_t usb_led) {
115 capslock_led_off(); 55 capslock_led_off();
116 } 56 }
117} 57}
118
119
120const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
121 if (record->event.pressed) {
122 switch(id) {
123 case 0:
124 SEND_STRING("sudo su -\n");
125 return false; break;
126 case 1:
127 SEND_STRING("puppet apply /etc/puppetlabs/code/environments/production/manifests/site.pp\n");
128 return false; break;
129 case 2:
130 SEND_STRING("ps -ef | grep ");
131 return false; break;
132 }
133 }
134 return MACRO_NONE;
135};
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 @@
1#ifndef USERSPACE_CONFIG_H
2#define USERSPACE_CONFIG_H
3
4// Put normal config.h settings here:
5#define TAPPING_TERM 250
6
7#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 @@
1#include "mtdjr.h"
2
3#ifdef SOLENOID_ENABLE
4 #include "solenoid.h"
5
6 void solenoid_buzz_on(void);
7 void solenoid_buzz_off(void);
8 void solenoid_dwell_minus(void);
9 void solenoid_dwell_plus(void);
10 void solenoid_toggle(void);
11 void solenoid_stop(void);
12 void solenoid_fire(void);
13 void solenoid_check(void);
14 void solenoid_setup(void);
15 void matrix_init_user(void);
16 void matrix_scan_user(void);
17#endif
18
19bool process_record_user(uint16_t keycode, keyrecord_t *record) {
20 #ifdef SOLENOID_ENABLE
21 if (record->event.pressed) {
22 solenoid_fire();
23 }
24 #endif
25 switch (keycode) {
26 case QWERTY:
27 if (record->event.pressed) {
28 set_single_persistent_default_layer(_QWERTY);
29 }
30 return false;
31 break;
32 case LOWER:
33 if (record->event.pressed) {
34 layer_on(_LOWER);
35 update_tri_layer(_LOWER, _RAISE, _ADJUST);
36 } else {
37 layer_off(_LOWER);
38 update_tri_layer(_LOWER, _RAISE, _ADJUST);
39 }
40 return false;
41 break;
42 case RAISE:
43 if (record->event.pressed) {
44 layer_on(_RAISE);
45 update_tri_layer(_LOWER, _RAISE, _ADJUST);
46 } else {
47 layer_off(_RAISE);
48 update_tri_layer(_LOWER, _RAISE, _ADJUST);
49 }
50 return false;
51 break;
52 case ADJUST:
53 if (record->event.pressed) {
54 layer_on(_ADJUST);
55 update_tri_layer(_LOWER, _RAISE, _ADJUST);
56 } else {
57 layer_off(_ADJUST);
58 update_tri_layer(_LOWER, _RAISE, _ADJUST);
59 }
60 return false;
61 break;
62 case SOLENOID_TOG:
63 #ifdef SOLENOID_ENABLE
64 if (record->event.pressed) {
65 solenoid_toggle();
66 }
67 #endif
68 break;
69 case SOLENOID_DWELL_MINUS:
70 #ifdef SOLENOID_ENABLE
71 if (record->event.pressed) {
72 solenoid_dwell_minus();
73 }
74 #endif
75 break;
76 case SOLENOID_DWELL_PLUS:
77 #ifdef SOLENOID_ENABLE
78 if (record->event.pressed) {
79 solenoid_dwell_plus();
80 }
81 #endif
82 break;
83 case SOLENOID_BUZZ_ON:
84 #ifdef SOLENOID_ENABLE
85 if (record->event.pressed) {
86 solenoid_buzz_on();
87 }
88 #endif
89 break;
90 case SOLENOID_BUZZ_OFF:
91 #ifdef SOLENOID_ENABLE
92 if (record->event.pressed) {
93 solenoid_buzz_off();
94 }
95 #endif
96 break;
97 }
98 return true;
99};
100
101
102//Tap Dance Definitions
103qk_tap_dance_action_t tap_dance_actions[] = {
104 [TD_ESC] = ACTION_TAP_DANCE_DOUBLE(KC_GRV, KC_ESC),
105 [TD_ALTLOCK] = ACTION_TAP_DANCE_DOUBLE(KC_RALT, LGUI(KC_L)),
106 [TD_ENDLOCK] = ACTION_TAP_DANCE_DOUBLE(KC_END, LGUI(KC_L)),
107 //[TD_PRNT] = ACTION_TAP_DANCE_DOUBLE(PRINT, PRINT_SEL)
108};
109
110const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
111 if (record->event.pressed) {
112 switch(id) {
113 case 0:
114 SEND_STRING("sudo su -\n");
115 return false; break;
116 case 1:
117 SEND_STRING("puppet apply /etc/puppetlabs/code/environments/production/manifests/site.pp\n");
118 return false; break;
119 case 2:
120 SEND_STRING("ps -ef | grep ");
121 return false; break;
122 case 3: // control + insert
123 return MACRO(D(LCTL), T(INS), U(LCTL), END);
124 break;
125 case 4: // shift + insert
126 return MACRO(D(LSFT), T(INS), U(LSFT), END);
127 break;
128 case 5: // control + alt + delete
129 return MACRO(D(LCTL), D(RALT), T(DEL), U(LCTL), U(LALT), END);
130 break;
131 case 6: // lgui + L
132 return MACRO(D(LGUI), T(L), U(LGUI), END);
133 break;
134 }
135 }
136 return MACRO_NONE;
137};
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 @@
1#ifndef USERSPACE
2#define USERSPACE
3
4#include "quantum.h"
5
6#define _QWERTY 0
7#define _LOWER 1
8#define _RAISE 2
9#define _SUPER 3
10#define _ADJUST 16
11
12enum user_layers {
13 QWERTY = SAFE_RANGE,
14 LOWER,
15 RAISE,
16 SUPER,
17 ADJUST,
18};
19
20enum user_tapdance {
21 TD_ENDLOCK,
22 TD_ALTLOCK,
23 TD_ESC,
24};
25
26enum user_solenoid {
27 SOLENOID_TOG,
28 SOLENOID_DWELL_MINUS,
29 SOLENOID_DWELL_PLUS,
30 SOLENOID_BUZZ_ON,
31 SOLENOID_BUZZ_OFF,
32};
33
34#define KC_STOG SOLENOID_TOG
35#define KC_SDM SOLENOID_DWELL_MINUS
36#define KC_SDP SOLENOID_DWELL_PLUS
37#define KC_SBON SOLENOID_BUZZ_ON
38#define KC_SBOF SOLENOID_BUZZ_OFF
39
40#define KC_ KC_TRNS
41#define _______ KC_TRNS
42#define XXXXXXX KC_NO
43#define KC_xxxx KC_NO
44
45#define KC_LOWR LOWER
46#define KC_RASE RAISE
47#define KC_SUPR SUPER
48#define KC_RST RESET
49
50// TapDance Keycodes
51#define KC_EXC TD_ESC
52
53// Macro Declarations
54#define KC_ROOT M(0)
55#define KC_PPLY M(1)
56#define KC_PSEF M(2)
57#define KC_XCPY M(3)
58#define KC_XINS M(4)
59#define KC_CAD M(5)
60#define UM_LOCK M(6)
61
62// RGB and Backlighting
63#define KC_RGB RGB_TOG
64#define KC_RHUI RGB_HUI
65#define KC_RHUD RGB_HUD
66#define KC_RSAI RGB_SAI
67#define KC_RSAD RGB_SAD
68#define KC_RVAI RGB_VAI
69#define KC_RVAD RGB_VAD
70#define KC_BLT BL_TOGG
71#define KC_BLS BL_STEP
72#define KC_BLI BL_INC
73#define KC_BLD BL_DEC
74
75
76#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 @@
1Copyright 2018 @mtdjr
2
3This program is free software: you can redistribute it and/or modify
4it under the terms of the GNU General Public License as published by
5the Free Software Foundation, either version 2 of the License, or
6(at your option) any later version.
7
8This program is distributed in the hope that it will be useful,
9but WITHOUT ANY WARRANTY; without even the implied warranty of
10MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11GNU General Public License for more details.
12
13You should have received a copy of the GNU General Public License
14along 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 @@
1SRC += mtdjr.c
2TAP_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 @@
1#ifndef SOLENOID_H
2#define SOLENOID_H
3
4#include <timer.h>
5#include "pincontrol.h"
6
7#define SOLENOID_DEFAULT_DWELL 12
8#define SOLENOID_MAX_DWELL 100
9#define SOLENOID_MIN_DWELL 4
10#ifndef SOLENOID_ACTIVE
11 #define SOLENOID_ACTIVE false
12#endif
13//#define SOLENOID_PIN F6
14
15bool solenoid_enabled = SOLENOID_ACTIVE;
16bool solenoid_on = false;
17bool solenoid_buzz = false;
18bool solenoid_buzzing = false;
19uint16_t solenoid_start = 0;
20uint8_t solenoid_dwell = SOLENOID_DEFAULT_DWELL;
21
22
23void solenoid_buzz_on(void) {
24 solenoid_buzz = true;
25}
26
27void solenoid_buzz_off(void) {
28 solenoid_buzz = false;
29}
30
31void solenoid_dwell_minus(void) {
32 if (solenoid_dwell > 0) solenoid_dwell--;
33}
34
35void solenoid_dwell_plus(void) {
36 if (solenoid_dwell < SOLENOID_MAX_DWELL) solenoid_dwell++;
37}
38
39void solenoid_toggle(void) {
40 solenoid_enabled = !solenoid_enabled;
41}
42
43void solenoid_stop(void) {
44 digitalWrite(SOLENOID_PIN, PinLevelLow);
45 solenoid_on = false;
46 solenoid_buzzing = false;
47}
48
49void solenoid_fire(void) {
50 if (!solenoid_enabled) return;
51
52 if (!solenoid_buzz && solenoid_on) return;
53 if (solenoid_buzz && solenoid_buzzing) return;
54
55 solenoid_on = true;
56 solenoid_buzzing = true;
57 solenoid_start = timer_read();
58 digitalWrite(SOLENOID_PIN, PinLevelHigh);
59}
60
61void solenoid_check(void) {
62 uint16_t elapsed = 0;
63
64 if (!solenoid_on) return;
65
66 elapsed = timer_elapsed(solenoid_start);
67
68 //Check if it's time to finish this solenoid click cycle
69 if (elapsed > solenoid_dwell) {
70 solenoid_stop();
71 return;
72 }
73
74 //Check whether to buzz the solenoid on and off
75 if (solenoid_buzz) {
76 if (elapsed / SOLENOID_MIN_DWELL % 2 == 0){
77 if (!solenoid_buzzing) {
78 solenoid_buzzing = true;
79 digitalWrite(SOLENOID_PIN, PinLevelHigh);
80 }
81 }
82 else {
83 if (solenoid_buzzing) {
84 solenoid_buzzing = false;
85 digitalWrite(SOLENOID_PIN, PinLevelLow);
86 }
87 }
88 }
89}
90
91void solenoid_setup(void) {
92 pinMode(SOLENOID_PIN, PinDirectionOutput);
93}
94
95void matrix_init_user(void) {
96 solenoid_setup();
97}
98
99void matrix_scan_user(void) {
100 solenoid_check();
101}
102
103#endif