Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

Thread: SK8612 RGBW Support with audio library...

  1. #1

    SK8612 RGBW Support with audio library...

    **SK6812 SORRY**

    So, after doing some research, I've come up empty handed on finding any official libraries that support RGBW on teensy. If I understand correctly, I need a library which is capable of running the neopixels without interrupting the audio library. Is there something I could do so that I can use the strips I have instead of buying all new dotstar strips?

    Currently, with the code I've written to activate two strips (in parallel), it takes several seconds to update the strips. I'm just using a basic for loop and the traditional adafruit neopixel library and pin 29 for the data. Any audio that is playing while this happens becomes extremely garbled.

    Also, the teensy 3.6 and prop shield are powered by a 3.3v to 5v step up regulator from pololu (can do 1.4 amps) while the strips are powered directly from a 1S lipo. There is a 500 ohm resistor on the data line. From what I understand I cannot use the prop shield's buffer with these rgbw leds at all.

    Code:
    /////////////////////////////////////////////////////////////////////////////
    //////////////////////////LIBRARIES AND VARIABLES////////////////////////////
    /////////////////////////////////////////////////////////////////////////////
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    #include <Adafruit_NeoPixel.h>
    
    const int ledPin = 13;
    
    //initialize button
    #define primaryButton 31
    
    //blade status
    int activated = 0;
    int prevState = 0;
    int bladeDelay = 1; //delay between led ignition
    
    //NEOPIXEL SETUP:
    //number leds
    byte nLeds = 144;
    //pin
    byte nPin = 29;
    //power factor
    byte pf = 4;
    //Default colors (preset 0):
    byte red = 0;
    byte green = 0;
    byte blue = 0;
    byte white = 255;
    Adafruit_NeoPixel blade = Adafruit_NeoPixel(nLeds, nPin, NEO_RGBW + NEO_KHZ800);
    uint32_t colorOn = blade.Color(green/pf, red/pf, blue/pf, white/pf);
    uint32_t colorOff = blade.Color(0,0,0,0);
    
    /////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////AUDIO SETUP//////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////
    // GUItool: begin automatically generated code
    AudioPlaySdWav           playSdWav1;     //xy=363.3333435058594,1350.333251953125
    AudioPlaySdWav           playSdWav7;     //xy=362.75,1674.75
    AudioPlaySdWav           playSdWav2;     //xy=366.3333435058594,1411.333251953125
    AudioPlaySdWav           playSdWav5;     //xy=374.3333435058594,1569.333251953125
    AudioPlaySdWav           playSdWav4;     //xy=375.3333435058594,1518.333251953125
    AudioPlaySdWav           playSdWav6;     //xy=376.3333435058594,1619.333251953125
    AudioPlaySdWav           playSdWav3;     //xy=377.3333435058594,1465.333251953125
    AudioMixer4              mixer2;         //xy=806.3333435058594,1618.333251953125
    AudioMixer4              mixer1;         //xy=816.3333435058594,1410.333251953125
    AudioOutputAnalog        dac1;           //xy=1082.3333435058594,1412.333251953125
    AudioConnection          patchCord1(playSdWav1, 0, mixer1, 0);
    AudioConnection          patchCord2(playSdWav7, 0, mixer2, 3);
    AudioConnection          patchCord3(playSdWav2, 0, mixer1, 1);
    AudioConnection          patchCord4(playSdWav5, 0, mixer2, 1);
    AudioConnection          patchCord5(playSdWav4, 0, mixer2, 0);
    AudioConnection          patchCord6(playSdWav6, 0, mixer2, 2);
    AudioConnection          patchCord7(playSdWav3, 0, mixer1, 2);
    AudioConnection          patchCord8(mixer2, 0, mixer1, 3);
    AudioConnection          patchCord9(mixer1, dac1);
    // GUItool: end automatically generated code
    
    float volumeGain = 4; //volume control variable
    
    
    /////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////SDCARD SETUP/////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////
    // Use these with the Teensy Audio Shield
    //#define SDCARD_CS_PIN    10
    //#define SDCARD_MOSI_PIN  7
    //#define SDCARD_SCK_PIN   14
    
    // Use these with the Teensy 3.5 & 3.6 SD card
    #define SDCARD_CS_PIN    BUILTIN_SDCARD
    #define SDCARD_MOSI_PIN  11  // not actually used
    #define SDCARD_SCK_PIN   13  // not actually used
    
    // Use these for the SD+Wiz820 or other adaptors
    //#define SDCARD_CS_PIN    4
    //#define SDCARD_MOSI_PIN  11
    //#define SDCARD_SCK_PIN   13
    
    
    
    /////////////////////////////////////////////////////////////////////////////
    ///////////////////////////////////SETUP/////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////
    void setup()
    {
      Serial.begin(115200);    //initialize serial communication
      delay(100);
      AudioMemory(16); //set memory allocated to audio functions
      dac1.analogReference(EXTERNAL); //much louder!
      delay(50);             //time for DAC voltage stabilization
      pinMode(5, OUTPUT);
      delay(50);
      digitalWrite(5, HIGH); // turn on the amplifier
      delay(50);
      SPI.setMOSI(SDCARD_MOSI_PIN);   //set SD card MOSI pin
      SPI.setSCK(SDCARD_SCK_PIN);     //set SD card clock pin
    
      //return error if SD card cannot be accessed
      if (!(SD.begin(SDCARD_CS_PIN)))
      {
        while (1) {
          Serial.println("Unable to access the SD card");
          delay(500);
        }
      }
    
      pinMode(ledPin, OUTPUT); //board indicator LED
    
      //Set the gain on one of the mixer's channels. Input "channel" must be 0 to 3.
      //Input "level" may be any floating point number from 0.00004 to 32768.0.
      //The default is 1.0.
      //Values less than 1.0 attenuate the inputs, and values greater than 1.0 cause amplification.
      mixer1.gain(0, volumeGain * .25); //sdwav1
      mixer1.gain(1, volumeGain * .25); //sdwav2
      mixer1.gain(2, volumeGain * .25); //sdwav3
      mixer2.gain(0, volumeGain * .25); //sdwav4
      mixer2.gain(1, volumeGain * .25); //sdwav5
      mixer2.gain(2, volumeGain * .25); //sdwav6
      mixer2.gain(3, volumeGain * .25); //sdwav7
    
      //setup button
      pinMode(primaryButton, INPUT_PULLUP);
    
      //neopixel start
      blade.begin();
      blade.show();
    }
    
    void loop() 
    {
      if(digitalRead(primaryButton)==LOW)
      {
        if(activated==0&&prevState==0)
        {
          prevState=1;
          digitalWrite(ledPin, HIGH);
          playSdWav1.play("PON.WAV");
          activated = 1;
          for(byte i=0; i<nLeds; i++)
          {
              blade.setPixelColor(i,colorOn);
              blade.show();
              delay(bladeDelay);
          }
        }else if(activated==1&&prevState==0)
        {
          prevState=1;
          digitalWrite(ledPin, LOW);
          playSdWav1.stop();
          delay(25); //prevents some weird clipping that happens when the sounds are played back to back
          playSdWav2.play("POFF.WAV");
          activated = 0;
          for(byte i=nLeds; i>=0; i--)
          {
              blade.setPixelColor(i,colorOff);
              blade.show();
              delay(bladeDelay);
          }
        }
      }else
      {
        //do nothing
        prevState=0;
      }
    }
    Any assistance or suggestions would be greatly appreciated. I'd be happy to answer further questions about my setup if there is anything I may have missed. Thank you!

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,550
    I've put this on my todo list....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •