Skip to content

Serial.println() kills Palette Knife on ESP8266 #670

Closed

Description

@janfiess

The palette knife for FastLED actually works as expected with a WS2812B strip, but as soon as I add a Serial.println() to the code, the strip won´t change the color anymore. It just keeps the previous color.
Is there a workaround?

#define FASTLED_ALLOW_INTERRUPTS 0
#include "FastLED.h"

DEFINE_GRADIENT_PALETTE( ib_jul01_gp ) {
    0,   0,  0,  0,
   64,   111,111,  0,
  128,   0,  0,  0,
  172,   0,200, 200,
  255,   0,  0,  0
};

#if FASTLED_VERSION < 3001000
#error "Requires FastLED 3.1 or later; check github for latest code."
#endif

#define DATA_PIN    2
#define LED_TYPE    WS2812B
#define COLOR_ORDER GRB
#define NUM_LEDS    50
#define BRIGHTNESS  100
#define DELAY       25

CRGB leds[NUM_LEDS];
static const uint8_t interval = 0;

void setup() {
  delay(3000); // 3 second delay for recovery
  Serial.begin(9600);
  
  // tell FastLED about the LED strip configuration
  FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS)
    //.setCorrection(TypicalLEDStrip) // cpt-city palettes have different color balance
    .setDither(BRIGHTNESS < 255);

  // set master brightness control
  FastLED.setBrightness(BRIGHTNESS);
}

CRGBPalette16 gTargetPalette( ib_jul01_gp );

void loop()
{
  Serial.println("Hello");  // ---> CRASH
  sunrise(); 
  FastLED.show();
  FastLED.delay(DELAY);
}

void sunrise() {
  // current gradient palette color index
  static uint8_t heatIndex = 0; // start out at 0

  CRGB color = ColorFromPalette(gTargetPalette, heatIndex);

  // fill the entire strip with the current color
  fill_solid(leds, NUM_LEDS, color);

  EVERY_N_SECONDS(interval) {
    // stop incrementing at 255, we don't want to overflow back to 0
    if(heatIndex < 255) {
      heatIndex++;
    }
    if(heatIndex >= 255) {
      heatIndex = 0;
    }
  }
}

Activity

  1. focalintent commented on Oct 25, 2018

    @focalintent
    Contributor

    try putting the println in an EVERY_N_MILLISECONDS -- e.g.

    EVERY_N_MILLISECONDS(250) { 
      Serial.println("Hello");
    }
    

    It's also possible that the combination of calling FastLED.show(), FastLED.delay(25) and outputting that bit of serial is tripping things up with the watchdog, but without seeing the output of your crash/serial console it's hard to tell for sure.

    (Also - generally speaking troubleshooting questions like this get answered more quickly in the g+ group at http://fastled.io/+ -- more people watching there than here, which is mostly used for tracking library bugs/enhancements)

  2. janfiess commented on Oct 26, 2018

    @janfiess
    Author
  3. marcmerlin commented on Dec 30, 2018

    @marcmerlin
    Contributor

    @janfiess can you please close/resolve the issue please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions