Get all hardware working.

pull/5516/merge^2
skullY 6 years ago
parent f1064de3e1
commit 269de5f4d7

@ -17,46 +17,111 @@
#include "encoder.h"
void matrix_init_kb(void) {
// Set our LED pins as output
DDRB |= (1<<4); // Numlock
DDRB |= (1<<5); // Capslock
DDRB |= (1<<6); // Scroll Lock
// Set our LED pins as output
setPinOutput(B4);
setPinOutput(B5);
setPinOutput(B6);
// Run the keymap level init
matrix_init_user();
// Set our Tilt Sensor pins as input
setPinInputHigh(SHAKE_PIN_A);
setPinInputHigh(SHAKE_PIN_B);
// Run the keymap level init
matrix_init_user();
}
#ifdef SHAKE_ENABLE
uint8_t tilt_state[2] = {1,1};
uint8_t detected_shakes = 0;
static uint16_t shake_timer;
#endif
void matrix_scan_kb(void) {
matrix_scan_user();
#ifdef SHAKE_ENABLE
// Read the current state of the tilt sensor. It is physically
// impossible for both pins to register a low state at the same time.
uint8_t tilt_read[2] = {readPin(SHAKE_PIN_A), readPin(SHAKE_PIN_B)};
// Check to see if the tilt sensor has changed state since our last read
for (uint8_t i = 0; i < 2; i++) {
if (tilt_state[i] != tilt_read[i]) {
shake_timer = timer_read();
detected_shakes++;
tilt_state[i] = tilt_read[i];
}
}
if ((detected_shakes > 0) && (timer_elapsed(shake_timer) > SHAKE_TIMEOUT)) {
if (detected_shakes > SHAKE_COUNT) {
dprintf("Shake detected! We had %d shakes detected.\n", detected_shakes);
tap_code16(SHAKE_KEY);
}
detected_shakes = 0;
}
#endif
matrix_scan_user();
}
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
return process_record_user(keycode, record);
return process_record_user(keycode, record);
}
void led_set_kb(uint8_t usb_led) {
// Toggle numlock as needed
if (usb_led & (1<<USB_LED_NUM_LOCK)) {
PORTB |= (1<<4);
} else {
PORTB &= ~(1<<4);
}
// Toggle capslock as needed
if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
PORTB |= (1<<5);
} else {
PORTB &= ~(1<<5);
}
// Toggle scrolllock as needed
if (usb_led & (1<<USB_LED_SCROLL_LOCK)) {
PORTB |= (1<<6);
} else {
PORTB &= ~(1<<6);
}
// Toggle numlock as needed
if (usb_led & (1<<USB_LED_NUM_LOCK)) {
writePinHigh(B4);
} else {
writePinLow(B4);
}
// Toggle capslock as needed
if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
writePinHigh(B5);
} else {
writePinLow(B5);
}
// Toggle scrolllock as needed
if (usb_led & (1<<USB_LED_SCROLL_LOCK)) {
writePinHigh(B6);
} else {
writePinLow(B6);
}
}
bool encoder_update_keymap(int8_t index, bool clockwise) {
return false;
}
void encoder_update_kb(int8_t index, bool clockwise) {
encoder_update_user(index, clockwise);
if (!encoder_update_keymap(index, clockwise)) {
// Encoder 1, outside left
if (index == 0 && clockwise) {
tap_code(KC_MS_U); // turned right
} else if (index == 0) {
tap_code(KC_MS_D); // turned left
}
// Encoder 2, inside left
else if (index == 1 && clockwise) {
tap_code(KC_WH_D); // turned right
} else if (index == 1) {
tap_code(KC_WH_U); // turned left
}
// Encoder 3, inside right
else if (index == 2 && clockwise) {
tap_code(KC_VOLU); // turned right
} else if (index == 2) {
tap_code(KC_VOLD); // turned left
}
// Encoder 4, outside right
else if (index == 3 && clockwise) {
tap_code(KC_MS_R); // turned right
} else if (index == 3) {
tap_code(KC_MS_L); // turned left
}
}
}

