Last active
October 6, 2016 20:17
-
-
Save tablatronix/9957ab3fadcfe8354120fef06b45d82f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint8_t *pixels; // global pixel array | |
uint8_t NUMPIXELS = 8; // number of leds/pixels | |
uint8_t NUMBYTES = 3; // bytes per pixel, RGBW = 4, RGB = 3 | |
uint16_t BUFFBYTES = NUMPIXELS*NUMBYTES; // bytes to allocate for pixel array | |
void allocPixelArray(uint8_t numPixels,uint8_t numBytes){ | |
NUMPIXELS = numPixels; | |
NUMBYTES = numBytes; | |
BUFFBYTES = numPixels*numBytes; | |
Serial.println("allocating " + (String)BUFFBYTES + " bytes"); | |
if(pixels) free(pixels); // free memory | |
pixels = (uint8_t *)malloc(BUFFBYTES); // allocate new memory | |
memset(pixels, 0, BUFFBYTES ); | |
} | |
void allocPixelArray(){ | |
allocPixelArray(NUMPIXELS,NUMBYTES); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment