AaronLiddiment / LEDText

FastLED Flexible Text Message Class requires LEDMatrix Class
89 stars 32 forks source link

OCTOWS2811 and DmxReceiver #4

Closed ChrisLaurie closed 7 years ago

ChrisLaurie commented 7 years ago

Hi Aaron

I am trying to use the LedMatrix, text and sprite libraries in my sketch together with the DmxReceiver library. I've got serious flickering problems when adding DMX data and was hoping to use the OCTOWS2811 library. FastLED has the feature to do this but it seems the the LedMatrix object does not inherit the correct templates.

To use the Teensy's OCTOWS2811 library with FastLED, one would add leds with this call:

FastLED.addLeds(leds, NUM_LEDS);

But if I do this inside the LEdMatrix sketch, I get this compile error:

no matching function for call to 'CFastLED::addLeds(cLEDMatrix<33, -7, (MatrixType_t)2u>&, int)'

and setting my CHIPSET to OCTOWS2811 with the standard LedMatrix call of:

FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds[0], leds.Size());

gives me this compile error:

no matching function for call to 'CFastLED::addLeds(CRGB*, int)'

I have tested the OCTOWS2811 example and added DMxReceiver to that and it seemed to work.

Can you please suggest how I can go about getting the OCTOWS2811 to wor with LedMatrix?

AaronLiddiment commented 7 years ago

I have used the Octo library with no issues, here is the top of one of my sketches....

#define USE_OCTOWS2811
#include <OctoWS2811.h>

#include <FastLED.h>

#include <LEDMatrix.h>

// Change the next 6 defines to match your matrix type and size

#define LED_PIN        2
#define COLOR_ORDER    GRB
#define CHIPSET        WS2812B

#define MATRIX_WIDTH   16  // Set this negative if physical led 0 is opposite to where you want logical 0
#define MATRIX_HEIGHT  512  // Set this negative if physical led 0 is opposite to where you want logical 0
#define MATRIX_TYPE    HORIZONTAL_ZIGZAG_MATRIX  // See top of LEDMatrix.h for matrix wiring types

cLEDMatrix<MATRIX_WIDTH, MATRIX_HEIGHT, MATRIX_TYPE> leds;

void setup()
{
  FastLED.addLeds<OCTOWS2811>(leds[0], (MATRIX_HEIGHT / 8) * MATRIX_WIDTH);

  FastLED.setDither(0);
  FastLED.setBrightness(255);
  FastLED.clear(true);
  delay(500);
  FastLED.showColor(CRGB::Red);
  delay(1000);
  FastLED.showColor(CRGB::Lime);
  delay(1000);
  FastLED.showColor(CRGB::Blue);
  delay(1000);
  FastLED.clear(true);
}

This was built using FastLED3.1. I haven't been doing much LED stuff recently so am not sure if FastLED has been updated but they are usually good about not breaking older code. What board are you using? Which compiler? What FastLED version?

ChrisLaurie commented 7 years ago

Thanks for this, Aaron. It is a bit different, so I will give it a go and see. How do I know that the OCTOWS2811 library is used? FastLED specifically mentions that you must change the chipset to OCTOWS2811 and you do not have to specify the pin, it hard coded inside FastLED.

On 17 Oct 2016 10:44 p.m., "Aaron Liddiment" notifications@github.com wrote:

I have used the Octo library with no issues, here is the top of one of my sketches....

define USE_OCTOWS2811

include

include

include

// Change the next 6 defines to match your matrix type and size

define LED_PIN 2

define COLOR_ORDER GRB

define CHIPSET WS2812B

define MATRIX_WIDTH 16 // Set this negative if physical led 0 is opposite

to where you want logical 0

define MATRIX_HEIGHT 512 // Set this negative if physical led 0 is

opposite to where you want logical 0

define MATRIX_TYPE HORIZONTAL_ZIGZAG_MATRIX // See top of LEDMatrix.h for

matrix wiring types

cLEDMatrix leds;

void setup() { FastLED.addLeds(leds[0], (MATRIX_HEIGHT / 8) * MATRIX_WIDTH);

FastLED.setDither(0); FastLED.setBrightness(255); FastLED.clear(true); delay(500); FastLED.showColor(CRGB::Red); delay(1000); FastLED.showColor(CRGB::Lime); delay(1000); FastLED.showColor(CRGB::Blue); delay(1000); FastLED.clear(true); }

