Go Down

Topic: Bliptronics spectrum analyzer shield with WS2801 FastSPI_LED (Read 996 times) previous topic - next topic

tactoad

Hello everyone,

I recently bought a spectrum analyzer shield from Bliptronics, a couple of WS2801 RGB led strands. All the sample code from Bliptronics seems to be broken and none of the libs seems to work with the latest IDE.
Has anyone got it to work with the FastSPI_led libs? The test code for FastSPI_led works fine. Unfortunately there is no support from Bliptronics.

I´m trying to build a 5x5 pixel spectrum analyzer. I just started coding with the arduino but I cant figure this one out. Any help is appreciated.

Thanks, 

dgarcia42

Yup - in fact I used it to create the sound reactive functionality in Liquid Eye (see http://www.youtube.com/watch?v=yMcP-ZvbEyw ).

Here is a rough version of the class that I use to interact with the MSGEQ7's - note this is based on Sparkfun's version of the board (https://www.sparkfun.com/products/10306) - but the bliptronics version should be similar, I suspect you'll need to change the pin definitions in CEQ().  Hope this is helpful!  (A future expansion to FastSPI_LED2 will include a variety of utility classes like this that i've made use of.


class CEQ {
  // Reset pin
  int m_nReset;
  // Left data pin
  int m_nLeft;
  // Right data pin
  int m_nRight;
  // Strobe pin
  int m_nStrobe;

  // Most recently read level values for left and right channels
  int m_nLeftVals[7];
  int m_nRightVals[7];

  // Lowest values received per channel yet, attempt to establish a noise floor
  int m_nMin[7];

  // Strobe the MSGEQ lines
  void strobe() {
    digitalWrite(m_nStrobe, HIGH);
    digitalWrite(m_nStrobe, LOW);
  }
 
  // Trigger a reset in the MSGEQ chip.  Also reset low/hi values
  void reset() {
    for(int i = 0; i < 7; i++) {
      // m_nMax = 0;
      m_nMin = 1023;
      m_nLeftVals = 0;
      m_nRightVals = 0;
    }
    digitalWrite(m_nReset, HIGH);
    strobe();
    digitalWrite(m_nReset, LOW);
  }
 
  void init() {
    pinMode(m_nStrobe, OUTPUT);
    pinMode(m_nReset, OUTPUT);
    digitalWrite(m_nStrobe, LOW);
    reset();
  }
 
 
  int readChannel(int pin) { return (analogRead(pin) + analogRead(pin)) >> 1; }
 
public:
  CEQ() {
    m_nStrobe = 4;
    m_nReset = 5;
    m_nLeft = 0;
    m_nRight = 1;
   
    init();
  }
 
  // Call this method to re-read data from the MSGEQ7 chip
  void refreshLevels() {
    for(byte band = 0; band < 7; band++) {
      m_nLeftVals[band] = readChannel(m_nLeft);
      m_nRightVals[band] = readChannel(m_nRight);
     
      if(m_nMin[band] > m_nLeftVals[band]) {
        m_nMin[band] = m_nLeftVals[band];
      }
      if(m_nMin[band] > m_nRightVals[band]) {
        m_nMin[band] = m_nRightVals[band];
      }
         
      strobe();
    }
  }
 
  // Get the left channel level for band n normalized to be between 0 and maxv
  int getLeftLevel(int n, int maxv) { return map(m_nLeftVals[n], m_nMin[n], 1023, 0, maxv); }
  // Get the right channel level for band n normalized to be between 0 and maxv
  int getRightLevel(int n, int maxv) { return map(m_nRightVals[n], m_nMin[n], 1023, 0, maxv); }
  // Get the highest level for band n on left vs right channels, normalized to be between 0 and maxv
  int getLevel(int n, int maxv) { return max(getLeftLevel(n, maxv), getRightLevel(n, maxv)); }
};

--

FastLED (formerly FastSPI_LED) -- new home http://fastled.io

Helmuth

#2
Mar 05, 2013, 09:10 am Last Edit: Mar 05, 2013, 10:43 am by Helmuth Reason: 1
Hi Daniel,

ist the liqid eye code without sound reactive functionality available somewhere?

Thanx

What? Karma 0? No way! +1 for making the world colorful.  ;)

tactoad

Thanks dgarcia42, I´ll give it a try as soon as my programming skills catch up :)

Go Up