espruino / Espruino

The Espruino JavaScript interpreter - Official Repo
http://www.espruino.com/
Other
2.73k stars 741 forks source link

Using different pins for neopixel on ESP32 does not work correct #2505

Closed MaBecker closed 2 weeks ago

MaBecker commented 1 month ago

Test Code:

np = require("neopixel");
// set first five neopixel blue on pin D16 - ok
np.write(D16,[0,0,40, 0,0,40, 0,0,40, 0,0,40, 0,0,40]);
// set first  five neopixel green on pin D17 - changes pixel on D16 to green too - err
np.write(D17,[40,0,0, 40,0,0, 40,0,0, 40,0,0, 40,0,0])

The neopixel implementation does not detach pins which is causing this effect.

First approche to fix this:

int neopixelConfiguredGPIO = -1;
....
void neopixel_init(int gpioNum){
....
  if (neopixelConfiguredGPIO != gpioNum) {
    // detach last pin 
    if (neopixelConfiguredGPIO)
      gpio_matrix_out(neopixelConfiguredGPIO,0,0,0);
    neopixelConfiguredGPIO = gpioNum;
  }    
  rmt_set_pin((rmt_channel_t)RMTCHANNEL, RMT_MODE_TX, (gpio_num_t)gpioNum);
....
}

Same behavior for all ESP-IDF versions. Needs more testing before sending a pr.

MaBecker commented 3 weeks ago

pr #2514