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:
- 8:0617f524d67d
- Parent:
- 6:5aff0da4b663
- Child:
- 9:087006b19049
--- a/WS281X.cpp Tue Aug 09 20:07:43 2016 +0000
+++ b/WS281X.cpp Thu Aug 11 07:57:18 2016 +0000
@@ -328,6 +328,35 @@
wait_us(50);
}
+// 指定位置のピクセルへ色配列を指定サイズ分をコピーする
+void WS281X::setColor(int index, RGBColor *color, int len)
+{
+ if (len < 1 || (uint16_t)index >= _numPixels)
+ return;
+ if (index + len > _numPixels)
+ len = _numPixels - index;
+ do
+ {
+ _pixels[index] = *color;
+ ++index;
+ ++color;
+ } while (--len);
+}
+
+// 指定位置のピクセルから指定色を指定サイズ分書き込む
+void WS281X::fillColor(int index, const RGBColor color, int len)
+{
+ if (len < 1 || (uint16_t)index >= _numPixels)
+ return;
+ if (index + len > _numPixels)
+ len = _numPixels - index;
+ do
+ {
+ _pixels[index] = color;
+ ++index;
+ } while (--len);
+}
+
// 先頭から指定サイズ分のブロックをバッファの最後までコピーする
void WS281X::repeatBlock(int block_size)
{
@@ -347,14 +376,14 @@
}
// 指定色でバッファを埋める
-void WS281X::clear(RGBColor color)
+void WS281X::clear(const RGBColor color)
{
_pixels[0] = color;
repeatBlock(1);
}
// 指定色でバッファを埋めた後表示
-void WS281X::show(RGBColor color)
+void WS281X::show(const RGBColor color)
{
clear(color);
show();