From 2a2f41c6de868c06c06cf437cf7c2b875b8c53a4 Mon Sep 17 00:00:00 2001 From: layne001365 Date: Tue, 12 Mar 2019 03:41:16 +0800 Subject: [PATCH] [Keyboard] Add HotDox keyboard (#5365) * Add HotDox * Update keyboards/hotdox/config.h Co-Authored-By: layne001365 * Update keyboards/hotdox/config.h Co-Authored-By: layne001365 * Update keyboards/hotdox/config.h Co-Authored-By: layne001365 * Update keyboards/hotdox/config.h Co-Authored-By: layne001365 * Update keyboards/hotdox/keymaps/default/keymap.c Co-Authored-By: layne001365 * * Update - keyboards/hotdox/config.h - keyboards/hotdox/hotdox.h - keyboards/hotdox/info.json - keyboards/hotdox/left.h - keyboards/hotdox/left.c - keyboards/hotdox/rules.mk * Replace EPRM with EPRM - keyboards/hotdox/keymaps/default/keymap.c - keyboards/hotdox/keymaps/eozaki/keymap.c - keyboards/hotdox/keymaps/kloki/keymap.c * Remove keymaps readme.md * Remove twimaster.h/ twimaster.c * * Update - remove FORCE_NKRO from keyboards/hotdox/config.h - keyboards/hotdox/hotdox.c - keyboards/hotdox/hotdox.h - keyboards/hotdox/keymaps/default/keymap.c - keyboards/hotdox/left.c - keyboards/hotdox/readme.md - keyboards/hotdox/rules.mk * Update keyboards/hotdox/keymaps/default/keymap.c Co-Authored-By: layne001365 * Update keyboards/hotdox/keymaps/default/keymap.c Co-Authored-By: layne001365 * Update keyboards/hotdox/rules.mk Co-Authored-By: layne001365 * Update keyboards/hotdox/rules.mk Co-Authored-By: layne001365 * Update keyboards/hotdox/rules.mk Co-Authored-By: layne001365 * Update keyboards/hotdox/rules.mk Co-Authored-By: layne001365 * Update keyboards/hotdox/rules.mk Co-Authored-By: layne001365 * Update keyboards/hotdox/hotdox.h Co-Authored-By: layne001365 * Update keyboards/hotdox/rules.mk Co-Authored-By: layne001365 * Update keyboards/hotdox/rules.mk Co-Authored-By: layne001365 * Update keyboards/hotdox/config.h Co-Authored-By: layne001365 * Update keyboards/hotdox/config.h Co-Authored-By: layne001365 --- keyboards/hotdox/config.h | 78 ++++++ keyboards/hotdox/hotdox.c | 44 ++++ keyboards/hotdox/hotdox.h | 187 ++++++++++++++ keyboards/hotdox/info.json | 107 ++++++++ keyboards/hotdox/keymaps/default/keymap.c | 190 +++++++++++++++ keyboards/hotdox/keymaps/eozaki/keymap.c | 192 +++++++++++++++ keyboards/hotdox/keymaps/kloki/keymap.c | 210 ++++++++++++++++ keyboards/hotdox/left.c | 130 ++++++++++ keyboards/hotdox/left.h | 57 +++++ keyboards/hotdox/matrix.c | 283 ++++++++++++++++++++++ keyboards/hotdox/readme.md | 23 ++ keyboards/hotdox/rules.mk | 82 +++++++ 12 files changed, 1583 insertions(+) create mode 100644 keyboards/hotdox/config.h create mode 100644 keyboards/hotdox/hotdox.c create mode 100644 keyboards/hotdox/hotdox.h create mode 100644 keyboards/hotdox/info.json create mode 100644 keyboards/hotdox/keymaps/default/keymap.c create mode 100644 keyboards/hotdox/keymaps/eozaki/keymap.c create mode 100644 keyboards/hotdox/keymaps/kloki/keymap.c create mode 100644 keyboards/hotdox/left.c create mode 100644 keyboards/hotdox/left.h create mode 100644 keyboards/hotdox/matrix.c create mode 100644 keyboards/hotdox/readme.md create mode 100644 keyboards/hotdox/rules.mk diff --git a/keyboards/hotdox/config.h b/keyboards/hotdox/config.h new file mode 100644 index 000000000..ed15f4bb4 --- /dev/null +++ b/keyboards/hotdox/config.h @@ -0,0 +1,78 @@ +#pragma once + +#include "config_common.h" + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0xE11D + +#define DEVICE_VER 0x0001 +#define MANUFACTURER Z.P.Z.O. +#define PRODUCT HotDox +#define DESCRIPTION QMK keyboard firmware for HotDox + +/* key matrix size */ +#define MATRIX_ROWS 6 +#define MATRIX_COLS 14 + +#define MOUSEKEY_INTERVAL 20 +#define MOUSEKEY_DELAY 0 +#define MOUSEKEY_TIME_TO_MAX 60 +#define MOUSEKEY_MAX_SPEED 7 +#define MOUSEKEY_WHEEL_DELAY 0 + +#define TAPPING_TOGGLE 1 + +/* define if matrix has ghost */ +//#define MATRIX_HAS_GHOST + +#define TAPPING_TERM 200 +#define IGNORE_MOD_TAP_INTERRUPT // this makes it possible to do rolling combos (zx) with keys that convert to other keys on hold (z becomes ctrl when you hold it, and when this option isn't enabled, z rapidly followed by x actually sends Ctrl-x. That's bad.) + +/* 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 */ +#ifndef IS_COMMAND +#define IS_COMMAND() ( \ + get_mods() == MOD_MASK_CTRL || \ + get_mods() == MOD_MASK_SHIFT \ +) +#endif + +#define BACKLIGHT_PIN B7 +/* number of backlight levels */ +#define BACKLIGHT_LEVELS 3 + +#define LED_BRIGHTNESS_LO 15 +#define LED_BRIGHTNESS_HI 255 + +/* fix space cadet rollover issue */ +#define DISABLE_SPACE_CADET_ROLLOVER + +/* Set 0 if debouncing isn't needed */ +#define DEBOUNCE 5 + +#define USB_MAX_POWER_CONSUMPTION 500 + +/* + * Feature disable options + * These options are also useful to firmware size reduction. + */ + +/* disable debug print */ +// #define NO_DEBUG + +/* disable print */ +// #define NO_PRINT + +/* disable action features */ +//#define NO_ACTION_LAYER +//#define NO_ACTION_TAPPING +//#define NO_ACTION_ONESHOT +//#define NO_ACTION_MACRO +//#define NO_ACTION_FUNCTION +//#define DEBUG_MATRIX_SCAN_RATE + diff --git a/keyboards/hotdox/hotdox.c b/keyboards/hotdox/hotdox.c new file mode 100644 index 000000000..00af9efb1 --- /dev/null +++ b/keyboards/hotdox/hotdox.c @@ -0,0 +1,44 @@ +#include "hotdox.h" +#include "backlight.h" +#include "quantum.h" + +extern inline void ergodox_board_led_on(void); +extern inline void ergodox_right_led_1_on(void); +extern inline void ergodox_right_led_2_on(void); +extern inline void ergodox_right_led_3_on(void); + +extern inline void ergodox_board_led_off(void); +extern inline void ergodox_right_led_1_off(void); +extern inline void ergodox_right_led_2_off(void); +extern inline void ergodox_right_led_3_off(void); + +extern inline void ergodox_led_all_on(void); +extern inline void ergodox_led_all_off(void); + +void ergodox_led_init(void); +void ergodox_blink_all_leds(void); + +void matrix_init_kb(void) { + ergodox_blink_all_leds(); + matrix_init_user(); +} + +void ergodox_blink_all_leds(void) +{ + ergodox_led_all_off(); + ergodox_led_all_set(LED_BRIGHTNESS_HI); + ergodox_right_led_1_on(); + _delay_ms(50); + ergodox_right_led_2_on(); + _delay_ms(50); + ergodox_right_led_3_on(); + _delay_ms(50); + ergodox_right_led_1_off(); + _delay_ms(50); + ergodox_right_led_2_off(); + _delay_ms(50); + ergodox_right_led_3_off(); + ergodox_led_all_on(); + _delay_ms(333); + ergodox_led_all_off(); +} diff --git a/keyboards/hotdox/hotdox.h b/keyboards/hotdox/hotdox.h new file mode 100644 index 000000000..d79f335ad --- /dev/null +++ b/keyboards/hotdox/hotdox.h @@ -0,0 +1,187 @@ +#pragma once + +#include "quantum.h" +#include +#include + +#define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n)) +#define CPU_16MHz 0x00 + +void init_ergodox(void); + +inline void ergodox_board_led_on(void) { DDRB |= (1<event.pressed) { + SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION); + } + return false; + break; + case RGB_SLD: + if (record->event.pressed) { + #ifdef RGBLIGHT_ENABLE + rgblight_mode(1); + #endif + } + return false; + break; + } + return true; +} + +// Runs just one time when the keyboard initializes. +void matrix_init_user(void) { + +}; + + +// Runs constantly in the background, in a loop. +void matrix_scan_user(void) { + + uint8_t layer = biton32(layer_state); + + ergodox_right_led_1_off(); + ergodox_right_led_2_off(); + ergodox_right_led_3_off(); + switch (layer) { + // TODO: Make this relevant to the ErgoDox EZ. + case 1: + ergodox_right_led_1_on(); + break; + case 2: + ergodox_right_led_2_on(); + break; + default: + // none + break; + } +}; diff --git a/keyboards/hotdox/keymaps/eozaki/keymap.c b/keyboards/hotdox/keymaps/eozaki/keymap.c new file mode 100644 index 000000000..dc80e7a34 --- /dev/null +++ b/keyboards/hotdox/keymaps/eozaki/keymap.c @@ -0,0 +1,192 @@ +#include QMK_KEYBOARD_H +#include "version.h" + +#define BASE 0 // default layer +#define SYMB 1 // symbols +#define MDIA 2 // media keys + +enum custom_keycodes { + PLACEHOLDER = SAFE_RANGE, // can always be here + VRSN, + RGB_SLD +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { +/* Keymap 0: Basic layer + * + * ,--------------------------------------------------. ,--------------------------------------------------. + * | Esc | 1 | 2 | 3 | 4 | 5 | ~ | | ' | 6 | 7 | 8 | 9 | 0 | = | + * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------| + * | Del | Q | W | E | R | T | ~ | | " | Y | U | I | O | P | - | + * |--------+------+------+------+------+------| ` | | |------+------+------+------+------+--------| + * | Ctrl | A | S | D | F | G |------| |------| H | J | K | L | ; | \ | + * |--------+------+------+------+------+------| { | | } |------+------+------+------+------+--------| + * | LAlt | Z | X | C | V | B | [ | | ] | N | M | , | . | / | LShift | + * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' + * | LT-1 | F4 | F5 | F6 | F11 | | Left | Down | Up | Right| RAlt | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | L1 | Prev | | Vol+ | L2 | + * ,------|------|------| |------+--------+------. + * | | | Play | | Vol- | | | + * | Space|Backsp|------| |------| Tab |Enter | + * | |ace | Next | | Mute | | | + * `--------------------' `----------------------' + */ +// If it accepts an argument (i.e, is a function), it doesn't need KC_. +// Otherwise, it needs KC_* +[BASE] = LAYOUT_ergodox( // layer 0 : default + // left hand + KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, LSFT(KC_GRV), + KC_DELT, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_GRV, + KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, + KC_LALT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_LBRC, + LT(SYMB, KC_F2), KC_F4, KC_F5, KC_F6, KC_F11, + TG(SYMB), KC_MPRV, + KC_MPLY, + KC_SPC,KC_BSPC,KC_MNXT, + // right hand + KC_QUOT, KC_6, KC_7, KC_8, KC_9, KC_0, KC_EQL, + LSFT(KC_QUOT), KC_Y, KC_U, KC_I, KC_O, KC_P, KC_MINS, + KC_H, KC_J, KC_K, KC_L, LT(MDIA, KC_SCLN),KC_BSLS, + KC_RBRC, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_LSFT, + KC_LEFT,KC_DOWN,KC_UP, KC_RGHT,KC_RALT, + KC_VOLU, TG(MDIA), + KC_VOLD, + KC_MUTE,KC_TAB, KC_ENT + ), +/* Keymap 1: Symbol Layer + * + * ,---------------------------------------------------. ,--------------------------------------------------. + * |Version | F1 | F2 | F3 | F4 | F5 | | | | F6 | F7 | F8 | F9 | F10 | F11 | + * |---------+------+------+------+------+------+------| |------+------+------+------+------+------+--------| + * | | ! | @ | { | } | | | | | | Up | 7 | 8 | 9 | * | F12 | + * |---------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | # | $ | ( | ) | ` |------| |------| Down | 4 | 5 | 6 | + | | + * |---------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | % | ^ | [ | ] | ~ | | | | & | 1 | 2 | 3 | \ | | + * `---------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' + * | EEP_RST | | | | | | | . | 0 | = | | + * `-----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * |Animat| | |Toggle|Solid | + * ,------|------|------| |------+------+------. + * |Bright|Bright| | | |Hue- |Hue+ | + * |ness- |ness+ |------| |------| | | + * | | | | | | | | + * `--------------------' `--------------------' + */ +// SYMBOLS +[SYMB] = LAYOUT_ergodox( + // left hand + VRSN, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_TRNS, + KC_TRNS,KC_EXLM,KC_AT, KC_LCBR,KC_RCBR,KC_PIPE,KC_TRNS, + KC_TRNS,KC_HASH,KC_DLR, KC_LPRN,KC_RPRN,KC_GRV, + KC_TRNS,KC_PERC,KC_CIRC,KC_LBRC,KC_RBRC,KC_TILD,KC_TRNS, + EEP_RST,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS, + RGB_MOD,KC_TRNS, + KC_TRNS, + RGB_VAD,RGB_VAI,KC_TRNS, + // right hand + KC_TRNS, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, + KC_TRNS, KC_UP, KC_7, KC_8, KC_9, KC_ASTR, KC_F12, + KC_DOWN, KC_4, KC_5, KC_6, KC_PLUS, KC_TRNS, + KC_TRNS, KC_AMPR, KC_1, KC_2, KC_3, KC_BSLS, KC_TRNS, + KC_TRNS,KC_DOT, KC_0, KC_EQL, KC_TRNS, + RGB_TOG, RGB_SLD, + KC_TRNS, + KC_TRNS, RGB_HUD, RGB_HUI +), +/* Keymap 2: Media and mouse keys + * + * ,--------------------------------------------------. ,--------------------------------------------------. + * | | | | | | | | | | | | | | | | + * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------| + * | | | | MsUp | | | | | | | | | | | | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | |MsLeft|MsDown|MsRght| |------| |------| | | | | | Play | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | | | | | | | | | | | Prev | Next | | | + * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' + * | | | | Lclk | Rclk | |VolUp |VolDn | Mute | | | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | | | | | | + * ,------|------|------| |------+------+------. + * | | | | | | |Brwser| + * | | |------| |------| |Back | + * | | | | | | | | + * `--------------------' `--------------------' + */ +// MEDIA AND MOUSE +[MDIA] = LAYOUT_ergodox( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_MS_U, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_MS_L, KC_MS_D, KC_MS_R, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_BTN1, KC_BTN2, + KC_TRNS, KC_TRNS, + KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, + // right hand + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MPLY, + KC_TRNS, KC_TRNS, KC_TRNS, KC_MPRV, KC_MNXT, KC_TRNS, KC_TRNS, + KC_VOLU, KC_VOLD, KC_MUTE, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, + KC_TRNS, + KC_TRNS, KC_TRNS, KC_WBAK +), +}; + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + // dynamically generate these. + case VRSN: + if (record->event.pressed) { + SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION); + } + return false; + break; + case RGB_SLD: + if (record->event.pressed) { + #ifdef RGBLIGHT_ENABLE + rgblight_mode(1); + #endif + } + return false; + break; + } + return true; +} + +// Runs just one time when the keyboard initializes. +void matrix_init_user(void) { + +}; + + +// Runs constantly in the background, in a loop. +void matrix_scan_user(void) { + + uint8_t layer = biton32(layer_state); + + ergodox_board_led_off(); + ergodox_right_led_1_off(); + ergodox_right_led_2_off(); + ergodox_right_led_3_off(); + switch (layer) { + // TODO: Make this relevant to the ErgoDox EZ. + case 1: + ergodox_right_led_1_on(); + break; + case 2: + ergodox_right_led_2_on(); + break; + default: + // none + break; + } + +}; diff --git a/keyboards/hotdox/keymaps/kloki/keymap.c b/keyboards/hotdox/keymaps/kloki/keymap.c new file mode 100644 index 000000000..f858effd5 --- /dev/null +++ b/keyboards/hotdox/keymaps/kloki/keymap.c @@ -0,0 +1,210 @@ +#include QMK_KEYBOARD_H +#include "version.h" + +#define BASE 0 // default layer +#define QW 1 // qwerty +#define SYMB 2 // symbols +#define NUM 3 // media keys + +enum custom_keycodes { + PLACEHOLDER = SAFE_RANGE, // can always be here + VRSN, + RGB_SLD +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { +/* Keymap 0: Basic layer + * + * ,--------------------------------------------------. ,--------------------------------------------------. + * | Esc | 1 | 2 | 3 | 4 | 5 | SHIFT| | SYM | 6 | 7 | 8 | 9 | 0 | Bck | + * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------| + * | Tab | Q | D | R | W | B | `~ | | "' | J | F | U | P | : | \ | | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | Ctr/Es | A | S | H | T | G |------| |------| Y | N | E | O | I | Enter | + * |--------+------+------+------+------+------| = + | | -_ |------+------+------+------+------+--------| + * | LShift | Z | X | M | C | V | | | | K | L | , | . | / | RShift | + * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' + * |MEH | Gui |AltShf| Left | Right| | DOWN | UP | [ | ] | ~SYM | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | ESC |Home | | PgUp | QW | + * ,------|------|------| |------+--------+------. + * | | ENT | End | | PgDn | | | + * | Space| WIN |------| |------| Tab |Back | + * | SYM | | SCTR | | SALT | SYM | | + * `--------------------' `----------------------' + */ + +[BASE] = LAYOUT_ergodox( // layer 0 : default + // left hand + KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_LSFT, + KC_TAB, KC_Q, KC_D, KC_R, KC_W, KC_B, KC_GRV, + CTL_T(KC_ESC), KC_A, KC_S, KC_H, KC_T, KC_G, + KC_LSFT, KC_Z, KC_X, KC_M, KC_C, KC_V, KC_EQL, + KC_MEH, KC_LGUI, KC_LALT, KC_LEFT,KC_RGHT, + KC_ESC, KC_HOME, + KC_END, + LT(SYMB, KC_SPC), LGUI_T(KC_ENT), S(KC_LGUI), + // right hand + TG(NUM), KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, + KC_QUOT, KC_J, KC_F, KC_U, KC_P, KC_SCLN, KC_BSLS, + KC_Y, KC_N, KC_E, KC_O, KC_I , KC_ENT, + KC_MINS, KC_K, KC_L, KC_COMM,KC_DOT, KC_SLSH, KC_RSFT, + KC_DOWN,KC_UP, KC_LBRC,KC_RBRC, MO(SYMB), + KC_PGUP, TG(QW), + KC_PGDN, + S(KC_LALT),LT(SYMB, KC_TAB), KC_BSPC + ), + +[QW] = LAYOUT_ergodox( + _______, _______, _______, _______, _______, _______, _______, + _______, KC_Q, KC_W, KC_E, KC_R, KC_T, _______, + _______, KC_A, KC_S, KC_D, KC_F, KC_G, + _______, KC_Z, KC_X, KC_C, KC_V, KC_B, _______, + _______, _______, _______, _______, _______, + _______, _______, + _______, + _______, _______, _______, + // right hand + _______, _______, _______, _______, _______, _______, _______, + _______, KC_Y, KC_U, KC_I , KC_O, KC_P, _______, + KC_H, KC_J, KC_K , KC_L, KC_SCLN, _______, + _______, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, _______, + _______, _______, _______, _______, _______, + _______, _______, + _______, + _______, _______, _______ +), +/* Keymap 1: Symbol Layer + * + * ,---------------------------------------------------. ,--------------------------------------------------. + * | | F1 | F2 | F3 | F4 | F5 | | | | F6 | F7 | F8 | F9 | F10 | DEL | + * |---------+------+------+------+------+------+------| |------+------+------+------+------+------+--------| + * | | ! | @ | { | } | * | | | | < | H | U | PU | * | | + * |---------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | # | $ | ( | ) | ` |------| |------| > | L | D | R | + | | + * |---------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | % | ^ | [ | ] | ~ | | | | & | E | D | PD | \ | | + * `---------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' + * | | | | | | | | | | | | + * `-----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | | | | | | + * ,------|------|------| |------+------+------. + * | | | | | | | | + * | | |------| |------| | | + * | | | | | | | | + * `--------------------' `--------------------' + */ +// SYMBOLS +[SYMB] = LAYOUT_ergodox( + // left hand + _______,KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, _______, + _______,KC_EXLM,KC_AT, KC_LCBR,KC_RCBR,KC_ASTR,_______, + _______,KC_HASH,KC_DLR, KC_LPRN,KC_RPRN,KC_GRV, + _______,KC_PERC,KC_CIRC,KC_LBRC,KC_RBRC,KC_TILD,_______, + _______,_______,_______,_______,_______, + _______,_______, + _______, + _______,_______,_______, + // right hand + _______, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_DEL, + _______, KC_LABK, KC_HOME, KC_UP, KC_PGUP, KC_ASTR, _______, + KC_RABK, KC_LEFT, KC_DOWN, KC_RIGHT, KC_PLUS, _______, + _______, KC_AMPR, KC_END, KC_DOWN, KC_PGDN, KC_BSLS, _______, + _______, _______, _______, _______, _______, + _______, _______, + _______, + _______, _______, _______ +), +/* Keymap 2: Media and mouse keys + * + * ,--------------------------------------------------. ,--------------------------------------------------. + * | | | | | | | | | | | | | | | | + * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------| + * | | | L | MsUp | R | | | | | | 4 | 5 | 6 | | TAB | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | |MsLeft|MsDown|MsRght| |------| |------| | 1 | 2 | 3 | | | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | | | | | | | | | | | 0 | 0 | | | + * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' + * | | | | | | | | | | | | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | | | | | | + * ,------|------|------| |------+------+------. + * | | | | | | | | + * | | |------| |------| | | + * | | | | | | | | + * `--------------------' `--------------------' + */ +[NUM] = LAYOUT_ergodox( + _______, _______, _______, _______, _______, _______, _______, + _______, _______, KC_BTN1, KC_MS_U, KC_BTN2, _______, _______, + _______, _______, KC_MS_L, KC_MS_D, KC_MS_R, _______, + _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, + _______, _______, + _______, + _______, _______, _______, + // right hand + _______, _______, _______, _______, _______, _______, _______, + _______, _______, KC_4, KC_5 , KC_6, _______, KC_TAB, + _______, KC_1, KC_2 , KC_3, _______, _______, + _______, _______, _______, KC_0, KC_0, _______, _______, + _______, _______, _______, _______, _______, + _______, _______, + _______, + _______, _______, _______ +), +}; + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + // dynamically generate these. + case VRSN: + if (record->event.pressed) { + SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION); + } + return false; + break; + case RGB_SLD: + if (record->event.pressed) { + #ifdef RGBLIGHT_ENABLE + rgblight_mode(1); + #endif + } + return false; + break; + } + return true; +} + +// Runs just one time when the keyboard initializes. +void matrix_init_user(void) { + +}; + + +// Runs constantly in the background, in a loop. +void matrix_scan_user(void) { + + uint8_t layer = biton32(layer_state); + + ergodox_board_led_off(); + ergodox_right_led_1_off(); + ergodox_right_led_2_off(); + ergodox_right_led_3_off(); + switch (layer) { + case 1: + ergodox_board_led_on(); + break; + case 3: + ergodox_board_led_on(); + break; + default: + // none + break; + } + +}; diff --git a/keyboards/hotdox/left.c b/keyboards/hotdox/left.c new file mode 100644 index 000000000..ae56b1816 --- /dev/null +++ b/keyboards/hotdox/left.c @@ -0,0 +1,130 @@ +#include "action.h" +#include "left.h" +#include "wait.h" + +bool i2c_initialized = false; + +void left_config(void); +uint8_t left_write(uint8_t reg, uint8_t data); +uint8_t left_read(uint8_t reg, uint8_t *data); + +uint8_t init_mcp23017(void) +{ + i2c_initialized = false; + + if (i2c_initialized == 0) + { + i2c_init(); // on pins D(1,0) + _delay_ms(1000); + } + + return 0; +} +void left_init(void) +{ + init_mcp23017(); + left_scan(); +#if 0 + while (1) + { + print("wait\n"); + wait_us(1000000); + } +#endif +} + +void left_scan(void) +{ + uint8_t ret = i2c_start(I2C_ADDR_WRITE, HOTDOX_I2C_TIMEOUT); + + if (ret == 0) + { + i2c_stop(HOTDOX_I2C_TIMEOUT); + + if (!i2c_initialized) + { + i2c_initialized = true; + left_config(); + clear_keyboard(); + print("mcp23017 attached!!!\n"); + } + } + else + { + if (i2c_initialized) + { + i2c_initialized = false; + clear_keyboard(); + print("mcp23017 deattached!!!\n"); + } + } + + return; +} + +uint8_t left_read_cols(void) +{ + uint8_t data = 0; + + left_read(MCP23017_B0_GPIOA, &data); + + return data; +} + +void left_unselect_rows(void) +{ + left_write(MCP23017_B0_IODIRB, 0x3F); +} + +void left_select_row(uint8_t row) +{ + left_write(MCP23017_B0_IODIRB, ~(1 << row)); +} + +void left_config(void) +{ + left_write(MCP23017_B0_IODIRA, 0x7F); + left_write(MCP23017_B0_IPOLA, 0x7F); + left_write(MCP23017_B0_GPPUA, 0x7F); + + left_write(MCP23017_B0_IODIRB, 0xFF); + left_write(MCP23017_B0_GPIOB, 0xC0); +} + +uint8_t left_write(uint8_t reg, uint8_t data) +{ + if (!i2c_initialized) + { + return 0; + } + + uint8_t ret; + + ret = i2c_start(I2C_ADDR_WRITE, HOTDOX_I2C_TIMEOUT); if (ret) goto out; + ret = i2c_write(reg, HOTDOX_I2C_TIMEOUT); if (ret) goto out; + ret = i2c_write(data, HOTDOX_I2C_TIMEOUT); + +out: + i2c_stop(HOTDOX_I2C_TIMEOUT); + return ret; +} + +uint8_t left_read(uint8_t reg, uint8_t *data) +{ + if (!i2c_initialized) + { + return 0; + } + + uint8_t ret = 0; + + ret = i2c_start(I2C_ADDR_WRITE, HOTDOX_I2C_TIMEOUT); if (ret) goto out; + ret = i2c_write(reg, HOTDOX_I2C_TIMEOUT); if (ret) goto out; + ret = i2c_start(I2C_ADDR_READ, HOTDOX_I2C_TIMEOUT); if (ret) goto out; + + *data = i2c_read_nack(HOTDOX_I2C_TIMEOUT); + +out: + i2c_stop(HOTDOX_I2C_TIMEOUT); + return ret; +} diff --git a/keyboards/hotdox/left.h b/keyboards/hotdox/left.h new file mode 100644 index 000000000..3d8b5a6ea --- /dev/null +++ b/keyboards/hotdox/left.h @@ -0,0 +1,57 @@ +#pragma once + +#include "quantum.h" +#include +#include "i2c_master.h" +#include + +#define MCP23017 +#define MCP23017_A0 0 +#define MCP23017_A1 0 +#define MCP23017_A2 0 + +#define I2C_ADDR (0x20) +#define I2C_ADDR_WRITE ((I2C_ADDR << 1) | I2C_WRITE) +#define I2C_ADDR_READ ((I2C_ADDR << 1) | I2C_READ) + + +#define MCP23017_B0_IODIRA 0x00 +#define MCP23017_B0_IODIRB 0x01 +#define MCP23017_B0_IPOLA 0x02 +#define MCP23017_B0_IPOLB 0x03 +#define MCP23017_B0_GPINTENA 0x04 +#define MCP23017_B0_GPINTENB 0x05 +#define MCP23017_B0_DEFVALA 0x06 +#define MCP23017_B0_DEFVALB 0x07 +#define MCP23017_B0_INTCONA 0x08 +#define MCP23017_B0_INTCONB 0x09 +#define MCP23017_B0_IOCONA 0x0A +#define MCP23017_B0_IOCONB 0x0B +#define MCP23017_B0_GPPUA 0x0C +#define MCP23017_B0_GPPUB 0x0D +#define MCP23017_B0_INTFA 0x0E +#define MCP23017_B0_INTFB 0x0F +#define MCP23017_B0_INTCAPA 0x10 +#define MCP23017_B0_INTCAPB 0x11 +#define MCP23017_B0_GPIOA 0x12 +#define MCP23017_B0_GPIOB 0x13 +#define MCP23017_B0_OLATA 0x14 +#define MCP23017_B0_OLATB 0x15 + +#define HOTDOX_I2C_TIMEOUT 100 + +typedef int16_t i2c_status_t; + +void left_init(void); +void left_scan(void); + +uint8_t left_read_cols(void); +uint8_t left_get_col(uint8_t col); + +matrix_row_t left_read_row(void); + +void left_unselect_rows(void); +void left_select_row(uint8_t row); + +uint8_t init_mcp23017(void); + diff --git a/keyboards/hotdox/matrix.c b/keyboards/hotdox/matrix.c new file mode 100644 index 000000000..9d3a98db2 --- /dev/null +++ b/keyboards/hotdox/matrix.c @@ -0,0 +1,283 @@ +#include +#include +#include +#include "wait.h" +#include "action_layer.h" +#include "print.h" +#include "debug.h" +#include "util.h" +#include "matrix.h" +#include "hotdox.h" +#include "left.h" +#ifdef DEBUG_MATRIX_SCAN_RATE +#include "timer.h" +#endif + +/* + * This constant define not debouncing time in msecs, but amount of matrix + * scan loops which should be made to get stable debounced results. + * + * On Ergodox matrix scan rate is relatively low, because of slow I2C. + * Now it's only 317 scans/second, or about 3.15 msec/scan. + * According to Cherry specs, debouncing time is 5 msec. + * + * And so, there is no sense to have DEBOUNCE higher than 2. + */ + +#ifndef DEBOUNCE +# define DEBOUNCE 5 +#endif + +/* matrix state(1:on, 0:off) */ +static matrix_row_t matrix[MATRIX_ROWS]; + +// Debouncing: store for each key the number of scans until it's eligible to +// change. When scanning the matrix, ignore any changes in keys that have +// already changed in the last DEBOUNCE scans. +static uint8_t debounce_matrix[MATRIX_ROWS * MATRIX_COLS]; + +static matrix_row_t read_cols(uint8_t row); +static void init_cols(void); +static void unselect_rows(void); +static void select_row(uint8_t row); + +#ifdef DEBUG_MATRIX_SCAN_RATE +uint32_t matrix_timer; +uint32_t matrix_scan_count; +#endif + + +__attribute__ ((weak)) +void matrix_init_user(void) {} + +__attribute__ ((weak)) +void matrix_scan_user(void) {} + +__attribute__ ((weak)) +void matrix_init_kb(void) { + matrix_init_user(); +} + +__attribute__ ((weak)) +void matrix_scan_kb(void) { + matrix_scan_user(); +} + +inline +uint8_t matrix_rows(void) +{ + return MATRIX_ROWS; +} + +inline +uint8_t matrix_cols(void) +{ + return MATRIX_COLS; +} + +void matrix_init(void) +{ + // disable JTAG + MCUCR = (1<1000) { + print("matrix scan frequency: "); + pdec(matrix_scan_count); + print("\n"); + matrix_print(); + + matrix_timer = timer_now; + matrix_scan_count = 0; + } +#endif + for (uint8_t i = 0; i < MATRIX_ROWS; i++) { + select_row(i); + wait_us(30); // without this wait read unstable value. + matrix_row_t mask = debounce_mask(i); + matrix_row_t cols = (read_cols(i) & mask) | (matrix[i] & ~mask); + debounce_report(cols ^ matrix[i], i); + matrix[i] = cols; + + unselect_rows(); + } + + matrix_scan_quantum(); + + return 1; +} + +inline +bool matrix_is_on(uint8_t row, uint8_t col) +{ + return (matrix[row] & ((matrix_row_t)1<