Merge remote-tracking branch 'origin/master' into develop

This commit is contained in:
QMK Bot 2021-12-27 10:16:53 +00:00
commit c929b7aadf
6 changed files with 184 additions and 35 deletions

View file

@ -87,6 +87,43 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
!> If you return `true`, this will allow the keyboard level code to run, as well. Returning `false` will override the keyboard level code. Depending on how the keyboard level function is set up.
Layer conditions can also be used with the callback function like the following:
```c
bool encoder_update_user(uint8_t index, bool clockwise) {
if (get_highest_layer(layer_state|default_layer_state) > 0) {
if (index == 0) {
if (clockwise) {
tap_code(KC_WH_D);
} else {
tap_code(KC_WH_U);
}
} else if (index == 1) {
if (clockwise) {
tap_code(KC_VOLU);
} else {
tap_code(KC_VOLD);
}
}
} else { /* Layer 0 */
if (index == 0) {
if (clockwise) {
tap_code(KC_PGDN);
} else {
tap_code(KC_PGUP);
}
} else if (index == 1) {
if (clockwise) {
tap_code(KC_DOWN);
} else {
tap_code(KC_UP);
}
}
}
return false;
}
```
## Hardware
The A an B lines of the encoders should be wired directly to the MCU, and the C/common lines should be wired to ground.

View file

@ -49,15 +49,17 @@
/* Locking resynchronize hack */
#define LOCKING_RESYNC_ENABLE
// #define RGB_DI_PIN B5
// #ifdef RGB_DI_PIN
// #define RGBLED_NUM 5
// #define RGBLIGHT_HUE_STEP 8
// #define RGBLIGHT_SAT_STEP 8
// #define RGBLIGHT_VAL_STEP 8
// #define RGBLIGHT_LIMIT_VAL 255 /* The maximum brightness level */
// #define RGBLIGHT_SLEEP /* If defined, the RGB lighting will be switched off when the host goes to sleep */
// #define RGBLIGHT_ANIMATIONS
// #define RGBLIGHT_LAYERS
// #define RGBLIGHT_LAYER_BLINK
// #endif
#define USB_MAX_POWER_CONSUMPTION 500
#define RGB_DI_PIN B5
#ifdef RGB_DI_PIN
#define RGBLED_NUM 15
#define RGBLIGHT_HUE_STEP 8
#define RGBLIGHT_SAT_STEP 8
#define RGBLIGHT_VAL_STEP 8
#define RGBLIGHT_LIMIT_VAL 255 /* The maximum brightness level */
#define RGBLIGHT_SLEEP /* If defined, the RGB lighting will be switched off when the host goes to sleep */
#define RGBLIGHT_ANIMATIONS
#define RGBLIGHT_LAYERS
#define RGBLIGHT_LAYER_BLINK
#endif

View file

