diff --git a/drivers/arm/i2c_master.c b/drivers/arm/i2c_master.c index 7369398cc4..58a995ecc2 100644 --- a/drivers/arm/i2c_master.c +++ b/drivers/arm/i2c_master.c @@ -92,6 +92,10 @@ i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16 return chibios_to_qmk(&status); } +i2c_status_t i2c_transmit_receive(uint8_t address, uint8_t * tx_body, uint16_t tx_length, uint8_t * rx_body, uint16_t rx_length) { + return i2cMasterTransmitTimeout(&I2C_DRIVER, address/2, tx_body, tx_length, rx_body, rx_length, MS2ST(100)); +} + i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout) { i2c_address = devaddr; diff --git a/keyboards/moonlander/config.h b/keyboards/moonlander/config.h new file mode 100644 index 0000000000..c55553174a --- /dev/null +++ b/keyboards/moonlander/config.h @@ -0,0 +1,86 @@ +/* +Copyright 2018 Jack Humbert + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#pragma once + +#include "config_common.h" + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x6060 +#define MANUFACTURER ZSA +#define PRODUCT Moonlander +#define DESCRIPTION A keyboard +#define DEVICE_VER 0x0001 + +/* key matrix size */ +#define MATRIX_ROWS 12 +#define MATRIX_COLS 7 + +/* Planck PCB default pin-out */ +// #define MATRIX_ROW_PINS { B10, B11, B12, B13, B14, B15 } +// #define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6 } + +// #define MCP23_ROW_PINS { GPB5, GBP4, GBP3, GBP2, GBP1, GBP0 } +// #define MCP23_COL_PINS { GPA0, GBA1, GBA2, GBA3, GBA4, GBA5, GBA6 } + +// #define MCP23_LED_R GPB7 +// #define MCP23_LED_G GPB6 +// #define MCP23_LED_B GPA7 + + +/* COL2ROW or ROW2COL */ +#define DIODE_DIRECTION ROW2COL + +/* Set 0 if debouncing isn't needed */ +#define DEBOUNCING_DELAY 5 + +/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ +#define LOCKING_SUPPORT_ENABLE +/* Locking resynchronize hack */ +#define LOCKING_RESYNC_ENABLE + +/* key combination for command */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ +) + +/* + * Feature disable options + * These options are also useful to firmware size reduction. + */ + +/* disable debug print */ +//#define NO_DEBUG + +/* disable print */ +//#define NO_PRINT + +/* disable action features */ +//#define NO_ACTION_LAYER +//#define NO_ACTION_TAPPING +//#define NO_ACTION_ONESHOT +//#define NO_ACTION_MACRO +//#define NO_ACTION_FUNCTION + +#define DRIVER_ADDR_1 0b1110100 +#define DRIVER_ADDR_2 0b1110111 + +#define DRIVER_COUNT 2 +#define DRIVER_1_LED_TOTAL 35 +#define DRIVER_2_LED_TOTAL 35 +#define DRIVER_LED_TOTAL DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL diff --git a/keyboards/moonlander/keymaps/default/keymap.c b/keyboards/moonlander/keymaps/default/keymap.c new file mode 100644 index 0000000000..576be7fb30 --- /dev/null +++ b/keyboards/moonlander/keymaps/default/keymap.c @@ -0,0 +1,70 @@ +/* +Copyright 2018 Jack Humbert + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "moonlander.h" + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + +[0] = LAYOUT_moonlander( + RGB_MOD, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, + 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_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(2), + KC_ENT,KC_SPC, KC_BSPC +), + +[1] = LAYOUT_moonlander( + RGB_MOD, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, + 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_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(2), + KC_ENT,KC_SPC, KC_BSPC +), + +[1] = LAYOUT_moonlander( + RGB_MOD, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, + 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_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(2), + KC_ENT,KC_SPC, KC_BSPC +) + +}; diff --git a/keyboards/moonlander/matrix.c b/keyboards/moonlander/matrix.c new file mode 100644 index 0000000000..9a3e3d0fe1 --- /dev/null +++ b/keyboards/moonlander/matrix.c @@ -0,0 +1,266 @@ +/* +Copyright 2018 Jack Humbert + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + + +#include +#include +#include +#include "hal.h" +#include "timer.h" +#include "wait.h" +#include "printf.h" +#include "backlight.h" +#include "matrix.h" +#include "action.h" +#include "keycode.h" +#include +#include "moonlander.h" +#include "i2c_master.h" + +/* +#define MATRIX_ROW_PINS { B10, B11, B12, B13, B14, B15 } outputs +#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6 } inputs + */ +/* matrix state(1:on, 0:off) */ +static matrix_row_t matrix[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) {} + +__attribute__ ((weak)) +void matrix_scan_user(void) {} + +__attribute__ ((weak)) +void matrix_init_kb(void) { + matrix_init_user(); +} + +__attribute__ ((weak)) +void matrix_scan_kb(void) { + matrix_scan_user(); +} + +bool mcp23018_initd = false; +uint8_t mcp23018_tx[3]; +uint8_t mcp23018_rx[1]; + +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] = 0b00000000; // A is output + mcp23018_tx[2] = 0b00111111; // B is inputs + + if (MSG_OK != i2c_transmit(MCP23018_DEFAULT_ADDRESS << 1, + mcp23018_tx, 3, 100 + )) { + printf("error hori\n"); + } else { + mcp23018_tx[0] = 0x0C; // GPPUA + 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 + )) { + printf("error hori\n"); + } else { + mcp23018_initd = true; + } + } +} + +void matrix_init(void) { + printf("matrix init\n"); + //debug_matrix = true; + + // outputs + palSetPadMode(GPIOB, 10, PAL_MODE_OUTPUT_PUSHPULL); + palSetPadMode(GPIOB, 11, PAL_MODE_OUTPUT_PUSHPULL); + palSetPadMode(GPIOB, 12, PAL_MODE_OUTPUT_PUSHPULL); + palSetPadMode(GPIOB, 13, PAL_MODE_OUTPUT_PUSHPULL); + palSetPadMode(GPIOB, 14, PAL_MODE_OUTPUT_PUSHPULL); + palSetPadMode(GPIOB, 15, PAL_MODE_OUTPUT_PUSHPULL); + + // inputs + palSetPadMode(GPIOA, 0, PAL_MODE_INPUT_PULLDOWN); + palSetPadMode(GPIOA, 1, PAL_MODE_INPUT_PULLDOWN); + palSetPadMode(GPIOA, 2, PAL_MODE_INPUT_PULLDOWN); + palSetPadMode(GPIOA, 3, PAL_MODE_INPUT_PULLDOWN); + palSetPadMode(GPIOA, 6, PAL_MODE_INPUT_PULLDOWN); + palSetPadMode(GPIOA, 7, PAL_MODE_INPUT_PULLDOWN); + palSetPadMode(GPIOB, 0, PAL_MODE_INPUT_PULLDOWN); + + memset(matrix, 0, MATRIX_ROWS * sizeof(matrix_row_t)); + memset(matrix_debouncing, 0, MATRIX_ROWS * sizeof(matrix_row_t)); + + mcp23018_init(); + + matrix_init_quantum(); +} + +uint8_t matrix_scan(void) { + + matrix_row_t data = 0; + // actual matrix + for (int row = 0; row < 6; row++) { + + // strobe row + switch (row) { + case 0: palSetPad(GPIOB, 10); break; + case 1: palSetPad(GPIOB, 11); break; + case 2: palSetPad(GPIOB, 12); break; + case 3: palSetPad(GPIOB, 13); break; + case 4: palSetPad(GPIOB, 14); break; + case 5: palSetPad(GPIOB, 15); break; + } + + // need wait to settle pin state + wait_us(20); + + // read col data + data = ( + (palReadPad(GPIOA, 0) << 0 ) | + (palReadPad(GPIOA, 1) << 1 ) | + (palReadPad(GPIOA, 2) << 2 ) | + (palReadPad(GPIOA, 3) << 3 ) | + (palReadPad(GPIOA, 6) << 4 ) | + (palReadPad(GPIOA, 7) << 5 ) | + (palReadPad(GPIOB, 0) << 6 ) + ); + + // unstrobe row + switch (row) { + case 0: palClearPad(GPIOB, 10); break; + case 1: palClearPad(GPIOB, 11); break; + case 2: palClearPad(GPIOB, 12); break; + case 3: palClearPad(GPIOB, 13); break; + case 4: palClearPad(GPIOB, 14); break; + case 5: palClearPad(GPIOB, 15); break; + } + + if (matrix_debouncing[row] != data) { + matrix_debouncing[row] = data; + debouncing = true; + debouncing_time = timer_read(); + } + } + + + for (int row = 0; row < 7; row++) { + // right side + + if (!mcp23018_initd) { + printf("trying to init right\n"); + mcp23018_init(); + } + + // #define MCP23_ROW_PINS { GPB5, GBP4, GBP3, GBP2, GBP1, GBP0 } outputs + // #define MCP23_COL_PINS { GPA0, GBA1, GBA2, GBA3, GBA4, GBA5, GBA6 } inputs + + // select row + + mcp23018_tx[0] = 0x12; // GPIOA + 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, 3, 100 + )) { + printf("error hori\n"); + } + + // read col + + mcp23018_tx[0] = 0x13; // GPIOB + + if (MSG_OK != i2c_transmit_receive(MCP23018_DEFAULT_ADDRESS << 1, + mcp23018_tx, 1, + mcp23018_rx, 1 + )) { + printf("error vert\n"); + } + + data = ~(mcp23018_rx[0] & 0b00111111); + // data = 0x01; + + if (matrix_debouncing_right[row] != data) { + matrix_debouncing_right[row] = data; + debouncing_right = true; + debouncing_time_right = timer_read(); + } + } + + + if (debouncing && timer_elapsed(debouncing_time) > DEBOUNCING_DELAY) { + for (int row = 0; row < 6; row++) { + matrix[row] = matrix_debouncing[row]; + } + debouncing = false; + } + + if (debouncing_right && timer_elapsed(debouncing_time_right) > DEBOUNCING_DELAY) { + 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; + } + + matrix_scan_quantum(); + + return 1; +} + +bool matrix_is_on(uint8_t row, uint8_t col) { + return (matrix[row] & (1< + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "moonlander.h" + +bool mcp23018_leds[3] = {0, 0, 0}; + +void matrix_init_kb(void) { + setPinOutput(B5); + setPinOutput(B4); + setPinOutput(B3); + + writePinLow(B5); + writePinLow(B4); + writePinLow(B3); + + mcp23018_leds[0] = 0; // blue + mcp23018_leds[1] = 0; // green + mcp23018_leds[2] = 0; // red + + eeconfig_init(); +} + +void matrix_scan_kb(void) { + +} + +uint32_t layer_state_set_kb(uint32_t state) { + 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: + ML_LED_1(1); + ML_LED_4(1); + break; + case 2: + ML_LED_2(1); + ML_LED_5(1); + break; + case 3: + ML_LED_3(1); + break; + case 4: + ML_LED_4(1); + break; + case 5: + ML_LED_5(1); + break; + case 6: + ML_LED_6(1); + break; + default: + break; + } + + return state; +} + +const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { +/* Refer to IS31 manual for these locations + * driver + * | R location + * | | G location + * | | | B location + * | | | | */ + {0, C3_2, C1_1, C4_2}, // 1 + {0, C2_2, C1_2, C4_3}, + {0, C2_3, C1_3, C3_3}, + {0, C2_4, C1_4, C3_4}, + {0, C2_5, C1_5, C3_5}, + {0, C2_6, C1_6, C3_6}, + {0, C2_7, C1_7, C3_7}, + {0, C2_8, C1_8, C3_8}, + {0, C3_1, C2_1, C4_1}, + + {0, C7_8, C6_8, C8_8}, // 10 + {0, C7_7, C6_7, C9_8}, + {0, C8_7, C6_6, C9_7}, + {0, C8_6, C7_6, C9_6}, + {0, C8_5, C7_5, C9_5}, + {0, C8_4, C7_4, C9_4}, + {0, C8_3, C7_3, C9_3}, + {0, C8_2, C7_2, C9_2}, + {0, C8_1, C7_1, C9_1}, + + {0, C3_10, C1_9, C4_10}, // 19 + {0, C2_10, C1_10, C4_11}, + {0, C2_11, C1_11, C3_11}, + {0, C2_12, C1_12, C3_12}, + {0, C2_13, C1_13, C3_13}, + {0, C2_14, C1_14, C3_14}, + {0, C2_15, C1_15, C3_15}, + {0, C2_16, C1_16, C3_16}, + {0, C3_9, C2_9, C4_9}, + + {0, C7_16, C6_16, C8_16}, // 28 + {0, C7_15, C6_15, C9_16}, + {0, C8_15, C6_14, C9_15}, + {0, C8_10, C7_10, C9_10}, + {0, C8_9, C7_9, C9_9}, + {0, C8_11, C7_11, C9_11}, + {0, C8_12, C7_12, C9_12}, + {0, C8_13, C7_13, C9_13}, +// {0, C8_14, C7_14, C9_4} + + {1, C3_2, C1_1, C4_2}, // 1 + {1, C2_2, C1_2, C4_3}, + {1, C2_3, C1_3, C3_3}, + {1, C2_4, C1_4, C3_4}, + {1, C2_5, C1_5, C3_5}, + {1, C2_6, C1_6, C3_6}, + {1, C2_7, C1_7, C3_7}, + {1, C2_8, C1_8, C3_8}, + {1, C3_1, C2_1, C4_1}, + + {1, C7_8, C6_8, C8_8}, // 10 + {1, C7_7, C6_7, C9_8}, + {1, C8_7, C6_6, C9_7}, + {1, C8_6, C7_6, C9_6}, + {1, C8_5, C7_5, C9_5}, + {1, C8_4, C7_4, C9_4}, + {1, C8_3, C7_3, C9_3}, + {1, C8_2, C7_2, C9_2}, + {1, C8_1, C7_1, C9_1}, + + {1, C3_10, C1_9, C4_10}, // 19 + {1, C2_10, C1_10, C4_11}, + {1, C2_11, C1_11, C3_11}, + {1, C2_12, C1_12, C3_12}, + {1, C2_13, C1_13, C3_13}, + {1, C2_14, C1_14, C3_14}, + {1, C2_15, C1_15, C3_15}, + {1, C2_16, C1_16, C3_16}, + {1, C3_9, C2_9, C4_9}, + + {1, C7_16, C6_16, C8_16}, // 28 + {1, C7_15, C6_15, C9_16}, + {1, C8_15, C6_14, C9_15}, + {1, C8_10, C7_10, C9_10}, + {1, C8_9, C7_9, C9_9}, + {1, C8_11, C7_11, C9_11}, + {1, C8_12, C7_12, C9_12}, + {1, C8_13, C7_13, C9_13}, + +}; + +rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { + + /*{row | col << 4} + | {x=0..224, y=0..64} + | | modifier + | | | */ + {{0|(0<<4)}, {17.23*0, 21.33*0}, 1}, + {{1|(0<<4)}, {17.23*0, 21.33*1}, 4}, + {{2|(0<<4)}, {17.23*0, 21.33*2}, 4}, + {{3|(0<<4)}, {17.23*0, 21.33*3}, 4}, + {{4|(0<<4)}, {17.23*0, 21.33*4}, 4}, + + {{0|(1<<4)}, {17.23*1, 21.33*0}, 4}, + {{1|(1<<4)}, {17.23*1, 21.33*1}, 4}, + {{2|(1<<4)}, {17.23*1, 21.33*2}, 4}, + {{3|(1<<4)}, {17.23*1, 21.33*3}, 4}, + {{4|(1<<4)}, {17.23*1, 21.33*4}, 4}, + + {{0|(2<<4)}, {17.23*2, 21.33*0}, 4}, + {{1|(2<<4)}, {17.23*2, 21.33*1}, 4}, + {{2|(2<<4)}, {17.23*2, 21.33*2}, 4}, + {{3|(2<<4)}, {17.23*2, 21.33*3}, 4}, + {{4|(2<<4)}, {17.23*2, 21.33*4}, 4}, + + {{0|(3<<4)}, {17.23*3, 21.33*0}, 4}, + {{1|(3<<4)}, {17.23*3, 21.33*1}, 4}, + {{2|(3<<4)}, {17.23*3, 21.33*2}, 4}, + {{3|(3<<4)}, {17.23*3, 21.33*3}, 4}, + {{4|(3<<4)}, {17.23*3, 21.33*4}, 4}, + + {{0|(4<<4)}, {17.23*4, 21.33*0}, 4}, + {{1|(4<<4)}, {17.23*4, 21.33*1}, 4}, + {{2|(4<<4)}, {17.23*4, 21.33*2}, 4}, + {{3|(4<<4)}, {17.23*4, 21.33*3}, 4}, + {{4|(4<<4)}, {17.23*4, 21.33*4}, 4}, + + {{0|(5<<4)}, {17.23*5, 21.33*0}, 4}, + {{1|(5<<4)}, {17.23*5, 21.33*1}, 4}, + {{2|(5<<4)}, {17.23*5, 21.33*2}, 4}, + {{3|(5<<4)}, {17.23*5, 21.33*3}, 4}, + + {{0|(6<<4)}, {17.23*6, 21.33*0}, 4}, + {{1|(6<<4)}, {17.23*6, 21.33*1}, 4}, + {{2|(6<<4)}, {17.23*6, 21.33*2}, 4}, + + // cluster + {{5|(0<<4)}, {17.23*5.5, 21.33*4}, 4}, + {{5|(1<<4)}, {17.23*6.0, 21.33*5}, 4}, + {{5|(2<<4)}, {17.23*6.5, 21.33*6}, 4}, + + + + + {{0|(0<<4)}, {17.23*13, 21.33*0}, 1}, + {{1|(0<<4)}, {17.23*13, 21.33*1}, 4}, + {{2|(0<<4)}, {17.23*13, 21.33*2}, 4}, + {{3|(0<<4)}, {17.23*13, 21.33*3}, 4}, + {{4|(0<<4)}, {17.23*13, 21.33*4}, 4}, + + {{0|(1<<4)}, {17.23*12, 21.33*0}, 4}, + {{1|(1<<4)}, {17.23*12, 21.33*1}, 4}, + {{2|(1<<4)}, {17.23*12, 21.33*2}, 4}, + {{3|(1<<4)}, {17.23*12, 21.33*3}, 4}, + {{4|(1<<4)}, {17.23*12, 21.33*4}, 4}, + + {{0|(2<<4)}, {17.23*11, 21.33*0}, 4}, + {{1|(2<<4)}, {17.23*11, 21.33*1}, 4}, + {{2|(2<<4)}, {17.23*11, 21.33*2}, 4}, + {{3|(2<<4)}, {17.23*11, 21.33*3}, 4}, + {{4|(2<<4)}, {17.23*11, 21.33*4}, 4}, + + {{0|(3<<4)}, {17.23*10, 21.33*0}, 4}, + {{1|(3<<4)}, {17.23*10, 21.33*1}, 4}, + {{2|(3<<4)}, {17.23*10, 21.33*2}, 4}, + {{3|(3<<4)}, {17.23*10, 21.33*3}, 4}, + {{4|(3<<4)}, {17.23*10, 21.33*4}, 4}, + + {{0|(4<<4)}, {17.23*9, 21.33*0}, 4}, + {{1|(4<<4)}, {17.23*9, 21.33*1}, 4}, + {{2|(4<<4)}, {17.23*9, 21.33*2}, 4}, + {{3|(4<<4)}, {17.23*9, 21.33*3}, 4}, + {{4|(4<<4)}, {17.23*9, 21.33*4}, 4}, + + {{0|(5<<4)}, {17.23*8, 21.33*0}, 4}, + {{1|(5<<4)}, {17.23*8, 21.33*1}, 4}, + {{2|(5<<4)}, {17.23*8, 21.33*2}, 4}, + {{3|(5<<4)}, {17.23*8, 21.33*3}, 4}, + + {{0|(6<<4)}, {17.23*7, 21.33*0}, 4}, + {{1|(6<<4)}, {17.23*7, 21.33*1}, 4}, + {{2|(6<<4)}, {17.23*7, 21.33*2}, 4}, + + // cluster + {{5|(0<<4)}, {17.23*7.5, 21.33*4}, 4}, + {{5|(1<<4)}, {17.23*7.0, 21.33*5}, 4}, + {{5|(2<<4)}, {17.23*6.5, 21.33*6}, 4}, + +}; diff --git a/keyboards/moonlander/moonlander.h b/keyboards/moonlander/moonlander.h new file mode 100644 index 0000000000..94743be6af --- /dev/null +++ b/keyboards/moonlander/moonlander.h @@ -0,0 +1,61 @@ +/* +Copyright 2018 Jack Humbert + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#pragma once + +#define MCP23018_DEFAULT_ADDRESS 0b0100000 + +#define ML_LED_1(status) (status ? writePinHigh(B5) : writePinLow(B5)) +#define ML_LED_2(status) (status ? writePinHigh(B4) : writePinLow(B4)) +#define ML_LED_3(status) (status ? writePinHigh(B3) : writePinLow(B3)) + +#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( \ + k00, k01, k02, k03, k04, k05, k06, \ + k10, k11, k12, k13, k14, k15, k16, \ + k20, k21, k22, k23, k24, k25, k26, \ + k30, k31, k32, k33, k34, k35, \ + k40, k41, k42, k43, k44, \ + 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 }, \ + { k10, k11, k12, k13, k14, k15, k16 }, \ + { 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 }, \ +\ + { 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 } \ +} diff --git a/keyboards/moonlander/rules.mk b/keyboards/moonlander/rules.mk new file mode 100644 index 0000000000..468a60ecef --- /dev/null +++ b/keyboards/moonlander/rules.mk @@ -0,0 +1,23 @@ +# project specific files +SRC = matrix.c +#LAYOUTS += ortho_4x12 + +# Cortex version +MCU = STM32F303 + +# Build Options +# comment out to disable the options. +# +BACKLIGHT_ENABLE = no +BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration +## (Note that for BOOTMAGIC on Teensy LC you have to use a custom .ld script.) +MOUSEKEY_ENABLE = yes # Mouse keys +EXTRAKEY_ENABLE = yes # Audio control and System control +CONSOLE_ENABLE = yes # Console for debug +COMMAND_ENABLE = yes # Commands for debug and configuration +#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend +NKRO_ENABLE = yes # USB Nkey Rollover +CUSTOM_MATRIX = yes # Custom matrix file +AUDIO_ENABLE = yes +RGB_MATRIX_ENABLE = IS31FL3731 +# SERIAL_LINK_ENABLE = yes diff --git a/keyboards/planck/rules.mk b/keyboards/planck/rules.mk new file mode 100644 index 0000000000..6097902384 --- /dev/null +++ b/keyboards/planck/rules.mk @@ -0,0 +1,48 @@ +# MCU name +MCU = atmega32u4 + +# Bootloader +# This definition is optional, and if your keyboard supports multiple bootloaders of +# different sizes, comment this out, and the correct address will be loaded +# automatically (+60). See bootloader.mk for all options. +ifeq ($(strip $(KEYBOARD)), planck/rev3) + BOOTLOADER = atmel-dfu +endif +ifeq ($(strip $(KEYBOARD)), planck/rev4) + BOOTLOADER = atmel-dfu +endif +ifeq ($(strip $(KEYBOARD)), planck/rev5) + BOOTLOADER = qmk-dfu +endif +ifeq ($(strip $(KEYBOARD)), planck/light) + BOOTLOADER = atmel-dfu +endif + +# Interrupt driven control endpoint task(+60) +OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT + +# Build Options +# change to "no" to disable the options, or define them in the Makefile in +# the appropriate keymap folder that will get included automatically +# +BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) +MOUSEKEY_ENABLE = no # Mouse keys(+4700) +EXTRAKEY_ENABLE = yes # Audio control and System control(+450) +CONSOLE_ENABLE = yes # Console for debug(+400) +COMMAND_ENABLE = no # Commands for debug and configuration +NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +MIDI_ENABLE = no # MIDI controls +AUDIO_ENABLE = yes # Audio output on port C6 +UNICODE_ENABLE = no # Unicode +BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID +RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. +API_SYSEX_ENABLE = no + +# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend + +LAYOUTS = ortho_4x12 planck_mit planck_grid +LAYOUTS_HAS_RGB = no + +DEFAULT_FOLDER = planck/rev5