APA102 + PropShield = no Audio

Status
Not open for further replies.

Break Stuff

Active member
Hoping there's an obvious solution and I'm just missing it. When I run this code the lights move. If I comment out line 23 (FastLED.addLeds) the sound works. But I'm greedy, I want lights and sound to both work. Attached raw audio file for testing and full code. Thanks for looking!

Using:
  • Teensy 3.2
  • Teensyduino 1.36
  • Arduino 1.8.1
  • PJRC Propshield
  • APA102 leds
  • FastLed 3.1.3


Code:
/******************************* LEDS */
#include <FastLED.h>
#define NUM_LEDS 144
CRGB leds[NUM_LEDS];

/******************************* Audio */
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

AudioPlaySerialflashRaw  playFlashRaw1;  
AudioMixer4              mixer1;         
AudioOutputAnalog        dac1;          
AudioConnection          patchCord1(playFlashRaw1, 0, mixer1, 0);
AudioConnection          patchCord2(mixer1, dac1);

void setup() {
  /************************************************************ LEDS */
  delay(1000);    
    
   FastLED.addLeds<APA102, BGR>(leds, NUM_LEDS); // Comment this out and the sounds work
 
  pinMode(7, OUTPUT);
  digitalWrite(7, HIGH);  

  /*********************************************************** Audio */
  AudioMemory(20);
  pinMode(5, OUTPUT);
  mixer1.gain(0, 0.8);
  digitalWrite(5, HIGH);
  if ( !SerialFlash.begin(6) ) Serial.println("spi failure"); else Serial.println("spi success");
}


void loop() {
  /********************************************************************************** LEDS */
  for(int n = 0; n < NUM_LEDS; n++) {
    leds[n] = CRGB::White;
   //   SPI.beginTransaction(SPISettings(24000000, MSBFIRST, SPI_MODE0));    //these 4 lines do not help
   //   digitalWrite(7, HIGH);  
    FastLED.show();
   //   digitalWrite(7, LOW);
   //   SPI.endTransaction(); 
    delay(8);
    leds[n] = CRGB::Black;  
  }
  /******************************************************************************* Audio */
   Serial.println("start play attempt");
   playFlashRaw1.play("rainstickMONO.raw");         
   delay(5);
   while ( playFlashRaw1.isPlaying() );
   Serial.println("end play attempt");
}
 

Attachments

  • rainstickMONO.zip
    228.2 KB · Views: 117
Does the LEDS work without the Audio Library?

In "fastled_config.h" you can uncomment line 21 and see if that helps, I had problems with FastLed and the Prop Shield with WS led's so I reworked the Octo library for a single channel freeing up the other pins. Another thing you can try is to comment out the FastLeds show function instead and see if the Audio works then you know it's the interrupts causing problems.
 
The lights work fine with or without the Audio Library.
line 21 from the "fastled_config.h" is
Code:
 #define FASTLED_ALLOW_INTERRUPTS 1

Putting that before the include
Code:
#define FASTLED_ALLOW_INTERRUPTS 1
#include <FastLED.h>
doesn't seem to change anything. Thanks though, any other ideas?
 
So it looks like an SPI conflict. Fastled docs say
Teensy 3/3.1: Will disable the use of the MISO pin while writing led data, but will enable it again afterwards.
But just the fastled setup line "FastLED.addLeds" stops playFlashRaw from working. Even if I never call "FastLED.show()"

Teensy Docs https://www.pjrc.com/teensy/td_libs_SPI.html say
Multiple SPI devices use the same SPI SCK, MISO and MOSI signals but each device will need it's own SS pin.

So maybe I could use alternate pins but how to do this on the prop shield? it's all hardwired.

Confusing things: Via this post The Neopixel library works fine. Is FastLED bugged? or am I talking to it wrong?
 
Status
Not open for further replies.
Back
Top