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>
This commit is contained in:
Joel Challis 2020-05-01 17:59:22 +01:00 committed by GitHub
parent 750c7c2bdb
commit f7324ec684
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 351 additions and 0 deletions

60
keyboards/xd002/config.h Normal file
View File

@ -0,0 +1,60 @@
/* Copyright 2020 zvecr<git@zvecr.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "config_common.h"
/* USB Device descriptor parameter */
#define VENDOR_ID 0x7844 // "XD"
#define PRODUCT_ID 0x0202
#define DEVICE_VER 0x0001
#define MANUFACTURER XIUDI
#define PRODUCT XD002
/* matrix size */
#define MATRIX_ROWS 1
#define MATRIX_COLS 2
/*
* Keyboard Matrix Assignments
*
* On this board we have direct connection: no diodes.
*/
#define DIRECT_PINS {{ B0, B1 }}
/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
#define DEBOUNCE 5
#define RGBLED_NUM 2
#define RGB_DI_PIN B2
// Save as much space as we can...
#define LAYER_STATE_8BIT
#define NO_ACTION_LAYER
#define NO_ACTION_TAPPING
#define NO_ACTION_ONESHOT
#define NO_RESET
// usbconfig.h overrides
#define USB_CFG_IOPORTNAME B
#define USB_CFG_DMINUS_BIT 3
#define USB_CFG_DPLUS_BIT 4
#define USB_COUNT_SOF 0
#define USB_INTR_CFG PCMSK
#define USB_INTR_CFG_SET (1<<USB_CFG_DPLUS_BIT)
#define USB_INTR_ENABLE_BIT PCIE
#define USB_INTR_PENDING_BIT PCIF
#define USB_INTR_VECTOR SIG_PIN_CHANGE

16
keyboards/xd002/info.json Normal file
View File

@ -0,0 +1,16 @@
{
"keyboard_name": "xd002",
"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",
"maintainer": "zvecr",
"width": 2,
"height": 1,
"layouts": {
"LAYOUT": {
"key_count": 2,
"layout": [
{"x":0, "y":0},
{"x":1, "y":0}
]
}
}
}

View File

@ -0,0 +1,7 @@
#include QMK_KEYBOARD_H
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT(
KC_A, KC_B
)
};

View File

@ -0,0 +1,46 @@
#include QMK_KEYBOARD_H
// Defines the keycodes used by our macros in process_record_user
enum custom_keycodes {
QMKURL = SAFE_RANGE,
};
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT(
RGB_HUI, QMKURL
)
};
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
switch (keycode) {
case QMKURL:
// Using SEND_STRING here adds 400bytes ...
// SEND_STRING("https://qmk.fm/" SS_TAP(X_ENTER));
tap_code(KC_H);
tap_code(KC_T);
tap_code(KC_T);
tap_code(KC_P);
tap_code(KC_S);
tap_code16(KC_COLON);
tap_code(KC_SLASH);
tap_code(KC_SLASH);
tap_code(KC_Q);
tap_code(KC_M);
tap_code(KC_K);
tap_code(KC_DOT);
tap_code(KC_F);
tap_code(KC_M);
tap_code(KC_SLASH);
tap_code(KC_ENTER);
break;
}
}
return true;
}
void keyboard_post_init_user(void) {
rgblight_enable_noeeprom(); // enables Rgb, without saving settings
rgblight_sethsv_noeeprom(180, 255, 255); // sets the color to teal/cyan without saving
rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT); // sets mode to Fast breathing without saving
}

View File

@ -0,0 +1 @@
RGBLIGHT_ENABLE = yes

View File

@ -0,0 +1,31 @@
#include QMK_KEYBOARD_H
#include "rgblite.h"
// Defines the keycodes used by our macros in process_record_user
enum custom_keycodes {
QMKURL = SAFE_RANGE,
};
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT(
RGB_HUI, QMKURL
)
};
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
switch (keycode) {
case RGB_HUI:
rgblight_increase_hue();
break;
case QMKURL:
SEND_STRING("https://qmk.fm/" SS_TAP(X_ENTER));
break;
}
}
return true;
}
void keyboard_post_init_user(void) {
rgblight_increase_hue();
}

View File

