Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions main/vendor/led/led_strip_rmt_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

// this file has been fucked around in - deki
// file has been fixed -RMT channel errors on reinit were broken - Mimsseey

#include "driver/rmt_tx.h"
#include "esp_check.h"
Expand Down Expand Up @@ -33,6 +34,7 @@ typedef struct {
rmt_encoder_handle_t strip_encoder;
uint32_t strip_len;
uint8_t bytes_per_pixel;
bool channel_enabled;
uint8_t pixel_buf[];
} led_strip_rmt_obj;

Expand Down Expand Up @@ -91,14 +93,13 @@ static esp_err_t led_strip_rmt_refresh(led_strip_t *strip) {
// Silent error handling for all operations
esp_err_t err;

// Ensure RMT channel is enabled (enable only first time)
static bool channel_enabled = false;
if (!channel_enabled) {
// Ensure RMT channel is enabled (enable only first time per instance)
if (!rmt_strip->channel_enabled) {
err = rmt_enable(rmt_strip->rmt_chan);
if (err != ESP_OK) {
return err;
}
channel_enabled = true;
rmt_strip->channel_enabled = true;
}

// Transmit
Expand Down Expand Up @@ -131,9 +132,10 @@ static esp_err_t led_strip_rmt_clear(led_strip_t *strip) {

static esp_err_t led_strip_rmt_del(led_strip_t *strip) {
led_strip_rmt_obj *rmt_strip = __containerof(strip, led_strip_rmt_obj, base);
esp_err_t disable_err = rmt_disable(rmt_strip->rmt_chan);
if (disable_err != ESP_OK && disable_err != ESP_ERR_INVALID_STATE) {
ESP_LOGW(TAG, "disable RMT channel failed: %d", disable_err);
// RMT channel must be disabled (back to init state) before deletion
if (rmt_strip->channel_enabled) {
rmt_disable(rmt_strip->rmt_chan);
rmt_strip->channel_enabled = false;
}
ESP_RETURN_ON_ERROR(rmt_del_channel(rmt_strip->rmt_chan), TAG,
"delete RMT channel failed");
Expand Down