From 3b5381d6893b02b48b9abd4845220cd68d02979f Mon Sep 17 00:00:00 2001 From: Balz Guenat Date: Wed, 8 Nov 2017 17:11:44 +0100 Subject: restructure converters (#1825) * restructure converters each converter is its own keyboard and different hardware variants are different subprojects. remove (seemingly) old method of loading layouts from main Makefile * call led_set_kb() from overridden led_set() * put converter back into one folder * revert some structure changes to bring in line with #1784. Also attempt to get the BLE thing more properly integrated. Also also fix led_set() to call led_set_kb(). --- keyboards/converter/ibm_terminal/README | 40 ----------------------- keyboards/converter/ibm_terminal/README.md | 40 +++++++++++++++++++++++ keyboards/converter/ibm_terminal/ibm_terminal.c | 5 --- keyboards/converter/usb_usb/README.md | 15 ++++++--- keyboards/converter/usb_usb/ble/README.md | 30 +++++++++++++++++ keyboards/converter/usb_usb/ble/ble.c | 1 + keyboards/converter/usb_usb/ble/ble.h | 6 ++++ keyboards/converter/usb_usb/ble/config.h | 13 ++++++++ keyboards/converter/usb_usb/ble/rules.mk | 4 +++ keyboards/converter/usb_usb/config.h | 1 + keyboards/converter/usb_usb/custom_matrix.cpp | 38 +++++++++++---------- keyboards/converter/usb_usb/hasu/hasu.c | 1 + keyboards/converter/usb_usb/hasu/hasu.h | 6 ++++ keyboards/converter/usb_usb/hasu/rules.mk | 1 + keyboards/converter/usb_usb/keymaps/ble/README.md | 30 ----------------- keyboards/converter/usb_usb/keymaps/ble/config.h | 9 ----- keyboards/converter/usb_usb/keymaps/ble/rules.mk | 3 -- keyboards/converter/usb_usb/pro_micro/pro_micro.c | 1 + keyboards/converter/usb_usb/pro_micro/pro_micro.h | 6 ++++ keyboards/converter/usb_usb/pro_micro/rules.mk | 1 + keyboards/converter/usb_usb/rules.mk | 10 +++++- keyboards/converter/usb_usb/usb_usb.c | 2 +- 22 files changed, 152 insertions(+), 111 deletions(-) delete mode 100644 keyboards/converter/ibm_terminal/README create mode 100644 keyboards/converter/ibm_terminal/README.md create mode 100644 keyboards/converter/usb_usb/ble/README.md create mode 100644 keyboards/converter/usb_usb/ble/ble.c create mode 100644 keyboards/converter/usb_usb/ble/ble.h create mode 100644 keyboards/converter/usb_usb/ble/config.h create mode 100644 keyboards/converter/usb_usb/ble/rules.mk create mode 100644 keyboards/converter/usb_usb/hasu/hasu.c create mode 100644 keyboards/converter/usb_usb/hasu/hasu.h create mode 100644 keyboards/converter/usb_usb/hasu/rules.mk delete mode 100644 keyboards/converter/usb_usb/keymaps/ble/README.md delete mode 100644 keyboards/converter/usb_usb/keymaps/ble/rules.mk create mode 100644 keyboards/converter/usb_usb/pro_micro/pro_micro.c create mode 100644 keyboards/converter/usb_usb/pro_micro/pro_micro.h create mode 100644 keyboards/converter/usb_usb/pro_micro/rules.mk (limited to 'keyboards') diff --git a/keyboards/converter/ibm_terminal/README b/keyboards/converter/ibm_terminal/README deleted file mode 100644 index 6b7aff2c84..0000000000 --- a/keyboards/converter/ibm_terminal/README +++ /dev/null @@ -1,40 +0,0 @@ -Keyboard converter for IBM terminal keyboard -============================================ - -This is a port of TMK's converter/terminal_usb to QMK. - -It supports PS/2 Scan Code Set 3 and runs on USB AVR chips such like PJRC Teensy. -I tested the converter on ATMega32U4 with 1392595(102keys) and 6110345(122keys). - -Source code: https://github.com/tmk/tmk_keyboard -Article: http://geekhack.org/index.php?topic=27272.0 - - -CONNECTION ----------- -Keyboard ATMega32U4 ----------------------- -Data: PD2 -Clock: PD5 - -And VCC and GND, of course. See RESOURCE for keyboard connector pin assign. - - -BUILD ------ -$ git clone https://github.com/tmk/tmk_keyboard.git -$ cd converter/terminal_usb -$ make - - -RESOURCE --------- -Soarer's Converter: http://geekhack.org/index.php?topic=17458.0 -102keys(1392595): http://geekhack.org/index.php?topic=10737.0 -122keys(1390876): http://www.seasip.info/VintagePC/ibm_1390876.html -KbdBabel: http://www.kbdbabel.org/ -RJ45 Connector: http://www.kbdbabel.org/conn/kbd_connector_ibmterm.png -DIN Connector: http://www.kbdbabel.org/conn/kbd_connector_ibm3179_318x_319x.png -WinAVR: http://winavr.sourceforge.net/ - -EOF diff --git a/keyboards/converter/ibm_terminal/README.md b/keyboards/converter/ibm_terminal/README.md new file mode 100644 index 0000000000..dff26e0594 --- /dev/null +++ b/keyboards/converter/ibm_terminal/README.md @@ -0,0 +1,40 @@ +Keyboard converter for IBM terminal keyboard +============================================ + +This is a port of TMK's converter/terminal_usb to QMK. + +It supports PS/2 Scan Code Set 3 and runs on USB AVR chips such like PJRC Teensy. +I tested the converter on ATMega32U4 with 1392595(102keys) and 6110345(122keys). + +Source code: https://github.com/qmk/qmk_firmware.git +Article: http://geekhack.org/index.php?topic=27272.0 + + +CONNECTION +---------- +Keyboard ATMega32U4 +---------------------- +Data: PD2 +Clock: PD5 + +And VCC and GND, of course. See RESOURCE for keyboard connector pin assign. + + +BUILD +----- +$ git clone https://github.com/qmk/qmk_firmware.git +$ cd qmk_firmware +$ make converter/ibm_terminal:default + + +RESOURCE +-------- +Soarer's Converter: http://geekhack.org/index.php?topic=17458.0 +102keys(1392595): http://geekhack.org/index.php?topic=10737.0 +122keys(1390876): http://www.seasip.info/VintagePC/ibm_1390876.html +KbdBabel: http://www.kbdbabel.org/ +RJ45 Connector: http://www.kbdbabel.org/conn/kbd_connector_ibmterm.png +DIN Connector: http://www.kbdbabel.org/conn/kbd_connector_ibm3179_318x_319x.png +WinAVR: http://winavr.sourceforge.net/ + +EOF diff --git a/keyboards/converter/ibm_terminal/ibm_terminal.c b/keyboards/converter/ibm_terminal/ibm_terminal.c index 17296864a3..fd64a21ace 100644 --- a/keyboards/converter/ibm_terminal/ibm_terminal.c +++ b/keyboards/converter/ibm_terminal/ibm_terminal.c @@ -1,6 +1 @@ #include "ibm_terminal.h" - -// void matrix_init_kb(void) { - -// matrix_init_user(); -// } \ No newline at end of file diff --git a/keyboards/converter/usb_usb/README.md b/keyboards/converter/usb_usb/README.md index 2ed702695b..b529fbd28d 100644 --- a/keyboards/converter/usb_usb/README.md +++ b/keyboards/converter/usb_usb/README.md @@ -13,13 +13,18 @@ Make example for this keyboard (after setting up your build environment): See [build environment setup](https://docs.qmk.fm/build_environment_setup.html) then the [make instructions](https://docs.qmk.fm/make_instructions.html) for more information. +Note that you have to choose the right hardware variant as your subproject, otherwise you will probably have issues. + Troubleshooting & Known Issues ------------------------------ -The Pro Micro variant runs at 8MHz, hence the following line in `usb_usb/rules.mk`: -`F_CPU ?= 8000000` -If the firmware doesn't work, try changing that line to -`F_CPU ?= 16000000` -or override the `F_CPU` variable in the `rules.mk` of your keymap. +If something doesn't work, it's probably because of the CPU clock. +Be sure to select the correct subproject (the middle part of the `make` argument) according to your hardware. +If you are sure you have this correct, try changeing the default in `usb_usb/rules.mk` or overriding the value in the `rules.mk` of your keymap. + +The Pro Micro variant uses a 3.3V Pro Micro and thus runs at 8MHz, hence the following line in `usb_usb/pro_micro/rules.mk`: +`F_CPU = 8000000` +The converter sold by Hasu runs at 16MHz and so the corresponding line in `usb_usb/hasu/rules.mk` is: +`F_CPU = 16000000` Getting the Hardware -------------------- diff --git a/keyboards/converter/usb_usb/ble/README.md b/keyboards/converter/usb_usb/ble/README.md new file mode 100644 index 0000000000..0ee7223fd4 --- /dev/null +++ b/keyboards/converter/usb_usb/ble/README.md @@ -0,0 +1,30 @@ +QMK BLE Adapter +=============== +A small device that reads USB keyboard input and passes it on over Bluetooth LE HID. + +![Picture of Adapter](https://i.imgur.com/O3VwBBJ.png) + +Hardware +-------- +The hardware is relatively easy to assemble. Just follow the schematic and don't forget to [cut the VBUS jumper](https://www.pjrc.com/teensy/td_libs_USBHostShield_4a.jpg). + +Schematic: +![Schematic](https://i.imgur.com/s1Ia9We.png) + +Part list: +* [Adafruit Feather 32u4 Bluefruit LE](https://www.adafruit.com/product/2829) +* [USB Host Mini](https://www.circuitsathome.com/arduino_usb_host_shield_projects/) +* [Pololu 5V Step-Up Voltage Regulator U3V12F5](https://www.pololu.com/product/2115) +* [Lithium Ion Battery - 3.7v 2000mAh](https://www.adafruit.com/product/2011) +* Some sort of switch to be able to turn it off + +Building and Flashing +--------------------- + +``` +make converter-usb_usb-ble +``` + +``` +make converter-usb_usb-ble-avrdude +``` \ No newline at end of file diff --git a/keyboards/converter/usb_usb/ble/ble.c b/keyboards/converter/usb_usb/ble/ble.c new file mode 100644 index 0000000000..387eb8166c --- /dev/null +++ b/keyboards/converter/usb_usb/ble/ble.c @@ -0,0 +1 @@ +#include "ble.h" diff --git a/keyboards/converter/usb_usb/ble/ble.h b/keyboards/converter/usb_usb/ble/ble.h new file mode 100644 index 0000000000..d28629643a --- /dev/null +++ b/keyboards/converter/usb_usb/ble/ble.h @@ -0,0 +1,6 @@ +#ifndef BLE_H +#define BLE_H + +#include QMK_KEYBOARD_H + +#endif diff --git a/keyboards/converter/usb_usb/ble/config.h b/keyboards/converter/usb_usb/ble/config.h new file mode 100644 index 0000000000..45aa778d57 --- /dev/null +++ b/keyboards/converter/usb_usb/ble/config.h @@ -0,0 +1,13 @@ +#ifndef CONFIG_BLE_H +#define CONFIG_BLE_H + +#undef PRODUCT +#define PRODUCT QMK BLE Adapter +#undef DESCRIPTION +#define DESCRIPTION + +// Turn off the mode leds on the BLE module +#define ADAFRUIT_BLE_ENABLE_MODE_LEDS 0 +#define ADAFRUIT_BLE_ENABLE_POWER_LED 0 + +#endif diff --git a/keyboards/converter/usb_usb/ble/rules.mk b/keyboards/converter/usb_usb/ble/rules.mk new file mode 100644 index 0000000000..c951780e20 --- /dev/null +++ b/keyboards/converter/usb_usb/ble/rules.mk @@ -0,0 +1,4 @@ +BLUETOOTH = AdafruitBLE +ADAFRUIT_BLE_ENABLE = yes +OPT_DEFS += -DCATERINA_BOOTLOADER +F_CPU = 8000000 diff --git a/keyboards/converter/usb_usb/config.h b/keyboards/converter/usb_usb/config.h index 591d80f32d..deee35948b 100644 --- a/keyboards/converter/usb_usb/config.h +++ b/keyboards/converter/usb_usb/config.h @@ -21,6 +21,7 @@ along with this program. If not, see . // do not #include "config_common.h" because the pin names conflict with the USB HID code. // CUSTOM_MATRIX is defined it that file, though, and we need it, so we define it ourselves. // It's a hack, yeah... + #define CUSTOM_MATRIX 2 /* USB Device descriptor parameter */ diff --git a/keyboards/converter/usb_usb/custom_matrix.cpp b/keyboards/converter/usb_usb/custom_matrix.cpp index 93d13edf0b..fba107c7cb 100644 --- a/keyboards/converter/usb_usb/custom_matrix.cpp +++ b/keyboards/converter/usb_usb/custom_matrix.cpp @@ -35,6 +35,9 @@ along with this program. If not, see . #include "host.h" #include "keyboard.h" +extern "C" { +#include "quantum.h" +} /* KEY CODE to Matrix * @@ -62,7 +65,7 @@ along with this program. If not, see . // Integrated key state of all keyboards -static report_keyboard_t keyboard_report; +static report_keyboard_t local_keyboard_report; static bool matrix_is_mod = false; @@ -98,13 +101,13 @@ extern "C" } static void or_report(report_keyboard_t report) { - // integrate reports into keyboard_report - keyboard_report.mods |= report.mods; + // integrate reports into local_keyboard_report + local_keyboard_report.mods |= report.mods; for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) { if (IS_ANY(report.keys[i])) { for (uint8_t j = 0; j < KEYBOARD_REPORT_KEYS; j++) { - if (! keyboard_report.keys[j]) { - keyboard_report.keys[j] = report.keys[i]; + if (! local_keyboard_report.keys[j]) { + local_keyboard_report.keys[j] = report.keys[i]; break; } } @@ -130,7 +133,7 @@ extern "C" last_time_stamp4 = kbd_parser4.time_stamp; // clear and integrate all reports - keyboard_report = {}; + local_keyboard_report = {}; or_report(kbd_parser1.report); or_report(kbd_parser2.report); or_report(kbd_parser3.report); @@ -138,9 +141,9 @@ extern "C" matrix_is_mod = true; - dprintf("state: %02X %02X", keyboard_report.mods, keyboard_report.reserved); + dprintf("state: %02X %02X", local_keyboard_report.mods, local_keyboard_report.reserved); for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) { - dprintf(" %02X", keyboard_report.keys[i]); + dprintf(" %02X", local_keyboard_report.keys[i]); } dprint("\r\n"); } else { @@ -177,12 +180,12 @@ extern "C" uint8_t code = CODE(row, col); if (IS_MOD(code)) { - if (keyboard_report.mods & ROW_BITS(code)) { + if (local_keyboard_report.mods & ROW_BITS(code)) { return true; } } for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) { - if (keyboard_report.keys[i] == code) { + if (local_keyboard_report.keys[i] == code) { return true; } } @@ -192,14 +195,14 @@ extern "C" matrix_row_t matrix_get_row(uint8_t row) { uint16_t row_bits = 0; - if (IS_MOD(CODE(row, 0)) && keyboard_report.mods) { - row_bits |= keyboard_report.mods; + if (IS_MOD(CODE(row, 0)) && local_keyboard_report.mods) { + row_bits |= local_keyboard_report.mods; } for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) { - if (IS_ANY(keyboard_report.keys[i])) { - if (row == ROW(keyboard_report.keys[i])) { - row_bits |= ROW_BITS(keyboard_report.keys[i]); + if (IS_ANY(local_keyboard_report.keys[i])) { + if (row == ROW(local_keyboard_report.keys[i])) { + row_bits |= ROW_BITS(local_keyboard_report.keys[i]); } } } @@ -209,9 +212,9 @@ extern "C" uint8_t matrix_key_count(void) { uint8_t count = 0; - count += bitpop(keyboard_report.mods); + count += bitpop(local_keyboard_report.mods); for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) { - if (IS_ANY(keyboard_report.keys[i])) { + if (IS_ANY(local_keyboard_report.keys[i])) { count++; } } @@ -233,6 +236,7 @@ extern "C" kbd2.SetReport(0, 0, 2, 0, 1, &usb_led); kbd3.SetReport(0, 0, 2, 0, 1, &usb_led); kbd4.SetReport(0, 0, 2, 0, 1, &usb_led); + led_set_kb(usb_led); } }; diff --git a/keyboards/converter/usb_usb/hasu/hasu.c b/keyboards/converter/usb_usb/hasu/hasu.c new file mode 100644 index 0000000000..3357735ffd --- /dev/null +++ b/keyboards/converter/usb_usb/hasu/hasu.c @@ -0,0 +1 @@ +#include "hasu.h" diff --git a/keyboards/converter/usb_usb/hasu/hasu.h b/keyboards/converter/usb_usb/hasu/hasu.h new file mode 100644 index 0000000000..d5e7855860 --- /dev/null +++ b/keyboards/converter/usb_usb/hasu/hasu.h @@ -0,0 +1,6 @@ +#ifndef HASU_H +#define HASU_H + +#include QMK_KEYBOARD_H + +#endif diff --git a/keyboards/converter/usb_usb/hasu/rules.mk b/keyboards/converter/usb_usb/hasu/rules.mk new file mode 100644 index 0000000000..27d8af7683 --- /dev/null +++ b/keyboards/converter/usb_usb/hasu/rules.mk @@ -0,0 +1 @@ +F_CPU = 16000000 diff --git a/keyboards/converter/usb_usb/keymaps/ble/README.md b/keyboards/converter/usb_usb/keymaps/ble/README.md deleted file mode 100644 index 0ee7223fd4..0000000000 --- a/keyboards/converter/usb_usb/keymaps/ble/README.md +++ /dev/null @@ -1,30 +0,0 @@ -QMK BLE Adapter -=============== -A small device that reads USB keyboard input and passes it on over Bluetooth LE HID. - -![Picture of Adapter](https://i.imgur.com/O3VwBBJ.png) - -Hardware --------- -The hardware is relatively easy to assemble. Just follow the schematic and don't forget to [cut the VBUS jumper](https://www.pjrc.com/teensy/td_libs_USBHostShield_4a.jpg). - -Schematic: -![Schematic](https://i.imgur.com/s1Ia9We.png) - -Part list: -* [Adafruit Feather 32u4 Bluefruit LE](https://www.adafruit.com/product/2829) -* [USB Host Mini](https://www.circuitsathome.com/arduino_usb_host_shield_projects/) -* [Pololu 5V Step-Up Voltage Regulator U3V12F5](https://www.pololu.com/product/2115) -* [Lithium Ion Battery - 3.7v 2000mAh](https://www.adafruit.com/product/2011) -* Some sort of switch to be able to turn it off - -Building and Flashing ---------------------- - -``` -make converter-usb_usb-ble -``` - -``` -make converter-usb_usb-ble-avrdude -``` \ No newline at end of file diff --git a/keyboards/converter/usb_usb/keymaps/ble/config.h b/keyboards/converter/usb_usb/keymaps/ble/config.h index c1859b7f1a..7fa3bf328e 100644 --- a/keyboards/converter/usb_usb/keymaps/ble/config.h +++ b/keyboards/converter/usb_usb/keymaps/ble/config.h @@ -3,13 +3,4 @@ #include "../../config.h" -#undef PRODUCT -#define PRODUCT QMK BLE Adapter -#undef DESCRIPTION -#define DESCRIPTION - -// Turn off the mode leds on the BLE module -#define ADAFRUIT_BLE_ENABLE_MODE_LEDS 0 -#define ADAFRUIT_BLE_ENABLE_POWER_LED 0 - #endif diff --git a/keyboards/converter/usb_usb/keymaps/ble/rules.mk b/keyboards/converter/usb_usb/keymaps/ble/rules.mk deleted file mode 100644 index 3beda3f445..0000000000 --- a/keyboards/converter/usb_usb/keymaps/ble/rules.mk +++ /dev/null @@ -1,3 +0,0 @@ -BLUETOOTH = AdafruitBLE -ADAFRUIT_BLE_ENABLE = yes -OPT_DEFS += -DCATERINA_BOOTLOADER \ No newline at end of file diff --git a/keyboards/converter/usb_usb/pro_micro/pro_micro.c b/keyboards/converter/usb_usb/pro_micro/pro_micro.c new file mode 100644 index 0000000000..f10142f81a --- /dev/null +++ b/keyboards/converter/usb_usb/pro_micro/pro_micro.c @@ -0,0 +1 @@ +#include "pro_micro.h" diff --git a/keyboards/converter/usb_usb/pro_micro/pro_micro.h b/keyboards/converter/usb_usb/pro_micro/pro_micro.h new file mode 100644 index 0000000000..566df9f20f --- /dev/null +++ b/keyboards/converter/usb_usb/pro_micro/pro_micro.h @@ -0,0 +1,6 @@ +#ifndef PRO_MICRO_H +#define PRO_MICRO_H + +#include QMK_KEYBOARD_H + +#endif diff --git a/keyboards/converter/usb_usb/pro_micro/rules.mk b/keyboards/converter/usb_usb/pro_micro/rules.mk new file mode 100644 index 0000000000..7c04fa34fd --- /dev/null +++ b/keyboards/converter/usb_usb/pro_micro/rules.mk @@ -0,0 +1 @@ +F_CPU = 8000000 diff --git a/keyboards/converter/usb_usb/rules.mk b/keyboards/converter/usb_usb/rules.mk index 81a393e8ab..b0e07c7649 100644 --- a/keyboards/converter/usb_usb/rules.mk +++ b/keyboards/converter/usb_usb/rules.mk @@ -13,7 +13,15 @@ MCU = atmega32u4 # 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 = 8000000 + +# Since there are different hardware variations of these adapters and since these +# have different CPU clocks, the clock speed should be set in the rules.mk file of the +# respective hardware variantion (i.e. subproject). For example, in /pro_micro/rules.mk +# this is set to 8000000. +# The value here is only a fallback and is ignored if it is defined in the subproject. +F_CPU ?= 16000000 + +DEFAULT_FOLDER = converter/usb_usb/hasu # diff --git a/keyboards/converter/usb_usb/usb_usb.c b/keyboards/converter/usb_usb/usb_usb.c index e7657938d2..e8f224ad46 100644 --- a/keyboards/converter/usb_usb/usb_usb.c +++ b/keyboards/converter/usb_usb/usb_usb.c @@ -1 +1 @@ -#include "usb_usb.h" \ No newline at end of file +#include "usb_usb.h" -- cgit v1.2.3