diff options
author | lokher <lokher@gmail.com> | 2022-12-06 17:04:10 +0800 |
---|---|---|
committer | lokher <lokher@gmail.com> | 2022-12-06 17:04:10 +0800 |
commit | 27fc28fd2ff52e079a5bc58d6aaea4c752420615 (patch) | |
tree | 7ac943fb1ba4f430a7220efd18f66f6a77205c30 /keyboards/crkbd/keymaps/kidbrazil | |
parent | e736133392fe6427cfb995da0787337189828272 (diff) | |
parent | 2709b6ed616f8012ff4cfd3ee69a822a8d188351 (diff) |
Merge upstream master
Diffstat (limited to 'keyboards/crkbd/keymaps/kidbrazil')
-rw-r--r-- | keyboards/crkbd/keymaps/kidbrazil/config.h | 109 | ||||
-rw-r--r-- | keyboards/crkbd/keymaps/kidbrazil/keymap.c | 214 |
2 files changed, 323 insertions, 0 deletions
diff --git a/keyboards/crkbd/keymaps/kidbrazil/config.h b/keyboards/crkbd/keymaps/kidbrazil/config.h new file mode 100644 index 0000000000..74f8a0823b --- /dev/null +++ b/keyboards/crkbd/keymaps/kidbrazil/config.h @@ -0,0 +1,109 @@ +/* +This is the c configuration file for the keymap + +Copyright 2012 Jun Wako <wakojun@gmail.com> +Copyright 2015 Jack Humbert +Copyright 2019 Lucas Moreira + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#pragma once + +//#define USE_MATRIX_I2C + +/* Select hand configuration */ + +#define MASTER_LEFT +// #define MASTER_RIGHT +// #define EE_HANDS + +#define TAPPING_FORCE_HOLD +#define TAPPING_TERM 150 +#undef PRODUCT +#define PRODUCT "CRKBD Loose Transistor Ed." + +#ifdef RGBLIGHT_ENABLE + //#undef RGBLED_NUM + #define RGBLIGHT_EFFECT_BREATHING + #define RGBLIGHT_EFFECT_RAINBOW_MOOD + #define RGBLIGHT_EFFECT_KNIGHT + //#define RGBLED_NUM 27 + #define RGBLIGHT_LIMIT_VAL 120 + #define RGBLIGHT_HUE_STEP 10 + #define RGBLIGHT_SAT_STEP 17 + #define RGBLIGHT_VAL_STEP 17 +#endif + +#ifdef RGB_MATRIX_ENABLE + //# define RGB_MATRIX_KEYPRESSES // reacts to keypresses + // # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses) + #define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended + #define RGB_MATRIX_FRAMEBUFFER_EFFECTS + // # define RGB_MATRIX_LED_PROCESS_LIMIT (RGB_MATRIX_LED_COUNT + 4) / 5 // limits the number of LEDs to process in an animation per task run (increases keyboard responsiveness) + // # define RGB_MATRIX_LED_FLUSH_LIMIT 16 // limits in milliseconds how frequently an animation will update the LEDs. 16 (16ms) is equivalent to limiting to 60fps (increases keyboard responsiveness) + #define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150 // limits maximum brightness of LEDs to 150 out of 255. Higher may cause the controller to crash. + #define RGB_MATRIX_HUE_STEP 4 + #define RGB_MATRIX_SAT_STEP 4 + #define RGB_MATRIX_VAL_STEP 4 + #define RGB_MATRIX_SPD_STEP 10 + + /* Disable the animations you don't want/need. You will need to disable a good number of these * + * because they take up a lot of space. Disable until you can successfully compile your firmware. */ +# undef ENABLE_RGB_MATRIX_ALPHAS_MODS +# undef ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN +# undef ENABLE_RGB_MATRIX_BREATHING +# undef ENABLE_RGB_MATRIX_BAND_PINWHEEL_SAT +# undef ENABLE_RGB_MATRIX_BAND_PINWHEEL_VAL +# undef ENABLE_RGB_MATRIX_BAND_SAT +# undef ENABLE_RGB_MATRIX_BAND_SPIRAL_SAT +# undef ENABLE_RGB_MATRIX_BAND_SPIRAL_VAL +# undef ENABLE_RGB_MATRIX_BAND_VAL +# undef ENABLE_RGB_MATRIX_CYCLE_ALL +# undef ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT +# undef ENABLE_RGB_MATRIX_CYCLE_OUT_IN +# undef ENABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL +# undef ENABLE_RGB_MATRIX_CYCLE_PINWHEEL +# undef ENABLE_RGB_MATRIX_CYCLE_SPIRAL +# undef ENABLE_RGB_MATRIX_CYCLE_UP_DOWN +# undef ENABLE_RGB_MATRIX_DUAL_BEACON +# undef ENABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS +# undef ENABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON +# undef ENABLE_RGB_MATRIX_RAINBOW_PINWHEELS +# undef ENABLE_RGB_MATRIX_SOLID_REACTIVE +# undef ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS +# undef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS +# undef ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS +# undef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS +# undef ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS +# undef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS +# undef ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS +# undef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS +# undef ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE +# undef ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE +# undef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE +# undef ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE +# undef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE +# undef ENABLE_RGB_MATRIX_SOLID_SPLASH +# undef ENABLE_RGB_MATRIX_SOLID_MULTISPLASH +# undef ENABLE_RGB_MATRIX_SOLID_SPLASH +# undef ENABLE_RGB_MATRIX_SOLID_MULTISPLASH +# undef ENABLE_RGB_MATRIX_SPLASH +# undef ENABLE_RGB_MATRIX_MULTISPLASH +# undef ENABLE_RGB_MATRIX_SPLASH +# undef ENABLE_RGB_MATRIX_MULTISPLASH +#endif +// Custom Font path +#define OLED_FONT_H "keyboards/crkbd/keymaps/kidbrazil/glcdfont.c" +#define OLED_DISABLE_TIMEOUT diff --git a/keyboards/crkbd/keymaps/kidbrazil/keymap.c b/keyboards/crkbd/keymaps/kidbrazil/keymap.c new file mode 100644 index 0000000000..d5966033f1 --- /dev/null +++ b/keyboards/crkbd/keymaps/kidbrazil/keymap.c @@ -0,0 +1,214 @@ +#include QMK_KEYBOARD_H +#include "enums.h" +#include "layer.h" +#include "lufa.h" + +// [Init Variables] ----------------------------------------------------------// +// Oled timer similar to Drashna's +static uint32_t oled_timer = 0; +// Boolean to store LED state +bool user_led_enabled = true; +// Boolean to store the master LED clear so it only runs once. +bool master_oled_cleared = false; + +// [Keymaps] -----------------------------------------------------------------// +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_QWERTY] = LAYOUT_split_3x6_3( + KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, + LSFT_T(KC_TAB), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, + KC_LCTL, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, + LGUI_T(KC_PGUP), MO(_NUM), KC_SPC, KC_ENT, MO(_SYM), LALT_T(KC_PGDN) + ), + + [_NUM] = LAYOUT_split_3x6_3( + KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, + LSFT_T(KC_TAB), KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_F12, KC_NO, + KC_LCTL, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_PGUP, KC_PGDN, KC_HOME, KC_END, KC_F11, KC_NO, + LGUI_T(KC_PGUP), KC_TRNS, KC_SPC, KC_ENT, KC_TRNS, LALT_T(KC_PGDN) + ), + + [_SYM] = LAYOUT_split_3x6_3( + KC_ESC, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, + LSFT_T(KC_TAB), RGB_TOG, KC_MPLY, KC_MUTE, KC_VOLU, KC_VOLD, KC_MINS, KC_EQL, KC_LCBR, KC_RCBR, KC_PIPE, KC_GRV, + KC_LCTL, KC_CALC, KC_MYCM, KC_MPRV, KC_MNXT, TG(_GAME), KC_UNDS, KC_PLUS, KC_LBRC, KC_RBRC, KC_BSLS, KC_TILD, + LGUI_T(KC_PGUP), KC_TRNS, KC_SPC, KC_ENT, KC_TRNS, LALT_T(KC_PGDN) + ), + + [_GAME] = LAYOUT_split_3x6_3( + KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, + KC_LSFT, KC_A, KC_S, KC_D, KC_F, KC_G, KC_F7, KC_F8, KC_F9, KC_F10, KC_NO, KC_NO, + KC_LCTL, KC_Z, KC_X, KC_C, KC_V, KC_TRNS, KC_PGUP, KC_PGDN, KC_NO, KC_NO, KC_NO, KC_NO, + KC_TAB, MO(_WEAPON), KC_SPC, KC_ENT, KC_TRNS, KC_NO + ), + + [_WEAPON] = LAYOUT_split_3x6_3( + KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_LSFT, KC_A, KC_S, KC_D, KC_F, KC_6, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_LCTL, KC_Z, KC_X, KC_C, KC_V, KC_7, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, EE_CLR, + KC_TRNS, KC_TAB, KC_TRNS, KC_SPC, KC_TRNS, KC_TRNS, KC_TRNS + ) +}; + +// [Post Init] --------------------------------------------------------------// +void keyboard_post_init_user(void) { + // Set RGB to known state + rgb_matrix_enable_noeeprom(); + rgb_matrix_set_color_all(RGB_GREEN); + rgb_matrix_mode_noeeprom(RGB_MATRIX_SOLID_COLOR); + user_led_enabled = true; +} +// [Process User Input] ------------------------------------------------------// +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + // Handle RGB Changes sans eeprom - necessary due to the layer dependent RGB color + // changes in marrix_scan_user + case RGB_TOG: + if (record->event.pressed) { + // Toggle matrix on key press + user_led_enabled ? rgb_matrix_disable_noeeprom() : rgb_matrix_enable_noeeprom(); + // Toggle boolean flag + user_led_enabled = !user_led_enabled; + } + return false; + default: + // Use process_record_keymap to reset timer on all other keypresses to awaken from idle. + if (record->event.pressed) { + #ifdef OLED_ENABLE + oled_timer = timer_read32(); + #endif + // Restore LEDs if they are enabled by user + if (user_led_enabled) { + rgb_matrix_enable_noeeprom(); + } + } + return true; + } +} + +// [Matrix Scan] ------------------------------------------------------------// +void matrix_scan_user(void) { + // Iddle timer to return to default layer if left on game layer + if (timer_elapsed32(oled_timer) > 380000 && timer_elapsed32(oled_timer) < 479999) { + // Reset layer in case it got left on _GAME + // This prevents the issue where the master side sometimes wont switch off as expected + // in the next step. + if (get_highest_layer(layer_state) == _GAME) { + layer_off(_GAME); + layer_on(_QWERTY); + } + return; + } + // Timeout to turn off LEDs + else if (timer_elapsed32(oled_timer) > 480000) { + rgb_matrix_disable_noeeprom(); + return; + } + // Set RGB Matrix color based on layers + if (user_led_enabled) { + switch (get_highest_layer(layer_state)){ + case _GAME: + rgb_matrix_set_color_all(RGB_PURPLE); + break; + case _NUM: + case _SYM: + case _QWERTY: + rgb_matrix_set_color_all(RGB_GREEN); + break; + default: + rgb_matrix_set_color_all(RGB_GREEN); + break; + + } + } else { + rgb_matrix_disable_noeeprom(); + return; + } +} +// [OLED Configuration] ------------------------------------------------------// +#ifdef OLED_ENABLE +// Init Oled and Rotate.... +oled_rotation_t oled_init_user(oled_rotation_t rotation) { + if (!is_keyboard_master()) + return OLED_ROTATION_180; // flips the display 180 to see it from my side + return rotation; +} + +// Read logo from font file +const char *read_logo(void); + +// {OLED helpers} -----------------------------------------------// +// Render Logo +void render_logo(void) { + oled_write(read_logo(), false); +} + +// Master OLED Screen (Left Hand ) +void render_master_oled(void) { + // Switch display based on Layer + switch (get_highest_layer(layer_state)){ + case _GAME: + render_separator(); + render_layer_state(); + render_separator(); + render_separator(); + break; + case _WEAPON: + render_separator(); + render_separator(); + render_layer_state(); + render_separator(); + break; + default: + render_separator(); + render_layer_state(); + render_separator(); + render_usb_state(); + } +} + +// Slave OLED scren (Right Hand) +void render_slave_oled(void) { + render_logo(); +} + +// {OLED Task} -----------------------------------------------// +bool oled_task_user(void) { + // First time out switches to logo as first indication of iddle. + if (timer_elapsed32(oled_timer) > 100000 && timer_elapsed32(oled_timer) < 479999) { + // Render logo on both halves before full timeout + if (is_keyboard_master() && !master_oled_cleared) { + // Clear master OLED once so the logo renders properly + oled_clear(); + master_oled_cleared = true; + } + render_logo(); + return false; + } + // Drashna style timeout for LED and OLED Roughly 8mins + else if (timer_elapsed32(oled_timer) > 480000) { + oled_off(); + rgb_matrix_disable_noeeprom(); + return false; + } + else { + oled_on(); + // Reset OLED Clear flag + master_oled_cleared = false; + // Show logo when USB dormant + switch (USB_DeviceState) { + case DEVICE_STATE_Unattached: + case DEVICE_STATE_Powered: + case DEVICE_STATE_Suspended: + render_logo(); + break; + default: + if (is_keyboard_master()) { + render_master_oled(); + } else { + render_slave_oled(); + } + } + } + return false; +} +#endif |