Adafruit-WS2801-Library icon indicating copy to clipboard operation
Adafruit-WS2801-Library copied to clipboard

ESP8266 compatibility

Open tdicola opened this issue 10 years ago • 2 comments

Need to tweak the library slightly to use the right calloc function (appears to be mem_calloc on the ESP8266).

tdicola avatar Sep 17 '15 01:09 tdicola

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.

tdicola avatar Sep 17 '15 01:09 tdicola

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.

thk4711 avatar Dec 02 '15 13:12 thk4711