Last active
August 10, 2018 20:10
-
-
Save hpwit/8069a68336453b106c9bc3ebf751d756 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <WiFi.h> | |
//#include <ESP8266WiFi.h> | |
#include <WiFiClient.h> | |
#include <Artnet.h> | |
//#define FASTLED_ALLOW_INTERRUPTS 0 | |
//#define INTERRUPT_THRESHOLD 1 | |
#include "FastLED.h" | |
FASTLED_USING_NAMESPACE | |
#define FASTLED_SHOW_CORE 0 | |
#define LED_WIDTH 80 | |
#define LED_HEIGHT 32 | |
#define NUM_LEDS LED_WIDTH*LED_HEIGHT | |
#define UNIVERSE_SIZE 170 | |
#define PIXEL_PER_PIN NUM_LEDS/5 | |
/*we will use 5 pins each pin will drive two 16x16 panel hence 512 pix it will take 15ms to refresh your entire panel instead of 76ms | |
hence having a refresh rate of 65fps instead of 13fps*/ | |
#define PIN1 2 | |
#define PIN2 4 | |
#define PIN3 5 | |
#define PIN4 12 | |
#define PIN5 13 | |
CRGB leds[NUM_LEDS]; | |
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)); | |
FastLED.show(); | |
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("", ""); | |
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()); | |
FastLED.addLeds<WS2812B, PIN1, GRB>(leds, 0*PIXEL_PER_PIN, PIXEL_PER_PIN); | |
FastLED.addLeds<WS2812B, PIN2, GRB>(leds, 1*PIXEL_PER_PIN, PIXEL_PER_PIN); | |
FastLED.addLeds<WS2812B, PIN3, GRB>(leds, 2*PIXEL_PER_PIN, PIXEL_PER_PIN); | |
FastLED.addLeds<WS2812B, PIN4, GRB>(leds, 3*PIXEL_PER_PIN, PIXEL_PER_PIN); | |
FastLED.addLeds<WS2812B, PIN5, GRB>(leds, 4*PIXEL_PER_PIN, PIXEL_PER_PIN); | |
artnet.begin(NUM_LEDS+160,UNIVERSE_SIZE,1); //the number of pixels and the maximum size of your iniverses | |
Serial.printf("nb Universes needed:%d\n",artnet.nbNeededUniverses); | |
} | |
void loop() { | |
artnet.read(); | |
memcpy(leds,artnet.getframe(),NUM_LEDS*sizeof(CRGB)); | |
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