mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-03 09:49:32 +02:00
implement changes from cefb980
This commit is contained in:
parent
29acf84a09
commit
ea5f2e9614
1 changed files with 15 additions and 21 deletions
|
@ -184,21 +184,13 @@
|
||||||
*item_num = num;
|
*item_num = num;
|
||||||
}
|
}
|
||||||
|
|
||||||
void espShow(uint8_t pin, uint8_t *pixels, uint32_t numBytes, boolean is800KHz) {
|
static bool rmt_initialized = false;
|
||||||
// Reserve channel
|
static bool rmt_adapter_initialized = false;
|
||||||
rmt_channel_t channel = ADAFRUIT_RMT_CHANNEL_MAX;
|
|
||||||
for (size_t i = 0; i < ADAFRUIT_RMT_CHANNEL_MAX; i++) {
|
|
||||||
if (!rmt_reserved_channels[i]) {
|
|
||||||
rmt_reserved_channels[i] = true;
|
|
||||||
channel = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (channel == ADAFRUIT_RMT_CHANNEL_MAX) {
|
|
||||||
// Ran out of channels!
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
void espShow(uint8_t pin, uint8_t *pixels, uint32_t numBytes, boolean is800KHz) {
|
||||||
|
if (rmt_initialized == false) {
|
||||||
|
// Reserve channel
|
||||||
|
rmt_channel_t channel = 0;
|
||||||
#if defined(HAS_ESP_IDF_4)
|
#if defined(HAS_ESP_IDF_4)
|
||||||
rmt_config_t config = RMT_DEFAULT_CONFIG_TX(pin, channel);
|
rmt_config_t config = RMT_DEFAULT_CONFIG_TX(pin, channel);
|
||||||
config.clk_div = 2;
|
config.clk_div = 2;
|
||||||
|
@ -258,17 +250,19 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize automatic timing translator
|
// Initialize automatic timing translator
|
||||||
rmt_translator_init(config.channel, ws2812_rmt_adapter);
|
rmt_translator_init(0, ws2812_rmt_adapter);
|
||||||
|
rmt_initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Write and wait to finish
|
// Write and wait to finish
|
||||||
rmt_write_sample(config.channel, pixels, (size_t)numBytes, true);
|
rmt_write_sample(0, pixels, (size_t)numBytes, false);
|
||||||
rmt_wait_tx_done(config.channel, pdMS_TO_TICKS(100));
|
//rmt_wait_tx_done(config.channel, pdMS_TO_TICKS(100));
|
||||||
|
|
||||||
// Free channel again
|
// Free channel again
|
||||||
rmt_driver_uninstall(config.channel);
|
//rmt_driver_uninstall(config.channel);
|
||||||
rmt_reserved_channels[channel] = false;
|
//rmt_reserved_channels[channel] = false;
|
||||||
|
|
||||||
gpio_set_direction(pin, GPIO_MODE_OUTPUT);
|
//gpio_set_direction(pin, GPIO_MODE_OUTPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ifndef IDF5
|
#endif // ifndef IDF5
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue