From 3f3d0551cd5f2ca0b72fc4b24d1d7955ffa8cb78 Mon Sep 17 00:00:00 2001 From: scott-t-wilson Date: Fri, 23 Feb 2018 13:16:10 -0500 Subject: Lfkeyboards updates (#2421) * Update smk65 fn layer, add iso * Added Fn layer to ISO keymap * Fix error when backlight is disabled but lighting isn't * Remove broke mini1800 iso map * Add keymaps * Add LFKPad * Add split delete to lfk78 * Typo * Custom keymap --- keyboards/lfkeyboards/lfkpad/config.h | 151 ++++++++++++++++++ .../lfkeyboards/lfkpad/keymaps/default/config.h | 8 + .../lfkeyboards/lfkpad/keymaps/default/keymap.c | 52 ++++++ .../lfkeyboards/lfkpad/keymaps/default/readme.md | 1 + .../lfkeyboards/lfkpad/keymaps/default/rules.mk | 53 +++++++ keyboards/lfkeyboards/lfkpad/lfkpad.c | 176 +++++++++++++++++++++ keyboards/lfkeyboards/lfkpad/lfkpad.h | 73 +++++++++ keyboards/lfkeyboards/lfkpad/readme.md | 28 ++++ keyboards/lfkeyboards/lfkpad/rules.mk | 14 ++ 9 files changed, 556 insertions(+) create mode 100644 keyboards/lfkeyboards/lfkpad/config.h create mode 100644 keyboards/lfkeyboards/lfkpad/keymaps/default/config.h create mode 100644 keyboards/lfkeyboards/lfkpad/keymaps/default/keymap.c create mode 100644 keyboards/lfkeyboards/lfkpad/keymaps/default/readme.md create mode 100644 keyboards/lfkeyboards/lfkpad/keymaps/default/rules.mk create mode 100644 keyboards/lfkeyboards/lfkpad/lfkpad.c create mode 100644 keyboards/lfkeyboards/lfkpad/lfkpad.h create mode 100644 keyboards/lfkeyboards/lfkpad/readme.md create mode 100644 keyboards/lfkeyboards/lfkpad/rules.mk (limited to 'keyboards/lfkeyboards/lfkpad') diff --git a/keyboards/lfkeyboards/lfkpad/config.h b/keyboards/lfkeyboards/lfkpad/config.h new file mode 100644 index 000000000..ea85f670c --- /dev/null +++ b/keyboards/lfkeyboards/lfkpad/config.h @@ -0,0 +1,151 @@ +/* +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 LFKPad 21 +#define DESCRIPTION QMK keyboard firmware for LFKPad LFK_REV_STRING + +#define DIODE_DIRECTION COL2ROW +#define MATRIX_ROWS 6 +#define MATRIX_COLS 4 +#define MATRIX_ROW_PINS { D5, F4, F6, F7, C7, C6} +#define MATRIX_COL_PINS { F1, F0, D4, D6} +#define UNUSED_PINS { } +#define RGBLED_NUM 28 // Number of LEDs + +#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/lfkpad/keymaps/default/config.h b/keyboards/lfkeyboards/lfkpad/keymaps/default/config.h new file mode 100644 index 000000000..8893d122e --- /dev/null +++ b/keyboards/lfkeyboards/lfkpad/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/lfkpad/keymaps/default/keymap.c b/keyboards/lfkeyboards/lfkpad/keymaps/default/keymap.c new file mode 100644 index 000000000..33ecfd56b --- /dev/null +++ b/keyboards/lfkeyboards/lfkpad/keymaps/default/keymap.c @@ -0,0 +1,52 @@ +#include "lfkpad.h" +#include "issi.h" +#include "lighting.h" +#include "action_layer.h" + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { +[0] = KEYMAP( /* Base */ + KC_ESC, KC_TAB, KC_PEQL, MO(1), \ + KC_LNUM, KC_PSLS, KC_PAST, KC_PMNS, \ + KC_P7, KC_P8, KC_P9, KC_PPLS, \ + KC_P4, KC_P5, KC_P6, \ + KC_P1, KC_P2, KC_P3, KC_PENT, \ + KC_P0, KC_PDOT), + +[1] = KEYMAP( /* RGB */ + RGB_SAI, RGB_VAI, RGB_HUI, KC_TRNS, \ + RGB_SAD, RGB_VAD, RGB_HUD, KC_TRNS, \ + RGB_M_X, RGB_M_G, RGB_MOD, RGB_RMOD, \ + RGB_M_SW, RGB_M_SN, RGB_M_K, \ + RGB_M_P, RGB_M_B, RGB_M_R, RGB_TOG, \ + KC_NO, KC_NO), +}; + + +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/lfkpad/keymaps/default/readme.md b/keyboards/lfkeyboards/lfkpad/keymaps/default/readme.md new file mode 100644 index 000000000..6c48b8d0b --- /dev/null +++ b/keyboards/lfkeyboards/lfkpad/keymaps/default/readme.md @@ -0,0 +1 @@ +# The default keymap LFKPad 21 diff --git a/keyboards/lfkeyboards/lfkpad/keymaps/default/rules.mk b/keyboards/lfkeyboards/lfkpad/keymaps/default/rules.mk new file mode 100644 index 000000000..d2ddd1578 --- /dev/null +++ b/keyboards/lfkeyboards/lfkpad/keymaps/default/rules.mk @@ -0,0 +1,53 @@ +# 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 = no # 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 = 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 + + +# # Set the LFK78 hardware version. This is defined in rules.mk, but can be overidden here if desired +# # +# # RevB - first public release, uses atmega32u4, has audio, ISSI matrix split between RGB and backlight +# # RevC/D - at90usb1286, no audio, ISSI device 0 is backlight, 4 is RGB +# # +# # Set to B, C or D +# LFK_REV = D + +# ifeq ($(LFK_REV), B) +# MCU = atmega32u4 +# else +# MCU = at90usb1286 +# endif +# OPT_DEFS += -DLFK_REV_$(LFK_REV) +# OPT_DEFS += -DUSB_PRODUCT=\"LFK_Rev$(LFK_REV)\" diff --git a/keyboards/lfkeyboards/lfkpad/lfkpad.c b/keyboards/lfkeyboards/lfkpad/lfkpad.c new file mode 100644 index 000000000..8caab8ba1 --- /dev/null +++ b/keyboards/lfkeyboards/lfkpad/lfkpad.c @@ -0,0 +1,176 @@ +#include +#include +#include +#include "lfkpad.h" +#include "keymap.h" +#include "issi.h" +#include "TWIlib.h" +#include "lighting.h" +#include "debug.h" +#include "quantum.h" + +uint16_t click_hz = CLICK_HZ; +uint16_t click_time = CLICK_MS; +uint8_t click_toggle = CLICK_ENABLED; + + +void matrix_init_kb(void) +{ + matrix_init_user(); +#ifndef AUDIO_ENABLE + // If we're not using the audio pin, drive it low + sbi(DDRC, 6); + cbi(PORTC, 6); +#endif + +#ifdef ISSI_ENABLE + issi_init(); +#endif +#ifdef WATCHDOG_ENABLE + // This is done after turning the layer LED red, if we're caught in a loop + // we should get a flashing red light + wdt_enable(WDTO_500MS); +#endif + +} + +void matrix_scan_kb(void) +{ +#ifdef WATCHDOG_ENABLE + wdt_reset(); +#endif +#ifdef ISSI_ENABLE + // switch/underglow lighting update + static uint32_t issi_device = 0; + static uint32_t twi_last_ready = 0; + if(twi_last_ready > 1000){ + // Its been way too long since the last ISSI update, reset the I2C bus and start again + dprintf("TWI failed to recover, TWI re-init\n"); + twi_last_ready = 0; + TWIInit(); + force_issi_refresh(); + } + if(isTWIReady()){ + twi_last_ready = 0; + // If the i2c bus is available, kick off the issi update, alternate between devices + update_issi(issi_device, issi_device); + if(issi_device){ + issi_device = 0; + }else{ + issi_device = 3; + } + }else{ + twi_last_ready++; + } +#endif + matrix_scan_user(); +} + +void click(uint16_t freq, uint16_t duration){ +#ifdef AUDIO_ENABLE + if(freq >= 100 && freq <= 20000 && duration < 100){ + play_note(freq, 10); + for (uint16_t i = 0; i < duration; i++){ + _delay_ms(1); + } + stop_all_notes(); + } +#endif +} + +bool process_record_kb(uint16_t keycode, keyrecord_t* record) +{ + if (click_toggle && record->event.pressed){ + click(click_hz, click_time); + } + if (keycode == RESET) { + reset_keyboard_kb(); + } else { + } + return process_record_user(keycode, record); +} + +void action_function(keyrecord_t *event, uint8_t id, uint8_t opt) +{ +#ifdef AUDIO_ENABLE + int8_t sign = 1; +#endif + if(id == LFK_ESC_TILDE){ + // Send ~ on shift-esc + void (*method)(uint8_t) = (event->event.pressed) ? &add_key : &del_key; + uint8_t shifted = get_mods() & (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)); + if(layer_state == 0){ + method(shifted ? KC_GRAVE : KC_ESCAPE); + }else{ + method(shifted ? KC_ESCAPE : KC_GRAVE); + } + send_keyboard_report(); + }else if(event->event.pressed){ + switch(id){ + case LFK_SET_DEFAULT_LAYER: + // set/save the current base layer to eeprom, falls through to LFK_CLEAR + eeconfig_update_default_layer(1UL << opt); + default_layer_set(1UL << opt); + case LFK_CLEAR: + // Go back to default layer + layer_clear(); + break; +#ifdef AUDIO_ENABLE + case LFK_CLICK_FREQ_LOWER: + sign = -1; // continue to next statement + case LFK_CLICK_FREQ_HIGHER: + click_hz += sign * 100; + click(click_hz, click_time); + break; + case LFK_CLICK_TOGGLE: + if(click_toggle){ + click_toggle = 0; + click(4000, 100); + click(1000, 100); + }else{ + click_toggle = 1; + click(1000, 100); + click(4000, 100); + } + break; + case LFK_CLICK_TIME_SHORTER: + sign = -1; // continue to next statement + case LFK_CLICK_TIME_LONGER: + click_time += sign; + click(click_hz, click_time); + break; +#endif + } + } +} + +void reset_keyboard_kb(){ +#ifdef WATCHDOG_ENABLE + MCUSR = 0; + wdt_disable(); + wdt_reset(); +#endif + reset_keyboard(); +} + +void led_set_kb(uint8_t usb_led) +{ + led_set_user(usb_led); +} + +// LFK lighting info +const uint8_t rgb_matrices[] = {0, 1}; +const uint8_t rgb_sequence[] = { + 32, 1, 2, 3, + 31, 30, 5, 6, + 28, 27, 7, 8, + 17, 18, 9, + 19, 21, 11, 12, + 22, 14, + + 16, 26, + 4, 25, + 13, 24, + 20 + +}; diff --git a/keyboards/lfkeyboards/lfkpad/lfkpad.h b/keyboards/lfkeyboards/lfkpad/lfkpad.h new file mode 100644 index 000000000..d7d66ea7a --- /dev/null +++ b/keyboards/lfkeyboards/lfkpad/lfkpad.h @@ -0,0 +1,73 @@ +#ifndef LFKPAD_H +#define LFKPAD_H + +/* if the kb.h file exists (because we're running from qmkbuilder) include it */ +#if __has_include("kb.h") +#include "kb.h" +#endif + +#include "quantum.h" +#include "matrix.h" +#include + +#ifndef cbi +#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) +#endif + +#ifndef sbi +#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) +#endif + + +typedef struct RGB_Color { + uint16_t red; + uint16_t green; + uint16_t blue; +} RGB_Color; + +typedef struct Layer_Info { + uint32_t layer; + uint32_t mask; + RGB_Color color; +} Layer_Info; + +extern const uint32_t layer_count; +extern const Layer_Info layer_info[]; + +enum action_functions { + LFK_CLEAR = 0, // Resets all layers + LFK_ESC_TILDE, // esc+lshift = ~ + LFK_SET_DEFAULT_LAYER, // changes and saves current base layer to eeprom + LFK_CLICK_TOGGLE, // Adjusts click duration + LFK_CLICK_FREQ_HIGHER, // Adjusts click frequency + LFK_CLICK_FREQ_LOWER, // Adjusts click frequency + LFK_CLICK_TIME_LONGER, // Adjusts click duration + LFK_CLICK_TIME_SHORTER, // Adjusts click duration + LFK_DEBUG_SETTINGS, // prints LED and click settings to HID + LFK_LED_TEST // cycles through switch and RGB LEDs +}; + +#define CLICK_HZ 500 +#define CLICK_MS 2 +#define CLICK_ENABLED 0 + +void reset_keyboard_kb(void); +void click(uint16_t freq, uint16_t duration); + +#define KEYMAP( \ + k00, k01, k02, k03,\ + k10, k11, k12, k13,\ + k20, k21, k22, k23,\ + k30, k31, k32,\ + k40, k41, k42, k43,\ + k50, k52\ +) { \ + { k00, k01, k02, k03 }, \ + { k10, k11, k12, k13 }, \ + { k20, k21, k22, k23 }, \ + { k30, k31, k32, KC_NO }, \ + { k40, k41, k42, k43 }, \ + { k50, KC_NO, k52, KC_NO } \ +} + +#endif //LFKPAD_H \ No newline at end of file diff --git a/keyboards/lfkeyboards/lfkpad/readme.md b/keyboards/lfkeyboards/lfkpad/readme.md new file mode 100644 index 000000000..5f23d988a --- /dev/null +++ b/keyboards/lfkeyboards/lfkpad/readme.md @@ -0,0 +1,28 @@ +bluepad keyboard firmware +====================== + +## Quantum MK Firmware + +For the full Quantum feature list, see [the parent readme.md](/doc/readme.md). + +## Building + +Download or clone the whole firmware and navigate to the keyboards/bluepad folder. Once your dev env is setup, you'll be able to type `make` to generate your .hex - you can then use the Teensy Loader to program your .hex file. + +Depending on which keymap you would like to use, you will have to compile slightly differently. + +### Default + +To build with the default keymap, simply run `make`. + +### Other Keymaps + +Several version of keymap are available in advance but you are recommended to define your favorite layout yourself. To define your own keymap create a folder with the name of your keymap in the keymaps folder, and see keymap documentation (you can find in top readme.md) and existant keymap files. + +To build the firmware binary hex file with a keymap just do `make` with `keymap` option like: + +``` +$ make keymap=[default|jack|] +``` + +Keymaps follow the format **__keymap.c__** and are stored in folders in the `keymaps` folder, eg `keymaps/my_keymap/` diff --git a/keyboards/lfkeyboards/lfkpad/rules.mk b/keyboards/lfkeyboards/lfkpad/rules.mk new file mode 100644 index 000000000..0b865537e --- /dev/null +++ b/keyboards/lfkeyboards/lfkpad/rules.mk @@ -0,0 +1,14 @@ +SRC = TWIlib.c issi.c lighting.c + +MCU = atmega32u4 +OPT_DEFS += -DBOOTLOADER_SIZE=4096 + +F_CPU = 16000000 +F_USB = $(F_CPU) +ARCH = AVR8 + +# Interrupt driven control endpoint task(+60) +OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT +ifndef QUANTUM_DIR + include ../../Makefile +endif -- cgit v1.2.3-24-g4f1b