@ -165,11 +165,11 @@ const unsigned char font[] PROGMEM = {
0xF1, 0xF9, 0xFD, 0x01, 0x01, 0xFE,
0xFE, 0x01, 0x01, 0xFD, 0xF9, 0xF1,
0x61, 0x01, 0xFD, 0x01, 0x01, 0xFE,
0xFE, 0x01, 0xF9, 0xF9, 0x31, 0xE1,
0xE1, 0x31, 0xF9, 0xF9, 0x01, 0xFE,
0xFE, 0x01, 0xF9, 0xF9, 0x61, 0x61,
0x61, 0x61, 0xF9, 0xF9, 0x01, 0xFE,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xF0, 0x08, 0x04, 0xC4, 0x24, 0x24,
0x24, 0xC4, 0x04, 0x08, 0xF0, 0x00,
0xF0, 0xF8, 0xFC, 0x3C, 0xDC, 0xDC,
0xDC, 0x3C, 0xFC, 0xF8, 0xF0, 0x00,
0xFE, 0xC1, 0xC1, 0xC9, 0xC5, 0xDD,
0xC5, 0xC9, 0xC1, 0xC1, 0xFE, 0x00,
0xFC, 0xFE, 0xFE, 0xEE, 0xF6, 0xC6,
@ -197,15 +197,15 @@ const unsigned char font[] PROGMEM = {
0x08, 0x09, 0x0B, 0x08, 0x08, 0x07,
0x07, 0x08, 0x08, 0x0B, 0x09, 0x08,
0x08, 0x08, 0x0B, 0x08, 0x08, 0x07,
0x07, 0x08, 0x09, 0x09, 0x08, 0x08,
0x08, 0x08, 0x09, 0x09, 0x08, 0x07,
0x07, 0x08, 0x09, 0x09, 0x08, 0x08,
0x08, 0x08, 0x09, 0x09, 0x08, 0x07,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x08, 0x10, 0x13, 0x11, 0x11,
0x11, 0x13, 0x10, 0x08, 0x07, 0x00,
0x07, 0x0F, 0x1F, 0x1C, 0x1E, 0x1E,
0x1E, 0x1C, 0x1F, 0x0F, 0x07, 0x00,
0xFE, 0x01, 0xF1, 0xF9, 0xFD, 0xFD,
0x05, 0x05, 0x09, 0xF1, 0x01, 0xFE,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFE, 0x01, 0x39, 0x7D, 0x6D, 0x6D,
0x6D, 0x6D, 0xED, 0xC9, 0x01, 0xFE,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@ -236,8 +236,8 @@ const unsigned char font[] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x08, 0x08, 0x09, 0x0B, 0x0B,
0x0A, 0x0A, 0x09, 0x08, 0x08, 0x07,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x08, 0x09, 0x0B, 0x0B, 0x0B,
0x0B, 0x0B, 0x0B, 0x09, 0x08, 0x07,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

View file

@ -16,11 +16,12 @@
#include QMK_KEYBOARD_H
#define LAYERNUM 2
#define LAYERNUM 3
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT(KC_MUTE, KC_MPLY, KC_MPRV, KC_MNXT, TO(1)),
[1] = LAYOUT(KC_TRNS, KC_MSTP, KC_MRWD, KC_MFFD, TO(0))
[1] = LAYOUT(KC_TRNS, KC_MSTP, KC_MRWD, KC_MFFD, TO(2)),
[2] = LAYOUT(KC_LSFT, RGB_MOD, RGB_HUI, RGB_SAI, TO(0))
};
int get_icon_start_position(int key_position) {
@ -44,13 +45,12 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
oled_write_P(UP_ICON, false);
} else {
tap_code(KC_VOLD);
oled_set_cursor(get_icon_start_position(7), 2);
oled_write_P(PSTR(" "), false);
oled_set_cursor(get_icon_start_position(7), 3);
oled_write_P(DOWN_ICON, false);
}
} else {
} else if (layer_state_is(1)) {
if (clockwise) {
tap_code(KC_BRIU);
oled_set_cursor(get_icon_start_position(7), 3);
@ -64,6 +64,20 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
oled_set_cursor(get_icon_start_position(7), 3);
oled_write_P(DOWN_ICON, false);
}
} else if (layer_state_is(2)) {
if (clockwise) {
rgblight_increase_val();
oled_set_cursor(get_icon_start_position(7), 3);
oled_write_P(PSTR(" "), false);
oled_set_cursor(get_icon_start_position(7), 2);
oled_write_P(UP_ICON, false);
} else {
rgblight_decrease_val();
oled_set_cursor(get_icon_start_position(7), 2);
oled_write_P(PSTR(" "), false);
oled_set_cursor(get_icon_start_position(7), 3);
oled_write_P(DOWN_ICON, false);
}
}
}
return true;
@ -174,7 +188,34 @@ void draw_brightness_icon(int key_position, int row) {
oled_write_P(ICON_BRIGHTNESS_1, false);
}
bool oled_task_user(void) {
void draw_mode_icon(int key_position, int row) {
static const char PROGMEM ICON_MODE_0[] = {0x94, 0x95, 0};
static const char PROGMEM ICON_MODE_1[] = {0xB4, 0xB5, 0};
oled_set_cursor(get_icon_start_position(key_position), row);
oled_write_P(ICON_MODE_0, false);
oled_set_cursor(get_icon_start_position(key_position), row + 1);
oled_write_P(ICON_MODE_1, false);
}
void draw_hue_icon(int key_position, int row) {
static const char PROGMEM ICON_HUE_0[] = {0x96, 0x97, 0};
static const char PROGMEM ICON_HUE_1[] = {0xB6, 0xB7, 0};
oled_set_cursor(get_icon_start_position(key_position), row);
oled_write_P(ICON_HUE_0, false);
oled_set_cursor(get_icon_start_position(key_position), row + 1);
oled_write_P(ICON_HUE_1, false);
}
void draw_sat_icon(int key_position, int row) {
static const char PROGMEM ICON_SAT_0[] = {0xBB, 0xBC, 0};
static const char PROGMEM ICON_SAT_1[] = {0xDB, 0xDC, 0};
oled_set_cursor(get_icon_start_position(key_position), row);
oled_write_P(ICON_SAT_0, false);
oled_set_cursor(get_icon_start_position(key_position), row + 1);
oled_write_P(ICON_SAT_1, false);
}
void oled_task_user(void) {
// Host Keyboard Layer Status
static const char PROGMEM ICON_LAYER[] = {0x80, 0x81, 0x82, 0x83, 0};
static const char PROGMEM ICON_ENCODER[] = {0x84, 0x85, 0x86, 0x87, 0};
@ -189,6 +230,9 @@ bool oled_task_user(void) {
case 1:
oled_write_P(PSTR("2ND "), false);
break;
case 2:
oled_write_P(PSTR("3RD "), false);
break;
default:
// Or use the write_ln shortcut over adding '\n' to the end of your string
oled_write_P(PSTR("UNDF"), false);
@ -204,6 +248,9 @@ bool oled_task_user(void) {
case 1:
oled_write_P(PSTR("BRGT"), false);
break;
case 2:
oled_write_P(PSTR("RGB "), false);
break;
default:
// Or use the write_ln shortcut over adding '\n' to the end of your string
oled_write_P(PSTR("UNDF"), false);
@ -227,6 +274,14 @@ bool oled_task_user(void) {
draw_lower_icon(5, 2);
draw_brightness_icon(6, 2);
break;
case 2:
draw_raise_icon(1, 2);
draw_mode_icon(2, 2);
draw_hue_icon(3, 2);
draw_sat_icon(4, 2);
draw_lower_icon(5, 2);
draw_brightness_icon(6, 2);
break;
}
return false;

View file

@ -16,11 +16,12 @@
#include QMK_KEYBOARD_H
#define LAYERNUM 2
#define LAYERNUM 3
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT(KC_MUTE, KC_MPLY, KC_MPRV, KC_MNXT, TO(1)),
[1] = LAYOUT(KC_TRNS, KC_MSTP, KC_MRWD, KC_MFFD, TO(0))
[1] = LAYOUT(KC_TRNS, KC_MSTP, KC_MRWD, KC_MFFD, TO(2)),
[2] = LAYOUT(KC_LSFT, RGB_MOD, RGB_HUI, RGB_SAI, TO(0))
};
int get_icon_start_position(int key_position) {
@ -44,13 +45,12 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
oled_write_P(UP_ICON, false);
} else {
tap_code(KC_VOLD);
oled_set_cursor(get_icon_start_position(7), 2);
oled_write_P(PSTR(" "), false);
oled_set_cursor(get_icon_start_position(7), 3);
oled_write_P(DOWN_ICON, false);
}
} else {
} else if (layer_state_is(1)) {
if (clockwise) {
tap_code(KC_BRIU);
oled_set_cursor(get_icon_start_position(7), 3);
@ -64,6 +64,20 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
oled_set_cursor(get_icon_start_position(7), 3);
oled_write_P(DOWN_ICON, false);
}
} else if (layer_state_is(2)) {
if (clockwise) {
rgblight_increase_val();
oled_set_cursor(get_icon_start_position(7), 3);
oled_write_P(PSTR(" "), false);
oled_set_cursor(get_icon_start_position(7), 2);
oled_write_P(UP_ICON, false);
} else {
rgblight_decrease_val();
oled_set_cursor(get_icon_start_position(7), 2);
oled_write_P(PSTR(" "), false);
oled_set_cursor(get_icon_start_position(7), 3);
oled_write_P(DOWN_ICON, false);
}
}
}
return true;
@ -174,7 +188,34 @@ void draw_brightness_icon(int key_position, int row) {
oled_write_P(ICON_BRIGHTNESS_1, false);
}
bool oled_task_user(void) {
void draw_mode_icon(int key_position, int row) {
static const char PROGMEM ICON_MODE_0[] = {0x94, 0x95, 0};
static const char PROGMEM ICON_MODE_1[] = {0xB4, 0xB5, 0};
oled_set_cursor(get_icon_start_position(key_position), row);
oled_write_P(ICON_MODE_0, false);
oled_set_cursor(get_icon_start_position(key_position), row + 1);
oled_write_P(ICON_MODE_1, false);
}
void draw_hue_icon(int key_position, int row) {
static const char PROGMEM ICON_HUE_0[] = {0x96, 0x97, 0};
static const char PROGMEM ICON_HUE_1[] = {0xB6, 0xB7, 0};
oled_set_cursor(get_icon_start_position(key_position), row);
oled_write_P(ICON_HUE_0, false);
oled_set_cursor(get_icon_start_position(key_position), row + 1);
oled_write_P(ICON_HUE_1, false);
}
void draw_sat_icon(int key_position, int row) {
static const char PROGMEM ICON_SAT_0[] = {0xBB, 0xBC, 0};
static const char PROGMEM ICON_SAT_1[] = {0xDB, 0xDC, 0};
oled_set_cursor(get_icon_start_position(key_position), row);
oled_write_P(ICON_SAT_0, false);
oled_set_cursor(get_icon_start_position(key_position), row + 1);
oled_write_P(ICON_SAT_1, false);
}
void oled_task_user(void) {
// Host Keyboard Layer Status
static const char PROGMEM ICON_LAYER[] = {0x80, 0x81, 0x82, 0x83, 0};
static const char PROGMEM ICON_ENCODER[] = {0x84, 0x85, 0x86, 0x87, 0};
@ -189,6 +230,9 @@ bool oled_task_user(void) {
case 1:
oled_write_P(PSTR("2ND "), false);
break;
case 2:
oled_write_P(PSTR("3RD "), false);
break;
default:
// Or use the write_ln shortcut over adding '\n' to the end of your string
oled_write_P(PSTR("UNDF"), false);
@ -204,6 +248,9 @@ bool oled_task_user(void) {
case 1:
oled_write_P(PSTR("BRGT"), false);
break;
case 2:
oled_write_P(PSTR("RGB "), false);
break;
default:
// Or use the write_ln shortcut over adding '\n' to the end of your string
oled_write_P(PSTR("UNDF"), false);
@ -227,6 +274,14 @@ bool oled_task_user(void) {
draw_lower_icon(5, 2);
draw_brightness_icon(6, 2);
break;
case 2:
draw_raise_icon(1, 2);
draw_mode_icon(2, 2);
draw_hue_icon(3, 2);
draw_sat_icon(4, 2);
draw_lower_icon(5, 2);
draw_brightness_icon(6, 2);
break;
}
return false;

View file

@ -14,7 +14,7 @@ CONSOLE_ENABLE = no # Console for debug
COMMAND_ENABLE = no # Commands for debug and configuration
NKRO_ENABLE = no # Enable N-Key Rollover
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow
AUDIO_ENABLE = no # Audio output
ENCODER_ENABLE = yes
OLED_ENABLE = yes