@ -189,3 +189,7 @@
}
#define LAYOUT LAYOUT_all
// Encoder update function that returns true/false
__attribute__ ((weak))
bool encoder_update_keymap(int8_t index, bool clockwise);

@ -46,15 +46,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define MATRIX_COL_PINS { D2, D3, D4, D5, D7, E0, E1, B0, E6, B3, B2 }
#define UNUSED_PINS { D0, D1, D6, C5, E7, F0, F1 }
/*
#define NUMBER_OF_ENCODERS 4
#define ENCODERS_PAD_A { A1, A0, A7, A5 }
#define ENCODERS_PAD_B { A2, A3, A6, A4 }
*/
#define NUMBER_OF_ENCODERS 1
#define ENCODERS_PAD_A { A1 }
#define ENCODERS_PAD_B { A2 }
#define ENCODER_RESOLUTION 2
#define ENCODERS_PAD_A { A5, A4, A2, A1 }
#define ENCODERS_PAD_B { A6, A7, A3, A0 }
#define ENCODER_RESOLUTION 4
/* COL2ROW, ROW2COL*/
#define DIODE_DIRECTION ROW2COL
@ -80,7 +75,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* Locking resynchronize hack */
#define LOCKING_RESYNC_ENABLE
#define RGB_DI_PIN C6
#define RGB_DI_PIN C5
#define RGBLIGHT_ANIMATIONS
#define RGBLED_NUM 16
#define RGBLIGHT_HUE_STEP 8
@ -203,3 +198,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//#define MIDI_TONE_KEYCODE_OCTAVES 1
#endif
/*
* Key to press when we do shake to undo.
*/
#define SHAKE_PIN_A E4
#define SHAKE_PIN_B E5
#define SHAKE_TIMEOUT 500 // How long after shaking stops before we register it
#define SHAKE_COUNT 8 // How many shakes it takes to activate
//#define SHAKE_KEY LGUI(KC_Z) // What key to send after a shake
//#define SHAKE_KEY LCTL(KC_Z)
#define SHAKE_KEY LGUI(KC_SLSH)

@ -17,7 +17,7 @@
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT_all( \
KC_1, KC_2, KC_3, KC_4, \
KC_BTN1, KC_BTN2, KC_BTN3, KC_BTN4, \
KC_HOME, KC_END, KC_PGUP, KC_PGDN, KC_ESC, 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_PSCR, KC_SLCK, KC_PAUS, KC_INS, \
\
KC_PMNS, KC_NLCK, KC_PSLS, KC_PAST, KC_GRV, 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_NLCK, KC_PSLS, KC_PAST, KC_PMNS, \
@ -27,35 +27,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_P0, KC_PDOT, KC_LEFT, KC_DOWN, KC_RGHT, KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_SPC, KC_SPC, KC_SPC, KC_RALT, KC_RGUI, KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT \
)
};
#ifdef ENCODER_ENABLE
void encoder_update_user(uint8_t index, bool clockwise) {
// Encoder 1, outside left
if (index == 0 && clockwise) {
tap_code(KC_MS_U); // turned right
} else if (index == 0) {
tap_code(KC_MS_D); // turned left
}
// Encoder 2, inside left
else if (index == 1 && clockwise) {
tap_code(KC_WH_D); // turned right
} else if (index == 1) {
tap_code(KC_WH_U); // turned left
}
// Encoder 3, inside right
else if (index == 2 && clockwise) {
tap_code(KC_VOLU); // turned right
} else if (index == 2) {
tap_code(KC_VOLD); // turned left
}
// Encoder 4, outside right
else if (index == 3 && clockwise) {
tap_code(KC_MS_R); // turned right
} else if (index == 3) {
tap_code(KC_MS_L); // turned left
}
}
#endif

