Minor modifications

This commit is contained in:
lalalademaxiya1 2022-07-14 17:34:22 +08:00
parent 7afdf42dd0
commit 6bb4611199
4 changed files with 12 additions and 18 deletions

View File

@ -26,7 +26,7 @@ bool dip_switch_update_kb(uint8_t index, bool active) {
return true;
}
#endif
#endif // DIP_SWITCH_ENABLE
#if defined(RGB_MATRIX_ENABLE) && defined(CAPS_LOCK_LED_INDEX)

View File

@ -80,6 +80,10 @@ void rgb_matrix_indicators_none_kb(void) {
bool led_update_kb(led_t led_state) {
bool res = led_update_user(led_state);
if (rgb_matrix_is_enabled()) {
return res;
}
if (res) {
if (led_state.caps_lock) {
uint8_t v = light_brightness_get();

View File

@ -73,7 +73,7 @@ static uint8_t light_brightness_get(void) {
}
void rgb_matrix_indicators_kb(void) {
# if defined(NUM_LOCK_LED_INDEX)
# if defined(CAPS_LOCK_LED_INDEX)
if (host_keyboard_led_state().caps_lock) {
uint8_t v = light_brightness_get();
rgb_matrix_set_color(CAPS_LOCK_LED_INDEX, v, v, v); // white, with the adjusted brightness
@ -100,8 +100,8 @@ bool led_update_kb(led_t led_state) {
}
if (res) {
if (led_state.caps_lock) {
# if defined(CAPS_LOCK_LED_INDEX)
if (led_state.caps_lock) {
uint8_t v = light_brightness_get();
rgb_matrix_set_color(CAPS_LOCK_LED_INDEX, v, v, v);
} else {

View File

@ -55,6 +55,7 @@ static int8_t encoder_LUT[] = {0, -1, 1, 0, 1, 0, 0, -1, -1, 0, 0, 1, 0, 1, -1,
static uint8_t encoder_state[NUM_ENCODERS] = {0};
static int8_t encoder_pulses[NUM_ENCODERS] = {0};
static bool encoder_external_update[NUM_ENCODERS] = {false};
// encoder counts
static uint8_t thisCount;
@ -201,31 +202,19 @@ static bool encoder_update(uint8_t index, uint8_t state) {
return changed;
}
#if defined(PAL_USE_CALLBACKS) || defined(AVR_USE_INT)
bool encoder_read(void) {
bool changed = false;
for (uint8_t i = 0; i < thisCount; i++) {
uint8_t new_status = (readPin(encoders_pad_a[i]) << 0) | (readPin(encoders_pad_b[i]) << 1);
encoder_state[i] <<= 2;
encoder_state[i] |= new_status;
changed |= encoder_update(i, encoder_state[i]);
}
return changed;
}
#else
bool encoder_read(void) {
bool changed = false;
for (uint8_t i = 0; i < thisCount; i++) {
uint8_t new_status = (readPin(encoders_pad_a[i]) << 0) | (readPin(encoders_pad_b[i]) << 1);
if ((encoder_state[i] & 0x3) != new_status) {
if ((encoder_state[i] & 0x3) != new_status || encoder_external_update[i]) {
encoder_state[i] <<= 2;
encoder_state[i] |= new_status;
changed |= encoder_update(i, encoder_state[i]);
encoder_external_update[i] = false;
}
}
return changed;
}
#endif
#ifdef SPLIT_KEYBOARD
void last_encoder_activity_trigger(void);
@ -271,5 +260,6 @@ void encoder_insert_state(uint8_t index) {
encoder_state[index] <<= 2;
encoder_state[index] |= (readPin(encoders_pad_a[index]) << 0) | (readPin(encoders_pad_b[index]) << 1);
encoder_pulses[index] += encoder_LUT[encoder_state[index] & 0xF];
encoder_external_update[index] = true;
}
#endif