Skip to content

Commit

Permalink
Merge pull request #2514 from MaBecker/master
Browse files Browse the repository at this point in the history
esp32 handle multiple pins
  • Loading branch information
gfwilliams committed Jun 17, 2024
2 parents 1ec70db + ca9b12f commit 6f91a26
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions targets/esp32/esp32_neopixel.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,9 @@ static rmtPulsePair neopixel_bits[2]= {
{{PULSE_T1H,1,PULSE_T1L,0}}
};

#if ESP_IDF_VERSION_MAJOR>=4

int neopixelConfiguredGPIO = -1;

#if ESP_IDF_VERSION_MAJOR>=4
/**
* @brief Convert RGB data to RMT format.
*
Expand Down Expand Up @@ -168,8 +167,12 @@ void neopixel_handleInterrupt(void *arg){
void neopixel_init(int gpioNum){
#if ESP_IDF_VERSION_MAJOR>=4
if (neopixelConfiguredGPIO != gpioNum) {
if (neopixelConfiguredGPIO)
if (neopixelConfiguredGPIO) {
rmt_driver_uninstall(RMTCHANNEL);
if (neopixelConfiguredGPIO != -1) {
gpio_matrix_out(neopixelConfiguredGPIO,0,0,0);
}
}
neopixelConfiguredGPIO = gpioNum;
rmt_config_t config = RMT_DEFAULT_CONFIG_TX(gpioNum, RMTCHANNEL);
// set counter clock to 40MHz
Expand All @@ -194,6 +197,14 @@ void neopixel_init(int gpioNum){
// PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[gpioNum], 2);
// gpio_matrix_out(gpioNum, RMT_SIG_OUT0_IDX + RMTCHANNEL, 0, 0);
// gpio_set_direction(gpioNum, GPIO_MODE_OUTPUT);
if (neopixelConfiguredGPIO != gpioNum) {
// detach last pin
if (neopixelConfiguredGPIO != -1) {
gpio_matrix_out(neopixelConfiguredGPIO,0,0,0);
}
neopixelConfiguredGPIO = gpioNum;
}
//gpio_matrix_out(gpioNum, RMT_SIG_OUT0_IDX + RMTCHANNEL, 0, 0);
rmt_set_pin((rmt_channel_t)RMTCHANNEL, RMT_MODE_TX, (gpio_num_t)gpioNum);

neopixel_initRMTChannel(RMTCHANNEL);
Expand Down

0 comments on commit 6f91a26

Please sign in to comment.