Skip to content

Instantly share code, notes, and snippets.

@litui
Created September 3, 2023 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save litui/680c73c55a6056870035bcca44e9a4aa to your computer and use it in GitHub Desktop.
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
#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