// // Created by erki on 26/06/23. // #include "app_led.hpp" #include "led_strip.h" namespace { led_strip_handle_t s_strip; bool s_tx_on = false; bool s_rx_on = false; void s_updateStrip() { const int red = s_tx_on ? 10 : 0; const int blue = s_rx_on ? 10 : 0; led_strip_set_pixel(s_strip, 0, red, 10, blue); led_strip_refresh(s_strip); } } namespace Led { void setupLed(const gpio_num_t gpio) { led_strip_config_t config = { .strip_gpio_num = gpio, .max_leds = 1, .led_pixel_format = LED_PIXEL_FORMAT_GRB, .led_model = LED_MODEL_WS2812, .flags = { 0 } }; led_strip_rmt_config_t rmt_config = { .clk_src = RMT_CLK_SRC_DEFAULT, .resolution_hz = 10 * 1000 * 1000, .mem_block_symbols = 0, .flags = { 0 } }; ESP_ERROR_CHECK(led_strip_new_rmt_device(&config, &rmt_config, &s_strip)); led_strip_clear(s_strip); s_updateStrip(); } void flashRx() { s_rx_on = !s_rx_on; s_updateStrip(); } void flashTx() { s_tx_on = !s_tx_on; s_updateStrip(); } }