support simple LEDs on ESP32-S2-based board

This commit is contained in:
King Kévin 2022-07-23 12:42:08 +02:00
parent b8bd21f11e
commit ed6ad9f9ca
1 changed files with 12 additions and 0 deletions

View File

@ -74,6 +74,15 @@ void board_init(void)
strip->clear(strip, 100); // off led
#endif
#ifdef LED_PIN
gpio_reset_pin(LED_PIN);
#if LED_ACTIVE
gpio_set_direction(LED_PIN, GPIO_MODE_OUTPUT);
#else
gpio_set_direction(LED_PIN, GPIO_MODE_OUTPUT_OD);
#endif
#endif
// Button
esp_rom_gpio_pad_select_gpio(BUTTON_PIN);
gpio_set_direction(BUTTON_PIN, GPIO_MODE_INPUT);
@ -128,6 +137,9 @@ void board_led_write(bool state)
strip->set_pixel(strip, 0, (state ? 0x88 : 0x00), 0x00, 0x00);
strip->refresh(strip, 100);
#endif
#ifdef LED_PIN
gpio_set_level(LED_PIN, state ? LED_ACTIVE : !LED_ACTIVE);
#endif
}
// Get the current state of button