Has anyone made any progress on this yet, I'm trying to port my last working OctoWS over, and can't work out how to make it work with FastLed, the new versions of artnet library I can't work out how to make the library work with multiple universes/pins, and with the old one, FASTled is complaining. The multi output Object fled examples don't seem to help either. As I'm only a part time arduino user, I'm unsure of where to start, new artnet libaries and fastled, or teenys artnet library, and then I can't get form octoWs to fastled. Which is the recomend path to take?
this is my last 32 pin OctoWS version, which does use Fastled but also octoWS
this is my last 32 pin OctoWS version, which does use Fastled but also octoWS
Code:
/*
This example will receive multiple universes via Artnet and control a strip of ws2811 leds via
Paul Stoffregen's excellent OctoWS2811 library: https://www.pjrc.com/teensy/td_libs_OctoWS2811.html
This example may be copied under the terms of the MIT license, see the LICENSE file for details
*/
#define SKETCH "32outputs"
// edit artnet.h to change etherent to NativeEthernet
#include <Artnet.h>
//#include <NativeEthernet.h>
//#include <NativeEthernetUdp.h>
#include <SPI.h>
#include <OctoWS2811.h>
#include <FastLED.h>
#define ETHERNET_BUFFER 540
// Change ip and mac address for your setup
byte ip[] = {2, 0, 0, 5};
byte broadcast[] = {2, 0, 0, 255};
const int ledsPerStrip = 340; // change for your setup 680 4 uni
const byte numStrips= 32; // change for your setup and uncomment below the pin list
//byte pinList[numStrips] = {2,3,4,5,6,7,8,9,10,11,12,13,14,16,17,16,27,28,29,30,31,35,36,37,38,39,40,41,42,43,44,45}; //listed sequentially, can be changed to meet hardware needs
//byte pinList[numStrips] = {37,36,35,34,15,14,39,38,19,18,17,16,23,22,21,20} ;//pinout order for the DTG WS2811 with the adamtech 4xRJ45 Ports
//byte pinList[30] = {37,36,35,34,15,14,39,38,19,18,17,16,23,22,21,20,9,8,7,6,13,12,11,10,27,26,25,24,32,31} ;// 30 outs //no 32 pinout order for the DTG WS2811 with the ada
// byte pinList[12] = {34,35,36,37,38,39,14,15,16,17,18,19}; //pinout order for shop
byte pinList[32] = {34,35,36,37,38,39,14,15,16,17,18,19,20,21,22,23,6,7,8,9,10,11,12,13,24,25,26,27,28,30,31,32}; //pinout order for DTG WS2811 \
//byte pinList[numStrips] = {37,36,35,34};
// OctoWS2811 settings
const int numLeds = ledsPerStrip * numStrips;
const int numberOfChannels = numLeds * 3; // Total number of channels you want to receive (1 led = 3 channels)
//DMAMEM int displayMemory[ledsPerStrip*6];
//int drawingMemory[ledsPerStrip*6];
const int config = WS2811_GRB | WS2811_800kHz;
//OctoWS2811 leds(ledsPerStrip, displayMemory, drawingMemory, config);
// Artnet settings
Artnet artnet;
const int startUniverse = 0; // CHANGE FOR YOUR SETUP most software this is 1, some software send out artnet first universe as 0.
// Check if we got all universes
const int maxUniverses = numberOfChannels / 512 + ((numberOfChannels % 512) ? 1 : 0);
bool universesReceived[maxUniverses];
bool sendFrame = 1;
int previousDataLength = 0;
//set up OctoWS2811 and FastLED for Teensy 4.1
//byte mac[] = {0x04, 0xE9, 0xE5, 0x00, 0x69, 0xEC};
uint8_t mac[6]; //this is determined from the Teensy 4.1 board.
CRGB rgbarray[numStrips * ledsPerStrip];
// These buffers need to be large enough for all the pixels.
// The total number of pixels is "ledsPerStrip * numStrips".
// Each pixel needs 3 bytes, so multiply by 3. An "int" is
// 4 bytes, so divide by 4. The array is created using "int"
// so the compiler will align it to 32 bit memory.
DMAMEM int displayMemory[ledsPerStrip * numStrips * 3 / 4];
int drawingMemory[ledsPerStrip * numStrips * 3 / 4];
OctoWS2811 octo(ledsPerStrip, displayMemory, drawingMemory, WS2811_GRB | WS2811_800kHz, numStrips, pinList);
template <EOrder RGB_ORDER = RGB,
uint8_t CHIP = WS2811_800kHz>
class CTeensy4Controller : public CPixelLEDController<RGB_ORDER, 8, 0xFF>
{
OctoWS2811 *pocto;
public:
CTeensy4Controller(OctoWS2811 *_pocto)
: pocto(_pocto){};
virtual void init() {}
virtual void showPixels(PixelController<RGB_ORDER, 8, 0xFF> &pixels)
{
uint32_t i = 0;
while (pixels.has(1))
{
uint8_t r = pixels.loadAndScale0();
uint8_t g = pixels.loadAndScale1();
uint8_t b = pixels.loadAndScale2();
pocto->setPixel(i++, r, g, b);
pixels.stepDithering();
pixels.advanceData();
}
pocto->show();
}
};
CTeensy4Controller<RGB, WS2811_800kHz> *pcontroller;
char IpString[4];
/////////////////////////////////////////////////////////////////////////////////
void setup()
{
Serial.println(SKETCH);
teensyMAC(mac);
Ethernet.begin(mac, ip);
// Check for Ethernet hardware present
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :(");
while (true) {
delay(1); // do nothing, no point running without Ethernet hardware
}
}
if (Ethernet.linkStatus() == LinkOFF) {
Serial.println("Ethernet cable is not connected.");
}
Serial.println(Ethernet.localIP());
// artnet.setBroadcast(broadcast);
artnet.begin(mac, ip);
// leds.begin();
octo.begin();
pcontroller = new CTeensy4Controller<RGB, WS2811_800kHz>(&octo);
FastLED.addLeds(pcontroller, rgbarray, numStrips * ledsPerStrip);
FastLED.setBrightness(180);
initTest();
// this will be called for each packet received
artnet.setArtDmxCallback(onDmxFrame);
Serial.println("SetupDone");
}
void loop()
{
// we call the read function inside the loop
artnet.read();
// initTest();
}
void onDmxFrame(uint16_t universe, uint16_t length, uint8_t sequence, uint8_t* data, IPAddress remoteIP)
{
sendFrame = 1;
Serial.println(universe);
// Store which universe has got in
if ((universe - startUniverse) < maxUniverses)
universesReceived[universe - startUniverse] = 1;
for (int i = 0 ; i < maxUniverses ; i++)
{
if (universesReceived[i] == 0)
{
sendFrame = 0;
break;
}
}
// read universe and put into the right part of the display buffer
for (int i = 0; i < length / 3; i++)
{
int led = i + (universe - startUniverse) * (previousDataLength / 3);
if (led < numLeds)
octo.setPixel(led, data[i * 3], data[i * 3 + 1], data[i * 3 + 2]);
}
previousDataLength = length;
if (sendFrame)
{
octo.show();
// Serial.println("Show");
// Reset universeReceived to 0
memset(universesReceived, 0, maxUniverses);
}
}
void initTest()
{
Serial.println("Test");
for (int i = 0 ; i < numLeds ; i++)
octo.setPixel(i, 127, 0, 0);
octo.show();
delay(500);
for (int i = 0 ; i < numLeds ; i++)
octo.setPixel(i, 0, 127, 0);
octo.show();
delay(500);
for (int i = 0 ; i < numLeds ; i++)
octo.setPixel(i, 0, 0, 127);
octo.show();
delay(500);
for (int i = 0 ; i < numLeds ; i++)
octo.setPixel(i, 0, 0, 0);
octo.show();
}
void teensyMAC(uint8_t *mac) {
for(uint8_t by=0; by<2; by++) mac[by]=(HW_OCOTP_MAC1 >> ((1-by)*8)) & 0xFF;
for(uint8_t by=0; by<4; by++) mac[by+2]=(HW_OCOTP_MAC0 >> ((3-by)*8)) & 0xFF;
Serial.printf("MAC: %02x:%02x:%02x:%02x:%02x:%02x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
}