From 089e3aed20bfa59e0ab0be2f973ebb7328b06fcb Mon Sep 17 00:00:00 2001 From: Michael Schwingen Date: Mon, 13 Jul 2020 21:31:44 +0200 Subject: [PATCH 01/26] add support for ModelM USB board --- keyboards/mschwingen/modelm/README.md | 26 +++ keyboards/mschwingen/modelm/config.h | 92 ++++++++ .../modelm/keymaps/default/keymap.c | 92 ++++++++ keyboards/mschwingen/modelm/led_ffc/rules.mk | 2 + .../mschwingen/modelm/led_wired/rules.mk | 2 + .../mschwingen/modelm/led_ws2812/rules.mk | 3 + keyboards/mschwingen/modelm/matrix.c | 126 +++++++++++ keyboards/mschwingen/modelm/modelm.c | 214 ++++++++++++++++++ keyboards/mschwingen/modelm/modelm.h | 58 +++++ keyboards/mschwingen/modelm/rules.mk | 55 +++++ 10 files changed, 670 insertions(+) create mode 100644 keyboards/mschwingen/modelm/README.md create mode 100644 keyboards/mschwingen/modelm/config.h create mode 100644 keyboards/mschwingen/modelm/keymaps/default/keymap.c create mode 100644 keyboards/mschwingen/modelm/led_ffc/rules.mk create mode 100644 keyboards/mschwingen/modelm/led_wired/rules.mk create mode 100644 keyboards/mschwingen/modelm/led_ws2812/rules.mk create mode 100644 keyboards/mschwingen/modelm/matrix.c create mode 100644 keyboards/mschwingen/modelm/modelm.c create mode 100644 keyboards/mschwingen/modelm/modelm.h create mode 100644 keyboards/mschwingen/modelm/rules.mk diff --git a/keyboards/mschwingen/modelm/README.md b/keyboards/mschwingen/modelm/README.md new file mode 100644 index 000000000000..f32ecb38e86f --- /dev/null +++ b/keyboards/mschwingen/modelm/README.md @@ -0,0 +1,26 @@ +# atmega32U4 board for IBM Model M + +![modelm](https://raw.githubusercontent.com/mschwingen/hardware/master/modelm-usb/images/PCB.jpg) + +This is a configuration of QMK intended to be used with the [Model M USB PCB](https://github.com/mschwingen/hardware/tree/master/modelm-usb). + +* Keyboard Maintainer: [Michael Schwingen](https://github.com/mschwingen/) +* Hardware Supported: [Model M USB PCB](https://github.com/mschwingen/hardware/tree/master/modelm-usb) +* Hardware Availability: need to build your own. + +Make example for this keyboard (after setting up your build environment), run one of: + + make mschwingen/modelm/led_wired:default + make mschwingen/modelm/led_ffc:default + make mschwingen/modelm/led_ws2812:default + +flash: + + make mschwingen/modelm/led_wired:default:dfu + make mschwingen/modelm/led_ffc:default:dfu + make mschwingen/modelm/led_ws2812:default:dfu + +See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). + +bootloader: + do not use the QMK bootloader, use the bootloader from [here](https://github.com/mschwingen/modelm-lufa-bootloader) diff --git a/keyboards/mschwingen/modelm/config.h b/keyboards/mschwingen/modelm/config.h new file mode 100644 index 000000000000..2ea59bf00562 --- /dev/null +++ b/keyboards/mschwingen/modelm/config.h @@ -0,0 +1,92 @@ +/* + * Copyright 2020 Michael Schwingen + + * 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 0x0000 +#define DEVICE_VER 0x0001 +#define MANUFACTURER mschwingen +#define PRODUCT IBM Model M 101/102 +#define DESCRIPTION www.schwingen.org + +/* key matrix size */ +#define MATRIX_ROWS 16 +#define MATRIX_COLS 8 + +/* pins for external shift registers */ +#define SR_LOAD_PIN B0 +#define SR_CLK_PIN B1 +#define SR_DIN_PIN B3 +#define SR_DOUT_PIN B2 + +/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed (5 is default) */ +#define DEBOUNCE 5 + +/* + * Feature disable options + * These options are also useful to firmware size reduction. + */ + +/* disable debug print */ +//#define NO_DEBUG + +/* disable print */ +//#define NO_PRINT +#define NORMAL_PRINT +//#define USER_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 DEBUG_MATRIX_SCAN_RATE +#define DYNAMIC_MACRO_NO_NESTING + +#define QMK_LED E6 + +#define MODELM_LED1 B5 +#define MODELM_LED2 B6 +#define MODELM_LED3 D0 + +#if defined MODELM_LEDS_WIRED +# define MODELM_LED_CAPSLOCK MODELM_LED1 +# define MODELM_LED_SCROLLOCK MODELM_LED2 +# define MODELM_LED_NUMLOCK MODELM_LED3 +#elif defined MODELM_LEDS_FFC +# define MODELM_LED_CAPSLOCK MODELM_LED2 +# define MODELM_LED_SCROLLOCK MODELM_LED3 +# define MODELM_LED_NUMLOCK MODELM_LED1 +#elif defined MODELM_LEDS_WS2812 +#else +# error one of MODELM_LEDS_FFC, MODELM_LEDS_WIRED or MODELM_LEDS_WS2812 must be set! +#endif + +// 3* WS2812 LEDs instead of singlecolor GPIO LEDs +#define RGB_DI_PIN B6 +#define RGBLED_NUM 3 + +// disabled, needs PCB patch. +//#define C6_AUDIO +//#define NO_MUSIC_MODE diff --git a/keyboards/mschwingen/modelm/keymaps/default/keymap.c b/keyboards/mschwingen/modelm/keymaps/default/keymap.c new file mode 100644 index 000000000000..92002181fbc0 --- /dev/null +++ b/keyboards/mschwingen/modelm/keymaps/default/keymap.c @@ -0,0 +1,92 @@ +/* Copyright 2019 ashpil + * + * 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 QMK_KEYBOARD_H + +#define ______ KC_TRNS +#define XXXXXX KC_NO + +enum layers { + _BL0 = 0, _BL1, _FL, _MS +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_BL0] = LAYOUT( /* Base layer - Windows key instead of CapsLock, hold ESC for special functions */ + LT(_FL,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_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_INS, KC_HOME, KC_PGUP, KC_NLCK, KC_PSLS, KC_PAST, KC_PMNS, + 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, KC_END, KC_PGDN, KC_P7, KC_P8, KC_P9, KC_PPLS, + KC_LWIN, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_NUHS, KC_ENT, KC_P4, KC_P5, KC_P6, + KC_LSFT, KC_NUBS, 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_P1, KC_P2, KC_P3, KC_PENT, + KC_LCTL, KC_LALT, KC_SPC, KC_RALT, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT + ), + + [_BL1] = LAYOUT( /* Base layer - standard layout without any special functions */ + 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_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_INS, KC_HOME, KC_PGUP, KC_NLCK, KC_PSLS, KC_PAST, KC_PMNS, + 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, KC_END, KC_PGDN, KC_P7, KC_P8, KC_P9, KC_PPLS, + 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_NUHS, KC_ENT, KC_P4, KC_P5, KC_P6, + KC_LSFT, KC_NUBS, 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_P1, KC_P2, KC_P3, KC_PENT, + KC_LCTL, KC_LALT, KC_SPC, KC_RALT, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT + ), + + [_FL] = LAYOUT( /* special functions layer */ + // F1: dyn. macro 1 play + // F2: dyn. macro 2 play + // F3: dyn. macro 1 record + // F4: dyn. macro 2 record + // F5: dyn. macro record stop + // Capslock: CapsLock (really!) + // ~: Key Lock + // Cursor: Media Pref / Next / Volume Up / Volume Down + // Space: Media Play / Pause + // m: enter mouse layer + ______, DYN_MACRO_PLAY1, DYN_MACRO_PLAY2, DYN_REC_START1, DYN_REC_START2, DYN_REC_STOP, ______, ______ , ______ , ______, ______, ______, ______, ______, ______, ______, + KC_LOCK, ______, ______, ______, ______, ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______, ______ , ______ , ______ , ______ , ______ , + ______, ______, ______, ______, ______, ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______, ______ , ______ , ______ , ______ , ______ , + KC_CAPS, ______, ______, ______, ______, ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , + ______, ______, ______, ______, ______, ______ , ______ , ______ , TG(_MS), ______ , ______ , ______ , ______ , KC_AUDIO_VOL_UP, ______ , ______ , ______ , ______ , + ______, ______, KC_MEDIA_PLAY_PAUSE , ______ , ______ , KC_MEDIA_PREV_TRACK , KC_AUDIO_VOL_DOWN , KC_MEDIA_NEXT_TRACK , ______ , ______ + ), + + [_MS] = LAYOUT( /* mouse key layer */ + // Cursor: mouse, INS/HOME/PgUp: Mouse Accel, Del, End, PageDn: mouse buttons + TG(_MS), ______, ______, ______, ______, ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , + ______, ______, ______, ______, ______, ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , KC_MS_ACCEL0, KC_MS_ACCEL1, KC_MS_ACCEL2, ______ , ______ , ______ , ______ , + ______, ______, ______, ______, ______, ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , KC_MS_BTN1, KC_MS_BTN3, KC_MS_BTN2, ______ , ______ , ______ , ______ , + ______, ______, ______, ______, ______, ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , + ______, ______ , ______, ______, ______, ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , KC_MS_UP, ______ , ______ , ______ , ______ , + ______, ______, ______ , ______ , ______ , KC_MS_LEFT, KC_MS_DOWN, KC_MS_RIGHT, ______ , ______ + ), + +}; + + +void keyboard_post_init_user(void) { + // Customise these values to desired behaviour + //debug_enable=true; + //debug_matrix=true; + //debug_keyboard=true; + //debug_mouse=true; +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + // If console is enabled, it will print the matrix position and status of each key pressed +#ifdef CONSOLE_ENABLE + dprintf("KL: kc: %u, col: %u, row: %u, pressed: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed); +#endif + return true; +} + + diff --git a/keyboards/mschwingen/modelm/led_ffc/rules.mk b/keyboards/mschwingen/modelm/led_ffc/rules.mk new file mode 100644 index 000000000000..837824d82c7b --- /dev/null +++ b/keyboards/mschwingen/modelm/led_ffc/rules.mk @@ -0,0 +1,2 @@ +# variant for FFC LED board +OPT_DEFS += -DMODELM_LEDS_FFC diff --git a/keyboards/mschwingen/modelm/led_wired/rules.mk b/keyboards/mschwingen/modelm/led_wired/rules.mk new file mode 100644 index 000000000000..4ccd2f2f3190 --- /dev/null +++ b/keyboards/mschwingen/modelm/led_wired/rules.mk @@ -0,0 +1,2 @@ +# variant for wired LED PCB +OPT_DEFS += -DMODELM_LEDS_WIRED diff --git a/keyboards/mschwingen/modelm/led_ws2812/rules.mk b/keyboards/mschwingen/modelm/led_ws2812/rules.mk new file mode 100644 index 000000000000..183af7f5926d --- /dev/null +++ b/keyboards/mschwingen/modelm/led_ws2812/rules.mk @@ -0,0 +1,3 @@ +# variant for WS2812 LEDs +SRC += ws2812.c +OPT_DEFS += -DMODELM_LEDS_WS2812 diff --git a/keyboards/mschwingen/modelm/matrix.c b/keyboards/mschwingen/modelm/matrix.c new file mode 100644 index 000000000000..cd1d7b4e0a42 --- /dev/null +++ b/keyboards/mschwingen/modelm/matrix.c @@ -0,0 +1,126 @@ +/* + * Copyright 2020 Michael Schwingen + + * 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 "util.h" +#include "matrix.h" +#include "debounce.h" +#include "quantum.h" +#include "spi_master.h" +#include "print.h" +#include "modelm.h" + +#define DEBUG 0 + +#define SPI_TIMEOUT 100 + +/* Keyboard Matrix Assignments */ +static uint16_t row_bits[MATRIX_ROWS] = { + 0x4000, 0x8000, 0x2000, 0x1000, 0x0800, 0x0400, 0x0100, 0x0200, + 0x0040, 0x0080, 0x0020, 0x0010, 0x0008, 0x0004, 0x0001, 0x0002}; + +static const pin_t col_pins[MATRIX_COLS] = {D1, D4, D7, B4, F7, F6, F5, F4}; + +static uint8_t modelm_spi_read(void) { + // set 4MHz SPI clock + SPSR = 0; + SPCR = _BV(SPE) | _BV(MSTR) | _BV(CPOL); + SPDR = 0x55; // Dummy + + uint16_t timeout_timer = timer_read(); + while (!(SPSR & _BV(SPIF))) { + if ((timer_read() - timeout_timer) >= SPI_TIMEOUT) { + return SPI_STATUS_TIMEOUT; + } + } + return SPDR; +} + +static void select_col(uint8_t col) { + setPinOutput(col_pins[col]); + writePinLow(col_pins[col]); +} + +static void unselect_col(uint8_t col) { setPinInputHigh(col_pins[col]); } + +static void unselect_cols(void) { + for (uint8_t x = 0; x < MATRIX_COLS; x++) { + setPinInputHigh(col_pins[x]); + } +} + +static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) { + uint16_t row_data; + bool matrix_changed = false; + + // Select col and wait for col selecton to stabilize + select_col(current_col); + matrix_io_delay(); + + writePinLow(SR_LOAD_PIN); + writePinHigh(SR_LOAD_PIN); + + row_data = modelm_spi_read() << 8; + row_data |= modelm_spi_read(); + +#if DEBUG + phex(~row_data); + uprint(" "); +#endif + // For each row... + for (uint8_t row_index = 0; row_index < MATRIX_ROWS; row_index++) { + // Store last value of row prior to reading + matrix_row_t last_row_value = current_matrix[row_index]; + matrix_row_t current_row_value = last_row_value; + + // Check row pin state + if ((row_data & row_bits[row_index]) == 0) { + // Pin LO, set col bit + current_row_value |= (MATRIX_ROW_SHIFTER << current_col); + } else { + // Pin HI, clear col bit + current_row_value &= ~(MATRIX_ROW_SHIFTER << current_col); + } + + // Determine if the matrix changed state + if ((last_row_value != current_row_value)) { + matrix_changed = true; + current_matrix[row_index] = current_row_value; + } + } + + // Unselect col + unselect_col(current_col); + + return matrix_changed; +} + +void matrix_init_custom(void) { unselect_cols(); } + +bool matrix_scan_custom(matrix_row_t current_matrix[]) { + bool changed = false; + +#if DEBUG + uprint("\r\nScan: "); +#endif + // Set col, read rows + for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) { + changed |= read_rows_on_col(current_matrix, current_col); + } + update_layer_leds(); + return changed; +} diff --git a/keyboards/mschwingen/modelm/modelm.c b/keyboards/mschwingen/modelm/modelm.c new file mode 100644 index 000000000000..9fc6d2c3db9a --- /dev/null +++ b/keyboards/mschwingen/modelm/modelm.c @@ -0,0 +1,214 @@ +/* + * Copyright 2020 Michael Schwingen + + * 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 "modelm.h" +#include "uart.h" +#include "print.h" +#include "sendchar.h" +#include "ws2812.h" +#include "modelm.h" +#include "sleep_led.h" + +#ifdef UART_DEBUG +# undef sendchar +static int8_t capture_sendchar(uint8_t c) { + // sendchar(c); + uart_putchar(c); + return 0; +} +#endif + +static uint16_t blink_cycle_timer; +static bool blink_state = false; +static uint8_t isRecording = 0; + +#ifdef MODELM_LEDS_WS2812 +# if RGBLED_NUM < 3 +# error we need at least 3 RGB LEDs! +# endif +static cRGB led[RGBLED_NUM] = {{255, 255, 255}, {255, 255, 255}, {255, 255, 255}}; + +# define BRIGHT 32 +# define DIM 6 + +static const cRGB black = {.r = 0, .g = 0, .b = 0}; + +static const cRGB green = {.r = 0, .g = BRIGHT, .b = 0}; +static const cRGB lgreen = {.r = 0, .g = DIM, .b = 0}; + +static const cRGB red = {.r = BRIGHT, .g = 0, .b = 0}; +static const cRGB lred = {.r = DIM, .g = 0, .b = 0}; + +static const cRGB blue = {.r = 0, .g = 0, .b = BRIGHT}; +static const cRGB lblue = {.r = 0, .g = 0, .b = DIM}; + +static const cRGB turq = {.r = 0, .g = BRIGHT, .b = BRIGHT}; +static const cRGB lturq = {.r = 0, .g = DIM, .b = DIM}; + +static const cRGB white = {.r = BRIGHT, .g = BRIGHT, .b = BRIGHT}; + +static led_t led_state; +static uint8_t layer; +static uint8_t default_layer; +#endif + +// we need our own sleep_led_* implementation to get callbacks on USB +// suspend/resume in order to completely turn off WS2812 LEDs +static bool suspend_active = false; +void sleep_led_init(void) {} + +void sleep_led_toggle(void) {} + +void sleep_led_disable(void) { + suspend_active = false; + writePinHigh(QMK_LED); +} + +void sleep_led_enable(void) { + suspend_active = true; + writePinLow(QMK_LED); +#ifdef MODELM_LEDS_WS2812 + led[0] = black; + led[1] = black; + led[2] = black; + ws2812_setleds(led, RGBLED_NUM); +#endif +} + +void keyboard_pre_init_kb(void) { +#ifdef MODELM_LEDS_WS2812 + ws2812_setleds(led, RGBLED_NUM); +#else + /* Set status LEDs pins to output and Low (on) */ + setPinOutput(MODELM_LED_CAPSLOCK); + setPinOutput(MODELM_LED_SCROLLOCK); + setPinOutput(MODELM_LED_NUMLOCK); + writePinLow(MODELM_LED_CAPSLOCK); + writePinLow(MODELM_LED_SCROLLOCK); + writePinLow(MODELM_LED_NUMLOCK); +#endif + setPinOutput(QMK_LED); + writePinHigh(QMK_LED); + _delay_ms(50); +#ifdef UART_DEBUG + uart_init(115200); + print_set_sendchar(capture_sendchar); + uprintf("\r\nHello world!\r\n"); +#endif + + setPinOutput(SR_LOAD_PIN); + setPinOutput(SR_CLK_PIN); + setPinOutput(SR_DOUT_PIN); // MOSI - unused + writePinLow(SR_CLK_PIN); +} + +#ifdef MODELM_LEDS_WS2812 +static void led_update_rgb(void) { + if (isRecording && blink_state) { + led[0] = white; + } else { + switch (default_layer) { + case 0: + led[0] = led_state.num_lock ? blue : lblue; + break; + case 1: + led[0] = led_state.num_lock ? green : black; + break; + } + } + + led[1] = led_state.caps_lock ? green : black; + + switch (layer) { + case 0: + case 1: + default: + led[2] = led_state.scroll_lock ? green : black; + break; + case 2: + led[2] = led_state.scroll_lock ? red : lred; + break; + case 3: + led[2] = led_state.scroll_lock ? turq : lturq; + break; + } + if (!suspend_active) { + ws2812_setleds(led, RGBLED_NUM); + } +} + +bool led_update_kb(led_t state) { + uprintf("LED Update: %d %d %d", led_state.num_lock, led_state.caps_lock, led_state.scroll_lock); + led_state = state; + led_update_rgb(); + + return true; +} + +void update_layer_leds(void) { + static uint8_t old_layer = 255; + static uint8_t old_default_layer = 255; + + layer = biton32(layer_state); + default_layer = biton32(default_layer_state); + + if (isRecording && timer_elapsed(blink_cycle_timer) > 150) { + blink_state = !blink_state; + blink_cycle_timer = timer_read(); + old_layer = 255; // fallthrough next check + } + + if (layer == old_layer && default_layer == old_default_layer) { + return; + } + old_layer = layer; + old_default_layer = default_layer; + uprintf("Layer change: %d %d", default_layer, layer); + led_update_rgb(); +} + +/*****************************************************************************/ +#else // classic LEDs on GPIO +bool led_update_kb(led_t led_state) { + uprintf("LED Update: %d %d %d", led_state.num_lock, led_state.caps_lock, led_state.scroll_lock); + + if (led_update_user(led_state)) { + if (!isRecording) writePin(MODELM_LED_NUMLOCK, !led_state.num_lock); + writePin(MODELM_LED_CAPSLOCK, !led_state.caps_lock); + writePin(MODELM_LED_SCROLLOCK, !led_state.scroll_lock); + } + return true; +} + +void update_layer_leds(void) { + if (isRecording && timer_elapsed(blink_cycle_timer) > 150) { + blink_state = !blink_state; + blink_cycle_timer = timer_read(); + writePin(MODELM_LED_NUMLOCK, blink_state); + } +} + +#endif + +void dynamic_macro_record_start_user(void) { + isRecording++; + blink_cycle_timer = timer_read(); +} + +void dynamic_macro_record_end_user(int8_t direction) { + if (isRecording) isRecording--; +} diff --git a/keyboards/mschwingen/modelm/modelm.h b/keyboards/mschwingen/modelm/modelm.h new file mode 100644 index 000000000000..04b6b6112570 --- /dev/null +++ b/keyboards/mschwingen/modelm/modelm.h @@ -0,0 +1,58 @@ +/* + * Copyright 2020 Michael Schwingen + + * 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 + +extern void update_layer_leds(void); + +#include "quantum.h" + +/* This a shortcut to help you visually see your layout. + * The first section contains "names" for physical keys of the keyboard + * and defines their position on the board. + * The second section defines position of the keys on the switch matrix + * (where COLUMNS and ROWS crosses). */ + +/* universla layout for both 101 and 102-key versions */ +#define LAYOUT( \ + K5A, K5B, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5P, \ + \ + K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, K4N, K4O, K4P, K4Q, K4R, K4S, K4T, K4U, \ + K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3N, K3O, K3P, K3Q, K3R, K3S, K3T, K3U, \ + K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2M, K2N, K2O, K2P, K2Q, \ + K1A, K1B, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1L, K1M, K1N, K1O, K1P, K1Q, K1R, \ + K0A, K0B, K0C, K0D, K0E, K0F, K0G, K0H, K0I, K0J \ +) \ + {/* COL0 ............ COL7 */ \ + { K0D , KC_NO, KC_NO, K5O , K5N , KC_NO, KC_NO, K0B }, /* ROW0 */ \ + { K0F , K5P , K1R , K3U , K3P , K4P , KC_NO, K1N }, \ + { K4U , K4T , K1Q , K3T , K3Q , K4Q , K2Q , K0J }, \ + { K0H , K4S , K1P , K3S , K5M , K4O , K2P , K0I }, \ + { K0G , K4R , K1O , K3R , K5L , K3O , K2O , KC_NO }, \ + { K1L , K2M , K2K , K3K , K4K , K4L , K3L , K2L }, \ + { KC_NO, K1K , K2J , K3J , K4J , K5I , K5H , KC_NO }, \ + { KC_NO, K1J , K2I , K3I , K4I , K4M , K3M , K5G }, \ + { K1H , K1I , K2H , K3H , K4H , K4G , K3G , K2G }, \ + { K0C , K2N , K3N , KC_NO, K5K , K5J , K4N , K5F }, \ + { K1G , K1F , K2E , K3E , K4E , K4F , K3F , K2F }, \ + { KC_NO, K1E , K2D , K3D , K4D , K5C , K5D , K5E }, \ + { KC_NO, K1D , K2C , K3C , K4C , K5B , K2A , K1B }, \ + { KC_NO, K1C , K2B , K3B , K4B , K4A , K3A , K5A }, \ + { KC_NO, K1M , KC_NO, KC_NO, KC_NO, KC_NO, K1A , KC_NO }, \ + { KC_NO, K0E , KC_NO, KC_NO, KC_NO, K0A , KC_NO, KC_NO }, /* ROW15 */ \ +} + diff --git a/keyboards/mschwingen/modelm/rules.mk b/keyboards/mschwingen/modelm/rules.mk new file mode 100644 index 000000000000..c6bd65c5fb3b --- /dev/null +++ b/keyboards/mschwingen/modelm/rules.mk @@ -0,0 +1,55 @@ +# MCU name +MCU = atmega32u4 + +# Bootloader selection +# Teensy halfkay +# Pro Micro caterina +# Atmel DFU atmel-dfu +# LUFA DFU lufa-dfu +# QMK DFU qmk-dfu +# ATmega32A bootloadHID +# ATmega328P USBasp +BOOTLOADER = qmk-dfu + +# Build Options +# change yes to no to disable +# +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 = yes # Commands for debug and configuration +# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend +# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +NKRO_ENABLE = no # USB Nkey Rollover +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality on B7 by default +RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow +MIDI_ENABLE = no # MIDI support +UNICODE_ENABLE = no # Unicode +BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID +AUDIO_ENABLE = no # Audio output +FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches +HD44780_ENABLE = no # Enable support for HD44780 based LCDs + +CUSTOM_MATRIX = lite +KEY_LOCK_ENABLE = yes + +DYNAMIC_MACRO_ENABLE = yes + +UART_DEBUG = no + +SRC += matrix.c +SRC += $(COMMON_DIR)/uart.c + +OPT_DEFS += -DSLEEP_LED_ENABLE # we need our own sleep callbacks to turn of WS2812 LEDs + +LINK_TIME_OPTIMIZATION_ENABLE = yes + +ifeq ($(strip $(UART_DEBUG)), yes) + OPT_DEFS += -DUART_DEBUG +endif + +DEFAULT_FOLDER=mschwingen/modelm/led_wired From af6096d9f77d3460aab68e3890dddab7a189d16d Mon Sep 17 00:00:00 2001 From: Michael Schwingen Date: Wed, 5 Aug 2020 21:22:13 +0200 Subject: [PATCH 02/26] EMI improvement: remove unnecessary toggling of MOSI pin --- keyboards/mschwingen/modelm/matrix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboards/mschwingen/modelm/matrix.c b/keyboards/mschwingen/modelm/matrix.c index cd1d7b4e0a42..91e5ac078eb5 100644 --- a/keyboards/mschwingen/modelm/matrix.c +++ b/keyboards/mschwingen/modelm/matrix.c @@ -39,7 +39,7 @@ static uint8_t modelm_spi_read(void) { // set 4MHz SPI clock SPSR = 0; SPCR = _BV(SPE) | _BV(MSTR) | _BV(CPOL); - SPDR = 0x55; // Dummy + SPDR = 0x00; // Dummy uint16_t timeout_timer = timer_read(); while (!(SPSR & _BV(SPIF))) { From a9cb7f184c73e550b32ce163f46c0f7d2f46ab3a Mon Sep 17 00:00:00 2001 From: Michael Schwingen Date: Wed, 5 Aug 2020 21:24:06 +0200 Subject: [PATCH 03/26] address review comments --- keyboards/mschwingen/modelm/config.h | 5 ++- .../modelm/keymaps/default/keymap.c | 36 +++++++++---------- keyboards/mschwingen/modelm/modelm.c | 6 ++-- keyboards/mschwingen/modelm/rules.mk | 11 ++---- 4 files changed, 24 insertions(+), 34 deletions(-) diff --git a/keyboards/mschwingen/modelm/config.h b/keyboards/mschwingen/modelm/config.h index 2ea59bf00562..4163741d25e9 100644 --- a/keyboards/mschwingen/modelm/config.h +++ b/keyboards/mschwingen/modelm/config.h @@ -20,12 +20,11 @@ #include "config_common.h" /* USB Device descriptor parameter */ -#define VENDOR_ID 0xFEED -#define PRODUCT_ID 0x0000 +#define VENDOR_ID 0x0000 +#define PRODUCT_ID 0x558e // echo -n "mschwingen IBM Model M 101/102" | shasum | cut -c1-4 #define DEVICE_VER 0x0001 #define MANUFACTURER mschwingen #define PRODUCT IBM Model M 101/102 -#define DESCRIPTION www.schwingen.org /* key matrix size */ #define MATRIX_ROWS 16 diff --git a/keyboards/mschwingen/modelm/keymaps/default/keymap.c b/keyboards/mschwingen/modelm/keymaps/default/keymap.c index 92002181fbc0..a2c8f21435bc 100644 --- a/keyboards/mschwingen/modelm/keymaps/default/keymap.c +++ b/keyboards/mschwingen/modelm/keymaps/default/keymap.c @@ -15,11 +15,11 @@ */ #include QMK_KEYBOARD_H -#define ______ KC_TRNS -#define XXXXXX KC_NO - enum layers { - _BL0 = 0, _BL1, _FL, _MS + _BL0 = 0, + _BL1, + _FL, + _MS }; const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { @@ -52,22 +52,22 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { // Cursor: Media Pref / Next / Volume Up / Volume Down // Space: Media Play / Pause // m: enter mouse layer - ______, DYN_MACRO_PLAY1, DYN_MACRO_PLAY2, DYN_REC_START1, DYN_REC_START2, DYN_REC_STOP, ______, ______ , ______ , ______, ______, ______, ______, ______, ______, ______, - KC_LOCK, ______, ______, ______, ______, ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______, ______ , ______ , ______ , ______ , ______ , - ______, ______, ______, ______, ______, ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______, ______ , ______ , ______ , ______ , ______ , - KC_CAPS, ______, ______, ______, ______, ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , - ______, ______, ______, ______, ______, ______ , ______ , ______ , TG(_MS), ______ , ______ , ______ , ______ , KC_AUDIO_VOL_UP, ______ , ______ , ______ , ______ , - ______, ______, KC_MEDIA_PLAY_PAUSE , ______ , ______ , KC_MEDIA_PREV_TRACK , KC_AUDIO_VOL_DOWN , KC_MEDIA_NEXT_TRACK , ______ , ______ + _______, DYN_MACRO_PLAY1, DYN_MACRO_PLAY2, DYN_REC_START1, DYN_REC_START2, DYN_REC_STOP, _______, _______ , _______ , _______, _______, _______, _______, _______, _______, _______, + KC_LOCK, _______, _______, _______, _______, _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______, _______ , _______ , _______ , _______ , _______ , + _______, _______, _______, _______, _______, _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______, _______ , _______ , _______ , _______ , _______ , + KC_CAPS, _______, _______, _______, _______, _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , + _______, _______, _______, _______, _______, _______ , _______ , _______ , TG(_MS), _______ , _______ , _______ , _______ , KC_AUDIO_VOL_UP, _______ , _______ , _______ , _______ , + _______, _______, KC_MEDIA_PLAY_PAUSE , _______ , _______ , KC_MEDIA_PREV_TRACK , KC_AUDIO_VOL_DOWN , KC_MEDIA_NEXT_TRACK , _______ , _______ ), [_MS] = LAYOUT( /* mouse key layer */ // Cursor: mouse, INS/HOME/PgUp: Mouse Accel, Del, End, PageDn: mouse buttons - TG(_MS), ______, ______, ______, ______, ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , - ______, ______, ______, ______, ______, ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , KC_MS_ACCEL0, KC_MS_ACCEL1, KC_MS_ACCEL2, ______ , ______ , ______ , ______ , - ______, ______, ______, ______, ______, ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , KC_MS_BTN1, KC_MS_BTN3, KC_MS_BTN2, ______ , ______ , ______ , ______ , - ______, ______, ______, ______, ______, ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , - ______, ______ , ______, ______, ______, ______ , ______ , ______ , ______ , ______ , ______ , ______ , ______ , KC_MS_UP, ______ , ______ , ______ , ______ , - ______, ______, ______ , ______ , ______ , KC_MS_LEFT, KC_MS_DOWN, KC_MS_RIGHT, ______ , ______ + TG(_MS), _______, _______, _______, _______, _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , + _______, _______, _______, _______, _______, _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , KC_MS_ACCEL0, KC_MS_ACCEL1, KC_MS_ACCEL2, _______ , _______ , _______ , _______ , + _______, _______, _______, _______, _______, _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , KC_MS_BTN1, KC_MS_BTN3, KC_MS_BTN2, _______ , _______ , _______ , _______ , + _______, _______, _______, _______, _______, _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , + _______, _______, _______, _______, _______, _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , KC_MS_UP, _______ , _______ , _______ , _______ , + _______, _______, _______ , _______ , _______ , KC_MS_LEFT, KC_MS_DOWN, KC_MS_RIGHT, _______ , _______ ), }; @@ -83,10 +83,8 @@ void keyboard_post_init_user(void) { bool process_record_user(uint16_t keycode, keyrecord_t *record) { // If console is enabled, it will print the matrix position and status of each key pressed -#ifdef CONSOLE_ENABLE dprintf("KL: kc: %u, col: %u, row: %u, pressed: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed); -#endif - return true; + return true; } diff --git a/keyboards/mschwingen/modelm/modelm.c b/keyboards/mschwingen/modelm/modelm.c index 9fc6d2c3db9a..25f67eeecb16 100644 --- a/keyboards/mschwingen/modelm/modelm.c +++ b/keyboards/mschwingen/modelm/modelm.c @@ -152,7 +152,7 @@ static void led_update_rgb(void) { } bool led_update_kb(led_t state) { - uprintf("LED Update: %d %d %d", led_state.num_lock, led_state.caps_lock, led_state.scroll_lock); + dprintf("LED Update: %d %d %d", led_state.num_lock, led_state.caps_lock, led_state.scroll_lock); led_state = state; led_update_rgb(); @@ -177,14 +177,14 @@ void update_layer_leds(void) { } old_layer = layer; old_default_layer = default_layer; - uprintf("Layer change: %d %d", default_layer, layer); + dprintf("Layer change: %d %d", default_layer, layer); led_update_rgb(); } /*****************************************************************************/ #else // classic LEDs on GPIO bool led_update_kb(led_t led_state) { - uprintf("LED Update: %d %d %d", led_state.num_lock, led_state.caps_lock, led_state.scroll_lock); + dprintf("LED Update: %d %d %d", led_state.num_lock, led_state.caps_lock, led_state.scroll_lock); if (led_update_user(led_state)) { if (!isRecording) writePin(MODELM_LED_NUMLOCK, !led_state.num_lock); diff --git a/keyboards/mschwingen/modelm/rules.mk b/keyboards/mschwingen/modelm/rules.mk index c6bd65c5fb3b..1e7309098b25 100644 --- a/keyboards/mschwingen/modelm/rules.mk +++ b/keyboards/mschwingen/modelm/rules.mk @@ -2,13 +2,6 @@ MCU = atmega32u4 # Bootloader selection -# Teensy halfkay -# Pro Micro caterina -# Atmel DFU atmel-dfu -# LUFA DFU lufa-dfu -# QMK DFU qmk-dfu -# ATmega32A bootloadHID -# ATmega328P USBasp BOOTLOADER = qmk-dfu # Build Options @@ -18,7 +11,7 @@ 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 +CONSOLE_ENABLE = yes # Console for debug COMMAND_ENABLE = yes # Commands for debug and configuration # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE @@ -46,7 +39,7 @@ SRC += $(COMMON_DIR)/uart.c OPT_DEFS += -DSLEEP_LED_ENABLE # we need our own sleep callbacks to turn of WS2812 LEDs -LINK_TIME_OPTIMIZATION_ENABLE = yes +LTO_ENABLE = yes ifeq ($(strip $(UART_DEBUG)), yes) OPT_DEFS += -DUART_DEBUG From ad26a0e6307aeeb45124e41f09d6f8ff8d575853 Mon Sep 17 00:00:00 2001 From: Michael Schwingen Date: Wed, 5 Aug 2020 21:25:33 +0200 Subject: [PATCH 04/26] Update keyboards/mschwingen/modelm/rules.mk Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com> --- keyboards/mschwingen/modelm/rules.mk | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/keyboards/mschwingen/modelm/rules.mk b/keyboards/mschwingen/modelm/rules.mk index c6bd65c5fb3b..fdb17099f249 100644 --- a/keyboards/mschwingen/modelm/rules.mk +++ b/keyboards/mschwingen/modelm/rules.mk @@ -17,22 +17,16 @@ BOOTLOADER = qmk-dfu 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 = yes # Commands for debug and configuration +CONSOLE_ENABLE = yes # Console for debug +COMMAND_ENABLE = yes # Commands for debug and configuration # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work NKRO_ENABLE = no # USB Nkey Rollover BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality on B7 by default RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow -MIDI_ENABLE = no # MIDI support -UNICODE_ENABLE = no # Unicode -BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID +BLUETOOTH_ENABLE = no # Enable Bluetooth AUDIO_ENABLE = no # Audio output -FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches -HD44780_ENABLE = no # Enable support for HD44780 based LCDs CUSTOM_MATRIX = lite KEY_LOCK_ENABLE = yes From fff835b74eeba198c5bc65636342ce134aebc936 Mon Sep 17 00:00:00 2001 From: Michael Schwingen Date: Wed, 5 Aug 2020 21:25:50 +0200 Subject: [PATCH 05/26] Update keyboards/mschwingen/modelm/rules.mk Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com> --- keyboards/mschwingen/modelm/rules.mk | 7 ------- 1 file changed, 7 deletions(-) diff --git a/keyboards/mschwingen/modelm/rules.mk b/keyboards/mschwingen/modelm/rules.mk index fdb17099f249..d559cb1b864c 100644 --- a/keyboards/mschwingen/modelm/rules.mk +++ b/keyboards/mschwingen/modelm/rules.mk @@ -2,13 +2,6 @@ MCU = atmega32u4 # Bootloader selection -# Teensy halfkay -# Pro Micro caterina -# Atmel DFU atmel-dfu -# LUFA DFU lufa-dfu -# QMK DFU qmk-dfu -# ATmega32A bootloadHID -# ATmega328P USBasp BOOTLOADER = qmk-dfu # Build Options From 133eaa546d6a5730ba806b4fa15391ca08ebc78a Mon Sep 17 00:00:00 2001 From: Michael Schwingen Date: Wed, 5 Aug 2020 21:26:47 +0200 Subject: [PATCH 06/26] Update keyboards/mschwingen/modelm/config.h Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com> --- keyboards/mschwingen/modelm/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboards/mschwingen/modelm/config.h b/keyboards/mschwingen/modelm/config.h index 2ea59bf00562..df5943017ad1 100644 --- a/keyboards/mschwingen/modelm/config.h +++ b/keyboards/mschwingen/modelm/config.h @@ -21,7 +21,7 @@ /* USB Device descriptor parameter */ #define VENDOR_ID 0xFEED -#define PRODUCT_ID 0x0000 +#define PRODUCT_ID 0x558E #define DEVICE_VER 0x0001 #define MANUFACTURER mschwingen #define PRODUCT IBM Model M 101/102 From 59ebdd888a0d76442c3189eb60876f34d7d10a8a Mon Sep 17 00:00:00 2001 From: Michael Schwingen Date: Wed, 5 Aug 2020 21:26:58 +0200 Subject: [PATCH 07/26] Update keyboards/mschwingen/modelm/config.h Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com> --- keyboards/mschwingen/modelm/config.h | 1 - 1 file changed, 1 deletion(-) diff --git a/keyboards/mschwingen/modelm/config.h b/keyboards/mschwingen/modelm/config.h index df5943017ad1..b8618169078b 100644 --- a/keyboards/mschwingen/modelm/config.h +++ b/keyboards/mschwingen/modelm/config.h @@ -25,7 +25,6 @@ #define DEVICE_VER 0x0001 #define MANUFACTURER mschwingen #define PRODUCT IBM Model M 101/102 -#define DESCRIPTION www.schwingen.org /* key matrix size */ #define MATRIX_ROWS 16 From 79a591e877540dbef05abf70bbc03f96feeb500d Mon Sep 17 00:00:00 2001 From: Michael Schwingen Date: Wed, 5 Aug 2020 21:27:08 +0200 Subject: [PATCH 08/26] Update keyboards/mschwingen/modelm/rules.mk Co-authored-by: Drashna Jaelre --- keyboards/mschwingen/modelm/rules.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboards/mschwingen/modelm/rules.mk b/keyboards/mschwingen/modelm/rules.mk index d559cb1b864c..f8026e5f93f8 100644 --- a/keyboards/mschwingen/modelm/rules.mk +++ b/keyboards/mschwingen/modelm/rules.mk @@ -33,7 +33,7 @@ SRC += $(COMMON_DIR)/uart.c OPT_DEFS += -DSLEEP_LED_ENABLE # we need our own sleep callbacks to turn of WS2812 LEDs -LINK_TIME_OPTIMIZATION_ENABLE = yes +LTO_ENABLE = yes ifeq ($(strip $(UART_DEBUG)), yes) OPT_DEFS += -DUART_DEBUG From 85fa0a3646e7fc6653a08770d220e90f2b04b8ee Mon Sep 17 00:00:00 2001 From: Michael Schwingen Date: Wed, 5 Aug 2020 21:27:25 +0200 Subject: [PATCH 09/26] Update keyboards/mschwingen/modelm/keymaps/default/keymap.c Co-authored-by: Drashna Jaelre --- keyboards/mschwingen/modelm/keymaps/default/keymap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/keyboards/mschwingen/modelm/keymaps/default/keymap.c b/keyboards/mschwingen/modelm/keymaps/default/keymap.c index 92002181fbc0..fd7f9ccee4e4 100644 --- a/keyboards/mschwingen/modelm/keymaps/default/keymap.c +++ b/keyboards/mschwingen/modelm/keymaps/default/keymap.c @@ -19,7 +19,10 @@ #define XXXXXX KC_NO enum layers { - _BL0 = 0, _BL1, _FL, _MS + _BL0, + _BL1, + _FL, + _MS }; const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { @@ -89,4 +92,3 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { return true; } - From a9ee75f140a74d352b13f3ad5eb1a131c1312fa8 Mon Sep 17 00:00:00 2001 From: Michael Schwingen Date: Wed, 5 Aug 2020 21:34:26 +0200 Subject: [PATCH 10/26] update printf usage --- keyboards/mschwingen/modelm/modelm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/keyboards/mschwingen/modelm/modelm.c b/keyboards/mschwingen/modelm/modelm.c index 9fc6d2c3db9a..25f67eeecb16 100644 --- a/keyboards/mschwingen/modelm/modelm.c +++ b/keyboards/mschwingen/modelm/modelm.c @@ -152,7 +152,7 @@ static void led_update_rgb(void) { } bool led_update_kb(led_t state) { - uprintf("LED Update: %d %d %d", led_state.num_lock, led_state.caps_lock, led_state.scroll_lock); + dprintf("LED Update: %d %d %d", led_state.num_lock, led_state.caps_lock, led_state.scroll_lock); led_state = state; led_update_rgb(); @@ -177,14 +177,14 @@ void update_layer_leds(void) { } old_layer = layer; old_default_layer = default_layer; - uprintf("Layer change: %d %d", default_layer, layer); + dprintf("Layer change: %d %d", default_layer, layer); led_update_rgb(); } /*****************************************************************************/ #else // classic LEDs on GPIO bool led_update_kb(led_t led_state) { - uprintf("LED Update: %d %d %d", led_state.num_lock, led_state.caps_lock, led_state.scroll_lock); + dprintf("LED Update: %d %d %d", led_state.num_lock, led_state.caps_lock, led_state.scroll_lock); if (led_update_user(led_state)) { if (!isRecording) writePin(MODELM_LED_NUMLOCK, !led_state.num_lock); From d5c969d1bfdf22d52ff26b3b9780086f0f94d5e6 Mon Sep 17 00:00:00 2001 From: Michael Schwingen Date: Wed, 5 Aug 2020 21:34:42 +0200 Subject: [PATCH 11/26] add comment --- keyboards/mschwingen/modelm/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboards/mschwingen/modelm/config.h b/keyboards/mschwingen/modelm/config.h index b8618169078b..d727be55eef4 100644 --- a/keyboards/mschwingen/modelm/config.h +++ b/keyboards/mschwingen/modelm/config.h @@ -21,7 +21,7 @@ /* USB Device descriptor parameter */ #define VENDOR_ID 0xFEED -#define PRODUCT_ID 0x558E +#define PRODUCT_ID 0x558E // echo -n "mschwingen IBM Model M 101/102" | shasum | cut -c1-4 #define DEVICE_VER 0x0001 #define MANUFACTURER mschwingen #define PRODUCT IBM Model M 101/102 From 255c39f72d2025d429da05a2162408155d46fa87 Mon Sep 17 00:00:00 2001 From: Michael Schwingen Date: Wed, 5 Aug 2020 21:35:07 +0200 Subject: [PATCH 12/26] EMI improvement: remove unnecessary toggling of MOSI signal --- keyboards/mschwingen/modelm/matrix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboards/mschwingen/modelm/matrix.c b/keyboards/mschwingen/modelm/matrix.c index cd1d7b4e0a42..91e5ac078eb5 100644 --- a/keyboards/mschwingen/modelm/matrix.c +++ b/keyboards/mschwingen/modelm/matrix.c @@ -39,7 +39,7 @@ static uint8_t modelm_spi_read(void) { // set 4MHz SPI clock SPSR = 0; SPCR = _BV(SPE) | _BV(MSTR) | _BV(CPOL); - SPDR = 0x55; // Dummy + SPDR = 0x00; // Dummy uint16_t timeout_timer = timer_read(); while (!(SPSR & _BV(SPIF))) { From eb45afedd3a761fae81ba7ed3bda553102b29656 Mon Sep 17 00:00:00 2001 From: Michael Schwingen Date: Wed, 5 Aug 2020 22:06:32 +0200 Subject: [PATCH 13/26] remove trailing space --- keyboards/mschwingen/modelm/keymaps/default/keymap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/keyboards/mschwingen/modelm/keymaps/default/keymap.c b/keyboards/mschwingen/modelm/keymaps/default/keymap.c index 871c75913cbf..30d52b40179d 100644 --- a/keyboards/mschwingen/modelm/keymaps/default/keymap.c +++ b/keyboards/mschwingen/modelm/keymaps/default/keymap.c @@ -16,9 +16,9 @@ #include QMK_KEYBOARD_H enum layers { - _BL0, - _BL1, - _FL, + _BL0, + _BL1, + _FL, _MS }; From ca3ef3d00416b65a294469703f2eb5626524ef42 Mon Sep 17 00:00:00 2001 From: Michael Schwingen Date: Wed, 5 Aug 2020 22:07:54 +0200 Subject: [PATCH 14/26] use shorter macros as suggested in review by noroadsleft, re-format table to line up columns --- .../modelm/keymaps/default/keymap.c | 52 +++++++++---------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/keyboards/mschwingen/modelm/keymaps/default/keymap.c b/keyboards/mschwingen/modelm/keymaps/default/keymap.c index 30d52b40179d..9485ca9a7e5d 100644 --- a/keyboards/mschwingen/modelm/keymaps/default/keymap.c +++ b/keyboards/mschwingen/modelm/keymaps/default/keymap.c @@ -24,21 +24,21 @@ enum layers { const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_BL0] = LAYOUT( /* Base layer - Windows key instead of CapsLock, hold ESC for special functions */ - LT(_FL,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_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_INS, KC_HOME, KC_PGUP, KC_NLCK, KC_PSLS, KC_PAST, KC_PMNS, - 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, KC_END, KC_PGDN, KC_P7, KC_P8, KC_P9, KC_PPLS, - KC_LWIN, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_NUHS, KC_ENT, KC_P4, KC_P5, KC_P6, - KC_LSFT, KC_NUBS, 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_P1, KC_P2, KC_P3, KC_PENT, - KC_LCTL, KC_LALT, KC_SPC, KC_RALT, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT + LT(_FL,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_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_INS , KC_HOME, KC_PGUP, KC_NLCK, KC_PSLS, KC_PAST, KC_PMNS, + 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 , KC_END , KC_PGDN, KC_P7, KC_P8 , KC_P9 , KC_PPLS, + KC_LWIN, KC_A, KC_S , KC_D , KC_F , KC_G , KC_H , KC_J , KC_K , KC_L , KC_SCLN, KC_QUOT, KC_NUHS, KC_ENT , KC_P4, KC_P5 , KC_P6 , + KC_LSFT, KC_NUBS, 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_P1, KC_P2 , KC_P3 , KC_PENT, + KC_LCTL, KC_LALT, KC_SPC , KC_RALT, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT ), [_BL1] = LAYOUT( /* Base layer - standard layout without any special functions */ - 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_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_INS, KC_HOME, KC_PGUP, KC_NLCK, KC_PSLS, KC_PAST, KC_PMNS, - 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, KC_END, KC_PGDN, KC_P7, KC_P8, KC_P9, KC_PPLS, - 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_NUHS, KC_ENT, KC_P4, KC_P5, KC_P6, - KC_LSFT, KC_NUBS, 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_P1, KC_P2, KC_P3, KC_PENT, - KC_LCTL, KC_LALT, KC_SPC, KC_RALT, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT + 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_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_INS , KC_HOME, KC_PGUP, KC_NLCK, KC_PSLS, KC_PAST, KC_PMNS, + 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 , KC_END , KC_PGDN, KC_P7, KC_P8 , KC_P9 , KC_PPLS, + 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_NUHS, KC_ENT , KC_P4, KC_P5 , KC_P6 , + KC_LSFT, KC_NUBS, 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_P1, KC_P2 , KC_P3 , KC_PENT, + KC_LCTL, KC_LALT, KC_SPC , KC_RALT, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT ), [_FL] = LAYOUT( /* special functions layer */ @@ -52,27 +52,25 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { // Cursor: Media Pref / Next / Volume Up / Volume Down // Space: Media Play / Pause // m: enter mouse layer - _______, DYN_MACRO_PLAY1, DYN_MACRO_PLAY2, DYN_REC_START1, DYN_REC_START2, DYN_REC_STOP, _______, _______ , _______ , _______, _______, _______, _______, _______, _______, _______, - KC_LOCK, _______, _______, _______, _______, _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______, _______ , _______ , _______ , _______ , _______ , - _______, _______, _______, _______, _______, _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______, _______ , _______ , _______ , _______ , _______ , - KC_CAPS, _______, _______, _______, _______, _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , - _______, _______, _______, _______, _______, _______ , _______ , _______ , TG(_MS), _______ , _______ , _______ , _______ , KC_AUDIO_VOL_UP, _______ , _______ , _______ , _______ , - _______, _______, KC_MEDIA_PLAY_PAUSE , _______ , _______ , KC_MEDIA_PREV_TRACK , KC_AUDIO_VOL_DOWN , KC_MEDIA_NEXT_TRACK , _______ , _______ + _______, DM_PLY1, DM_PLY2, DM_REC1, DM_REC2, DM_RSTP, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + KC_LOCK, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + KC_CAPS, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, TG(_MS), _______, _______, _______, _______, KC_VOLU, _______, _______, _______, _______, + _______, _______, KC_MPLY, _______, _______, KC_MPRV, KC_VOLD, KC_MNXT, _______, _______ ), [_MS] = LAYOUT( /* mouse key layer */ // Cursor: mouse, INS/HOME/PgUp: Mouse Accel, Del, End, PageDn: mouse buttons - TG(_MS), _______, _______, _______, _______, _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , - _______, _______, _______, _______, _______, _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , KC_MS_ACCEL0, KC_MS_ACCEL1, KC_MS_ACCEL2, _______ , _______ , _______ , _______ , - _______, _______, _______, _______, _______, _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , KC_MS_BTN1, KC_MS_BTN3, KC_MS_BTN2, _______ , _______ , _______ , _______ , - _______, _______, _______, _______, _______, _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , - _______, _______, _______, _______, _______, _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , KC_MS_UP, _______ , _______ , _______ , _______ , - _______, _______, _______ , _______ , _______ , KC_MS_LEFT, KC_MS_DOWN, KC_MS_RIGHT, _______ , _______ - ), - + TG(_MS), _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_ACL0, KC_ACL1, KC_ACL2, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_BTN1, KC_BTN3, KC_BTN2, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MS_U, _______, _______, _______, _______, + _______, _______, _______, _______, _______, KC_MS_L, KC_MS_D, KC_MS_R, _______, _______ + ) }; - void keyboard_post_init_user(void) { // Customise these values to desired behaviour //debug_enable=true; From 796ae42b7626fd7a5dbad1d1fcede04849ae74d3 Mon Sep 17 00:00:00 2001 From: Michael Schwingen Date: Thu, 6 Aug 2020 14:03:24 +0200 Subject: [PATCH 15/26] Update keyboards/mschwingen/modelm/config.h Co-authored-by: Ryan --- keyboards/mschwingen/modelm/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboards/mschwingen/modelm/config.h b/keyboards/mschwingen/modelm/config.h index d727be55eef4..b8618169078b 100644 --- a/keyboards/mschwingen/modelm/config.h +++ b/keyboards/mschwingen/modelm/config.h @@ -21,7 +21,7 @@ /* USB Device descriptor parameter */ #define VENDOR_ID 0xFEED -#define PRODUCT_ID 0x558E // echo -n "mschwingen IBM Model M 101/102" | shasum | cut -c1-4 +#define PRODUCT_ID 0x558E #define DEVICE_VER 0x0001 #define MANUFACTURER mschwingen #define PRODUCT IBM Model M 101/102 From 18d4748e1f6aad8e0a1751c9c806b5cab8e4b13c Mon Sep 17 00:00:00 2001 From: Michael Schwingen Date: Thu, 6 Aug 2020 14:03:37 +0200 Subject: [PATCH 16/26] Update keyboards/mschwingen/modelm/rules.mk Co-authored-by: Ryan --- keyboards/mschwingen/modelm/rules.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboards/mschwingen/modelm/rules.mk b/keyboards/mschwingen/modelm/rules.mk index f8026e5f93f8..eeade9f607f8 100644 --- a/keyboards/mschwingen/modelm/rules.mk +++ b/keyboards/mschwingen/modelm/rules.mk @@ -39,4 +39,4 @@ ifeq ($(strip $(UART_DEBUG)), yes) OPT_DEFS += -DUART_DEBUG endif -DEFAULT_FOLDER=mschwingen/modelm/led_wired +DEFAULT_FOLDER = mschwingen/modelm/led_wired From ddcbacc5e783d395875010ec65534f9157cdaa70 Mon Sep 17 00:00:00 2001 From: Michael Schwingen Date: Thu, 6 Aug 2020 14:03:53 +0200 Subject: [PATCH 17/26] Update keyboards/mschwingen/modelm/rules.mk Co-authored-by: Ryan --- keyboards/mschwingen/modelm/rules.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboards/mschwingen/modelm/rules.mk b/keyboards/mschwingen/modelm/rules.mk index eeade9f607f8..7e3589bd2b5f 100644 --- a/keyboards/mschwingen/modelm/rules.mk +++ b/keyboards/mschwingen/modelm/rules.mk @@ -16,7 +16,7 @@ COMMAND_ENABLE = yes # Commands for debug and configuration SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work NKRO_ENABLE = no # USB Nkey Rollover -BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality on B7 by default +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow BLUETOOTH_ENABLE = no # Enable Bluetooth AUDIO_ENABLE = no # Audio output From 9a2c572a17d298c7de041d166fbee81fd0507a04 Mon Sep 17 00:00:00 2001 From: Michael Schwingen Date: Thu, 6 Aug 2020 14:12:40 +0200 Subject: [PATCH 18/26] Update keyboards/mschwingen/modelm/rules.mk Co-authored-by: Ryan --- keyboards/mschwingen/modelm/rules.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboards/mschwingen/modelm/rules.mk b/keyboards/mschwingen/modelm/rules.mk index 7e3589bd2b5f..e29c9d297b06 100644 --- a/keyboards/mschwingen/modelm/rules.mk +++ b/keyboards/mschwingen/modelm/rules.mk @@ -2,7 +2,7 @@ MCU = atmega32u4 # Bootloader selection -BOOTLOADER = qmk-dfu +BOOTLOADER = lufa-dfu # Build Options # change yes to no to disable From 8a2df94704ef7a98a82cf14d083ea389a7f74d83 Mon Sep 17 00:00:00 2001 From: Michael Schwingen Date: Thu, 6 Aug 2020 14:13:08 +0200 Subject: [PATCH 19/26] Update keyboards/mschwingen/modelm/README.md Co-authored-by: Ryan --- keyboards/mschwingen/modelm/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/keyboards/mschwingen/modelm/README.md b/keyboards/mschwingen/modelm/README.md index f32ecb38e86f..123c0581990b 100644 --- a/keyboards/mschwingen/modelm/README.md +++ b/keyboards/mschwingen/modelm/README.md @@ -16,9 +16,9 @@ Make example for this keyboard (after setting up your build environment), run on flash: - make mschwingen/modelm/led_wired:default:dfu - make mschwingen/modelm/led_ffc:default:dfu - make mschwingen/modelm/led_ws2812:default:dfu + make mschwingen/modelm/led_wired:default:flash + make mschwingen/modelm/led_ffc:default:flash + make mschwingen/modelm/led_ws2812:default:flash See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). From 820160f73aac854f7387b784c57398cec5205044 Mon Sep 17 00:00:00 2001 From: Michael Schwingen Date: Thu, 6 Aug 2020 14:13:20 +0200 Subject: [PATCH 20/26] Update keyboards/mschwingen/modelm/README.md Co-authored-by: Ryan --- keyboards/mschwingen/modelm/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/keyboards/mschwingen/modelm/README.md b/keyboards/mschwingen/modelm/README.md index 123c0581990b..36e3b1737de8 100644 --- a/keyboards/mschwingen/modelm/README.md +++ b/keyboards/mschwingen/modelm/README.md @@ -22,5 +22,4 @@ flash: See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). -bootloader: - do not use the QMK bootloader, use the bootloader from [here](https://github.com/mschwingen/modelm-lufa-bootloader) +Bootloader: do not use the QMK bootloader, use the bootloader from [here](https://github.com/mschwingen/modelm-lufa-bootloader) From 4ec0aa4bd823d6366def5c832ebb27a48d653ae3 Mon Sep 17 00:00:00 2001 From: Michael Schwingen Date: Thu, 6 Aug 2020 14:42:19 +0200 Subject: [PATCH 21/26] Apply suggestions from code review use spi_read from core insteads of our own copy Co-authored-by: Ryan --- keyboards/mschwingen/modelm/matrix.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/keyboards/mschwingen/modelm/matrix.c b/keyboards/mschwingen/modelm/matrix.c index 91e5ac078eb5..ef725a61eb72 100644 --- a/keyboards/mschwingen/modelm/matrix.c +++ b/keyboards/mschwingen/modelm/matrix.c @@ -35,21 +35,6 @@ static uint16_t row_bits[MATRIX_ROWS] = { static const pin_t col_pins[MATRIX_COLS] = {D1, D4, D7, B4, F7, F6, F5, F4}; -static uint8_t modelm_spi_read(void) { - // set 4MHz SPI clock - SPSR = 0; - SPCR = _BV(SPE) | _BV(MSTR) | _BV(CPOL); - SPDR = 0x00; // Dummy - - uint16_t timeout_timer = timer_read(); - while (!(SPSR & _BV(SPIF))) { - if ((timer_read() - timeout_timer) >= SPI_TIMEOUT) { - return SPI_STATUS_TIMEOUT; - } - } - return SPDR; -} - static void select_col(uint8_t col) { setPinOutput(col_pins[col]); writePinLow(col_pins[col]); @@ -74,8 +59,8 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) writePinLow(SR_LOAD_PIN); writePinHigh(SR_LOAD_PIN); - row_data = modelm_spi_read() << 8; - row_data |= modelm_spi_read(); + row_data = spi_read() << 8; + row_data |= spi_read(); #if DEBUG phex(~row_data); @@ -109,7 +94,13 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) return matrix_changed; } -void matrix_init_custom(void) { unselect_cols(); } +void matrix_init_custom(void) { + unselect_cols(); + + // set 4MHz SPI clock + SPSR = 0; + SPCR = _BV(SPE) | _BV(MSTR) | _BV(CPOL); +} bool matrix_scan_custom(matrix_row_t current_matrix[]) { bool changed = false; From fc551c66ba4d9a3ce9ef865d82e1e249c9120839 Mon Sep 17 00:00:00 2001 From: Michael Schwingen Date: Thu, 6 Aug 2020 14:46:27 +0200 Subject: [PATCH 22/26] include spi_master.c to use spi_read() --- keyboards/mschwingen/modelm/rules.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/keyboards/mschwingen/modelm/rules.mk b/keyboards/mschwingen/modelm/rules.mk index e29c9d297b06..a94c812fc63a 100644 --- a/keyboards/mschwingen/modelm/rules.mk +++ b/keyboards/mschwingen/modelm/rules.mk @@ -30,6 +30,7 @@ UART_DEBUG = no SRC += matrix.c SRC += $(COMMON_DIR)/uart.c +QUANTUM_LIB_SRC += spi_master.c OPT_DEFS += -DSLEEP_LED_ENABLE # we need our own sleep callbacks to turn of WS2812 LEDs From 13cdfbb41aa6cee8d7e931e633060b0db1c220e2 Mon Sep 17 00:00:00 2001 From: Michael Schwingen Date: Sat, 8 Aug 2020 11:41:27 +0200 Subject: [PATCH 23/26] Update keyboards/mschwingen/modelm/README.md Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com> --- keyboards/mschwingen/modelm/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/keyboards/mschwingen/modelm/README.md b/keyboards/mschwingen/modelm/README.md index 36e3b1737de8..f4cb3606252f 100644 --- a/keyboards/mschwingen/modelm/README.md +++ b/keyboards/mschwingen/modelm/README.md @@ -20,6 +20,6 @@ flash: make mschwingen/modelm/led_ffc:default:flash make mschwingen/modelm/led_ws2812:default:flash -See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). - Bootloader: do not use the QMK bootloader, use the bootloader from [here](https://github.com/mschwingen/modelm-lufa-bootloader) + +See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). From cc3c9398aa677c7664ef183d14ae5315aee0b58d Mon Sep 17 00:00:00 2001 From: Michael Schwingen Date: Sat, 8 Aug 2020 11:45:55 +0200 Subject: [PATCH 24/26] Apply suggestions from code review: correct indenting in keymap Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com> --- keyboards/mschwingen/modelm/keymaps/default/keymap.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/keyboards/mschwingen/modelm/keymaps/default/keymap.c b/keyboards/mschwingen/modelm/keymaps/default/keymap.c index 9485ca9a7e5d..7f43746db9d0 100644 --- a/keyboards/mschwingen/modelm/keymaps/default/keymap.c +++ b/keyboards/mschwingen/modelm/keymaps/default/keymap.c @@ -52,17 +52,17 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { // Cursor: Media Pref / Next / Volume Up / Volume Down // Space: Media Play / Pause // m: enter mouse layer - _______, DM_PLY1, DM_PLY2, DM_REC1, DM_REC2, DM_RSTP, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, DM_PLY1, DM_PLY2, DM_REC1, DM_REC2, DM_RSTP, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_LOCK, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_CAPS, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, TG(_MS), _______, _______, _______, _______, KC_VOLU, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, TG(_MS), _______, _______, _______, _______, KC_VOLU, _______, _______, _______, _______, _______, _______, KC_MPLY, _______, _______, KC_MPRV, KC_VOLD, KC_MNXT, _______, _______ ), [_MS] = LAYOUT( /* mouse key layer */ // Cursor: mouse, INS/HOME/PgUp: Mouse Accel, Del, End, PageDn: mouse buttons - TG(_MS), _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + TG(_MS), _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_ACL0, KC_ACL1, KC_ACL2, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_BTN1, KC_BTN3, KC_BTN2, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, @@ -84,4 +84,3 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { dprintf("KL: kc: %u, col: %u, row: %u, pressed: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed); return true; } - From e102881c969a2f85a1bb449958b55cefb000410e Mon Sep 17 00:00:00 2001 From: Michael Schwingen Date: Fri, 21 Aug 2020 15:25:32 +0200 Subject: [PATCH 25/26] Apply suggestions from code review use automatic variant defines from makefile instead of defining our own Co-authored-by: Drashna Jaelre --- keyboards/mschwingen/modelm/config.h | 6 +++--- keyboards/mschwingen/modelm/led_ffc/rules.mk | 3 +-- keyboards/mschwingen/modelm/led_wired/rules.mk | 3 +-- keyboards/mschwingen/modelm/led_ws2812/rules.mk | 1 - keyboards/mschwingen/modelm/modelm.c | 8 ++++---- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/keyboards/mschwingen/modelm/config.h b/keyboards/mschwingen/modelm/config.h index b8618169078b..07881cd211f9 100644 --- a/keyboards/mschwingen/modelm/config.h +++ b/keyboards/mschwingen/modelm/config.h @@ -69,15 +69,15 @@ #define MODELM_LED2 B6 #define MODELM_LED3 D0 -#if defined MODELM_LEDS_WIRED +#if defined(KEYBOARD_mschwingen_modelm_led_wired) # define MODELM_LED_CAPSLOCK MODELM_LED1 # define MODELM_LED_SCROLLOCK MODELM_LED2 # define MODELM_LED_NUMLOCK MODELM_LED3 -#elif defined MODELM_LEDS_FFC +#elif defined(KEYBOARD_mschwingen_modelm_led_ffc) # define MODELM_LED_CAPSLOCK MODELM_LED2 # define MODELM_LED_SCROLLOCK MODELM_LED3 # define MODELM_LED_NUMLOCK MODELM_LED1 -#elif defined MODELM_LEDS_WS2812 +#elif defined(KEYBOARD_mschwingen_modelm_led_ws2812) #else # error one of MODELM_LEDS_FFC, MODELM_LEDS_WIRED or MODELM_LEDS_WS2812 must be set! #endif diff --git a/keyboards/mschwingen/modelm/led_ffc/rules.mk b/keyboards/mschwingen/modelm/led_ffc/rules.mk index 837824d82c7b..8b137891791f 100644 --- a/keyboards/mschwingen/modelm/led_ffc/rules.mk +++ b/keyboards/mschwingen/modelm/led_ffc/rules.mk @@ -1,2 +1 @@ -# variant for FFC LED board -OPT_DEFS += -DMODELM_LEDS_FFC + diff --git a/keyboards/mschwingen/modelm/led_wired/rules.mk b/keyboards/mschwingen/modelm/led_wired/rules.mk index 4ccd2f2f3190..8b137891791f 100644 --- a/keyboards/mschwingen/modelm/led_wired/rules.mk +++ b/keyboards/mschwingen/modelm/led_wired/rules.mk @@ -1,2 +1 @@ -# variant for wired LED PCB -OPT_DEFS += -DMODELM_LEDS_WIRED + diff --git a/keyboards/mschwingen/modelm/led_ws2812/rules.mk b/keyboards/mschwingen/modelm/led_ws2812/rules.mk index 183af7f5926d..424388fd8f6f 100644 --- a/keyboards/mschwingen/modelm/led_ws2812/rules.mk +++ b/keyboards/mschwingen/modelm/led_ws2812/rules.mk @@ -1,3 +1,2 @@ # variant for WS2812 LEDs SRC += ws2812.c -OPT_DEFS += -DMODELM_LEDS_WS2812 diff --git a/keyboards/mschwingen/modelm/modelm.c b/keyboards/mschwingen/modelm/modelm.c index 25f67eeecb16..5756a95170bc 100644 --- a/keyboards/mschwingen/modelm/modelm.c +++ b/keyboards/mschwingen/modelm/modelm.c @@ -36,7 +36,7 @@ static uint16_t blink_cycle_timer; static bool blink_state = false; static uint8_t isRecording = 0; -#ifdef MODELM_LEDS_WS2812 +#ifdef KEYBOARD_mschwingen_modelm_led_ws2812 # if RGBLED_NUM < 3 # error we need at least 3 RGB LEDs! # endif @@ -81,7 +81,7 @@ void sleep_led_disable(void) { void sleep_led_enable(void) { suspend_active = true; writePinLow(QMK_LED); -#ifdef MODELM_LEDS_WS2812 +#ifdef KEYBOARD_mschwingen_modelm_led_ws2812 led[0] = black; led[1] = black; led[2] = black; @@ -90,7 +90,7 @@ void sleep_led_enable(void) { } void keyboard_pre_init_kb(void) { -#ifdef MODELM_LEDS_WS2812 +#ifdef KEYBOARD_mschwingen_modelm_led_ws2812 ws2812_setleds(led, RGBLED_NUM); #else /* Set status LEDs pins to output and Low (on) */ @@ -116,7 +116,7 @@ void keyboard_pre_init_kb(void) { writePinLow(SR_CLK_PIN); } -#ifdef MODELM_LEDS_WS2812 +#ifdef KEYBOARD_mschwingen_modelm_led_ws2812 static void led_update_rgb(void) { if (isRecording && blink_state) { led[0] = white; From 5ccbc50717839c4fe58bcbe82ebb662759b96907 Mon Sep 17 00:00:00 2001 From: Michael Schwingen Date: Fri, 21 Aug 2020 15:26:37 +0200 Subject: [PATCH 26/26] Update keyboards/mschwingen/modelm/rules.mk: use QUANTUM_LIB_SRC for uart.c Co-authored-by: Drashna Jaelre --- keyboards/mschwingen/modelm/rules.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/keyboards/mschwingen/modelm/rules.mk b/keyboards/mschwingen/modelm/rules.mk index a94c812fc63a..f3af26eeeb0f 100644 --- a/keyboards/mschwingen/modelm/rules.mk +++ b/keyboards/mschwingen/modelm/rules.mk @@ -29,8 +29,8 @@ DYNAMIC_MACRO_ENABLE = yes UART_DEBUG = no SRC += matrix.c -SRC += $(COMMON_DIR)/uart.c -QUANTUM_LIB_SRC += spi_master.c +QUANTUM_LIB_SRC += $(COMMON_DIR)/uart.c \ + spi_master.c OPT_DEFS += -DSLEEP_LED_ENABLE # we need our own sleep callbacks to turn of WS2812 LEDs