aboutsummaryrefslogtreecommitdiff
path: root/keyboards/jd40
diff options
context:
space:
mode:
authorMajor Koos <MajorKoos@users.noreply.github.com>2016-09-02 16:14:40 -0700
committerMajor Koos <MajorKoos@users.noreply.github.com>2016-09-02 16:14:40 -0700
commit295ef0d9649b7482c380f38dd6157879df4af91d (patch)
tree9263d0c4ee25e8bc2a63f8493f8ecd07975a00a3 /keyboards/jd40
parente28d151a8a1d458f3c18897c6095decc17b0c3a1 (diff)
downloadqmk_firmware-295ef0d9649b7482c380f38dd6157879df4af91d.tar.gz
qmk_firmware-295ef0d9649b7482c380f38dd6157879df4af91d.zip
Add support for JD40 MKII PCB
RGB Included.
Diffstat (limited to 'keyboards/jd40')
-rw-r--r--keyboards/jd40/Makefile74
-rw-r--r--keyboards/jd40/config.h79
-rw-r--r--keyboards/jd40/jd40.c26
-rw-r--r--keyboards/jd40/jd40.h45
-rw-r--r--keyboards/jd40/keymaps/default/keymap.c164
-rw-r--r--keyboards/jd40/readme.md17
6 files changed, 405 insertions, 0 deletions
diff --git a/keyboards/jd40/Makefile b/keyboards/jd40/Makefile
new file mode 100644
index 000000000..242748111
--- /dev/null
+++ b/keyboards/jd40/Makefile
@@ -0,0 +1,74 @@
1
2
3# MCU name
4#MCU = at90usb1287
5MCU = atmega32u4
6
7# Processor frequency.
8# This will define a symbol, F_CPU, in all source code files equal to the
9# processor frequency in Hz. You can then use this symbol in your source code to
10# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
11# automatically to create a 32-bit value in your source code.
12#
13# This will be an integer division of F_USB below, as it is sourced by
14# F_USB after it has run through any CPU prescalers. Note that this value
15# does not *change* the processor frequency - it should merely be updated to
16# reflect the processor speed set externally so that the code can use accurate
17# software delays.
18F_CPU = 16000000
19
20
21#
22# LUFA specific
23#
24# Target architecture (see library "Board Types" documentation).
25ARCH = AVR8
26
27# Input clock frequency.
28# This will define a symbol, F_USB, in all source code files equal to the
29# input clock frequency (before any prescaling is performed) in Hz. This value may
30# differ from F_CPU if prescaling is used on the latter, and is required as the
31# raw input clock is fed directly to the PLL sections of the AVR for high speed
32# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
33# at the end, this will be done automatically to create a 32-bit value in your
34# source code.
35#
36# If no clock division is performed on the input clock inside the AVR (via the
37# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
38F_USB = $(F_CPU)
39
40# Interrupt driven control endpoint task(+60)
41OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
42
43
44# Boot Section Size in *bytes*
45# Teensy halfKay 512
46# Teensy++ halfKay 1024
47# Atmel DFU loader 4096
48# LUFA bootloader 4096
49# USBaspLoader 2048
50OPT_DEFS += -DBOOTLOADER_SIZE=4096
51
52
53# Build Options
54# comment out to disable the options.
55#
56BOOTMAGIC_ENABLE ?= yes # Virtual DIP switch configuration(+1000)
57MOUSEKEY_ENABLE ?= yes # Mouse keys(+4700)
58EXTRAKEY_ENABLE ?= yes # Audio control and System control(+450)
59# CONSOLE_ENABLE ?= yes # Console for debug(+400)
60# COMMAND_ENABLE ?= yes # Commands for debug and configuration
61KEYBOARD_LOCK_ENABLE ?= yes # Allow locking of keyboard via magic key
62# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
63# SLEEP_LED_ENABLE ?= yes # Breathing sleep LED during USB suspend
64NKRO_ENABLE ?= yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
65# BACKLIGHT_ENABLE ?= yes # Enable keyboard backlight functionality
66# MIDI_ENABLE ?= YES # MIDI controls
67# UNICODE_ENABLE ?= YES # Unicode
68# BLUETOOTH_ENABLE ?= yes # Enable Bluetooth with the Adafruit EZ-Key HID
69RGBLIGHT_ENABLE ?= yes # Enable RGB Underglow
70
71ifndef QUANTUM_DIR
72 include ../../Makefile
73endif
74
diff --git a/keyboards/jd40/config.h b/keyboards/jd40/config.h
new file mode 100644
index 000000000..e2594f4b3
--- /dev/null
+++ b/keyboards/jd40/config.h
@@ -0,0 +1,79 @@
1/*
2Copyright 2012 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#ifndef CONFIG_H
19#define CONFIG_H
20
21#include "config_common.h"
22
23/* USB Device descriptor parameter */
24#define VENDOR_ID 0xFEED
25#define PRODUCT_ID 0x6060
26#define DEVICE_VER 0x0001
27#define MANUFACTURER geekhack
28#define PRODUCT jd40v2
29#define DESCRIPTION t.m.k. keyboard firmware for JD40 MKII
30
31/* key matrix size */
32#define MATRIX_ROWS 4
33#define MATRIX_COLS 12
34
35/*
36 * Keyboard Matrix Assignments
37 *
38 * Change this to how you wired your keyboard
39 * COLS: AVR pins used for columns, left to right
40 * ROWS: AVR pins used for rows, top to bottom
41 * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode)
42 * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode)
43 *
44*/
45#define MATRIX_ROW_PINS { F0, F1, F5, B4 }
46#define MATRIX_COL_PINS { F4, D7, B5, B6, C6, C7, D4, D6, D5, D0, D1, D2 }
47#define UNUSED_PINS
48
49/* COL2ROW or ROW2COL */
50#define DIODE_DIRECTION COL2ROW
51
52/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
53#define DEBOUNCING_DELAY 5
54
55/* define if matrix has ghost (lacks anti-ghosting diodes) */
56//#define MATRIX_HAS_GHOST
57
58/* number of backlight levels */
59#define BACKLIGHT_LEVELS 3
60
61/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
62#define LOCKING_SUPPORT_ENABLE
63/* Locking resynchronize hack */
64#define LOCKING_RESYNC_ENABLE
65
66
67/* key combination for magic key command */
68#define IS_COMMAND() ( \
69 keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
70)
71
72#define RGB_DI_PIN D3
73#define RGBLIGHT_TIMER
74#define RGBLED_NUM 12 // Number of LEDs
75#define RGBLIGHT_HUE_STEP 8
76#define RGBLIGHT_SAT_STEP 8
77#define RGBLIGHT_VAL_STEP 8
78
79#endif
diff --git a/keyboards/jd40/jd40.c b/keyboards/jd40/jd40.c
new file mode 100644
index 000000000..fa06356d9
--- /dev/null
+++ b/keyboards/jd40/jd40.c
@@ -0,0 +1,26 @@
1#include "jd40.h"
2
3void led_set_kb(uint8_t usb_led) {
4 // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
5
6
7 // if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
8 // gh60_caps_led_on();
9 // } else {
10 // gh60_caps_led_off();
11 // }
12
13 // if (usb_led & (1<<USB_LED_NUM_LOCK)) {
14 // gh60_esc_led_on();
15 // } else {
16 // gh60_esc_led_off();
17 // }
18
19 // if (usb_led & (1<<USB_LED_SCROLL_LOCK)) {
20 // gh60_fn_led_on();
21 // } else {
22 // gh60_fn_led_off();
23 // }
24
25 led_set_user(usb_led);
26}
diff --git a/keyboards/jd40/jd40.h b/keyboards/jd40/jd40.h
new file mode 100644
index 000000000..77a122299
--- /dev/null
+++ b/keyboards/jd40/jd40.h
@@ -0,0 +1,45 @@
1#ifndef JD40_H
2#define JD40_H
3
4#include "quantum.h"
5#include "led.h"
6
7/* GH60 LEDs
8 * GPIO pads
9 * 0 F7 WASD LEDs
10 * 1 F6 ESC LED
11 * 2 F5 FN LED
12 * 3 F4 POKER Arrow LEDs
13 * B2 Capslock LED
14 * B0 not connected
15 */
16
17 /*
18inline void gh60_caps_led_on(void) { DDRB |= (1<<2); PORTB &= ~(1<<2); }
19inline void gh60_poker_leds_on(void) { DDRF |= (1<<4); PORTF &= ~(1<<4); }
20inline void gh60_fn_led_on(void) { DDRF |= (1<<5); PORTF &= ~(1<<5); }
21inline void gh60_esc_led_on(void) { DDRF |= (1<<6); PORTF &= ~(1<<6); }
22inline void gh60_wasd_leds_on(void) { DDRF |= (1<<7); PORTF &= ~(1<<7); }
23
24inline void gh60_caps_led_off(void) { DDRB &= ~(1<<2); PORTB &= ~(1<<2); }
25inline void gh60_poker_leds_off(void) { DDRF &= ~(1<<4); PORTF &= ~(1<<4); }
26inline void gh60_fn_led_off(void) { DDRF &= ~(1<<5); PORTF &= ~(1<<5); }
27inline void gh60_esc_led_off(void) { DDRF &= ~(1<<6); PORTF &= ~(1<<6); }
28inline void gh60_wasd_leds_off(void) { DDRF &= ~(1<<7); PORTF &= ~(1<<7); }
29*/
30
31/* JD40 MKII keymap definition macro
32 */
33#define KEYMAP( \
34 K01, K02, K03, K04, K05, K06, K07, K08, K09, K10, K11, K12, \
35 K13, K14, K15, K16, K17, K18, K19, K20, K21, K22, K23, \
36 K24, K25, K26, K27, K28, K29, K30, K31, K32, K33, K34, \
37 K35, K36, K37, K38, K39, K40, K41, K42, K43, K44 \
38) { \
39 { KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K10, KC_##K11, KC_##K12 }, \
40 { KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_NO }, \
41 { KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_NO }, \
42 { KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_NO, KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_NO } \
43}
44
45#endif
diff --git a/keyboards/jd40/keymaps/default/keymap.c b/keyboards/jd40/keymaps/default/keymap.c
new file mode 100644
index 000000000..79ac146c9
--- /dev/null
+++ b/keyboards/jd40/keymaps/default/keymap.c
@@ -0,0 +1,164 @@
1#include "jd40.h"
2#include "action_layer.h"
3
4#define _BL 0
5#define _AL 1
6#define _FL 2
7#define _UL 3
8
9const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
10 [_BL] = KEYMAP(
11 F12, Q, W, E, R, T, Y, U, I, O, P, BSPC,
12 TAB, A, S, D, F, G, H, J, K, L, ENT,
13 LSFT, Z, X, C, V, B, N, M, COMM, UP, DOT,
14 LCTL, LGUI, LALT, FN0, SPC, SPC, FN0, LEFT, DOWN, RIGHT ),
15
16 [_AL] = KEYMAP(
17 GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, DEL,
18 CAPS, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
19 TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, SCLN, PGUP, QUOT,
20 TRNS, TRNS, TRNS, TRNS, FN3, FN3, TRNS, HOME, PGDN, END ),
21
22 [_FL] = KEYMAP(
23 TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
24 TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
25 TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
26 TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS ),
27
28 [_UL] = KEYMAP(
29 TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
30 TRNS, FN4, FN5, FN11, FN10, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
31 TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
32 TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS ),
33};
34
35enum function_id {
36 RGBLED_TOGGLE,
37 RGBLED_STEP_MODE,
38 RGBLED_INCREASE_HUE,
39 RGBLED_DECREASE_HUE,
40 RGBLED_INCREASE_SAT,
41 RGBLED_DECREASE_SAT,
42 RGBLED_INCREASE_VAL,
43 RGBLED_DECREASE_VAL,
44 SHIFT_ESC,
45};
46
47const uint16_t PROGMEM fn_actions[] = {
48 [0] = ACTION_LAYER_MOMENTARY(1), // Momentary Fn overlay
49 [1] = ACTION_LAYER_TOGGLE(2), // Toggle Arrow Layer overlay
50 [2] = ACTION_LAYER_TAP_KEY(2, KC_CAPS), // Tap to toggle caps lock and hold to activate function layer
51 [3] = ACTION_LAYER_TOGGLE(3), // Toggle Underglow Layer overlay
52 [4] = ACTION_FUNCTION(RGBLED_TOGGLE), //Turn on/off underglow
53 [5] = ACTION_FUNCTION(RGBLED_STEP_MODE), // Change underglow mode
54 [6] = ACTION_FUNCTION(RGBLED_INCREASE_HUE),
55 [7] = ACTION_FUNCTION(RGBLED_DECREASE_HUE),
56 [8] = ACTION_FUNCTION(RGBLED_INCREASE_SAT),
57 [9] = ACTION_FUNCTION(RGBLED_DECREASE_SAT),
58 [10] = ACTION_FUNCTION(RGBLED_INCREASE_VAL),
59 [11] = ACTION_FUNCTION(RGBLED_DECREASE_VAL),
60 [12] = ACTION_FUNCTION(SHIFT_ESC),
61};
62
63const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
64{
65 // MACRODOWN only works in this function
66 switch(id) {
67 case 0:
68 if (record->event.pressed) {
69 register_code(KC_RSFT);
70 } else {
71 unregister_code(KC_RSFT);
72 }
73 break;
74 }
75 return MACRO_NONE;
76};
77
78void matrix_scan_user(void) {
79
80// Layer LED indicators
81// ESC led on when in function layer, WASD cluster leds enabled when on arrow cluster
82 uint32_t layer = layer_state;
83 if (layer & (1<<1)) {
84 //gh60_wasd_leds_on();
85 } else {
86 //gh60_wasd_leds_off();
87 }
88
89 if (layer & (1<<2)) {
90 //gh60_esc_led_on();
91 } else {
92 //gh60_esc_led_off();
93 }
94};
95
96#define MODS_CTRL_MASK (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT))
97
98void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
99 switch (id) {
100 case RGBLED_TOGGLE:
101 //led operations
102 if (record->event.pressed) {
103 rgblight_toggle();
104 }
105 break;
106 case RGBLED_INCREASE_HUE:
107 if (record->event.pressed) {
108 rgblight_increase_hue();
109 }
110 break;
111 case RGBLED_DECREASE_HUE:
112 if (record->event.pressed) {
113 rgblight_decrease_hue();
114 }
115 break;
116 case RGBLED_INCREASE_SAT:
117 if (record->event.pressed) {
118 rgblight_increase_sat();
119 }
120 break;
121 case RGBLED_DECREASE_SAT:
122 if (record->event.pressed) {
123 rgblight_decrease_sat();
124 }
125 break;
126 case RGBLED_INCREASE_VAL:
127 if (record->event.pressed) {
128 rgblight_increase_val();
129 }
130 break;
131 case RGBLED_DECREASE_VAL:
132 if (record->event.pressed) {
133 rgblight_decrease_val();
134 }
135 break;
136 case RGBLED_STEP_MODE:
137 if (record->event.pressed) {
138 rgblight_step();
139 }
140 break;
141 static uint8_t shift_esc_shift_mask;
142 // Shift + ESC = ~
143 case SHIFT_ESC:
144 shift_esc_shift_mask = get_mods()&MODS_CTRL_MASK;
145 if (record->event.pressed) {
146 if (shift_esc_shift_mask) {
147 add_key(KC_GRV);
148 send_keyboard_report();
149 } else {
150 add_key(KC_ESC);
151 send_keyboard_report();
152 }
153 } else {
154 if (shift_esc_shift_mask) {
155 del_key(KC_GRV);
156 send_keyboard_report();
157 } else {
158 del_key(KC_ESC);
159 send_keyboard_report();
160 }
161 }
162 break;
163 }
164};
diff --git a/keyboards/jd40/readme.md b/keyboards/jd40/readme.md
new file mode 100644
index 000000000..7daa0980e
--- /dev/null
+++ b/keyboards/jd40/readme.md
@@ -0,0 +1,17 @@
1## jd40 mkii keyboard firmware
2
3 Pins:
4 MATRIX_ROW_PINS { F0, F1, F5, B4 }
5 MATRIX_COL_PINS { F4, D7, B5, B6, C6, C7, D4, D6, D5, D0, D1, D2 }
6 RGB_DI_PIN D3
7
8======================
9
10## Quantum MK Firmware
11
12For the full Quantum feature list, see [the parent readme.md](/readme.md).
13
14## Building
15
16Download or clone the whole firmware and navigate to the keyboards/jd40 folder.
17Once your dev env is setup, you'll be able to type `make` to generate your .hex - you can then use the Amtel Flip to program your .hex file.