@ -0,0 +1,26 @@
#pragma once
#include "ws2812.h"
#include "rgblight_list.h"
static inline void rgblight_setrgb(uint8_t _r, uint8_t _g, uint8_t _b) {
LED_TYPE leds[RGBLED_NUM] = {{.r = _r, .g = _g, .b = _b}, {.r = _r, .g = _g, .b = _b}};
ws2812_setleds(leds, RGBLED_NUM);
}
static void rgblight_increase_hue(void) {
static uint8_t state = 0;
state = (state + 1) % 3;
switch (state) {
case 1:
rgblight_setrgb_red();
break;
case 2:
rgblight_setrgb_blue();
break;
default:
rgblight_setrgb_green();
break;
}
}

View File

@ -0,0 +1 @@
SRC += ws2812.c

View File

@ -0,0 +1,3 @@
#pragma once
#define TAPPING_TERM 500

View File

@ -0,0 +1,19 @@
#include QMK_KEYBOARD_H
enum layers {
_BASE = 0,
};
enum {
TD_BC = 0
};
qk_tap_dance_action_t tap_dance_actions[] = {
[TD_BC] = ACTION_TAP_DANCE_DOUBLE(KC_B, KC_C)
};
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_BASE] = LAYOUT(
KC_A, TD(TD_BC)
)
};

View File

@ -0,0 +1 @@
TAP_DANCE_ENABLE = yes

View File

@ -0,0 +1,7 @@
#include QMK_KEYBOARD_H
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT(
KC_VOLU, KC_VOLD
)
};

View File

@ -0,0 +1 @@
EXTRAKEY_ENABLE = yes

49
keyboards/xd002/readme.md Normal file
View File

@ -0,0 +1,49 @@
# xd002
![xd002](https://cdn.shopify.com/s/files/1/2711/4238/products/xd002_1024x1024.jpg?v=1522134411)
2% Custom mechanical keyboard. ATtiny85 powered, with 2*WS2812 LEDs, and the micronucleus bootloader.
**Note**: Due to limited firmware space, a _**lot**_ of features have to be disabled to get a functioning QMK based keyboard.
* Keyboard Maintainer: [zvecr](https://github.com/zvecr)
* Hardware Supported: xd002
* 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)
Make example for this keyboard (after setting up your build environment):
make xd002:default
See 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).
## Flashing
### Prerequisites
```bash
git clone https://github.com/micronucleus/micronucleus.git
cd micronucleus/commandline/
sudo make install
```
On Linux, youll 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:
```bash
sudo udevadm control --reload-rules
sudo udevadm trigger
```
### Instructions
**Reset Key**: Hold down key nearest to the USB socket while plugging in the keyboard.
```bash
make xd002:default:flash
# or directly with...
micronucleus --run <firmware.hex>
```
### Recovery
* [Original Firmware](https://github.com/xiudi/Attiny85_vusb_pad_test)
* [Bootloader Repair](https://digistump.com/wiki/digispark/tutorials/proisp)

34
keyboards/xd002/rules.mk Normal file
View File

@ -0,0 +1,34 @@
# MCU name
MCU = attiny85
# Bootloader selection
BOOTLOADER = micronucleus
OPT_DEFS += -DBOOTLOADER_SIZE=1862
PROGRAM_CMD = micronucleus --run $(BUILD_DIR)/$(TARGET).hex
# Build Options
# change yes to no to disable
#
BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration
MOUSEKEY_ENABLE = no # Mouse keys
EXTRAKEY_ENABLE = no # Audio control and System control
CONSOLE_ENABLE = no # Console for debug
COMMAND_ENABLE = no # Commands for debug and configuration
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
NKRO_ENABLE = no # USB Nkey Rollover
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality on B7 by default
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
MIDI_ENABLE = no # MIDI support
UNICODE_ENABLE = no # Unicode
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
AUDIO_ENABLE = no # Audio output on port C6
FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches
HD44780_ENABLE = no # Enable support for HD44780 based LCDs
# Save as much space as we can...
LTO_ENABLE = yes
GRAVE_ESC_ENABLE = no
MAGIC_ENABLE = no
SPACE_CADET_ENABLE = no

16
keyboards/xd002/xd002.c Normal file
View File

@ -0,0 +1,16 @@
/* Copyright 2020 zvecr<git@zvecr.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include "xd002.h"

33
keyboards/xd002/xd002.h Normal file
View File

@ -0,0 +1,33 @@
/* Copyright 2020 zvecr<git@zvecr.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "quantum.h"
/* This a shortcut to help you visually see your layout.
*
* The first section contains all of the arguments representing the physical
* layout of the board and position of the keys.
*
* The second converts the arguments into a two-dimensional array which
* represents the switch matrix.
*/
#define LAYOUT( \
K01, K02 \
) \
{ \
{ K01, K02 }, \
}