Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: WS281X.cpp
- Revision:
- 34:5a141ed5d52a
- Parent:
- 32:64c391617f6c
- Child:
- 35:dffa06d09fdc
--- a/WS281X.cpp	Mon Oct 31 17:50:12 2016 +0000
+++ b/WS281X.cpp	Fri Nov 04 13:19:38 2016 +0000
@@ -416,6 +416,14 @@
     {
         if (index + len > _numPixels)
             len = _numPixels - index;
+
+        if (index < 0)
+		{
+			len = len - (-index);
+			color += (-index);
+			index = 0;
+		}
+
         memcpy(&_pixels[index], color, len * sizeof(_pixels[0]));
     }
 }
@@ -426,6 +434,14 @@
     {
         if (index + len > _numPixels)
             len = _numPixels - index;
+
+        if (index < 0)
+		{
+			len = len - (-index);
+			color += (-index);
+			index = 0;
+		}
+
         RGBColor *dest = &_pixels[index];
         do
         {