Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add device independent wrappers to non-parallel I2S methods #869

Open
blazoncek opened this issue Jan 12, 2025 · 1 comment
Open

Add device independent wrappers to non-parallel I2S methods #869

blazoncek opened this issue Jan 12, 2025 · 1 comment

Comments

@blazoncek
Copy link

Is your feature request related to a problem? Please describe.
For WLED (where multiple ESP devices are supported) I added a wrapper typedef methods to simplify coding effort while supporting single/non-parallel I2S for those devices. Similar to what is done for parallel I2S methods using X8xxxxxxxMethod or X16xxxxxxMethod.
It would be nice to have similar wrappers for single I2S methods.

Describe the solution you'd like
I constructed:

#if defined(CONFIG_IDF_TARGET_ESP32S3)
  // S3 will always use LCD parallel output
  typedef X8Ws2812xMethod X1Ws2812xMethod;
  typedef X8Sk6812Method X1Sk6812Method;
  typedef X8400KbpsMethod X1400KbpsMethod;
  typedef X8800KbpsMethod X1800KbpsMethod;
  typedef X8Tm1814Method X1Tm1814Method;
  typedef X8Tm1829Method X1Tm1829Method;
  typedef X8Apa106Method X1Apa106Method;
  typedef X8Ws2805Method X1Ws2805Method;
  typedef X8Tm1914Method X1Tm1914Method;
#elif defined(CONFIG_IDF_TARGET_ESP32S2)
  // S2 will use I2S0
  typedef NeoEsp32I2s0Ws2812xMethod X1Ws2812xMethod;
  typedef NeoEsp32I2s0Sk6812Method X1Sk6812Method;
  typedef NeoEsp32I2s0400KbpsMethod X1400KbpsMethod;
  typedef NeoEsp32I2s0800KbpsMethod X1800KbpsMethod;
  typedef NeoEsp32I2s0Tm1814Method X1Tm1814Method;
  typedef NeoEsp32I2s0Tm1829Method X1Tm1829Method;
  typedef NeoEsp32I2s0Apa106Method X1Apa106Method;
  typedef NeoEsp32I2s0Ws2805Method X1Ws2805Method;
  typedef NeoEsp32I2s0Tm1914Method X1Tm1914Method;
#elif !defined(CONFIG_IDF_TARGET_ESP32C3)
  // regular ESP32 will use I2S1
  typedef NeoEsp32I2s1Ws2812xMethod X1Ws2812xMethod;
  typedef NeoEsp32I2s1Sk6812Method X1Sk6812Method;
  typedef NeoEsp32I2s1400KbpsMethod X1400KbpsMethod;
  typedef NeoEsp32I2s1800KbpsMethod X1800KbpsMethod;
  typedef NeoEsp32I2s1Tm1814Method X1Tm1814Method;
  typedef NeoEsp32I2s1Tm1829Method X1Tm1829Method;
  typedef NeoEsp32I2s1Apa106Method X1Apa106Method;
  typedef NeoEsp32I2s1Ws2805Method X1Ws2805Method;
  typedef NeoEsp32I2s1Tm1914Method X1Tm1914Method;
#endif

I chose I2S1 for ESP32 since I2S0 is used by audio routines and I2S0 for S2. For S2 this unfortunately means that if user selects I2S output (last bus created) that audio will not function but this is of lesser importance as S2 only has single core and is not best suited for audio (audio is still available when only using 4 RMT outputs).
For S3 this is more of a workaround to still allow I2S compilation (it is impossible to select single I2S, only parallel).
For C3 devices (also supported by WLED but unsupported by NeoPixelBus ATM) I2S is excluded from compilation.

Describe alternatives you've considered
Multiple #ifdef or unsupported options.
I am also sure that having I2S1 for ESP32 and I2S0 for ESP32-S2 with these wrappers may not be to everyone's liking.

Additional context
N/A

@blazoncek
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants