From c51dfef958bce4a792b66db337d5c7cdf0956fc4 Mon Sep 17 00:00:00 2001 From: Scott Wilson Date: Sun, 3 Dec 2017 10:32:07 -0500 Subject: Add support for LFKeyboard products: LFK78, LFK87 and SMK65 --- keyboards/lfkeyboards/lfk78/config.h | 172 ++++++++++++++++ .../lfkeyboards/lfk78/keymaps/default/config.h | 8 + .../lfkeyboards/lfk78/keymaps/default/keymap.c | 123 +++++++++++ .../lfkeyboards/lfk78/keymaps/default/readme.md | 1 + .../lfkeyboards/lfk78/keymaps/default/rules.mk | 42 ++++ keyboards/lfkeyboards/lfk78/lfk78.c | 225 +++++++++++++++++++++ keyboards/lfkeyboards/lfk78/lfk78.h | 155 ++++++++++++++ keyboards/lfkeyboards/lfk78/readme.md | 14 ++ keyboards/lfkeyboards/lfk78/rules.mk | 34 ++++ 9 files changed, 774 insertions(+) create mode 100644 keyboards/lfkeyboards/lfk78/config.h create mode 100644 keyboards/lfkeyboards/lfk78/keymaps/default/config.h create mode 100644 keyboards/lfkeyboards/lfk78/keymaps/default/keymap.c create mode 100644 keyboards/lfkeyboards/lfk78/keymaps/default/readme.md create mode 100644 keyboards/lfkeyboards/lfk78/keymaps/default/rules.mk create mode 100644 keyboards/lfkeyboards/lfk78/lfk78.c create mode 100644 keyboards/lfkeyboards/lfk78/lfk78.h create mode 100644 keyboards/lfkeyboards/lfk78/readme.md create mode 100644 keyboards/lfkeyboards/lfk78/rules.mk (limited to 'keyboards/lfkeyboards/lfk78') diff --git a/keyboards/lfkeyboards/lfk78/config.h b/keyboards/lfkeyboards/lfk78/config.h new file mode 100644 index 0000000000..32f4455dae --- /dev/null +++ b/keyboards/lfkeyboards/lfk78/config.h @@ -0,0 +1,172 @@ +/* +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" + +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x6060 +#define DEVICE_VER 0x0001 +#define MANUFACTURER LFKeyboards +#define PRODUCT LFK78 +#define DESCRIPTION QMK keyboard firmware for LFK78 LFK_REV_STRING + +#ifdef LFK_REV_B +/* RevB Matrix config */ + #define DIODE_DIRECTION COL2ROW + #define MATRIX_ROWS 10 + #define MATRIX_COLS 8 + #define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, F0, F1, F4, F5, F6} + #define MATRIX_COL_PINS { E6, F7, D2, D3, D4, D5, D6, D7 } + #define UNUSED_PINS { C7 } + #define RGBLED_NUM 31 // Number of LEDs +#else +/* RevC/D Matrix config */ + #define DIODE_DIRECTION COL2ROW + #define MATRIX_ROWS 5 + #define MATRIX_COLS 18 + #define MATRIX_ROW_PINS {D2, D3, D4, D5, D6 } + #define MATRIX_COL_PINS {A0, A1, A2, A3, A4, A5, A6, A7, E6, E7,\ + F0, F1, F2, F3, C0, C1, C2, C3 } + #define UNUSED_PINS {B0, B1, B2, B3, B4, B4, B5, B6, B7, C4, C5, C6, C7,\ + D0, D1, D7, E0, E1, E2, E3, E4, D5, F4, F5, F6, F7,\ + E6, E7, F0, F1, F2, F3, C0, C1, C2, C3} + #define RGBLED_NUM 27 // Number of LEDs +#endif + +#define AUDIO_VOICES +#define C6_AUDIO + +#define BACKLIGHT_LEVELS 8 +#define BACKLIGHT_PWM_MAP {8, 16, 40, 55, 70, 128, 200, 255} + +#define RGB_DI_PIN C7 // Have to set it to something to get the ws2812 code to compile +#define RGBLIGHT_ANIMATIONS +#define RGBLIGHT_HUE_STEP 10 +#define RGBLIGHT_SAT_STEP 17 +#define RGBLIGHT_VAL_STEP 17 + +#define TAPPING_TERM 200 + +/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ +#define DEBOUNCING_DELAY 5 + +/* define if matrix has ghost (lacks anti-ghosting diodes) */ +//#define MATRIX_HAS_GHOST + +/* number of backlight levels */ + +/* 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/lfkeyboards/lfk78/keymaps/default/config.h b/keyboards/lfkeyboards/lfk78/keymaps/default/config.h new file mode 100644 index 0000000000..8893d122e0 --- /dev/null +++ b/keyboards/lfkeyboards/lfk78/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/lfkeyboards/lfk78/keymaps/default/keymap.c b/keyboards/lfkeyboards/lfk78/keymaps/default/keymap.c new file mode 100644 index 0000000000..613213f067 --- /dev/null +++ b/keyboards/lfkeyboards/lfk78/keymaps/default/keymap.c @@ -0,0 +1,123 @@ +#include "lfk78.h" +#include "issi.h" +#include "lighting.h" +#include "action_layer.h" + +//Define a shorter 'transparent' key code to make the keymaps more compact +#define KC_TR KC_TRNS + +enum keymap_layout { + VANILLA = 0, // matches MF68 layout + FUNC, // 0x02 + SETTINGS, // 0x04 +}; + +// Colors of the layer indicator LED +// This list needs to define layer 0xFFFFFFFF, it is the end of the list, and the unknown layer +const Layer_Info layer_info[] = { + // Layer Mask Red Green Blue + {0x00000000, 0xFFFFFFFF, {0x0000, 0x0FFF, 0x0000}}, // base layer - green + {0x00000002, 0xFFFFFFFE, {0x0000, 0x0000, 0x0FFF}}, // function layer - blue + {0x00000004, 0xFFFFFFFC, {0x0FFF, 0x0000, 0x0FFF}}, // settings layer - magenta + {0xFFFFFFFF, 0xFFFFFFFF, {0x0FFF, 0x0FFF, 0x0FFF}}, // unknown layer - REQUIRED - white +}; + + + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { +[VANILLA] = KEYMAP( + /* Keymap VANILLA: (Base Layer) Default Layer + * ,---------. ,------------------------------------------------------------. ,---------. + * | F1 | F2 | |Esc~| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0| - | = |Backspa| | Ins|PgUp| + * |---------| |------------------------------------------------------------| |---------| + * | F3 | F4 | |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| | Del|PgDn| + * |---------| |------------------------------------------------------------| `---------' + * | F5 | F6 | |CAPS | A| S| D| F| G| H| J| K| L| ;| '|Return | + * |---------| |------------------------------------------------------------| ,----. + * | F7 | F8 | |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | | Up | + * |---------| |-------------------------------------------------------------------------. + * | F9 | F10| |Ctrl|Win |Alt | Space |Alt |Ctrl|Func | |Lft| Dn |Rig | + * `---------' `------------------------------------------------------' `-------------' + */ + KC_F1, KC_F2, KC_GESC,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_PGUP, + 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_BSLS, KC_DEL, KC_PGDN, + KC_F5, KC_F6, 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_F7, KC_F8, KC_LSFT, 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_F9, KC_F10, KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RCTL, MO(FUNC), KC_LEFT, KC_DOWN, KC_RGHT), + /* Keymap FUNCTION: Function Layer + * ,---------. ,-------------------------------------------------------------. ,---------. + * | | | | ` |F1 |F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10|F11|F12|Delete | | Ins|Home| + * |---------| |-------------------------------------------------------------| |---------| + * | | | |Tab |Hom| Up|End|PgU| | | | | | | | | | | Del|End | + * |---------| |-------------------------------------------------------------| `---------' + * | | | |MO(FUNC)|Lft|Dn |Rig|PgD| |Lft|Dwn| Up|Rgt| | | | + * |---------| |-------------------------------------------------------------| ,----. + * | | | |Shift | | | | | | |Mute|V- |V+ | |TG(SETTINGS)| | Up | + * |---------| |--------------------------------------------------------------------------. + * | | | |Ctrl|Win |Alt | Enter |Alt |Func |CTRL | |Lft| Dn |Rig | + * `---------' `------------------------------------------------------' `-------------' + */ +[FUNC] = KEYMAP( + KC_TR, KC_TR, KC_GRV, 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_DEL, KC_TR, KC_HOME, + KC_TR, KC_TR, KC_NO,KC_HOME, KC_UP, KC_END, KC_PGUP, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_TR, KC_END, + KC_TR, KC_TR, KC_TR, KC_LEFT, KC_DOWN, KC_RGHT, KC_PGDN, KC_NO, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_NO, KC_NO, KC_NO, + KC_TR, KC_TR, KC_TR, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_MUTE, KC_VOLD, KC_VOLU, KC_NO, TG(SETTINGS), KC_TR, + KC_TR, KC_TR, KC_TR, KC_TR, KC_TR, KC_ENT, KC_TR, KC_TR, KC_TR, KC_TR, KC_TR, KC_TR), + + /* Keymap SETTINGS: Settings Layer + * ,---------. ,-------------------------------------------------------------. ,-------------. + * | | | |LayClr| | | | | | | | | | |BL-|BL+|BL Togl| |RGB Tog |Val+| + * |---------| |-------------------------------------------------------------| |-------------| + * | | | |MuMode | | | | | | | | | | | | |LEDTst| |RGB Mode|Val-| + * |---------| |-------------------------------------------------------------| `-------------' + * | | | |AudTgl |Hz+|MS+| | | | | | | | | | RST | + * |---------| |-------------------------------------------------------------| ,----. + * | | | |ClickTgl |Hz-|MS-| | | | |MuTgl| | | |Layer Clr | |Hue+| + * |---------| |-------------------------------------------------------------------------. + * | | | | | | | | | | | |Sat-|Hue-|Sat+| + * `---------' `--------------------------------------------------------' `--------------' + */ +[SETTINGS] = KEYMAP( + KC_NO, KC_NO, KC_FN0,KC_NO,KC_NO,KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, BL_DEC, BL_INC, BL_TOGG, RGB_TOG, RGB_VAI, + KC_NO, KC_NO, MU_MOD, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, RGB_MOD, RGB_VAD, + KC_NO, KC_NO, AU_TOG, KC_FN1,KC_FN3, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, RESET, + KC_NO, KC_NO, KC_FN5, KC_FN2,KC_FN4, KC_NO, KC_NO, KC_NO, KC_NO, MU_TOG, KC_NO, KC_NO, KC_NO, KC_NO, RGB_HUI, + KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, RGB_SAD, RGB_HUD, RGB_SAI), +}; + +const uint16_t PROGMEM fn_actions[] = { + ACTION_FUNCTION(LFK_CLEAR), // FN0 - reset layers + ACTION_FUNCTION(LFK_CLICK_FREQ_HIGHER), // FN1 - Increase Freq of audio click + ACTION_FUNCTION(LFK_CLICK_FREQ_LOWER), // FN2 - Decrease Freq of audio click + ACTION_FUNCTION(LFK_CLICK_TIME_LONGER), // FN3 - Increase length of audio click + ACTION_FUNCTION(LFK_CLICK_TIME_SHORTER), // FN4 - Decrease length of audio click + ACTION_FUNCTION(LFK_CLICK_TOGGLE), // FN5 - Toggle audio click + }; + + +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + // MACRODOWN only works in this function + switch(id) { + } + return MACRO_NONE; +}; + + +void matrix_init_user(void) { + // This keymap only has a single base layer, so reset the default if needed + if(eeconfig_read_default_layer() > 1){ + eeconfig_update_default_layer(1); + default_layer_set(1); + } +} + +void matrix_scan_user(void) { +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + return true; +} + +void led_set_user(uint8_t usb_led) { +} diff --git a/keyboards/lfkeyboards/lfk78/keymaps/default/readme.md b/keyboards/lfkeyboards/lfk78/keymaps/default/readme.md new file mode 100644 index 0000000000..8321adeb7a --- /dev/null +++ b/keyboards/lfkeyboards/lfk78/keymaps/default/readme.md @@ -0,0 +1 @@ +# The default keymap for LFK78 diff --git a/keyboards/lfkeyboards/lfk78/keymaps/default/rules.mk b/keyboards/lfkeyboards/lfk78/keymaps/default/rules.mk new file mode 100644 index 0000000000..dd973eac3d --- /dev/null +++ b/keyboards/lfkeyboards/lfk78/keymaps/default/rules.mk @@ -0,0 +1,42 @@ +# 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 = yes # 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 = yes # Enable keyboard backlight functionality +MIDI_ENABLE = no # MIDI controls +AUDIO_ENABLE = yes # Audio output on port C6 +UNICODE_ENABLE = no # Unicode +BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID +RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. +RGBLIGHT_CUSTOM_DRIVER = yes # RGB code is implemented in lefkeyboards, not qmk base +SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend +TAP_DANCE_ENABLE = no + +ISSI_ENABLE = yes # If the I2C pullup resistors aren't install this must be disabled +WATCHDOG_ENABLE = no # Resets keyboard if matrix_scan isn't run every 250ms + +ifndef QUANTUM_DIR + include ../../../../Makefile +endif + +ifeq ($(strip $(ISSI_ENABLE)), yes) + TMK_COMMON_DEFS += -DISSI_ENABLE +endif + +ifeq ($(strip $(WATCHDOG_ENABLE)), yes) + TMK_COMMON_DEFS += -DWATCHDOG_ENABLE +endif + +# Override the LFK78 hardware version: +# +# B - first public release, uses atmega32u4, has audio, ISSI matrix split between RGB and backlight +# C-H - at90usb1286, no audio, ISSI device 0 is backlight, 4 is RGB +# J - at90usb646, C6 audio, ISSI device 0 is backlight, 4 is RGB +# LFK_REV = J diff --git a/keyboards/lfkeyboards/lfk78/lfk78.c b/keyboards/lfkeyboards/lfk78/lfk78.c new file mode 100644 index 0000000000..e4393327f3 --- /dev/null +++ b/keyboards/lfkeyboards/lfk78/lfk78.c @@ -0,0 +1,225 @@ +#include +#include +#include +#include "lfk78.h" +#include "keymap.h" +#include "issi.h" +#include "TWIlib.h" +#include "lighting.h" +#include "debug.h" +#include