Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BastardKB: upstream dilemma/4x6_4 #23816

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 63 additions & 2 deletions keyboards/bastardkb/dilemma/4x6_4/4x6_4.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@

#include "dilemma.h"

#ifndef LAYER_INDICATOR_BRIGHTNESS_INC
# define LAYER_INDICATOR_BRIGHTNESS_INC 22
#endif

#ifndef CAPSLOCK_INDICATOR_BRIGHTNESS_INC
# define CAPSLOCK_INDICATOR_BRIGHTNESS_INC 76
#endif

#ifdef SWAP_HANDS_ENABLE
const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = {
/* Left hand, matrix positions */
Expand All @@ -33,8 +41,7 @@ const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = {
{{0, 1}, {1, 1}, {2, 1}, {3, 1}, {4, 1}, {5, 1}},
{{0, 2}, {1, 2}, {2, 2}, {3, 2}, {4, 2}, {5, 2}},
{{0, 3}, {1, 3}, {2, 3}, {3, 3}, {4, 3}, {5, 3}},
{{0, 4}, {1, 4}, {2, 4}, {3, 4}, {4, 4}, {5, 4}}
};
{{0, 4}, {1, 4}, {2, 4}, {3, 4}, {4, 4}, {5, 4}}};

# ifdef ENCODER_MAP_ENABLE
const uint8_t PROGMEM encoder_hand_swap_config[NUM_ENCODERS] = {1, 0};
Expand All @@ -57,3 +64,57 @@ bool encoder_update_kb(uint8_t index, bool clockwise) {
return true;
}
#endif // ENCODER_ENABLE

#ifdef RGB_MATRIX_ENABLE
static HSV _get_hsv_for_layer_index(uint8_t layer) {
switch (layer) {
case 1:
return (HSV){HSV_BLUE};
case 2:
return (HSV){HSV_AZURE};
case 3:
return (HSV){HSV_ORANGE};
case 4:
return (HSV){HSV_GREEN};
case 5:
return (HSV){HSV_TEAL};
case 6:
return (HSV){HSV_PURPLE};
default:
return (HSV){HSV_RED};
};
}

// Layer state indicator
bool rgb_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max) {
if (!rgb_matrix_indicators_advanced_user(led_min, led_max)) {
return false;
}
// Set indicator LEDs to red if caps lock is enabled
if (host_keyboard_led_state().caps_lock) {
for (int i = led_min; i <= led_max; i++) {
if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_MODIFIER)) {
// set modifier-flagged LEDs to a pure a configured interval brighter than the current brightness, clamped to 255 (ie. uint8_t max value).
rgb_matrix_set_color(i, MIN(rgb_matrix_get_val() + CAPSLOCK_INDICATOR_BRIGHTNESS_INC, 255), 0, 0);
}
}
}

// Set underglow to a solid color for highest active layer apart from the base layer.
const uint8_t layer = get_highest_layer(layer_state);
if (layer > 0) {
HSV hsv = _get_hsv_for_layer_index(layer);

// Set brightness to the configured interval brighter than current brightness, clamped to 255 (ie. uint8_t max value). This compensates for the dimmer appearance of the underglow LEDs.
hsv.v = MIN(rgb_matrix_get_val() + LAYER_INDICATOR_BRIGHTNESS_INC, 255);
const RGB rgb = hsv_to_rgb(hsv);

for (int i = led_min; i < led_max; i++) {
if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_UNDERGLOW)) {
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
}
}
}
return true;
};
#endif // RGB_MATRIX_ENABLE
3 changes: 3 additions & 0 deletions keyboards/bastardkb/dilemma/4x6_4/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@
#define RP2040_BOOTLOADER_DOUBLE_TAP_RESET
#define RP2040_BOOTLOADER_DOUBLE_TAP_RESET_LED GP17
#define RP2040_BOOTLOADER_DOUBLE_TAP_RESET_TIMEOUT 500U

