diff options
author | nuess0r <[email protected]> | 2023-05-27 15:12:36 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2023-05-27 23:12:36 +1000 |
commit | f98f8eedf0dc6fe939162210ad44d5af8a0dfa08 (patch) | |
tree | 171b1de71a2fec4e7c4f30b6c7e0275061a8d3f3 /keyboards/ibm/model_m/mschwingen | |
parent | e759230706373e9db8a0d6758f8c210288870d9f (diff) | |
download | qmk_firmware-f98f8eedf0dc6fe939162210ad44d5af8a0dfa08.tar.gz qmk_firmware-f98f8eedf0dc6fe939162210ad44d5af8a0dfa08.zip |
Consolidate modelm v2 (#14996)
Co-authored-by: Ryan <[email protected]>
Co-authored-by: Nick Brassel <[email protected]>
Diffstat (limited to 'keyboards/ibm/model_m/mschwingen')
-rw-r--r-- | keyboards/ibm/model_m/mschwingen/config.h | 77 | ||||
-rw-r--r-- | keyboards/ibm/model_m/mschwingen/info.json | 143 | ||||
-rw-r--r-- | keyboards/ibm/model_m/mschwingen/keymaps/default/keymap.c | 86 | ||||
-rw-r--r-- | keyboards/ibm/model_m/mschwingen/led_ffc/readme.md | 21 | ||||
-rw-r--r-- | keyboards/ibm/model_m/mschwingen/led_ffc/rules.mk | 1 | ||||
-rw-r--r-- | keyboards/ibm/model_m/mschwingen/led_wired/readme.md | 21 | ||||
-rw-r--r-- | keyboards/ibm/model_m/mschwingen/led_wired/rules.mk | 1 | ||||
-rw-r--r-- | keyboards/ibm/model_m/mschwingen/led_ws2812/readme.md | 21 | ||||
-rw-r--r-- | keyboards/ibm/model_m/mschwingen/led_ws2812/rules.mk | 1 | ||||
-rw-r--r-- | keyboards/ibm/model_m/mschwingen/matrix.c | 113 | ||||
-rw-r--r-- | keyboards/ibm/model_m/mschwingen/mschwingen.c | 213 | ||||
-rw-r--r-- | keyboards/ibm/model_m/mschwingen/mschwingen.h | 22 | ||||
-rw-r--r-- | keyboards/ibm/model_m/mschwingen/post_rules.mk | 3 | ||||
-rw-r--r-- | keyboards/ibm/model_m/mschwingen/readme.md | 25 | ||||
-rw-r--r-- | keyboards/ibm/model_m/mschwingen/rules.mk | 29 |
15 files changed, 777 insertions, 0 deletions
diff --git a/keyboards/ibm/model_m/mschwingen/config.h b/keyboards/ibm/model_m/mschwingen/config.h new file mode 100644 index 0000000000..b1dc81b8c7 --- /dev/null +++ b/keyboards/ibm/model_m/mschwingen/config.h @@ -0,0 +1,77 @@ +/* + * 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 <http://www.gnu.org/licenses/>. + */ + +#pragma once + + +/* 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 + +/* + * 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 DEBUG_MATRIX_SCAN_RATE +#define DYNAMIC_MACRO_NO_NESTING + +#define MODELM_STATUS_LED E6 + +#define MODELM_LED1 B5 +#define MODELM_LED2 B6 +#define MODELM_LED3 D0 + +#if defined(KEYBOARD_ibm_model_m_mschwingen_led_wired) +# define MODELM_LED_CAPSLOCK MODELM_LED1 +# define MODELM_LED_SCROLLOCK MODELM_LED2 +# define MODELM_LED_NUMLOCK MODELM_LED3 +#elif defined(KEYBOARD_ibm_model_m_mschwingen_led_ffc) +# define MODELM_LED_CAPSLOCK MODELM_LED2 +# define MODELM_LED_SCROLLOCK MODELM_LED3 +# define MODELM_LED_NUMLOCK MODELM_LED1 +#elif defined(KEYBOARD_ibm_model_m_mschwingen_led_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 RGBLED_NUM 3 + +// disabled, needs PCB patch. +//#define AUDIO_PIN C6 +//#define NO_MUSIC_MODE diff --git a/keyboards/ibm/model_m/mschwingen/info.json b/keyboards/ibm/model_m/mschwingen/info.json new file mode 100644 index 0000000000..1ba525de6c --- /dev/null +++ b/keyboards/ibm/model_m/mschwingen/info.json @@ -0,0 +1,143 @@ +{ + "keyboard_name": "atmega32U4 board for IBM Model M", + "manufacturer": "mschwingen", + "url": "https://github.com/qmk/qmk_firmware/tree/master/keyboards/ibm/model_m/mschwingen", + "maintainer": "mschwingen", + "usb": { + "vid": "0xFEED", + "pid": "0x558E", + "device_version": "0.0.1" + }, + "ws2812": { + "pin": "B6" + }, + "processor": "atmega32u4", + "bootloader": "lufa-dfu", + "layouts": { + "LAYOUT": { + "layout": [ + {"matrix": [13, 7], "x": 0, "y": 0}, + + {"matrix": [12, 5], "x": 2, "y": 0}, + {"matrix": [11, 5], "x": 3, "y": 0}, + {"matrix": [11, 6], "x": 4, "y": 0}, + {"matrix": [11, 7], "x": 5, "y": 0}, + + {"matrix": [9, 7], "x": 6.5, "y": 0}, + {"matrix": [7, 7], "x": 7.5, "y": 0}, + {"matrix": [6, 6], "x": 8.5, "y": 0}, + {"matrix": [6, 5], "x": 9.5, "y": 0}, + + {"matrix": [9, 5], "x": 11, "y": 0}, + {"matrix": [9, 4], "x": 12, "y": 0}, + {"matrix": [4, 4], "x": 13, "y": 0}, + {"matrix": [3, 4], "x": 14, "y": 0}, + + {"matrix": [0, 4], "x": 15.5, "y": 0}, + {"matrix": [0, 3], "x": 16.5, "y": 0}, + {"matrix": [1, 1], "x": 17.5, "y": 0}, + + {"matrix": [13, 5], "x": 0, "y": 2}, + {"matrix": [13, 4], "x": 1, "y": 2}, + {"matrix": [12, 4], "x": 2, "y": 2}, + {"matrix": [11, 4], "x": 3, "y": 2}, + {"matrix": [10, 4], "x": 4, "y": 2}, + {"matrix": [10, 5], "x": 5, "y": 2}, + {"matrix": [8, 5], "x": 6, "y": 2}, + {"matrix": [8, 4], "x": 7, "y": 2}, + {"matrix": [7, 4], "x": 8, "y": 2}, + {"matrix": [6, 4], "x": 9, "y": 2}, + {"matrix": [5, 4], "x": 10, "y": 2}, + {"matrix": [5, 5], "x": 11, "y": 2}, + {"matrix": [7, 5], "x": 12, "y": 2}, + {"matrix": [9, 6], "x": 13, "y": 2, "w": 2}, + + {"matrix": [3, 5], "x": 15.5, "y": 2}, + {"matrix": [1, 5], "x": 16.5, "y": 2}, + {"matrix": [2, 5], "x": 17.5, "y": 2}, + + {"matrix": [4, 1], "x": 19, "y": 2}, + {"matrix": [3, 1], "x": 20, "y": 2}, + {"matrix": [2, 1], "x": 21, "y": 2}, + {"matrix": [2, 0], "x": 22, "y": 2}, + + {"matrix": [13, 6], "x": 0, "y": 3, "w": 1.5}, + {"matrix": [13, 3], "x": 1.5, "y": 3}, + {"matrix": [12, 3], "x": 2.5, "y": 3}, + {"matrix": [11, 3], "x": 3.5, "y": 3}, + {"matrix": [10, 3], "x": 4.5, "y": 3}, + {"matrix": [10, 6], "x": 5.5, "y": 3}, + {"matrix": [8, 6], "x": 6.5, "y": 3}, + {"matrix": [8, 3], "x": 7.5, "y": 3}, + {"matrix": [7, 3], "x": 8.5, "y": 3}, + {"matrix": [6, 3], "x": 9.5, "y": 3}, + {"matrix": [5, 3], "x": 10.5, "y": 3}, + {"matrix": [5, 6], "x": 11.5, "y": 3}, + {"matrix": [7, 6], "x": 12.5, "y": 3}, + {"matrix": [9, 2], "x": 13.5, "y": 3, "w": 1.5}, + + {"matrix": [4, 5], "x": 15.5, "y": 3}, + {"matrix": [1, 4], "x": 16.5, "y": 3}, + {"matrix": [2, 4], "x": 17.5, "y": 3}, + + {"matrix": [4, 3], "x": 19, "y": 3}, + {"matrix": [3, 3], "x": 20, "y": 3}, + {"matrix": [2, 3], "x": 21, "y": 3}, + {"matrix": [1, 3], "x": 22, "y": 3, "h": 2}, + + {"matrix": [12, 6], "x": 0, "y": 4, "w": 1.75}, + {"matrix": [13, 2], "x": 1.75, "y": 4}, + {"matrix": [12, 2], "x": 2.75, "y": 4}, + {"matrix": [11, 2], "x": 3.75, "y": 4}, + {"matrix": [10, 2], "x": 4.75, "y": 4}, + {"matrix": [10, 7], "x": 5.75, "y": 4}, + {"matrix": [8, 7], "x": 6.75, "y": 4}, + {"matrix": [8, 2], "x": 7.75, "y": 4}, + {"matrix": [7, 2], "x": 8.75, "y": 4}, + {"matrix": [6, 2], "x": 9.75, "y": 4}, + {"matrix": [5, 2], "x": 10.75, "y": 4}, + {"matrix": [5, 7], "x": 11.75, "y": 4}, + {"matrix": [5, 1], "x": 12.75, "y": 4}, + {"matrix": [9, 1], "x": 13.75, "y": 4, "w": 1.25}, + + {"matrix": [4, 6], "x": 19, "y": 4}, + {"matrix": [3, 6], "x": 20, "y": 4}, + {"matrix": [2, 6], "x": 21, "y": 4}, + + {"matrix": [14, 6], "x": 0, "y": 5, "w": 1.25}, + {"matrix": [12, 7], "x": 1.25, "y": 5}, + {"matrix": [13, 1], "x": 2.25, "y": 5}, + {"matrix": [12, 1], "x": 3.25, "y": 5}, + {"matrix": [11, 1], "x": 4.25, "y": 5}, + {"matrix": [10, 1], "x": 5.25, "y": 5}, + {"matrix": [10, 0], "x": 6.25, "y": 5}, + {"matrix": [8, 0], "x": 7.25, "y": 5}, + {"matrix": [8, 1], "x": 8.25, "y": 5}, + {"matrix": [7, 1], "x": 9.25, "y": 5}, + {"matrix": [6, 1], "x": 10.25, "y": 5}, + {"matrix": [5, 0], "x": 11.25, "y": 5}, + {"matrix": [14, 1], "x": 12.25, "y": 5, "w": 2.75}, + + {"matrix": [1, 7], "x": 16.5, "y": 5}, + + {"matrix": [4, 2], "x": 19, "y": 5}, + {"matrix": [3, 2], "x": 20, "y": 5}, + {"matrix": [2, 2], "x": 21, "y": 5}, + {"matrix": [1, 2], "x": 22, "y": 5, "h": 2}, + + {"matrix": [15, 5], "x": 0, "y": 6, "w": 1.5}, + {"matrix": [0, 7], "x": 2.5, "y": 6, "w": 1.5}, + {"matrix": [9, 0], "x": 4, "y": 6, "w": 7}, + {"matrix": [0, 0], "x": 11, "y": 6, "w": 1.5}, + {"matrix": [15, 1], "x": 13.5, "y": 6, "w": 1.5}, + + {"matrix": [1, 0], "x": 15.5, "y": 6}, + {"matrix": [4, 0], "x": 16.5, "y": 6}, + {"matrix": [3, 0], "x": 17.5, "y": 6}, + + {"matrix": [3, 7], "x": 19, "y": 6, "w": 2}, + {"matrix": [2, 7], "x": 21, "y": 6} + ] + } + } +} diff --git a/keyboards/ibm/model_m/mschwingen/keymaps/default/keymap.c b/keyboards/ibm/model_m/mschwingen/keymaps/default/keymap.c new file mode 100644 index 0000000000..8e28b4e449 --- /dev/null +++ b/keyboards/ibm/model_m/mschwingen/keymaps/default/keymap.c @@ -0,0 +1,86 @@ +/* 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 <http://www.gnu.org/licenses/>. + */ +#include QMK_KEYBOARD_H + +enum layers { + _BL0, + _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_SCRL, 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_NUM, 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_SCRL, 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_NUM, 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 + _______, DM_PLY1, DM_PLY2, DM_REC1, DM_REC2, DM_RSTP, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + QK_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_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; + //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 + 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; +} diff --git a/keyboards/ibm/model_m/mschwingen/led_ffc/readme.md b/keyboards/ibm/model_m/mschwingen/led_ffc/readme.md new file mode 100644 index 0000000000..722567c18f --- /dev/null +++ b/keyboards/ibm/model_m/mschwingen/led_ffc/readme.md @@ -0,0 +1,21 @@ +# atmega32U4 board for IBM Model M, LEDs connected with flexible flat cable (FFC) + + + +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 ibm/model_m/mschwingen/led_ffc:default + +Flashing example for this keyboard: + + make ibm/model_m/mschwingen/led_ffc:default:flash + +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). diff --git a/keyboards/ibm/model_m/mschwingen/led_ffc/rules.mk b/keyboards/ibm/model_m/mschwingen/led_ffc/rules.mk new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/keyboards/ibm/model_m/mschwingen/led_ffc/rules.mk @@ -0,0 +1 @@ + diff --git a/keyboards/ibm/model_m/mschwingen/led_wired/readme.md b/keyboards/ibm/model_m/mschwingen/led_wired/readme.md new file mode 100644 index 0000000000..073c75c10d --- /dev/null +++ b/keyboards/ibm/model_m/mschwingen/led_wired/readme.md @@ -0,0 +1,21 @@ +# atmega32U4 board for IBM Model M, LEDs connected with wires + + + +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 ibm/model_m/mschwingen/led_wired:default + +Flashing example for this keyboard: + + make ibm/model_m/mschwingen/led_wired:default:flash + +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). diff --git a/keyboards/ibm/model_m/mschwingen/led_wired/rules.mk b/keyboards/ibm/model_m/mschwingen/led_wired/rules.mk new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/keyboards/ibm/model_m/mschwingen/led_wired/rules.mk @@ -0,0 +1 @@ + diff --git a/keyboards/ibm/model_m/mschwingen/led_ws2812/readme.md b/keyboards/ibm/model_m/mschwingen/led_ws2812/readme.md new file mode 100644 index 0000000000..669f7f37a1 --- /dev/null +++ b/keyboards/ibm/model_m/mschwingen/led_ws2812/readme.md @@ -0,0 +1,21 @@ +# atmega32U4 board for IBM Model M, old LEDs replaces with WS2812 RGB LEDs + + + +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 ibm/model_m/mschwingen/led_ws2812:default + +Flashing example for this keyboard: + + make ibm/model_m/mschwingen/led_ws2812:default:flash + +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). diff --git a/keyboards/ibm/model_m/mschwingen/led_ws2812/rules.mk b/keyboards/ibm/model_m/mschwingen/led_ws2812/rules.mk new file mode 100644 index 0000000000..9a69649289 --- /dev/null +++ b/keyboards/ibm/model_m/mschwingen/led_ws2812/rules.mk @@ -0,0 +1 @@ +WS2812_DRIVER_REQUIRED = yes diff --git a/keyboards/ibm/model_m/mschwingen/matrix.c b/keyboards/ibm/model_m/mschwingen/matrix.c new file mode 100644 index 0000000000..9997b65975 --- /dev/null +++ b/keyboards/ibm/model_m/mschwingen/matrix.c @@ -0,0 +1,113 @@ +/* + * 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 <http://www.gnu.org/licenses/>. + */ +#include <stdint.h> +#include <stdbool.h> +#include "util.h" +#include "matrix.h" +#include "debounce.h" +#include "quantum.h" +#include "spi_master.h" +#include "print.h" +#include "mschwingen.h" + +#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 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 = spi_read() << 8; + row_data |= spi_read(); + + debug_hex8(~row_data); + dprint(" "); + + // 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(); + + // 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; + + dprint("\r\nScan: "); + + // 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/ibm/model_m/mschwingen/mschwingen.c b/keyboards/ibm/model_m/mschwingen/mschwingen.c new file mode 100644 index 0000000000..b764660e21 --- /dev/null +++ b/keyboards/ibm/model_m/mschwingen/mschwingen.c @@ -0,0 +1,213 @@ +/* + * 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 <http://www.gnu.org/licenses/>. + */ +#include <util/delay.h> +#include "mschwingen.h" +#include "uart.h" +#include "print.h" +#include "sendchar.h" +#include "ws2812.h" +#include "sleep_led.h" + +#ifdef UART_DEBUG +# undef sendchar +static int8_t capture_sendchar(uint8_t c) { + // sendchar(c); + uart_write(c); + return 0; +} +#endif + +static uint16_t blink_cycle_timer; +static bool blink_state = false; +static uint8_t isRecording = 0; + +#ifdef KEYBOARD_ibm_model_m_mschwingen_led_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 __attribute__((unused)) cRGB green = {.r = 0, .g = BRIGHT, .b = 0}; +static const __attribute__((unused)) cRGB lgreen = {.r = 0, .g = DIM, .b = 0}; + +static const __attribute__((unused)) cRGB red = {.r = BRIGHT, .g = 0, .b = 0}; +static const __attribute__((unused)) cRGB lred = {.r = DIM, .g = 0, .b = 0}; + +static const __attribute__((unused)) cRGB blue = {.r = 0, .g = 0, .b = BRIGHT}; +static const __attribute__((unused)) cRGB lblue = {.r = 0, .g = 0, .b = DIM}; + +static const __attribute__((unused)) cRGB turq = {.r = 0, .g = BRIGHT, .b = BRIGHT}; +static const __attribute__((unused)) cRGB lturq = {.r = 0, .g = DIM, .b = DIM}; + +static const __attribute__((unused)) 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(MODELM_STATUS_LED); +} + +void sleep_led_enable(void) { + suspend_active = true; + writePinLow(MODELM_STATUS_LED); +#ifdef KEYBOARD_ibm_model_m_mschwingen_led_ws2812 + led[0] = black; + led[1] = black; + led[2] = black; + ws2812_setleds(led, RGBLED_NUM); +#endif +} + +void keyboard_pre_init_kb(void) { +#ifdef KEYBOARD_ibm_model_m_mschwingen_led_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(MODELM_STATUS_LED); + writePinHigh(MODELM_STATUS_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 KEYBOARD_ibm_model_m_mschwingen_led_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) { + dprintf("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 = get_highest_layer(layer_state); + default_layer = get_highest_layer(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; + dprintf("Layer change: %d %d", default_layer, layer); + led_update_rgb(); +} + +/*****************************************************************************/ +#else // classic LEDs on GPIO +bool led_update_kb(led_t led_state) { + 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); + 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(int8_t direction) { + isRecording++; + blink_cycle_timer = timer_read(); +} + +void dynamic_macro_record_end_user(int8_t direction) { + if (isRecording) isRecording--; +} diff --git a/keyboards/ibm/model_m/mschwingen/mschwingen.h b/keyboards/ibm/model_m/mschwingen/mschwingen.h new file mode 100644 index 0000000000..d842793ccd --- /dev/null +++ b/keyboards/ibm/model_m/mschwingen/mschwingen.h @@ -0,0 +1,22 @@ +/* + * 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 <http://www.gnu.org/licenses/>. + */ + +#pragma once + +extern void update_layer_leds(void); + +#include "quantum.h" diff --git a/keyboards/ibm/model_m/mschwingen/post_rules.mk b/keyboards/ibm/model_m/mschwingen/post_rules.mk new file mode 100644 index 0000000000..a1c2040f4c --- /dev/null +++ b/keyboards/ibm/model_m/mschwingen/post_rules.mk @@ -0,0 +1,3 @@ +ifeq ($(strip $(UART_DEBUG)), yes) + OPT_DEFS += -DUART_DEBUG +endif diff --git a/keyboards/ibm/model_m/mschwingen/readme.md b/keyboards/ibm/model_m/mschwingen/readme.md new file mode 100644 index 0000000000..69c5c8b268 --- /dev/null +++ b/keyboards/ibm/model_m/mschwingen/readme.md @@ -0,0 +1,25 @@ +# atmega32U4 board for IBM Model M + + + +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 ibm/model_m/mschwingen/led_wired:default + make ibm/model_m/mschwingen/led_ffc:default + make ibm/model_m/mschwingen/led_ws2812:default + +flash: + + make ibm/model_m/mschwingen/led_wired:default:flash + make ibm/model_m/mschwingen/led_ffc:default:flash + make ibm/model_m/mschwingen/led_ws2812:default:flash + +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). diff --git a/keyboards/ibm/model_m/mschwingen/rules.mk b/keyboards/ibm/model_m/mschwingen/rules.mk new file mode 100644 index 0000000000..5ccab87d9b --- /dev/null +++ b/keyboards/ibm/model_m/mschwingen/rules.mk @@ -0,0 +1,29 @@ +# Build Options +# change yes to no to disable +# +BOOTMAGIC_ENABLE = no # Enable Bootmagic Lite +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 +NKRO_ENABLE = no # Enable N-Key Rollover +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow +AUDIO_ENABLE = no # Audio output + +CUSTOM_MATRIX = lite +KEY_LOCK_ENABLE = yes + +DYNAMIC_MACRO_ENABLE = yes + +UART_DEBUG = no + +SRC += matrix.c +QUANTUM_LIB_SRC += uart.c \ + spi_master.c + +OPT_DEFS += -DSLEEP_LED_ENABLE # we need our own sleep callbacks to turn of WS2812 LEDs + +LTO_ENABLE = yes + +DEFAULT_FOLDER = ibm/model_m/mschwingen/led_wired |