This was built using FastLED3.1. I haven't been doing much LED stuff recently so am not sure if FastLED has been updated but they are usually good about not breaking older code. What board are you using? Which compiler? What FastLED version?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AaronLiddiment/LEDText/issues/4#issuecomment-254328052, or mute the thread https://github.com/notifications/unsubscribe-auth/ABwAle__QESQeDWeRm3aEOlmfaHxjCIdks5q094OgaJpZM4KY0vQ .

ChrisLaurie commented 7 years ago

I am afraid this does not work.

FastLED.addLeds(leds[0], MATRIX_HEIGHT * MATRIX_WIDTH);

returns the compile error:

no matching function for call to 'CFastLED::addLeds(CRGB*, int)'

On 17 October 2016 at 22:43, Aaron Liddiment notifications@github.com wrote:

I have used the Octo library with no issues, here is the top of one of my sketches....

define USE_OCTOWS2811

include

include

include

// Change the next 6 defines to match your matrix type and size

define LED_PIN 2

define COLOR_ORDER GRB

define CHIPSET WS2812B

define MATRIX_WIDTH 16 // Set this negative if physical led 0 is opposite

to where you want logical 0

define MATRIX_HEIGHT 512 // Set this negative if physical led 0 is

opposite to where you want logical 0

define MATRIX_TYPE HORIZONTAL_ZIGZAG_MATRIX // See top of LEDMatrix.h for

matrix wiring types

cLEDMatrix leds;

void setup() { FastLED.addLeds(leds[0], (MATRIX_HEIGHT / 8) * MATRIX_WIDTH);

FastLED.setDither(0); FastLED.setBrightness(255); FastLED.clear(true); delay(500); FastLED.showColor(CRGB::Red); delay(1000); FastLED.showColor(CRGB::Lime); delay(1000); FastLED.showColor(CRGB::Blue); delay(1000); FastLED.clear(true); }

This was built using FastLED3.1. I haven't been doing much LED stuff recently so am not sure if FastLED has been updated but they are usually good about not breaking older code. What board are you using? Which compiler? What FastLED version?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AaronLiddiment/LEDText/issues/4#issuecomment-254328052, or mute the thread https://github.com/notifications/unsubscribe-auth/ABwAle__QESQeDWeRm3aEOlmfaHxjCIdks5q094OgaJpZM4KY0vQ .

AaronLiddiment commented 7 years ago

My bad, the LED_PIN, COLOR_ORDER and CHIPSET are just left over defines and are not used in the above code. The code compiles for me and is currently controlling 8192 WS2812's in a series of ceiling panels. I used FastLED V3.1, Arduino 1.6.6 & Teensyduino and have it running on a Teensy 3.1 What is your setup?

ChrisLaurie commented 7 years ago

I am using a Teensy 3.1 on a matrix of 33 x 7 with LedText and LedSprites via LedMatrix. As long as I am in demo mode (no dmx), this works fine using FastLed to generate the signal.

When dmx signals arrive I think that the DmxReceivers interrupts clash with FastLed's and I get massive flicker issues.

FastLed allows me to use the Teensy's OCTOWS2811 library (this library uses DMA so there is very little impact on the rest of the code). FastLed does this by changing the chipset to OCTOWS2811. Here is an extract from their example sketch, OctoWS2811Demo.ino :

define USE_OCTOWS2811

include

include

define NUM_LEDS_PER_STRIP 64

define NUM_STRIPS 8

CRGB leds[NUM_STRIPS * NUM_LEDS_PER_STRIP]; // Pin layouts on the teensy 3: // OctoWS2811: 2,14,7,8,6,20,21,5 void setup() { LEDS.addLeds(leds, NUM_LEDS_PER_STRIP); LEDS.setBrightness(32); }

This example compiles and runs fine, even when I add dmxreceiver to it.

I want to use this but I cannot get a correct addLeds call when using the LedMatrix library.

On 18 October 2016 at 10:59, Aaron Liddiment notifications@github.com wrote:

My bad, the LED_PIN, COLOR_ORDER and CHIPSET are just left over defines and are not used in the above code. The code compiles for me and is currently controlling 8192 WS2812's in a series of ceiling panels. I used FastLED V3.1, Arduino 1.6.6 & Teensyduino and have it running on a Teensy 3.1 What is your setup?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AaronLiddiment/LEDText/issues/4#issuecomment-254448363, or mute the thread https://github.com/notifications/unsubscribe-auth/ABwAldSwqVZtV2S7uZcKlToxtEy_FRnyks5q1IqBgaJpZM4KY0vQ .

AaronLiddiment commented 7 years ago

I presume when using my matrix class your are defining an instance?