// Reduce soft serial speed: Work around rp2040 issues
#define SELECT_SOFT_SERIAL_SPEED 4
burkfers marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 4 additions & 4 deletions keyboards/bastardkb/dilemma/4x6_4/keyboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@
{"matrix": [8, 3], "x": 175, "y": 38, "flags": 4},
{"matrix": [8, 4], "x": 162, "y": 40, "flags": 4},
{"matrix": [8, 5], "x": 149, "y": 42, "flags": 4},
{"matrix": [9, 4], "x": 170, "y": 51, "flags": 4},
{"matrix": [9, 2], "x": 156, "y": 53, "flags": 4},
{"matrix": [9, 1], "x": 143, "y": 57, "flags": 4},
{"matrix": [9, 3], "x": 132, "y": 64, "flags": 4}
{"matrix": [9, 3], "x": 170, "y": 51, "flags": 4},
{"matrix": [9, 1], "x": 156, "y": 53, "flags": 4},
{"matrix": [9, 2], "x": 143, "y": 57, "flags": 4},
{"matrix": [9, 4], "x": 132, "y": 64, "flags": 4}
],
"sleep": true
},
Expand Down
2 changes: 2 additions & 0 deletions keyboards/bastardkb/dilemma/4x6_4/keymaps/via/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@
#pragma once

#define DYNAMIC_KEYMAP_LAYER_COUNT 8
#define SPLIT_LAYER_STATE_ENABLE
#define SPLIT_LED_STATE_ENABLE
6 changes: 3 additions & 3 deletions keyboards/bastardkb/dilemma/4x6_4/keymaps/via/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,14 @@ layer_state_t layer_state_set_user(layer_state_t state) {
#ifdef RGB_MATRIX_ENABLE
// Forward-declare this helper function since it is defined in rgb_matrix.c.
void rgb_matrix_update_pwm_buffers(void);
#endif
#endif // RGB_MATRIX_ENABLE

#ifdef ENCODER_MAP_ENABLE
// clang-format off
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = {
[LAYER_BASE] = {ENCODER_CCW_CW(KC_WH_U, KC_WH_D), ENCODER_CCW_CW(KC_VOLU, KC_VOLD)},
[LAYER_BASE] = {ENCODER_CCW_CW(KC_WH_U, KC_WH_D), ENCODER_CCW_CW(KC_VOLD, KC_VOLU)},
[LAYER_LOWER] = {ENCODER_CCW_CW(KC_UP, KC_DOWN), ENCODER_CCW_CW(KC_LEFT, KC_RGHT)},
[LAYER_RAISE] = {ENCODER_CCW_CW(KC_PGUP, KC_PGDN), ENCODER_CCW_CW(KC_VOLU, KC_VOLD)},
[LAYER_RAISE] = {ENCODER_CCW_CW(KC_PGUP, KC_PGDN), ENCODER_CCW_CW(KC_VOLD, KC_VOLU)},
[LAYER_POINTER] = {ENCODER_CCW_CW(RGB_HUD, RGB_HUI), ENCODER_CCW_CW(RGB_SAD, RGB_SAI)},
};
// clang-format on
Expand Down
2 changes: 1 addition & 1 deletion keyboards/bastardkb/dilemma/4x6_4/keymaps/via/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ To disable this, add the following to your keymap:

### Sniping

Use the `SNIPING_MODE` keycode to enable sniping mode on hold. Use the `SNIPING_TOGGLE` keycode to enable/disable sniping mode on key press.
Use the `SNIPING_MODE` keycode to enable sniping mode on hold. Use the `SNIPING_MODE_TOGGLE` (aliased as `SNP_TOG`) keycode to enable/disable sniping mode on key press.

Change the value of `DILEMMA_AUTO_SNIPING_ON_LAYER` to automatically enable sniping mode on layer change. By default, sniping mode is enabled on the pointer layer:

Expand Down
14 changes: 13 additions & 1 deletion keyboards/bastardkb/dilemma/4x6_4/readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Dilemma Max (4x6+4)

This keyboard is an upsized version of the [3x5+3 Dilemma](../3x5_3/).

The Dilemma Max is available at [bastardkb.com](https://bastardkb.com).

## Layer and capslock indicators
The Dilemma Max comes with layer indicators using the underglow LEDs and a capslock indicator using the outermost columns of per-key LEDs.

The brightness of both indicators is boosted to counteract them being perceived as dimmer (the underglow has to go through an acrylic plate, and pure red appears dimmer than other colors on these LEDs). This has the side effect that the indicators are visible even if the current RGB brightness is set to zero.

The brightness boosts can be adjusted from your keymap using two defines:
```c
#define LAYER_INDICATOR_BRIGHTNESS_INC 22
#define CAPSLOCK_INDICATOR_BRIGHTNESS_INC 76
```

A value of 255 would make the indicators appear at maximum brightness regardless of the RGB effect brightness. A value of 0 will disable the brightness boosts.
Loading