diff --git a/keyboards/acheron/shark/alpha/alpha.c b/keyboards/acheron/shark/alpha/alpha.c new file mode 100644 index 0000000000..e841f3fbd5 --- /dev/null +++ b/keyboards/acheron/shark/alpha/alpha.c @@ -0,0 +1,16 @@ +/* Copyright 2019 Álvaro "Gondolindrim" Volpato + * + * 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 "alpha.h" diff --git a/keyboards/acheron/shark/alpha/alpha.h b/keyboards/acheron/shark/alpha/alpha.h new file mode 100644 index 0000000000..d58b72548a --- /dev/null +++ b/keyboards/acheron/shark/alpha/alpha.h @@ -0,0 +1,39 @@ +/* Copyright 2019 Álvaro "Gondolindrim" Volpato + * + * 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" + +/* 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_ortho_4x12( \ + K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, \ + K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, \ + K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, \ + K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B \ +) \ +{ \ + { K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B }, \ + { K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B }, \ + { K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B }, \ + { K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B } \ +} diff --git a/keyboards/acheron/shark/config.h b/keyboards/acheron/shark/alpha/config.h similarity index 100% rename from keyboards/acheron/shark/config.h rename to keyboards/acheron/shark/alpha/config.h diff --git a/keyboards/acheron/shark/info.json b/keyboards/acheron/shark/alpha/info.json similarity index 100% rename from keyboards/acheron/shark/info.json rename to keyboards/acheron/shark/alpha/info.json diff --git a/keyboards/acheron/shark/keymaps/ajp10304/readme.md b/keyboards/acheron/shark/alpha/keymaps/ajp10304/readme.md similarity index 100% rename from keyboards/acheron/shark/keymaps/ajp10304/readme.md rename to keyboards/acheron/shark/alpha/keymaps/ajp10304/readme.md diff --git a/keyboards/acheron/shark/keymaps/default/keymap.c b/keyboards/acheron/shark/alpha/keymaps/default/keymap.c similarity index 100% rename from keyboards/acheron/shark/keymaps/default/keymap.c rename to keyboards/acheron/shark/alpha/keymaps/default/keymap.c diff --git a/keyboards/acheron/shark/keymaps/via/keymap.c b/keyboards/acheron/shark/alpha/keymaps/via/keymap.c similarity index 100% rename from keyboards/acheron/shark/keymaps/via/keymap.c rename to keyboards/acheron/shark/alpha/keymaps/via/keymap.c diff --git a/keyboards/acheron/shark/keymaps/via/rules.mk b/keyboards/acheron/shark/alpha/keymaps/via/rules.mk similarity index 100% rename from keyboards/acheron/shark/keymaps/via/rules.mk rename to keyboards/acheron/shark/alpha/keymaps/via/rules.mk diff --git a/keyboards/acheron/shark/rules.mk b/keyboards/acheron/shark/alpha/rules.mk similarity index 100% rename from keyboards/acheron/shark/rules.mk rename to keyboards/acheron/shark/alpha/rules.mk diff --git a/keyboards/acheron/shark/beta/beta.c b/keyboards/acheron/shark/beta/beta.c new file mode 100644 index 0000000000..597dc78548 --- /dev/null +++ b/keyboards/acheron/shark/beta/beta.c @@ -0,0 +1,32 @@ +/* Copyright 2020 Gondolindrim + * + * 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 "beta.h" +void board_init(void) { + setPinInput(B6); + setPinInput(B7); +} + +#ifdef ENCODER_ENABLE +bool encoder_update_kb(uint8_t index, bool clockwise) { + if(!encoder_update_user(index, clockwise)) return false; + if (index == 0) { + if (clockwise) tap_code_delay(KC_VOLU, 10); + else tap_code_delay(KC_VOLD, 10); + } + return true; +} +#endif diff --git a/keyboards/acheron/shark/beta/beta.h b/keyboards/acheron/shark/beta/beta.h new file mode 100644 index 0000000000..1002659d3d --- /dev/null +++ b/keyboards/acheron/shark/beta/beta.h @@ -0,0 +1,31 @@ +/* Copyright 2020 Gondolindrim + * + * 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 LAYOUT_ortho_4x12( \ + K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, \ + K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, \ + K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, \ + K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B \ +)\ +{\ + { K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B }, \ + { K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B }, \ + { K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B }, \ + { K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B } \ +} diff --git a/keyboards/acheron/shark/beta/chconf.h b/keyboards/acheron/shark/beta/chconf.h new file mode 100644 index 0000000000..cbbae31079 --- /dev/null +++ b/keyboards/acheron/shark/beta/chconf.h @@ -0,0 +1,25 @@ +/* Copyright 2020 QMK + * + * 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 + +#define CH_CFG_ST_FREQUENCY 10000 + +#define CH_CFG_OPTIMIZE_SPEED FALSE + +#define CH_CFG_USE_CONDVARS_TIMEOUT FALSE + +#include_next diff --git a/keyboards/acheron/shark/beta/config.h b/keyboards/acheron/shark/beta/config.h new file mode 100644 index 0000000000..54fa270336 --- /dev/null +++ b/keyboards/acheron/shark/beta/config.h @@ -0,0 +1,66 @@ +/* +Copyright 2020 Gondolindrim + +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" + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xAC11 +#define PRODUCT_ID 0x5369 // For Shark+1 +#define DEVICE_VER 0x0002 +#define MANUFACTURER AcheronProject +#define PRODUCT SharkPCB rev. Beta + +#define MATRIX_ROWS 4 +#define MATRIX_COLS 12 + +#define MATRIX_COL_PINS { A5 , A10, C13, B9 , B8 , B5 , B4 , B3 , A15, A0 , A1 , A2 } +#define MATRIX_ROW_PINS { A8 , B14, A4 , A3 } +#define DIODE_DIRECTION COL2ROW + +#define DEBOUNCE 5 + +#define LOCKING_SUPPORT_ENABLE +#define LOCKING_RESYNC_ENABLE + +#define BACKLIGHT_PIN A6 +#define BACKLIGHT_PWM_DRIVER PWMD3 +#define BACKLIGHT_PWM_CHANNEL 1 +#define BACKLIGHT_PAL_MODE 2 +#define BACKLIGHT_LEVELS 20 +#define BACKLIGHT_BREATHING +#define BREATHING_PERIOD 5 +#define BACKLIGHT_ON_STATE 1 + +#define STM32_HSECLK 8000000 + +#define RGB_DI_PIN B15 +#define RGBLED_NUM 24 +#define RGBLIGHT_ANIMATIONS + +#define WS2812_PWM_COMPLEMENTARY_OUTPUT +#define WS2812_PWM_DRIVER PWMD1 +#define WS2812_PWM_CHANNEL 3 +#define WS2812_PWM_PAL_MODE 1 +#define WS2812_DMA_STREAM STM32_DMA2_STREAM5 +#define WS2812_DMA_CHANNEL 6 + +#define ENCODERS_PAD_A { C15 } +#define ENCODERS_PAD_B { C14 } + +#define EEPROM_I2C_24LC256 diff --git a/keyboards/acheron/shark/beta/halconf.h b/keyboards/acheron/shark/beta/halconf.h new file mode 100644 index 0000000000..ebdb4954a1 --- /dev/null +++ b/keyboards/acheron/shark/beta/halconf.h @@ -0,0 +1,24 @@ +/* Copyright 2020 QMK + * + * 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 + +#define HAL_USE_PWM TRUE +#define HAL_USE_PAL TRUE + +#define HAL_USE_I2C TRUE + +#include_next diff --git a/keyboards/acheron/shark/beta/keymaps/default/keymap.c b/keyboards/acheron/shark/beta/keymaps/default/keymap.c new file mode 100644 index 0000000000..5cf5ac40da --- /dev/null +++ b/keyboards/acheron/shark/beta/keymaps/default/keymap.c @@ -0,0 +1,43 @@ +/* Copyright 2019 + * + * 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 + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [0] = LAYOUT_ortho_4x12( + KC_TAB , KC_Q , KC_W , KC_E , KC_R , KC_T , KC_Y , KC_U , KC_I , KC_O , KC_P , KC_BSPC, + KC_ESC , KC_A , KC_S , KC_D , KC_F , KC_G , KC_H , KC_J , KC_K , KC_L , KC_SCLN , KC_QUOT, + KC_LSFT , KC_Z , KC_X , KC_C , KC_V , KC_B , KC_N , KC_M , KC_COMM , KC_DOT , KC_SLSH , KC_ENT , + KC_LCTL , KC_LALT , KC_LGUI , KC_NO , MO(1) , KC_SPC , KC_SPC , MO(2) , KC_LEFT , KC_DOWN , KC_UP , KC_RGHT + ), + [1] = LAYOUT_ortho_4x12( + 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_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_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS + ), + [2] = LAYOUT_ortho_4x12( + 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_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_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS + ), + [3] = LAYOUT_ortho_4x12( + 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_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_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS + ) +}; diff --git a/keyboards/acheron/shark/beta/keymaps/gondolindrim/keymap.c b/keyboards/acheron/shark/beta/keymaps/gondolindrim/keymap.c new file mode 100755 index 0000000000..cae98411d6 --- /dev/null +++ b/keyboards/acheron/shark/beta/keymaps/gondolindrim/keymap.c @@ -0,0 +1,265 @@ +/* +Copyright 2020 Álvaro "Gondolindrim" Volpato + +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 "config_common.h" + +#define MEDIA_KEY_DELAY 10 +#define ALT_TAB_DELAY 1000 + +// Persistent encoder modes: the current encoder mode is written into EEPROM memory, and retrieved at the keyboard initialization. This means the current encoder mode is persistent even if the keyboard is reset or turned off +#define PERSISTENT_ENCODER_MODES + +#define ENCODER_MODE_CHANGE_DELAY 500 + +// Defining special keycodes +enum keyboard_keycodes { + ECLICK = SAFE_RANGE, // Encoder click + ALTTABF , // ALT-TAB forward + ALTTABB , // ALT-TAB backwards + ALTTABC , // For alt-tab-click + ENCMUP , // Encoder mode up + ENCMDN , // Encoder mode down + NEW_SAFE_RANGE +}; + +// Creates sample keyevents and keyrecords to be used in the processing of the custom keycodes. Their time should be resampled everytime they are used; their cols and rows are set to be "impossible", that is, outside the normal key matrix bounds. +const keyevent_t sample_pressed_keyevent = { + .key = (keypos_t){.row = 5, .col = 13}, + .pressed = true, + .time = 0 +}; + +keyrecord_t sample_pressed_keyrecord = { + .event = sample_pressed_keyevent +}; + +const keyevent_t sample_released_keyevent = { + .key = (keypos_t){.row = 5, .col = 13}, + .pressed = false, + .time = 0 +}; + +keyrecord_t sample_released_keyrecord = { + .event = sample_released_keyevent +}; + +// tap_process_record_user calls process_record_user with the pressed and released sample keyrecords with a delay of MEDIA_KEY_DELAY. The idea is to allow custom keycodes a simulation of a key press and release, allowing them to be treated in process_record_user. This, in turn, allows the custom keycodes to be used both in the encoder callback and the keyboard keymap. +uint16_t temp_timer = 0; +void tap_process_record_user(uint16_t keycode) +{ + temp_timer = timer_read(); + sample_pressed_keyrecord.event.time = timer_read(); + process_record_user( keycode, &sample_pressed_keyrecord ); + while (timer_elapsed(temp_timer) < MEDIA_KEY_DELAY); + sample_released_keyrecord.event.time = timer_read(); + process_record_user( keycode, &sample_released_keyrecord ); +} + +// process_special_keycode is a function that distinguishes between the native keycodes and the ones custom-defined here. Normal keycodes are tapped, while keycodes in the SAFE_RANGE - NEW_SAFE_RANGE interval are treated with tap_process_record_user. +void process_special_keycode(uint16_t keycode) { + if (SAFE_RANGE <= keycode && keycode < NEW_SAFE_RANGE) tap_process_record_user(keycode); + else tap_code(keycode); +} + +uint16_t encoder_click_delay = ENCODER_MODE_CHANGE_DELAY; + +uint8_t startup_color[3] = {0xFF,0xFF,0xFF}; + +typedef struct _encoder_mode_t { + uint8_t indicator_color[3]; + uint16_t clockwise_key[4]; + uint16_t counterclockwise_key[4]; + uint16_t clicked_key[4] ; + uint16_t hold_key; +} encoder_mode_t; + +encoder_mode_t encoder_modes[] = { + { .indicator_color = {0x22,0x00,0xFF} , .clockwise_key = {KC_VOLU, KC_VOLU, ENCMUP, KC_VOLU}, .counterclockwise_key = {KC_VOLD, KC_VOLD, ENCMDN, KC_VOLD}, .clicked_key = {KC_MUTE, KC_MPLY, KC_MUTE, KC_MUTE}, .hold_key = ENCMUP }, + { .indicator_color = {0x00,0x33,0xFF} , .clockwise_key = {KC_WH_D, KC_WH_D, ENCMUP, KC_WH_D}, .counterclockwise_key = {KC_WH_U, KC_WH_U, ENCMDN, KC_WH_U}, .clicked_key = {KC_BTN1, KC_BTN1, KC_BTN1, KC_BTN1}, .hold_key = ENCMUP }, + { .indicator_color = {0xFF,0x88,0x00} , .clockwise_key = {ALTTABF, ALTTABF, ENCMUP, ALTTABF}, .counterclockwise_key = {ALTTABB, ALTTABB, ENCMDN, ALTTABB}, .clicked_key = {ALTTABC, ALTTABC, ALTTABC, ALTTABC}, .hold_key = ENCMUP } + // Insert your custom encoder mode here +}; + +#define NUM_ENCODER_MODES (sizeof(encoder_modes)/sizeof(encoder_modes[0])) + +// This counter is used to track what encoder mode is being used at a certain time +int encoder_mode_count = 0; + + +#ifdef PERSISTENT_ENCODER_MODES +typedef union { + uint32_t raw; + struct { + int user_encoder_mode_count; +}; +} user_config_t; + +user_config_t user_config; +#endif + +void set_indicator_colors(uint8_t color[3]){ + rgblight_setrgb(color[0], color[1], color[2]); +} + +// Board init: RGB indicator is set to startup_color +void keyboard_pre_init_user(void){ + set_indicator_colors(startup_color); +}; + +void keyboard_post_init_user(void){ +#ifdef PERSISTENT_ENCODER_MODES + user_config.raw = eeconfig_read_user(); + encoder_mode_count = user_config.user_encoder_mode_count ; +#else + encoder_mode_count = 0; +#endif + set_indicator_colors(encoder_modes[ encoder_mode_count ].indicator_color); +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [0] = LAYOUT_ortho_4x12( + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, ECLICK , + KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , + KC_LCTL, KC_LALT, KC_LGUI, _______, MO(1), KC_SPC, KC_SPC, MO(2), KC_LEFT, KC_DOWN, KC_UP, KC_RGHT + ), + [1] = LAYOUT_ortho_4x12( + 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_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_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS + ), + [2] = LAYOUT_ortho_4x12( + 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_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_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS + ), + [3] = LAYOUT_ortho_4x12( + 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_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_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS + ) +}; + +// ------------------------------------------------------------------------------------------------ + +bool is_alt_tab_active = false; // Flag to check if alt tab is active +uint32_t alt_tab_timer = 0; // Time trigger for alt tab +uint16_t mapped_code = 0; +uint32_t held_keycode_timer = 0; + +int current_layer = 0 ; // Updated in layer_state_set_user each time a layer change is made + +void cycle_encoder_mode(bool forward){ + if (forward) encoder_mode_count++ ; // Shifts encoder mode forward + else encoder_mode_count-- ; + if (encoder_mode_count == -1) encoder_mode_count = NUM_ENCODER_MODES - 1; + // Shifts encoder mode backward + encoder_mode_count = encoder_mode_count % NUM_ENCODER_MODES ; // This makes sure encoder_mode_count keeps cycling between 0,1,...,NUM_ENCODER_MODES and doesnt eventually overflow +#ifdef PERSISTENT_ENCODER_MODES + user_config.user_encoder_mode_count = encoder_mode_count ; + eeconfig_update_user(user_config.raw); +#endif + set_indicator_colors( encoder_modes[ encoder_mode_count ].indicator_color ); // Set indicator color to the corresponding defined color +} + +bool encoder_update_user(uint8_t index, bool clockwise) { + process_special_keycode(clockwise ? encoder_modes[ encoder_mode_count ].clockwise_key[ current_layer ] : encoder_modes[ encoder_mode_count ].counterclockwise_key[ current_layer ]); + return false; +} + +uint32_t held_click_timer = 0; +bool is_click_held = false; +bool is_shift_held = false; +bool automatic_hold_cycle = false; // This flag registers if the encoder hold was automatically cycled + +// This bool records if LALT is pressed or not. Due to the automatic disabling of the ALT-TAB of the ALTTABS custom keystroke, the automatic disabling can un-register KC_LALT even when the LALT key is phisically pressed. Hence there needs to be two bools: one that keebs track of the ALT-TAB activity and one that keeps track of LALT so that the automatic disabling will not disable LALT if it is phisically pressed. +bool is_lalt_pressed = false; + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case KC_LSFT: + case KC_RSFT: + if (record->event.pressed) is_shift_held = true; + else is_shift_held = false; + return true; + case ECLICK: + // Checks if the encoder has been pressed; if so, sets the corresponding flag and starts the corresponding timer + if (record->event.pressed) { + is_click_held = true; + held_click_timer = timer_read32(); + // Checks if the encoder has been released: samples the duration of the encoder push; if this time was less than the encoder_click_delay, processes the clicked key. If it was bigger, processes the hold key. This behavior is adjusted using the ENCODER_MODE_CHANGE_DELAY macro. There is an exception made when automatic_hold_cycle is true; this means that the encoder push has been pressed enough to trigger a hold cycle. This case is taken care of in the housekeeping routine, where the held key is triggered and the timer reset. Hence the automatic_hold_cycle needs to be checked because without this check the function will trigger the clicked key after the hold cycle has been cycled more than once. + } else { + is_click_held = false; + if (timer_elapsed32(held_click_timer) < encoder_click_delay && !automatic_hold_cycle ) process_special_keycode( encoder_modes[ encoder_mode_count ].clicked_key[ current_layer ] ) ; + automatic_hold_cycle = false; + } + return true; // Skip all further processing of this key + case KC_LALT: // If this is not defined, if the encoder is activated in the alt-tab mode while the LALT key is pressed, the menu goes away. + if (record->event.pressed) is_lalt_pressed = true; + else is_lalt_pressed = false; + return true; + case ENCMUP: + case ENCMDN: + if (record->event.pressed) cycle_encoder_mode(keycode == ENCMUP); // If keycode == ENCMUP the expression returns true and the cycle function cycles the modes forward. If not, then cycles backwards. + return false; + case ALTTABF: + case ALTTABB: + if (record->event.pressed) { + if (!is_alt_tab_active) { + is_alt_tab_active = true; + register_code(KC_LALT); + + } + tap_code16(keycode == ALTTABF ? KC_TAB : S(KC_TAB)); // Due to S(KC_TAB), the 16-bit tap_code16 is needed. + alt_tab_timer = timer_read32(); + } + return true; + case ALTTABC: + if (record->event.pressed) { + if (is_alt_tab_active) { + if (!is_lalt_pressed) unregister_code(KC_LALT); + is_alt_tab_active = false; + } + } + return false; + default: + return true; // Process all other keycodes normally + } +} + +void housekeeping_task_user(void) { + if (is_alt_tab_active) { + if (is_lalt_pressed) alt_tab_timer = timer_read32(); + else if (timer_elapsed32(alt_tab_timer) > ALT_TAB_DELAY) { + unregister_code(KC_LALT); + is_alt_tab_active = false; + } + } +/* This piece of the code checks for the encoder push timer. If the encoder push interval was less than encoder_click_delay then it is automatically processed by process_record_user by triggering the current mode's click key. However, if the encoder push is held for more time than the defined delay, then the encoder hold "cycles", that is, gets activated and the timer needs to be reset. This does three things: +- (1) Sets the automatic_hold_cycle flag which prevents process_record_user from triggering the click key when the push is released +- (2) Processes the current mode's hold key in process_record_user +- (3) Resets the click timer +*/ + if (is_click_held && timer_elapsed32(held_click_timer) > encoder_click_delay ){ + automatic_hold_cycle = true; + process_special_keycode( encoder_modes[ encoder_mode_count ].hold_key ); + held_click_timer = timer_read32(); + } +} diff --git a/keyboards/acheron/shark/beta/keymaps/gondolindrim/rules.mk b/keyboards/acheron/shark/beta/keymaps/gondolindrim/rules.mk new file mode 100644 index 0000000000..1e5b99807c --- /dev/null +++ b/keyboards/acheron/shark/beta/keymaps/gondolindrim/rules.mk @@ -0,0 +1 @@ +VIA_ENABLE = yes diff --git a/keyboards/acheron/shark/beta/keymaps/via/keymap.c b/keyboards/acheron/shark/beta/keymaps/via/keymap.c new file mode 100644 index 0000000000..5cf5ac40da --- /dev/null +++ b/keyboards/acheron/shark/beta/keymaps/via/keymap.c @@ -0,0 +1,43 @@ +/* Copyright 2019 + * + * 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 + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [0] = LAYOUT_ortho_4x12( + KC_TAB , KC_Q , KC_W , KC_E , KC_R , KC_T , KC_Y , KC_U , KC_I , KC_O , KC_P , KC_BSPC, + KC_ESC , KC_A , KC_S , KC_D , KC_F , KC_G , KC_H , KC_J , KC_K , KC_L , KC_SCLN , KC_QUOT, + KC_LSFT , KC_Z , KC_X , KC_C , KC_V , KC_B , KC_N , KC_M , KC_COMM , KC_DOT , KC_SLSH , KC_ENT , + KC_LCTL , KC_LALT , KC_LGUI , KC_NO , MO(1) , KC_SPC , KC_SPC , MO(2) , KC_LEFT , KC_DOWN , KC_UP , KC_RGHT + ), + [1] = LAYOUT_ortho_4x12( + 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_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_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS + ), + [2] = LAYOUT_ortho_4x12( + 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_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_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS + ), + [3] = LAYOUT_ortho_4x12( + 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_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_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS , KC_TRNS + ) +}; diff --git a/keyboards/acheron/shark/beta/keymaps/via/rules.mk b/keyboards/acheron/shark/beta/keymaps/via/rules.mk new file mode 100644 index 0000000000..1e5b99807c --- /dev/null +++ b/keyboards/acheron/shark/beta/keymaps/via/rules.mk @@ -0,0 +1 @@ +VIA_ENABLE = yes diff --git a/keyboards/acheron/shark/beta/mcuconf.h b/keyboards/acheron/shark/beta/mcuconf.h new file mode 100644 index 0000000000..35d7e95f57 --- /dev/null +++ b/keyboards/acheron/shark/beta/mcuconf.h @@ -0,0 +1,44 @@ +/* Copyright 2020 QMK + * + * 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_next +#undef STM32_PLLM_VALUE +#undef STM32_PLLN_VALUE +#undef STM32_PLLP_VALUE +#undef STM32_PLLQ_VALUE +#undef STM32_PPRE1 +#undef STM32_PPRE2 + +#define STM32_PLLM_VALUE 4 +#define STM32_PLLN_VALUE 96 +#define STM32_PLLP_VALUE 2 +#define STM32_PLLQ_VALUE 4 +#define STM32_PPRE1 STM32_PPRE1_DIV2 +#define STM32_PPRE2 STM32_PPRE2_DIV1 + +#undef STM32_I2C_USE_I2C1 +#define STM32_I2C_USE_I2C1 TRUE + +#undef STM32_PWM_USE_ADVANCED +#define STM32_PWM_USE_ADVANCED TRUE + +#undef STM32_PWM_USE_TIM3 +#define STM32_PWM_USE_TIM3 TRUE + +#undef STM32_PWM_USE_TIM1 +#define STM32_PWM_USE_TIM1 TRUE diff --git a/keyboards/acheron/shark/beta/rules.mk b/keyboards/acheron/shark/beta/rules.mk new file mode 100644 index 0000000000..928ad2d49a --- /dev/null +++ b/keyboards/acheron/shark/beta/rules.mk @@ -0,0 +1,26 @@ +MCU = STM32F411 + +# Bootloader selection +BOOTLOADER = stm32-dfu + +# Build Options +# change yes to no to disable +# +BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite +MOUSEKEY_ENABLE = yes # Mouse keys +EXTRAKEY_ENABLE = yes # Audio control and System control +CONSOLE_ENABLE = no # Console for debug +COMMAND_ENABLE = yes # Commands for debug and configuration +NKRO_ENABLE = yes # Enable N-Key rollover +BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality +RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow +AUDIO_ENABLE = no # Audio output +BACKLIGHT_DRIVER = pwm +LTO_ENABLE = no +ENCODER_ENABLE = yes + +LAYOUTS = ortho_4x12 +EEPROM_DRIVER = i2c + +# Enter lower-power sleep mode when on the ChibiOS idle thread +OPT_DEFS += -DCORTEX_ENABLE_WFI_IDLE=TRUE diff --git a/keyboards/acheron/shark/readme.md b/keyboards/acheron/shark/readme.md index 962a73c6d1..d805571ebb 100644 --- a/keyboards/acheron/shark/readme.md +++ b/keyboards/acheron/shark/readme.md @@ -1,17 +1,46 @@ -# Acheron Aχξρων 40-SM-O-MX-TH-WI (Codename "SharkPCB") QMK firmware +# SharkPCB QMK firmware -

- -

+![sharkpcb](https://acheronproject.com/images/shark/shark_beta_pic3_small.jpg) -This is the QMK firmware repository for the Shark, updated until [revision Alpha](https://github.com/Gondolindrim/SharkPCB/releases/tag/Alpha). +The SharkPCB is an open-source ortholinear 40% layout designed by Gondolindrim for the AcheronProject. -The SharkPCB is an Open-Hardware guidelines compliant PCB which files can be found at [this link](https://github.com/Gondolindrim/SharkPCB). Its designer and maintainer is [Gondolindrim](https://github.com/Gondolindrim). +* Keyboard Maintainer: [Gondolindrim](https://github.com/gondolindrim) +* Hardware Availability: you can get release Beta SharkPCBs using the JLCPCB manufacturer using the files at [its documentation](http:/acheronproject.com/pcbs/shark/shark/) -See the [AcheronDocs](https://gondolindrim.github.io/AcheronDocs/shark/intro.html) page for the SharkPCB full documentation. +## How to flash -Make example for this keyboard (after setting up your build environment): +### Enter bootloader - make acheron/shark:default +### Release Alpha: + +The DFU state in the bootloader can be accessed in 2 ways: + +* **Bootmagic reset**: hold down the key at (0,0) in the matrix (usually the top left key or Escape) and plug in the keyboard +* **Physical reset button**: press the button on the back of the PCB +* **Keycode in layout**: press the key mapped to `RESET` if it is available (ESC key at layer 1 in the default layout) + +### Release Beta: + +The DFU state in the bootloader can be accessed in 3 ways: + +* **Bootmagic reset**: hold down the key at (0,0) in the matrix (usually the top left key or Escape) and plug in the keyboard +* **Physical reset button**: press the button on the back of the PCB, for at least five seconds +* **Keycode in layout**: press the key mapped to `RESET` if it is available (ESC key at layer 1 in the default layout) + +## Compile firmware + +### Release Alpha + +After accessing the DFU state in your PCB, build the default layout using: + + make acheron/shark/alpha:default + +### Release Beta + +After accessing the DFU state in your PCB, build the default layout using: + + make acheron/shark/beta:default + +Then download the resulting binary `*bin` file using `dfu-util` or QMK Toolbox. 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/acheron/shark/shark.c b/keyboards/acheron/shark/shark.c index ab607edae1..1a660019e2 100644 --- a/keyboards/acheron/shark/shark.c +++ b/keyboards/acheron/shark/shark.c @@ -1,16 +1,14 @@ -/* Copyright 2019 Álvaro "Gondolindrim" Volpato - * - * 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 . - */ + /* Copyright 2022 Álvaro "Gondolindrim" Volpato + * + * 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. + */ + #include "shark.h" diff --git a/keyboards/acheron/shark/shark.h b/keyboards/acheron/shark/shark.h index d58b72548a..0f65419885 100644 --- a/keyboards/acheron/shark/shark.h +++ b/keyboards/acheron/shark/shark.h @@ -1,39 +1,9 @@ -/* Copyright 2019 Álvaro "Gondolindrim" Volpato - * - * 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" -/* 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_ortho_4x12( \ - K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, \ - K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, \ - K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, \ - K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B \ -) \ -{ \ - { K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B }, \ - { K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B }, \ - { K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B }, \ - { K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B } \ -} +#if defined(KEYBOARD_acheron_shark_alpha) + #include "alpha.h" +#elif defined(KEYBOARD_acheron_shark_beta) + #include "beta.h" +#endif