iliketomakestuff
Member
So, here's a stripped down version of the essentials of this code. Basically, I can get audio to play or LEDs to work, but if both are active in the code, only the first one called works.
I tried doing an SPI transaction around the LED lines, but that doesn't seem to affect it. Any ideas?
I tried doing an SPI transaction around the LED lines, but that doesn't seem to affect it. Any ideas?
Code:
#include <FastLED.h>
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
AudioPlaySerialflashRaw playRawHUM; //xy=149,388
AudioPlaySerialflashRaw playRawBlade; //xy=149,388
AudioMixer4 mixer1; //xy=445,386
AudioOutputAnalog dac1; //xy=591,379
AudioConnection patchCord2(playRawBlade, 0, mixer1, 0);
//AudioConnection patchCord1(playRawHUM, 1, mixer1, 1);
AudioConnection patchCord3(mixer1, dac1);
#define LED_PIN 7
#define COLOR_ORDER BGR
#define CHIPSET APA102
#define NUM_LEDS 300
#define BRIGHTNESS 100
#define FRAMES_PER_SECOND 70
#define PROP_AMP_ENABLE 5
#define FLASH_CHIP_SELECT 6
CRGB leds[NUM_LEDS];
int potVal = 0;
int outputValue = 0;
int presetColors[] = {CRGB::Red,CRGB::Blue,CRGB::ForestGreen,CRGB::White, CRGB::Orange};
void setup() {
delay(1000); // sanity delay
//FastLED.addLeds<APA102, BGR>(leds, NUM_LEDS);
FastLED.addLeds<CHIPSET, COLOR_ORDER>(leds, NUM_LEDS);//.setCorrection( TypicalLEDStrip );
FastLED.setBrightness( BRIGHTNESS );
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, HIGH);
Serial.begin(9600);
// wait up to 3 seconds for the Serial device to become available
long unsigned debug_start = millis ();
while (!Serial && ((millis () - debug_start) <= 3000))
;
Serial.println ("Start prop shield RAW player");
pinMode(PROP_AMP_ENABLE, OUTPUT);
digitalWrite(PROP_AMP_ENABLE, HIGH);
AudioMemory(20);
dac1.analogReference(EXTERNAL); // much louder!
delay(50); // time for DAC voltage stable
mixer1.gain(0, 1.5f);
// Start SerialFlash
if (!SerialFlash.begin(FLASH_CHIP_SELECT)) {
while (1)
{
Serial.println ("Cannot access SPI Flash chip");
delay (3000);
}
}
}
void loop()
{
//This audio or the LEDs work, but only whichever is first in the code
for( int j = 0; j < 50; j++) {
leds[j] = CRGB::Red;
}
SPI.beginTransaction(SPISettings(24000000, MSBFIRST, SPI_MODE0));
digitalWrite(7, HIGH); // enable access to LEDs
FastLED.show();
digitalWrite(7, LOW);
SPI.endTransaction(); // allow other libs to use SPI again
// playRawBlade.play("BLADEUP.RAW");
// delay(2000);
FastLED.delay(1000 / FRAMES_PER_SECOND);
}