Skip to content

Instantly share code, notes, and snippets.

@hpwit
Last active September 18, 2019 21:29
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 hpwit/7a3d3523af663870cf112d478cf137de to your computer and use it in GitHub Desktop.
Save hpwit/7a3d3523af663870cf112d478cf137de to your computer and use it in GitHub Desktop.
#include <WiFi.h>
//#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <Artnet.h>
#include "FastLED.h"
FASTLED_USING_NAMESPACE
//#include "I2S.h"
#define FASTLED_SHOW_CORE 0
#define NUM_STRIPS 16 //up to 22
#define LED_WIDTH 16
#define LED_HEIGHT 16
#define NUM_LEDS LED_WIDTH*LED_HEIGHT
#define NUM_LEDS_PER_STRIP NUM_LEDS //you distribute your leds over 4 pins
#define UNIVERSE_SIZE NUM_LEDS / 2 //you want to have 16 universes
//that will give you a size of 160 pixels per universes
//your universes numbers need to be from 0.0.0.0 to 0.0.1.0
CRGB leds[NUM_LEDS];
//I2S controller(0);
//int Pins[16]={12,2,4,5,0,13,14,15,16,17,18,19,21,22,23,25};
Artnet artnet;
static TaskHandle_t FastLEDshowTaskHandle2 = 0;
static TaskHandle_t userTaskHandle = 0;
void FastLEDshowESP322()
{
if (userTaskHandle == 0) {
const TickType_t xMaxBlockTime = pdMS_TO_TICKS( 200 );
// -- Store the handle of the current task, so that the show task can
// notify it when it's done
// noInterrupts();
userTaskHandle = xTaskGetCurrentTaskHandle();
// -- Trigger the show task
xTaskNotifyGive(FastLEDshowTaskHandle2);
//to thge contrary to the other one we do not wait for the display task to come back
}
}
void FastLEDshowTask2(void *pvParameters)
{
const TickType_t xMaxBlockTime = pdMS_TO_TICKS( 500 );
// -- Run forever...
for(;;) {
// -- Wait for the trigger
ulTaskNotifyTake(pdTRUE,portMAX_DELAY);
// memcpy(leds,Tpic,LED_WIDTH*LED_HEIGHT*sizeof(CRGB));
memcpy(leds,artnet.getframe(),NUM_LEDS*sizeof(CRGB));
FastLED.show();
// controller.showPixels();
userTaskHandle=0; //so we can't have two display tasks at the same time
}
}
void setup() {
Serial.begin(115200);
xTaskCreatePinnedToCore(FastLEDshowTask2, "FastLEDshowTask2", 1000, NULL,3, &FastLEDshowTaskHandle2, FASTLED_SHOW_CORE);
WiFi.mode(WIFI_STA);
Serial.printf("Connecting ");
WiFi.begin("Keizahpot", "PKeizahpass");
while (WiFi.status() != WL_CONNECTED) {
Serial.println(WiFi.status());
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected.");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
// put your setup code here, to run once:
//FastLED.addLeds<WS2812B, 22>(leds,0, NUM_LEDS);
//FastLED.addLeds<WS2812B, 23>(leds, NUM_LEDS,NUM_LEDS);
FastLED.addLeds<WS2812B, 22>(leds, NUM_LEDS_PER_STRIP,NUM_LEDS_PER_STRIP);
//FastLED.addLeds<WS2812B, 23>(leds, 2*NUM_LEDS_PER_STRIP,NUM_LEDS_PER_STRIP);
//FastLED.addLeds<WS2812B, 12>(leds, 3*NUM_LEDS_PER_STRIP,NUM_LEDS_PER_STRIP);
//FastLED.addLeds<WS2812B, 27>(leds, 4*NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP);
//controller.initled(leds,Pins,NUM_STRIPS,NUM_LEDS_PER_STRIP);
artnet.begin(NUM_LEDS,UNIVERSE_SIZE,1); //the number of pixels and the maximum size of your iniverses 1 represent the buffer
}
void loop() {
artnet.read();
/* in artnet.getframe() you have the content of the frame
for instance you can do*/
FastLEDshowESP322();
artnet.resetsync();
// put your main code here, to run repeatedly:
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment