give the pixel strip its own fixture class
This commit is contained in:
parent
20c6da9ca7
commit
d8ef8b3279
|
@ -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 "AbstractRGBA.h"
|
||||
|
||||
/*
|
||||
Constructor
|
||||
*/
|
||||
AbstractRGBA::AbstractRGBA (uint16_t address)
|
||||
: AbstractFixture(address)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
Load data into profile from new DMX
|
||||
*/
|
||||
void AbstractRGBA::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,56 @@
|
|||
/*
|
||||
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_RGBA {
|
||||
uint8_t dmx[4];
|
||||
struct {
|
||||
uint8_t red;
|
||||
uint8_t green;
|
||||
uint8_t blue;
|
||||
uint8_t amber;
|
||||
} __attribute__((packed));
|
||||
};
|
||||
|
||||
class AbstractRGBA
|
||||
: public AbstractFixture
|
||||
{
|
||||
public:
|
||||
AbstractRGBA(uint16_t address);
|
||||
|
||||
const profile_RGBA * profile() {return &profile_;};
|
||||
virtual void recvData(DMX::Universe *); // data recieved callback
|
||||
|
||||
protected:
|
||||
profile_RGBA 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 "AbstractRgbaStrip.h"
|
||||
|
||||
/*
|
||||
Constructor
|
||||
*/
|
||||
AbstractRgbaStrip::AbstractRgbaStrip (uint16_t address, uint8_t pxl_count)
|
||||
: AbstractFixture(address)
|
||||
{
|
||||
for (int p = 0; p < pxl_count; p++)
|
||||
pixels_.push_back(new AbstractRGBA(address + (p * sizeof(profile_RGBA))));
|
||||
}
|
||||
|
||||
/*
|
||||
Load data into profile from new DMX
|
||||
*/
|
||||
void AbstractRgbaStrip::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 "AbstractRGBA.h"
|
||||
#include "../dmx/universe.h"
|
||||
#include <vector>
|
||||
|
||||
using std::vector;
|
||||
|
||||
class AbstractRgbaStrip
|
||||
: public AbstractFixture
|
||||
{
|
||||
public:
|
||||
AbstractRgbaStrip(uint16_t address, uint8_t pxl_count);
|
||||
|
||||
virtual void recvData(DMX::Universe *); // data recieved callback
|
||||
|
||||
protected:
|
||||
vector<AbstractRGBA*> pixels_;
|
||||
};
|
|
@ -29,20 +29,20 @@
|
|||
#include "AbstractFixture.h"
|
||||
#include "../dmx/universe.h"
|
||||
|
||||
typedef union {
|
||||
union strobe_profile {
|
||||
uint8_t dmx[4];
|
||||
struct {
|
||||
uint16_t intensity;
|
||||
uint8_t duration;
|
||||
uint8_t rate;
|
||||
} __attribute__((packed));
|
||||
} strobe_profile_t;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
enum strobe_state {
|
||||
STROBE_INACTIVE,
|
||||
STROBE_ACTIVE_ON,
|
||||
STROBE_ACTIVE_OFF
|
||||
} strobe_state_t;
|
||||
};
|
||||
|
||||
class AbstractStrobe
|
||||
: public AbstractFixture
|
||||
|
@ -50,11 +50,12 @@ class AbstractStrobe
|
|||
public:
|
||||
AbstractStrobe(uint16_t address);
|
||||
|
||||
const strobe_profile * profile() {return &profile_;};
|
||||
void recvData(DMX::Universe *); // data recieved callback
|
||||
|
||||
protected:
|
||||
strobe_state_t state_; // state machine cycle state
|
||||
strobe_profile_t profile_; // dmx data
|
||||
strobe_state state_; // state machine cycle state
|
||||
strobe_profile profile_; // dmx data
|
||||
uint32_t dmxPeriod(uint8_t dmx); // strobe period from dmx value (ms)
|
||||
uint32_t dmxDuration(uint8_t dmx); // strobe duration from dmx value (ms)
|
||||
};
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
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 "EspRgbaStrip.h"
|
||||
|
||||
EspRgbaStrip::EspRgbaStrip(uint16_t address, uint16_t pxl_count)
|
||||
: AbstractRgbaStrip(address, pxl_count)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool EspRgbaStrip::begin(uint8_t pin) {
|
||||
strip_ = new NeoPixelBus<NeoGrbwFeature, Neo800KbpsMethod>(pixels_.size(), pin);
|
||||
strip_->Begin();
|
||||
strip_->Show();
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
Load data into profile from new DMX
|
||||
*/
|
||||
void EspRgbaStrip::recvData(DMX::Universe * univ) {
|
||||
for (int i = 0; i < pixels_.size(); i++) {
|
||||
pixels_[i]->recvData(univ);
|
||||
const profile_RGBA * profile = pixels_[i]->profile();
|
||||
strip_->SetPixelColor(i, RgbwColor(profile->red, profile->green,
|
||||
profile->blue, profile->amber));
|
||||
}
|
||||
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 "AbstractRgbaStrip.h"
|
||||
#include <NeoPixelBus.h>
|
||||
|
||||
|
||||
class EspRgbaStrip
|
||||
: public AbstractRgbaStrip
|
||||
{
|
||||
public:
|
||||
EspRgbaStrip(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<NeoGrbwFeature, Neo800KbpsMethod> * strip_;
|
||||
|
||||
};
|
|
@ -31,12 +31,12 @@
|
|||
#include <ESPmDNS.h>
|
||||
#include <SPIFFS.h>
|
||||
#include <ArduinoOSC.h>
|
||||
#include <NeoPixelBus.h>
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#include "src/wiflash_configure.h"
|
||||
#include "src/wiflash_status.h"
|
||||
#include "src/lib/sacn/receiver-esp.h"
|
||||
#include "src/lib/fixture/EspStrobe.h"
|
||||
#include "src/lib/fixture/EspRgbaStrip.h"
|
||||
|
||||
// ESP logging module
|
||||
#include <esp_log.h>
|
||||
|
@ -44,8 +44,8 @@ static const char* TAG = "WiFlash";
|
|||
|
||||
|
||||
//// device objects
|
||||
EspStrobe *strobe;
|
||||
NeoPixelBus<NeoGrbwFeature, Neo800KbpsMethod> *strip;
|
||||
EspStrobe * strobe;
|
||||
EspRgbaStrip * strip;
|
||||
auto *e131 = new SACN::EspReceiver();
|
||||
auto *httpd = new AsyncWebServer(80);
|
||||
|
||||
|
@ -109,22 +109,6 @@ void startHTTPD() {
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
change pixel strip colours on DMX change
|
||||
*/
|
||||
void recvPixelData(DMX::Universe *universe) {
|
||||
for (int i = 0; i < config::settings.strip_led_count; i++) {
|
||||
uint8_t r, g, b, w;
|
||||
r = universe->slot(config::settings.strip_address + (i * 4) + 0);
|
||||
g = universe->slot(config::settings.strip_address + (i * 4) + 1);
|
||||
b = universe->slot(config::settings.strip_address + (i * 4) + 2);
|
||||
w = universe->slot(config::settings.strip_address + (i * 4) + 3);
|
||||
strip->SetPixelColor(i, RgbwColor(r, g, b, w));
|
||||
}
|
||||
strip->Show();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Arduino powerup
|
||||
*/
|
||||
|
@ -211,14 +195,12 @@ void setup() {
|
|||
|
||||
// pixels
|
||||
if (config::settings.strip_enable) {
|
||||
strip = new EspRgbaStrip(config::settings.strip_address,config::settings.strip_led_count);
|
||||
ESP_LOGI(TAG, "Initializing Pixelmapped LEDs.");
|
||||
|
||||
strip = new NeoPixelBus<NeoGrbwFeature, Neo800KbpsMethod>(config::settings.strip_led_count, config::settings.strip_data_pin);
|
||||
strip->Begin();
|
||||
strip->Show();
|
||||
strip->begin(config::settings.strip_data_pin);
|
||||
e131->subscribe(config::settings.strip_universe);
|
||||
e131->universe(config::settings.strip_universe)->onData(std::bind(&recvPixelData,
|
||||
std::placeholders::_1));
|
||||
e131->universe(config::settings.strip_universe)->onData(std::bind(&EspRgbaStrip::recvData,
|
||||
strip, std::placeholders::_1));
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue