Last active
April 19, 2019 20:35
-
-
Save hpwit/7d4ca8a5654bb5b2c9bb0b5dc0d4252a 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
/* | |
XWLGFX lib example 2019 | |
Enjoy! | |
*/ | |
#define FASTLED_ALLOW_INTERRUPTS 0 | |
#include "FastLED.h" | |
#include "XWLGFX.h" | |
#include "I2S.h" | |
#define NUM_OUT 16 | |
#define NUM_LED_PER_OUT 118 | |
#define MAX_LED_OUT NUM_OUT * NUM_LED_PER_OUT | |
#define LED_TYPE WS2812B | |
#define COLOR_ORDER RGB | |
#define LED_PIN1 2 | |
#define LED_PIN2 4 | |
#define LED_PIN3 5 | |
#define LED_PIN4 12 | |
#define LED_PIN5 13 | |
#define LED_PIN6 14 | |
#define LED_PIN7 15 | |
#define LED_PIN8 16 | |
//--------//-------- | |
#define LED_PIN9 17 | |
#define LED_PIN10 18 | |
#define LED_PIN11 19 | |
#define LED_PIN12 21 | |
#define LED_PIN13 22 | |
#define LED_PIN14 23 //25 | |
#define LED_PIN15 25 //33 | |
#define LED_PIN16 26 //32 | |
XWLGFX gfx; | |
CRGB out_leds [MAX_LED_OUT]; | |
uint8_t params[20]; | |
int Pins[16]={2,4,5,12,13,14,15,16,17,18,19,21,22,23,25,26}; | |
I2S controller(0); | |
boolean rmt=false; //to switch between sams (rmt=true) an my drivers | |
void showLEDS() | |
{ | |
if(rmt) | |
FastLED.show(); | |
else | |
controller.showPixels(); | |
} | |
void setup() { | |
// xTaskCreatePinnedToCore(FastLEDshowTask, "FastLEDshowTask", 2000, NULL,2, &FastLEDshowTaskHandle, 0); | |
Serial.begin(115200); | |
if(!rmt) | |
{ | |
controller.initled(out_leds,Pins,NUM_OUT,NUM_LED_PER_OUT); | |
Serial.println("we do I2S"); | |
} | |
else | |
{ | |
Serial.println("we do RMT"); | |
FastLED.addLeds<LED_TYPE, LED_PIN1, COLOR_ORDER>(out_leds, 0, NUM_LED_PER_OUT).setCorrection(TypicalLEDStrip); | |
FastLED.addLeds<LED_TYPE, LED_PIN2, COLOR_ORDER>(out_leds, NUM_LED_PER_OUT, NUM_LED_PER_OUT).setCorrection(TypicalLEDStrip); | |
FastLED.addLeds<LED_TYPE, LED_PIN3, COLOR_ORDER>(out_leds, 2 * NUM_LED_PER_OUT, NUM_LED_PER_OUT).setCorrection(TypicalLEDStrip); | |
FastLED.addLeds<LED_TYPE, LED_PIN4, COLOR_ORDER>(out_leds, 3 * NUM_LED_PER_OUT, NUM_LED_PER_OUT).setCorrection(TypicalLEDStrip); | |
FastLED.addLeds<LED_TYPE, LED_PIN5, COLOR_ORDER>(out_leds, 4 * NUM_LED_PER_OUT, NUM_LED_PER_OUT).setCorrection(TypicalLEDStrip); | |
FastLED.addLeds<LED_TYPE, LED_PIN6, COLOR_ORDER>(out_leds, 5 * NUM_LED_PER_OUT, NUM_LED_PER_OUT).setCorrection(TypicalLEDStrip); | |
FastLED.addLeds<LED_TYPE, LED_PIN7, COLOR_ORDER>(out_leds, 6 * NUM_LED_PER_OUT, NUM_LED_PER_OUT).setCorrection(TypicalLEDStrip); | |
FastLED.addLeds<LED_TYPE, LED_PIN8, COLOR_ORDER>(out_leds, 7 * NUM_LED_PER_OUT, NUM_LED_PER_OUT).setCorrection(TypicalLEDStrip); | |
FastLED.addLeds<LED_TYPE, LED_PIN9, COLOR_ORDER>(out_leds, 8 * NUM_LED_PER_OUT, NUM_LED_PER_OUT).setCorrection(TypicalLEDStrip); | |
FastLED.addLeds<LED_TYPE, LED_PIN10, COLOR_ORDER>(out_leds, 9 * NUM_LED_PER_OUT, NUM_LED_PER_OUT).setCorrection(TypicalLEDStrip); | |
FastLED.addLeds<LED_TYPE, LED_PIN11, COLOR_ORDER>(out_leds, 10 * NUM_LED_PER_OUT, NUM_LED_PER_OUT).setCorrection(TypicalLEDStrip); | |
FastLED.addLeds<LED_TYPE, LED_PIN12, COLOR_ORDER>(out_leds, 11 * NUM_LED_PER_OUT, NUM_LED_PER_OUT).setCorrection(TypicalLEDStrip); | |
FastLED.addLeds<LED_TYPE, LED_PIN13, COLOR_ORDER>(out_leds, 12 * NUM_LED_PER_OUT, NUM_LED_PER_OUT).setCorrection(TypicalLEDStrip); | |
FastLED.addLeds<LED_TYPE, LED_PIN14, COLOR_ORDER>(out_leds, 13 * NUM_LED_PER_OUT, NUM_LED_PER_OUT).setCorrection(TypicalLEDStrip); | |
FastLED.addLeds<LED_TYPE, LED_PIN15, COLOR_ORDER>(out_leds, 14 * NUM_LED_PER_OUT, NUM_LED_PER_OUT).setCorrection(TypicalLEDStrip); | |
FastLED.addLeds<LED_TYPE, LED_PIN16, COLOR_ORDER>(out_leds, 15 * NUM_LED_PER_OUT, NUM_LED_PER_OUT).setCorrection(TypicalLEDStrip); | |
} | |
/* | |
Begin gfx: | |
1. width | |
2. height | |
Super Resolution modificator | |
3. scale width. default 2 | |
4. scale height. default 2 | |
*/ | |
//gfx.begin(NUM_OUT, NUM_LED_PER_OUT); | |
// | |
fill_solid(out_leds,MAX_LED_OUT,CRGB::Red); | |
showLEDS(); | |
delay(2000); | |
// gfx.begin(48, 123, 1, 1); | |
/* | |
* Options for GFX. Let the library know what you want :) | |
*/ | |
params[0] = 100; //Manual mode. At the moment, only he. | |
params[1] = 255; //Global Brightness | |
/* | |
* Scene (Not all scene functions are implemented.Not all scene functions are implemented): | |
* The basis of scenes is the code from DemoReel100 by Mark Kriegsman: | |
* 15 - fire | |
* 25 - bpm | |
* 35 - confetti | |
* Demonstration of Super Resolution features | |
* Change speed to feel the power! :) | |
* 65 - lines | |
* 75 - circles | |
*/ | |
params[2] = 61; //scene | |
params[3] = 255; //Scene Brightness | |
params[4] = 10; //Scene Preset (Implemented for "Fire") | |
params[5] = 0; //Color red Coming soon... | |
params[6] = 0; //Color green | |
params[7] = 0; //Color blue | |
params[8] = 60; //16-bit scene speed by BPM | |
params[9] = 0; //Fractional part 1/256 | |
//Add effect | |
params[10] = 10; //fx - glitter | |
params[11] = 200; //fx bri | |
params[12] = 1; //fx speed BPM. don't use | |
} | |
void loop() { | |
EVERY_N_MILLISECONDS(100/33) { | |
// | |
Serial.println("new frame"); | |
long lastHandle=ESP.getCycleCount(); | |
showLEDS(); | |
Serial.printf("FPS led show: %f \n",(float)240000000/(ESP.getCycleCount() - lastHandle)); | |
long lastHandle2=ESP.getCycleCount(); | |
gfx.handle(params); | |
Serial.printf("HandleTime: %f us\n",(float)(ESP.getCycleCount() - lastHandle2)/240); | |
lastHandle2=ESP.getCycleCount(); | |
gfx.getData(out_leds); | |
Serial.printf("GetTime: %f us\n",(float)(ESP.getCycleCount() - lastHandle2)/240); | |
Serial.printf("Total FPS: %f\n",(float)240000000/(ESP.getCycleCount() - lastHandle)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment