From 3381254c65375c7da451973c7d843bf257a0d4a7 Mon Sep 17 00:00:00 2001 From: TerryMathews Date: Sun, 7 May 2017 17:23:19 -0400 Subject: [PATCH 1/2] Establish support for Bathroom Epiphanies Tiger Lily controller Replacement controller for Filco Majestouch 2 104 key keyboard. BE advises code will also work with the Black Petal controller - I don't have one to test with. Tests working perfectly on my Filco. --- keyboards/tiger_lily/Makefile | 3 + keyboards/tiger_lily/config.h | 147 ++++++++++++++++++ keyboards/tiger_lily/keymaps/default/Makefile | 21 +++ keyboards/tiger_lily/keymaps/default/config.h | 8 + keyboards/tiger_lily/keymaps/default/keymap.c | 11 ++ .../tiger_lily/keymaps/default/readme.md | 1 + keyboards/tiger_lily/matrix.c | 135 ++++++++++++++++ keyboards/tiger_lily/readme.md | 32 ++++ keyboards/tiger_lily/rules.mk | 71 +++++++++ keyboards/tiger_lily/tiger_lily.c | 63 ++++++++ keyboards/tiger_lily/tiger_lily.h | 50 ++++++ 11 files changed, 542 insertions(+) create mode 100644 keyboards/tiger_lily/Makefile create mode 100644 keyboards/tiger_lily/config.h create mode 100644 keyboards/tiger_lily/keymaps/default/Makefile create mode 100644 keyboards/tiger_lily/keymaps/default/config.h create mode 100644 keyboards/tiger_lily/keymaps/default/keymap.c create mode 100644 keyboards/tiger_lily/keymaps/default/readme.md create mode 100644 keyboards/tiger_lily/matrix.c create mode 100644 keyboards/tiger_lily/readme.md create mode 100644 keyboards/tiger_lily/rules.mk create mode 100644 keyboards/tiger_lily/tiger_lily.c create mode 100644 keyboards/tiger_lily/tiger_lily.h diff --git a/keyboards/tiger_lily/Makefile b/keyboards/tiger_lily/Makefile new file mode 100644 index 0000000000..57b2ef62e5 --- /dev/null +++ b/keyboards/tiger_lily/Makefile @@ -0,0 +1,3 @@ +ifndef MAKEFILE_INCLUDED + include ../../Makefile +endif diff --git a/keyboards/tiger_lily/config.h b/keyboards/tiger_lily/config.h new file mode 100644 index 0000000000..4908192906 --- /dev/null +++ b/keyboards/tiger_lily/config.h @@ -0,0 +1,147 @@ +/* +Copyright 2012 Jun Wako + +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 . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + +#include "config_common.h" + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x6060 +#define DEVICE_VER 0x0001 +#define MANUFACTURER Bathroom Epiphanies +#define PRODUCT tiger_lily +#define DESCRIPTION Tiger Lily controller for the Filco Majestouch 2 + +/* + * Frosty Flake Rev. 20140521 made by Bathroom Ephiphanies + * Ported from the Bathroom Epiphanies TMK Firmware: + * https://github.com/BathroomEpiphanies/epiphanies_tmk_keyboard/tree/master/be_controllers + * + */ + +/* key matrix size */ +#define MATRIX_ROWS 8 // Row0 - Row7 in the schematic +#define MATRIX_COLS 18 // ColA - ColR in the schematic + +/* + * Keyboard Matrix Assignments + */ +#define UNUSED_PINS { B0, C4, D3 } + +/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ +#define DEBOUNCING_DELAY 5 + +/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ +#define LOCKING_SUPPORT_ENABLE +/* Locking resynchronize hack */ +#define LOCKING_RESYNC_ENABLE + +/* + * Force NKRO + * + * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved + * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the + * makefile for this to work.) + * + * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N) + * until the next keyboard reset. + * + * NKRO may prevent your keystrokes from being detected in the BIOS, but it is + * fully operational during normal computer usage. + * + * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N) + * or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by + * bootmagic, NKRO mode will always be enabled until it is toggled again during a + * power-up. + * + */ +//#define FORCE_NKRO + +/* + * Magic Key Options + * + * Magic keys are hotkey commands that allow control over firmware functions of + * the keyboard. They are best used in combination with the HID Listen program, + * found here: https://www.pjrc.com/teensy/hid_listen.html + * + * The options below allow the magic key functionality to be changed. This is + * useful if your keyboard/keypad is missing keys and you want magic key support. + * + */ + +/* key combination for magic key command */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ +) + +/* control how magic key switches layers */ +//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS true +//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS true +//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM false + +/* override magic key keymap */ +//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS +//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS +//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM +//#define MAGIC_KEY_HELP1 H +//#define MAGIC_KEY_HELP2 SLASH +//#define MAGIC_KEY_DEBUG D +//#define MAGIC_KEY_DEBUG_MATRIX X +//#define MAGIC_KEY_DEBUG_KBD K +//#define MAGIC_KEY_DEBUG_MOUSE M +//#define MAGIC_KEY_VERSION V +//#define MAGIC_KEY_STATUS S +//#define MAGIC_KEY_CONSOLE C +//#define MAGIC_KEY_LAYER0_ALT1 ESC +//#define MAGIC_KEY_LAYER0_ALT2 GRAVE +//#define MAGIC_KEY_LAYER0 0 +//#define MAGIC_KEY_LAYER1 1 +//#define MAGIC_KEY_LAYER2 2 +//#define MAGIC_KEY_LAYER3 3 +//#define MAGIC_KEY_LAYER4 4 +//#define MAGIC_KEY_LAYER5 5 +//#define MAGIC_KEY_LAYER6 6 +//#define MAGIC_KEY_LAYER7 7 +//#define MAGIC_KEY_LAYER8 8 +//#define MAGIC_KEY_LAYER9 9 +//#define MAGIC_KEY_BOOTLOADER PAUSE +//#define MAGIC_KEY_LOCK CAPS +//#define MAGIC_KEY_EEPROM E +//#define MAGIC_KEY_NKRO N +//#define MAGIC_KEY_SLEEP_LED Z + +/* + * 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 +//#define NO_ACTION_MACRO +//#define NO_ACTION_FUNCTION + +#endif diff --git a/keyboards/tiger_lily/keymaps/default/Makefile b/keyboards/tiger_lily/keymaps/default/Makefile new file mode 100644 index 0000000000..9d3df5964f --- /dev/null +++ b/keyboards/tiger_lily/keymaps/default/Makefile @@ -0,0 +1,21 @@ +# 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 = yes # Mouse keys(+4700) +EXTRAKEY_ENABLE = yes # Audio control and System control(+450) +CONSOLE_ENABLE = no # Console for debug(+400) +COMMAND_ENABLE = yes # 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. Do not enable this with audio at the same time. +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend + +ifndef QUANTUM_DIR + include ../../../../Makefile +endif diff --git a/keyboards/tiger_lily/keymaps/default/config.h b/keyboards/tiger_lily/keymaps/default/config.h new file mode 100644 index 0000000000..8893d122e0 --- /dev/null +++ b/keyboards/tiger_lily/keymaps/default/config.h @@ -0,0 +1,8 @@ +#ifndef CONFIG_USER_H +#define CONFIG_USER_H + +#include "../../config.h" + +// place overrides here + +#endif diff --git a/keyboards/tiger_lily/keymaps/default/keymap.c b/keyboards/tiger_lily/keymaps/default/keymap.c new file mode 100644 index 0000000000..f4526dc59b --- /dev/null +++ b/keyboards/tiger_lily/keymaps/default/keymap.c @@ -0,0 +1,11 @@ +#include "tiger_lily.h" + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { +[0] = KEYMAP(\ + 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_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_LGUI,KC_LALT, KC_SPC, KC_RALT,KC_RGUI, KC_APP,KC_RCTL, KC_LEFT,KC_DOWN,KC_RGHT, KC_P0,KC_PDOT) +}; \ No newline at end of file diff --git a/keyboards/tiger_lily/keymaps/default/readme.md b/keyboards/tiger_lily/keymaps/default/readme.md new file mode 100644 index 0000000000..4626859df4 --- /dev/null +++ b/keyboards/tiger_lily/keymaps/default/readme.md @@ -0,0 +1 @@ +# The default keymap for tiger_lily diff --git a/keyboards/tiger_lily/matrix.c b/keyboards/tiger_lily/matrix.c new file mode 100644 index 0000000000..57e352520a --- /dev/null +++ b/keyboards/tiger_lily/matrix.c @@ -0,0 +1,135 @@ +/* + Copyright 2017 Gabriel Young + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include +#include +#include +#include +#include "print.h" +#include "debug.h" +#include "util.h" +#include "matrix.h" + +#ifndef DEBOUNCING_DELAY +# define DEBOUNCING_DELAY 5 +#endif +static uint8_t debouncing = DEBOUNCING_DELAY; + +static matrix_row_t matrix[MATRIX_ROWS]; +static matrix_row_t matrix_debouncing[MATRIX_ROWS]; + +static matrix_row_t scan_col(void) { + return ( + (PINC&(1<<2) ? 0 : ((matrix_row_t)1<<0)) | \ + (PINB&(1<<3) ? 0 : ((matrix_row_t)1<<1)) | \ + (PINB&(1<<4) ? 0 : ((matrix_row_t)1<<2)) | \ + (PINB&(1<<2) ? 0 : ((matrix_row_t)1<<3)) | \ + (PINB&(1<<1) ? 0 : ((matrix_row_t)1<<4)) | \ + (PINC&(1<<7) ? 0 : ((matrix_row_t)1<<5)) | \ + (PINB&(1<<6) ? 0 : ((matrix_row_t)1<<6)) | \ + (PINB&(1<<5) ? 0 : ((matrix_row_t)1<<7)) + ); +} + +static void select_col(uint8_t col) { + switch (col) { + case 0: PORTD = (PORTD & ~0b01110111) | 0b01110110; break; \ + case 1: PORTD = (PORTD & ~0b01110111) | 0b01100001; break; \ + case 2: PORTD = (PORTD & ~0b01110111) | 0b01100101; break; \ + case 3: PORTD = (PORTD & ~0b01110111) | 0b00000011; break; \ + case 4: PORTD = (PORTD & ~0b01110111) | 0b00000111; break; \ + case 5: PORTD = (PORTD & ~0b01110111) | 0b00010011; break; \ + case 6: PORTD = (PORTD & ~0b01110111) | 0b00010111; break; \ + case 7: PORTD = (PORTD & ~0b01110111) | 0b00100011; break; \ + case 8: PORTD = (PORTD & ~0b01110111) | 0b00100111; break; \ + case 9: PORTD = (PORTD & ~0b01110111) | 0b00110011; break; \ + case 10: PORTD = (PORTD & ~0b01110111) | 0b01110010; break; \ + case 11: PORTD = (PORTD & ~0b01110111) | 0b01100110; break; \ + case 12: PORTD = (PORTD & ~0b01110111) | 0b01110000; break; \ + case 13: PORTD = (PORTD & ~0b01110111) | 0b01100100; break; \ + case 14: PORTD = (PORTD & ~0b01110111) | 0b01100000; break; \ + case 15: PORTD = (PORTD & ~0b01110111) | 0b01000111; break; \ + case 16: PORTD = (PORTD & ~0b01110111) | 0b01000011; break; \ + case 17: PORTD = (PORTD & ~0b01110111) | 0b00110111; break; + } +} + +void matrix_init(void) { + /* Column output pins */ \ + DDRD |= 0b01110111; \ + /* Row input pins */ \ + DDRC &= ~0b10000100; \ + DDRB &= ~0b01111110; \ + PORTC |= 0b10000100; \ + PORTB |= 0b01111110; + + for (uint8_t i=0; i < MATRIX_ROWS; i++) + matrix[i] = matrix_debouncing[i] = 0; + + matrix_init_quantum(); +} + +uint8_t matrix_scan(void) { + for (uint8_t col = 0; col < MATRIX_COLS; col++) { + select_col(col); + _delay_us(3); + matrix_row_t col_scan = scan_col(); + for (uint8_t row = 0; row < MATRIX_ROWS; row++) { + bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<] +``` + +Keymaps follow the format **__\.c__** and are stored in the `keymaps` folder. diff --git a/keyboards/tiger_lily/rules.mk b/keyboards/tiger_lily/rules.mk new file mode 100644 index 0000000000..dd2f4b6eec --- /dev/null +++ b/keyboards/tiger_lily/rules.mk @@ -0,0 +1,71 @@ +# MCU name +#MCU = at90usb1287 +MCU = atmega32u2 + +# 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 + + +# Boot Section Size in *bytes* +# Teensy halfKay 512 +# Teensy++ halfKay 1024 +# Atmel DFU loader 4096 +# LUFA bootloader 4096 +# USBaspLoader 2048 +OPT_DEFS += -DBOOTLOADER_SIZE=4096 + + +# Build Options +# change yes to no to disable +# +BOOTMAGIC_ENABLE ?= no # Virtual DIP switch configuration(+1000) +MOUSEKEY_ENABLE ?= yes # Mouse keys(+4700) +EXTRAKEY_ENABLE ?= yes # Audio control and System control(+450) +CONSOLE_ENABLE ?= yes # Console for debug(+400) +COMMAND_ENABLE ?= yes # Commands for debug and configuration +# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE +SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend +# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +NKRO_ENABLE ?= no # USB Nkey Rollover +BACKLIGHT_ENABLE ?= no # Enable keyboard backlight functionality on B7 by default +MIDI_ENABLE ?= no # MIDI controls +UNICODE_ENABLE ?= no # Unicode +BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID +AUDIO_ENABLE ?= no # Audio output on port C6 +FAUXCLICKY_ENABLE ?= no # Use buzzer to emulate clicky switches + +CUSTOM_MATRIX = yes +SRC += matrix.c \ No newline at end of file diff --git a/keyboards/tiger_lily/tiger_lily.c b/keyboards/tiger_lily/tiger_lily.c new file mode 100644 index 0000000000..d2e7ba7095 --- /dev/null +++ b/keyboards/tiger_lily/tiger_lily.c @@ -0,0 +1,63 @@ +#include "tiger_lily.h" + +void matrix_init_kb(void) { + // put your keyboard start-up code here + // runs once when the firmware starts up + + matrix_init_user(); +} + +void matrix_scan_kb(void) { + // put your looping keyboard code here + // runs every cycle (a lot) + + matrix_scan_user(); +} + +bool process_record_kb(uint16_t keycode, keyrecord_t *record) { + // put your per-action keyboard code here + // runs for every action, just before processing by the firmware + + return process_record_user(keycode, record); +} + +void led_set_kb(uint8_t usb_led) { + DDRB |= (1<<7); + DDRC |= (1<<5) | (1<<6); + + print_dec(usb_led); + + if (usb_led & (1< Date: Sun, 7 May 2017 18:00:06 -0400 Subject: [PATCH 2/2] Fix compile error --- keyboards/tiger_lily/matrix.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/keyboards/tiger_lily/matrix.c b/keyboards/tiger_lily/matrix.c index 57e352520a..d3a0d7ebd1 100644 --- a/keyboards/tiger_lily/matrix.c +++ b/keyboards/tiger_lily/matrix.c @@ -115,6 +115,7 @@ inline matrix_row_t matrix_get_row(uint8_t row) { } void matrix_print(void) { + #ifndef NO_PRINT print("\nr\\c ABCDEFGHIJKLMNOPQR\n"); for (uint8_t row = 0; row < MATRIX_ROWS; row++) { matrix_row_t matrix_row = matrix_get_row(row); @@ -125,6 +126,7 @@ void matrix_print(void) { } print("\n"); } + #endif } uint8_t matrix_key_count(void) {