Adafruit-WS2801-Library
Adafruit-WS2801-Library copied to clipboard
ESP8266 compatibility
Need to tweak the library slightly to use the right calloc function (appears to be mem_calloc on the ESP8266).
Actually there is no calloc from what I can see, but there is os_malloc which is plain old malloc. We can switch to call malloc/os_malloc and explicitly set all the heap memory to zero with memset.
Just replaced the lines with
numLEDs = ((pixels = (uint8_t *)calloc(n, 3)) != NULL) ? n : 0;
with the following lines
numLEDs = ((pixels = (uint8_t *)malloc(n * 3)) != NULL) ? n : 0;
if ( numLEDs > 0) {
memset(pixels, 0, n * 3);
}
This is now compiling on the AVR plattform and on the ESP8266 as well.