Skip to content

Commit 55d78cf

Browse files
committed
correct BLEAdafruitRgbPixel
1 parent 986a0f8 commit 55d78cf

File tree

3 files changed

+32
-7
lines changed

3 files changed

+32
-7
lines changed

libraries/BLEAdafruitService/src/BLEAdafruitService.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,11 @@
3131

3232
#include "services/BLEAdafruitSensor.h"
3333
#include "services/BLEAdafruitTemperature.h"
34-
#include "services/BLEAdafruitTemperature.h"
35-
#include "services/BLEAdafruitRgbPixel.h"
3634
#include "services/BLEAdafruitAccel.h"
3735
#include "services/BLEAdafruitLightSensor.h"
3836
#include "services/BLEAdafruitButton.h"
3937
#include "services/BLEAdafruitTone.h"
38+
#include "services/BLEAdafruitRgbPixel.h"
4039

4140

4241
#endif /* BLEADAFRUITSERVICE_H_ */

libraries/BLEAdafruitService/src/services/BLEAdafruitRgbPixel.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
* THE SOFTWARE.
2323
*/
2424

25-
#include "BLEAdafruitService.h"
25+
#include "bluefruit_common.h"
26+
#include "BLECharacteristic.h"
27+
#include "BLEService.h"
28+
29+
#include "BLEAdafruitRgbPixel.h"
2630

2731
//--------------------------------------------------------------------+
2832
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
@@ -66,10 +70,16 @@ const uint8_t BLEAdafruitRgbPixel::UUID128_CHR_DATA[16] =
6670
BLEAdafruitRgbPixel::BLEAdafruitRgbPixel(void)
6771
: BLEService(UUID128_SERVICE), Pin(UUID128_CHR_PIN), Type(UUID128_CHR_TYPE), Data(UUID128_CHR_DATA)
6872
{
73+
_neo = NULL;
74+
}
6975

76+
err_t BLEAdafruitRgbPixel::begin (Adafruit_NeoPixel_Type* neo_pixel)
77+
{
78+
_neo = neo_pixel;
79+
return begin((uint8_t) _neo->getPin(), 0);
7080
}
7181

72-
err_t BLEAdafruitRgbPixel::begin (/*Adafruit_NeoPixel* neo_pixel*/)
82+
err_t BLEAdafruitRgbPixel::begin(uint8_t pin, uint8_t type)
7383
{
7484
// Invoke base class begin()
7585
VERIFY_STATUS( BLEService::begin() );
@@ -79,14 +89,14 @@ err_t BLEAdafruitRgbPixel::begin (/*Adafruit_NeoPixel* neo_pixel*/)
7989
Pin.setPermission(SECMODE_OPEN, SECMODE_OPEN);
8090
Pin.setFixedLen(1);
8191
VERIFY_STATUS( Pin.begin() );
82-
Pin.write8(0);
92+
Pin.write8(pin);
8393

8494
// Add Characteristic
8595
Type.setProperties(CHR_PROPS_READ | CHR_PROPS_WRITE);
8696
Type.setPermission(SECMODE_OPEN, SECMODE_OPEN);
8797
Type.setFixedLen(1);
8898
VERIFY_STATUS( Type.begin() );
89-
Type.write16(0);
99+
Type.write8(type);
90100

91101
// Add Characteristic
92102
Data.setProperties(CHR_PROPS_WRITE);

libraries/BLEAdafruitService/src/services/BLEAdafruitRgbPixel.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@
2525
#ifndef BLEADAFRUITRGBPIXEL_H_
2626
#define BLEADAFRUITRGBPIXEL_H_
2727

28+
// use Adafruit_CPlay_NeoPixel instead of Adafruit_NeoPixel
29+
#define USE_CPLAY_NEOPIXEL 0
30+
31+
#if USE_CPLAY_NEOPIXEL
32+
#include "Adafruit_CPlay_NeoPixel.h"
33+
#define Adafruit_NeoPixel_Type Adafruit_CPlay_NeoPixel
34+
#else
35+
#include "Adafruit_NeoPixel.h"
36+
#define Adafruit_NeoPixel_Type Adafruit_NeoPixel
37+
#endif
38+
2839
class BLEAdafruitRgbPixel : public BLEService
2940
{
3041
public:
@@ -40,7 +51,12 @@ class BLEAdafruitRgbPixel : public BLEService
4051
BLECharacteristic Data;
4152

4253
BLEAdafruitRgbPixel(void);
43-
virtual err_t begin(void);
54+
virtual err_t begin(Adafruit_NeoPixel_Type* neo);
55+
56+
private:
57+
Adafruit_NeoPixel_Type* _neo;
58+
59+
err_t begin(uint8_t pin, uint8_t type);
4460
};
4561

4662

0 commit comments

Comments
 (0)