From 3fe356e65c65f725e94f3ad32fd65cc24befb531 Mon Sep 17 00:00:00 2001 From: Mango The Fourth <40720523+MangoIV@users.noreply.github.com> Date: Tue, 27 Apr 2021 19:41:11 +0200 Subject: [PATCH] Add Draculad keyboard (#12604) Co-authored-by: Drashna Jaelre Co-authored-by: Ryan Co-authored-by: Erovia Co-authored-by: mangoiv --- keyboards/draculad/config.h | 67 ++++ keyboards/draculad/draculad.c | 18 + keyboards/draculad/draculad.h | 39 +++ keyboards/draculad/keymaps/default/keymap.c | 220 ++++++++++++ keyboards/draculad/keymaps/pimoroni/config.h | 25 ++ keyboards/draculad/keymaps/pimoroni/keymap.c | 318 ++++++++++++++++++ .../keymaps/pimoroni/pimoroni_trackball.c | 177 ++++++++++ .../keymaps/pimoroni/pimoroni_trackball.h | 35 ++ keyboards/draculad/keymaps/pimoroni/rules.mk | 6 + keyboards/draculad/readme.md | 33 ++ keyboards/draculad/rules.mk | 27 ++ 11 files changed, 965 insertions(+) create mode 100644 keyboards/draculad/config.h create mode 100644 keyboards/draculad/draculad.c create mode 100644 keyboards/draculad/draculad.h create mode 100644 keyboards/draculad/keymaps/default/keymap.c create mode 100644 keyboards/draculad/keymaps/pimoroni/config.h create mode 100644 keyboards/draculad/keymaps/pimoroni/keymap.c create mode 100644 keyboards/draculad/keymaps/pimoroni/pimoroni_trackball.c create mode 100644 keyboards/draculad/keymaps/pimoroni/pimoroni_trackball.h create mode 100644 keyboards/draculad/keymaps/pimoroni/rules.mk create mode 100644 keyboards/draculad/readme.md create mode 100644 keyboards/draculad/rules.mk diff --git a/keyboards/draculad/config.h b/keyboards/draculad/config.h new file mode 100644 index 0000000000..8a27fdea4d --- /dev/null +++ b/keyboards/draculad/config.h @@ -0,0 +1,67 @@ +/* +Copyright 2021 @mangoiv + +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 . +*/ + +#pragma once + +#include "config_common.h" + +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x1B1E +#define DEVICE_VER 0x0001 +#define MANUFACTURER mangoiv +#define PRODUCT draculad + +#define MATRIX_ROWS 8 +#define MATRIX_COLS 5 + +#define MATRIX_ROW_PINS {D4, C6, D7, E6} +#define MATRIX_COL_PINS {F4, F5,F6, F7, B1} + +#define DIODE_DIRECTION COL2ROW + +#define DEBOUNCE 5 + + +#define USE_SERIAL +#define SOFT_SERIAL_PIN D2 + +#ifdef OLED_DRIVER_ENABLE + #define OLED_DISPLAY_128X64 + #define OLED_TIMEOUT 30000 +#endif + +#define RGB_DI_PIN D3 +#ifdef RGB_DI_PIN +#define RGBLIGHT_EFFECT_RAINBOW_SWIRL +#define RGBLIGHT_EFFECT_RAINBOW_MOOD +#define RGBLIGHT_EFFECT_STATIC_GRADIENT +#define RGBLIGHT_EFFECT_BREATHING +#define RGBLED_NUM 10 +#define RGBLIGHT_SPLIT +#define RGBLIGHT_HUE_STEP 8 +#define RGBLIGHT_SAT_STEP 8 +#define RGBLIGHT_VAL_STEP 8 +#define RGBLIGHT_SLEEP +#endif + +#define ENCODERS_PAD_A {B2 , B4} +#define ENCODERS_PAD_B {B6 , B5} + +#define ENCODER_RESOLUTIONS { 4, 4, 4, 1} +#define UNUSED_PINS + +#define EE_HANDS diff --git a/keyboards/draculad/draculad.c b/keyboards/draculad/draculad.c new file mode 100644 index 0000000000..04a83ef2e3 --- /dev/null +++ b/keyboards/draculad/draculad.c @@ -0,0 +1,18 @@ +/* +Copyright 2021 @mangoiv + +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 . +*/ + +#include "draculad.h" \ No newline at end of file diff --git a/keyboards/draculad/draculad.h b/keyboards/draculad/draculad.h new file mode 100644 index 0000000000..47d4b21435 --- /dev/null +++ b/keyboards/draculad/draculad.h @@ -0,0 +1,39 @@ +/* +Copyright 2021 @mangoiv + +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 . +*/ + +#pragma once + +#include "quantum.h" + +#define XXX KC_NO + +#define LAYOUT( \ + L00, L01, L02, L03, L04, R00, R01, R02, R03, R04, \ + L10, L11, L12, L13, L14, R10, R11, R12, R13, R14, \ + L20, L21, L22, L23, L24, R20, R21, R22, R23, R24, \ + L30, L31, L32, L33, R30, R31, R32, R33 \ + ) \ + { \ + { L00, L01, L02, L03, L04 }, \ + { L10, L11, L12, L13, L14 }, \ + { L20, L21, L22, L23, L24 }, \ + { XXX, L30, L31, L32, L33 }, \ + { R04, R03, R02, R01, R00 }, \ + { R14, R13, R12, R11, R10 }, \ + { R24, R23, R22, R21, R20 }, \ + { XXX, R33, R32, R31, R30 } \ + } diff --git a/keyboards/draculad/keymaps/default/keymap.c b/keyboards/draculad/keymaps/default/keymap.c new file mode 100644 index 0000000000..b24cca9327 --- /dev/null +++ b/keyboards/draculad/keymaps/default/keymap.c @@ -0,0 +1,220 @@ +/* +Copyright 2021 @mangoiv + +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 . +*/ + +#include QMK_KEYBOARD_H + + +enum layer_number { + _BASE, + _NUM, + _SYMB, + _MUS, + _ADJ +}; + + +char wpm_as_str[8]; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_BASE] = LAYOUT( + KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, + KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K , KC_L , KC_SCLN, + LSFT_T(KC_Z), KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, RSFT_T(KC_SLSH), + KC_MUTE, KC_LCTL, LALT_T(KC_BSPC), LT(_MUS, KC_SPC), LT(_NUM,KC_DEL), LT(_SYMB, KC_ENT), KC_CAPS, TG(_ADJ) + ), + [_NUM] = LAYOUT( + KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, + KC_TAB, XXXXXXX, KC_VOLD, KC_VOLU, XXXXXXX, KC_LEFT, KC_DOWN, KC_UP , KC_RIGHT , KC_QUOT, + KC_LSFT, XXXXXXX, XXXXXXX, KC_MUTE, RESET, KC_HOME, KC_END, KC_PGUP, KC_PGDN, KC_RSFT, + XXXXXXX, XXXXXXX, KC_LALT, XXXXXXX, _______, KC_ENT, KC_NO, KC_NO + ), + [_SYMB] = LAYOUT( + KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, XXXXXXX, XXXXXXX, XXXXXXX, KC_EQL, KC_MINS, + XXXXXXX, KC_F5, KC_F6, KC_F7, KC_F8, KC_LBRC, KC_RBRC, XXXXXXX , KC_GRV , KC_BSLS, + KC_LSFT, KC_F9, KC_F10, KC_F11, KC_F12, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_RSFT, + XXXXXXX, KC_LALT, XXXXXXX, XXXXXXX, XXXXXXX, _______, KC_NO, KC_NO + ), + [_MUS] = LAYOUT( + KC_LCTL, XXXXXXX, XXXXXXX, XXXXXXX,XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + KC_LALT, KC_BTN3, KC_BTN2, KC_BTN1 , XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX , XXXXXXX , XXXXXXX, + KC_LSFT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX + ), + [_ADJ] = LAYOUT( + RESET, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + EEP_RST, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, RGB_MOD, RGB_HUI, RGB_SAI , RGB_VAI , RGB_TOG, + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, RGB_RMOD, RGB_HUD, RGB_SAD, RGB_VAD, _______, + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _______ + ) +}; + +#ifdef OLED_DRIVER_ENABLE + + +oled_rotation_t oled_init_user(oled_rotation_t rotation) { + + if (is_keyboard_master()) { + if(is_keyboard_left()){ + return OLED_ROTATION_270; + } + else { + return OLED_ROTATION_90; + } + } else { + return OLED_ROTATION_0; + } +} +static void render_logo(void) { + static const char PROGMEM drac_logo[] = { + // drac_logo, 128x64px + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x0c, 0x18, 0x78, 0xf0, 0xf0, 0xe0, 0xe0, 0xc0, + 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x07, 0x3e, 0xfc, 0xf0, 0x00, 0x00, 0x00, + 0xf0, 0xf0, 0x60, 0x30, 0x30, 0x30, 0x00, 0x00, 0xe0, 0xe0, 0x30, 0x30, 0x30, 0x30, 0x30, 0xe0, + 0xe0, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0x70, 0x30, 0x30, 0x30, 0x70, 0xe0, 0xc0, 0x00, 0x00, + 0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xe0, 0xe0, 0xe0, 0xc0, + 0x80, 0x00, 0x00, 0x00, 0x80, 0xe0, 0xf8, 0xf0, 0x80, 0xc0, 0xe0, 0xf0, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x3f, 0xff, 0xff, + 0xff, 0xff, 0xfe, 0xfc, 0xf8, 0xe0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xc0, 0xe0, 0x7c, 0x3f, 0x0f, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0xf8, 0xcc, 0x8c, 0x84, 0x86, 0x86, 0xc6, 0xff, + 0xff, 0x80, 0x80, 0x00, 0x3f, 0x7f, 0xe0, 0xc0, 0x80, 0x80, 0x80, 0xc0, 0xf0, 0x71, 0x00, 0x00, + 0x1f, 0xff, 0xff, 0x80, 0x80, 0x80, 0x80, 0xc0, 0xf8, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x03, 0x03, 0x07, 0x0f, 0x0f, 0x0f, 0x1f, + 0x7f, 0x7f, 0x3e, 0x3e, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xf8, 0xf8, 0xfc, + 0xfc, 0xfe, 0xfe, 0x7e, 0x7c, 0x78, 0xe0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfe, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0x60, 0x60, + 0x60, 0x60, 0x60, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xe0, 0x60, 0x60, 0x60, 0xc0, + 0xc0, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, + 0x0f, 0x3e, 0x7c, 0xfc, 0xf8, 0xf8, 0xf8, 0xf8, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf8, + 0xf8, 0xf8, 0xfc, 0xfc, 0xfc, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xf1, 0x99, 0x18, 0x08, + 0x0c, 0x0c, 0x8c, 0xff, 0xff, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xc1, 0x80, 0x00, 0x00, 0x00, 0x80, + 0xc3, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x07, 0x0f, 0x0f, 0x0f, 0x1f, 0x1f, 0x1f, 0x1f, + 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x0f, 0x0f, 0x07, 0x07, 0x03, 0x03, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x01, 0x01, 0x03, 0x03, 0x03, 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x03, 0x03, 0x01, + 0x01, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + oled_write_raw_P(drac_logo, sizeof(drac_logo)); +} + +static void render_status(void) { + oled_write_P(PSTR("This is\n~~~~~~~~~\nDracu\nLad\n~~~~~~~~~\nv1.0\n~~~~~~~~~\n"), false); + sprintf(wpm_as_str, "WPM %03d", get_current_wpm()); + oled_write(wpm_as_str,false); + led_t led_state = host_keyboard_led_state(); + oled_write_P(PSTR("\nCaps: "), false); + oled_write_P(led_state.caps_lock ? PSTR("on ") : PSTR("off"), false); + oled_write_P(PSTR("\n"),false); + switch (get_highest_layer(layer_state)) { + case _BASE: + oled_write_P(PSTR("Base "), false); + break; + case _NUM: + oled_write_P(PSTR("Numbers"), false); + break; + case _SYMB: + oled_write_P(PSTR("Symbols"), false); + break; + case _ADJ: + oled_write_P(PSTR("Adjust "), false); + break; + case _MUS: + oled_write_P(PSTR("Mouse "), false); + break; + default: + oled_write_P(PSTR("Unkn "), false); + break; + } +} + +void oled_task_user(void) { + if (is_keyboard_master()) { + render_status(); // Renders the current keyboard state (layer, lock, caps, scroll, etc) + } else { + render_logo(); + } +} + +#endif + +#ifdef ENCODER_ENABLE +void encoder_update_user(uint8_t index, bool clockwise) { + if (index == 0) { + // Volume control + if (clockwise) { + tap_code(KC_VOLU); + } else { + tap_code(KC_VOLD); + } + } + else if (index == 2) { + if(clockwise) { + tap_code(KC_PGUP); + } + else{ + tap_code(KC_PGDN); + } + } + else if (index == 3 ) { + // Page up/Page down + if (clockwise) { + tap_code(KC_WH_U); + } else { + tap_code(KC_WH_D); + } + } + +} +#endif diff --git a/keyboards/draculad/keymaps/pimoroni/config.h b/keyboards/draculad/keymaps/pimoroni/config.h new file mode 100644 index 0000000000..c5f9df6f99 --- /dev/null +++ b/keyboards/draculad/keymaps/pimoroni/config.h @@ -0,0 +1,25 @@ +/* +Copyright 2021 @mangoiv + +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 . +*/ + +//comment that out if your trackball is on the left side +#define TRACKBALL_RIGHT + +#ifdef TRACKBALL_RIGHT + #define PIMORONI_TRACKBALL_INVERT_X + #define PIMORONI_TRACKBALL_INVERT_Y +#endif + diff --git a/keyboards/draculad/keymaps/pimoroni/keymap.c b/keyboards/draculad/keymaps/pimoroni/keymap.c new file mode 100644 index 0000000000..d3a8e1f79f --- /dev/null +++ b/keyboards/draculad/keymaps/pimoroni/keymap.c @@ -0,0 +1,318 @@ +/* +Copyright 2021 @mangoiv + +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 . +*/ + +#include QMK_KEYBOARD_H +#include "pimoroni_trackball.h" +#include "pointing_device.h" + + +enum layer_number { + _BASE, + _NUM, + _SYMB, + _MUS, + _ADJ +}; + +enum custom_keycodes { + BALL_HUI,//cycles hue + BALL_WHT,//cycles white + BALL_DEC,//decreased color + BALL_SCR,//scrolls + BALL_NCL,//left click + BALL_RCL,//right click + BALL_MCL,//middle click +}; + + +char wpm_as_str[8]; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_BASE] = LAYOUT( + KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, + KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K , KC_L , KC_SCLN, + LSFT_T(KC_Z), KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, RSFT_T(KC_SLSH), + KC_MUTE, KC_LCTL, LALT_T(KC_BSPC), LT(_MUS, KC_SPC), KC_NO, LT(_NUM,KC_ENT), LT(_SYMB, KC_DEL), TG(_ADJ) + ), + [_NUM] = LAYOUT( + KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, + KC_TAB, KC_MUTE, KC_VOLD, KC_VOLU, XXXXXXX, KC_LEFT, KC_DOWN, KC_UP , KC_RIGHT , KC_QUOT, + KC_LSFT, XXXXXXX, KC_MPRV, KC_MNXT, RESET, KC_HOME, KC_END, KC_PGUP, KC_PGDN, KC_RSFT, + XXXXXXX, KC_LCTL, KC_LALT, XXXXXXX, KC_NO, _______, KC_ENT, KC_NO + ), + [_SYMB] = LAYOUT( + KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, XXXXXXX, XXXXXXX, XXXXXXX, KC_EQL, KC_MINS, + XXXXXXX, KC_F5, KC_F6, KC_F7, KC_F8, KC_LBRC, KC_RBRC, XXXXXXX , KC_GRV , KC_BSLS, + KC_LSFT, KC_F9, KC_F10, KC_F11, KC_F12, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_RSFT, + XXXXXXX, KC_LALT, XXXXXXX, XXXXXXX, XXXXXXX, KC_NO, _______, KC_NO + ), + [_MUS] = LAYOUT( + KC_LCTL, XXXXXXX, XXXXXXX, XXXXXXX,XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + KC_LALT, KC_BTN3, KC_BTN2, KC_BTN1 , BALL_SCR, XXXXXXX, XXXXXXX, XXXXXXX , XXXXXXX , XXXXXXX, + KC_LSFT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX + ), + [_ADJ] = LAYOUT( + RESET, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, BALL_HUI, BALL_WHT, BALL_DEC, XXXXXXX, XXXXXXX, + EEP_RST, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, RGB_MOD, RGB_HUI, RGB_SAI , RGB_VAI , RGB_TOG, + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, RGB_RMOD, RGB_HUD, RGB_SAD, RGB_VAD, _______, + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _______ + ) +}; + + +#ifdef OLED_DRIVER_ENABLE + + +oled_rotation_t oled_init_user(oled_rotation_t rotation) { + + if (is_keyboard_master()) { + if(is_keyboard_left()){ + return OLED_ROTATION_270; + } + else { + return OLED_ROTATION_90; + } + } else { + return OLED_ROTATION_0; + } +} +static void render_logo(void) { + static const char PROGMEM drac_logo[] = { + // drac_logo, 128x64px + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x0c, 0x18, 0x78, 0xf0, 0xf0, 0xe0, 0xe0, 0xc0, + 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x07, 0x3e, 0xfc, 0xf0, 0x00, 0x00, 0x00, + 0xf0, 0xf0, 0x60, 0x30, 0x30, 0x30, 0x00, 0x00, 0xe0, 0xe0, 0x30, 0x30, 0x30, 0x30, 0x30, 0xe0, + 0xe0, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0x70, 0x30, 0x30, 0x30, 0x70, 0xe0, 0xc0, 0x00, 0x00, + 0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xe0, 0xe0, 0xe0, 0xc0, + 0x80, 0x00, 0x00, 0x00, 0x80, 0xe0, 0xf8, 0xf0, 0x80, 0xc0, 0xe0, 0xf0, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x3f, 0xff, 0xff, + 0xff, 0xff, 0xfe, 0xfc, 0xf8, 0xe0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xc0, 0xe0, 0x7c, 0x3f, 0x0f, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0xf8, 0xcc, 0x8c, 0x84, 0x86, 0x86, 0xc6, 0xff, + 0xff, 0x80, 0x80, 0x00, 0x3f, 0x7f, 0xe0, 0xc0, 0x80, 0x80, 0x80, 0xc0, 0xf0, 0x71, 0x00, 0x00, + 0x1f, 0xff, 0xff, 0x80, 0x80, 0x80, 0x80, 0xc0, 0xf8, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x03, 0x03, 0x07, 0x0f, 0x0f, 0x0f, 0x1f, + 0x7f, 0x7f, 0x3e, 0x3e, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xf8, 0xf8, 0xfc, + 0xfc, 0xfe, 0xfe, 0x7e, 0x7c, 0x78, 0xe0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfe, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0x60, 0x60, + 0x60, 0x60, 0x60, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xe0, 0x60, 0x60, 0x60, 0xc0, + 0xc0, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, + 0x0f, 0x3e, 0x7c, 0xfc, 0xf8, 0xf8, 0xf8, 0xf8, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf8, + 0xf8, 0xf8, 0xfc, 0xfc, 0xfc, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xf1, 0x99, 0x18, 0x08, + 0x0c, 0x0c, 0x8c, 0xff, 0xff, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xc1, 0x80, 0x00, 0x00, 0x00, 0x80, + 0xc3, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x07, 0x0f, 0x0f, 0x0f, 0x1f, 0x1f, 0x1f, 0x1f, + 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x0f, 0x0f, 0x07, 0x07, 0x03, 0x03, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x01, 0x01, 0x03, 0x03, 0x03, 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x03, 0x03, 0x01, + 0x01, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + oled_write_raw_P(drac_logo, sizeof(drac_logo)); +} + +static void render_status(void) { + oled_write_P(PSTR("This is\n~~~~~~~~~\nDracu\nLad\n~~~~~~~~~\nv1.0\n~~~~~~~~~\n"), false); + sprintf(wpm_as_str, "WPM %03d", get_current_wpm()); + oled_write(wpm_as_str,false); + led_t led_state = host_keyboard_led_state(); + oled_write_P(PSTR("\nCaps: "), false); + oled_write_P(led_state.caps_lock ? PSTR("on ") : PSTR("off"), false); + oled_write_P(PSTR("\n"),false); + switch (get_highest_layer(layer_state)) { + case _BASE: + oled_write_P(PSTR("Base "), false); + break; + case _NUM: + oled_write_P(PSTR("Numbers"), false); + break; + case _SYMB: + oled_write_P(PSTR("Symbols"), false); + break; + case _ADJ: + oled_write_P(PSTR("Adjust "), false); + break; + case _MUS: + oled_write_P(PSTR("Mouse "), false); + break; + default: + oled_write_P(PSTR("Unkn "), false); + break; + } +} + +void oled_task_user(void) { + if (is_keyboard_master()) { + render_status(); // Renders the current keyboard state (layer, lock, caps, scroll, etc) + } else { + render_logo(); + } +} + +#endif + +uint8_t white = 0; +uint8_t red = 255; +uint8_t green = 0; +uint8_t blue = 0; + +void ball_increase_hue(void){ + if(red!=255&&green!=255&&blue!=255){ + red =255; + } + if (red==255&&green<255&&blue==0){ + green += 15; + } else if(green==255&&blue==0&&red>0){ + red-=15; + } else if(red==0&&blue<255&&green==255){ + blue+=15; + } else if(blue==255&&green>0&&red==0){ + green -= 15; + } else if(green == 0&&blue==255&&red<255){ + red +=15; + } else if(green ==0&&blue>0&&red==255){ + blue -=15; + } + trackball_set_rgbw(red,green,blue,white); +} + +void decrease_color(void){ + if (green>0){ + green-=15; + } + if (red>0){ + red-=15; + } + if (blue>0){ + blue-=15; + } + trackball_set_rgbw(red,green,blue,white); +} + +void cycle_white(void){ + if (white<255){ + white +=15; + } else{ + white=0; + } + trackball_set_rgbw(red,green,blue,white); +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record){ + switch (keycode){ + case BALL_HUI: + if(record->event.pressed){ + ball_increase_hue(); + } + break; + + case BALL_WHT: + if(record-> event.pressed){ + cycle_white(); + } + break; + + case BALL_DEC: + if(record-> event.pressed){ + decrease_color(); + } + break; + + case BALL_SCR: + if(record->event.pressed){ + trackball_set_scrolling(true); + } else{ + trackball_set_scrolling(false); + } + break; + + case BALL_NCL: + record->event.pressed?register_code(KC_BTN1):unregister_code(KC_BTN1); + break; + case BALL_RCL: + record->event.pressed?register_code(KC_BTN2):unregister_code(KC_BTN2); + break; + case BALL_MCL: + record->event.pressed?register_code(KC_BTN3):unregister_code(KC_BTN3); + break; + } + return true; +} +#ifdef ENCODER_ENABLE +void encoder_update_user(uint8_t index, bool clockwise) { + if (index == 0) { + // Volume control + if (clockwise) { + tap_code(KC_VOLU); + } else { + tap_code(KC_VOLD); + } + } + else if (index == 2) { + switch (get_highest_layer(layer_state)) { + case _ADJ: + clockwise?ball_increase_hue():cycle_white(); + break; + case _MUS: + clockwise?tap_code(KC_WH_U):tap_code(KC_WH_D); + break; + default: + clockwise?tap_code(KC_PGUP):tap_code(KC_PGDN); + break; + } + } + // I only have 2 encoders on the the pimoroni example board, just add else ifs for your other encoders... + // the missing ones are encoder 1 on the right side and encoder 3 on the left side +} +#endif diff --git a/keyboards/draculad/keymaps/pimoroni/pimoroni_trackball.c b/keyboards/draculad/keymaps/pimoroni/pimoroni_trackball.c new file mode 100644 index 0000000000..c4f4a0441a --- /dev/null +++ b/keyboards/draculad/keymaps/pimoroni/pimoroni_trackball.c @@ -0,0 +1,177 @@ +/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) + * + * 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 . + */ + +#include "pimoroni_trackball.h" +#include "i2c_master.h" + +static uint8_t scrolling = 0; +static int16_t x_offset = 0; +static int16_t y_offset = 0; +static int16_t h_offset = 0; +static int16_t v_offset = 0; +static float precisionSpeed = 1; + +static uint16_t i2c_timeout_timer; + +#ifndef I2C_TIMEOUT +# define I2C_TIMEOUT 100 +#endif +#ifndef I2C_WAITCHECK +# define I2C_WAITCHECK 1000 +#endif +#ifndef MOUSE_DEBOUNCE +# define MOUSE_DEBOUNCE 5 +#endif + +void trackball_set_rgbw(uint8_t red, uint8_t green, uint8_t blue, uint8_t white) { + uint8_t data[] = {0x00, red, green, blue, white}; + i2c_transmit(TRACKBALL_WRITE, data, sizeof(data), I2C_TIMEOUT); +} + +int16_t mouse_offset(uint8_t positive, uint8_t negative, int16_t scale) { + int16_t offset = (int16_t)positive - (int16_t)negative; + int16_t magnitude = (int16_t)(scale * offset * offset * precisionSpeed); + return offset < 0 ? -magnitude : magnitude; +} + +void update_member(int8_t* member, int16_t* offset) { + if (*offset > 127) { + *member = 127; + *offset -= 127; + } else if (*offset < -127) { + *member = -127; + *offset += 127; + } else { + *member = *offset; + *offset = 0; + } +} + +__attribute__((weak)) void trackball_check_click(bool pressed, report_mouse_t* mouse) { + if (pressed) { + mouse->buttons |= MOUSE_BTN1; + } else { + mouse->buttons &= ~MOUSE_BTN1; + } +} + +bool process_record_kb(uint16_t keycode, keyrecord_t* record) { + if (true) { + xprintf("KL: kc: %u, col: %u, row: %u, pressed: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed); + } + + + if (!process_record_user(keycode, record)) { return false; } + +/* If Mousekeys is disabled, then use handle the mouse button + * keycodes. This makes things simpler, and allows usage of + * the keycodes in a consistent manner. But only do this if + * Mousekeys is not enable, so it's not handled twice. + */ +#ifndef MOUSEKEY_ENABLE + if (IS_MOUSEKEY_BUTTON(keycode)) { + report_mouse_t currentReport = pointing_device_get_report(); + if (record->event.pressed) { + currentReport.buttons |= 1 << (keycode - KC_MS_BTN1); + } else { + currentReport.buttons &= ~(1 << (keycode - KC_MS_BTN1)); + } + pointing_device_set_report(currentReport); + pointing_device_send(); + } +#endif + + return true; +} + +void trackball_register_button(bool pressed, enum mouse_buttons button) { + report_mouse_t currentReport = pointing_device_get_report(); + if (pressed) { + currentReport.buttons |= button; + } else { + currentReport.buttons &= ~button; + } + pointing_device_set_report(currentReport); +} + +float trackball_get_precision(void) { return precisionSpeed; } +void trackball_set_precision(float precision) { precisionSpeed = precision; } +bool trackball_is_scrolling(void) { return scrolling; } +void trackball_set_scrolling(bool scroll) { scrolling = scroll; } + + +__attribute__((weak)) void pointing_device_init(void) { trackball_set_rgbw(0x80, 0x00, 0x00, 0x00); } + +void pointing_device_task(void) { + static bool debounce; + static uint16_t debounce_timer; + uint8_t state[5] = {}; + if (timer_elapsed(i2c_timeout_timer) > I2C_WAITCHECK) { + if (i2c_readReg(TRACKBALL_WRITE, 0x04, state, 5, I2C_TIMEOUT) == I2C_STATUS_SUCCESS) { + if (!state[4] && !debounce) { + if (scrolling) { +#ifdef PIMORONI_TRACKBALL_INVERT_X + h_offset += mouse_offset(state[2], state[3], 1); +#else + h_offset -= mouse_offset(state[2], state[3], 1); +#endif +#ifdef PIMORONI_TRACKBALL_INVERT_Y + v_offset += mouse_offset(state[1], state[0], 1); +#else + v_offset -= mouse_offset(state[1], state[0], 1); +#endif + } else { +#ifdef PIMORONI_TRACKBALL_INVERT_X + x_offset -= mouse_offset(state[2], state[3], 5); +#else + x_offset += mouse_offset(state[2], state[3], 5); +#endif +#ifdef PIMORONI_TRACKBALL_INVERT_Y + y_offset -= mouse_offset(state[1], state[0], 5); +#else + y_offset += mouse_offset(state[1], state[0], 5); +#endif + } + } else { + if (state[4]) { + debounce = true; + debounce_timer = timer_read(); + } + } + } else { + i2c_timeout_timer = timer_read(); + } + } + + if (timer_elapsed(debounce_timer) > MOUSE_DEBOUNCE) debounce = false; + + report_mouse_t mouse = pointing_device_get_report(); + // trackball_check_click(state[4] & (1 << 7), &mouse); + +#ifndef PIMORONI_TRACKBALL_ROTATE + update_member(&mouse.x, &x_offset); + update_member(&mouse.y, &y_offset); + update_member(&mouse.h, &h_offset); + update_member(&mouse.v, &v_offset); +#else + update_member(&mouse.x, &y_offset); + update_member(&mouse.y, &x_offset); + update_member(&mouse.h, &v_offset); + update_member(&mouse.v, &h_offset); +#endif + pointing_device_set_report(mouse); + pointing_device_send(); +} diff --git a/keyboards/draculad/keymaps/pimoroni/pimoroni_trackball.h b/keyboards/draculad/keymaps/pimoroni/pimoroni_trackball.h new file mode 100644 index 0000000000..cfcd5a47a1 --- /dev/null +++ b/keyboards/draculad/keymaps/pimoroni/pimoroni_trackball.h @@ -0,0 +1,35 @@ +/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) + * + * 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 . + */ + +#pragma once + +#include "quantum.h" +#include "pointing_device.h" + +#ifndef TRACKBALL_ADDRESS +# define TRACKBALL_ADDRESS 0x0A +#endif +#define TRACKBALL_WRITE ((TRACKBALL_ADDRESS << 1) | I2C_WRITE) +#define TRACKBALL_READ ((TRACKBALL_ADDRESS << 1) | I2C_READ) + +void trackball_set_rgbw(uint8_t red, uint8_t green, uint8_t blue, uint8_t white); +void trackball_check_click(bool pressed, report_mouse_t *mouse); +void trackball_register_button(bool pressed, enum mouse_buttons button); + +float trackball_get_precision(void); +void trackball_set_precision(float precision); +bool trackball_is_scrolling(void); +void trackball_set_scrolling(bool scroll); \ No newline at end of file diff --git a/keyboards/draculad/keymaps/pimoroni/rules.mk b/keyboards/draculad/keymaps/pimoroni/rules.mk new file mode 100644 index 0000000000..547a02f26f --- /dev/null +++ b/keyboards/draculad/keymaps/pimoroni/rules.mk @@ -0,0 +1,6 @@ +# only uncomment on the side you have your trackball on +POINTING_DEVICE_ENABLE = yes +SRC += pimoroni_trackball.c +QUANTUM_LIB_SRC += i2c_master.c +OLED_DRIVER_ENABLE = yes +MOUSEKEY_ENABLE = no diff --git a/keyboards/draculad/readme.md b/keyboards/draculad/readme.md new file mode 100644 index 0000000000..f1fd546cd2 --- /dev/null +++ b/keyboards/draculad/readme.md @@ -0,0 +1,33 @@ +# DracuLad + +![DracuLad](https://github.com/mangoiv/draculad/blob/master/pictures/rev1/both_sides_showcase.jpg?raw=true) + +*A 34-36 key split keyboard* +- 36 keys, two of them can be replaced by rotary encoders making it support 34-36 keys and 2-4 encoders. +- bright RGB Underglow with ws2812b LEDs +- one ssd1306 OLED per side +- aggressive pinky stagger similar to the kyria but with an alternative thumb cluster to raise comfort for large hands +- support for mx and choc switches + +* keyboard Maintainer: [MangoIV](https://github.com/MangoIV) +* Hardware Supported: [DracuLad PCBs and cases](https://github.com/MangoIV/dracuLad), [the pimoroni trackball](https://shop.pimoroni.com/products/trackball-breakout) +* Hardware availability: [check my github](https://github.com/MangoIV) + +Make example for this keyboard (after setting up your build env): + + make draculad:default + +or for the version using the pimoroni trackball + + make draculad:pimoroni + +Flashing example for dfu and catarina respectively (replace default with the name of your keymap) + + make draculad:default:dfu + + make draculad:default:flash + + +When flashing the first time using handedness by eeprom, use the [qmk guide for that topic](https://docs.qmk.fm/#/feature_split_keyboard?id=handedness-by-eeprom) + +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). diff --git a/keyboards/draculad/rules.mk b/keyboards/draculad/rules.mk new file mode 100644 index 0000000000..d8596006c3 --- /dev/null +++ b/keyboards/draculad/rules.mk @@ -0,0 +1,27 @@ +# MCU name +MCU = atmega32u4 + +# Bootloader selection +BOOTLOADER = caterina + +# Build Options +# change yes to no to disable +# +BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration +MOUSEKEY_ENABLE = yes # Mouse keys +EXTRAKEY_ENABLE = yes # 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 = yes # USB Nkey Rollover +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow +BLUETOOTH_ENABLE = no # Enable Bluetooth +AUDIO_ENABLE = no # Audio output +SPLIT_KEYBOARD = yes +OLED_DRIVER_ENABLE = yes +WPM_ENABLE = yes +ENCODER_ENABLE = yes +LTO_ENABLE = yes