rmt helper to function

This commit is contained in:
Wizmo2
2023-09-28 07:34:58 -04:00
parent 60bd591bf8
commit f33cb569ce
5 changed files with 6 additions and 6 deletions

View File

@@ -97,7 +97,7 @@ void led_vu_init()
led_strip_config.led_strip_working = heap_caps_malloc(strip.length * sizeof(struct led_color_t), MALLOC_CAP_8BIT); led_strip_config.led_strip_working = heap_caps_malloc(strip.length * sizeof(struct led_color_t), MALLOC_CAP_8BIT);
led_strip_config.led_strip_showing = heap_caps_malloc(strip.length * sizeof(struct led_color_t), MALLOC_CAP_8BIT); led_strip_config.led_strip_showing = heap_caps_malloc(strip.length * sizeof(struct led_color_t), MALLOC_CAP_8BIT);
led_strip_config.gpio = strip.gpio; led_strip_config.gpio = strip.gpio;
led_strip_config.rmt_channel = RMT_NEXT_TX_CHANNEL; led_strip_config.rmt_channel = RMT_NEXT_TX_CHANNEL();
// initialize driver // initialize driver
bool led_init_ok = led_strip_init(&led_strip_config); bool led_init_ok = led_strip_init(&led_strip_config);

View File

@@ -13,8 +13,8 @@
#define I2C_SYSTEM_PORT 1 #define I2C_SYSTEM_PORT 1
#define SPI_SYSTEM_HOST SPI2_HOST #define SPI_SYSTEM_HOST SPI2_HOST
#define RMT_NEXT_TX_CHANNEL rmt_system_base_tx_channel++; #define RMT_NEXT_TX_CHANNEL() rmt_system_base_tx_channel++;
#define RMT_NEXT_RX_CHANNEL rmt_system_base_rx_channel--; #define RMT_NEXT_RX_CHANNEL() rmt_system_base_rx_channel--;
extern int i2c_system_port; extern int i2c_system_port;
extern int i2c_system_speed; extern int i2c_system_speed;

View File

@@ -491,7 +491,7 @@ int8_t infrared_gpio(void) {
* *
*/ */
void infrared_init(RingbufHandle_t *rb, int gpio, infrared_mode_t mode) { void infrared_init(RingbufHandle_t *rb, int gpio, infrared_mode_t mode) {
int rmt_channel = RMT_NEXT_RX_CHANNEL; int rmt_channel = RMT_NEXT_RX_CHANNEL();
rmt_config_t rmt_rx_config = RMT_DEFAULT_CONFIG_RX(gpio, rmt_channel); rmt_config_t rmt_rx_config = RMT_DEFAULT_CONFIG_RX(gpio, rmt_channel);
rmt_config(&rmt_rx_config); rmt_config(&rmt_rx_config);
rmt_driver_install(rmt_rx_config.channel, 1000, 0); rmt_driver_install(rmt_rx_config.channel, 1000, 0);

View File

@@ -241,7 +241,7 @@ bool led_config(int idx, gpio_num_t gpio, int color, int bright, led_type_t type
for (const struct rmt_led_param_s *p = rmt_led_param; !leds[idx].rmt && p->type >= 0; p++) if (p->type == type) leds[idx].rmt = p; for (const struct rmt_led_param_s *p = rmt_led_param; !leds[idx].rmt && p->type >= 0; p++) if (p->type == type) leds[idx].rmt = p;
if (!leds[idx].rmt) return false; if (!leds[idx].rmt) return false;
if (led_rmt_channel < 0) led_rmt_channel = RMT_NEXT_TX_CHANNEL; if (led_rmt_channel < 0) led_rmt_channel = RMT_NEXT_TX_CHANNEL();
leds[idx].channel = led_rmt_channel; leds[idx].channel = led_rmt_channel;
leds[idx].bright = bright > 0 ? bright : 100; leds[idx].bright = bright > 0 ? bright : 100;

View File

@@ -95,7 +95,7 @@ void setup_rmt_data_buffer(struct led_state new_state);
void ws2812_control_init(void) void ws2812_control_init(void)
{ {
rmt_channel = RMT_NEXT_TX_CHANNEL; rmt_channel = RMT_NEXT_TX_CHANNEL();
rmt_config_t config; rmt_config_t config;
config.rmt_mode = RMT_MODE_TX; config.rmt_mode = RMT_MODE_TX;
config.channel = rmt_channel; config.channel = rmt_channel;