Skip to content

Commit

Permalink
fix: restores status led control voyager / moonlander
Browse files Browse the repository at this point in the history
  • Loading branch information
fdidron committed Jul 12, 2024
1 parent 9f2e238 commit 27a59c8
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 50 deletions.
22 changes: 22 additions & 0 deletions keyboards/zsa/common/oryx.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
// SPDX-License-Identifier: GPL-2.0-or-later

#include <string.h>
#include QMK_KEYBOARD_H
#include "oryx.h"

rawhid_state_t rawhid_state = {
.paired = false,
.rgb_control = false,
.status_led_control = false,
};

uint8_t pairing_input_index = 0;
Expand Down Expand Up @@ -250,6 +252,26 @@ void raw_hid_receive(uint8_t *data, uint8_t length) {
}
case ORYX_STATUS_LED_CONTROL: {
rawhid_state.status_led_control = param[0];
if (!param[0]) {
#ifdef STATUS_LED_1
STATUS_LED_1(0);
#endif
#ifdef STATUS_LED_2
STATUS_LED_2(0);
#endif
#ifdef STATUS_LED_3
STATUS_LED_3(0);
#endif
#ifdef STATUS_LED_4
STATUS_LED_4(0);
#endif
#ifdef STATUS_LED_5
STATUS_LED_5(0);
#endif
#ifdef STATUS_LED_6
STATUS_LED_6(0);
#endif
}
uint8_t event[RAW_EPSIZE];
event[0] = ORYX_EVT_STATUS_LED_CONTROL;
event[1] = rawhid_state.status_led_control;
Expand Down
12 changes: 6 additions & 6 deletions keyboards/zsa/moonlander/matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,12 @@ void matrix_power_up(void) {

is_launching = temp_launching;
if (!is_launching) {
ML_LED_1(false);
ML_LED_2(false);
ML_LED_3(false);
ML_LED_4(false);
ML_LED_5(false);
ML_LED_6(false);
STATUS_LED_1(false);
STATUS_LED_2(false);
STATUS_LED_3(false);
STATUS_LED_4(false);
STATUS_LED_5(false);
STATUS_LED_6(false);
}

// initialize matrix state: all keys off
Expand Down
69 changes: 36 additions & 33 deletions keyboards/zsa/moonlander/moonlander.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@ static uint32_t dynamic_macro_led(uint32_t trigger_time, void *cb_arg) {
static bool led_state = true;
if (!is_launching) {
led_state = !led_state;
ML_LED_3(led_state);
STATUS_LED_3(led_state);
}
return 100;
}

void dynamic_macro_record_start_user(int8_t direction) {
if (dynamic_macro_token == INVALID_DEFERRED_TOKEN) {
ML_LED_3(true);
STATUS_LED_3(true);
dynamic_macro_token = defer_exec(100, dynamic_macro_led, NULL);
}
}

void dynamic_macro_record_end_user(int8_t direction) {
if (cancel_deferred_exec(dynamic_macro_token)) {
dynamic_macro_token = INVALID_DEFERRED_TOKEN;
ML_LED_3(false);
STATUS_LED_3(false);
}
}
# endif
Expand All @@ -56,45 +56,45 @@ static uint32_t startup_exec(uint32_t trigger_time, void *cb_arg) {

switch (startup_loop++) {
case 0:
ML_LED_1(true);
ML_LED_2(false);
ML_LED_3(false);
ML_LED_4(false);
ML_LED_5(false);
ML_LED_6(false);
STATUS_LED_1(true);
STATUS_LED_2(false);
STATUS_LED_3(false);
STATUS_LED_4(false);
STATUS_LED_5(false);
STATUS_LED_6(false);
break;
case 1:
ML_LED_2(true);
STATUS_LED_2(true);
break;
case 2:
ML_LED_3(true);
STATUS_LED_3(true);
break;
case 3:
ML_LED_4(true);
STATUS_LED_4(true);
break;
case 4:
ML_LED_5(true);
STATUS_LED_5(true);
break;
case 5:
ML_LED_6(true);
STATUS_LED_6(true);
break;
case 6:
ML_LED_1(false);
STATUS_LED_1(false);
break;
case 7:
ML_LED_2(false);
STATUS_LED_2(false);
break;
case 8:
ML_LED_3(false);
STATUS_LED_3(false);
break;
case 9:
ML_LED_4(false);
STATUS_LED_4(false);
break;
case 10:
ML_LED_5(false);
STATUS_LED_5(false);
break;
case 11:
ML_LED_6(false);
STATUS_LED_6(false);
break;
case 12:
is_launching = false;
Expand All @@ -121,6 +121,9 @@ layer_state_t layer_state_set_kb(layer_state_t state) {
#if !defined(MOONLANDER_USER_LEDS)
state = layer_state_set_user(state);
if (is_launching || !keyboard_config.led_level) return state;
#ifdef ORYX_ENABLE
if (rawhid_state.status_led_control) return state;
#endif
bool LED_1 = false;
bool LED_2 = false;
bool LED_3 = false;
Expand Down Expand Up @@ -161,13 +164,13 @@ layer_state_t layer_state_set_kb(layer_state_t state) {
break;
}

ML_LED_1(LED_1);
ML_LED_2(LED_2);
ML_LED_3(LED_3);
ML_LED_4(LED_4);
ML_LED_5(LED_5);
STATUS_LED_1(LED_1);
STATUS_LED_2(LED_2);
STATUS_LED_3(LED_3);
STATUS_LED_4(LED_4);
STATUS_LED_5(LED_5);
#if !defined(CAPS_LOCK_STATUS)
ML_LED_6(LED_6);
STATUS_LED_6(LED_6);
#endif
#endif
#ifdef ORYX_ENABLE
Expand Down Expand Up @@ -330,7 +333,7 @@ const uint8_t music_map[MATRIX_ROWS][MATRIX_COLS] = {

#ifdef CAPS_LOCK_STATUS
void led_update_ports(led_t led_state) {
ML_LED_6(led_state.caps_lock);
STATUS_LED_6(led_state.caps_lock);
}
#endif

Expand All @@ -345,12 +348,12 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
if (keyboard_config.led_level) {
layer_state_set_kb(layer_state);
} else {
ML_LED_1(false);
ML_LED_2(false);
ML_LED_3(false);
ML_LED_4(false);
ML_LED_5(false);
ML_LED_6(false);
STATUS_LED_1(false);
STATUS_LED_2(false);
STATUS_LED_3(false);
STATUS_LED_4(false);
STATUS_LED_5(false);
STATUS_LED_6(false);
}
}
break;
Expand Down
12 changes: 6 additions & 6 deletions keyboards/zsa/moonlander/moonlander.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ extern bool mcp23018_leds[];

#define MCP23018_DEFAULT_ADDRESS 0b0100000

#define ML_LED_1(status) gpio_write_pin(B5, (bool)status)
#define ML_LED_2(status) gpio_write_pin(B4, (bool)status)
#define ML_LED_3(status) gpio_write_pin(B3, (bool)status)
#define STATUS_LED_1(status) gpio_write_pin(B5, (bool)status)
#define STATUS_LED_2(status) gpio_write_pin(B4, (bool)status)
#define STATUS_LED_3(status) gpio_write_pin(B3, (bool)status)

#define ML_LED_4(status) mcp23018_leds[0] = (bool)status
#define ML_LED_5(status) mcp23018_leds[1] = (bool)status
#define ML_LED_6(status) mcp23018_leds[2] = (bool)status
#define STATUS_LED_4(status) mcp23018_leds[0] = (bool)status
#define STATUS_LED_5(status) mcp23018_leds[1] = (bool)status
#define STATUS_LED_6(status) mcp23018_leds[2] = (bool)status

enum planck_ez_keycodes {
TOGGLE_LAYER_COLOR = QK_KB_0,
Expand Down
14 changes: 9 additions & 5 deletions keyboards/zsa/voyager/voyager.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,20 @@ layer_state_t layer_state_set_kb(layer_state_t state) {
#if !defined(VOYAGER_USER_LEDS)
state = layer_state_set_user(state);
if (is_launching || !keyboard_config.led_level) return state;

#ifdef ORYX_ENABLE
if (rawhid_state.status_led_control) return state;
#endif
uint8_t layer = get_highest_layer(state);

STATUS_LED_1(layer & (1 << 0));
STATUS_LED_2(layer & (1 << 1));
STATUS_LED_3(layer & (1 << 2));
if(!rawhid_state.status_led_control) {
STATUS_LED_1(layer & (1 << 0));
STATUS_LED_2(layer & (1 << 1));
STATUS_LED_3(layer & (1 << 2));

# if !defined(CAPS_LOCK_STATUS)
STATUS_LED_4(layer & (1 << 3));
STATUS_LED_4(layer & (1 << 3));
# endif
}
#endif
#ifdef ORYX_ENABLE
layer_state_set_oryx(state);
Expand Down

0 comments on commit 27a59c8

Please sign in to comment.