aboutsummaryrefslogtreecommitdiffstats
path: root/keyboards/deltasplit75
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/deltasplit75')
-rw-r--r--keyboards/deltasplit75/keymaps/itsaferbie/config.h7
-rw-r--r--keyboards/deltasplit75/keymaps/itsaferbie/keymap.c6
-rw-r--r--keyboards/deltasplit75/matrix.c244
-rw-r--r--keyboards/deltasplit75/readme.md137
-rw-r--r--keyboards/deltasplit75/split_util.c7
5 files changed, 220 insertions, 181 deletions
diff --git a/keyboards/deltasplit75/keymaps/itsaferbie/config.h b/keyboards/deltasplit75/keymaps/itsaferbie/config.h
index 4fb2554e0..b32d08290 100644
--- a/keyboards/deltasplit75/keymaps/itsaferbie/config.h
+++ b/keyboards/deltasplit75/keymaps/itsaferbie/config.h
@@ -29,3 +29,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifdef SUBPROJECT_protosplit
#include "../../protosplit/config.h"
#endif
+
+#undef RGBLED_NUM
+#define RGBLIGHT_ANIMATIONS
+#define RGBLED_NUM 20
+#define RGBLIGHT_HUE_STEP 8
+#define RGBLIGHT_SAT_STEP 8
+#define RGBLIGHT_VAL_STEP 8
diff --git a/keyboards/deltasplit75/keymaps/itsaferbie/keymap.c b/keyboards/deltasplit75/keymaps/itsaferbie/keymap.c
index 82c292f49..bc0b23868 100644
--- a/keyboards/deltasplit75/keymaps/itsaferbie/keymap.c
+++ b/keyboards/deltasplit75/keymaps/itsaferbie/keymap.c
@@ -24,16 +24,16 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* |----------------------------------------------------------------------|
* |Shif| | Z| X| C| V| B| N| M| ,| .| /|Shift | Up| End|
* |----------------------------------------------------------------------|
- * |CapsLo|Gui |Alt |Sp |Mod | Sp| Alt| Gui| Ctrl| | Lef| Dow| Rig|
+ * |CapsLo|Gui |Alt |Mod|Sp | Sp| Alt| Gui| Ctrl| | Lef| Dow| Rig|
* `----------------------------------------------------------------------'
*/
KEYMAP_V2(
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_INS, KC_DEL,
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_TRNS, KC_HOME, // KC_TRNS is the unneeded key in the split backspace.
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_PGUP,
- KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_TRNS, KC_ENT, KC_PGDN, // KC_TRNS is unneeded ISO enter key.
+ KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_TRNS, KC_ENT, KC_PGDN, // KC_TRNS is uneeded ISO enter key.
KC_LSFT, KC_TRNS, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_END, // KC_TRNS is uneeded ISO layout key.
- KC_CAPS, KC_LGUI, KC_LALT, KC_SPC, MO(1), KC_SPC, KC_RALT, KC_RGUI, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),
+ KC_CAPS, KC_LGUI, KC_LALT, MO(1), KC_SPC, KC_SPC, KC_RALT, KC_RGUI, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),
KEYMAP_V2(
RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RESET,
diff --git a/keyboards/deltasplit75/matrix.c b/keyboards/deltasplit75/matrix.c
index 138969004..4def27239 100644
--- a/keyboards/deltasplit75/matrix.c
+++ b/keyboards/deltasplit75/matrix.c
@@ -21,9 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdint.h>
#include <stdbool.h>
#include <avr/io.h>
-#include <avr/wdt.h>
-#include <avr/interrupt.h>
-#include <util/delay.h>
+#include "wait.h"
#include "print.h"
#include "debug.h"
#include "util.h"
@@ -31,6 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "split_util.h"
#include "pro_micro.h"
#include "config.h"
+#include "timer.h"
#ifdef USE_I2C
# include "i2c.h"
@@ -38,14 +37,29 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# include "serial.h"
#endif
-#ifndef DEBOUNCE
-# define DEBOUNCE 5
+#ifndef DEBOUNCING_DELAY
+# define DEBOUNCING_DELAY 5
#endif
+#if (DEBOUNCING_DELAY > 0)
+ static uint16_t debouncing_time;
+ static bool debouncing = false;
+#endif
+
+#if (MATRIX_COLS <= 8)
+# define print_matrix_header() print("\nr/c 01234567\n")
+# define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row))
+# define matrix_bitpop(i) bitpop(matrix[i])
+# define ROW_SHIFTER ((uint8_t)1)
+#else
+# error "Currently only supports 8 COLS"
+#endif
+static matrix_row_t matrix_debouncing[MATRIX_ROWS];
+
#define ERROR_DISCONNECT_COUNT 5
-static uint8_t debouncing = DEBOUNCE;
-static const int ROWS_PER_HAND = MATRIX_ROWS/2;
+#define ROWS_PER_HAND (MATRIX_ROWS/2)
+
static uint8_t error_count = 0;
static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
@@ -55,11 +69,19 @@ static const uint8_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
static matrix_row_t matrix[MATRIX_ROWS];
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
-static matrix_row_t read_cols(void);
-static void init_cols(void);
-static void unselect_rows(void);
-static void select_row(uint8_t row);
-
+#if (DIODE_DIRECTION == COL2ROW)
+ static void init_cols(void);
+ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row);
+ static void unselect_rows(void);
+ static void select_row(uint8_t row);
+ static void unselect_row(uint8_t row);
+#elif (DIODE_DIRECTION == ROW2COL)
+ static void init_rows(void);
+ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col);
+ static void unselect_cols(void);
+ static void unselect_col(uint8_t col);
+ static void select_col(uint8_t col);
+#endif
__attribute__ ((weak))
void matrix_init_quantum(void) {
matrix_init_kb();
@@ -118,33 +140,54 @@ void matrix_init(void)
}
matrix_init_quantum();
+
}
uint8_t _matrix_scan(void)
{
- // Right hand is stored after the left in the matirx so, we need to offset it
int offset = isLeftHand ? 0 : (ROWS_PER_HAND);
+#if (DIODE_DIRECTION == COL2ROW)
+ // Set row, read cols
+ for (uint8_t current_row = 0; current_row < ROWS_PER_HAND; current_row++) {
+# if (DEBOUNCING_DELAY > 0)
+ bool matrix_changed = read_cols_on_row(matrix_debouncing+offset, current_row);
+
+ if (matrix_changed) {
+ debouncing = true;
+ debouncing_time = timer_read();
+ PORTD ^= (1 << 2);
+ }
+
+# else
+ read_cols_on_row(matrix+offset, current_row);
+# endif
+
+ }
+
+#elif (DIODE_DIRECTION == ROW2COL)
+ // Set col, read rows
+ for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) {
+# if (DEBOUNCING_DELAY > 0)
+ bool matrix_changed = read_rows_on_col(matrix_debouncing+offset, current_col);
+ if (matrix_changed) {
+ debouncing = true;
+ debouncing_time = timer_read();
+ }
+# else
+ read_rows_on_col(matrix+offset, current_col);
+# endif
- for (uint8_t i = 0; i < ROWS_PER_HAND; i++) {
- select_row(i);
- _delay_us(30); // without this wait read unstable value.
- matrix_row_t cols = read_cols();
- if (matrix_debouncing[i+offset] != cols) {
- matrix_debouncing[i+offset] = cols;
- debouncing = DEBOUNCE;
- }
- unselect_rows();
}
+#endif
- if (debouncing) {
- if (--debouncing) {
- _delay_ms(1);
- } else {
+# if (DEBOUNCING_DELAY > 0)
+ if (debouncing && (timer_elapsed(debouncing_time) > DEBOUNCING_DELAY)) {
for (uint8_t i = 0; i < ROWS_PER_HAND; i++) {
matrix[i+offset] = matrix_debouncing[i+offset];
}
+ debouncing = false;
}
- }
+# endif
return 1;
}
@@ -200,9 +243,7 @@ int serial_transaction(void) {
uint8_t matrix_scan(void)
{
- int ret = _matrix_scan();
-
-
+ uint8_t ret = _matrix_scan();
#ifdef USE_I2C
if( i2c_transaction() ) {
@@ -226,20 +267,17 @@ uint8_t matrix_scan(void)
TXLED0;
error_count = 0;
}
-
matrix_scan_quantum();
-
return ret;
}
void matrix_slave_scan(void) {
_matrix_scan();
- int offset = (isLeftHand) ? 0 : (MATRIX_ROWS / 2);
+ int offset = (isLeftHand) ? 0 : ROWS_PER_HAND;
#ifdef USE_I2C
for (int i = 0; i < ROWS_PER_HAND; ++i) {
- /* i2c_slave_buffer[i] = matrix[offset+i]; */
i2c_slave_buffer[i] = matrix[offset+i];
}
#else // USE_SERIAL
@@ -286,33 +324,141 @@ uint8_t matrix_key_count(void)
return count;
}
-static void init_cols(void)
+#if (DIODE_DIRECTION == COL2ROW)
+
+static void init_cols(void)
{
- for(int x = 0; x < MATRIX_COLS; x++) {
- _SFR_IO8((col_pins[x] >> 4) + 1) &= ~_BV(col_pins[x] & 0xF);
- _SFR_IO8((col_pins[x] >> 4) + 2) |= _BV(col_pins[x] & 0xF);
+ for(uint8_t x = 0; x < MATRIX_COLS; x++) {
+ uint8_t pin = col_pins[x];
+ _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN
+ _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI
}
}
-static matrix_row_t read_cols(void)
+static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
{
- matrix_row_t result = 0;
- for(int x = 0; x < MATRIX_COLS; x++) {
- result |= (_SFR_IO8(col_pins[x] >> 4) & _BV(col_pins[x] & 0xF)) ? 0 : (1 << x);
+ // Store last value of row prior to reading
+ matrix_row_t last_row_value = current_matrix[current_row];
+
+ // Clear data in matrix row
+ current_matrix[current_row] = 0;
+
+ // Select row and wait for row selecton to stabilize
+ select_row(current_row);
+ wait_us(30);
+
+ // For each col...
+ for(uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {
+
+ // Select the col pin to read (active low)
+ uint8_t pin = col_pins[col_index];
+ uint8_t pin_state = (_SFR_IO8(pin >> 4) & _BV(pin & 0xF));
+
+ // Populate the matrix row with the state of the col pin
+ current_matrix[current_row] |= pin_state ? 0 : (ROW_SHIFTER << col_index);
}
- return result;
+
+ // Unselect row
+ unselect_row(current_row);
+
+ return (last_row_value != current_matrix[current_row]);
+}
+
+static void select_row(uint8_t row)
+{
+ uint8_t pin = row_pins[row];
+ _SFR_IO8((pin >> 4) + 1) |= _BV(pin & 0xF); // OUT
+ _SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF); // LOW
+}
+
+static void unselect_row(uint8_t row)
+{
+ uint8_t pin = row_pins[row];
+ _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN
+ _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI
}
static void unselect_rows(void)
{
- for(int x = 0; x < ROWS_PER_HAND; x++) {
- _SFR_IO8((row_pins[x] >> 4) + 1) &= ~_BV(row_pins[x] & 0xF);
- _SFR_IO8((row_pins[x] >> 4) + 2) |= _BV(row_pins[x] & 0xF);
+ for(uint8_t x = 0; x < ROWS_PER_HAND; x++) {
+ uint8_t pin = row_pins[x];
+ _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN
+ _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI
}
}
-static void select_row(uint8_t row)
+#elif (DIODE_DIRECTION == ROW2COL)
+
+static void init_rows(void)
{
- _SFR_IO8((row_pins[row] >> 4) + 1) |= _BV(row_pins[row] & 0xF);
- _SFR_IO8((row_pins[row] >> 4) + 2) &= ~_BV(row_pins[row] & 0xF);
+ for(uint8_t x = 0; x < ROWS_PER_HAND; x++) {
+ uint8_t pin = row_pins[x];
+ _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN
+ _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI
+ }
}
+
+static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)
+{
+ bool matrix_changed = false;
+
+ // Select col and wait for col selecton to stabilize
+ select_col(current_col);
+ wait_us(30);
+
+ // For each row...
+ for(uint8_t row_index = 0; row_index < ROWS_PER_HAND; row_index++)
+ {
+
+ // Store last value of row prior to reading
+ matrix_row_t last_row_value = current_matrix[row_index];
+
+ // Check row pin state
+ if ((_SFR_IO8(row_pins[row_index] >> 4) & _BV(row_pins[row_index] & 0xF)) == 0)
+ {
+ // Pin LO, set col bit
+ current_matrix[row_index] |= (ROW_SHIFTER << current_col);
+ }
+ else
+ {
+ // Pin HI, clear col bit
+ current_matrix[row_index] &= ~(ROW_SHIFTER << current_col);
+ }
+
+ // Determine if the matrix changed state
+ if ((last_row_value != current_matrix[row_index]) && !(matrix_changed))
+ {
+ matrix_changed = true;
+ }
+ }
+
+ // Unselect col
+ unselect_col(current_col);
+
+ return matrix_changed;
+}
+
+static void select_col(uint8_t col)
+{
+ uint8_t pin = col_pins[col];
+ _SFR_IO8((pin >> 4) + 1) |= _BV(pin & 0xF); // OUT
+ _SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF); // LOW
+}
+
+static void unselect_col(uint8_t col)
+{
+ uint8_t pin = col_pins[col];
+ _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN
+ _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI
+}
+
+static void unselect_cols(void)
+{
+ for(uint8_t x = 0; x < MATRIX_COLS; x++) {
+ uint8_t pin = col_pins[x];
+ _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN
+ _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI
+ }
+}
+
+#endif
diff --git a/keyboards/deltasplit75/readme.md b/keyboards/deltasplit75/readme.md
index 04ed35c29..a1e35e337 100644
--- a/keyboards/deltasplit75/readme.md
+++ b/keyboards/deltasplit75/readme.md
@@ -1,137 +1,18 @@
DeltaSplit75
======
-This readme and most of the code are from https://github.com/ahtn/tmk_keyboard/ and https://github.com/qmk/qmk_firmware/tree/master/keyboards/lets_split
+A split 75% keyboard made by xyxjj. [More info on qmk.fm](http://qmk.fm/deltasplit75/)
-Credit to ahtn and wootpatoot for work on the split keyboard firmware
+Keyboard Maintainer: [xyxjj](https://github.com/xyxjj)
+Hardware Supported: Pro Micro
+Hardware Availability: Group Buy
-Split keyboard firmware for Arduino Pro Micro or other ATmega32u4
-based boards.
+Make example for this keyboard (after setting up your build environment):
-## Case Files
-Files are available here: https://github.com/xyxjj/DeltaSplit75-Case-files
+ make deltasplit75-v2-default
-## Build Guide
-The build guide should be found at https://qmk.fm/deltasplit75
+See [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.
+Files are available here: [DeltaSplit75 Case Files](https://github.com/xyxjj/DeltaSplit75-Case-files)
-## First Time Setup
-
-Download or clone the whole firmware and navigate to the keyboards/deltasplit75 directory. Once your dev env is setup, you'll be able to generate the .hex using:
-
-```
-make v2
-
-or
-
-make v2-YOUR_KEYMAP_NAME (if you make a folder for your keymap)
-
-or
-
-make protosplit (if you have one of the prototype PCBs)
-```
-
-You will see a lot of output and if everything worked correctly you will see the built hex files:
-
-```
-deltasplit75_v2_protosplit.hex
-
-or
-
-deltasplit74_v2_YOUR_KEYMAP_NAME.hex
-
-or
-
-deltasplit75_v2_default.hex
-
-```
-
-
-For more information on customizing keymaps, take a look at the primary documentation for [Customizing Your Keymap](/readme.md##customizing-your-keymap) in the main readme.md.
-
-### DeltaSplit75 V2
-The PCBs available in groupbuy are all v2, if you've bought one of my prototype PCBs (it says DeltaSplit65 on the silkscreen instead of 75), use the code make protosplit instead
-
-Features
---------
-
-For the full Quantum Mechanical Keyboard feature list, see [the parent readme.md](/readme.md).
-
-Some features supported by the firmware:
-
-* Either half can connect to the computer via USB, or both halves can be used
- independently.
-* 75% formfactor
-* Support for multiple Bottom Rows
-* RGB underglow support
-* Split Backspace and ISO support
-
-
-Flashing
--------
-I personally use xLoader to upload my hex files to the keyboard, though any other working software is fine too
-
-
-Choosing which board to plug the USB cable into (choosing Master)
---------
-Because the two boards are identical, the firmware has logic to differentiate the left and right board.
-
-It 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.
-
-The EEPROM approach requires additional setup (flashing the eeeprom) but allows you to swap the usb cable to either side.
-
-The 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.
-
-### Setting the left hand as master
-If 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.
-
-### Setting the right hand as master
-If you always plug the usb cable into the right board, add an extra flag to your `config.h`
-```
- #define MASTER_RIGHT
-```
-
-### Setting EE_hands to use either hands as master
-If you define `EE_HANDS` in your `config.h`, you will need to set the
-EEPROM for the left and right halves.
-
-The EEPROM is used to store whether the
-half is left handed or right handed. This makes it so that the same firmware
-file will run on both hands instead of having to flash left and right handed
-versions of the firmware to each half. To flash the EEPROM file for the left
-half run:
-```
-avrdude -p atmega32u4 -P $(COM_PORT) -c avr109 -U eeprom:w:eeprom-lefthand.eep
-// or the equivalent in dfu-programmer
-
-```
-and similarly for right half
-```
-avrdude -p atmega32u4 -P $(COM_PORT) -c avr109 -U eeprom:w:eeprom-righhand.eep
-// or the equivalent in dfu-programmer
-```
-
-NOTE: replace `$(COM_PORT)` with the port of your device (e.g. `/dev/ttyACM0`)
-
-After you have flashed the EEPROM, you then need to set `EE_HANDS` in your config.h, rebuild the hex files and reflash.
-
-Note that you need to program both halves, but you have the option of using
-different keymaps for each half. You could program the left half with a QWERTY
-layout and the right half with a Colemak layout using bootmagic's default layout option.
-Then if you connect the left half to a computer by USB the keyboard will use QWERTY and Colemak when the
-right half is connected.
-
-
-Notes on Using Pro Micro 3.3V
------------------------------
-
-Do update the `F_CPU` parameter in `rules.mk` to `8000000` which reflects
-the frequency on the 3.3V board.
-
-Also, if the slave board is producing weird characters in certain columns,
-update the following line in `matrix.c` to the following:
-
-```
-// _delay_us(30); // without this wait read unstable value.
-_delay_us(300); // without this wait read unstable value.
-```
+The build guide should be found here: [DeltaSplit75 Build Guide](http://qmk.fm/deltasplit75/)
diff --git a/keyboards/deltasplit75/split_util.c b/keyboards/deltasplit75/split_util.c
index 226dc1881..346cbc908 100644
--- a/keyboards/deltasplit75/split_util.c
+++ b/keyboards/deltasplit75/split_util.c
@@ -8,6 +8,7 @@
#include "matrix.h"
#include "keyboard.h"
#include "config.h"
+#include "timer.h"
#ifdef USE_I2C
# include "i2c.h"
@@ -21,7 +22,7 @@ static void setup_handedness(void) {
#ifdef EE_HANDS
isLeftHand = eeprom_read_byte(EECONFIG_HANDEDNESS);
#else
- // I2C_MASTER_RIGHT is deprecated use MASTER_RIGHT instead since this works for both serial and i2c
+ // I2C_MASTER_RIGHT is deprecated, use MASTER_RIGHT instead, since this works for both serial and i2c
#if defined(I2C_MASTER_RIGHT) || defined(MASTER_RIGHT)
isLeftHand = !has_usb();
#else
@@ -33,12 +34,16 @@ static void setup_handedness(void) {
static void keyboard_master_setup(void) {
#ifdef USE_I2C
i2c_master_init();
+#ifdef SSD1306OLED
+ matrix_master_OLED_init ();
+#endif
#else
serial_master_init();
#endif
}
static void keyboard_slave_setup(void) {
+ timer_init();
#ifdef USE_I2C
i2c_slave_init(SLAVE_I2C_ADDRESS);
#else