]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Keyboard: 5291 firmware to replace the existing soarers controller firmware (#4483)
authorlistofoptions <39714365+listofoptions@users.noreply.github.com>
Mon, 26 Nov 2018 17:53:49 +0000 (12:53 -0500)
committerDrashna Jaelre <drashna@live.com>
Mon, 26 Nov 2018 17:53:49 +0000 (09:53 -0800)
* compiles but is not working

* still testing 5291

* compiles but is not working

* still testing 5291

* fixed a but in the layout (reversed key order in row)

* compiles but is not working

* still testing 5291

* fixed a but in the layout (reversed key order in row)

* fixed some issues

* doumentation needed

* doumentation needed

* documentation needed

* documentation needed

* Update readme.md

documentation

* Update readme.md

i dislike markdown <_>

* merge preperation

keyboards/converter/ibm_5291/config.h [new file with mode: 0644]
keyboards/converter/ibm_5291/ibm_5291.c [new file with mode: 0644]
keyboards/converter/ibm_5291/ibm_5291.h [new file with mode: 0644]
keyboards/converter/ibm_5291/info.json [new file with mode: 0644]
keyboards/converter/ibm_5291/keymaps/default/keymap.c [new file with mode: 0644]
keyboards/converter/ibm_5291/keymaps/kbdbabel_doc_ibm5291_kbd.pdf [new file with mode: 0644]
keyboards/converter/ibm_5291/matrix.c [new file with mode: 0644]
keyboards/converter/ibm_5291/matrix.csv [new file with mode: 0644]
keyboards/converter/ibm_5291/readme.md [new file with mode: 0644]
keyboards/converter/ibm_5291/rules.mk [new file with mode: 0644]

diff --git a/keyboards/converter/ibm_5291/config.h b/keyboards/converter/ibm_5291/config.h
new file mode 100644 (file)
index 0000000..5c9ca1e
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+Copyright 2018 listofoptions <listofoptions@gmail.com>
+
+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
+
+#include "config_common.h"
+
+#define VENDOR_ID           0xFEED
+#define PRODUCT_ID          0x6060
+#define DEVICE_VER          1
+#define MANUFACTURER        QMK
+#define PRODUCT             5291 keyboard converter
+#define DESCRIPTION         5291 keyboard converter
+
+#define MATRIX_ROWS         24
+#define MATRIX_COLS         4
+
+#define MATRIX_ROW_PINS   {B2, B3, B4, B5, B6}
+#define MATRIX_COL_PINS   {B0, B1}
+#define MATRIX_DATA_PIN   D0
+#define MATRIX_STROBE_PIN D1
+#define LED_PIN           D6
+
+
+/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
+#define DEBOUNCING_DELAY    0
+
+
diff --git a/keyboards/converter/ibm_5291/ibm_5291.c b/keyboards/converter/ibm_5291/ibm_5291.c
new file mode 100644 (file)
index 0000000..9b937a5
--- /dev/null
@@ -0,0 +1,3 @@
+#include "ibm_5291.h"
+#include <avr/io.h>
+#include "quantum.h"
\ No newline at end of file
diff --git a/keyboards/converter/ibm_5291/ibm_5291.h b/keyboards/converter/ibm_5291/ibm_5291.h
new file mode 100644 (file)
index 0000000..aa1b403
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+Copyright 2018 listofoptions <listofoptions@gmail.com>
+
+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
+
+#include "quantum.h"
+
+/*
+ * ,-------.  ,--------------------------------------------------------------------------.
+ * | F1| F2|  |Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|  BS  |NumLck |ScrLck |
+ * |-------|  |--------------------------------------------------------------------------|
+ * | F3| F4|  | Tab |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ] |   |  7|  8|  9|  -|
+ * |-------|  |------------------------------------------------------|Ent|---------------|
+ * | F5| F6|  | Ctrl |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|  `|   |  4|  5|  6|   |
+ * |-------|  |----------------------------------------------------------------------|   |
+ * | F7| F8|  |Shif|  \|  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shift|PrS|  1|  2|  3|  +|
+ * |-------|  |----------------------------------------------------------------------|   |
+ * | F9|F10|  |  Alt  |               Space                  |CapsLck|   0   |   .   |   |
+ * `-------'  `--------------------------------------------------------------------------'
+*/
+
+#define LAYOUT_5291( \
+    KEY_F1,KEY_F2,  KEY_ESC, KEY_1,   KEY_2,KEY_3,KEY_4,KEY_5,KEY_6,KEY_7,KEY_8,KEY_9,   KEY_0,   KEY_MIN, KEY_EQU,  KEY_BACK,         KEY_NLOCK,         KEY_SLOCK, \
+    KEY_F3,KEY_F4,  KEY_TAB, KEY_Q,   KEY_W,KEY_E,KEY_R,KEY_T,KEY_Y,KEY_U,KEY_I,KEY_O,   KEY_P,   KEY_LBRC,KEY_RBRC,          KEY_PAD7,KEY_PAD8, KEY_PAD9,KEY_PMIN,  \
+    KEY_F5,KEY_F6,  KEY_LCTR,KEY_A,   KEY_S,KEY_D,KEY_F,KEY_G,KEY_H,KEY_J,KEY_K,KEY_L,   KEY_SEMI,KEY_QUOT,KEY_TICK, KEY_ENTR,KEY_PAD4,KEY_PAD5, KEY_PAD6,           \
+    KEY_F7,KEY_F8,  KEY_LSFS,KEY_BSLS,KEY_Z,KEY_X,KEY_C,KEY_V,KEY_B,KEY_N,KEY_M,KEY_COMM,KEY_DOT, KEY_SLS,KEY_RSFS, KEY_PAST,KEY_PAD1,KEY_PAD2, KEY_PAD3,KEY_PPLS,  \
+    KEY_F9,KEY_F10, KEY_LALT,                              KEY_SPACE,                                     KEY_CLOCK,         KEY_PAD0,          KEY_PDOT            \
+) \
+{ {KEY_Z,     KEY_S,   KEY_W,   KEY_3     }\
+, {KEY_X,     KEY_D,   KEY_E,   KEY_4     }\
+, {KEY_C,     KEY_F,   KEY_R,   KEY_5     }\
+, {KEY_V,     KEY_G,   KEY_T,   KEY_6     }\
+, {KEY_B,     KEY_H,   KEY_Y,   KEY_7     }\
+, {KEY_N,     KEY_J,   KEY_U,   KEY_8     }\
+, {KEY_PAD2,  KEY_PAD5,KEY_PAD8,KEY_NLOCK }\
+, {KEY_M,     KEY_K,   KEY_I,   KEY_9     }\
+, {KEY_COMM,  KEY_L,   KEY_O,   KEY_0     }\
+, {KEY_DOT,   KEY_SEMI,KEY_P,   KEY_MIN   }\
+, {KEY_SLS,   KEY_QUOT,KEY_LBRC,KEY_EQU   }\
+, {KEY_SPACE, KEY_RSFS,KEY_TICK,KEY_RBRC  }\
+, {KEY_CLOCK, KEY_PAST,KEY_ENTR,KEY_BACK  }\
+, {KEY_PAD0,  KEY_PAD1,KEY_PAD4,KEY_PAD7  }\
+, {KEY_PPLS,  KC_NO,   KEY_PMIN,KEY_SLOCK }\
+, {KEY_PDOT,  KEY_PAD3,KEY_PAD6,KEY_PAD9  }\
+, {KEY_BSLS,  KEY_A,   KEY_Q,   KEY_2     }\
+, {KEY_LALT,  KC_NO,   KC_NO,   KEY_1     }\
+, {KEY_F7,    KEY_F5,  KEY_F3,  KEY_F1    }\
+, {KEY_F8,    KEY_F6,  KEY_F4,  KEY_F2    }\
+, {KC_F10,    KC_NO,   KC_NO,   KC_NO     }\
+, {KC_F9,     KC_NO,   KC_NO,   KC_NO     }\
+, {KEY_LSFS,  KEY_LCTR,KEY_TAB, KEY_ESC   }\
+, {KC_NO,     KC_NO,   KC_NO,   KC_NO     }\
+}
+
+#define LAYOUT LAYOUT_5291
\ No newline at end of file
diff --git a/keyboards/converter/ibm_5291/info.json b/keyboards/converter/ibm_5291/info.json
new file mode 100644 (file)
index 0000000..080a163
--- /dev/null
@@ -0,0 +1,6 @@
+{
+  "keyboard_name": "IBM 5291",
+  "keyboard_folder": "converter/5291",
+  "url": "https://deskthority.net/wiki/IBM_Model_F#IBM_5291_Keyboard",
+  "maintainer": "listofoptions",
+}
diff --git a/keyboards/converter/ibm_5291/keymaps/default/keymap.c b/keyboards/converter/ibm_5291/keymaps/default/keymap.c
new file mode 100644 (file)
index 0000000..9b286c8
--- /dev/null
@@ -0,0 +1,233 @@
+/*
+Copyright 2018 listofoptions <listofoptions@gmail.com>
+
+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 xt_keycodes
+    { XT_PAST = SAFE_RANGE // XT pad asterisk / print screen
+    , XT_SLCK              // XT scroll lock / break
+    , XT_F6                // F6 / app key
+    , XT_F5                // F5 / gui
+    , XT_F9                // F9 / F11
+    , XT_F10               // F10 / F12
+    } ;
+    
+static bool shift_pressed   = false ,
+            alt_pressed     = false ,
+            ctrl_pressed    = false ,
+            xt_pscr_pressed = false ,
+            xt_brk_pressed  = false ,
+            xt_app_pressed  = false ,
+            xt_gui_pressed  = false ,
+            xt_lout_pressed = false ,
+            xt_f11_pressed  = false ,
+            xt_f12_pressed  = false ;
+
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+  switch (keycode) {
+    case KC_LSFT:
+    case KC_RSFT:
+        if (record->event.pressed) {
+            shift_pressed = true ;
+        } else {
+            shift_pressed = false ;
+        }
+        return true;
+        break;
+        
+    case KC_LALT:
+        if (record->event.pressed) {
+            alt_pressed = true ;
+        } else {
+            alt_pressed = false ;
+        }
+        return true;
+        break;
+        
+    case KC_LCTL:
+        if (record->event.pressed) {
+            ctrl_pressed = true ;
+        } else {
+            ctrl_pressed = false ;
+        }
+        return true;
+        break;
+    
+    case XT_PAST:
+        if (record->event.pressed) {
+            if (shift_pressed) {
+                xt_pscr_pressed = true ;
+                register_code(KC_PSCR);
+            } else {
+                register_code(KC_PAST);
+            }
+        } else {
+            if (xt_pscr_pressed) {
+                xt_pscr_pressed = false ;
+                unregister_code(KC_PSCR);
+            } else {
+                unregister_code(KC_PAST);
+            }
+        }
+        return false;
+        break;
+      
+    case XT_SLCK:
+        if (record->event.pressed) {
+            if (ctrl_pressed) {
+                xt_brk_pressed  = true ;
+                register_code(KC_BRK);
+            } else {
+                register_code(KC_SLCK);
+            }
+        } else {
+            if (xt_brk_pressed) {
+                xt_brk_pressed  = false ;
+                unregister_code(KC_BRK);
+            } else {
+                unregister_code(KC_SLCK);
+            }
+        }
+        return false;
+        break;
+    
+    case XT_F6:
+        if (record->event.pressed) {
+            if (shift_pressed) {
+                xt_app_pressed = true ;
+                register_code(KC_APP);
+            } else {
+                register_code(KC_F6);
+            }
+        } else {
+            if (xt_app_pressed) {
+                xt_app_pressed = false ;
+                unregister_code(KC_APP);
+            } else {
+                unregister_code(KC_F6);
+            }
+        }
+        return false;
+        break;
+    
+    case XT_F5:
+        if (record->event.pressed) {
+            if (shift_pressed) {
+                xt_gui_pressed = true ;
+                register_code(KC_LGUI);
+            } else if (ctrl_pressed) {
+                xt_lout_pressed = true ;
+                register_code (KC_LGUI) ;
+                register_code (KC_L)    ;
+            } else {
+                register_code(KC_F5);
+            }
+        } else {
+            if (xt_gui_pressed) {
+                xt_gui_pressed = false ;
+                unregister_code(KC_LGUI);
+            } else if (xt_lout_pressed) {
+                xt_lout_pressed = false ;
+                unregister_code (KC_LGUI) ;
+                unregister_code (KC_L)    ;
+            } else {
+                unregister_code(KC_F5);
+            }
+        }
+        return false;
+        break;
+    
+    case XT_F9:
+        if (record->event.pressed) {
+            if (shift_pressed) {
+                xt_f11_pressed = true ;
+                register_code(KC_F11);
+            } else {
+                register_code(KC_F9);
+            }
+        } else {
+            if (xt_f11_pressed) {
+                xt_f11_pressed = false ;
+                unregister_code(KC_F11);
+            } else {
+                unregister_code(KC_F9);
+            }
+        }
+        return false;
+        break;
+    
+    case XT_F10:
+        if (record->event.pressed) {
+            if (shift_pressed) {
+                xt_f12_pressed = true ;
+                register_code(KC_F12);
+            } else {
+                register_code(KC_F10);
+            }
+        } else {
+            if (xt_f12_pressed) {
+                xt_f12_pressed = false ;
+                unregister_code(KC_F12);
+            } else {
+                unregister_code(KC_F10);
+            }
+        }
+        return false;
+        break;
+    
+    default:
+        return true;
+        break;
+  }
+  
+  return true;
+}
+*/
+    
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+// default layout is the standard XT layout
+/*
+ * ,-------.  ,--------------------------------------------------------------------------.
+ * | F1| F2|  |Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|  BS  |NumLck |ScrLck |
+ * |-------|  |--------------------------------------------------------------------------|
+ * | F3| F4|  | Tab |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ] |   |  7|  8|  9|  -|
+ * |-------|  |------------------------------------------------------|Ent|---------------|
+ * | F5| F6|  | Ctrl |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|  `|   |  4|  5|  6|   |
+ * |-------|  |----------------------------------------------------------------------|   |
+ * | F7| F8|  |Shif|  \|  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shift|  *|  1|  2|  3|  +|
+ * |-------|  |----------------------------------------------------------------------|   |
+ * | F9|F10|  |  Alt  |               Space                  |CapsLck|   0   |   .   |   |
+ * `-------'  `--------------------------------------------------------------------------'
+*/
+/*
+    [0] = LAYOUT (
+        KC_F1,KC_F2, KC_ESC, 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_NLCK,       XT_SLCK,
+        KC_F3,KC_F4, 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_P7,KC_P8,  KC_P9, KC_PMNS, 
+        XT_F5,XT_F6, KC_LCTL,KC_A,   KC_S,KC_D,KC_F,KC_G,KC_H,KC_J,KC_K,KC_L,   KC_SCLN,KC_QUOT,KC_GRV, KC_ENT, KC_P4,KC_P5,  KC_P6,           
+        KC_F7,KC_F8, KC_LSFT,KC_BSLS,KC_Z,KC_X,KC_C,KC_V,KC_B,KC_N,KC_M,KC_COMM,KC_DOT, KC_SLSH,KC_RSFT,XT_PAST,KC_P1,KC_P2,  KC_P3, KC_PPLS, 
+        XT_F9,XT_F10,KC_LALT,                              KC_SPACE,                                    KC_CAPS,      KC_P0,  KC_PDOT           
+    )
+*/
+    [0] = LAYOUT (
+        KC_F1,KC_F2, KC_ESC, 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_NLCK,       KC_SLCK,
+        KC_F3,KC_F4, 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_P7,KC_P8,  KC_P9, KC_PMNS, 
+        KC_F5,KC_F6, KC_LCTL,KC_A,   KC_S,KC_D,KC_F,KC_G,KC_H,KC_J,KC_K,KC_L,   KC_SCLN,KC_QUOT,KC_GRV, KC_ENT, KC_P4,KC_P5,  KC_P6,           
+        KC_F7,KC_F8, KC_LSFT,KC_BSLS,KC_Z,KC_X,KC_C,KC_V,KC_B,KC_N,KC_M,KC_COMM,KC_DOT, KC_SLSH,KC_RSFT,KC_PAST,KC_P1,KC_P2,  KC_P3, KC_PPLS, 
+        KC_F9,KC_F10,KC_LALT,                              KC_SPACE,                                    KC_CAPS,      KC_P0,  KC_PDOT           
+    )
+} ;
+
diff --git a/keyboards/converter/ibm_5291/keymaps/kbdbabel_doc_ibm5291_kbd.pdf b/keyboards/converter/ibm_5291/keymaps/kbdbabel_doc_ibm5291_kbd.pdf
new file mode 100644 (file)
index 0000000..3560598
Binary files /dev/null and b/keyboards/converter/ibm_5291/keymaps/kbdbabel_doc_ibm5291_kbd.pdf differ
diff --git a/keyboards/converter/ibm_5291/matrix.c b/keyboards/converter/ibm_5291/matrix.c
new file mode 100644 (file)
index 0000000..58f6e37
--- /dev/null
@@ -0,0 +1,284 @@
+/*
+Copyright 2018 listofoptions <listofoptions@gmail.com>
+
+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 <string.h>
+#if defined(__AVR__)
+#include <avr/io.h>
+#endif
+#include <util/delay.h>
+
+#include "wait.h"
+#include "print.h"
+#include "debug.h"
+#include "util.h"
+#include "matrix.h"
+#include "timer.h"
+
+#include "config.h"
+
+
+#ifndef DEBOUNCING_DELAY
+#   define DEBOUNCING_DELAY 5
+#endif
+
+#define print_matrix_header()      print("\nr/c 01234567\n")
+#define print_matrix_row(row)      print_bin_reverse8(matrix_get_row(row))
+#define matrix_bitpop(i)           bitpop(matrix[i])
+#define ROW_SHIFTER                ((uint8_t)1)
+#define check_bit(var,pos)         ((var) & (1<<(pos)))
+
+#define NUM_ROW_PINS 5
+#define NUM_COL_PINS 2
+
+static const uint8_t row_pins [NUM_ROW_PINS] = MATRIX_ROW_PINS ;
+static const uint8_t col_pins [NUM_ROW_PINS] = MATRIX_COL_PINS ;
+
+#if ( DEBOUNCING_DELAY > 0 )
+static uint16_t debouncing_time         ;
+static bool     debouncing      = false ;
+#endif
+
+static uint8_t matrix          [MATRIX_ROWS] = {0};
+
+#if ( DEBOUNCING_DELAY > 0 )
+static uint8_t matrix_debounce [MATRIX_ROWS] = {0};
+#endif 
+
+static
+inline
+void toggle_led(void) {
+    uint8_t pin = LED_PIN ;
+    _SFR_IO8((pin >> 4) + 2) ^= _BV(pin & 0xF);
+}
+
+static
+inline
+void init_led(void) {
+    uint8_t pin = LED_PIN ;
+    _SFR_IO8((pin >> 4) + 1) |= _BV(pin & 0xF);  // OUT
+    _SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF); // LOW
+}
+
+static
+inline
+void init_data(void) {
+    uint8_t pin = MATRIX_DATA_PIN ;
+    _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN
+    _SFR_IO8((pin >> 4) + 2) |=  _BV(pin & 0xF); // LO
+}
+
+static
+inline
+void init_strobe(void) {
+    uint8_t pin = MATRIX_STROBE_PIN ;
+    _SFR_IO8((pin >> 4) + 1) |= _BV(pin & 0xF);  // OUT
+    _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF);  // HI
+}
+
+static
+inline
+void init_rows(void) {
+    for ( uint8_t i = 0 ; i < NUM_ROW_PINS; ++i ) {
+        uint8_t pin = row_pins[i];
+        _SFR_IO8((pin >> 4) + 1) |=  _BV(pin & 0xF); // OUT
+        _SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF); // LOW
+    }
+}
+
+static
+inline
+void init_cols(void) {
+    for ( uint8_t i = 0 ; i < NUM_COL_PINS; ++i ) {
+        uint8_t pin = col_pins[i];
+        _SFR_IO8((pin >> 4) + 1) |=  _BV(pin & 0xF); // OUT
+        _SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF); // LOW
+    }
+}
+
+static
+inline
+void select_row(uint8_t current_row) {
+    for ( uint8_t i = 0 ; i < NUM_ROW_PINS; ++i ) {
+        uint8_t pin = row_pins[i] ;
+        if ( check_bit( current_row, i ) ) {
+            _SFR_IO8((pin >> 4) + 2) |=  _BV(pin & 0xF); // HI
+        } else {
+            _SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF); // LOW
+        }
+    }
+    wait_us(30) ;
+}
+
+static
+inline
+void select_col(uint8_t current_col) {
+    for ( uint8_t i = 0 ; i < NUM_COL_PINS; ++i ) {
+        uint8_t pin = col_pins[i] ;
+        if ( check_bit( current_col, i ) ) {
+            _SFR_IO8((pin >> 4) + 2) |=  _BV(pin & 0xF); // HI
+        } else {
+            _SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF); // LOW
+        }
+    }
+    wait_us(30) ;
+}
+
+static
+inline
+uint8_t matrix_strobe(uint8_t col_index) {
+    uint8_t strobe_pin = MATRIX_STROBE_PIN ;
+    uint8_t data_pin   = MATRIX_DATA_PIN   ;
+    
+    // set strobe pin low
+    _SFR_IO8((strobe_pin >> 4) + 2) &=  ~_BV(strobe_pin & 0xF);
+    
+    wait_us(30) ;
+    
+    // read data 
+    uint8_t data = (_SFR_IO8(data_pin >> 4) & _BV(data_pin & 0xF)) ;
+    
+    // set strobe pin hi
+    _SFR_IO8((strobe_pin >> 4) + 2) |= _BV(strobe_pin & 0xF);
+    
+    uint8_t out = data ? (1 << col_index) : 0 ;
+    return out ;
+}
+
+static
+bool matrix_read(uint8_t current_matrix[], uint8_t current_row) {
+    // Store last value of row prior to reading
+    uint8_t last_row_value = current_matrix[current_row];
+
+    // Clear data in matrix row
+    current_matrix[current_row] = 0;
+
+    select_row(current_row);
+
+    // For each col...
+    for(uint8_t col_index = 0; col_index < MATRIX_COLS; ++col_index) {
+
+        select_col(col_index) ;
+        
+        // strobe the matrix
+        // Populate the matrix row with the state of the data pin
+        current_matrix[current_row] |= matrix_strobe(col_index) ;
+    }
+
+    bool test = last_row_value != current_matrix[current_row] ;
+    return test ;
+}
+
+__attribute__ ((weak))
+void matrix_init_quantum(void) {
+    matrix_init_kb();
+}
+
+__attribute__ ((weak))
+void matrix_scan_quantum(void) {
+    matrix_scan_kb();
+}
+
+__attribute__ ((weak))
+void matrix_init_kb(void) {    
+    matrix_init_user();
+}
+
+__attribute__ ((weak))
+void matrix_scan_kb(void) {
+    matrix_scan_user();
+}
+
+__attribute__ ((weak))
+void matrix_init_user(void) {
+}
+
+__attribute__ ((weak))
+void matrix_scan_user(void) {
+}
+
+inline
+uint8_t matrix_rows(void) {
+    return MATRIX_ROWS;
+}
+
+inline
+uint8_t matrix_cols(void) {
+    return MATRIX_COLS;
+}
+
+inline
+uint8_t matrix_get_row(uint8_t row) {
+    return matrix[row];
+}
+
+void matrix_init(void) {
+    init_led()    ;   
+    init_rows()   ;
+    init_cols()   ;
+    init_data()   ;
+    init_strobe() ;
+    
+    // initialize matrix state: all keys off
+    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
+        matrix[i]            = 0;
+#       if (DEBOUNCING_DELAY > 0)
+        matrix_debounce  [i] = 0;
+#       endif
+    }
+
+    matrix_init_quantum() ;
+}
+
+uint8_t matrix_scan(void) { 
+    for ( uint8_t current_row = 0; current_row < MATRIX_ROWS; ++current_row ) {
+#       if (DEBOUNCING_DELAY > 0)
+            bool matrix_changed = matrix_read(matrix_debounce, current_row);
+            
+            if (matrix_changed) {
+                debouncing      = true        ;
+                debouncing_time = timer_read();
+            }
+                        
+#       else
+            matrix_read(matrix, current_row);
+#       endif
+    }
+    
+#   if (DEBOUNCING_DELAY > 0)
+        if (debouncing && (timer_elapsed(debouncing_time) > DEBOUNCING_DELAY)) {
+            for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
+                matrix[i] = matrix_debounce[i];
+            }
+            debouncing = false;
+        }
+#   endif
+
+    matrix_scan_quantum();
+    return 1;
+}
+
+void matrix_print(void) {
+    print_matrix_header();
+
+    for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
+        phex(row); print(": ");
+        print_matrix_row(row);
+        print("\n");
+    }
+}
diff --git a/keyboards/converter/ibm_5291/matrix.csv b/keyboards/converter/ibm_5291/matrix.csv
new file mode 100644 (file)
index 0000000..40462c2
--- /dev/null
@@ -0,0 +1,96 @@
+0,Z
+1,S
+2,W
+3,3
+4,X
+5,D
+6,E
+7,4
+8,C
+9,F
+10,R
+11,5
+12,V
+13,G
+14,T
+15,6
+16,B
+17,H
+18,Y
+19,7
+20,N
+21,J
+22,U
+23,8
+24,PAD_2
+25,PAD_5
+26,PAD_8
+27,NUM_LOCK
+28,M
+29,K
+30,I
+31,9
+32,COMMA
+33,L
+34,O
+35,0
+36,PERIOD
+37,SEMICOLON
+38,P
+39,MINUS
+40,SLASH
+41,QUOTE
+42,LEFT_BRACE
+43,EQUAL
+44,SPACE
+45,RSHIFT
+46,BACK_QUOTE
+47,RIGHT_BRACE
+48,CAPS_LOCK
+49,PAD_ASTERIX
+50,ENTER
+51,BACKSPACE
+52,PAD_0
+53,PAD_1
+54,PAD_4
+55,PAD_7
+56,PAD_PLUS
+57,UNASSIGNED
+58,PAD_MINUS
+59,SCROLL_LOCK
+60,PAD_PERIOD
+61,PAD_3
+62,PAD_6
+63,PAD_9
+64,BACKSLASH
+65,A
+66,Q
+67,2
+68,LALT
+69,UNASSIGNED
+70,UNASSIGNED
+71,1
+72,F7
+73,F5
+74,F3
+75,F1
+76,F8
+77,F6
+78,F4
+79,F2
+80,F10
+81,UNASSIGNED
+82,UNASSIGNED
+83,UNASSIGNED
+84,F9
+85,UNASSIGNED
+86,UNASSIGNED
+87,UNASSIGNED
+88,LSHIFT
+89,LCTRL
+90,TAB
+91,ESC
+92,UNASSIGNED
+93,UNASSIGNED
+94,UNASSIGNED
+95,UNASSIGNED
diff --git a/keyboards/converter/ibm_5291/readme.md b/keyboards/converter/ibm_5291/readme.md
new file mode 100644 (file)
index 0000000..06ae2e9
--- /dev/null
@@ -0,0 +1,70 @@
+# IBM 5291 keyboard converter
+
+![5291](https://deskthority.net/wiki/IBM_Model_F#IBM_5291_Keyboard)
+
+A converter for the eponymous keyboard.
+
+Keyboard Maintainer: [Listofoptions](https://github.com/listofoptions)  
+Hardware Supported: IBM 5291, Teensy 2.0  
+
+Make example for this keyboard (after setting up your build environment):
+
+    make converter/ibm_5291:default
+    
+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).
+
+
+the pinout is as follows:
+
+IBM−5291−Cable to Pinhead−14 
+
+| pin | description
+----|------------------------
+1 | GND   
+2 | NC    
+3 | GND   
+4 | GN)   
+5 | +5V   
+6 | D0    
+7 | D1    
+8 | D2    
+9 | D3    
+10| D4    
+11| D5    
+12| D6    
+13| Strobe
+14| Out   
+
+the pins on this connector are organized ![here](https://geekhack.org/index.php?action=dlattach;topic=48950.0;attach=36759;image)
+
+IBM−5291−2 Cable with DB15M connector
+
+| pin | description
+----|-------------
+|1,2,3 | GND
+|4     | +5V
+|5     | D0
+|6     | D1
+|7     | D2
+|8     | D3
+|9     | D4
+|10    | D5
+|11    | D6
+|12    | Strobe
+|13    | Out
+|14    | PE 
+|15    | NC
+
+the above connector is actually numbered so it should be easier to determine
+where the needed connections are.
+
+to connect to the teensy, the following are pins are needed (if you should choose not set your own):
+* PB0 -> PB6 are connected to D0 -> D6
+* +5V is connected to the corresponding teensy pin
+* gnd is as well, only one of the gnd pins needs to be connected though.
+* strobe is connected to pin PD1
+* data is connected to PD0
+* PE does not need to be connected to anything, but it could also be connected to gnd 
+
+sources:
+    http://www.retrocomputing.eu/documents/5291_MaintenanceLibrary.pdf
diff --git a/keyboards/converter/ibm_5291/rules.mk b/keyboards/converter/ibm_5291/rules.mk
new file mode 100644 (file)
index 0000000..ca0c850
--- /dev/null
@@ -0,0 +1,72 @@
+# MCU name
+#MCU = at90usb1287
+MCU = atmega32u4
+
+# Processor frequency.
+#     This will define a symbol, F_CPU, in all source code files equal to the
+#     processor frequency in Hz. You can then use this symbol in your source code to
+#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
+#     automatically to create a 32-bit value in your source code.
+#
+#     This will be an integer division of F_USB below, as it is sourced by
+#     F_USB after it has run through any CPU prescalers. Note that this value
+#     does not *change* the processor frequency - it should merely be updated to
+#     reflect the processor speed set externally so that the code can use accurate
+#     software delays.
+F_CPU = 16000000
+
+#
+# LUFA specific
+#
+# Target architecture (see library "Board Types" documentation).
+ARCH = AVR8
+
+# Input clock frequency.
+#     This will define a symbol, F_USB, in all source code files equal to the
+#     input clock frequency (before any prescaling is performed) in Hz. This value may
+#     differ from F_CPU if prescaling is used on the latter, and is required as the
+#     raw input clock is fed directly to the PLL sections of the AVR for high speed
+#     clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+#     at the end, this will be done automatically to create a 32-bit value in your
+#     source code.
+#
+#     If no clock division is performed on the input clock inside the AVR (via the
+#     CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_USB = $(F_CPU)
+
+# Interrupt driven control endpoint task(+60)
+OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
+
+# Bootloader
+#     This definition is optional, and if your keyboard supports multiple bootloaders of
+#     different sizes, comment this out, and the correct address will be loaded 
+#     automatically (+60). See bootloader.mk for all options.
+BOOTLOADER = halfkay
+
+# Build Options
+#   change to "no" to disable the options, or define them in the Makefile in
+#   the appropriate keymap folder that will get included automatically
+#
+BOOTMAGIC_ENABLE = no       # Virtual DIP switch configuration(+1000)
+MOUSEKEY_ENABLE = no        # Mouse keys(+4700)
+EXTRAKEY_ENABLE = no        # Audio control and System control(+450)
+CONSOLE_ENABLE = no         # Console for debug(+400)
+COMMAND_ENABLE = no         # Commands for debug and configuration
+NKRO_ENABLE = yes           # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
+BACKLIGHT_ENABLE = no       # Enable keyboard backlight functionality
+MIDI_ENABLE = no            # MIDI controls
+AUDIO_ENABLE = no           # Audio output on port C6
+UNICODE_ENABLE = no         # Unicode
+BLUETOOTH_ENABLE = no       # Enable Bluetooth with the Adafruit EZ-Key HID
+RGBLIGHT_ENABLE = no        # Enable WS2812 RGB underlight.
+API_SYSEX_ENABLE = no
+SPLIT_KEYBOARD = no
+WAIT_FOR_USB = yes
+
+# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
+SLEEP_LED_ENABLE = no    # Breathing sleep LED during USB suspend
+
+LAYOUTS_HAS_RGB = NO
+
+CUSTOM_MATRIX = yes
+SRC = matrix.c
\ No newline at end of file