adafruit / Adafruit_NeoPixel

Arduino library for controlling single-wire LED pixels (NeoPixel, WS2812, etc.)
GNU Lesser General Public License v3.0
3.05k stars 1.26k forks source link

The allocation of pixels does not reduce program storage and overwrite the program #163

Open ednieuw opened 6 years ago

ednieuw commented 6 years ago

Thank you for opening an issue on an Adafruit Arduino library repository. To improve the speed of resolution please review the following guidelines and common troubleshooting steps below before creating the issue:

If you're sure this issue is a defect in the code and checked the steps above please fill in the following fields to provide enough troubleshooting information. You may delete the guideline and text above to just leave the following details:

ednieuw commented 6 years ago

When using SK6821 LEDs the SoftwareSerial library stops the communication to the LEDs. When the SoftwareSerial library is removed from the program the LEDs works OK. The old slibrary NewSoftwareSerial library also interferes with the communication. With the very old outdated library AFSoftSerial the LEDs works OK, For the second serial communication (to Bluetooth) I use pin BT_RX = 6, BT_TX = 7. changing these pin numbers do not restore communication to the SK6812 LEDs The SK6812 LEDs are connected to pin 5. I use a Arduino Nano When this line, SoftwareSerial Bluetooth(BT_RX, BT_TX); , is removed the communication to the LEDs is working. I upgraded to the Arduino IDE 1.8.5

driverblock commented 6 years ago

Please post a complete sketch which demonstrates the problem, so that we can try to reproduce the problem.

ednieuw commented 6 years ago

DriverBlock.zip Problem After changing from the WS2812 library with WS2812 LEDs to AdaFruit Neopixels to use the SK6812 pixels two problems occurred. 1 The communication to the LEDs on pin 5 stopped when the Bluetooth connection to pin 6 and 7 was started with the SoftwareSerial library. The FAB_LED library gave the same problems but after changing the RX en TX to higher pin numbers 10 and 11 the communication to the LEDs was working again. But this library uses too much memory and also did not work on pins 6&7. To use other pin numbers did not solved the problem with the Neopixel library 2 When typing text in the serial monitor to let the program do some action the text was read properly in function void SerialCheck(void) but is not passed in a String to the processing function ReworkInputString(SerialString); when at line 600 // Serial.print(" Serialstring: "); Serial.println(SerialString); was introduced the function works as expected. After preparing a small extract program, for you to test, no problems were found. Everything works without problems. I removed and added many functions but until now I cannot pinpoint the problem.
An Arduino Nano and UNO behaves identically I attached in the ZIP the small working script, the larger not working script and all the libraries from my Library folder

Thanks in advance Ed

ednieuw commented 6 years ago

After renaming the defines used in my program and names of function calls with the program was rebuilt from the last working version until the communication error occurred. I pin pointed the problem to the three dimensional bool array. When the array bool digit[][3][5] = { { {1, 1, 1, 1, 1}, {1, 0, 0, 0, 1}, {1, 1, 1, 1, 1} }, //0 { {1, 0, 0, 0, 1}, {1, 1, 1, 1, 1}, {0, 0, 0, 0, 1} }, //1 { {1, 0, 1, 1, 1}, {1, 0, 1, 0, 1}, {1, 1, 1, 0, 1} }, //2 { {1, 0, 1, 0, 1}, {1, 0, 1, 0, 1}, {1, 1, 1, 1, 1} }, //3 { {1, 1, 1, 0, 0}, {0, 0, 1, 0, 0}, {1, 1, 1, 1, 1} }, //4 { {1, 1, 1, 0, 0}, {1, 0, 1, 0, 1}, {1, 0, 1, 1, 1} }, //5 { {1, 1, 1, 1, 1}, {0, 0, 1, 0, 1}, {0, 0, 1, 1, 1} }, //6 { {1, 1, 0, 0, 0}, {1, 0, 0, 0, 0}, {1, 1, 1, 1, 1} }, //7 { {1, 1, 1, 1, 1}, {1, 0, 1, 0, 1}, {1, 1, 1, 1, 1} }, //8 { {1, 1, 1, 0, 1}, {1, 0, 1, 0, 1}, {1, 1, 1, 1, 1} } //9 }; Becomes larger than digit[4] no signals are send to the SK6812 LEDs. if( digit[0][3][5] ) { ....} was the statement that stopped the communication. when this line was removed signal were send to the LEDs. After moving this array into PROGMEM the problem is solved. Placing the array into PROGMEM is a work around I can live with. Hope you can find out what stopped communication.

ednieuw commented 6 years ago

Update. As long as sketch size stays under approx. 22500 bytes no problems occur. Looks like a memory problem. The amount of used LEDS in the initialisation: Adafruit_NeoPixel(NUM_LEDS, LED_PIN, NEO_GRBW + NEO_KHZ800); does not change storage space.

NUM_LEDS = 144 LEDs Sketch uses 22224 bytes (72%) of program storage space. Maximum is 30720 bytes. Global variables use 1221 bytes (59%) of dynamic memory, leaving 827 bytes for local variables. Maximum is 2048 bytes. NUM_LEDS = 72 LEDs Sketch uses 22224 bytes (72%) of program storage space. Maximum is 30720 bytes. Global variables use 1221 bytes (59%) of dynamic memory, leaving 827 bytes for local variables. Maximum is 2048 bytes.