Created
September 3, 2023 19:01
-
-
Save litui/680c73c55a6056870035bcca44e9a4aa to your computer and use it in GitHub Desktop.
As-is class for using an Adafruit_NeoPXL8 driven device from FastLED as one channel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <Arduino.h> | |
#include <Adafruit_NeoPXL8.h> | |
#include <FastLED.h> | |
class NP8Controller : public CPixelLEDController<RGB, 1, 0xFFFFFFFF> | |
{ | |
Adafruit_NeoPXL8 *_driver; | |
public: | |
NP8Controller(Adafruit_NeoPXL8 *driver) | |
{ | |
_driver = driver; | |
}; | |
virtual void init(){}; | |
virtual void showPixels(PixelController<RGB, 1, 0xFFFFFFFF> &pixels) | |
{ | |
uint32_t i = 0; | |
while (pixels.has(1)) { | |
uint8_t r = pixels.loadAndScale0(); | |
uint8_t g = pixels.loadAndScale1(); | |
uint8_t b = pixels.loadAndScale2(); | |
_driver->setPixelColor(i++, r, g, b); | |
pixels.stepDithering(); | |
pixels.advanceData(); | |
} | |
_driver->show(); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment