void runRmtTest() { ESP_LOGD(tag, ">> runRmtTest"); rmt_config_t config; config.rmt_mode = RMT_MODE_TX; config.channel = RMT_CHANNEL_0; config.gpio_num = 21; config.mem_block_num = 1; config.tx_config.loop_en = 0; config.tx_config.carrier_en = 0; config.tx_config.idle_output_en = 1; config.tx_config.idle_level = 0; config.tx_config.carrier_duty_percent = 50; config.tx_config.carrier_freq_hz = 10000; config.tx_config.carrier_level = 1; config.clk_div = 80; ESP_ERROR_CHECK(rmt_config(&config)); ESP_ERROR_CHECK(rmt_driver_install(config.channel, 0, 0)); dumpStatus(config.channel); rmt_item32_t items[3]; items[0].duration0 = 10000; items[0].level0 = 1; items[0].duration1 = 10000; items[0].level1 = 0; items[1].duration0 = 10000; items[1].level0 = 1; items[1].duration1 = 5000; items[1].level1 = 0; items[2].duration0 = 0; items[2].level0 = 1; items[2].duration1 = 0; items[2].level1 = 0; while(1) { ESP_ERROR_CHECK(rmt_write_items(config.channel, items, 3, /* Number of items */ 1 /* wait till done */)); vTaskDelay(1000/portTICK_PERIOD_MS); } ESP_LOGD(tag, "<< runRmtTest"); }
void WS2812::show() { uint32_t i,j; rmt_item32_t *pCurrentItem = this->items; for (i=0; i<this->pixelCount; i++) { uint32_t currentPixel = this->pixels[i].red | (this->pixels[i].green << 8) | (this->pixels[i].blue << 16); for (j=0; j<24; j++) { if (currentPixel & 1<<j) { setItem1(pCurrentItem); } else { setItem0(pCurrentItem); } pCurrentItem++; } } // Show the pixels. rmt_write_items(this->channel, this->items, this->pixelCount*24, 1 /* wait till done */); } // show