keymap and mapping

titmlb
Jack Humbert 6 years ago
parent beaf774a81
commit d16568eca9

@ -25,7 +25,14 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H,
KC_LSFT,KC_Z, KC_X, KC_C, KC_V, KC_B,
MO(1),KC_LCTL,KC_LALT,KC_LGUI,KC_RALT,
KC_BSPC,KC_SPC, KC_ENT
KC_BSPC,KC_SPC, KC_ENT,
KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC,
KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_DEL,
KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN,KC_QUOT,
KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH,KC_ENT,
KC_RALT,KC_LGUI,KC_LALT,KC_LCTL,MO(1),
KC_ENT,KC_SPC, KC_BSPC
),
[1] = LAYOUT_moonlander(
@ -34,7 +41,14 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H,
KC_LSFT,KC_Z, KC_X, KC_C, KC_V, KC_B,
MO(1),KC_LCTL,KC_LALT,KC_LGUI,KC_RALT,
KC_BSPC,KC_SPC, KC_ENT
KC_BSPC,KC_SPC, KC_ENT,
KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC,
KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_DEL,
KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN,KC_QUOT,
KC_B, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH,
KC_RALT,KC_LGUI,KC_LALT,KC_LCTL,MO(1),
KC_ENT,KC_SPC, KC_BSPC
)
};

