From 5ca3bde10aa5d8057895475840800544599ea33f Mon Sep 17 00:00:00 2001 From: Ralf Schmitt Date: Tue, 18 Mar 2014 20:06:24 +0100 Subject: Support for Lightsaber keyboard --- keyboard/lightsaber/Makefile.lufa | 125 +++++++++++++++ keyboard/lightsaber/Makefile.pjrc | 101 +++++++++++++ keyboard/lightsaber/README.md | 110 ++++++++++++++ keyboard/lightsaber/config.h | 43 ++++++ keyboard/lightsaber/keymap.c | 77 ++++++++++ keyboard/lightsaber/keymap_winkey.h | 12 ++ keyboard/lightsaber/led.c | 24 +++ keyboard/lightsaber/matrix.c | 292 ++++++++++++++++++++++++++++++++++++ 8 files changed, 784 insertions(+) create mode 100644 keyboard/lightsaber/Makefile.lufa create mode 100644 keyboard/lightsaber/Makefile.pjrc create mode 100644 keyboard/lightsaber/README.md create mode 100644 keyboard/lightsaber/config.h create mode 100644 keyboard/lightsaber/keymap.c create mode 100644 keyboard/lightsaber/keymap_winkey.h create mode 100644 keyboard/lightsaber/led.c create mode 100644 keyboard/lightsaber/matrix.c (limited to 'keyboard') diff --git a/keyboard/lightsaber/Makefile.lufa b/keyboard/lightsaber/Makefile.lufa new file mode 100644 index 0000000000..6982b51f70 --- /dev/null +++ b/keyboard/lightsaber/Makefile.lufa @@ -0,0 +1,125 @@ +#---------------------------------------------------------------------------- +# On command line: +# +# make all = Make software. +# +# make clean = Clean out built project files. +# +# make coff = Convert ELF to AVR COFF. +# +# make extcoff = Convert ELF to AVR Extended COFF. +# +# make program = Download the hex file to the device. +# Please customize your programmer settings(PROGRAM_CMD) +# +# make teensy = Download the hex file to the device, using teensy_loader_cli. +# (must have teensy_loader_cli installed). +# +# make dfu = Download the hex file to the device, using dfu-programmer (must +# have dfu-programmer installed). +# +# make flip = Download the hex file to the device, using Atmel FLIP (must +# have Atmel FLIP installed). +# +# make dfu-ee = Download the eeprom file to the device, using dfu-programmer +# (must have dfu-programmer installed). +# +# make flip-ee = Download the eeprom file to the device, using Atmel FLIP +# (must have Atmel FLIP installed). +# +# make debug = Start either simulavr or avarice as specified for debugging, +# with avr-gdb or avr-insight as the front end for debugging. +# +# make filename.s = Just compile filename.c into the assembler code only. +# +# make filename.i = Create a preprocessed source file for use in submitting +# bug reports to the GCC project. +# +# To rebuild project do "make clean" then "make all". +#---------------------------------------------------------------------------- + +# Target file name (without extension). +TARGET = lightsaber_lufa + +# Directory common source filess exist +TOP_DIR = ../.. + +# Directory keyboard dependent files exist +TARGET_DIR = . + + +# List C source files here. (C dependencies are automatically generated.) +SRC += keymap.c \ + led.c \ + matrix.c + +CONFIG_H = config.h + + +# MCU name +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 = 8000000 + + +# +# 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) + + +# Build Options +# comment out to disable the options. +# +BOOTMAGIC_ENABLE = yes # 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 +#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend +#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA +#BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality + + +# Boot Section Size in bytes +# Teensy halfKay 512 +# Atmel DFU loader 4096 +# LUFA bootloader 4096 +OPT_DEFS += -DBOOTLOADER_SIZE=4096 + + +# Search Path +VPATH += $(TARGET_DIR) +VPATH += $(TOP_DIR) + +include $(TOP_DIR)/protocol/lufa.mk +include $(TOP_DIR)/common.mk +include $(TOP_DIR)/rules.mk + +winkey: OPT_DEFS += -DLAYOUT_WINKEY +winkey: all diff --git a/keyboard/lightsaber/Makefile.pjrc b/keyboard/lightsaber/Makefile.pjrc new file mode 100644 index 0000000000..1c5a9710f4 --- /dev/null +++ b/keyboard/lightsaber/Makefile.pjrc @@ -0,0 +1,101 @@ +#---------------------------------------------------------------------------- +# On command line: +# +# make all = Make software. +# +# make clean = Clean out built project files. +# +# make coff = Convert ELF to AVR COFF. +# +# make extcoff = Convert ELF to AVR Extended COFF. +# +# make program = Download the hex file to the device. +# Please customize your programmer settings(PROGRAM_CMD) +# +# make teensy = Download the hex file to the device, using teensy_loader_cli. +# (must have teensy_loader_cli installed). +# +# make dfu = Download the hex file to the device, using dfu-programmer (must +# have dfu-programmer installed). +# +# make flip = Download the hex file to the device, using Atmel FLIP (must +# have Atmel FLIP installed). +# +# make dfu-ee = Download the eeprom file to the device, using dfu-programmer +# (must have dfu-programmer installed). +# +# make flip-ee = Download the eeprom file to the device, using Atmel FLIP +# (must have Atmel FLIP installed). +# +# make debug = Start either simulavr or avarice as specified for debugging, +# with avr-gdb or avr-insight as the front end for debugging. +# +# make filename.s = Just compile filename.c into the assembler code only. +# +# make filename.i = Create a preprocessed source file for use in submitting +# bug reports to the GCC project. +# +# To rebuild project do "make clean" then "make all". +#---------------------------------------------------------------------------- + +# Target file name (without extension). +TARGET = lightsaber_pjrc + +# Directory common source filess exist +TOP_DIR = ../.. + +# Directory keyboard dependent files exist +TARGET_DIR = . + +# keyboard dependent files +SRC = keymap.c \ + matrix.c \ + led.c \ + backlight.c + +CONFIG_H = config.h + + +# MCU name, you MUST set this to match the board you are using +# type "make clean" after changing this, so all files will be rebuilt +#MCU = at90usb162 # Teensy 1.0 +MCU = atmega32u4 # Teensy 2.0 +#MCU = at90usb646 # Teensy++ 1.0 +#MCU = at90usb1286 # Teensy++ 2.0 + + +# Processor frequency. +# Normally the first thing your program should do is set the clock prescaler, +# so your program will run at the correct speed. You should also set this +# variable to same clock speed. The _delay_ms() macro uses this, and many +# examples use this variable to calculate timings. Do not add a "UL" here. +F_CPU = 8000000 + + +# Build Options +# comment out to disable the options. +# +BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) +#MOUSEKEY_ENABLE = yes # Mouse keys(+5000) +EXTRAKEY_ENABLE = yes # Audio control and System control(+600) +CONSOLE_ENABLE = yes # Console for debug +COMMAND_ENABLE = yes # Commands for debug and configuration +#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend +#NKRO_ENABLE = yes # USB Nkey Rollover(+500) +#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support +BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality + + +# Search Path +VPATH += $(TARGET_DIR) +VPATH += $(TOP_DIR) + +include $(TOP_DIR)/protocol/pjrc.mk +include $(TOP_DIR)/common.mk +include $(TOP_DIR)/rules.mk + +winkey: OPT_DEFS += -DLAYOUT_WINKEY +winkey: all + +winkeyless: OPT_DEFS += -DLAYOUT_WINKEYLESS +winkeyless: all diff --git a/keyboard/lightsaber/README.md b/keyboard/lightsaber/README.md new file mode 100644 index 0000000000..dc35870caa --- /dev/null +++ b/keyboard/lightsaber/README.md @@ -0,0 +1,110 @@ +KMAC keyboard firmware +====================== +Korean custom keyboard designed by Byungho Kim and KBDMania community. + +*Note that this is not the official firmware* + +Supported models +---------------- +At the moment only the TKL models is supported. + + +Build +----- +Move to this directory then just run `make` like: + + $ make -f Makefile.[pjrc|lufa] [winkey|winkeyless] + +Use `Makefile.pjrc` if you want to use PJRC stack or use `Makefile.lufa` for LUFA stack. + + +Bootloader +--------- +The PCB is hardwired to run the bootloader if the key at the `Caps Lock` position is held down when connecting the keyboard. + +It is still possible to use Boot Magic and Command to access the bootloader though. + + +Keymap +------ +There are 2 different types of PCB. +They each have their own keymap file. + +To customize a keymap: + 1. Edit the file that corresponds to your PCB. + 2. Specify your layout when building. + +### 1. Winkey +This is the default keymap. + +See [keymap_winkey.h](keymap_winkey.h) for detail. + +#### 1.0. Winkey Default Layer + ,---. ,---------------. ,---------------. ,---------------. ,-----------. + |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| + `---' `---------------' `---------------' `---------------' `-----------' + ,-----------------------------------------------------------. ,-----------. + |~ | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |Ins|Hom|PgU| + |-----------------------------------------------------------| |-----------| + |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD| + |-----------------------------------------------------------| '-----------' + |Fn0 | A| S| D| F| G| H| J| K| L| ;| '|Return | + |-----------------------------------------------------------| ,---. + |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | |Up | + |-----------------------------------------------------------| ,-----------. + |Ctl|Gui|Alt| Space |Alt|Gui|App|Ctl| |Lef|Dow|Rig| + `-----------------------------------------------------------' `-----------' + +#### 1.1. Winkey Media Layer + ,---. ,---------------. ,---------------. ,---------------. ,-----------. + |Led| | | | | | | | | | | | | | | | | | |Slp| + `---' `---------------' `---------------' `---------------' `-----------' + ,-----------------------------------------------------------. ,-----------. + | | | | | | | | | | |Mut|V- |V+ | | | | | | + |-----------------------------------------------------------| |-----------| + | | | | | | | | | |Stp|Ply|Prv|Nxt|Media| | | | | + |-----------------------------------------------------------| '-----------' + | | | | | | | | | | | | | | + |-----------------------------------------------------------| ,---. + | | | |Clc| | | | | | | |Caps | | | + |-----------------------------------------------------------| ,-----------. + | | | | | | | | | | | | | + `-----------------------------------------------------------' `-----------' + + +### 2. Winkeyless +Layout with 1.5 unit modifiers. + +See [keymap_winkeyless.h](keymap_winkeyless.h) for detail. + +#### 2.0. Winkeyless Default Layer + ,---. ,---------------. ,---------------. ,---------------. ,-----------. + |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| + `---' `---------------' `---------------' `---------------' `-----------' + ,-----------------------------------------------------------. ,-----------. + |~ | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |Ins|Hom|PgU| + |-----------------------------------------------------------| |-----------| + |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD| + |-----------------------------------------------------------| '-----------' + |Fn0 | A| S| D| F| G| H| J| K| L| ;| '|Return | + |-----------------------------------------------------------| ,---. + |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | |Up | + |-----------------------------------------------------------| ,-----------. + |Ctl |Gui|Alt | Space |Alt |Gui|Ctl | |Lef|Dow|Rig| + `-----------------------------------------------------------' `-----------' + +#### 2.1. Winkeyless Media Layer + ,---. ,---------------. ,---------------. ,---------------. ,-----------. + |Led| | | | | | | | | | | | | | | | | | |Slp| + `---' `---------------' `---------------' `---------------' `-----------' + ,-----------------------------------------------------------. ,-----------. + | | | | | | | | | | |Mut|V- |V+ | | | | | | + |-----------------------------------------------------------| |-----------| + | | | | | | | | | |Stp|Ply|Prv|Nxt|Media| | | | | + |-----------------------------------------------------------| '-----------' + | | | | | | | | | | | | | | + |-----------------------------------------------------------| ,---. + | | | |Clc| | | | | | | |Caps | | | + |-----------------------------------------------------------| ,-----------. + | | | | | | | | | | | | + `-----------------------------------------------------------' `-----------' diff --git a/keyboard/lightsaber/config.h b/keyboard/lightsaber/config.h new file mode 100644 index 0000000000..b8de6adbff --- /dev/null +++ b/keyboard/lightsaber/config.h @@ -0,0 +1,43 @@ +/* +Copyright 2013 Mathias Andersson + +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 + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x6050 +#define DEVICE_VER 0x0104 +#define MANUFACTURER Duck +#define PRODUCT Lightsaber + +/* message strings */ +#define DESCRIPTION t.m.k. keyboard firmware for Lightsaber + +/* matrix size */ +#define MATRIX_ROWS 6 +#define MATRIX_COLS 18 + +/* Set 0 if need no debouncing */ +#define DEBOUNCE 5 + +/* key combination for command */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ +) + +#endif diff --git a/keyboard/lightsaber/keymap.c b/keyboard/lightsaber/keymap.c new file mode 100644 index 0000000000..398e51ec4a --- /dev/null +++ b/keyboard/lightsaber/keymap.c @@ -0,0 +1,77 @@ +/* +Copyright 2014 Ralf Schmitt + +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 . +*/ + +/* + * Keymap for Lightsaber controller + */ +#include +#include +#include +#include "keycode.h" +#include "action.h" +#include "action_macro.h" +#include "report.h" +#include "host.h" +#include "debug.h" +#include "keymap.h" + +// Convert physical keyboard layout to matrix array. +// This is a macro to define keymap easily in keyboard layout form. +#define KEYMAP( \ + K5A, K5B, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5P, K5Q, K5R, \ + K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, K4N, K4O, K4P, K4Q, K4R, \ + K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3N, K3O, K3P, K3Q, K3R, \ + K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2M, K2N, K2O, K2P, K2Q, K2R, \ + K1A, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1L, K1M, K1N, K1O, K1P, K1Q, K1R, \ + K0A, K0B, K0C, K0G, K0K, K0L, K0M, K0N, K0O, K0P, K0Q, K0R \ +) { \ +/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 */ \ +/* 5 */ { KC_##K5A, KC_##K5B, KC_##K5C, KC_##K5D, KC_##K5E, KC_##K5F, KC_##K5G, KC_##K5H, KC_##K5I, KC_##K5J, KC_##K5K, KC_##K5L, KC_##K5M, KC_##K5N, KC_##K5O, KC_##K5P, KC_##K5Q, KC_##K5R}, \ +/* 4 */ { KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E, KC_##K4F, KC_##K4G, KC_##K4H, KC_##K4I, KC_##K4J, KC_##K4K, KC_##K4L, KC_##K4M, KC_##K4N, KC_##K4O, KC_##K4P, KC_##K4Q, KC_##K4R}, \ +/* 3 */ { KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_##K3F, KC_##K3G, KC_##K3H, KC_##K3I, KC_##K3J, KC_##K3K, KC_##K3L, KC_##K3M, KC_##K3N, KC_##K3O, KC_##K3P, KC_##K3Q, KC_##K3R}, \ +/* 2 */ { KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F, KC_##K2G, KC_##K2H, KC_##K2I, KC_##K2J, KC_##K2K, KC_##K2L, KC_##K2M, KC_##K2N, KC_##K2O, KC_##K2P, KC_##K2Q, KC_##K2R}, \ +/* 1 */ { KC_##K1A, KC_##K1C, KC_##K1D, KC_##K1E, KC_##K1F, KC_##K1G, KC_##K1H, KC_##K1I, KC_##K1J, KC_##K1K, KC_##K1L, KC_NO, KC_##K1M, KC_##K1N, KC_##K1O, KC_##K1P, KC_##K1Q, KC_##K1R}, \ +/* 0 */ { KC_##K0A, KC_##K0B, KC_##K0C, KC_NO, KC_NO, KC_##K0G, KC_NO, KC_NO, KC_##K0K, KC_NO, KC_##K0L, KC_NO, KC_##K0M, KC_##K0N, KC_##K0O, KC_##K0P, KC_##K0Q, KC_##K0R} \ +} + +#include "keymap_winkey.h" + +#define KEYMAPS_SIZE (sizeof(keymaps) / sizeof(keymaps[0])) +#define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0])) + +/* translates key to keycode */ +uint8_t keymap_key_to_keycode(uint8_t layer, key_t key) +{ + if (layer < KEYMAPS_SIZE) { + return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); + } else { + // fall back to layer 0 + return pgm_read_byte(&keymaps[0][(key.row)][(key.col)]); + } +} + +/* translates Fn keycode to action */ +action_t keymap_fn_to_action(uint8_t keycode) +{ + action_t action; + if (FN_INDEX(keycode) < FN_ACTIONS_SIZE) { + action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]); + } else { + action.code = ACTION_NO; + } + return action; +} diff --git a/keyboard/lightsaber/keymap_winkey.h b/keyboard/lightsaber/keymap_winkey.h new file mode 100644 index 0000000000..510fa7f72e --- /dev/null +++ b/keyboard/lightsaber/keymap_winkey.h @@ -0,0 +1,12 @@ +static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + KEYMAP(\ + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, INS, PSCR, SLCK, BRK, \ + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, NUMLOCK,KP_SLASH,KP_ASTERISK,KP_MINUS, \ + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, KP_7, KP_8, KP_9, KP_PLUS, \ + CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,NO, ENT, KP_4, KP_5, KP_6, NO, \ + LSFT, Z, X, C, V, B, N, M, COMM,DOT, SLSH,NO, RSFT, KP_1, KP_2, KP_3, KP_ENTER, \ + LCTL,LGUI,LALT, SPC, NO, RALT,RGUI,RCTL, KP_0, NO, KP_DOT, NO) +}; + +static const uint16_t PROGMEM fn_actions[] = { +}; diff --git a/keyboard/lightsaber/led.c b/keyboard/lightsaber/led.c new file mode 100644 index 0000000000..9c98f9db2c --- /dev/null +++ b/keyboard/lightsaber/led.c @@ -0,0 +1,24 @@ +/* +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 . +*/ + +#include +#include "stdint.h" +#include "led.h" + +void led_set(uint8_t usb_led) +{ +} diff --git a/keyboard/lightsaber/matrix.c b/keyboard/lightsaber/matrix.c new file mode 100644 index 0000000000..e3eca84df8 --- /dev/null +++ b/keyboard/lightsaber/matrix.c @@ -0,0 +1,292 @@ +/* +Copyright 2014 Ralf Schmitt + +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 DEBOUNCE +# define DEBOUNCE 0 +#endif +static uint8_t debouncing = DEBOUNCE; + +/* matrix state(1:on, 0:off) */ +static matrix_row_t matrix[MATRIX_ROWS]; +static matrix_row_t matrix_debouncing[MATRIX_ROWS]; + +static uint8_t read_rows(void); +static uint8_t read_fwkey(void); +static void init_rows(void); +static void unselect_cols(void); +static void select_col(uint8_t col); + +inline +uint8_t matrix_rows(void) +{ + return MATRIX_ROWS; +} + +inline +uint8_t matrix_cols(void) +{ + return MATRIX_COLS; +} + +void matrix_init(void) +{ + unselect_cols(); + init_rows(); + // initialize matrix state: all keys off + for (uint8_t i=0; i < MATRIX_ROWS; i++) { + matrix[i] = 0; + matrix_debouncing[i] = 0; + } +} + +uint8_t matrix_scan(void) +{ + for (uint8_t col = 0; col < MATRIX_COLS; col++) { // 0-17 + select_col(col); + _delay_us(3); // TODO: Determine the correct value needed here. + uint8_t rows = read_rows(); + // Use the otherwise unused col: 12 row: 3 for firmware. + if(col == 12) { + rows |= read_fwkey(); + } + for (uint8_t row = 0; row < MATRIX_ROWS; row++) { // 0-5 + bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1< Date: Wed, 19 Mar 2014 00:21:45 +0100 Subject: Updated Lightsaber read me --- keyboard/lightsaber/README.md | 92 ++----------------------------------------- 1 file changed, 4 insertions(+), 88 deletions(-) (limited to 'keyboard') diff --git a/keyboard/lightsaber/README.md b/keyboard/lightsaber/README.md index dc35870caa..bd2b3fb528 100644 --- a/keyboard/lightsaber/README.md +++ b/keyboard/lightsaber/README.md @@ -1,12 +1,12 @@ -KMAC keyboard firmware +Lightsaber keyboard firmware ====================== -Korean custom keyboard designed by Byungho Kim and KBDMania community. +Korean custom keyboard designed by Duck. *Note that this is not the official firmware* Supported models ---------------- -At the moment only the TKL models is supported. +All pcb options are supported. Build @@ -20,91 +20,7 @@ Use `Makefile.pjrc` if you want to use PJRC stack or use `Makefile.lufa` for LUF Bootloader --------- -The PCB is hardwired to run the bootloader if the key at the `Caps Lock` position is held down when connecting the keyboard. +The PCB is hardwired to run the bootloader if the key at the `one above backspace` position is held down when connecting the keyboard. It is still possible to use Boot Magic and Command to access the bootloader though. - -Keymap ------- -There are 2 different types of PCB. -They each have their own keymap file. - -To customize a keymap: - 1. Edit the file that corresponds to your PCB. - 2. Specify your layout when building. - -### 1. Winkey -This is the default keymap. - -See [keymap_winkey.h](keymap_winkey.h) for detail. - -#### 1.0. Winkey Default Layer - ,---. ,---------------. ,---------------. ,---------------. ,-----------. - |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| - `---' `---------------' `---------------' `---------------' `-----------' - ,-----------------------------------------------------------. ,-----------. - |~ | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |Ins|Hom|PgU| - |-----------------------------------------------------------| |-----------| - |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD| - |-----------------------------------------------------------| '-----------' - |Fn0 | A| S| D| F| G| H| J| K| L| ;| '|Return | - |-----------------------------------------------------------| ,---. - |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | |Up | - |-----------------------------------------------------------| ,-----------. - |Ctl|Gui|Alt| Space |Alt|Gui|App|Ctl| |Lef|Dow|Rig| - `-----------------------------------------------------------' `-----------' - -#### 1.1. Winkey Media Layer - ,---. ,---------------. ,---------------. ,---------------. ,-----------. - |Led| | | | | | | | | | | | | | | | | | |Slp| - `---' `---------------' `---------------' `---------------' `-----------' - ,-----------------------------------------------------------. ,-----------. - | | | | | | | | | | |Mut|V- |V+ | | | | | | - |-----------------------------------------------------------| |-----------| - | | | | | | | | | |Stp|Ply|Prv|Nxt|Media| | | | | - |-----------------------------------------------------------| '-----------' - | | | | | | | | | | | | | | - |-----------------------------------------------------------| ,---. - | | | |Clc| | | | | | | |Caps | | | - |-----------------------------------------------------------| ,-----------. - | | | | | | | | | | | | | - `-----------------------------------------------------------' `-----------' - - -### 2. Winkeyless -Layout with 1.5 unit modifiers. - -See [keymap_winkeyless.h](keymap_winkeyless.h) for detail. - -#### 2.0. Winkeyless Default Layer - ,---. ,---------------. ,---------------. ,---------------. ,-----------. - |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| - `---' `---------------' `---------------' `---------------' `-----------' - ,-----------------------------------------------------------. ,-----------. - |~ | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |Ins|Hom|PgU| - |-----------------------------------------------------------| |-----------| - |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD| - |-----------------------------------------------------------| '-----------' - |Fn0 | A| S| D| F| G| H| J| K| L| ;| '|Return | - |-----------------------------------------------------------| ,---. - |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | |Up | - |-----------------------------------------------------------| ,-----------. - |Ctl |Gui|Alt | Space |Alt |Gui|Ctl | |Lef|Dow|Rig| - `-----------------------------------------------------------' `-----------' - -#### 2.1. Winkeyless Media Layer - ,---. ,---------------. ,---------------. ,---------------. ,-----------. - |Led| | | | | | | | | | | | | | | | | | |Slp| - `---' `---------------' `---------------' `---------------' `-----------' - ,-----------------------------------------------------------. ,-----------. - | | | | | | | | | | |Mut|V- |V+ | | | | | | - |-----------------------------------------------------------| |-----------| - | | | | | | | | | |Stp|Ply|Prv|Nxt|Media| | | | | - |-----------------------------------------------------------| '-----------' - | | | | | | | | | | | | | | - |-----------------------------------------------------------| ,---. - | | | |Clc| | | | | | | |Caps | | | - |-----------------------------------------------------------| ,-----------. - | | | | | | | | | | | | - `-----------------------------------------------------------' `-----------' -- cgit v1.2.3 From 526d988a0caadc1a48bea862f605c9cee90c3dd3 Mon Sep 17 00:00:00 2001 From: Ralf Schmitt Date: Wed, 19 Mar 2014 23:58:08 +0100 Subject: Added basic led+backlight support --- keyboard/lightsaber/Makefile.lufa | 3 +- keyboard/lightsaber/backlight.c | 56 +++++++++++++++++++++++++++++++++++++ keyboard/lightsaber/config.h | 3 ++ keyboard/lightsaber/keymap_winkey.h | 3 +- keyboard/lightsaber/led.c | 32 ++++++++++++++++++++- 5 files changed, 94 insertions(+), 3 deletions(-) create mode 100644 keyboard/lightsaber/backlight.c (limited to 'keyboard') diff --git a/keyboard/lightsaber/Makefile.lufa b/keyboard/lightsaber/Makefile.lufa index 6982b51f70..25816ac03e 100644 --- a/keyboard/lightsaber/Makefile.lufa +++ b/keyboard/lightsaber/Makefile.lufa @@ -51,6 +51,7 @@ TARGET_DIR = . # List C source files here. (C dependencies are automatically generated.) SRC += keymap.c \ led.c \ + backlight.c \ matrix.c CONFIG_H = config.h @@ -103,7 +104,7 @@ CONSOLE_ENABLE = yes # Console for debug(+400) COMMAND_ENABLE = yes # Commands for debug and configuration #SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend #NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA -#BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality +BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality # Boot Section Size in bytes diff --git a/keyboard/lightsaber/backlight.c b/keyboard/lightsaber/backlight.c new file mode 100644 index 0000000000..b28200807c --- /dev/null +++ b/keyboard/lightsaber/backlight.c @@ -0,0 +1,56 @@ +/* +Copyright 2014 Ralf Schmitt + +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 "backlight.h" + +/* Backlight pin configuration + * + * Alphas PB1 (high) + * Numeric PB2 (high) + * Mod+Num PB3 (high) + * Backside PD6 (high) + * TopRight PD7 (low) + * F-Row PE6 (high) + * + */ +void backlight_set(uint8_t level) +{ + // Set as output. + DDRB |= (1<<1) | (1<<2) | (1<<3); + DDRD |= (1<<6) | (1<<7); + DDRE |= (1<<6); + + if(level & (1<<0)) + { + PORTB &= ~(1<<1); + PORTB &= ~(1<<2); + PORTB &= ~(1<<3); + PORTD &= ~(1<<6); + PORTD |= (1<<7); + PORTE &= ~(1<<6); + } + else + { + PORTB |= (1<<1); + PORTB |= (1<<2); + PORTB |= (1<<3); + PORTD |= (1<<6); + PORTD &= ~(1<<7); + PORTE |= (1<<6); + } +} diff --git a/keyboard/lightsaber/config.h b/keyboard/lightsaber/config.h index b8de6adbff..d971d038e3 100644 --- a/keyboard/lightsaber/config.h +++ b/keyboard/lightsaber/config.h @@ -32,6 +32,9 @@ along with this program. If not, see . #define MATRIX_ROWS 6 #define MATRIX_COLS 18 +/* number of backlight levels */ +#define BACKLIGHT_LEVELS 1 + /* Set 0 if need no debouncing */ #define DEBOUNCE 5 diff --git a/keyboard/lightsaber/keymap_winkey.h b/keyboard/lightsaber/keymap_winkey.h index 510fa7f72e..9d558ae734 100644 --- a/keyboard/lightsaber/keymap_winkey.h +++ b/keyboard/lightsaber/keymap_winkey.h @@ -3,10 +3,11 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, INS, PSCR, SLCK, BRK, \ GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, NUMLOCK,KP_SLASH,KP_ASTERISK,KP_MINUS, \ TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, KP_7, KP_8, KP_9, KP_PLUS, \ - CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,NO, ENT, KP_4, KP_5, KP_6, NO, \ + CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,FN0, ENT, KP_4, KP_5, KP_6, NO, \ LSFT, Z, X, C, V, B, N, M, COMM,DOT, SLSH,NO, RSFT, KP_1, KP_2, KP_3, KP_ENTER, \ LCTL,LGUI,LALT, SPC, NO, RALT,RGUI,RCTL, KP_0, NO, KP_DOT, NO) }; static const uint16_t PROGMEM fn_actions[] = { + [0] = ACTION_BACKLIGHT_STEP() }; diff --git a/keyboard/lightsaber/led.c b/keyboard/lightsaber/led.c index 9c98f9db2c..c3f85427f5 100644 --- a/keyboard/lightsaber/led.c +++ b/keyboard/lightsaber/led.c @@ -1,5 +1,5 @@ /* -Copyright 2012 Jun Wako +Copyright 2014 Ralf Schmitt 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 @@ -19,6 +19,36 @@ along with this program. If not, see . #include "stdint.h" #include "led.h" +/* LED pin configuration + * + * Caps PB0 (low) + * NumLock PB4 (low) + * + */ void led_set(uint8_t usb_led) { + // Set as output. + DDRB |= (1<<0) | (1<<4); + + if (usb_led & (1< Date: Sat, 22 Mar 2014 12:41:45 +0100 Subject: Lightsaber clean ups --- keyboard/lightsaber/Makefile.lufa | 6 +++--- keyboard/lightsaber/Makefile.pjrc | 11 ++--------- keyboard/lightsaber/README.md | 2 +- 3 files changed, 6 insertions(+), 13 deletions(-) (limited to 'keyboard') diff --git a/keyboard/lightsaber/Makefile.lufa b/keyboard/lightsaber/Makefile.lufa index 25816ac03e..b430efd229 100644 --- a/keyboard/lightsaber/Makefile.lufa +++ b/keyboard/lightsaber/Makefile.lufa @@ -49,10 +49,10 @@ TARGET_DIR = . # List C source files here. (C dependencies are automatically generated.) -SRC += keymap.c \ +SRC = keymap.c \ + matrix.c \ led.c \ - backlight.c \ - matrix.c + backlight.c CONFIG_H = config.h diff --git a/keyboard/lightsaber/Makefile.pjrc b/keyboard/lightsaber/Makefile.pjrc index 1c5a9710f4..58735a7ef0 100644 --- a/keyboard/lightsaber/Makefile.pjrc +++ b/keyboard/lightsaber/Makefile.pjrc @@ -56,12 +56,8 @@ SRC = keymap.c \ CONFIG_H = config.h -# MCU name, you MUST set this to match the board you are using -# type "make clean" after changing this, so all files will be rebuilt -#MCU = at90usb162 # Teensy 1.0 -MCU = atmega32u4 # Teensy 2.0 -#MCU = at90usb646 # Teensy++ 1.0 -#MCU = at90usb1286 # Teensy++ 2.0 +# MCU name +MCU = atmega32u4 # Processor frequency. @@ -96,6 +92,3 @@ include $(TOP_DIR)/rules.mk winkey: OPT_DEFS += -DLAYOUT_WINKEY winkey: all - -winkeyless: OPT_DEFS += -DLAYOUT_WINKEYLESS -winkeyless: all diff --git a/keyboard/lightsaber/README.md b/keyboard/lightsaber/README.md index bd2b3fb528..9dcd693095 100644 --- a/keyboard/lightsaber/README.md +++ b/keyboard/lightsaber/README.md @@ -13,7 +13,7 @@ Build ----- Move to this directory then just run `make` like: - $ make -f Makefile.[pjrc|lufa] [winkey|winkeyless] + $ make -f Makefile.[pjrc|lufa] Use `Makefile.pjrc` if you want to use PJRC stack or use `Makefile.lufa` for LUFA stack. -- cgit v1.2.3 From 1482fe92a0c5af6f0a84396a3f9fee73d59bb48f Mon Sep 17 00:00:00 2001 From: Ralf Schmitt Date: Sat, 22 Mar 2014 13:13:37 +0100 Subject: Added Lightsaber FN-layer --- keyboard/lightsaber/keymap_winkey.h | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'keyboard') diff --git a/keyboard/lightsaber/keymap_winkey.h b/keyboard/lightsaber/keymap_winkey.h index 9d558ae734..59ffd4a8fc 100644 --- a/keyboard/lightsaber/keymap_winkey.h +++ b/keyboard/lightsaber/keymap_winkey.h @@ -1,13 +1,21 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KEYMAP(\ - ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, INS, PSCR, SLCK, BRK, \ - GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, NUMLOCK,KP_SLASH,KP_ASTERISK,KP_MINUS, \ - TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, KP_7, KP_8, KP_9, KP_PLUS, \ - CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,FN0, ENT, KP_4, KP_5, KP_6, NO, \ - LSFT, Z, X, C, V, B, N, M, COMM,DOT, SLSH,NO, RSFT, KP_1, KP_2, KP_3, KP_ENTER, \ - LCTL,LGUI,LALT, SPC, NO, RALT,RGUI,RCTL, KP_0, NO, KP_DOT, NO) + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, INS, PSCR, SLCK, BRK, \ + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, NUMLOCK,KP_SLASH,KP_ASTERISK,KP_MINUS, \ + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, KP_7, KP_8, KP_9, KP_PLUS, \ + CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,FN0, ENT, KP_4, KP_5, KP_6, NO, \ + LSFT, Z, X, C, V, B, N, M, COMM,DOT, SLSH,NO, RSFT, KP_1, KP_2, KP_3, KP_ENTER, \ + LCTL,LGUI,LALT, SPC, NO, RALT,RGUI,RCTL, KP_0, NO, KP_DOT, NO), \ + KEYMAP(\ + CALC,MYCM,WSCH,WHOM,MAIL,MUTE,VOLD,VOLU,MSEL,MSTP,MPLY,MPRV,MNXT,TRNS, TRNS, WAKE, PWR, SLEP, \ + TRNS,TRNS,TRNS,TRNS,END ,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS, TRNS, TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS, TRNS, TRNS, \ + TRNS,TRNS,TRNS,TRNS,PGDN,TRNS,LEFT,DOWN,UP ,RGHT,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS, TRNS, TRNS, \ + TRNS, TRNS,TRNS,TRNS,TRNS,PGUP,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS, TRNS, TRNS, \ + TRNS,TRNS,TRNS, FN1, TRNS,TRNS,TRNS,TRNS, TRNS, TRNS, TRNS, TRNS) }; static const uint16_t PROGMEM fn_actions[] = { - [0] = ACTION_BACKLIGHT_STEP() + [0] = ACTION_LAYER_MOMENTARY(1), + [1] = ACTION_BACKLIGHT_STEP() }; -- cgit v1.2.3