Hey everyone. I am just getting around to finishing the code i wrote for my parents under cabinet lighting, and when compiling, im getting a strange lengthy message. I wont be able to test the code until i finish installing the actual leds. I don’t really know what all this means. it seems to be all about the line that names LEDS 251-293 Anyone have any ideas? Here is the actual code - http://pastebin.com/dK6er2k4
Yes i also know that Daniel posted a few days ago a way to make all this code alot easier to write with his new CRGBSet coding. I had already counted pixels and written the code so, im just going to use it. http://pastebin.com/miLkSkFf
uint8_t can only hold values from 0-255 - however, some of the elements in your array here:
uint8_t colora[NUM_COLORA]
are greater than 255. You should change the array definition to be:
uint16_t colora[NUM_COLORA]
@Hung_Vu there is nothing wrong with his led definition - if you read further in the code you’ll notice that he’s calling addLeds w/NEOPIXEL directly and isn’t using the LED_TYPE define - that’s not what’s causing the problems he’s having.
@Daniel_Garcia OK. That makes total sense and also fixed the issue when compiling. Here is a question, why bother using the uint8_t? Is there benefits to it sometimes?
A uint8_t takes only 1 byte of ram, a uint16_t takes 2, and a uint32_t takes 32. There’s two reasons to care, both having to do with those sizes.
The first is just about how much memory you’re using. If you have an array with 300 items in it, uint8_t a[300] will take 300 bytes, uint16_t b[300] will take 600 bytes and uint32_t[300] will take 1200 bytes. When you’re using something that only has 2k of ram - this may become important for you
The other is a performance thing on AVR (and mostly a non-issue on ARM). The AVR is an 8-bit processor. Adding two 8-bit numbers together is a single instruction, ADD, which only takes one cycle. Adding two 16-bt numbers together, however, is an ADD followed by an ADC (ADd with Carry) - and so it takes two cycles. adding 2 32-bit numbers is an ADD followed by three ADCs. So, if you’re doing a lot of math operations, larger types come at a performance cost as well.
@Daniel_Garcia OK, thanks for your responses. As you can tell I am still new at this and I really appreciate all your support and dedication to keep us all out of the dark. I plan on taking a class next semester on c++. Hopefully I will be able to connect a lot of the missing dots I see talked about here. Thank you again for your help!