#define MATRIX_WIDTH   16  // Set this negative if physical led 0 is opposite to where you want logical 0
#define MATRIX_HEIGHT  512  // Set this negative if physical led 0 is opposite to where you want logical 0
#define MATRIX_TYPE    HORIZONTAL_ZIGZAG_MATRIX  // See top of LEDMatrix.h for matrix wiring types

cLEDMatrix<MATRIX_WIDTH, MATRIX_HEIGHT, MATRIX_TYPE> leds;

You then do not need the CRGB leds declare as the CRGB array is defined within the MatrixClass. And in the addLeds call you would just use led[0] which in my matrix class returns the address of element 0 of the array.

ChrisLaurie commented 7 years ago

Hi Aaron

Thanks for your indulgence! I have gotten somewhere! The problem is finding the correct addleds call. So what seems to work is this (redacted a bit):

define USE_OCTOWS2811

include

define CHIPSET OCTOWS2811

cLEDMatrix < MATRIX_WIDTH, -MATRIX_HEIGHT, MATRIX_TYPE > leds;

FastLED.addLeds(leds[0], leds.Size());

or

FastLED.addLeds(leds[0], leds.Size());

also works

And I am displaying using the very fast OCTOWS2811 library and reading dmx does not interfere! Whoohoo! Now I need to cleanup, check all functionality and document for the lighting guys that will be setting up our show.

Thanks again - even though you are not that active with this stuff you still found the time to help, kudos to you!

On 18 October 2016 at 19:58, Aaron Liddiment notifications@github.com wrote:

I presume when using my matrix class your are defining an instance?

define MATRIX_WIDTH 16 // Set this negative if physical led 0 is opposite to where you want logical 0

define MATRIX_HEIGHT 512 // Set this negative if physical led 0 is opposite to where you want logical 0

define MATRIX_TYPE HORIZONTAL_ZIGZAG_MATRIX // See top of LEDMatrix.h for matrix wiring types

cLEDMatrix<MATRIX_WIDTH, MATRIX_HEIGHT, MATRIX_TYPE> leds;

You then do not need the CRGB leds declare as the CRGB array is defined within the MatrixClass. And in the addLeds call you would just use led[0] which in my matrix class returns the address of element 0 of the array.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AaronLiddiment/LEDText/issues/4#issuecomment-254588185, or mute the thread https://github.com/notifications/unsubscribe-auth/ABwAleZsqUUI5zufqqETFJTVxf3gLTtXks5q1Qi_gaJpZM4KY0vQ .

AaronLiddiment commented 7 years ago

No problem :) Good luck with the project.

ChrisLaurie commented 7 years ago

Sorry to be a pain - but I am getting an unwanted column of leds when writing static text (no scrolling); The sketch gets a dmx setting and then calculates a year to display:. My code:

curFunction = _year; char yeartxt[]={" "}; String str; str = String(curYear); str.toCharArray(yeartxt, ARRAY_SIZE(yeartxt)); ScrollingMsg.SetFont(RobotronFontData); ScrollingMsg.SetText((unsigned char *)yeartxt, ARRAY_SIZE(yeartxt)); ScrollingMsg.SetTextColrOptions(COLR_HSV, patternHue, 255, 255); ScrollingMsg.UpdateText();

I have tried various things but I get a single column of pixels at the far left of the matrix.

On 18 October 2016 at 21:39, Aaron Liddiment notifications@github.com wrote:

Closed #4 https://github.com/AaronLiddiment/LEDText/issues/4.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AaronLiddiment/LEDText/issues/4#event-828044574, or mute the thread https://github.com/notifications/unsubscribe-auth/ABwAlW6PvzAbLLg1vnaSO0RezutUrg6eks5q1SBVgaJpZM4KY0vQ .

AaronLiddiment commented 7 years ago

I have never been a fan of string functions ;) I would write it this way.

unsigned char yeartxt[5];
sprintf((char *)yeartxt, "%04.4d", _year);
ScrollingMsg.SetFont(RobotronFontData);
ScrollingMsg.SetText(yeartxt, strlen((char *)yeartxt));
ScrollingMsg.SetTextColrOptions(COLR_HSV, patternHue, 255, 255);
ScrollingMsg.UpdateText();

Of course it might not be a rogue character in the char array. Do you have the ERASE_BACKGROUND mode set or are you using LEAVE_BACKGROUND. And have you set the XY origin of the text area to be 0,0 and made it the full size of matrix area. Also you might want to make the Y origin -1 as if I remember correctly the Robotron font is 7 pixels high with a blank line along the bottom of the font.