From 99e9e1b8e70b7b6a0cc03a6672f2512b472fb650 Mon Sep 17 00:00:00 2001
From: wangfuco <46733695+wangfuco@users.noreply.github.com>
Date: Wed, 13 Jul 2022 15:24:42 -0700
Subject: [PATCH] [Keyboard] Modelm101 teensy2 (#16805)
* Add modelm101_teensy2 files from modelm101
* Change info.json
* Update README.md
* Update pin def
* Fix file name
* Update readme.md
* Delete config.h
* Apply suggestions from code review
* Update keyboards/converter/modelm101_teensy2/config.h
* Delete keyboards/converter/modelm101_teensy2/keymaps/iw0rm3r directory
* Delete .noci
---
.../converter/modelm101_teensy2/config.h | 74 +++++++++++++++++++
.../converter/modelm101_teensy2/info.json | 10 +++
.../keymaps/default/keymap.c | 27 +++++++
.../keymaps/default/readme.md | 1 +
.../modelm101_teensy2/modelm101_teensy2.c | 16 ++++
.../modelm101_teensy2/modelm101_teensy2.h | 45 +++++++++++
.../converter/modelm101_teensy2/readme.md | 29 ++++++++
.../converter/modelm101_teensy2/rules.mk | 18 +++++
8 files changed, 220 insertions(+)
create mode 100644 keyboards/converter/modelm101_teensy2/config.h
create mode 100644 keyboards/converter/modelm101_teensy2/info.json
create mode 100644 keyboards/converter/modelm101_teensy2/keymaps/default/keymap.c
create mode 100644 keyboards/converter/modelm101_teensy2/keymaps/default/readme.md
create mode 100644 keyboards/converter/modelm101_teensy2/modelm101_teensy2.c
create mode 100644 keyboards/converter/modelm101_teensy2/modelm101_teensy2.h
create mode 100644 keyboards/converter/modelm101_teensy2/readme.md
create mode 100644 keyboards/converter/modelm101_teensy2/rules.mk
diff --git a/keyboards/converter/modelm101_teensy2/config.h b/keyboards/converter/modelm101_teensy2/config.h
new file mode 100644
index 0000000000..eb443856cd
--- /dev/null
+++ b/keyboards/converter/modelm101_teensy2/config.h
@@ -0,0 +1,74 @@
+/*
+Copyright 2019 iw0rm3r
+
+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 wangfuco
+#define PRODUCT IBM Model M 101/102
+
+/* key matrix size */
+#define MATRIX_ROWS 8
+#define MATRIX_COLS 16
+
+/*
+ * Keyboard Matrix Assignments
+ *
+ * Change this to how you wired your keyboard
+ * COLS: AVR pins used for columns, left to right
+ * ROWS: AVR pins used for rows, top to bottom
+ * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode)
+ * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode)
+ *
+*/
+#define MATRIX_ROW_PINS { D0, D1, D2, D3, C6, C7, D5, D4 }
+#define MATRIX_COL_PINS { F0, F1, F4, F5, F6, F7, B6, B5, B4, D7, D6, B0, B1, B2, B3, B7 }
+#define UNUSED_PINS
+
+/* COL2ROW, ROW2COL*/
+#define DIODE_DIRECTION ROW2COL
+
+/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed (5 is default) */
+#define DEBOUNCE 5
+
+/* The Model M has no diodes */
+#define MATRIX_HAS_GHOST
+
+/* Indicator LEDs */
+#define LED_CAPS_LOCK_PIN E6
+#define LED_PIN_ON_STATE 0
+
+/*
+ * Feature disable options
+ * These options are also useful to firmware size reduction.
+ */
+
+/* disable debug print */
+//#define NO_DEBUG
+
+/* disable print */
+//#define NO_PRINT
+
+/* disable action features */
+//#define NO_ACTION_LAYER
+//#define NO_ACTION_TAPPING
+//#define NO_ACTION_ONESHOT
diff --git a/keyboards/converter/modelm101_teensy2/info.json b/keyboards/converter/modelm101_teensy2/info.json
new file mode 100644
index 0000000000..1da0a88738
--- /dev/null
+++ b/keyboards/converter/modelm101_teensy2/info.json
@@ -0,0 +1,10 @@
+{
+ "keyboard_name": "IBM Model M 101 ANSI/102 ISO",
+ "url": "https://github.com/wangfuco/qmk_firmware/tree/modelm101_teensy2/keyboards/converter/modelm101_teensy2",
+ "maintainer": "wangfuco",
+ "layouts": {
+ "LAYOUT": {
+ "layout": [{"label":"Esc", "x":0, "y":0}, {"label":"F1", "x":2, "y":0}, {"label":"F2", "x":3, "y":0}, {"label":"F3", "x":4, "y":0}, {"label":"F4", "x":5, "y":0}, {"label":"F5", "x":6.5, "y":0}, {"label":"F6", "x":7.5, "y":0}, {"label":"F7", "x":8.5, "y":0}, {"label":"F8", "x":9.5, "y":0}, {"label":"F9", "x":11, "y":0}, {"label":"F10", "x":12, "y":0}, {"label":"F11", "x":13, "y":0}, {"label":"F12", "x":14, "y":0}, {"label":"PrtSc", "x":15.25, "y":0}, {"label":"Scroll Lock", "x":16.25, "y":0}, {"label":"Pause", "x":17.25, "y":0}, {"label":"~", "x":0, "y":1.5}, {"label":"!", "x":1, "y":1.5}, {"label":"@", "x":2, "y":1.5}, {"label":"#", "x":3, "y":1.5}, {"label":"$", "x":4, "y":1.5}, {"label":"%", "x":5, "y":1.5}, {"label":"^", "x":6, "y":1.5}, {"label":"&", "x":7, "y":1.5}, {"label":"*", "x":8, "y":1.5}, {"label":"(", "x":9, "y":1.5}, {"label":")", "x":10, "y":1.5}, {"label":"_", "x":11, "y":1.5}, {"label":"+", "x":12, "y":1.5}, {"label":"Backspace", "x":13, "y":1.5, "w":2}, {"label":"Insert", "x":15.25, "y":1.5}, {"label":"Home", "x":16.25, "y":1.5}, {"label":"PgUp", "x":17.25, "y":1.5}, {"label":"Num Lock", "x":18.5, "y":1.5}, {"label":"/", "x":19.5, "y":1.5}, {"label":"*", "x":20.5, "y":1.5}, {"label":"-", "x":21.5, "y":1.5}, {"label":"Tab", "x":0, "y":2.5, "w":1.5}, {"label":"Q", "x":1.5, "y":2.5}, {"label":"W", "x":2.5, "y":2.5}, {"label":"E", "x":3.5, "y":2.5}, {"label":"R", "x":4.5, "y":2.5}, {"label":"T", "x":5.5, "y":2.5}, {"label":"Y", "x":6.5, "y":2.5}, {"label":"U", "x":7.5, "y":2.5}, {"label":"I", "x":8.5, "y":2.5}, {"label":"O", "x":9.5, "y":2.5}, {"label":"P", "x":10.5, "y":2.5}, {"label":"{", "x":11.5, "y":2.5}, {"label":"}", "x":12.5, "y":2.5}, {"label":"|", "x":13.5, "y":2.5, "w":1.5}, {"label":"Delete", "x":15.25, "y":2.5}, {"label":"End", "x":16.25, "y":2.5}, {"label":"PgDn", "x":17.25, "y":2.5}, {"label":"7", "x":18.5, "y":2.5}, {"label":"8", "x":19.5, "y":2.5}, {"label":"9", "x":20.5, "y":2.5}, {"label":"+", "x":21.5, "y":2.5, "h":2}, {"label":"Caps Lock", "x":0, "y":3.5, "w":1.5}, {"label":"A", "x":1.75, "y":3.5}, {"label":"S", "x":2.75, "y":3.5}, {"label":"D", "x":3.75, "y":3.5}, {"label":"F", "x":4.75, "y":3.5}, {"label":"G", "x":5.75, "y":3.5}, {"label":"H", "x":6.75, "y":3.5}, {"label":"J", "x":7.75, "y":3.5}, {"label":"K", "x":8.75, "y":3.5}, {"label":"L", "x":9.75, "y":3.5}, {"label":":", "x":10.75, "y":3.5}, {"label":"\"", "x":11.75, "y":3.5}, {"label":"~", "x":12.75, "y":3.5}, {"label":"Enter", "x":13.75, "y":3.5, "w":1.25}, {"label":"4", "x":18.5, "y":3.5}, {"label":"5", "x":19.5, "y":3.5}, {"label":"6", "x":20.5, "y":3.5}, {"label":"Shift", "x":0, "y":4.5, "w":1.25}, {"label":"|", "x":1.25, "y":4.5}, {"label":"Z", "x":2.25, "y":4.5}, {"label":"X", "x":3.25, "y":4.5}, {"label":"C", "x":4.25, "y":4.5}, {"label":"V", "x":5.25, "y":4.5}, {"label":"B", "x":6.25, "y":4.5}, {"label":"N", "x":7.25, "y":4.5}, {"label":"M", "x":8.25, "y":4.5}, {"label":"<", "x":9.25, "y":4.5}, {"label":">", "x":10.25, "y":4.5}, {"label":"?", "x":11.25, "y":4.5}, {"label":"Shift", "x":12.25, "y":4.5, "w":2.75}, {"label":"\u2191", "x":16.25, "y":4.5}, {"label":"1", "x":18.5, "y":4.5}, {"label":"2", "x":19.5, "y":4.5}, {"label":"3", "x":20.5, "y":4.5}, {"label":"Enter", "x":21.5, "y":4.5, "h":2}, {"label":"Ctrl", "x":0, "y":5.5, "w":1.5}, {"label":"Alt", "x":2.5, "y":5.5, "w":1.5}, {"x":4, "y":5.5, "w":7}, {"label":"Alt", "x":11, "y":5.5, "w":1.5}, {"label":"Ctrl", "x":13.5, "y":5.5, "w":1.5}, {"label":"\u2190", "x":15.25, "y":5.5}, {"label":"\u2193", "x":16.25, "y":5.5}, {"label":"\u2192", "x":17.25, "y":5.5}, {"label":"0", "x":18.5, "y":5.5, "w":2}, {"label":".", "x":20.5, "y":5.5}]
+ }
+ }
+}
diff --git a/keyboards/converter/modelm101_teensy2/keymaps/default/keymap.c b/keyboards/converter/modelm101_teensy2/keymaps/default/keymap.c
new file mode 100644
index 0000000000..3f01f2c65c
--- /dev/null
+++ b/keyboards/converter/modelm101_teensy2/keymaps/default/keymap.c
@@ -0,0 +1,27 @@
+/* Copyright 2019 iw0rm3r
+ *
+ * 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
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+ [0] = LAYOUT( /* Base layer */
+ 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
+ ),
+};
diff --git a/keyboards/converter/modelm101_teensy2/keymaps/default/readme.md b/keyboards/converter/modelm101_teensy2/keymaps/default/readme.md
new file mode 100644
index 0000000000..fb91a8ebe5
--- /dev/null
+++ b/keyboards/converter/modelm101_teensy2/keymaps/default/readme.md
@@ -0,0 +1 @@
+# The default keymap for modelm101
\ No newline at end of file
diff --git a/keyboards/converter/modelm101_teensy2/modelm101_teensy2.c b/keyboards/converter/modelm101_teensy2/modelm101_teensy2.c
new file mode 100644
index 0000000000..8283d91eda
--- /dev/null
+++ b/keyboards/converter/modelm101_teensy2/modelm101_teensy2.c
@@ -0,0 +1,16 @@
+/* Copyright 2019 iw0rm3r
+ *
+ * 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 "modelm101_teensy2.h"
diff --git a/keyboards/converter/modelm101_teensy2/modelm101_teensy2.h b/keyboards/converter/modelm101_teensy2/modelm101_teensy2.h
new file mode 100644
index 0000000000..1a2cdc8b68
--- /dev/null
+++ b/keyboards/converter/modelm101_teensy2/modelm101_teensy2.h
@@ -0,0 +1,45 @@
+/* Copyright 2019 iw0rm3r
+ *
+ * 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 "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). */
+
+#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 \
+) \
+{ \
+/* 00 */ { KC_NO, KC_NO, K5A, K1B, K5E, K2F, K5F, K2G, K5G, KC_NO, K2L, KC_NO, K0I, K0J, K1N, K0B }, \
+/* 01 */ { KC_NO, K1A, K3A, K2A, K5D, K3F, K4N, K3G, K3M, K5H, K3L, K2O, K2P, K2Q, KC_NO, KC_NO }, \
+/* 02 */ { K0A, KC_NO, K4A, K5B, K5C, K4F, K5J, K4G, K4M, K5I, K4L, K3O, K4O, K4Q, K4P, KC_NO }, \
+/* 03 */ { KC_NO, KC_NO, K4B, K4C, K4D, K4E, K5K, K4H, K4I, K4J, K4K, K5L, K5M, K3Q, K3P, K5N }, \
+/* 04 */ { KC_NO, KC_NO, K3B, K3C, K3D, K3E, KC_NO, K3H, K3I, K3J, K3K, K3R, K3S, K3T, K3U, K5O }, \
+/* 05 */ { KC_NO, KC_NO, K2B, K2C, K2D, K2E, K3N, K2H, K2I, K2J, K2K, K1O, K1P, K1Q, K1R, KC_NO }, \
+/* 06 */ { K0E, K1M, K1C, K1D, K1E, K1F, K2N, K1I, K1J, K1K, K2M, K4R, K4S, K4T, K5P, KC_NO }, \
+/* 07 */ { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, K1G, K0C, K1H, KC_NO, KC_NO, K1L, K0G, K0H, K4U, K0F, K0D }, \
+}
+/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
\ No newline at end of file
diff --git a/keyboards/converter/modelm101_teensy2/readme.md b/keyboards/converter/modelm101_teensy2/readme.md
new file mode 100644
index 0000000000..d65df72580
--- /dev/null
+++ b/keyboards/converter/modelm101_teensy2/readme.md
@@ -0,0 +1,29 @@
+# modelm101_teensy2
+
+![IBM Model M 101 ANSI/102 ISO](https://user-images.githubusercontent.com/46733695/161862805-c891735b-e2e8-418a-ad82-d71c00570eab.jpg)
+
+This is based on the modelm101 keyboard by iw0rm3r. The difference is that Teensy 2.0 board (produced by PJRC) is used instead of the Teensy 2.0++ due to the availability issues. Only CapsLock LED is supported since Teensy 2.0 only has 25 digital I/0 pins.
+
+Configuration is build for the Atmel ATmega32U4 controller, which you can easily use on the Teensy 2.0 board (produced by PJRC).
+
+Pins of the Teensy board you should use by default:
+```
+Columns: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+Pins: F0 F1 F4 F5 F6 F7 B6 B5 B4 D7 D6 B0 B1 B2 B3 B7
+--------------------------------------------------------
+Rows: 1 2 3 4 5 6 7 8
+Pins: D0 D1 D2 D3 C6 C7 D5 D4
+--------------------------------------------------------
+Status LEDs: CapsLock +5V ScrollLock NumLock
+Pins: E6 5V - -
+```
+
+Keyboard Maintainer: [wangfuco](https://github.com/wangfuco)
+Hardware Supported: Teensy 2.0 board by PJRC
+Hardware Availability: https://www.pjrc.com/store/teensy.html
+
+Make example for this keyboard (after setting up your build environment):
+
+ make converter/modelm101_teensy2:default:teensy
+
+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/converter/modelm101_teensy2/rules.mk b/keyboards/converter/modelm101_teensy2/rules.mk
new file mode 100644
index 0000000000..c1c611e577
--- /dev/null
+++ b/keyboards/converter/modelm101_teensy2/rules.mk
@@ -0,0 +1,18 @@
+# MCU name
+MCU = atmega32u4
+
+# Bootloader selection
+BOOTLOADER = halfkay
+
+# Build Options
+# change yes to no to disable
+#
+BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite
+MOUSEKEY_ENABLE = no # Mouse keys
+EXTRAKEY_ENABLE = yes # Audio control and System control
+CONSOLE_ENABLE = no # Console for debug
+COMMAND_ENABLE = no # 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