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 42
42
43
43
#include "shared-bindings/neopixel_write/__init__.h"
44
44
45
+ #include "esp_clk_tree.h"
45
46
#include "py/mphal.h"
46
47
#include "py/runtime.h"
47
48
@@ -61,10 +62,14 @@ static uint64_t next_start_raw_ticks = 0;
61
62
62
63
void common_hal_neopixel_write (const digitalio_digitalinout_obj_t * digitalinout , uint8_t * pixels , uint32_t numBytes ) {
63
64
// 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 );
64
69
rmt_tx_channel_config_t config = {
65
70
.gpio_num = digitalinout -> pin -> number ,
66
71
.clk_src = RMT_CLK_SRC_DEFAULT ,
67
- .resolution_hz = 40000000 ,
72
+ .resolution_hz = clock_speed ,
68
73
.trans_queue_depth = 1 ,
69
74
};
70
75
@@ -81,7 +86,7 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t *digitalinout,
81
86
}
82
87
CHECK_ESP_RESULT (result );
83
88
84
- size_t ns_per_tick = 1e9 / 40000000 ;
89
+ size_t ns_per_tick = 1e9 / clock_speed ;
85
90
uint16_t ws2812_t0h_ticks = WS2812_T0H_NS / ns_per_tick ;
86
91
uint16_t ws2812_t0l_ticks = WS2812_T0L_NS / ns_per_tick ;
87
92
uint16_t ws2812_t1h_ticks = WS2812_T1H_NS / ns_per_tick ;
You can’t perform that action at this time.
0 commit comments