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.
Revision 4:874beb47b375, committed 2016-11-21
- Comitter:
- MikamiUitOpen
- Date:
- Mon Nov 21 09:28:49 2016 +0000
- Parent:
- 3:e09aafc9cabe
- Commit message:
- 5
Changed in this revision
| ws2812B.cpp | Show annotated file Show diff for this revision Revisions of this file |
| ws2812B.hpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/ws2812B.cpp Mon Sep 26 02:05:50 2016 +0000
+++ b/ws2812B.cpp Mon Nov 21 09:28:49 2016 +0000
@@ -2,21 +2,23 @@
// SPI を使って WS2812B を点灯するためのクラス
// サポートするボード: Nucleo-F401RE, Nucleo-F446RE
//
-// 2016/09/26, Copyright (c) 2016 MIKAMI, Naoki
+// 2016/11/21, Copyright (c) 2016 MIKAMI, Naoki
//--------------------------------------------------------
#include "ws2812B.hpp"
+#include "PeripheralPins.h" // for pinmap_peripheral()
namespace Mikami
{
WS2812B::WS2812B(PinName pin, bool inv)
- : SPI(pin, NC, NC), mySpi_((SPI_TypeDef *)_spi.spi)
+ : spi_(pin, NC, NC),
+ mySpi_((SPI_TypeDef *)pinmap_peripheral(pin, PinMap_SPI_MOSI))
{
- format(8, 0);
+ spi_.format(8, 0);
// クロックを 23 MHz 以下で最大の値に設定
// F401RE: 21.0 MHz
// F446RE: 22.5 MHz
- frequency(23000000);
+ spi_.frequency(23000000);
if (!inv) fp = &WS2812B::SendByteNorm;
else fp = &WS2812B::SendByteInv;
--- a/ws2812B.hpp Mon Sep 26 02:05:50 2016 +0000
+++ b/ws2812B.hpp Mon Nov 21 09:28:49 2016 +0000
@@ -2,7 +2,7 @@
// SPI を使って WS2812B を点灯するためのクラス(ヘッダ)
// サポートするボード: Nucleo-F401RE, Nucleo-F446RE
//
-// 2016/09/26, Copyright (c) 2016 MIKAMI, Naoki
+// 2016/11/21, Copyright (c) 2016 MIKAMI, Naoki
//--------------------------------------------------------
#include "mbed.h"
@@ -16,7 +16,7 @@
namespace Mikami
{
- class WS2812B : public SPI
+ class WS2812B
{
public:
// コンストラクタ
@@ -32,6 +32,7 @@
void Clear(int k); // k 個の LED を消灯
private:
+ SPI spi_;
SPI_TypeDef *mySpi_;
void (WS2812B::*fp)(uint8_t);