@ -27,35 +27,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_P0, KC_PDOT, KC_LEFT, KC_DOWN, KC_RGHT, KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_SPC, KC_SPC, KC_SPC, KC_RALT, KC_RGUI, KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT \
)
};
#ifdef ENCODER_ENABLE
void encoder_update_user(uint8_t index, bool clockwise) {
// Encoder 1, outside left
if (index == 0 && clockwise) {
tap_code(KC_MS_U); // turned right
} else if (index == 0) {
tap_code(KC_MS_D); // turned left
}
// Encoder 2, inside left
else if (index == 1 && clockwise) {
tap_code(KC_WH_D); // turned right
} else if (index == 1) {
tap_code(KC_WH_U); // turned left
}
// Encoder 3, inside right
else if (index == 2 && clockwise) {
tap_code(KC_VOLU); // turned right
} else if (index == 2) {
tap_code(KC_VOLD); // turned left
}
// Encoder 4, outside right
else if (index == 3 && clockwise) {
tap_code(KC_MS_R); // turned right
} else if (index == 3) {
tap_code(KC_MS_L); // turned left
}
}
#endif

@ -27,35 +27,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_P0, KC_PDOT, KC_LEFT, KC_DOWN, KC_RGHT, KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_SPC, KC_SPC, KC_SPC, KC_RALT, KC_RGUI, KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT \
)
};
#ifdef ENCODER_ENABLE
void encoder_update_user(uint8_t index, bool clockwise) {
// Encoder 1, outside left
if (index == 0 && clockwise) {
tap_code(KC_MS_U); // turned right
} else if (index == 0) {
tap_code(KC_MS_D); // turned left
}
// Encoder 2, inside left
else if (index == 1 && clockwise) {
tap_code(KC_WH_D); // turned right
} else if (index == 1) {
tap_code(KC_WH_U); // turned left
}
// Encoder 3, inside right
else if (index == 2 && clockwise) {
tap_code(KC_VOLU); // turned right
} else if (index == 2) {
tap_code(KC_VOLD); // turned left
}
// Encoder 4, outside right
else if (index == 3 && clockwise) {
tap_code(KC_MS_R); // turned right
} else if (index == 3) {
tap_code(KC_MS_L); // turned left
}
}
#endif

@ -27,35 +27,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_P0, KC_PDOT, KC_LEFT, KC_DOWN, KC_RGHT, KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RGUI, KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT \
)
};
#ifdef ENCODER_ENABLE
void encoder_update_user(uint8_t index, bool clockwise) {
// Encoder 1, outside left
if (index == 0 && clockwise) {
tap_code(KC_MS_U); // turned right
} else if (index == 0) {
tap_code(KC_MS_D); // turned left
}
// Encoder 2, inside left
else if (index == 1 && clockwise) {
tap_code(KC_WH_D); // turned right
} else if (index == 1) {
tap_code(KC_WH_U); // turned left
}
// Encoder 3, inside right
else if (index == 2 && clockwise) {
tap_code(KC_VOLU); // turned right
} else if (index == 2) {
tap_code(KC_VOLD); // turned left
}
// Encoder 4, outside right
else if (index == 3 && clockwise) {
tap_code(KC_MS_R); // turned right
} else if (index == 3) {
tap_code(KC_MS_L); // turned left
}
}
#endif

@ -27,35 +27,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_P0, KC_PDOT, KC_LEFT, KC_DOWN, KC_RGHT, KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RGUI, KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT \
)
};
#ifdef ENCODER_ENABLE
void encoder_update_user(uint8_t index, bool clockwise) {
// Encoder 1, outside left
if (index == 0 && clockwise) {
tap_code(KC_MS_U); // turned right
} else if (index == 0) {
tap_code(KC_MS_D); // turned left
}
// Encoder 2, inside left
else if (index == 1 && clockwise) {
tap_code(KC_WH_D); // turned right
} else if (index == 1) {
tap_code(KC_WH_U); // turned left
}
// Encoder 3, inside right
else if (index == 2 && clockwise) {
tap_code(KC_VOLU); // turned right
} else if (index == 2) {
tap_code(KC_VOLD); // turned left
}
// Encoder 4, outside right
else if (index == 3 && clockwise) {
tap_code(KC_MS_R); // turned right
} else if (index == 3) {
tap_code(KC_MS_L); // turned left
}
}
#endif