@ -37,12 +37,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* matrix state(1:on, 0:off) */
static matrix_row_t matrix[MATRIX_ROWS];
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
static matrix_row_t matrix_debouncing[6];
static matrix_row_t matrix_debouncing_right[MATRIX_COLS];
static bool debouncing = false;
static uint16_t debouncing_time = 0;
static bool debouncing_right = false;
static uint16_t debouncing_time_right = 0;
extern bool mcp23018_leds[3];
__attribute__ ((weak))
void matrix_init_user(void) {}
@ -68,12 +71,13 @@ void mcp23018_init(void) {
i2c_init();
i2c_start(MCP23018_DEFAULT_ADDRESS << 1);
// #define MCP23_ROW_PINS { GPB5, GBP4, GBP3, GBP2, GBP1, GBP0 } outputs
// #define MCP23_COL_PINS { GPA0, GBA1, GBA2, GBA3, GBA4, GBA5, GBA6 } inputs
mcp23018_tx[0] = 0x00; // IODIRA
mcp23018_tx[1] = 0x00; // ?
mcp23018_tx[2] = 0b00111111; // A is inputs
mcp23018_tx[1] = 0b00000000; // A is output
mcp23018_tx[2] = 0b00111111; // B is inputs
if (MSG_OK != i2c_transmit(MCP23018_DEFAULT_ADDRESS << 1,
mcp23018_tx, 3, 100
@ -81,8 +85,8 @@ void mcp23018_init(void) {
printf("error hori\n");
} else {
mcp23018_tx[0] = 0x0C; // GPPUA
mcp23018_tx[1] = 0x00; // ?
mcp23018_tx[2] = 0b00111111; // pull-up As
mcp23018_tx[1] = 0b10000000; // A is not pulled-up
mcp23018_tx[2] = 0b11111111; // B is pulled-up
if (MSG_OK != i2c_transmit(MCP23018_DEFAULT_ADDRESS << 1,
mcp23018_tx, 3, 100
@ -125,9 +129,9 @@ void matrix_init(void) {
uint8_t matrix_scan(void) {
matrix_row_t data = 0;
// actual matrix
for (int row = 0; row < 6; row++) {
matrix_row_t data = 0;
// strobe row
switch (row) {
@ -168,9 +172,10 @@ uint8_t matrix_scan(void) {
debouncing = true;
debouncing_time = timer_read();
}
}
for (int row = 0; row < 7; row++) {
// right side
if (!mcp23018_initd) {
@ -184,10 +189,11 @@ uint8_t matrix_scan(void) {
// select row
mcp23018_tx[0] = 0x12; // GPIOA
mcp23018_tx[1] = 0xFF & ~(1<<(row)); // activate row
mcp23018_tx[1] = (0b01111111 & ~(1<<(row))) | ((uint8_t)mcp23018_leds[2] << 7); // activate row
mcp23018_tx[2] = ((uint8_t)mcp23018_leds[1] << 6) | ((uint8_t)mcp23018_leds[0] << 7); // activate row
if (MSG_OK != i2c_transmit(MCP23018_DEFAULT_ADDRESS << 1,
mcp23018_tx, 2, 100
mcp23018_tx, 3, 100
)) {
printf("error hori\n");
}
@ -203,10 +209,11 @@ uint8_t matrix_scan(void) {
printf("error vert\n");
}
data = mcp23018_rx[0];
data = ~(mcp23018_rx[0] & 0b00111111);
// data = 0x01;
if (matrix_debouncing[row + 6] != data) {
matrix_debouncing[row + 6] = data;
if (matrix_debouncing_right[row] != data) {
matrix_debouncing_right[row] = data;
debouncing_right = true;
debouncing_time_right = timer_read();
}
@ -222,8 +229,11 @@ uint8_t matrix_scan(void) {
}
if (debouncing_right && timer_elapsed(debouncing_time_right) > DEBOUNCING_DELAY) {
for (int row = 6; row < 12; row++) {
matrix[row] = matrix_debouncing[row];
for (int row = 0; row < 6; row++) {
matrix[11 - row] = 0;
for (int col = 0; col < MATRIX_COLS; col++) {
matrix[11 - row] |= ((matrix_debouncing_right[6 - col] & (1 << row) ? 1 : 0) << col);
}
}
debouncing_right = false;
}

@ -17,6 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "moonlander.h"
bool mcp23018_leds[3] = {0, 0, 0};
void matrix_init_kb(void) {
setPinOutput(B0);
setPinOutput(B1);
@ -25,6 +27,10 @@ void matrix_init_kb(void) {
writePinLow(B0);
writePinLow(B1);
writePinLow(B2);
mcp23018_leds[0] = 0; // blue
mcp23018_leds[1] = 0; // green
mcp23018_leds[2] = 0; // red
}
void matrix_scan_kb(void) {
@ -32,39 +38,35 @@ void matrix_scan_kb(void) {
}
uint32_t layer_state_set_kb(uint32_t state) {
writePinLow(B0);
writePinLow(B1);
writePinLow(B2);
ML_LED_1(0);
ML_LED_2(0);
ML_LED_3(0);
ML_LED_4(0);
ML_LED_5(0);
ML_LED_6(0);
uint8_t layer = biton32(state);
switch (layer) {
case 0:
break;
case 1:
writePinHigh(B0);
ML_LED_1(1);
ML_LED_4(1);
break;
case 2:
writePinHigh(B1);
ML_LED_2(1);
break;
case 3:
writePinHigh(B2);
ML_LED_3(1);
break;
case 4:
writePinHigh(B0);
writePinHigh(B1);
ML_LED_4(1);
break;
case 5:
writePinHigh(B0);
writePinHigh(B2);
ML_LED_5(1);
break;
case 6:
writePinHigh(B1);
writePinHigh(B2);
break;
case 7:
writePinHigh(B0);
writePinHigh(B1);
writePinHigh(B2);
ML_LED_6(1);
break;
default:
break;

@ -19,6 +19,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define MCP23018_DEFAULT_ADDRESS 0b0100000
#define ML_LED_1(status) (status ? writePinHigh(B0) : writePinLow(B0))
#define ML_LED_2(status) (status ? writePinHigh(B1) : writePinLow(B1))
#define ML_LED_3(status) (status ? writePinHigh(B2) : writePinLow(B2))
#define ML_LED_4(status) mcp23018_leds[0] = status
#define ML_LED_5(status) mcp23018_leds[1] = status
#define ML_LED_6(status) mcp23018_leds[2] = status
#include "quantum.h"
#define LAYOUT_moonlander( \
@ -27,7 +35,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
k20, k21, k22, k23, k24, k25, k26, \
k30, k31, k32, k33, k34, k35, \
k40, k41, k42, k43, k44, \
k50, k51, k52 \
k50, k51, k52, \
\
k60, k61, k62, k63, k64, k65, k66, \
k70, k71, k72, k73, k74, k75, k76, \
k80, k81, k82, k83, k84, k85, k86, \
k91, k92, k93, k94, k95, k96, \
ka2, ka3, ka4, ka5, ka6, \
kb4, kb5, kb6 \
) \
{ \
{ k00, k01, k02, k03, k04, k05, k06 }, \
@ -35,5 +50,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
{ k20, k21, k22, k23, k24, k25, k26 }, \
{ k30, k31, k32, k33, k34, k35, KC_NO }, \
{ k40, k41, k42, k43, k44, KC_NO, KC_NO }, \
{ k50, k51, k52, KC_NO, KC_NO, KC_NO, KC_NO } \
{ k50, k51, k52, KC_NO, KC_NO, KC_NO, KC_NO }, \
\
{ k60, k61, k62, k63, k64, k65, k66 }, \
{ k70, k71, k72, k73, k74, k75, k76 }, \
{ k80, k81, k82, k83, k84, k85, k86 }, \
{ KC_NO,k91, k92, k93, k94, k95, k96 }, \
{ KC_NO, KC_NO, ka2, ka3, ka4, ka5, ka6 }, \
{ KC_NO, KC_NO, KC_NO, KC_NO, kb4, kb5, kb6 } \
}

Loading…
Cancel
Save