Closed CobaltEcho closed 2 years ago
A good place to start is to read the Wiki I created for the cLEDMatrix Class:
https://github.com/AaronLiddiment/LEDMatrix/wiki
cLEDText relys on my cLEDMatrix class and it is the Matrix class which allocates the CRGB array of leds therefore you do not need to allocate them with CRGB leds[NumLeds];
If you look at my examples you will notice that the array of leds is passed to Fastled with:
FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds[0], leds.Size());
Then you can access the leds by Index or X/Y using the following syntax:
leds(i) = CRGB::Red;
or
leds(x,y) = CRGB::Red
If you need an address for the leds CRGB structure then you use leds[i]
, note the square brackets.
Thanks @AaronLiddiment , I did read through the Wiki and have had things set up as follows:
const uint8_t DisplayWidth = 14;
const uint8_t DisplayHeight = 10;
const uint16_t NumLeds = DisplayWidth * DisplayHeight;
const uint16_t NUM_LEDS = NumLeds;
cLEDMatrix<DisplayWidth, DisplayHeight, HORIZONTAL_ZIGZAG_MATRIX> leds;
FastLED.addLeds<WS2812B, 9, GRB>(leds[0], leds.Size());
FastLED.addLeds<WS2812B, 10, GRB>(leds[0], leds.Size());
Maybe these errors makes sense?
FastLED\src/pixeltypes.h:751:44: note: candidate: bool operator<(const CRGB&, const CRGB&) inline attribute((always_inline)) bool operator< (const CRGB& lhs, const CRGB& rhs)
FastLED\src/pixeltypes.h:751:44: note: no known conversion for argument 2 from 'cLEDMatrix<14, 10, (MatrixType_t)2>' to 'const CRGB&' MatrixTestv6:497:35: error: lvalue required as left operand of assignment leds[i] = CHSV(hue++, 255, 255);
error: request for member 'getAverageLight' in 'leds.cLEDMatrix<14, 10, (MatrixType_t)2>::
Why do you have 2 addLeds lines? Do you have 2 led matrix connected? Unless you want both to display the same info you need to use different led arrays!
Please re-read my previous reply! There is a big difference between [] & ()! In my cLEDMatrix class I override [] to reference the address of CRGB class for that index but () to reference the CRGB class for the index.
Ahh, ok, I'm new to programming so I think I'm getting mixed up between address and reference.
So if I'm understanding correctly... So you would use leds(i) to use something built into the (class?), like cHSV to set the color for the led, but not specifically addressing that led for output.
But if you want to actually address the led, as in, set the led to something specific, you use the [i] to say "led i should be red".
So how would you do something like this, where it's assumed leds
is an int?
for(int i = 0; i < leds; i++) {
error: no match for 'operator<' (operand types are 'int
' and 'cLEDMatrix<14, 10, (MatrixType_t)2>
')
Disreguard Question, but going to anwser in case someone in the future needs this info: Use Num_Leds
(or the number of LED's you have) instead of leds
:
for(int i = 0; i < NumLeds; i++) {
Well for a start this is not really the place for me to teach you the basics of C++, what you really need to do is look up some online reasources for learning about c++ classes. A class consists of a definition for the class which will declare a number of variables, functions & operators that make up that class. So for exmaple my cLEDMatrix class has a function called Size() which returns the number of CRGB elements in the array. So you can use leds.Size() to return the number of LEDs you have. It would be a good idea for you to take a look at the examples and wiki for the cLEDMatrix class as this may answer your questions about it's usage. It will start to make sense once you study it a bit more. I have been doing it so long I forget how baffling it can be when you first start out.
Newer to programming, so hope this isn't something overly stupid.
I have the LEDText examples working, so looking to incorportate that into some other code I'm working on.
Per FastLED, I have
CRGB leds[NumLeds];
Per LED Matrix/Text I have
cLEDMatrix<DisplayWidth, DisplayHeight, HORIZONTAL_ZIGZAG_MATRIX> leds;
These lines both define
leds
from my understanding.And a ton of others. How do I get
CRGB
to work withcLEDMatrix
?