@ -27,35 +27,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_P0, KC_PDOT, KC_LEFT, KC_DOWN, KC_RGHT, KC_LCTL, KC_LALT, KC_SPC, KC_LGUI, KC_APP, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT \
)
};
#ifdef ENCODER_ENABLE
void encoder_update_user(uint8_t index, bool clockwise) {
// Encoder 1, outside left
if (index == 0 && clockwise) {
tap_code(KC_MS_U); // turned right
} else if (index == 0) {
tap_code(KC_MS_D); // turned left
}
// Encoder 2, inside left
else if (index == 1 && clockwise) {
tap_code(KC_WH_D); // turned right
} else if (index == 1) {
tap_code(KC_WH_U); // turned left
}
// Encoder 3, inside right
else if (index == 2 && clockwise) {
tap_code(KC_VOLU); // turned right
} else if (index == 2) {
tap_code(KC_VOLD); // turned left
}
// Encoder 4, outside right
else if (index == 3 && clockwise) {
tap_code(KC_MS_R); // turned right
} else if (index == 3) {
tap_code(KC_MS_L); // turned left
}
}
#endif

@ -27,35 +27,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_P0, KC_PDOT, KC_LEFT, KC_DOWN, KC_RGHT, KC_LCTL, KC_LALT, KC_SPC, KC_LGUI, KC_APP, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT \
)
};
#ifdef ENCODER_ENABLE
void encoder_update_user(uint8_t index, bool clockwise) {
// Encoder 1, outside left
if (index == 0 && clockwise) {
tap_code(KC_MS_U); // turned right
} else if (index == 0) {
tap_code(KC_MS_D); // turned left
}
// Encoder 2, inside left
else if (index == 1 && clockwise) {
tap_code(KC_WH_D); // turned right
} else if (index == 1) {
tap_code(KC_WH_U); // turned left
}
// Encoder 3, inside right
else if (index == 2 && clockwise) {
tap_code(KC_VOLU); // turned right
} else if (index == 2) {
tap_code(KC_VOLD); // turned left
}
// Encoder 4, outside right
else if (index == 3 && clockwise) {
tap_code(KC_MS_R); // turned right
} else if (index == 3) {
tap_code(KC_MS_L); // turned left
}
}
#endif

@ -8,14 +8,15 @@ OPT_DEFS += -DBOOTLOADER_SIZE=1024
# Build Options
BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
CONSOLE_ENABLE = yes # Console for debug(+400)
BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration
MOUSEKEY_ENABLE = yes # Mouse keys
EXTRAKEY_ENABLE = yes # Audio control and System control
CONSOLE_ENABLE = yes # Console for debug
COMMAND_ENABLE = no # Commands for debug and configuration
ENCODER_ENABLE = yes
ENCODER_ENABLE = yes # Rotary encoder (knob) support
NKRO_ENABLE = yes # USB Nkey Rollover
MIDI_ENABLE = no # MIDI support (+2400 to 4200, depending on config)
MIDI_ENABLE = no # MIDI support
UNICODE_ENABLE = no # Unicode
RGBLIGHT_ENABLE = yes # RGB on port C6
AUDIO_ENABLE = yes # Audio output on port C4 and B7
RGBLIGHT_ENABLE = yes # RGB on pin C5
AUDIO_ENABLE = yes # Audio output on pin C4 and B7
SHAKE_ENABLE = yes # Shake to undo

@ -22,10 +22,7 @@
void encoder_init(void);
void encoder_read(void);
__attribute__((weak))
void encoder_update_kb(int8_t index, bool clockwise);
__attribute__((weak))
void encoder_update_user(int8_t index, bool clockwise);
#ifdef SPLIT_KEYBOARD

Loading…
Cancel
Save