Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <FastLED.h>
- #include "OctoWS2811.h"
- #define NUM_LEDS_STRIP 248
- #define NUM_PINS 12
- #define NUM_LEDS_TABLE NUM_LEDS_STRIP*NUM_PINS // 2976
- #define LED_TYPE WS2812B
- #define COLOR_ORDER RGB
- typedef struct fillgrad {
- uint8_t one;
- uint8_t two;
- uint8_t three;
- uint8_t four;
- uint8_t five;
- uint8_t six;
- } fillgrad_t;
- fillgrad_t fg;
- template <EOrder RGB_ORDER = RGB, uint8_t CHIP = WS2811_800kHz>
- class CTeensy4Controller : public CPixelLEDController<RGB_ORDER, 8, 0xFF>
- {
- OctoWS2811 *pocto;
- public:
- CTeensy4Controller(OctoWS2811 *_pocto)
- : pocto(_pocto){};
- virtual void init() {}
- virtual void showPixels(PixelController<RGB_ORDER, 8, 0xFF> &pixels) {
- uint32_t i = 0;
- while (pixels.has(1)) {
- uint8_t r = pixels.loadAndScale0();
- uint8_t g = pixels.loadAndScale1();
- uint8_t b = pixels.loadAndScale2();
- pocto->setPixel(i++, r, g, b);
- pixels.stepDithering();
- pixels.advanceData();
- }
- pocto->show();
- }
- };
- byte pinList[NUM_PINS] = {0,8,9,1,2,10, 3,11,4,12,5,24};
- DMAMEM int displayMemory[NUM_LEDS_TABLE * 3];
- //DMAMEM int displayMemory[NUM_LEDS_TABLE * 3 / 4]; //also tried this
- int drawingMemory[NUM_LEDS_TABLE * 3];// * 3 / 4];
- //int drawingMemory[NUM_LEDS_TABLE * 3 / 4]; //also tried this
- OctoWS2811 octo(NUM_LEDS_STRIP, displayMemory, drawingMemory,
- WS2811_RGB | WS2811_800kHz, NUM_PINS, pinList);
- CTeensy4Controller<RGB, WS2811_800kHz> *pcontroller;
- CRGB leds[NUM_LEDS_TABLE];
- void setup() {
- octo.begin();
- pcontroller = new CTeensy4Controller<RGB, WS2811_800kHz>(&octo);
- FastLED.addLeds(pcontroller, leds, NUM_LEDS_TABLE);
- fill_solid(leds, NUM_LEDS_TABLE, CRGB::Black);
- FastLED.setBrightness(255);
- }
- void loop() {
- mode_fillgrad();
- FastLED.show();
- }
- void fillgrad_random() {
- fg.one = random8(1,25);
- fg.two = random8(0,10);
- fg.three = random8(200,255);
- fg.four = random8(1,25);
- fg.five = random8(0,10);
- fg.six = random8(200,255);
- }
- void fill_grad() {
- uint8_t starthue = beatsin8(fg.one, fg.two, fg.three);
- uint8_t endhue = beatsin8(fg.four, fg.five, fg.six);
- if (starthue < endhue) {
- fill_gradient(leds, NUM_LEDS_TABLE, CHSV(starthue,255,255), CHSV(endhue,255,255), FORWARD_HUES);
- } else {
- fill_gradient(leds, NUM_LEDS_TABLE, CHSV(starthue,255,255), CHSV(endhue,255,255), BACKWARD_HUES);
- }
- EVERY_N_SECONDS(5) {
- fillgrad_random();
- }
- }
- void mode_fillgrad() {
- EVERY_N_MILLIS(10) {
- fill_grad();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement