Permalink
Browse files

Add WS2812Serial driver (#517)

* Update Pintest example

* Use arm/k66 platform for Teensy 3.5

* Add WS2812Serial driver
  • Loading branch information...
PaulStoffregen authored and focalintent committed Nov 2, 2017
1 parent af2beed commit 65a563f58fbfe66fa3ff3d62a19c4ee821c59d28
View
@@ -84,6 +84,7 @@ enum ESPIChipsets {
enum ESM { SMART_MATRIX };
enum OWS2811 { OCTOWS2811,OCTOWS2811_400, OCTOWS2813};
enum SWS2812 { WS2812SERIAL };
#ifdef HAS_PIXIE
template<uint8_t DATA_PIN, EOrder RGB_ORDER> class PIXIE : public PixieController<DATA_PIN, RGB_ORDER> {};
@@ -373,6 +374,15 @@ class CFastLED {
#endif
#ifdef USE_WS2812SERIAL
template<SWS2812 CHIPSET, int DATA_PIN, EOrder RGB_ORDER>
static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
{
static CWS2812SerialController<DATA_PIN,RGB_ORDER> controller;
return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset);
}
#endif
#ifdef SmartMatrix_h
template<ESM CHIPSET>
static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0)
@@ -1,5 +1,5 @@
#include <FastSPI_LED2.h>
#include <FastSPI_LED.h>
const char *getPort(void *portPtr) {
#ifdef PORTA
@@ -102,4 +102,4 @@ void setup() {
void loop() {
CheckPin<MAX_PIN>();
delay(10000);
}
}
View
@@ -313,6 +313,11 @@ UCS1903B LITERAL1
GW6205 LITERAL1
GW6205B LITERAL1
LPD1886 LITERAL1
OCTOWS2811 LITERAL1
OCTOWS2811_400 LITERAL1
OCTOWS2813 LITERAL1
WS2812SERIAL LITERAL1
SMART_MATRIX LITERAL1
# RGB orderings
RGB LITERAL1
View
@@ -10,7 +10,7 @@
#elif defined(__MK20DX128__) || defined(__MK20DX256__)
// Include k20/T3 headers
#include "platforms/arm/k20/led_sysdefs_arm_k20.h"
#elif defined(__MK66FX1M0__)
#elif defined(__MK66FX1M0__) || defined(__MK64FX512__)
// Include k66/T3.6 headers
#include "platforms/arm/k66/led_sysdefs_arm_k66.h"
#elif defined(__MKL26Z64__)
View
@@ -10,7 +10,7 @@
#elif defined(__MK20DX128__) || defined(__MK20DX256__)
// Include k20/T3 headers
#include "platforms/arm/k20/fastled_arm_k20.h"
#elif defined(__MK66FX1M0__)
#elif defined(__MK66FX1M0__) || defined(__MK64FX512__)
// Include k66/T3.6 headers
#include "platforms/arm/k66/fastled_arm_k66.h"
#elif defined(__MKL26Z64__)
@@ -5,6 +5,7 @@
#include "fastpin_arm_k20.h"
#include "fastspi_arm_k20.h"
#include "octows2811_controller.h"
#include "ws2812serial_controller.h"
#include "smartmatrix_t3.h"
#include "clockless_arm_k20.h"
#include "clockless_block_arm_k20.h"
@@ -0,0 +1,46 @@
#ifndef __INC_WS2812SERIAL_CONTROLLER_H
#define __INC_WS2812SERIAL_CONTROLLER_H
#ifdef USE_WS2812SERIAL
FASTLED_NAMESPACE_BEGIN
template<int DATA_PIN, EOrder RGB_ORDER>
class CWS2812SerialController : public CPixelLEDController<RGB_ORDER, 8, 0xFF> {
WS2812Serial *pserial;
uint8_t *drawbuffer,*framebuffer;
void _init(int nLeds) {
if (pserial == NULL) {
drawbuffer = (uint8_t*)malloc(nLeds * 3);
framebuffer = (uint8_t*)malloc(nLeds * 12);
pserial = new WS2812Serial(nLeds, framebuffer, drawbuffer, DATA_PIN, WS2812_RGB);
pserial->begin();
}
}
public:
CWS2812SerialController() { pserial = NULL; }
virtual void init() { /* do nothing yet */ }
virtual void showPixels(PixelController<RGB_ORDER, 8, 0xFF> & pixels) {
_init(pixels.size());
uint8_t *p = drawbuffer;
while(pixels.has(1)) {
*p++ = pixels.loadAndScale0();
*p++ = pixels.loadAndScale1();
*p++ = pixels.loadAndScale2();
pixels.stepDithering();
pixels.advanceData();
}
pserial->show();
}
};
FASTLED_NAMESPACE_END
#endif // USE_WS2812SERIAL
#endif // __INC_WS2812SERIAL_CONTROLLER_H
@@ -5,6 +5,7 @@
#include "fastpin_arm_k66.h"
#include "fastspi_arm_k66.h"
#include "../k20/octows2811_controller.h"
#include "../k20/ws2812serial_controller.h"
#include "../k20/smartmatrix_t3.h"
#include "clockless_arm_k66.h"
#include "clockless_block_arm_k66.h"
@@ -5,5 +5,6 @@
#include "fastpin_arm_kl26.h"
#include "fastspi_arm_kl26.h"
#include "clockless_arm_kl26.h"
#include "../k20/ws2812serial_controller.h"
#endif

0 comments on commit 65a563f

Please sign in to comment.