@@ -180,23 +180,19 @@ esp_err_t rmt_new_led_strip_encoder(const led_strip_encoder_config_t *config, rm
180180{
181181 esp_err_t ret = ESP_OK ;
182182 rmt_led_strip_encoder_t * led_encoder = NULL ;
183- if (!(config && ret_encoder )) {
184- return ESP_ERR_INVALID_ARG ;
185- }
183+ if (!(config && ret_encoder )) return ESP_ERR_INVALID_ARG ;
186184
187185 led_encoder = rmt_alloc_encoder_mem (sizeof (rmt_led_strip_encoder_t ));
188- if (!led_encoder ) {
189- return ESP_ERR_NO_MEM ;
190- }
186+ if (!led_encoder ) return ESP_ERR_NO_MEM ;
187+
191188 led_encoder -> base .encode = rmt_encode_led_strip ;
192189 led_encoder -> base .del = rmt_del_led_strip_encoder ;
193190 led_encoder -> base .reset = rmt_led_strip_encoder_reset ;
194191
195192 uint32_t bit0_duration0 = 0 ;
196193 uint32_t bit0_duration1 = 0 ;
197-
198194 uint32_t bit1_duration0 = 0 ;
199- uint32_t bit2_duration1 = 0 ;
195+ uint32_t bit1_duration1 = 0 ;
200196
201197 if (config -> bit0_duration0 < 0 ) bit0_duration0 = (uint32_t )(- config -> bit0_duration0 );
202198 else bit0_duration0 = (uint32_t )config -> bit0_duration0 ;
@@ -223,19 +219,16 @@ esp_err_t rmt_new_led_strip_encoder(const led_strip_encoder_config_t *config, rm
223219 .level1 = config -> bit1_duration1 < 0 ? 0 : 1 ,
224220 .duration1 = bit1_duration1 * config -> resolution / 1000000000 ,
225221 },
226- .flags .msb_first = 1 // WS2812 transfer bit order: G7...G0R7...R0B7...B0
222+ .flags .msb_first = 1
227223 };
228224
229225
230- ret = rmt_new_bytes_encoder (& bytes_encoder_config , & led_encoder -> bytes_encoder )
231- if (err != ESP_OK ) {
232- goto err ;
233- }
226+ ret = rmt_new_bytes_encoder (& bytes_encoder_config , & led_encoder -> bytes_encoder );
227+ if (ret != ESP_OK ) goto err ;
228+
234229 rmt_copy_encoder_config_t copy_encoder_config = {};
235- ret = rmt_new_copy_encoder (& copy_encoder_config , & led_encoder -> copy_encoder )
236- if (err != ESP_OK ) {
237- goto err ;
238- }
230+ ret = rmt_new_copy_encoder (& copy_encoder_config , & led_encoder -> copy_encoder );
231+ if (ret != ESP_OK ) goto err ;
239232
240233 uint32_t reset_duration ;
241234
@@ -262,10 +255,11 @@ esp_err_t rmt_new_led_strip_encoder(const led_strip_encoder_config_t *config, rm
262255 free (led_encoder );
263256 }
264257 return ret ;
258+ }
265259
266260
267261// Use the reserved RMT channel to stream high/low data on the specified pin.
268- static void machine_bitstream_high_low_rmt (mp_hal_pin_obj_t pin , uint32_t * timing_ns , const uint8_t * buf , size_t len , uint8_t channel_id ) {
262+ void machine_bitstream_high_low_rmt (mp_hal_pin_obj_t pin , uint32_t * timing_ns , const uint8_t * buf , size_t len , uint8_t channel_id ) {
269263
270264 ((void )channel_id );
271265
@@ -295,11 +289,11 @@ static void machine_bitstream_high_low_rmt(mp_hal_pin_obj_t pin, uint32_t *timin
295289 .loop_count = 0 , // no transfer loop
296290 };
297291
298- check_esp_err (rmt_transmit (channel_handle , encoder_handle , buf , len , & tx_config ))) ;
292+ check_esp_err (rmt_transmit (channel_handle , encoder_handle , buf , len , & tx_config ));
299293
300294 // Wait 50% longer than we expect (if every bit takes the maximum time).
301295 uint32_t timeout_ms = (3 * len / 2 ) * (1 + (8 * MAX (timing_ns [0 ] + timing_ns [1 ], timing_ns [2 ] + timing_ns [3 ])) / 1000 );
302- check_esp_err (rmt_tx_wait_all_done (config . channel , pdMS_TO_TICKS (timeout_ms )));
296+ check_esp_err (rmt_tx_wait_all_done (channel_handle , pdMS_TO_TICKS (timeout_ms )));
303297
304298 // Uninstall the driver.
305299 check_esp_err (rmt_del_led_strip_encoder (encoder_handle ));
0 commit comments