File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
ports/espressif/common-hal/neopixel_write Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change 4242
4343#include "shared-bindings/neopixel_write/__init__.h"
4444
45+ #include "esp_clk_tree.h"
4546#include "py/mphal.h"
4647#include "py/runtime.h"
4748
@@ -61,10 +62,14 @@ static uint64_t next_start_raw_ticks = 0;
6162
6263void common_hal_neopixel_write (const digitalio_digitalinout_obj_t * digitalinout , uint8_t * pixels , uint32_t numBytes ) {
6364 // Reserve channel
65+ uint32_t clock_speed ;
66+ esp_clk_tree_src_get_freq_hz (RMT_CLK_SRC_DEFAULT ,
67+ ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED ,
68+ & clock_speed );
6469 rmt_tx_channel_config_t config = {
6570 .gpio_num = digitalinout -> pin -> number ,
6671 .clk_src = RMT_CLK_SRC_DEFAULT ,
67- .resolution_hz = 40000000 ,
72+ .resolution_hz = clock_speed ,
6873 .trans_queue_depth = 1 ,
6974 };
7075
@@ -81,7 +86,7 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t *digitalinout,
8186 }
8287 CHECK_ESP_RESULT (result );
8388
84- size_t ns_per_tick = 1e9 / 40000000 ;
89+ size_t ns_per_tick = 1e9 / clock_speed ;
8590 uint16_t ws2812_t0h_ticks = WS2812_T0H_NS / ns_per_tick ;
8691 uint16_t ws2812_t0l_ticks = WS2812_T0L_NS / ns_per_tick ;
8792 uint16_t ws2812_t1h_ticks = WS2812_T1H_NS / ns_per_tick ;
You can’t perform that action at this time.
0 commit comments