Kris Scholte Lubberink
/
SSS_Ble
Ble for smart sOlutions
Diff: source/ColorService.h
- Revision:
- 9:92d861703f96
- Parent:
- 8:369b80cef5ae
- Child:
- 10:d845189d146e
diff -r 369b80cef5ae -r 92d861703f96 source/ColorService.h --- a/source/ColorService.h Tue May 21 13:57:27 2019 +0200 +++ b/source/ColorService.h Tue Jun 11 11:16:55 2019 +0200 @@ -3,7 +3,9 @@ #include "ble/BLE.h" #include "CustomUUIDs.h" -#define STRIP_LENGTH 20 +#include "Adafruit_WS2801/Adafruit_WS2801.h" + +#define STRIP_LENGTH 37 class ColorService { public: @@ -18,6 +20,19 @@ mystrip(Adafruit_WS2801(STRIP_LENGTH, p26,p27, WS2801_RGB)), colorCharacteristic((UUID)CustomUUIDs::UUID_COLOR_CHAR, &color) { + mystrip.begin(); + + for (int z=STRIP_LENGTH; z >= 0 ; z--) { + mystrip.setPixelColor(z, 0xFFFFFF); + mystrip.show(); + } + + wait(0.5); + + for (int z=STRIP_LENGTH; z >= 0 ; z--) { + mystrip.setPixelColor(z, 0); + } + mystrip.show(); static bool serviceAdded = false; /* We should only ever need to add the information service once. */ if (serviceAdded) { return; @@ -59,20 +74,22 @@ printf("You wrote some data... But for which char? \r\n"); printf("%d == %d", handle, colorCharacteristic.getValueHandle());//colorCharacteristic.getValueHandle()); if(handle == colorCharacteristic.getValueHandle()){ - printf("You wrote a color!"); - printf("The value should be an array of integers."); + printf("[PERIPHERAL]\t You wrote a color! \r\n"); + printf("[PERIPHERAL]\t The value should be an array of integers.\r\n"); // color = writeParams->data; int ledIndex = 0; - for (int i=0; i < this->mystrip.numPixels()*4; i+=4) { + /* for (int i=0; i < this->mystrip.getNpixels()*4; i+=4) { color[i] = writeParams->data[i] << 24 | (writeParams->data[i+1] & 0xff) << 16 | (writeParams->data[i+2] & 0xff) << 8| (writeParams->data[i+3] & 0xff); // color[i] = writeParams->data[i]; - this->mystrip.setPixelColor(ledIndex, color[i]); + this->mystrip.setColor(ledIndex, color[i]); ledIndex++; - printf("Index: %d, val %08X \r\n", ledIndex, color[i]); + printf("[PERIPHERAL]\t Index: %d, val %08X \r\n", ledIndex, color[i]); - } + }*/ } - this->mystrip.show(); + printf("[PERIPHERAL]\t Tryna set color\n\r"); +// this->mystrip.show(); + printf("[PERIPHERAL]\t Did that work?\n\r"); } private: BLE& ble;