adafruit / Adafruit_NeoPixel_ZeroDMA

DMA-based NeoPixel library for SAMD microcontrollers (Feather M0, M4, Arduino Zero, etc.)
MIT License
39 stars 13 forks source link

Disable and reenable output pin #28

Closed Alloc86 closed 1 month ago

Alloc86 commented 1 month ago

Hi,

I was trying to disable the output pin while the pixels are not used so I can also disconnect pixel power for power saving. When using the basic non-DMA pixel library this works fine, but when using the ZeroDMA one it seems like reenabling the pin does not suffice to get output back working.

For testing I simply used the strandtest and added the following to the end of the loop function:

  strip.clear();
  strip.show();
  delay(1500);
  pinMode(NEO_PIN, INPUT);
  delay(2000);
  pinMode(NEO_PIN, OUTPUT);

The first delay was to make sure it had enough time to actually write the cleared data, second delay is to actually simulate the time when the output is not required.

I see this library is constantly outputting the data to the pixels, but is there any way to still temporarily disable the output pin to save on power?

Cheers, Chris

Alloc86 commented 1 month ago

Was a "me-issue" of course :) Missed that pinMode not only changes the INEN bit in PINCFG but completely overwrites the reg, thus clearing the PMUXEN bit. Now using pinMode to disable the output and pinPeripheral to reenable and it works :) Great library, thanks!