mirror of
https://gitlab.com/zwirbel/illucat.git
synced 2025-12-18 02:36:40 +01:00
externalize pixel stuff, add pixel instance to plugin, remove old code
This commit is contained in:
@@ -4,10 +4,42 @@ PixelPlugin::PixelPlugin(NeoPixelConfig cfg, NeoPattern *neoPattern)
|
||||
{
|
||||
pixelConfig = cfg;
|
||||
pixels = neoPattern;
|
||||
pixels->begin();
|
||||
applyConfig(pixelConfig);
|
||||
defaultAnimation();
|
||||
}
|
||||
|
||||
PixelPlugin::PixelPlugin(NeoPattern *neoPattern)
|
||||
{
|
||||
pixels = neoPattern;
|
||||
loadConfigFromFile();
|
||||
applyConfig(pixelConfig);
|
||||
defaultAnimation();
|
||||
}
|
||||
|
||||
PixelPlugin::PixelPlugin()
|
||||
{
|
||||
loadConfigFromFile();
|
||||
pixels = new NeoPattern(pixelConfig.length, pixelConfig.pin, NEO_GRB + NEO_KHZ800);
|
||||
applyConfig(pixelConfig);
|
||||
defaultAnimation();
|
||||
}
|
||||
|
||||
void PixelPlugin::loadConfigFromFile(){
|
||||
if (SPIFFS.begin()){
|
||||
pixelConfig.fromFile(PIXEL_CONFIG_FILE);
|
||||
}
|
||||
}
|
||||
|
||||
void PixelPlugin::applyConfig(NeoPixelConfig cfg)
|
||||
{
|
||||
pixels->setBrightness(pixelConfig.brightness);
|
||||
}
|
||||
|
||||
void PixelPlugin::defaultAnimation() {
|
||||
pixels->RainbowCycle(pixelConfig.updateInterval);
|
||||
animate();
|
||||
}
|
||||
|
||||
void PixelPlugin::activate(Scheduler *userScheduler, Network *network)
|
||||
{
|
||||
subscribe("pixels/colorWheel", bind(&PixelPlugin::colorWheel, this, _1));
|
||||
|
||||
Reference in New Issue
Block a user