Skip to content

Commit

Permalink
Cleanup leds
Browse files Browse the repository at this point in the history
  • Loading branch information
drashna committed Nov 25, 2024
1 parent f616fb6 commit d386e81
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
25 changes: 13 additions & 12 deletions keyboards/zsa/ergodox_ez/ergodox_ez.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

#include "ergodox_ez.h"
#include "bootmagic.h"
#include "gpio.h"

keyboard_config_t keyboard_config;

__attribute__((weak)) void keyboard_post_init_sub(void) {
setPinOutput(ERGODOX_LED_1_PIN);
setPinOutput(ERGODOX_LED_2_PIN);
setPinOutput(ERGODOX_LED_3_PIN);
gpio_set_pin_output(ERGODOX_LED_1_PIN);
gpio_set_pin_output(ERGODOX_LED_2_PIN);
gpio_set_pin_output(ERGODOX_LED_3_PIN);
}

void keyboard_post_init_kb(void) {
keyboard_post_init_sub();
#ifdef ERGODOX_LED_SHUTOFF_PIN
setPinOutput(ERGODOX_LED_SHUTOFF_PIN);
gpio_set_pin_output(ERGODOX_LED_SHUTOFF_PIN);
#endif

keyboard_config.raw = eeconfig_read_kb();
Expand All @@ -49,25 +50,25 @@ void keyboard_post_init_kb(void) {

void ergodox_board_led_on(void) {
#ifdef ERGODOX_LED_SHUTOFF_PIN
writePinHigh(ERGODOX_LED_SHUTOFF_PIN);
gpio_write_pin_high(ERGODOX_LED_SHUTOFF_PIN);
#endif
}

__attribute__((weak)) void ergodox_right_led_1_on(void) {
writePinHigh(ERGODOX_LED_1_PIN);
gpio_write_pin_high(ERGODOX_LED_1_PIN);
}

__attribute__((weak)) void ergodox_right_led_2_on(void) {
writePinHigh(ERGODOX_LED_2_PIN);
gpio_write_pin_high(ERGODOX_LED_2_PIN);
}

__attribute__((weak)) void ergodox_right_led_3_on(void) {
writePinHigh(ERGODOX_LED_3_PIN);
gpio_write_pin_high(ERGODOX_LED_3_PIN);
}

void ergodox_board_led_off(void) {
#ifdef ERGODOX_LED_SHUTOFF_PIN
writePinLow(ERGODOX_LED_SHUTOFF_PIN);
gpio_write_pin_low(ERGODOX_LED_SHUTOFF_PIN);
#else
ergodox_right_led_1_off();
ergodox_right_led_2_off();
Expand All @@ -76,15 +77,15 @@ void ergodox_board_led_off(void) {
}

__attribute__((weak)) void ergodox_right_led_1_off(void) {
setPinInput(ERGODOX_LED_1_PIN);
gpio_write_pin_low(ERGODOX_LED_1_PIN);
}

__attribute__((weak)) void ergodox_right_led_2_off(void) {
setPinInput(ERGODOX_LED_2_PIN);
gpio_write_pin_low(ERGODOX_LED_2_PIN);
}

__attribute__((weak)) void ergodox_right_led_3_off(void) {
setPinInput(ERGODOX_LED_3_PIN);
gpio_write_pin_low(ERGODOX_LED_3_PIN);
}

void ergodox_right_led_on(uint8_t led) {
Expand Down
14 changes: 5 additions & 9 deletions keyboards/zsa/ergodox_ez/m32u4/m32u4.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,14 @@ void keyboard_post_init_sub(void) {
TCCR1B = 0b00001001; // set and configure fast PWM

// (tied to Vcc for hardware convenience)
setPinInput(B4);
gpio_set_pin_input(B4);

// unused pins - C7, D4, D5, E6
// set as input with internal pull-up enabled
setPinInputHigh(C7);
setPinInputHigh(D4);
setPinInputHigh(D5);
setPinInputHigh(E6);

setPinOutput(ERGODOX_LED_1_PIN);
setPinOutput(ERGODOX_LED_2_PIN);
setPinOutput(ERGODOX_LED_3_PIN);
gpio_set_pin_input_high(C7);
gpio_set_pin_input_high(D4);
gpio_set_pin_input_high(D5);
gpio_set_pin_input_high(E6);
}

#ifdef RGB_MATRIX_ENABLE
Expand Down

0 comments on commit d386e81

Please sign in to comment.