Skip to content

Commit

Permalink
Update sethBarberee Userspace (qmk#12620)
Browse files Browse the repository at this point in the history
* update for LTO and guard RGBLED_SPLIT

* Revert "update for LTO and guard RGBLED_SPLIT"

This reverts commit ce81177.

* Revert "Revert "update for LTO and guard RGBLED_SPLIT""

This reverts commit 67da0ce.

* update iris keymap for keymap_kc removal and overhaul userspace

* add licenses

* fix tap_dance error when rgblight is disabled and update/clean iris/sinc maps
  • Loading branch information
SethBarberee authored May 8, 2021
1 parent eb1e1b2 commit bf4c5f6
Show file tree
Hide file tree
Showing 9 changed files with 453 additions and 53 deletions.
69 changes: 65 additions & 4 deletions users/sethBarberee/config.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,69 @@
/* Copyright 2021 SethBarberee <seth.barberee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once

#ifdef RGBLIGHT_ENABLE
# ifndef CAPS_LOCK_MODE
# define CAPS_LOCK_MODE 1
# define RGBLIGHT_SLEEP
# ifndef RGBLIGHT_HUE_STEP
# define RGBLIGHT_HUE_STEP 8
#endif
# ifndef RGBLIGHT_SAT_STEPT
# define RGBLIGHT_SAT_STEP 8
#endif
# ifndef RGBLIGHT_VAL_STEP
# define RGBLIGHT_VAL_STEP 8
#endif
// Trim animations I don't use/like
# ifdef RGBLIGHT_ANIMATIONS
# undef RGBLIGHT_ANIMATIONS
# endif
# ifndef NORMAL_MODE
# define NORMAL_MODE 4
# define RGBLIGHT_EFFECT_BREATHING
# define RGBLIGHT_EFFECT_STATIC_GRADIENT
# define RGBLIGHT_EFFECT_TWINKLE
# ifndef CAPS_LOCK_MODE
# define CAPS_LOCK_MODE RGBLIGHT_MODE_STATIC_LIGHT
# endif
#endif // RGBLIGHT_ENABLE

#ifndef AUDIO_ENABLE
# define NO_MUSIC_MODE
#endif // AUDIO_ENABLE

#define FORCE_NKRO // Force NKRO on by default

// Totally taken from @drashna's userspace
#ifdef TAPPING_TERM
# undef TAPPING_TERM
#endif // TAPPING_TERM
//
// Keeping these commented for examples when I want to tweak per keyboard
// but setting a default across my boards for now
//
//#if defined(KEYBOARD_ergodox_ez)
//# define TAPPING_TERM 185
#if defined(KEYBOARD_crkbd)
# define TAPPING_TERM 185
#else
# define TAPPING_TERM 200
#endif

/* Disable unused and unneeded features to reduce on firmware size */
#ifdef LOCKING_SUPPORT_ENABLE
# undef LOCKING_SUPPORT_ENABLE
#endif
#ifdef LOCKING_RESYNC_ENABLE
# undef LOCKING_RESYNC_ENABLE
#endif
52 changes: 52 additions & 0 deletions users/sethBarberee/rgb_light.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* Copyright 2021 SethBarberee <seth.barberee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "rgb_light.h"

#if defined(RGBLIGHT_ENABLE)
layer_state_t layer_state_set_rgb_light(layer_state_t state){
switch(get_highest_layer(state)) {
case _QWERTY:
rgblight_set_hsv_and_mode(HSV_RED, RGBLIGHT_MODE_BREATHING + 3);
break;
case _LOWER:
rgblight_set_hsv_and_mode(HSV_GREEN, RGBLIGHT_MODE_BREATHING + 3);
break;
case _RAISE:
rgblight_set_hsv_and_mode(HSV_BLUE, RGBLIGHT_MODE_BREATHING + 3);
break;
case _ADJUST:
rgblight_set_hsv_and_mode(HSV_GOLDENROD, RGBLIGHT_MODE_BREATHING + 3);
break;
default:
rgblight_set_hsv_and_mode(HSV_PINK, RGBLIGHT_MODE_TWINKLE + 3);
break;

}
return state;
}

void rgblight_set_hsv_and_mode(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode) {
rgblight_sethsv_noeeprom(hue, sat, val);
// wait_us(175); // Add a slight delay between color and mode to ensure it's processed correctly
rgblight_mode_noeeprom(mode);
}

void keyboard_post_init_rgb_light(void)
{
layer_state_set_rgb_light(layer_state);
}
#endif

21 changes: 21 additions & 0 deletions users/sethBarberee/rgb_light.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* Copyright 2021 SethBarberee <seth.barberee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "sethBarberee.h"

layer_state_t layer_state_set_rgb_light(layer_state_t state);
void keyboard_post_init_rgb_light(void);
void rgblight_set_hsv_and_mode(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode);
9 changes: 9 additions & 0 deletions users/sethBarberee/rules.mk
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
SRC += sethBarberee.c

# Add in custom tap dances when tap dance is enabled
ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
SRC += tap_dance.c
endif

ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
SRC += rgb_light.c
endif
112 changes: 76 additions & 36 deletions users/sethBarberee/sethBarberee.c
Original file line number Diff line number Diff line change
@@ -1,45 +1,85 @@
/* Copyright 2021 SethBarberee <seth.barberee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "sethBarberee.h"
#ifdef RGBLIGHT_ENABLE
#ifdef TAP_DANCE_ENABLE

// Initialize it now
tap caps_status = {
.toggled = false,
.toggle_mode = CAPS_LOCK_MODE,
.normal_mode = NORMAL_MODE
};

void dance_ecap_finished (qk_tap_dance_state_t *state, void *user_data){
if(state->count == 1){
register_code(KC_ESC);
} else {
register_code(KC_CAPS);
if(!caps_status.toggled){
// Toggling caps so indicate
caps_status.toggled = true;
rgblight_mode_noeeprom(caps_status.toggle_mode);
} else {
// Turning off so return to normal mode
caps_status.toggled = false;
rgblight_mode_noeeprom(caps_status.normal_mode);
}
}
#include "version.h"

__attribute__ ((weak)) void keyboard_pre_init_keymap(void) {}

void keyboard_pre_init_user(void){
#if defined(BOOTLOADER_CATERINA)
// Make sure the red LEDs don't light
setPinOutput(D5);
writePinHigh(D5);

setPinOutput(B0);
writePinHigh(B0);
#endif
keyboard_pre_init_keymap();
}

void dance_ecap_reset (qk_tap_dance_state_t *state, void *user_data){
if(state->count == 1){
unregister_code(KC_ESC);
} else {
unregister_code(KC_CAPS);
__attribute__ ((weak)) layer_state_t layer_state_set_keymap (layer_state_t state) { return state; }

layer_state_t layer_state_set_user(layer_state_t state){

if (!is_keyboard_master()) {
return state;
}

state = update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST);
#if defined(RGBLIGHT_ENABLE)
state = layer_state_set_rgb_light(state);
#endif
return layer_state_set_keymap(state);
}

//Tap Dance Definitions
qk_tap_dance_action_t tap_dance_actions[] = {
//Tap once for Esc, twice for Caps Lock
[TD_ECAP] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, dance_ecap_finished, dance_ecap_reset),
// Other declarations would go here, separated by commas, if you have them
};
__attribute__ ((weak)) void keyboard_post_init_keymap(void) {}

void keyboard_post_init_user(void)
{
#if defined(RGBLIGHT_ENABLE)
keyboard_post_init_rgb_light();
#endif
keyboard_post_init_keymap();
}

__attribute__((weak)) void suspend_power_down_keymap(void) {}

void suspend_power_down_user(void) {
#ifdef OLED_DRIVER_ENABLE
oled_off();
#endif
suspend_power_down_keymap();
}

__attribute__((weak)) void suspend_wakeup_init_keymap(void) {}

void suspend_wakeup_init_user(void) { suspend_wakeup_init_keymap(); }

__attribute__ ((weak)) bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { return true;}

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (process_record_keymap(keycode, record))
{
switch (keycode) {
case KC_VRSN: // Prints firmware version
if (record->event.pressed) {
SEND_STRING(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION ", Built on: " QMK_BUILDDATE);
}
break;
}
}
return true;
}
56 changes: 43 additions & 13 deletions users/sethBarberee/sethBarberee.h
Original file line number Diff line number Diff line change
@@ -1,20 +1,50 @@
#ifndef USERSPACE
#define USERSPACE
/* Copyright 2021 SethBarberee <seth.barberee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once

#include "quantum.h"
#include QMK_KEYBOARD_H

#ifdef TAP_DANCE_ENABLE // only enable for tap dances
enum {
TD_ECAP = 0,
};
#include "wrappers.h"

#define KC_ECAP TD(TD_ECAP)
enum layers {
_QWERTY,
_LOWER,
_RAISE,
_ADJUST
};

typedef struct {
bool toggled; // store whether we have toggled caps lock
int toggle_mode; // idk why but maybe do something with this..
int normal_mode;
} tap;
enum userspace_keycodes {
KC_VRSN = SAFE_RANGE,
NEW_SAFE_RANGE
};

#define KC_LOWR MO(_LOWER)
#define KC_RASE MO(_RAISE)

#ifdef TAP_DANCE_ENABLE
# include "tap_dance.h"
#endif

#ifdef RGBLIGHT_ENABLE
# include "rgb_light.h"
#endif

void keyboard_pre_init_keymap(void);
void keyboard_post_init_keymap(void);
void suspend_power_down_keymap(void);
void suspend_wakeup_init_keymap(void);
layer_state_t layer_state_set_keymap (layer_state_t state);
bool process_record_keymap(uint16_t keycode, keyrecord_t *record);
Loading

0 comments on commit bf4c5f6

Please sign in to comment.