Add RGB pixel strips
This commit is contained in:
parent
8f0822f719
commit
d3b4d794c4
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
AbstractRGBA.cpp
|
||||||
|
|
||||||
|
Part of WiFlash_esp32
|
||||||
|
|
||||||
|
Copyright (c) 2021 Kevin Matz (kevin.matz@gmail.com)
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "AbstractRGB.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Constructor
|
||||||
|
*/
|
||||||
|
AbstractRGB::AbstractRGB (uint16_t address)
|
||||||
|
: AbstractFixture(address)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Load data into profile from new DMX
|
||||||
|
*/
|
||||||
|
void AbstractRGB::recvData(DMX::Universe * univ) {
|
||||||
|
// copy data from universe to profile
|
||||||
|
std::copy(univ->data()->begin() + address_,
|
||||||
|
univ->data()->begin() + address_ + sizeof(profile_.dmx),
|
||||||
|
std::begin(profile_.dmx));
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
AbstractRGBA.h
|
||||||
|
|
||||||
|
Part of WiFlash_esp32
|
||||||
|
|
||||||
|
Copyright (c) 2021 Kevin Matz (kevin.matz@gmail.com)
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include "AbstractFixture.h"
|
||||||
|
#include "../dmx/universe.h"
|
||||||
|
|
||||||
|
using std::uint8_t;
|
||||||
|
using std::uint16_t;
|
||||||
|
|
||||||
|
union profile_RGB {
|
||||||
|
uint8_t dmx[3];
|
||||||
|
struct {
|
||||||
|
uint8_t red;
|
||||||
|
uint8_t green;
|
||||||
|
uint8_t blue;
|
||||||
|
} __attribute__((packed));
|
||||||
|
};
|
||||||
|
|
||||||
|
class AbstractRGB
|
||||||
|
: public AbstractFixture
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AbstractRGB(uint16_t address);
|
||||||
|
|
||||||
|
const profile_RGB * profile() {return &profile_;};
|
||||||
|
virtual void recvData(DMX::Universe *); // data recieved callback
|
||||||
|
|
||||||
|
protected:
|
||||||
|
profile_RGB profile_; // dmx data
|
||||||
|
};
|
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
AbstractRgbaStrip.cpp
|
||||||
|
|
||||||
|
Part of WiFlash_esp32
|
||||||
|
|
||||||
|
Copyright (c) 2021 Kevin Matz (kevin.matz@gmail.com)
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "AbstractRgbStrip.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Constructor
|
||||||
|
*/
|
||||||
|
AbstractRgbStrip::AbstractRgbStrip (uint16_t address, uint8_t pxl_count)
|
||||||
|
: AbstractFixture(address)
|
||||||
|
{
|
||||||
|
for (int p = 0; p < pxl_count; p++)
|
||||||
|
pixels_.push_back(new AbstractRGB(address + (p * sizeof(profile_RGB))));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Load data into profile from new DMX
|
||||||
|
*/
|
||||||
|
void AbstractRgbStrip::recvData(DMX::Universe * univ) {
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
AbstractRgbaStrip.h
|
||||||
|
|
||||||
|
Part of WiFlash_esp32
|
||||||
|
|
||||||
|
Copyright (c) 2021 Kevin Matz (kevin.matz@gmail.com)
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "AbstractFixture.h"
|
||||||
|
#include "AbstractRGB.h"
|
||||||
|
#include "../dmx/universe.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
using std::vector;
|
||||||
|
|
||||||
|
class AbstractRgbStrip
|
||||||
|
: public AbstractFixture
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AbstractRgbStrip(uint16_t address, uint8_t pxl_count);
|
||||||
|
|
||||||
|
virtual void recvData(DMX::Universe *); // data recieved callback
|
||||||
|
|
||||||
|
protected:
|
||||||
|
vector<AbstractRGB*> pixels_;
|
||||||
|
};
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
EspRgbaStrip.cpp
|
||||||
|
|
||||||
|
Part of WiFlash_esp32
|
||||||
|
|
||||||
|
Copyright (c) 2020 Kevin Matz (kevin.matz@gmail.com)
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "EspRgbStrip.h"
|
||||||
|
|
||||||
|
EspRgbStrip::EspRgbStrip(uint16_t address, uint16_t pxl_count)
|
||||||
|
: AbstractRgbStrip(address, pxl_count)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EspRgbStrip::begin(uint8_t pin) {
|
||||||
|
strip_ = new NeoPixelBus<NeoRgbFeature, Neo800KbpsMethod>(pixels_.size(), pin);
|
||||||
|
strip_->Begin();
|
||||||
|
strip_->Show();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Load data into profile from new DMX
|
||||||
|
*/
|
||||||
|
void EspRgbStrip::recvData(DMX::Universe * univ) {
|
||||||
|
for (int i = 0; i < pixels_.size(); i++) {
|
||||||
|
pixels_[i]->recvData(univ);
|
||||||
|
const profile_RGB * profile = pixels_[i]->profile();
|
||||||
|
strip_->SetPixelColor(i, RgbColor(profile->red, profile->green, profile->blue));
|
||||||
|
}
|
||||||
|
strip_->Show();
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
EspRgbaStrip.h
|
||||||
|
|
||||||
|
Part of WiFlash_esp32
|
||||||
|
|
||||||
|
Copyright (c) 2020 Kevin Matz (kevin.matz@gmail.com)
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "AbstractRgbStrip.h"
|
||||||
|
#include <NeoPixelBus.h>
|
||||||
|
|
||||||
|
|
||||||
|
class EspRgbStrip
|
||||||
|
: public AbstractRgbStrip
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
EspRgbStrip(uint16_t address, uint16_t pxl_count);
|
||||||
|
|
||||||
|
virtual bool begin(uint8_t); // call in setup()
|
||||||
|
virtual void recvData(DMX::Universe *); // data recieved callback
|
||||||
|
|
||||||
|
private:
|
||||||
|
NeoPixelBus<NeoRgbFeature, Neo800KbpsMethod> * strip_;
|
||||||
|
|
||||||
|
};
|
|
@ -36,6 +36,7 @@
|
||||||
#include "src/wiflash_status.h"
|
#include "src/wiflash_status.h"
|
||||||
#include "src/lib/libESTA/sacn/receiver-esp.h"
|
#include "src/lib/libESTA/sacn/receiver-esp.h"
|
||||||
#include "src/lib/libESTA/fixture/EspStrobe.h"
|
#include "src/lib/libESTA/fixture/EspStrobe.h"
|
||||||
|
#include "src/lib/libESTA/fixture/EspRgbStrip.h"
|
||||||
#include "src/lib/libESTA/fixture/EspRgbaStrip.h"
|
#include "src/lib/libESTA/fixture/EspRgbaStrip.h"
|
||||||
|
|
||||||
// ESP logging module
|
// ESP logging module
|
||||||
|
@ -45,7 +46,8 @@ static const char* TAG = "WiFlash";
|
||||||
|
|
||||||
//// device objects
|
//// device objects
|
||||||
EspStrobe * strobe;
|
EspStrobe * strobe;
|
||||||
EspRgbaStrip * strip;
|
EspRgbStrip * strip;
|
||||||
|
//EspRgbaStrip * strip;
|
||||||
auto *e131 = new SACN::EspReceiver();
|
auto *e131 = new SACN::EspReceiver();
|
||||||
auto *httpd = new AsyncWebServer(80);
|
auto *httpd = new AsyncWebServer(80);
|
||||||
|
|
||||||
|
@ -195,12 +197,15 @@ void setup() {
|
||||||
|
|
||||||
// pixels
|
// pixels
|
||||||
if (config::settings.strip_enable) {
|
if (config::settings.strip_enable) {
|
||||||
strip = new EspRgbaStrip(config::settings.strip_address,config::settings.strip_led_count);
|
strip = new EspRgbStrip(config::settings.strip_address,config::settings.strip_led_count);
|
||||||
|
// strip = new EspRgbaStrip(config::settings.strip_address,config::settings.strip_led_count);
|
||||||
ESP_LOGI(TAG, "Initializing Pixelmapped LEDs.");
|
ESP_LOGI(TAG, "Initializing Pixelmapped LEDs.");
|
||||||
strip->begin(config::settings.strip_data_pin);
|
strip->begin(config::settings.strip_data_pin);
|
||||||
e131->subscribe(config::settings.strip_universe);
|
e131->subscribe(config::settings.strip_universe);
|
||||||
e131->universe(config::settings.strip_universe)->onData(std::bind(&EspRgbaStrip::recvData,
|
e131->universe(config::settings.strip_universe)->onData(std::bind(&EspRgbStrip::recvData,
|
||||||
strip, std::placeholders::_1));
|
strip, std::placeholders::_1));
|
||||||
|
// e131->universe(config::settings.strip_universe)->onData(std::bind(&EspRgbaStrip::recvData,
|
||||||
|
// strip, std::placeholders::_1));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue