Fastled and SSD1306

Status
Not open for further replies.

jgilbert

Member
I'm creating a clock for my daughter that has a 60 Neopixel ring AND a SSD1306 OLED display. I am using a Teensy 3.2 and a prop shield to level shift and buffer the neopixels.

I've been noticing that I cannot seem to get the SSD1306 to work AND the strip of neopixels. I am using the adafruit driver for the SSD1306, and FastLED for the strip. Both are using SPI pins so I suspect some sort of conflict but I can't see anything amiss. I've tried swapping FastLED with the adafruit drivers to no avail.

Can anyone offer any ideas? I'm pretty sure all libraries involved are using SPI transactions which I would have thought would avoid this problem.

The only thing vaguely nonstandard about this setup is I have the neopixels voltage on a STMPS2171STR high side switch but I have confirmed this doesn't seem to affect the behavior when removed or bypassed. (The rationale for this switch is to facilitate a low-power shutdown mode.)

In the following example, the LEDs animate but the display goes dark after the splash screen comes on initially.

Code:
#include <Adafruit_NeoPixel.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define PIN_LED_ENABLE 7
#define PIN_MEM_CS 6
#define PIN_AMP_ENABLE 5
#define PIN_LED_DATA  11


#define PIN_LED_VOLTAGE_SWITCH 3

#define OLED_DC     9
#define OLED_CS     10
#define OLED_RESET  8

#define NUM_LEDS 60

Adafruit_SSD1306 display(OLED_DC, OLED_RESET, OLED_CS);

#include <FastLED.h>
// This is an array of leds.  One item for each led in your strip.
CRGB leds[60];


void setup() {
  // put your setup code here, to run once:

  pinMode( PIN_LED_ENABLE, OUTPUT );
  digitalWrite( PIN_LED_ENABLE, LOW );

  pinMode( PIN_MEM_CS, OUTPUT );
  digitalWrite( PIN_MEM_CS, LOW );

  pinMode( PIN_AMP_ENABLE, OUTPUT );
  digitalWrite( PIN_AMP_ENABLE, LOW );

  pinMode( PIN_LED_VOLTAGE_SWITCH, OUTPUT );
  digitalWrite( PIN_LED_VOLTAGE_SWITCH, HIGH );


  display.begin(SSD1306_SWITCHCAPVCC);

  display.display();
  delay(2000);
  display.clearDisplay();

  // Adafruit SSD1306 and FastLED don't seem to cooperate
  // This is a sterling example why you'd need makernet
  // Another reason is that hte prop sheild has also sorts of special pins
  // that you'd have to read all of the docs to understand
  // otherwise you'd get a shit ton of unexplained behavior

  FastLED.addLeds<WS2811, PIN_LED_DATA, RGB>(leds, 60);
  FastLED.setBrightness( 50 );
}

void loop() {
  // put your main code here, to run repeatedly:




  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0, 0);
  display.println("Hello, world!");
  display.println( millis() );
  display.display();



  digitalWrite( PIN_LED_ENABLE, HIGH );

  // Move a single white led
  for (int n = 0; n < NUM_LEDS; n++) {
    leds[n] = CRGB::White;
    FastLED.show();
    delay(8);
    // leds[n] = CRGB::Black;
  }
  for (int n = 0; n < NUM_LEDS; n++) {
    leds[n] = CRGB::Black;
    FastLED.show();
    delay(8);

  }
  digitalWrite( PIN_LED_ENABLE, LOW );

}
 
Please disregard this post. It doesn't look like FastLED is performing transactions properly so that seems to be the issue.
 
That in itself makes this a worthy post so others can be aware of the problem. If you get a solution or more details adding them may help.

Does it relate to FASTLED doing the SPI on Interrupts?

Going to T_3.5 or T_3.6 (or even a T_LC?) and putting the display on second SPI bus may be a solution allowing use of the LEDS and Display you already have.
 
Status
Not open for further replies.
Back
Top