aboutsummaryrefslogtreecommitdiff
path: root/keyboards/xd002
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2020-05-01 17:59:22 +0100
committerGitHub <noreply@github.com>2020-05-01 17:59:22 +0100
commitf7324ec68494026c27b9c4af4b34bf4a98d2c75b (patch)
treece303538e8eed3d667ef5097eb7b279ad3030e77 /keyboards/xd002
parent750c7c2bdbfb4b4e9d3a9efe6cb3f95ef0b43c53 (diff)
downloadqmk_firmware-f7324ec68494026c27b9c4af4b34bf4a98d2c75b.tar.gz
qmk_firmware-f7324ec68494026c27b9c4af4b34bf4a98d2c75b.zip
Add xd002 support (#8598)
* Add xd002 support * tidy some whitespace * align filename * Update keyboards/xd002/info.json Co-authored-by: Erovia <Erovia@users.noreply.github.com> Co-authored-by: Erovia <Erovia@users.noreply.github.com>
Diffstat (limited to 'keyboards/xd002')
-rw-r--r--keyboards/xd002/config.h60
-rw-r--r--keyboards/xd002/info.json16
-rw-r--r--keyboards/xd002/keymaps/default/keymap.c7
-rw-r--r--keyboards/xd002/keymaps/rgb/keymap.c46
-rw-r--r--keyboards/xd002/keymaps/rgb/rules.mk1
-rw-r--r--keyboards/xd002/keymaps/rgb_lite/keymap.c31
-rw-r--r--keyboards/xd002/keymaps/rgb_lite/rgblite.h26
-rw-r--r--keyboards/xd002/keymaps/rgb_lite/rules.mk1
-rw-r--r--keyboards/xd002/keymaps/tap_dance/config.h3
-rw-r--r--keyboards/xd002/keymaps/tap_dance/keymap.c19
-rw-r--r--keyboards/xd002/keymaps/tap_dance/rules.mk1
-rw-r--r--keyboards/xd002/keymaps/volume/keymap.c7
-rw-r--r--keyboards/xd002/keymaps/volume/rules.mk1
-rw-r--r--keyboards/xd002/readme.md49
-rw-r--r--keyboards/xd002/rules.mk34
-rw-r--r--keyboards/xd002/xd002.c16
-rw-r--r--keyboards/xd002/xd002.h33
17 files changed, 351 insertions, 0 deletions
diff --git a/keyboards/xd002/config.h b/keyboards/xd002/config.h
new file mode 100644
index 000000000..c17d816cf
--- /dev/null
+++ b/keyboards/xd002/config.h
@@ -0,0 +1,60 @@
1/* Copyright 2020 zvecr<git@zvecr.com>
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#pragma once
17
18#include "config_common.h"
19
20/* USB Device descriptor parameter */
21#define VENDOR_ID 0x7844 // "XD"
22#define PRODUCT_ID 0x0202
23#define DEVICE_VER 0x0001
24#define MANUFACTURER XIUDI
25#define PRODUCT XD002
26
27/* matrix size */
28#define MATRIX_ROWS 1
29#define MATRIX_COLS 2
30
31/*
32 * Keyboard Matrix Assignments
33 *
34 * On this board we have direct connection: no diodes.
35 */
36#define DIRECT_PINS {{ B0, B1 }}
37
38/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
39#define DEBOUNCE 5
40
41#define RGBLED_NUM 2
42#define RGB_DI_PIN B2
43
44// Save as much space as we can...
45#define LAYER_STATE_8BIT
46#define NO_ACTION_LAYER
47#define NO_ACTION_TAPPING
48#define NO_ACTION_ONESHOT
49#define NO_RESET
50
51// usbconfig.h overrides
52#define USB_CFG_IOPORTNAME B
53#define USB_CFG_DMINUS_BIT 3
54#define USB_CFG_DPLUS_BIT 4
55#define USB_COUNT_SOF 0
56#define USB_INTR_CFG PCMSK
57#define USB_INTR_CFG_SET (1<<USB_CFG_DPLUS_BIT)
58#define USB_INTR_ENABLE_BIT PCIE
59#define USB_INTR_PENDING_BIT PCIF
60#define USB_INTR_VECTOR SIG_PIN_CHANGE
diff --git a/keyboards/xd002/info.json b/keyboards/xd002/info.json
new file mode 100644
index 000000000..101952ec3
--- /dev/null
+++ b/keyboards/xd002/info.json
@@ -0,0 +1,16 @@
1{
2 "keyboard_name": "xd002",
3 "url": "https://kprepublic.com/products/xd002-xiudi-2-custom-mechanical-keyboard-2-keys-underglow-and-switch-rgb-pcb-programmed-hot-swappable-macro-key-aluminum-case",
4 "maintainer": "zvecr",
5 "width": 2,
6 "height": 1,
7 "layouts": {
8 "LAYOUT": {
9 "key_count": 2,
10 "layout": [
11 {"x":0, "y":0},
12 {"x":1, "y":0}
13 ]
14 }
15 }
16}
diff --git a/keyboards/xd002/keymaps/default/keymap.c b/keyboards/xd002/keymaps/default/keymap.c
new file mode 100644
index 000000000..ae53d396d
--- /dev/null
+++ b/keyboards/xd002/keymaps/default/keymap.c
@@ -0,0 +1,7 @@
1#include QMK_KEYBOARD_H
2
3const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
4 [0] = LAYOUT(
5 KC_A, KC_B
6 )
7};
diff --git a/keyboards/xd002/keymaps/rgb/keymap.c b/keyboards/xd002/keymaps/rgb/keymap.c
new file mode 100644
index 000000000..af0473413
--- /dev/null
+++ b/keyboards/xd002/keymaps/rgb/keymap.c
@@ -0,0 +1,46 @@
1#include QMK_KEYBOARD_H
2
3// Defines the keycodes used by our macros in process_record_user
4enum custom_keycodes {
5 QMKURL = SAFE_RANGE,
6};
7
8const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
9 [0] = LAYOUT(
10 RGB_HUI, QMKURL
11 )
12};
13
14bool process_record_user(uint16_t keycode, keyrecord_t *record) {
15 if (record->event.pressed) {
16 switch (keycode) {
17 case QMKURL:
18 // Using SEND_STRING here adds 400bytes ...
19 // SEND_STRING("https://qmk.fm/" SS_TAP(X_ENTER));
20 tap_code(KC_H);
21 tap_code(KC_T);
22 tap_code(KC_T);
23 tap_code(KC_P);
24 tap_code(KC_S);
25 tap_code16(KC_COLON);
26 tap_code(KC_SLASH);
27 tap_code(KC_SLASH);
28 tap_code(KC_Q);
29 tap_code(KC_M);
30 tap_code(KC_K);
31 tap_code(KC_DOT);
32 tap_code(KC_F);
33 tap_code(KC_M);
34 tap_code(KC_SLASH);
35 tap_code(KC_ENTER);
36 break;
37 }
38 }
39 return true;
40}
41
42void keyboard_post_init_user(void) {
43 rgblight_enable_noeeprom(); // enables Rgb, without saving settings
44 rgblight_sethsv_noeeprom(180, 255, 255); // sets the color to teal/cyan without saving
45 rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT); // sets mode to Fast breathing without saving
46}
diff --git a/keyboards/xd002/keymaps/rgb/rules.mk b/keyboards/xd002/keymaps/rgb/rules.mk
new file mode 100644
index 000000000..1e3cebb14
--- /dev/null
+++ b/keyboards/xd002/keymaps/rgb/rules.mk
@@ -0,0 +1 @@
RGBLIGHT_ENABLE = yes
diff --git a/keyboards/xd002/keymaps/rgb_lite/keymap.c b/keyboards/xd002/keymaps/rgb_lite/keymap.c
new file mode 100644
index 000000000..ed9185e3b
--- /dev/null
+++ b/keyboards/xd002/keymaps/rgb_lite/keymap.c
@@ -0,0 +1,31 @@
1#include QMK_KEYBOARD_H
2#include "rgblite.h"
3
4// Defines the keycodes used by our macros in process_record_user
5enum custom_keycodes {
6 QMKURL = SAFE_RANGE,
7};
8
9const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
10 [0] = LAYOUT(
11 RGB_HUI, QMKURL
12 )
13};
14
15bool process_record_user(uint16_t keycode, keyrecord_t *record) {
16 if (record->event.pressed) {
17 switch (keycode) {
18 case RGB_HUI:
19 rgblight_increase_hue();
20 break;
21 case QMKURL:
22 SEND_STRING("https://qmk.fm/" SS_TAP(X_ENTER));
23 break;
24 }
25 }
26 return true;
27}
28
29void keyboard_post_init_user(void) {
30 rgblight_increase_hue();
31}
diff --git a/keyboards/xd002/keymaps/rgb_lite/rgblite.h b/keyboards/xd002/keymaps/rgb_lite/rgblite.h
new file mode 100644
index 000000000..ca98484b8
--- /dev/null
+++ b/keyboards/xd002/keymaps/rgb_lite/rgblite.h
@@ -0,0 +1,26 @@
1#pragma once
2
3#include "ws2812.h"
4#include "rgblight_list.h"
5
6static inline void rgblight_setrgb(uint8_t _r, uint8_t _g, uint8_t _b) {
7 LED_TYPE leds[RGBLED_NUM] = {{.r = _r, .g = _g, .b = _b}, {.r = _r, .g = _g, .b = _b}};
8 ws2812_setleds(leds, RGBLED_NUM);
9}
10
11static void rgblight_increase_hue(void) {
12 static uint8_t state = 0;
13
14 state = (state + 1) % 3;
15 switch (state) {
16 case 1:
17 rgblight_setrgb_red();
18 break;
19 case 2:
20 rgblight_setrgb_blue();
21 break;
22 default:
23 rgblight_setrgb_green();
24 break;
25 }
26}
diff --git a/keyboards/xd002/keymaps/rgb_lite/rules.mk b/keyboards/xd002/keymaps/rgb_lite/rules.mk
new file mode 100644
index 000000000..227bbcae3
--- /dev/null
+++ b/keyboards/xd002/keymaps/rgb_lite/rules.mk
@@ -0,0 +1 @@
SRC += ws2812.c
diff --git a/keyboards/xd002/keymaps/tap_dance/config.h b/keyboards/xd002/keymaps/tap_dance/config.h
new file mode 100644
index 000000000..b86e862d3
--- /dev/null
+++ b/keyboards/xd002/keymaps/tap_dance/config.h
@@ -0,0 +1,3 @@
1#pragma once
2
3#define TAPPING_TERM 500
diff --git a/keyboards/xd002/keymaps/tap_dance/keymap.c b/keyboards/xd002/keymaps/tap_dance/keymap.c
new file mode 100644
index 000000000..0f384ce99
--- /dev/null
+++ b/keyboards/xd002/keymaps/tap_dance/keymap.c
@@ -0,0 +1,19 @@
1#include QMK_KEYBOARD_H
2
3enum layers {
4 _BASE = 0,
5};
6
7enum {
8 TD_BC = 0
9};
10
11qk_tap_dance_action_t tap_dance_actions[] = {
12 [TD_BC] = ACTION_TAP_DANCE_DOUBLE(KC_B, KC_C)
13};
14
15const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
16 [_BASE] = LAYOUT(
17 KC_A, TD(TD_BC)
18 )
19};
diff --git a/keyboards/xd002/keymaps/tap_dance/rules.mk b/keyboards/xd002/keymaps/tap_dance/rules.mk
new file mode 100644
index 000000000..e5ddcae8d
--- /dev/null
+++ b/keyboards/xd002/keymaps/tap_dance/rules.mk
@@ -0,0 +1 @@
TAP_DANCE_ENABLE = yes
diff --git a/keyboards/xd002/keymaps/volume/keymap.c b/keyboards/xd002/keymaps/volume/keymap.c
new file mode 100644
index 000000000..2365d7b24
--- /dev/null
+++ b/keyboards/xd002/keymaps/volume/keymap.c
@@ -0,0 +1,7 @@
1#include QMK_KEYBOARD_H
2
3const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
4 [0] = LAYOUT(
5 KC_VOLU, KC_VOLD
6 )
7};
diff --git a/keyboards/xd002/keymaps/volume/rules.mk b/keyboards/xd002/keymaps/volume/rules.mk
new file mode 100644
index 000000000..fcfd2225b
--- /dev/null
+++ b/keyboards/xd002/keymaps/volume/rules.mk
@@ -0,0 +1 @@
EXTRAKEY_ENABLE = yes
diff --git a/keyboards/xd002/readme.md b/keyboards/xd002/readme.md
new file mode 100644
index 000000000..6358bc754
--- /dev/null
+++ b/keyboards/xd002/readme.md
@@ -0,0 +1,49 @@
1# xd002
2
3![xd002](https://cdn.shopify.com/s/files/1/2711/4238/products/xd002_1024x1024.jpg?v=1522134411)
4
52% Custom mechanical keyboard. ATtiny85 powered, with 2*WS2812 LEDs, and the micronucleus bootloader.
6
7**Note**: Due to limited firmware space, a _**lot**_ of features have to be disabled to get a functioning QMK based keyboard.
8
9* Keyboard Maintainer: [zvecr](https://github.com/zvecr)
10* Hardware Supported: xd002
11* Hardware Availability: [kprepublic](https://kprepublic.com/products/xd002-xiudi-2-custom-mechanical-keyboard-2-keys-underglow-and-switch-rgb-pcb-programmed-hot-swappable-macro-key-aluminum-case)
12
13Make example for this keyboard (after setting up your build environment):
14
15 make xd002:default
16
17See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).
18
19## Flashing
20### Prerequisites
21
22```bash
23git clone https://github.com/micronucleus/micronucleus.git
24cd micronucleus/commandline/
25sudo make install
26```
27
28On Linux, you’ll need proper privileges to access the MCU. You can either use sudo when flashing firmware, or place [these files](https://github.com/micronucleus/micronucleus/blob/master/commandline/49-micronucleus.rules) in /etc/udev/rules.d/. Once added run the following:
29
30```bash
31sudo udevadm control --reload-rules
32sudo udevadm trigger
33```
34
35### Instructions
36
37**Reset Key**: Hold down key nearest to the USB socket while plugging in the keyboard.
38
39```bash
40make xd002:default:flash
41
42# or directly with...
43micronucleus --run <firmware.hex>
44```
45
46### Recovery
47
48* [Original Firmware](https://github.com/xiudi/Attiny85_vusb_pad_test)
49* [Bootloader Repair](https://digistump.com/wiki/digispark/tutorials/proisp)
diff --git a/keyboards/xd002/rules.mk b/keyboards/xd002/rules.mk
new file mode 100644
index 000000000..1142142bf
--- /dev/null
+++ b/keyboards/xd002/rules.mk
@@ -0,0 +1,34 @@
1# MCU name
2MCU = attiny85
3
4# Bootloader selection
5BOOTLOADER = micronucleus
6OPT_DEFS += -DBOOTLOADER_SIZE=1862
7PROGRAM_CMD = micronucleus --run $(BUILD_DIR)/$(TARGET).hex
8
9# Build Options
10# change yes to no to disable
11#
12BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration
13MOUSEKEY_ENABLE = no # Mouse keys
14EXTRAKEY_ENABLE = no # Audio control and System control
15CONSOLE_ENABLE = no # Console for debug
16COMMAND_ENABLE = no # Commands for debug and configuration
17# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
18SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
19# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
20NKRO_ENABLE = no # USB Nkey Rollover
21BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality on B7 by default
22RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
23MIDI_ENABLE = no # MIDI support
24UNICODE_ENABLE = no # Unicode
25BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
26AUDIO_ENABLE = no # Audio output on port C6
27FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches
28HD44780_ENABLE = no # Enable support for HD44780 based LCDs
29
30# Save as much space as we can...
31LTO_ENABLE = yes
32GRAVE_ESC_ENABLE = no
33MAGIC_ENABLE = no
34SPACE_CADET_ENABLE = no
diff --git a/keyboards/xd002/xd002.c b/keyboards/xd002/xd002.c
new file mode 100644
index 000000000..e679b9724
--- /dev/null
+++ b/keyboards/xd002/xd002.c
@@ -0,0 +1,16 @@
1/* Copyright 2020 zvecr<git@zvecr.com>
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#include "xd002.h"
diff --git a/keyboards/xd002/xd002.h b/keyboards/xd002/xd002.h
new file mode 100644
index 000000000..3d780191b
--- /dev/null
+++ b/keyboards/xd002/xd002.h
@@ -0,0 +1,33 @@
1/* Copyright 2020 zvecr<git@zvecr.com>
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#pragma once
17
18#include "quantum.h"
19
20/* This a shortcut to help you visually see your layout.
21 *
22 * The first section contains all of the arguments representing the physical
23 * layout of the board and position of the keys.
24 *
25 * The second converts the arguments into a two-dimensional array which
26 * represents the switch matrix.
27 */
28#define LAYOUT( \
29 K01, K02 \
30) \
31{ \
32 { K01, K02 }, \
33}