Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a simple 2x5 Keypad with 4 layers #6699

Merged
merged 21 commits into from
Sep 10, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions keyboards/2x5keypad/2x5keypad.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "2x5keypad.h"

void keyboard_pre_init_user(void)
{
setPinOutput(RED_LED);
setPinOutput(BLUE_LED);
setPinOutput(GREEN_LED);
}
23 changes: 23 additions & 0 deletions keyboards/2x5keypad/2x5keypad.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef KB_H
jmcameron marked this conversation as resolved.
Show resolved Hide resolved
#define KB_H
jmcameron marked this conversation as resolved.
Show resolved Hide resolved

#include "quantum.h"
#include "led.h"

#define RED_LED D0
#define BLUE_LED B5
#define GREEN_LED B6


#define KEYMAP( \
jmcameron marked this conversation as resolved.
Show resolved Hide resolved
K00, K01, K02, K03, K04, \
K10, K11, K12, K13, K14 \
) { \
{ K00, K01, K02, K03, K04 }, \
{ K10, K11, K12, K13, K14 } \
}

void keyboard_pre_init_user(void);


#endif
jmcameron marked this conversation as resolved.
Show resolved Hide resolved
58 changes: 58 additions & 0 deletions keyboards/2x5keypad/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#ifndef CONFIG_H
jmcameron marked this conversation as resolved.
Show resolved Hide resolved
#define CONFIG_H
jmcameron marked this conversation as resolved.
Show resolved Hide resolved

#include "config_common.h"

/* USB Device descriptor parameter */
#define VENDOR_ID 0xFEED
#define PRODUCT_ID 0x2020
#define DEVICE_VER 0x0001
#define MANUFACTURER Jonathan Cameron
#define PRODUCT 2x5keypad
#define DESCRIPTION 2x5 Keypad

/* key matrix size */
#define MATRIX_ROWS 2
#define MATRIX_COLS 5

/* key matrix pins */
#define MATRIX_ROW_PINS { B3, B2 }
#define MATRIX_COL_PINS { D4, C6, D7, E6, B4 }
#define UNUSED_PINS

/* COL2ROW or ROW2COL */
#define DIODE_DIRECTION COL2ROW

/* number of backlight levels */

#ifdef BACKLIGHT_PIN
#define BACKLIGHT_LEVELS 0
#endif

/* Set 0 if debouncing isn't needed */
#define DEBOUNCING_DELAY 5
jmcameron marked this conversation as resolved.
Show resolved Hide resolved

/* 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

/* key combination for command */
#define IS_COMMAND() ( \
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
jmcameron marked this conversation as resolved.
Show resolved Hide resolved
)

/* prevent stuck modifiers */
#define PREVENT_STUCK_MODIFIERS
jmcameron marked this conversation as resolved.
Show resolved Hide resolved


#ifdef RGB_DI_PIN
#define RGBLIGHT_ANIMATIONS
#define RGBLED_NUM 0
#define RGBLIGHT_HUE_STEP 8
#define RGBLIGHT_SAT_STEP 8
#define RGBLIGHT_VAL_STEP 8
#endif

#endif
jmcameron marked this conversation as resolved.
Show resolved Hide resolved
72 changes: 72 additions & 0 deletions keyboards/2x5keypad/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#include "2x5keypad.h"
jmcameron marked this conversation as resolved.
Show resolved Hide resolved
#include "keymap.h"

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[NORMAL_LAYER]=
KEYMAP(
jmcameron marked this conversation as resolved.
Show resolved Hide resolved
TO(1), WIN_TAB, KC_HOME, KC_UP, KC_END,
WIN_LOCK, KC_MUTE, KC_LEFT, KC_DOWN, KC_RGHT),

[MEDIA_LAYER]=
KEYMAP(
jmcameron marked this conversation as resolved.
Show resolved Hide resolved
TO(2), KC_CALC, KC_MPRV, KC_MNXT, KC_VOLU,
KC_TRNS, KC_TRNS, KC_MSTP, KC_MPLY, KC_VOLD),

[TBD_LAYER2]=
KEYMAP(
jmcameron marked this conversation as resolved.
Show resolved Hide resolved
TO(3), KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),

[TBD_LAYER3]=
KEYMAP(
jmcameron marked this conversation as resolved.
Show resolved Hide resolved
TO(0), KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS)
};

const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
jmcameron marked this conversation as resolved.
Show resolved Hide resolved

// keyevent_t event = record->event;

switch (id) {

}
return MACRO_NONE;
}

void matrix_init_user(void) {
}

void matrix_scan_user(void) {
}

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return true;
}

uint32_t layer_state_set_user(uint32_t state)
jmcameron marked this conversation as resolved.
Show resolved Hide resolved
{
switch (biton32(state))
jmcameron marked this conversation as resolved.
Show resolved Hide resolved
{
case NORMAL_LAYER:
writePinLow(RED_LED);
writePinLow(BLUE_LED);
writePinLow(GREEN_LED);
break;
case MEDIA_LAYER:
writePinHigh(RED_LED);
writePinLow(BLUE_LED);
writePinLow(GREEN_LED);
break;
case TBD_LAYER2:
writePinLow(RED_LED);
writePinHigh(BLUE_LED);
writePinLow(GREEN_LED);
break;
case TBD_LAYER3:
writePinLow(RED_LED);
writePinLow(BLUE_LED);
writePinHigh(GREEN_LED);
break;
}
return state;
}
14 changes: 14 additions & 0 deletions keyboards/2x5keypad/keymaps/default/keymap.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include QMK_KEYBOARD_H

#define WIN_TAB LGUI(KC_TAB)
#define WIN_LOCK LGUI(KC_L)

enum layers {
NORMAL_LAYER = 0,
MEDIA_LAYER,
TBD_LAYER2,
TBD_LAYER3
};


uint32_t layer_state_set_user(uint32_t state);
56 changes: 56 additions & 0 deletions keyboards/2x5keypad/rules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# MCU name
MCU = atmega32u4
jmcameron marked this conversation as resolved.
Show resolved Hide resolved

# 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*
OPT_DEFS += -DBOOTLOADER_SIZE=4096
jmcameron marked this conversation as resolved.
Show resolved Hide resolved


# 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 ?= no # Console for debug(+400)
COMMAND_ENABLE ?= no # Commands for debug and configuration
SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend
NKRO_ENABLE ?= yes # USB 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
AUDIO_ENABLE ?= no
RGBLIGHT_ENABLE ?= no