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: ws2812B.hpp
- Revision:
- 2:2d4f2cc38f87
- Parent:
- 1:2d0f84d78ca2
- Child:
- 3:e09aafc9cabe
--- a/ws2812B.hpp Sat Sep 24 06:24:10 2016 +0000
+++ b/ws2812B.hpp Sun Sep 25 10:01:11 2016 +0000
@@ -2,7 +2,7 @@
// SPI を使って WS2812B を点灯するためのクラス(ヘッダ)
// サポートしているボード
// Nucleo-F401RE, Nucleo-F446RE
-// 2016/09/24, Copyright (c) 2016 MIKAMI, Naoki
+// 2016/09/25, Copyright (c) 2016 MIKAMI, Naoki
//----------------------------------------------------
#include "mbed.h"
@@ -16,7 +16,7 @@
namespace Mikami
{
- class WS2812B
+ class WS2812B : public SPI
{
public:
// コンストラクタ
@@ -24,8 +24,10 @@
// = false: 直接 WS2812B に接続する場合
WS2812B(PinName pin, bool inv = false);
+ virtual ~WS2812B() {}
+
void Write(uint32_t x); // 一つの LED へ書き込む
- void Reset(); // 一連の書き込みの最後に実行する
+ void Reset() { wait_us(50); }
void Clear(int k); // k 個の LED を消灯
private:
@@ -36,9 +38,12 @@
void Send3Bytes(uint8_t x0, uint8_t x1, uint8_t x2);
void T0HL() { Send3Bytes(0xFE, 0x00, 0x00); } // 0 を送る
void T1HL() { Send3Bytes(0xFF, 0xFF, 0x00); } // 1 を送る
- void Dummy() { SendByte(0x00); }
- void SendByteNrm(uint8_t x); // データをそのまま送る
+ void SendByteNorm(uint8_t x); // データをそのまま送る
void SendByteInv(uint8_t x); // データを反転して送る
+
+ // コピー・コンストラクタと代入演算子は使用禁止
+ WS2812B(const WS2812B&);
+ WS2812B& operator=(const WS2812B&);
};
}
#endif // STM32F4xx_WS2812B_HPP