chore: clean code
This commit is contained in:
parent
19641844da
commit
9dfcee5e8d
7 changed files with 34 additions and 68 deletions
|
|
@ -16,10 +16,6 @@ enum right_encoder_mode {
|
|||
enum left_encoder_mode left_encoder = LENC_VOL;
|
||||
enum right_encoder_mode right_encoder = RENC_TAB;
|
||||
|
||||
// Alt tab on steroids
|
||||
//bool is_alt_tab_active = false;
|
||||
//uint16_t alt_tab_timer = 0;
|
||||
|
||||
void left_encoder_click(void) {
|
||||
left_encoder++;
|
||||
if (left_encoder == LENC_NOOP) {
|
||||
|
|
@ -42,7 +38,6 @@ void right_encoder_hold(void) {
|
|||
tap_code(KC_MUTE);
|
||||
}
|
||||
|
||||
|
||||
void left_encoder_oled(void) {
|
||||
switch (left_encoder) {
|
||||
case LENC_VOL:
|
||||
|
|
@ -69,9 +64,8 @@ void right_encoder_oled(void) {
|
|||
}
|
||||
}
|
||||
|
||||
/**************** Encoder *****************/
|
||||
bool encoder_update_user(uint8_t index, bool clockwise) {
|
||||
if (index == 0) { // left
|
||||
if (index == 0) {
|
||||
switch (left_encoder) {
|
||||
case LENC_VOL:
|
||||
if (clockwise) {
|
||||
|
|
@ -91,7 +85,7 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
|
|||
default:
|
||||
return false;
|
||||
}
|
||||
} else if (index == 1) { // right
|
||||
} else if (index == 1) {
|
||||
switch (right_encoder) {
|
||||
case RENC_PAGE:
|
||||
if (clockwise) {
|
||||
|
|
|
|||
|
|
@ -5,14 +5,32 @@
|
|||
extern enum left_encoder_mode left_encoder_mode;
|
||||
extern enum right_encoder_mode right_encoder_mode;
|
||||
|
||||
/**
|
||||
* Action to do when the left encoder is clicked
|
||||
*/
|
||||
void left_encoder_click(void);
|
||||
|
||||
/**
|
||||
* Action to do when the left encoder is held down
|
||||
*/
|
||||
void left_encoder_hold(void);
|
||||
|
||||
/**
|
||||
* Action to do when the right encoder is clicked
|
||||
*/
|
||||
void right_encoder_click(void);
|
||||
|
||||
/**
|
||||
* Action to do when the right encoder is held down
|
||||
*/
|
||||
void right_encoder_hold(void);
|
||||
|
||||
/**
|
||||
* Draws the left encoder information on the OLED screen
|
||||
*/
|
||||
void left_encoder_oled(void);
|
||||
|
||||
/**
|
||||
* Draws the right encoder information on the OLED screen
|
||||
*/
|
||||
void right_encoder_oled(void);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
* `----------------------------------' `----------------------------------'
|
||||
*/
|
||||
[_NAV] = LAYOUT(
|
||||
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_REDO, PASTE, COPY, CUT, KC_UNDO, XXXXXXX,
|
||||
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, REDO, PASTE, COPY, CUT, UNDO, XXXXXXX,
|
||||
XXXXXXX, KC_LGUI, KC_LALT, KC_LCTL, KC_LSFT, XXXXXXX, KC_CAPS, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, XXXXXXX,
|
||||
XXXXXXX, XXXXXXX, XXXXXXX, COPY, XXXXXXX, PASTE, XXXXXXX, _______, _______, XXXXXXX, KC_INS, KC_HOME, KC_PGDN, KC_PGUP, KC_END, XXXXXXX,
|
||||
_______, _______, KC_ESC, KC_SPC, KC_TAB, KC_ENT, KC_BSPC, KC_DEL, _______, _______
|
||||
|
|
@ -96,83 +96,56 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
|
||||
};
|
||||
|
||||
// Initialize variable holding the binary
|
||||
// representation of active modifiers.
|
||||
uint8_t mod_state;
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
// Store the current modifier state in the variable for later reference
|
||||
mod_state = get_mods();
|
||||
switch (keycode) {
|
||||
case QC_EAIG:
|
||||
if (record->event.pressed) {
|
||||
// First temporarily canceling both shifts so that
|
||||
// shift isn't applied to the X_QUOTE keycode
|
||||
del_mods(MOD_MASK_SHIFT);
|
||||
SEND_STRING(SS_TAP(X_QUOTE));
|
||||
// Reapplying modifier state so that the held shift key(s)
|
||||
// still work
|
||||
set_mods(mod_state);
|
||||
SEND_STRING("e");
|
||||
}
|
||||
return true;
|
||||
case QC_EGRV:
|
||||
if (record->event.pressed) {
|
||||
// First temporarily canceling both shifts so that
|
||||
// shift isn't applied to the X_QUOTE keycode
|
||||
del_mods(MOD_MASK_SHIFT);
|
||||
SEND_STRING(SS_TAP(X_GRV));
|
||||
// Reapplying modifier state so that the held shift key(s)
|
||||
// still work
|
||||
set_mods(mod_state);
|
||||
SEND_STRING("e");
|
||||
}
|
||||
return true;
|
||||
case QC_AGRV:
|
||||
if (record->event.pressed) {
|
||||
// First temporarily canceling both shifts so that
|
||||
// shift isn't applied to the X_QUOTE keycode
|
||||
del_mods(MOD_MASK_SHIFT);
|
||||
SEND_STRING(SS_TAP(X_GRV));
|
||||
// Reapplying modifier state so that the held shift key(s)
|
||||
// still work
|
||||
set_mods(mod_state);
|
||||
SEND_STRING("a");
|
||||
}
|
||||
return true;
|
||||
case QC_ICRC:
|
||||
if (record->event.pressed) {
|
||||
// First temporarily canceling both shifts so that
|
||||
// shift isn't applied to the X_QUOTE keycode
|
||||
add_mods(MOD_MASK_SHIFT);
|
||||
SEND_STRING(SS_TAP(X_6));
|
||||
del_mods(MOD_MASK_SHIFT);
|
||||
// Reapplying modifier state so that the held shift key(s)
|
||||
// still work
|
||||
set_mods(mod_state);
|
||||
SEND_STRING("i");
|
||||
}
|
||||
return true;
|
||||
case QC_OCRC:
|
||||
if (record->event.pressed) {
|
||||
// First temporarily canceling both shifts so that
|
||||
// shift isn't applied to the X_QUOTE keycode
|
||||
add_mods(MOD_MASK_SHIFT);
|
||||
SEND_STRING(SS_TAP(X_6));
|
||||
del_mods(MOD_MASK_SHIFT);
|
||||
// Reapplying modifier state so that the held shift key(s)
|
||||
// still work
|
||||
set_mods(mod_state);
|
||||
SEND_STRING("o");
|
||||
}
|
||||
return true;
|
||||
case QC_UGRV:
|
||||
if (record->event.pressed) {
|
||||
// First temporarily canceling both shifts so that
|
||||
// shift isn't applied to the X_QUOTE keycode
|
||||
del_mods(MOD_MASK_SHIFT);
|
||||
SEND_STRING(SS_TAP(X_GRV));
|
||||
// Reapplying modifier state so that the held shift key(s)
|
||||
// still work
|
||||
set_mods(mod_state);
|
||||
SEND_STRING("u");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,17 +19,13 @@ uint8_t current_frame = 0;
|
|||
uint32_t anim_timer_luna = 0;
|
||||
uint32_t anim_sleep = 0;
|
||||
|
||||
// Draw Luna on OLED
|
||||
void render_luna(int LUNA_X, int LUNA_Y) {
|
||||
// Sit
|
||||
static const char PROGMEM sit[2][3][ANIM_SIZE/3] = {
|
||||
// 'sit1', 32x22px
|
||||
{
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x1c, 0x02, 0x05, 0x02, 0x24, 0x04, 0x04, 0x02, 0xa9, 0x1e, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x10, 0x08, 0x68, 0x10, 0x08, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x06, 0x82, 0x7c, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x0c, 0x10, 0x10, 0x20, 0x20, 0x20, 0x28, 0x3e, 0x1c, 0x20, 0x20, 0x3e, 0x0f, 0x11, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
|
||||
},
|
||||
// 'sit2', 32x22px
|
||||
{
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x1c, 0x02, 0x05, 0x02, 0x24, 0x04, 0x04, 0x02, 0xa9, 0x1e, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x90, 0x08, 0x18, 0x60, 0x10, 0x08, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x0e, 0x82, 0x7c, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
|
|
@ -37,15 +33,12 @@ void render_luna(int LUNA_X, int LUNA_Y) {
|
|||
}
|
||||
};
|
||||
|
||||
// Walk
|
||||
static const char PROGMEM walk[2][3][ANIM_SIZE/3] = {
|
||||
// 'walk1', 32x22px
|
||||
{
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x20, 0x10, 0x90, 0x90, 0x90, 0xa0, 0xc0, 0x80, 0x80, 0x80, 0x70, 0x08, 0x14, 0x08, 0x90, 0x10, 0x10, 0x08, 0xa4, 0x78, 0x80, 0x00, 0x00, 0x00, 0x00},
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x08, 0xfc, 0x01, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x18, 0xea, 0x10, 0x0f, 0x00, 0x00, 0x00, 0x00},
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1c, 0x20, 0x20, 0x3c, 0x0f, 0x11, 0x1f, 0x03, 0x06, 0x18, 0x20, 0x20, 0x3c, 0x0c, 0x12, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
|
||||
},
|
||||
// 'walk2', 32x22px
|
||||
{
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x20, 0x20, 0x20, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x10, 0x28, 0x10, 0x20, 0x20, 0x20, 0x10, 0x48, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x20, 0xf8, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x30, 0xd5, 0x20, 0x1f, 0x00, 0x00, 0x00, 0x00},
|
||||
|
|
@ -53,15 +46,12 @@ void render_luna(int LUNA_X, int LUNA_Y) {
|
|||
}
|
||||
};
|
||||
|
||||
// Run
|
||||
static const char PROGMEM run[2][3][ANIM_SIZE/3] = {
|
||||
// 'run1', 32x22px
|
||||
{
|
||||
{0x00, 0x00, 0x00, 0x00, 0xe0, 0x10, 0x08, 0x08, 0xc8, 0xb0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x40, 0x40, 0x3c, 0x14, 0x04, 0x08, 0x90, 0x18, 0x04, 0x08, 0xb0, 0x40, 0x80, 0x00, 0x00},
|
||||
{0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0xc4, 0xa4, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc8, 0x58, 0x28, 0x2a, 0x10, 0x0f, 0x00, 0x00},
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x09, 0x04, 0x04, 0x04, 0x04, 0x02, 0x03, 0x02, 0x01, 0x01, 0x02, 0x02, 0x04, 0x08, 0x10, 0x26, 0x2b, 0x32, 0x04, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00}
|
||||
},
|
||||
// 'run2', 32x22px
|
||||
{
|
||||
{0x00, 0x00, 0x00, 0xe0, 0x10, 0x10, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x78, 0x28, 0x08, 0x10, 0x20, 0x30, 0x08, 0x10, 0x20, 0x40, 0x80, 0x00, 0x00, 0x00},
|
||||
{0x00, 0x00, 0x00, 0x03, 0x04, 0x08, 0x10, 0x11, 0xf9, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0xb0, 0x50, 0x55, 0x20, 0x1f, 0x00, 0x00},
|
||||
|
|
@ -69,15 +59,12 @@ void render_luna(int LUNA_X, int LUNA_Y) {
|
|||
}
|
||||
};
|
||||
|
||||
// Bark
|
||||
static const char PROGMEM bark[2][3][ANIM_SIZE/3] = {
|
||||
// 'bark1', 32x22px
|
||||
{
|
||||
{0x00, 0xc0, 0x20, 0x10, 0xd0, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x40, 0x3c, 0x14, 0x04, 0x08, 0x90, 0x18, 0x04, 0x08, 0xb0, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
{0x00, 0x03, 0x04, 0x08, 0x10, 0x11, 0xf9, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc8, 0x48, 0x28, 0x2a, 0x10, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x0c, 0x10, 0x20, 0x28, 0x37, 0x02, 0x02, 0x04, 0x08, 0x10, 0x26, 0x2b, 0x32, 0x04, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
|
||||
},
|
||||
// 'bark2', 32x22px
|
||||
{
|
||||
{0x00, 0xe0, 0x10, 0x10, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x40, 0x40, 0x2c, 0x14, 0x04, 0x08, 0x90, 0x18, 0x04, 0x08, 0xb0, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00},
|
||||
{0x00, 0x03, 0x04, 0x08, 0x10, 0x11, 0xf9, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0x48, 0x28, 0x2a, 0x10, 0x0f, 0x20, 0x4a, 0x09, 0x10},
|
||||
|
|
@ -85,15 +72,12 @@ void render_luna(int LUNA_X, int LUNA_Y) {
|
|||
}
|
||||
};
|
||||
|
||||
// Sneak
|
||||
static const char PROGMEM sneak[2][3][ANIM_SIZE/3] = {
|
||||
// 'sneak1', 32x22px
|
||||
{
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0x40, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x40, 0x40, 0x80, 0x00, 0x80, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
{0x00, 0x00, 0x00, 0x00, 0x1e, 0x21, 0xf0, 0x04, 0x02, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02, 0x04, 0x04, 0x04, 0x03, 0x01, 0x00, 0x00, 0x09, 0x01, 0x80, 0x80, 0xab, 0x04, 0xf8, 0x00, 0x00, 0x00},
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1c, 0x20, 0x20, 0x3c, 0x0f, 0x11, 0x1f, 0x02, 0x06, 0x18, 0x20, 0x20, 0x38, 0x08, 0x10, 0x18, 0x04, 0x04, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00}
|
||||
},
|
||||
// 'sneak2', 32x22px
|
||||
{
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xa0, 0x20, 0x40, 0x80, 0xc0, 0x20, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
{0x00, 0x00, 0x00, 0x00, 0x3e, 0x41, 0xf0, 0x04, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02, 0x02, 0x04, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x40, 0x40, 0x55, 0x82, 0x7c, 0x00, 0x00, 0x00},
|
||||
|
|
@ -153,7 +137,6 @@ void render_luna(int LUNA_X, int LUNA_Y) {
|
|||
}
|
||||
}
|
||||
|
||||
/*** Custom data sync for OLED ***/
|
||||
void user_sync_slave_handler(uint8_t in_buflen, const void* in_data, uint8_t out_buflen, void* out_data) {
|
||||
const master_to_slave_t *m2s = (const master_to_slave_t*)in_data;
|
||||
is_sneaking = m2s->is_sneaking;
|
||||
|
|
|
|||
|
|
@ -3,4 +3,9 @@
|
|||
extern bool is_sneaking;
|
||||
extern bool is_barking;
|
||||
|
||||
/**
|
||||
* Render Luna on the Oled screen
|
||||
*
|
||||
* @param LUNA_X, LUNA_Y the coordinates on which we start drawing Luna
|
||||
*/
|
||||
void render_luna(int LUNA_X, int LUNA_Y);
|
||||
|
|
|
|||
|
|
@ -4,9 +4,6 @@
|
|||
#include "luna.h"
|
||||
#include "encoder.h"
|
||||
|
||||
/**************** Oled *****************/
|
||||
|
||||
// Used to draw on to the oled screen
|
||||
bool oled_task_user(void) {
|
||||
if (is_keyboard_master()) {
|
||||
oled_write_P(PSTR("Layer: "), false);
|
||||
|
|
|
|||
|
|
@ -29,18 +29,14 @@ typedef struct _master_to_slave_t {
|
|||
bool is_barking;
|
||||
} master_to_slave_t;
|
||||
|
||||
#define CTL_ESC MT(MOD_LCTL, KC_ESC)
|
||||
#define LALT_ENT MT(MOD_LALT, KC_ENT)
|
||||
#define RALT_ENT MT(MOD_RALT, KC_ENT)
|
||||
#define KC_LENC LT(0, KC_LEFT_ENC_MODE)
|
||||
#define KC_RENC LT(0, KC_RIGHT_ENC_MODE)
|
||||
|
||||
// Custom actions
|
||||
#define COPY LCTL(KC_C)
|
||||
#define PASTE LCTL(KC_V)
|
||||
#define CUT LCTL(KC_X)
|
||||
#define KC_REDO LCTL(KC_Y)
|
||||
#define KC_UNDO LCTL(KC_Z)
|
||||
#define REDO LCTL(KC_Y)
|
||||
#define UNDO LCTL(KC_Z)
|
||||
#define KC_LENC LT(0, KC_LEFT_ENC_MODE) // Left encoder
|
||||
#define KC_RENC LT(0, KC_RIGHT_ENC_MODE) // Right encoder
|
||||
|
||||
// Home row mods
|
||||
#define HR_GA LGUI_T(KC_A)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue