Skip to content

Commit ed6e95d

Browse files
committed
feat(board): use existing led API
1 parent 349b11d commit ed6e95d

File tree

1 file changed

+4
-42
lines changed

1 file changed

+4
-42
lines changed

variants/sensebox_eye/variant.cpp

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,12 @@
11
#include "esp32-hal-gpio.h"
22
#include "pins_arduino.h"
3-
#include "driver/rmt_tx.h"
43

54
extern "C" {
65

7-
void blinkLED(uint8_t color[3], rmt_channel_handle_t led_chan, rmt_encoder_handle_t ws2812_encoder, rmt_transmit_config_t tx_config) {
8-
ESP_ERROR_CHECK(rmt_transmit(led_chan, ws2812_encoder, color, sizeof(color), &tx_config));
9-
rmt_tx_wait_all_done(led_chan, portMAX_DELAY);
10-
11-
// Wait a moment
12-
delay(50);
13-
14-
// Turn LED off
15-
uint8_t pixel_off[3] = { 0x00, 0x00, 0x00 };
16-
ESP_ERROR_CHECK(rmt_transmit(led_chan, ws2812_encoder, pixel_off, sizeof(pixel_off), &tx_config));
17-
rmt_tx_wait_all_done(led_chan, portMAX_DELAY);
18-
}
19-
206
void initVariant(void) {
21-
rmt_channel_handle_t led_chan = NULL;
22-
rmt_tx_channel_config_t tx_chan_config = {};
23-
tx_chan_config.clk_src = RMT_CLK_SRC_DEFAULT;
24-
tx_chan_config.resolution_hz = 10 * 1000 * 1000;
25-
tx_chan_config.mem_block_symbols = 64;
26-
tx_chan_config.trans_queue_depth = 4;
27-
tx_chan_config.gpio_num = (gpio_num_t)PIN_LED;
28-
tx_chan_config.flags.invert_out = false;
29-
tx_chan_config.flags.with_dma = false;
30-
ESP_ERROR_CHECK(rmt_new_tx_channel(&tx_chan_config, &led_chan));
31-
32-
// WS2812 encoder config (available in `esp-rmt`)
33-
rmt_encoder_handle_t ws2812_encoder = NULL;
34-
rmt_bytes_encoder_config_t bytes_encoder_config = {
35-
.bit0 = { .duration0 = 4, .level0 = 1, .duration1 = 9, .level1 = 0 },
36-
.bit1 = { .duration0 = 8, .level0 = 1, .duration1 = 5, .level1 = 0 },
37-
.flags = { .msb_first = true }
38-
};
39-
ESP_ERROR_CHECK(rmt_new_bytes_encoder(&bytes_encoder_config, &ws2812_encoder));
40-
41-
ESP_ERROR_CHECK(rmt_enable(led_chan));
42-
43-
rmt_transmit_config_t tx_config = {
44-
.loop_count = 0
45-
};
46-
47-
uint8_t pixel[3] = { 0x10, 0x00, 0x00 }; // green
48-
blinkLED(pixel, led_chan, ws2812_encoder, tx_config);
7+
// blink the RGB LED
8+
rgbLedWrite(PIN_LED, 0x00, 0x10, 0x00); // green
9+
delay(20);
10+
rgbLedWrite(PIN_LED, 0x00, 0x00, 0x00); // off
4911
}
5012
}

0 commit comments

Comments
 (0)