AaronLiddiment / LEDText

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

LEDMatrix: field 'm_OutOfBounds' has incomplete type 'CRGB' #20

Closed JaredTamana closed 4 years ago

JaredTamana commented 4 years ago

Hi there. I'm trying to use LEDText on a WS2812B 32x8 controlled by a Nano 328P. When I try to include LEDText, I get an error regarding LEDMatrix's header file and the struct definitions of CRGB:


                 from D:\OneDrive\Documents\Arduino\sketch_may22a\ledtext\ledtext.ino:1:

LEDMatrix.h:27:17: error: field 'm_OutOfBounds' has incomplete type 'CRGB'

     struct CRGB m_OutOfBounds;

                 ^~~~~~~~~~~~~

D:\OneDrive\Documents\Arduino\libraries\LEDMatrix/LEDMatrix.h:26:12: note: forward declaration of 'struct CRGB'

     struct CRGB *m_LED;

            ^~~~

In file included from C:\Users\jared\AppData\Local\Temp\arduino_build_573779\sketch\config.h:3:0,

                 from D:\OneDrive\Documents\Arduino\sketch_may22a\ledtext\ledtext.ino:1:

D:\OneDrive\Documents\Arduino\libraries\LEDMatrix/LEDMatrix.h: In constructor 'cLEDMatrix<tMWidth, tMHeight, tMType, tBWidth, tBHeight, tBType>::cLEDMatrix(bool)':

LEDMatrix.h:75:111: error: invalid application of 'sizeof' to incomplete type 'CRGB'

           p_LED = (struct CRGB *) malloc(m_absMWidth * m_absBWidth * m_absMHeight * m_absBHeight * sizeof(CRGB));

                                                                                                               ^

In file included from C:\Users\jared\AppData\Local\Temp\arduino_build_573779\sketch\config.h:8:0,

                 from D:\OneDrive\Documents\Arduino\sketch_may22a\ledtext\ledtext.ino:1:

D:\OneDrive\Documents\Arduino\libraries\FastLED/FastLED.h: At global scope:

D:\OneDrive\Documents\Arduino\libraries\FastLED/FastLED.h:14:21: note: #pragma message: FastLED version 3.003.003

 #    pragma message "FastLED version 3.003.003"

                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~

Using library LEDMatrix in folder: D:\OneDrive\Documents\Arduino\libraries\LEDMatrix (legacy)
Using library LEDText in folder: D:\OneDrive\Documents\Arduino\libraries\LEDText (legacy)
Using library FastLED at version 3.3.3 in folder: D:\OneDrive\Documents\Arduino\libraries\FastLED 
exit status 1
field 'm_OutOfBounds' has incomplete type 'CRGB'

I'm not sure if this is a library issue or something I've done, but this occurs even when I've only written the bare minimum setup.

#ifndef config_h
#define config_h
#include <LEDMatrix.h> 
#include <Font12x16.h>
#include <Font16x24.h>
#include <FontMatrise.h>
#include <LEDText.h> 
#include <FastLED.h>
//
// Used by LEDMatrix
#define MATRIX_TILE_WIDTH   8 // width of EACH NEOPIXEL MATRIX (not total display)
#define MATRIX_TILE_HEIGHT  32 // height of each matrix
#define MATRIX_TILE_H       1  // number of matrices arranged horizontally
#define MATRIX_TILE_V       1  // number of matrices arranged vertically
#define COLOR_ORDER GRB
#define NUM_LEDS 256
#define LED_PIN 6

#define BRIGHTNESS 32
#endif

#include "config.h"

cLEDMatrix<-MATRIX_TILE_WIDTH, -MATRIX_TILE_HEIGHT, HORIZONTAL_ZIGZAG_MATRIX,
    MATRIX_TILE_H, MATRIX_TILE_V, HORIZONTAL_BLOCKS> ledmatrix;
CRGB *leds = ledmatrix[0];

// a bunch of definitions for FastLED code

void setup() {
  FastLED.addLeds<WS2812B, LED_PIN, COLOR_ORDER>(ledmatrix[0], ledmatrix.Size());
  FastLED.setBrightness(2);
  cLEDText ScrollingMsg;
}

void loop() {

  // a bunch of commented FastLED code

}

void drawPattern(uint16_t patternArray[], int patternSize, long int colour) {
  uint16_t nextPixel;
  int pixelCounter = 0;
  for (int i = 0; i < NUM_LEDS; i++) {
    for (int j = 0; j < patternSize; j++) {
      nextPixel = pgm_read_word(&patternArray[pixelCounter]);
      if (i == nextPixel) {
        ledmatrix.DrawPixel(floor(i / 8), (i % 8), colour);
        pixelCounter++;
      }
    }
  }
}

void singleLED(int number, int delaytime, long int colour) {
  ledmatrix.DrawPixel(floor(number / 8), (number % 8), colour);
  FastLED.show();
  delay(delaytime);
}

What're my next steps? Where am I tripping up?

AaronLiddiment commented 4 years ago

Only had a quick look but noticed that you include the FastLED header after the LEDMatrix header, this will cause problems as the CRGB structure is only declared in FastLED :) Try this order:-

include

include

include

include

include

include

JaredTamana commented 4 years ago

That'll do it! Thanks, I'm just getting back into Arduino, it's been a while :)