├── .gitmodules ├── 3rdParty └── Spiralight │ └── Spiralight.ino ├── Basic-ESP-Fixtrure ├── Basic-ESP-Fixtrure.ino ├── README.md └── demo.h ├── Crossfade └── Crossfade.ino ├── Datchet_ESP └── Datchet_ESP.ino ├── Deevstock ├── Clouds │ └── Clouds.ino ├── CloudsV1 │ └── CloudsV1.ino ├── CloudsV3 │ └── CloudsV3.ino ├── DSGrid │ ├── Animations.ino │ ├── DSGrid.ino │ ├── DevelopmentTools.ino │ ├── FunkyClouds.ino │ ├── HelperFunctions.ino │ ├── Palettes.ino │ ├── Squares.ino │ ├── Table.ino │ ├── Vortex.ino │ ├── audio-palettes.h │ ├── colours.h │ ├── control_esp.h │ ├── control_null.h │ ├── control_tdmx.h │ ├── control_tdmx_audio.h │ ├── experimental.ino │ ├── neomatrix_config.h │ ├── ota.h │ └── stars.h ├── DSMesh │ ├── DSMesh.ino │ ├── chase.h │ ├── colorWaves.h │ ├── datchet.h │ ├── demo.h │ ├── funkynoise.h │ ├── pride.h │ └── stars.h ├── DeevstockDMX │ ├── AudioPatterns.ino │ ├── DeevstockDMX.ino │ ├── audio.h │ ├── besin.h │ ├── colours.h │ ├── cylon.h │ ├── fillnoise.h │ ├── jugglep.h │ ├── matrix.h │ ├── noisefire.h │ ├── noisefiretest.h │ ├── noisepal.h │ ├── noisewide.h │ ├── onesine.h │ ├── p-datchet.ino │ ├── p-ledTest.ino │ ├── p-rainbow.ino │ ├── p-rainbowSweep.ino │ ├── p-rainbowWash.ino │ ├── p-ripple.ino │ ├── p-shimmer.ino │ ├── p-sinwave_1.ino │ ├── p-snake.ino │ ├── pixel.h │ ├── pixels.h │ ├── plasma.h │ ├── rainbowbit.h │ ├── rainbowg.h │ ├── ripple.h │ ├── soundmems.h │ ├── support.h │ └── z-demoReel.ino └── Test1 │ ├── Test1.ino │ └── p-snake.ino ├── DemoReel100-XMAS └── DemoReel100-XMAS.ino ├── DiodTest ├── Diod_Visualizer_ESP │ ├── Diod_Visualizer_ESP.ino │ └── data │ │ ├── images │ │ └── hsvChart.png │ │ ├── index.html │ │ └── style.css └── Diod_Visualizer_Teensy │ ├── DDAnimations.h │ ├── DDAudio.h │ ├── DDDrawing.h │ ├── DDESPcomm.h │ ├── DDGradients.h │ ├── DDPatternLists.h │ └── Diod_Visualizer_Teensy.ino ├── E131DMX └── E131DMX.ino ├── ESP8266 ├── Cylon_wifi │ └── Cylon_wifi.ino ├── ESP8266_Blink │ └── ESP8266_Blink.ino ├── ESP8266_strandtest │ └── ESP8266_strandtest.ino ├── Snakes_WIFI │ └── Snakes_WIFI.ino ├── WIFIMood │ ├── WIFIMood.ino │ └── index.html └── WifiTest │ └── WifiTest.ino ├── ESP8266_Rings ├── Clock.h ├── Disk.h ├── ESP8266_Rings.ino ├── F_lying_circular.h ├── Spiralight.h └── audio.h ├── FastLED-Patterns ├── Concentric_Squares │ ├── Concentric_Squares.ino │ └── README.md ├── Datchet │ ├── Datchet.ino │ └── README.md ├── Stars │ ├── README.md │ ├── Stars.ino │ └── stars.h └── Table_EQ │ └── Table_EQ.ino ├── FringeThing └── FringeThing.ino ├── MSEQ7_vu_matrix └── MSEQ7_vu_matrix.ino ├── MSGEQ7_FastLED └── MSGEQ7_FastLED.ino ├── MSGEQ7_FastLED_Rings └── MSGEQ7_FastLED_Rings.ino ├── PlasmaAnimation └── PlasmaAnimation.ino ├── SegmentMirror └── SegmentMirror.ino ├── Shimmer └── Shimmer.ino ├── SmartMatrixTests ├── DemoReel100SmartMatrix │ ├── DemoReel100SmartMatrix.ino │ ├── default.h │ └── smartmatrixControl.h └── FeatureDemoTeensy4 │ ├── FeatureDemoTeensy4.ino │ ├── colorwheel.c │ └── gimpbitmap.h ├── Snakes └── Snakes.ino ├── TeensyFFT └── TeensyFFT.ino ├── Tetris └── Tetris.ino ├── Vortex ├── README.md ├── Vortex.ino └── p-vortex.ino ├── VortexSmartMatrix ├── README.md ├── VortexSmartMatrix.ino └── p-vortex.ino ├── hhukgrid └── hhukgrid.ino ├── libraries ├── Adafruit_GFX_Library │ ├── Adafruit_GFX.cpp │ ├── Adafruit_GFX.h │ ├── README.txt │ ├── glcdfont.c │ └── license.txt ├── Adafruit_NeoMatrix │ ├── Adafruit_NeoMatrix.cpp │ ├── Adafruit_NeoMatrix.h │ ├── COPYING │ ├── README.md │ ├── examples │ │ ├── matrixtest │ │ │ └── matrixtest.pde │ │ └── tiletest │ │ │ └── tiletest.pde │ ├── extras │ │ └── gamma.c │ └── gamma.h ├── Adafruit_NeoPixel │ ├── Adafruit_NeoPixel.cpp │ ├── Adafruit_NeoPixel.h │ ├── COPYING │ ├── README.md │ └── examples │ │ ├── goggles │ │ └── goggles.pde │ │ └── strandtest │ │ └── strandtest.ino ├── Adafruit_nRF8001 │ ├── Adafruit_BLE_UART.cpp │ ├── Adafruit_BLE_UART.h │ ├── README.md │ ├── examples │ │ ├── callbackEcho │ │ │ └── callbackEcho.ino │ │ └── echoDemo │ │ │ └── echoDemo.ino │ └── utility │ │ ├── aci.h │ │ ├── aci_cmds.h │ │ ├── aci_evts.h │ │ ├── aci_protocol_defines.h │ │ ├── aci_setup.cpp │ │ ├── aci_setup.h │ │ ├── acilib.cpp │ │ ├── acilib.h │ │ ├── acilib_defs.h │ │ ├── acilib_if.h │ │ ├── acilib_types.h │ │ ├── ble_system.h │ │ ├── dtm.h │ │ ├── hal │ │ ├── hal_aci_tl.h │ │ └── hal_io.h │ │ ├── hal_aci_tl.cpp │ │ ├── hal_platform.h │ │ ├── lib_aci.cpp │ │ ├── lib_aci.h │ │ └── uart │ │ ├── UART_over_BLE.xml │ │ ├── services.h │ │ └── ublue_setup.gen.out.txt ├── QLC │ └── qlc.h ├── ffft │ ├── ffft.S │ └── ffft.h ├── readme.txt └── update-all-libraries.sh ├── patterns ├── p-EQ.ino ├── p-FFT.ino ├── p-VU.ino ├── p-ledTest.ino ├── p-rainbow.ino ├── p-rainbowSweep.ino ├── p-rainbowWash.ino ├── p-ripple.ino ├── p-shimmer.ino ├── p-sinwave_1.ino └── p-snake.ino ├── pulse └── pulse.ino ├── spectrum └── spectrum.ino ├── strandtest_120 └── strandtest_120.ino ├── strandtest_40 └── strandtest_40.ino ├── strandtest_table └── strandtest_table.ino ├── table ├── spectrum_table │ └── spectrum_table.ino ├── table-900 │ ├── p-snake.ino │ └── table-900.ino └── table │ └── table.ino ├── tests ├── INMP441 │ └── INMP441.ino ├── SPH0645 │ └── SPH0645.ino ├── beattest2 │ └── beattest2.ino ├── neomatrixTest │ ├── EQ.ino │ ├── FFT.ino │ ├── VU.ino │ ├── ledTest.ino │ ├── neomatrixTest.ino │ ├── ripple.ino │ └── snake.ino └── rings │ └── rings.ino ├── tiletest_40 └── tiletest_40.ino └── vu_matrix └── vu_matrix.ino /Basic-ESP-Fixtrure/README.md: -------------------------------------------------------------------------------- 1 | Sample project that shows how to create an basic DMX lighting fixture using E1.31 (sACN) running on ESP8266 or ESP32 2 | 3 | You can easily then add your own patterns, change LED config ext to suit your needs 4 | -------------------------------------------------------------------------------- /Basic-ESP-Fixtrure/demo.h: -------------------------------------------------------------------------------- 1 | uint8_t gHue = 0; // rotating "base color" used by many of the patterns 2 | 3 | void rainbow() 4 | { 5 | // FastLED's built-in rainbow generator 6 | fill_rainbow( leds, NUM_LEDS, gHue, 7); 7 | } 8 | 9 | void addGlitter( fract8 chanceOfGlitter) 10 | { 11 | if( random8() < chanceOfGlitter) { 12 | leds[ random16(NUM_LEDS) ] += CRGB::White; 13 | } 14 | } 15 | 16 | void rainbowWithGlitter() 17 | { 18 | // built-in FastLED rainbow, plus some random sparkly glitter 19 | rainbow(); 20 | addGlitter(80); 21 | } 22 | 23 | 24 | void confetti() 25 | { 26 | // random colored speckles that blink in and fade smoothly 27 | fadeToBlackBy( leds, NUM_LEDS, 10); 28 | int pos = random16(NUM_LEDS); 29 | leds[pos] += CHSV( gHue + random8(64), 200, 255); 30 | } 31 | 32 | void sinelon() 33 | { 34 | // a colored dot sweeping back and forth, with fading trails 35 | fadeToBlackBy( leds, NUM_LEDS, 20); 36 | int pos = beatsin16( 13, 0, NUM_LEDS-1 ); 37 | leds[pos] += CHSV( gHue, 255, 192); 38 | } 39 | 40 | void bpm() 41 | { 42 | // colored stripes pulsing at a defined Beats-Per-Minute (BPM) 43 | uint8_t BeatsPerMinute = 62; 44 | CRGBPalette16 palette = PartyColors_p; 45 | uint8_t beat = beatsin8( BeatsPerMinute, 64, 255); 46 | for( int i = 0; i < NUM_LEDS; i++) { //9948 47 | leds[i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10)); 48 | } 49 | } 50 | 51 | void juggle() { 52 | // eight colored dots, weaving in and out of sync with each other 53 | fadeToBlackBy( leds, NUM_LEDS, 20); 54 | byte dothue = 0; 55 | for( int i = 0; i < 8; i++) { 56 | leds[beatsin16( i+7, 0, NUM_LEDS-1 )] |= CHSV(dothue, 200, 255); 57 | dothue += 32; 58 | } 59 | } 60 | 61 | -------------------------------------------------------------------------------- /Deevstock/Clouds/Clouds.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // params - saturation, speed, 4 | 5 | #define LED_PIN D4 6 | 7 | #define COLOR_ORDER RGB 8 | #define CHIPSET WS2811 9 | 10 | #define NUM_LEDS 200 11 | 12 | CRGB leds[NUM_LEDS]; //naming our LED array 13 | 14 | void setup() { 15 | FastLED.addLeds(leds, NUM_LEDS).setCorrection(TypicalSMD5050); 16 | FastLED.setBrightness(255); 17 | } 18 | 19 | void loop() { 20 | addGlitter(); 21 | fadeToBlackBy(leds, NUM_LEDS, 70); 22 | FastLED.delay(40); 23 | 24 | } 25 | 26 | void addGlitter() { 27 | // clusters of leds, souce of 28 | if (random(0, 20) == 0) { 29 | for (int i = 0; i < random(1, NUM_LEDS); i++) { 30 | int r = random16(NUM_LEDS); 31 | for (int j = 0; j < random(1, 15); j++) { 32 | if ((r + j) < NUM_LEDS) { 33 | leds[(r + j)] = CHSV(random(0, 255), 100, 255); 34 | } 35 | } 36 | } 37 | } 38 | } 39 | 40 | 41 | -------------------------------------------------------------------------------- /Deevstock/DSGrid/Squares.ino: -------------------------------------------------------------------------------- 1 | int hue = 0; 2 | int hueOffset = 10; 3 | void squares() { 4 | FastLED.clear(); 5 | for(int i = 0; i < (kMatrixWidth / 2); i++) { 6 | square(i, ColorFromPalette(currentPalette, (hue + (hueOffset * (i * 0.5))), 255, LINEARBLEND)); 7 | } 8 | hue += 8; 9 | if(hue % 4 == 0) hueOffset += 1; 10 | delay(10); 11 | } 12 | 13 | void square(int s, CRGB color) { 14 | int p = (kMatrixWidth - 1) - s; 15 | for(int i = s; i <= p; i++) { 16 | leds[XY(i,s)] = color; 17 | } 18 | for(int i = s; i <= p; i++) { 19 | leds[XY(s,i)] = color; 20 | } 21 | for(int i = s; i <= p; i++) { 22 | leds[XY(p,i)] = color; 23 | } 24 | for(int i = s; i <= p; i++) { 25 | leds[XY(i,p)] = color; 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /Deevstock/DSGrid/Vortex.ino: -------------------------------------------------------------------------------- 1 | class Vortex { 2 | int x = 0; 3 | int y = 0; 4 | int right = 1; 5 | int up = 0; 6 | int w = kMatrixWidth - 1; 7 | int h = kMatrixHeight - 1; 8 | int margin = 0; 9 | int hue; 10 | 11 | public: 12 | Vortex() { 13 | 14 | } 15 | 16 | void vortex() { 17 | leds[ XY(x, y)] = ColorFromPalette(currentPalette, hue, 255, LINEARBLEND); 18 | // End of right 19 | if ((x >= (w - margin)) && (up == 0)) { 20 | up = 1; 21 | right = 0; 22 | // vortexHue += 15; 23 | } 24 | // End of up 25 | else if ((y >= (h - margin)) && (up == 1)) { 26 | up = 0; 27 | right = -1; 28 | // vortexHue += 15; 29 | } 30 | // End of left 31 | else if ((x == (0 + margin)) && (up == 0 && right == -1)) { 32 | up = -1; 33 | right = 0; 34 | // vortexHue += 15; 35 | } 36 | // End of down 37 | else if ((x == (0 + margin) && y == (1 + margin)) && (up == -1 && right == 0)) { 38 | y += up; 39 | up = 0; 40 | right = 1; 41 | hue += 15; 42 | margin++; 43 | y++; 44 | } 45 | 46 | // Final LED 47 | if (right == 0 && up == -1 && margin == ( (kMatrixHeight / 2) - 1)) { // >= 48 | //delay(5000); 49 | hue = random(0, 255); 50 | margin = 0; 51 | x = -1; 52 | y = 0; 53 | right = 1; 54 | up = 0; 55 | } 56 | 57 | // Option toggle? 58 | // fadeLightBy(leds, (kMatrixWidth * kMatrixHeight), 20); 59 | x += right; 60 | y += up; 61 | } 62 | }; 63 | 64 | #define SNAKE_GAP 30 65 | #define NUM_SNAKES (NUM_LEDS / SNAKE_GAP) 66 | Vortex vortexs[NUM_SNAKES]; 67 | 68 | int vortexsStarted = 1; 69 | //int const vortexDelay = ((kMatrixWidth * 2) + (kMatrixHeight * 2) - 1); 70 | int const vortexDelay = SNAKE_GAP; 71 | int vortexGap = 0; 72 | 73 | void vortex() { 74 | 75 | if (vortexsStarted < NUM_SNAKES) { 76 | if (vortexGap == vortexDelay) { 77 | vortexsStarted++; 78 | vortexGap = 0; 79 | } 80 | else { 81 | vortexGap++; 82 | } 83 | } 84 | 85 | for (int i = 0; i < vortexsStarted; i++) { 86 | vortexs[i].vortex(); 87 | } 88 | fadeToBlackBy(leds, NUM_LEDS, map(FADE, 0, 255, 100, 0)); 89 | FastLED.delay(map(SPEED, 0, 255, 70, 0)); 90 | EVERY_N_SECONDS(10) { 91 | Serial.printf("FPS: %u\n", FastLED.getFPS()); 92 | } 93 | } 94 | 95 | 96 | -------------------------------------------------------------------------------- /Deevstock/DSGrid/audio-palettes.h: -------------------------------------------------------------------------------- 1 | CRGB getCRGBForBand(int x, int pal) { 2 | CRGB value; 3 | CHSV hsv; 4 | if(pal == 1) { // bit hacky to use palette id here, but don't want to litter the code with lots of different methods. TODO: add enum for palette creation type 5 | if(x == 1) { 6 | value = CRGB(MSGEQ7get(MSGEQ7_HIGH)/2, MSGEQ7get(MSGEQ7_MID)/2, MSGEQ7get(MSGEQ7_LOW)/2); 7 | } 8 | else if(x == 255) { 9 | value = CRGB(MSGEQ7get(MSGEQ7_HIGH)/2, MSGEQ7get(MSGEQ7_LOW)/2, MSGEQ7get(MSGEQ7_MID)/2); 10 | } 11 | else { 12 | value = CRGB(MSGEQ7get(MSGEQ7_LOW)/2, MSGEQ7get(MSGEQ7_MID)/2, MSGEQ7get(MSGEQ7_HIGH)/2); 13 | } 14 | } 15 | else if(pal == 2) { 16 | int b = map(x, 0, 255, 0, (NUM_GEQ_CHANNELS - 1)); // convert palette position to lower half of freq band 17 | hsv = CHSV(MSGEQ7get(b), 255, 255); // map(MSGEQ7get(b), 0, 255, 30, 255)); // pick hue 18 | hsv2rgb_rainbow(hsv, value); // convert to R,G,B 19 | } 20 | return value; 21 | } 22 | 23 | CRGBPalette16 getAudioPalette(int pal) { 24 | // https://forum.makerforums.info/t/hi-is-it-possible-to-define-a-gradient-palette-at-runtime-the-define-gradient-palette-uses-the/63339 25 | 26 | static uint8_t xyz[16]; // Needs to be 4 times however many colors are being used. 27 | // 3 colors = 12, 4 colors = 16, etc. 28 | 29 | xyz[0] = 0; // anchor of first color - must be zero 30 | xyz[1] = 0; 31 | xyz[2] = 0; 32 | xyz[3] = 0; 33 | 34 | CRGB rgb = getCRGBForBand(1, pal); 35 | xyz[4] = 1; // anchor of first color 36 | xyz[5] = rgb.r; 37 | xyz[6] = rgb.g; 38 | xyz[7] = rgb.b; 39 | 40 | rgb = getCRGBForBand(128, pal); 41 | xyz[8] = 128; 42 | xyz[9] = rgb.r; 43 | xyz[10] = rgb.g; 44 | xyz[11] = rgb.b; 45 | 46 | rgb = getCRGBForBand(255, pal); 47 | xyz[12] = 255; // anchor of last color - must be 255 48 | xyz[13] = rgb.r; 49 | xyz[14] = rgb.g; 50 | xyz[15] = rgb.b; 51 | 52 | CRGBPalette16 p; 53 | return p.loadDynamicGradientPalette(xyz); 54 | } 55 | -------------------------------------------------------------------------------- /Deevstock/DSGrid/control_null.h: -------------------------------------------------------------------------------- 1 | #pragma message No control 2 | 3 | void controlSetup() { 4 | 5 | } 6 | 7 | void controlLoop() { 8 | // placeholder for when no external controls 9 | pgm = 0; 10 | } 11 | 12 | 13 | boolean MSGEQ7read() { 14 | return true; // TODO: add delay 15 | } 16 | 17 | int MSGEQ7get(int band) { 18 | return random(0, 255); 19 | } 20 | 21 | int MSGEQ7get(int band, int channel) { 22 | return random(0, 255); 23 | } 24 | -------------------------------------------------------------------------------- /Deevstock/DSGrid/control_tdmx.h: -------------------------------------------------------------------------------- 1 | #pragma message Teensy 3.2 + MSGEQ7 2 | 3 | #include 4 | 5 | //#define MSGEQ7_10BIT 6 | // MSGEQ7 7 | #include "MSGEQ7.h" 8 | 9 | // MSGEQ7 wiring on spectrum analyser shield 10 | #define MSGEQ7_RESET_PIN 5 11 | #define MSGEQ7_STROBE_PIN 6 12 | #define AUDIO_LEFT_PIN A2 13 | #define AUDIO_RIGHT_PIN A1 14 | #define MSGEQ7_INTERVAL ReadsPerSecond(50) 15 | #define MSGEQ7_SMOOTH 0 16 | 17 | CMSGEQ7 MSGEQ7; 18 | 19 | TeensyDmx Dmx(Serial1); 20 | 21 | void InitMSGEQ7() { 22 | MSGEQ7.begin(); 23 | } 24 | 25 | void controlSetup() { 26 | pinMode(LED_BUILTIN, OUTPUT); 27 | Dmx.setMode(TeensyDmx::DMX_IN); 28 | pgm = 0; 29 | 30 | InitMSGEQ7(); 31 | 32 | delay(1000); 33 | Serial.println("Startup"); 34 | } 35 | 36 | int getValue(int chan, int minV, int maxV) { 37 | return map(Dmx.getBuffer()[(chan - 1)], 0, 255, minV, maxV); 38 | } 39 | 40 | 41 | boolean MSGEQ7read() { 42 | return MSGEQ7.read(MSGEQ7_INTERVAL); 43 | } 44 | 45 | int MSGEQ7get(int band) { 46 | return mapNoise(MSGEQ7.get(band)); 47 | } 48 | 49 | int MSGEQ7get(int band, int channel) { 50 | return mapNoise(MSGEQ7.get(band, channel)); 51 | } 52 | 53 | int led = 0; 54 | 55 | // storage of the 7 10Bit (0-1023) audio band values 56 | int left[7]; 57 | int right[7]; 58 | 59 | void controlLoop() { 60 | Dmx.loop(); 61 | if (Dmx.newFrame()) { 62 | EVERY_N_SECONDS( 2 ) { 63 | Serial.printf("Brighness: %u\n", getValue(1, 0, 255)); // Dimmer data for Channel 1 64 | } 65 | led = !led; 66 | digitalWrite(LED_BUILTIN, led); 67 | int b = getValue(1); // brightness = 1 68 | if (b != BRIGHTNESS) { 69 | BRIGHTNESS = b; 70 | FastLED.setBrightness(BRIGHTNESS); 71 | } 72 | pgm = getValue(2, 0, (gPatternCount - 1)); // pattern = 2 73 | SPEED = getValue(3); // speed = 3 74 | FADE = getValue(4); // fade = 4 75 | currentPalette = getPalette(getValue(5)); // palette = 5 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Deevstock/DSGrid/control_tdmx_audio.h: -------------------------------------------------------------------------------- 1 | #pragma message Teensy 3.2 + MSGEQ7 2 | 3 | #include 4 | 5 | #define NUM_GEQ_CHANNELS 16 6 | 7 | #define MSGEQ7_OUT_MAX 255 8 | #define MSGEQ7_BASS 0 9 | #define MSGEQ7_LOW 0 10 | #define MSGEQ7_MID (NUM_GEQ_CHANNELS / 2) 11 | #define MSGEQ7_HIGH NUM_GEQ_CHANNELS 12 | 13 | 14 | uint8_t fftResult[NUM_GEQ_CHANNELS]; 15 | 16 | TeensyDmx Dmx(Serial1); 17 | 18 | void controlSetup() { 19 | pinMode(LED_BUILTIN, OUTPUT); 20 | Dmx.setMode(TeensyDmx::DMX_IN); 21 | pgm = 0; 22 | 23 | delay(1000); 24 | Serial.println("Startup"); 25 | } 26 | 27 | int getValue(int chan, int minV, int maxV) { 28 | return map(Dmx.getBuffer()[(chan - 1)], 0, 255, minV, maxV); 29 | } 30 | 31 | // storage of the 7 10Bit (0-1023) audio band values 32 | int left[7]; 33 | int right[7]; 34 | 35 | bool newReading; 36 | bool MSGEQ7read() { 37 | return newReading; 38 | } 39 | 40 | int MSGEQ7get(int band) { 41 | // return left[band]; 42 | return fftResult[map(band, 0, 6, 0, (NUM_GEQ_CHANNELS - 1))]; 43 | } 44 | 45 | int MSGEQ7get(int band, int channel) { 46 | return MSGEQ7get(band); 47 | } 48 | 49 | int led = 0; 50 | 51 | // storage of the 7 10Bit (0-1023) audio band values 52 | int left[7]; 53 | int right[7]; 54 | 55 | void controlLoop() { 56 | Dmx.loop(); 57 | if (Dmx.newFrame()) { 58 | EVERY_N_SECONDS( 2 ) { 59 | Serial.printf("Brighness: %u\n", getValue(1, 0, 255)); // Dimmer data for Channel 1 60 | } 61 | led = !led; 62 | digitalWrite(LED_BUILTIN, led); 63 | int b = getValue(1); // brightness = 1 64 | if (b != BRIGHTNESS) { 65 | BRIGHTNESS = b; 66 | FastLED.setBrightness(BRIGHTNESS); 67 | } 68 | pgm = getValue(2, 0, (gPatternCount - 1)); // pattern = 2 69 | SPEED = getValue(3); // speed = 3 70 | FADE = getValue(4); // fade = 4 71 | currentPalette = getPalette(getValue(5)); // palette = 5 72 | 73 | // Serial.println(getValue(400, 0, 255)); 74 | if(getValue(400, 0, 255) > 0) { 75 | newReading = true; 76 | // Serial.println("T"); 77 | } 78 | else { 79 | newReading = false; 80 | Serial.println("F"); 81 | } 82 | for(int b = 0; b < NUM_GEQ_CHANNELS; b++) { 83 | fftResult[b] = getValue((401 + b), 0, 255); 84 | // Serial.printf("%03d ", fftResult[b]); 85 | } 86 | // Serial.println(" "); 87 | 88 | // "Legacy" - for MSGEQ7 patterns 89 | for (int b = 0; b < 7; b++) { 90 | left[b] = map(fftResult[(b * 2)], 0, 255, 0, 1023); 91 | right[b] = left[b]; 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /Deevstock/DSGrid/experimental.ino: -------------------------------------------------------------------------------- 1 | // some stuff which has to prove if its worth to become part of FunkyNoise 2 | 3 | 4 | // All the caleidoscope functions work directly within the screenbuffer (leds array). 5 | // Draw whatever you like in the area x(0-15) and y (0-15) and then copy it arround. 6 | 7 | // rotates the first 16x16 quadrant 3 times onto a 32x32 (+90 degrees rotation for each one) 8 | 9 | void Caleidoscope1() { 10 | for(int x = 0; x < kMatrixWidth / 2 ; x++) { 11 | for(int y = 0; y < kMatrixHeight / 2; y++) { 12 | leds[XY( kMatrixWidth - 1 - x, y )] = leds[XY( y, x )]; 13 | leds[XY( kMatrixWidth - 1 - x, kMatrixHeight - 1 - y )] = leds[XY( x, y )]; 14 | leds[XY( x, kMatrixHeight - 1 - y )] = leds[XY( y, x )]; 15 | } 16 | } 17 | } 18 | 19 | 20 | // mirror the first 16x16 quadrant 3 times onto a 32x32 21 | 22 | void Caleidoscope2() { 23 | for(int x = 0; x < kMatrixWidth / 2 ; x++) { 24 | for(int y = 0; y < kMatrixHeight / 2; y++) { 25 | leds[XY( kMatrixWidth - 1 - x, y )] = leds[XY( x, y )]; 26 | leds[XY( x, kMatrixHeight - 1 - y )] = leds[XY( x, y )]; 27 | leds[XY( kMatrixWidth - 1 - x, kMatrixHeight - 1 - y )] = leds[XY( x, y )]; 28 | } 29 | } 30 | } 31 | 32 | 33 | // copy one diagonal triangle into the other one within a 16x16 34 | 35 | void Caleidoscope3() { 36 | for(int x = 0; x <= CentreX ; x++) { 37 | for(int y = 0; y <= x; y++) { 38 | leds[XY( x, y )] = leds[XY( y, x )]; 39 | } 40 | } 41 | } 42 | 43 | 44 | // copy one diagonal triangle into the other one within a 16x16 (90 degrees rotated compared to Caleidoscope3) 45 | 46 | void Caleidoscope4() { 47 | for(int x = 0; x <= CentreX ; x++) { 48 | for(int y = 0; y <= CentreY-x; y++) { 49 | leds[XY( CentreY - y, CentreX - x )] = leds[XY( x, y )]; 50 | } 51 | } 52 | } 53 | 54 | 55 | // copy one diagonal triangle into the other one within a 8x8 56 | 57 | void Caleidoscope5() { 58 | for(int x = 0; x < kMatrixWidth/4 ; x++) { 59 | for(int y = 0; y <= x; y++) { 60 | leds[XY( x, y )] = leds[XY( y, x )]; 61 | } 62 | } 63 | 64 | for(int x = kMatrixWidth/4; x < kMatrixWidth/2 ; x++) { 65 | for(int y = kMatrixHeight/4; y >= 0; y--) { 66 | leds[XY( x, y )] = leds[XY( y, x )]; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Deevstock/DSGrid/ota.h: -------------------------------------------------------------------------------- 1 | #ifdef ESP32 2 | #include 3 | #else 4 | #include 5 | #endif 6 | #include 7 | #include 8 | 9 | void setupOTA() { 10 | 11 | 12 | // Port defaults to 3232 13 | // ArduinoOTA.setPort(3232); 14 | 15 | // Hostname defaults to esp3232-[MAC] 16 | ArduinoOTA.setHostname("DSGrid"); 17 | 18 | // No authentication by default 19 | // ArduinoOTA.setPassword("admin"); 20 | 21 | // Password can be set with it's md5 value as well 22 | // MD5(admin) = 21232f297a57a5a743894a0e4a801fc3 23 | // ArduinoOTA.setPasswordHash("21232f297a57a5a743894a0e4a801fc3"); 24 | 25 | ArduinoOTA 26 | .onStart([]() { 27 | String type; 28 | if (ArduinoOTA.getCommand() == U_FLASH) 29 | type = "sketch"; 30 | else // U_SPIFFS 31 | type = "filesystem"; 32 | 33 | // NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end() 34 | Serial.println("Start updating " + type); 35 | }) 36 | .onEnd([]() { 37 | Serial.println("\nEnd"); 38 | }) 39 | .onProgress([](unsigned int progress, unsigned int total) { 40 | Serial.printf("Progress: %u%%\r", (progress / (total / 100))); 41 | }) 42 | .onError([](ota_error_t error) { 43 | Serial.printf("Error[%u]: ", error); 44 | if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed"); 45 | else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed"); 46 | else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed"); 47 | else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed"); 48 | else if (error == OTA_END_ERROR) Serial.println("End Failed"); 49 | }); 50 | 51 | ArduinoOTA.begin(); 52 | 53 | Serial.println("ArduinoOTA - Setup Complete"); 54 | Serial.print("IP address: "); 55 | Serial.println(WiFi.localIP()); 56 | } 57 | -------------------------------------------------------------------------------- /Deevstock/DSGrid/stars.h: -------------------------------------------------------------------------------- 1 | class Star { 2 | int p = 0; 3 | int dir = 0; 4 | uint8_t hue = random(0, 255); 5 | int v = 0; 6 | int vary = random(1, 5); 7 | int r = 15; 8 | 9 | public: 10 | Star() { 11 | 12 | } 13 | 14 | void setPixel(int pixel) { 15 | p = pixel; 16 | } 17 | 18 | void sparkle() { 19 | // should we change colour? 20 | if (random(1, r) == 1) { 21 | if (dir > 0) { 22 | hue += vary; 23 | } 24 | else { 25 | hue -= vary; 26 | } 27 | // should we change direction? 28 | if (random(1, 25) == 1) { 29 | dir = random(0, 1); 30 | if (v == 0) v = 255; 31 | } 32 | } 33 | if (v >= 1) v--; 34 | leds[p] = ColorFromPalette(currentPalette, hue, v, LINEARBLEND); 35 | } 36 | }; 37 | 38 | 39 | 40 | Star stars[NUM_LEDS]; 41 | 42 | void showStars() { 43 | static boolean started = false; 44 | if(!started) { 45 | for (int i = 0; i < NUM_LEDS; i++) { 46 | stars[i].setPixel(i); 47 | } 48 | started = true; 49 | } 50 | for (int i = 0; i < NUM_LEDS; i++) { 51 | stars[i].sparkle(); 52 | } 53 | FastLED.delay(0); 54 | } 55 | 56 | 57 | -------------------------------------------------------------------------------- /Deevstock/DSMesh/chase.h: -------------------------------------------------------------------------------- 1 | int p = 0; 2 | void chase() { 3 | leds[p] = ColorFromPalette(currentPalette, gHue, 255, currentBlending); 4 | // FastLED.show(); 5 | gHue += random(0, STEPS); 6 | if (gHue > 255) gHue = 0; 7 | p++; 8 | if (p > ( NUM_LEDS - 1)) p = 0; 9 | for (int i = 0; i < NUM_LEDS; i++) { 10 | leds[i].fadeToBlackBy(FADE); 11 | // leds[i].fadeLightBy(10); 12 | } 13 | FastLED.delay(map(SPEEDO, 0, 255, 200, 0)); 14 | } 15 | -------------------------------------------------------------------------------- /Deevstock/DSMesh/colorWaves.h: -------------------------------------------------------------------------------- 1 | 2 | // ColorWavesWithPalettes by Mark Kriegsman: https://gist.github.com/kriegsman/8281905786e8b2632aeb 3 | // This function draws color waves with an ever-changing, 4 | // widely-varying set of parameters, using a color palette. 5 | void colorwaves( CRGB* ledarray, uint16_t numleds, CRGBPalette16& palette) 6 | { 7 | static uint16_t sPseudotime = 0; 8 | static uint16_t sLastMillis = 0; 9 | static uint16_t sHue16 = 0; 10 | 11 | // uint8_t sat8 = beatsin88( 87, 220, 250); 12 | uint8_t brightdepth = beatsin88( 341, 96, 224); 13 | uint16_t brightnessthetainc16 = beatsin88( 203, (25 * 256), (40 * 256)); 14 | uint8_t msmultiplier = beatsin88(147, 23, 60); 15 | 16 | uint16_t hue16 = sHue16;//gHue * 256; 17 | uint16_t hueinc16 = beatsin88(113, 300, 1500); 18 | 19 | uint16_t ms = millis(); 20 | uint16_t deltams = ms - sLastMillis ; 21 | sLastMillis = ms; 22 | sPseudotime += deltams * msmultiplier; 23 | sHue16 += deltams * beatsin88( 400, 5, 9); 24 | uint16_t brightnesstheta16 = sPseudotime; 25 | 26 | for ( uint16_t i = 0 ; i < numleds; i++) { 27 | hue16 += hueinc16; 28 | uint8_t hue8 = hue16 / 256; 29 | uint16_t h16_128 = hue16 >> 7; 30 | if ( h16_128 & 0x100) { 31 | hue8 = 255 - (h16_128 >> 1); 32 | } else { 33 | hue8 = h16_128 >> 1; 34 | } 35 | 36 | brightnesstheta16 += brightnessthetainc16; 37 | uint16_t b16 = sin16( brightnesstheta16 ) + 32768; 38 | 39 | uint16_t bri16 = (uint32_t)((uint32_t)b16 * (uint32_t)b16) / 65536; 40 | uint8_t bri8 = (uint32_t)(((uint32_t)bri16) * brightdepth) / 65536; 41 | bri8 += (255 - brightdepth); 42 | 43 | uint8_t index = hue8; 44 | //index = triwave8( index); 45 | index = scale8( index, 240); 46 | 47 | CRGB newcolor = ColorFromPalette( palette, index, bri8); 48 | 49 | uint16_t pixelnumber = i; 50 | pixelnumber = (numleds - 1) - pixelnumber; 51 | 52 | nblend( ledarray[pixelnumber], newcolor, 128); 53 | } 54 | } 55 | 56 | void colorWaves() 57 | { 58 | colorwaves( leds, NUM_LEDS, currentPalette); 59 | } 60 | 61 | -------------------------------------------------------------------------------- /Deevstock/DSMesh/datchet.h: -------------------------------------------------------------------------------- 1 | 2 | class Snake { 3 | int p = 0; 4 | int hue = random(0, 255); 5 | int v = random(50, 255); 6 | 7 | public: 8 | Snake() { 9 | } 10 | 11 | void snake() { 12 | leds[p] = CHSV(hue, 255, v); 13 | p++; 14 | if (p > ( NUM_LEDS - 1)) { 15 | p = 0; 16 | hue = random(0, 255); 17 | } 18 | } 19 | }; 20 | 21 | #define NUM_SNAKES 3 22 | Snake snakes[NUM_SNAKES]; 23 | 24 | int snakesStarted = 0; 25 | int const snakeDelay = 20; 26 | int snakeGap = 0; 27 | 28 | void datchet() { 29 | 30 | if (snakesStarted < NUM_SNAKES) { 31 | if (snakeGap == snakeDelay) { 32 | snakesStarted++; 33 | snakeGap = 0; 34 | } 35 | else { 36 | snakeGap++; 37 | } 38 | } 39 | 40 | for (int i = 0; i < snakesStarted; i++) { 41 | snakes[i].snake(); 42 | } 43 | // fadeToBlackBy(leds, NUM_LEDS, 30); 44 | fadeLightBy(leds, NUM_LEDS, 50); 45 | FastLED.delay(50); 46 | } 47 | 48 | -------------------------------------------------------------------------------- /Deevstock/DSMesh/demo.h: -------------------------------------------------------------------------------- 1 | uint8_t gHue = 0; // rotating "base color" used by many of the patterns 2 | 3 | void rainbow() 4 | { 5 | // FastLED's built-in rainbow generator 6 | fill_rainbow( leds, NUM_LEDS, gHue, 7); 7 | } 8 | 9 | void addGlitter( fract8 chanceOfGlitter) 10 | { 11 | if( random8() < chanceOfGlitter) { 12 | leds[ random16(NUM_LEDS) ] += CRGB::White; 13 | } 14 | } 15 | 16 | void rainbowWithGlitter() 17 | { 18 | // built-in FastLED rainbow, plus some random sparkly glitter 19 | rainbow(); 20 | addGlitter(80); 21 | } 22 | 23 | 24 | void confetti() 25 | { 26 | // random colored speckles that blink in and fade smoothly 27 | fadeToBlackBy( leds, NUM_LEDS, 10); 28 | int pos = random16(NUM_LEDS); 29 | leds[pos] += CHSV( gHue + random8(64), 200, 255); 30 | } 31 | 32 | void sinelon() 33 | { 34 | // a colored dot sweeping back and forth, with fading trails 35 | fadeToBlackBy( leds, NUM_LEDS, 20); 36 | int pos = beatsin16( 13, 0, NUM_LEDS-1 ); 37 | leds[pos] += CHSV( gHue, 255, 192); 38 | } 39 | 40 | void bpm() 41 | { 42 | // colored stripes pulsing at a defined Beats-Per-Minute (BPM) 43 | uint8_t BeatsPerMinute = 62; 44 | CRGBPalette16 palette = PartyColors_p; 45 | uint8_t beat = beatsin8( BeatsPerMinute, 64, 255); 46 | for( int i = 0; i < NUM_LEDS; i++) { //9948 47 | leds[i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10)); 48 | } 49 | } 50 | 51 | void juggle() { 52 | // eight colored dots, weaving in and out of sync with each other 53 | fadeToBlackBy( leds, NUM_LEDS, 20); 54 | byte dothue = 0; 55 | for( int i = 0; i < 8; i++) { 56 | leds[beatsin16( i+7, 0, NUM_LEDS-1 )] |= CHSV(dothue, 200, 255); 57 | dothue += 32; 58 | } 59 | } 60 | 61 | -------------------------------------------------------------------------------- /Deevstock/DSMesh/pride.h: -------------------------------------------------------------------------------- 1 | // Pride2015 by Mark Kriegsman: https://gist.github.com/kriegsman/964de772d64c502760e5 2 | // This function draws rainbows with an ever-changing, 3 | // widely-varying set of parameters. 4 | void pride() 5 | { 6 | static uint16_t sPseudotime = 0; 7 | static uint16_t sLastMillis = 0; 8 | static uint16_t sHue16 = 0; 9 | 10 | uint8_t sat8 = beatsin88( 87, 220, 250); 11 | uint8_t brightdepth = beatsin88( 341, 96, 224); 12 | uint16_t brightnessthetainc16 = beatsin88( 203, (25 * 256), (40 * 256)); 13 | uint8_t msmultiplier = beatsin88(147, 23, 60); 14 | 15 | uint16_t hue16 = sHue16;//gHue * 256; 16 | uint16_t hueinc16 = beatsin88(113, 1, 3000); 17 | 18 | uint16_t ms = millis(); 19 | uint16_t deltams = ms - sLastMillis ; 20 | sLastMillis = ms; 21 | sPseudotime += deltams * msmultiplier; 22 | sHue16 += deltams * beatsin88( 400, 5, 9); 23 | uint16_t brightnesstheta16 = sPseudotime; 24 | 25 | for ( uint16_t i = 0 ; i < NUM_LEDS; i++) { 26 | hue16 += hueinc16; 27 | uint8_t hue8 = hue16 / 256; 28 | 29 | brightnesstheta16 += brightnessthetainc16; 30 | uint16_t b16 = sin16( brightnesstheta16 ) + 32768; 31 | 32 | uint16_t bri16 = (uint32_t)((uint32_t)b16 * (uint32_t)b16) / 65536; 33 | uint8_t bri8 = (uint32_t)(((uint32_t)bri16) * brightdepth) / 65536; 34 | bri8 += (255 - brightdepth); 35 | 36 | CRGB newcolor = CHSV( hue8, sat8, bri8); 37 | 38 | uint16_t pixelnumber = i; 39 | pixelnumber = (NUM_LEDS - 1) - pixelnumber; 40 | 41 | nblend( leds[pixelnumber], newcolor, 64); 42 | } 43 | } 44 | 45 | -------------------------------------------------------------------------------- /Deevstock/DSMesh/stars.h: -------------------------------------------------------------------------------- 1 | class Star { 2 | int p = 0; 3 | int dir = 0; 4 | uint8_t hue = random(0, 255); 5 | int v = 0; 6 | int vary = random(1, 5); 7 | int r = 15; 8 | 9 | public: 10 | Star() { 11 | 12 | } 13 | 14 | void setPixel(int pixel) { 15 | p = pixel; 16 | } 17 | 18 | void sparkle() { 19 | // should we change colour? 20 | if (random(1, r) == 1) { 21 | if (dir > 0) { 22 | hue += vary; 23 | } 24 | else { 25 | hue -= vary; 26 | } 27 | // should we change direction? 28 | if (random(1, 25) == 1) { 29 | dir = random(0, 1); 30 | if (v == 0) v = 255; 31 | } 32 | } 33 | if (v >= 1) v--; 34 | leds[p] = CHSV(hue, 255, v); 35 | } 36 | }; 37 | 38 | 39 | 40 | Star stars[NUM_LEDS]; 41 | 42 | void showStars() { 43 | static boolean started = false; 44 | if(!started) { 45 | for (int i = 0; i < NUM_LEDS; i++) { 46 | stars[i].setPixel(i); 47 | } 48 | started = true; 49 | } 50 | for (int i = 0; i < NUM_LEDS; i++) { 51 | stars[i].sparkle(); 52 | } 53 | // FastLED.delay(0); 54 | } 55 | 56 | 57 | -------------------------------------------------------------------------------- /Deevstock/DeevstockDMX/audio.h: -------------------------------------------------------------------------------- 1 | boolean MSGEQ7read() { 2 | return fft_available; 3 | } 4 | #define NUM_GEQ_CHANNELS 16 5 | #define MSGEQ7_OUT_MAX 255 6 | #define MSGEQ7_BASS 0 7 | #define MSGEQ7_LOW 0 8 | #define MSGEQ7_MID (NUM_GEQ_CHANNELS / 2) 9 | #define MSGEQ7_HIGH (NUM_GEQ_CHANNELS - 1) 10 | 11 | 12 | int MSGEQ7get(int band) { 13 | int value = map((fftData[map(band, 0, 6, 0, (NUM_GEQ_CHANNELS - 1))] * 1000), 0, 100, 0, MSGEQ7_OUT_MAX); // TODO: should be 100, but testing at home 14 | // float value = fftData[map(band, 0, 6, 0, (NUM_GEQ_CHANNELS - 1))] * 10000;// // map((fftData[map(band, 0, 6, 0, NUM_GEQ_CHANNELS)] * 100), 0, 100, 0, MSGEQ7_OUT_MAX); // TODO: should be 100, but testing at home 15 | // Serial.printf("Band: %u = %f\n", band, value); 16 | return (int) value; 17 | } 18 | 19 | int MSGEQ7get(int band, int channel) { 20 | return MSGEQ7get(band); 21 | } 22 | 23 | int mapNoise(int value) { 24 | return value; // TODO: fitler noise 25 | } 26 | -------------------------------------------------------------------------------- /Deevstock/DeevstockDMX/besin.h: -------------------------------------------------------------------------------- 1 | #ifndef besin_H 2 | #define besin_H 3 | 4 | void besin() { // Add a Perlin noise soundbar. This looks really cool. 5 | 6 | // Local definitions 7 | 8 | 9 | // Persistent local variables 10 | 11 | 12 | timeval = 30; // Our EVERY_N_MILLIS_I timer value. 13 | 14 | 15 | // This works. 16 | ledsAudio[NUM_AUDIO_LEDS/2] = ColorFromPalette(currentPalette, millis(), sampleavg, NOBLEND); 17 | ledsAudio[NUM_AUDIO_LEDS/2-1] = ColorFromPalette(currentPalette, millis(), sampleavg, NOBLEND); 18 | 19 | 20 | // ledsAudio[NUM_AUDIO_LEDS/2] = ColorFromPalette(currentPalette, sampleavg, beatsin8(sampleavg,0,255), NOBLEND); 21 | // ledsAudio[NUM_AUDIO_LEDS/2-1] = ColorFromPalette(currentPalette, sampleavg, beatsin8(sampleavg,0,255), NOBLEND); 22 | 23 | 24 | waveit(); // Move the pixels to the left/right, but not too fast. 25 | 26 | // fadeToBlackBy(ledsAudio+NUM_AUDIO_LEDS/2-1, 2, 128); // Fade the center, while waveit moves everything out to the edges. 27 | fadeToBlackBy(ledsAudio, NUM_AUDIO_LEDS, 2); 28 | 29 | showSegments(); 30 | } // besin() 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /Deevstock/DeevstockDMX/cylon.h: -------------------------------------------------------------------------------- 1 | void fadeall() { 2 | for (int i = 0; i < NUM_AUDIO_LEDS; i++) { 3 | ledsAudio[i].nscale8(FADE); 4 | } 5 | } 6 | int cylonDir = 1; 7 | void cylon() { 8 | static uint8_t hue = 0; 9 | static uint8_t i = 0; 10 | 11 | // First slide the led in one direction 12 | if(i > NUM_AUDIO_LEDS) { 13 | if(cylonDir == 1) { 14 | cylonDir = -1; 15 | } 16 | else { 17 | cylonDir = 1; 18 | } 19 | } 20 | i += cylonDir; 21 | 22 | // Set the i'th led to red 23 | hue += STEPS; 24 | ledsAudio[i] = ColorFromPalette(currentPalette, hue, 255, currentBlending); 25 | // Show the leds 26 | showSegments(); 27 | // now that we've shown the leds, reset the i'th led to black 28 | // leds[i] = CRGB::Black; 29 | fadeall(); 30 | // Wait a little bit before we loop around and do it again 31 | FastLED.delay(map(SPEEDO, 0, 255, 100, 0)); 32 | 33 | // Now go in the other direction. 34 | for(int i = (NUM_AUDIO_LEDS)-1; i >= 0; i--) { 35 | // Set the i'th led to red 36 | ledsAudio[i] = ColorFromPalette(currentPalette, hue, 255, currentBlending); 37 | // Show the leds 38 | showSegments(); 39 | // now that we've shown the leds, reset the i'th led to black 40 | // leds[i] = CRGB::Black; 41 | fadeall(); 42 | // Wait a little bit before we loop around and do it again 43 | FastLED.delay(map(SPEEDO, 0, 255, 100, 0)); 44 | } 45 | 46 | } 47 | 48 | 49 | -------------------------------------------------------------------------------- /Deevstock/DeevstockDMX/fillnoise.h: -------------------------------------------------------------------------------- 1 | #ifndef FILLNOISE_H 2 | #define FILLNOISE_H 3 | 4 | void fillnoise() { // Add a Perlin noise soundbar. This looks really cool. 5 | 6 | // Local definitions 7 | #define xscale 160 8 | #define yscale 160 9 | 10 | // Persistent local variables 11 | static int16_t xdist; // A random number for our noise generator. 12 | static int16_t ydist; 13 | 14 | 15 | timeval = 40; // Our EVERY_N_MILLIS_I timer value. 16 | 17 | if (sampleavg > NUM_AUDIO_LEDS) sampleavg = NUM_AUDIO_LEDS; // Clip the sampleavg to maximize at NUM_AUDIO_LEDS. 18 | 19 | for (int i= (NUM_AUDIO_LEDS-sampleavg/2)/2; i<(NUM_AUDIO_LEDS+sampleavg/2)/2; i++) { // The louder the sound, the wider the soundbar. 20 | uint8_t index = inoise8(i*sampleavg+xdist, ydist+i*sampleavg); // Get a value from the noise function. I'm using both x and y axis. 21 | ledsAudio[i] = ColorFromPalette(currentPalette, index, sampleavg, LINEARBLEND); // With that value, look up the 8 bit colour palette value and assign it to the current LED. 22 | } // Effect is a NOISE bar the width of sampleavg. Very fun. By Andrew Tuline. 23 | 24 | xdist=xdist+beatsin8(5,0,3); // Moving forward in the NOISE field, but with a sine motion. 25 | ydist=ydist+beatsin8(4,0,3); // Moving sideways in the NOISE field, but with a sine motion. 26 | 27 | addGlitter(sampleavg/2); // Add glitter based on sample and not peaks. 28 | 29 | waveit(); // Move the pixels to the left/right, but not too fast. 30 | 31 | fadeToBlackBy(ledsAudio+NUM_AUDIO_LEDS/2-1, 2, 128); // Fade the center, while waveit moves everything out to the edges. 32 | 33 | showSegments(); 34 | } // fillnoise() 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /Deevstock/DeevstockDMX/jugglep.h: -------------------------------------------------------------------------------- 1 | #ifndef JUGGLEP_H 2 | #define JUGGLEP_H 3 | 4 | void jugglep() { // Use the juggle routine, but adjust the timebase based on sampleavg for some randomness. 5 | 6 | // Persistent local variables 7 | static uint8_t curhue; // Let's rotate the hue. 8 | static int thistime = 20; // Time shifted value keeps changing thus interrupting the juggle pattern. 9 | 10 | timeval = 20; // Our EVERY_N_MILLIS_I timer value. 11 | 12 | curhue = curhue + 4; // Change the hue pretty quickly, so that the juggle changes colours on the fly. 13 | 14 | fadeToBlackBy(ledsAudio, NUM_AUDIO_LEDS, 12); // Fade the strand. 15 | 16 | ledsAudio[beatsin16(thistime,0,NUM_AUDIO_LEDS-1, 0, 0)] += ColorFromPalette( currentPalette, curhue, sampleavg, currentBlending); 17 | ledsAudio[beatsin16(thistime-3,0,NUM_AUDIO_LEDS-1, 0, 0)] += ColorFromPalette( currentPalette, curhue, sampleavg, currentBlending); 18 | 19 | 20 | EVERY_N_MILLISECONDS(250) { 21 | thistime = sampleavg/2; // Change the beat frequency every 250 ms. By Andrew Tuline. 22 | } 23 | 24 | addGlitter(sampleavg/2); // Add glitter based on sampleavg. 25 | showSegments(); 26 | } 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /Deevstock/DeevstockDMX/matrix.h: -------------------------------------------------------------------------------- 1 | #ifndef MATRIX_H 2 | #define MATRIX_H 3 | 4 | void matrix() { // A 'Matrix' like display using sampleavg for brightness. Also add glitter based on peaks (and not sampleavg). 5 | 6 | // Persistent local variables 7 | static uint8_t thishue=0; 8 | 9 | timeval = 40; // Our EVERY_N_MILLIS_I timer value. 10 | 11 | ledsAudio[0] = ColorFromPalette(currentPalette, thishue++, sampleavg, LINEARBLEND); 12 | 13 | for (int i = NUM_AUDIO_LEDS-1; i >0 ; i-- ) ledsAudio[i] = ledsAudio[i-1]; 14 | 15 | addGlitter(sampleavg/2); // Add glitter based on sampleavg. By Andrew Tuline. 16 | showSegments(); 17 | 18 | } // matrix() 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /Deevstock/DeevstockDMX/noisefire.h: -------------------------------------------------------------------------------- 1 | #ifndef NOISEFIRE_H 2 | #define NOISEFIRE_H 3 | 4 | void noisefire() { // Create fire based on noise and sampleavg. 5 | 6 | // Local definitions 7 | #define xscale 20 // How far apart they are 8 | #define yscale 3 // How fast they move 9 | 10 | // Temporary local variable 11 | uint8_t index = 0; // Current colour lookup value. 12 | 13 | timeval = 0; // Our EVERY_N_MILLIS_I timer value. 14 | 15 | currentPalette = CRGBPalette16(CHSV(0,255,2), CHSV(0,255,4), CHSV(0,255,8), CHSV(0, 255, 8), // Fire palette definition. Lower value = darker. 16 | CHSV(0, 255, 16), CRGB::Red, CRGB::Red, CRGB::Red, 17 | CRGB::DarkOrange,CRGB::DarkOrange, CRGB::Orange, CRGB::Orange, 18 | CRGB::Yellow, CRGB::Orange, CRGB::Yellow, CRGB::Yellow); 19 | 20 | for(int i = 0; i < NUM_AUDIO_LEDS; i++) { 21 | index = inoise8(i*xscale,millis()*yscale*NUM_AUDIO_LEDS/255); // X location is constant, but we move along the Y at the rate of millis(). By Andrew Tuline. 22 | 23 | index = (255 - i*256/NUM_AUDIO_LEDS) * index/128; // Now we need to scale index so that it gets blacker as we get close to one of the ends 24 | // This is a simple y=mx+b equation that's been scaled. index/128 is another scaling. 25 | ledsAudio[i] = ColorFromPalette(currentPalette, index, sampleavg, NOBLEND); // With that value, look up the 8 bit colour palette value and assign it to the current LED. 26 | } // The higher the value of i => the higher up the palette index (see palette definition). 27 | showSegments(); 28 | } // noisefire() 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /Deevstock/DeevstockDMX/noisefiretest.h: -------------------------------------------------------------------------------- 1 | #ifndef NOISEFIRETEST_H 2 | #define NOISEFIRETEST_H 3 | 4 | void noisefiretest() { // Create fire based on noise and sampleavg. 5 | 6 | // Local definitions 7 | #define xscale 20 // How far apart they are 8 | #define yscale 3 // How fast they move 9 | 10 | // Temporary local variable 11 | uint16_t index = 0; // Current colour lookup value. 12 | 13 | timeval = 10; // Our EVERY_N_MILLIS_I timer value. 14 | 15 | currentPalette = CRGBPalette16(CHSV(0,255,2), CHSV(0,255,4), CHSV(0,255,8), CHSV(0, 255, 8), // Fire palette definition. Lower value = darker. 16 | CHSV(0, 255, 16), CRGB::Red, CRGB::Red, CRGB::Red, 17 | CRGB::DarkOrange,CRGB::DarkOrange, CRGB::Orange, CRGB::Orange, 18 | CRGB::Yellow, CRGB::Orange, CRGB::Yellow, CRGB::Yellow); 19 | 20 | for(int i = 0; i < NUM_AUDIO_LEDS; i++) { 21 | 22 | // Serial.print(i); 23 | // Serial.print(" "); 24 | index = inoise8(i*xscale,millis()*yscale*NUM_AUDIO_LEDS/255); // X location is constant, but we move along the Y at the rate of millis(). By Andrew Tuline. 25 | // Serial.print(index); 26 | // Serial.print(" "); 27 | 28 | // index = (255 - *i*128/NUM_AUDIO_LEDS); // Now we need to scale index so that it gets blacker as we get close to one of the ends 29 | 30 | index = (255 - i*256/NUM_AUDIO_LEDS) * index / 128; // Now we need to scale index so that it gets blacker as we get close to one of the ends 31 | 32 | 33 | // Serial.print(index); 34 | // Serial.println(" "); 35 | 36 | 37 | ledsAudio[NUM_AUDIO_LEDS/2-i/2+1] = ColorFromPalette(currentPalette, index, sampleavg, NOBLEND); // With that value, look up the 8 bit colour palette value and assign it to the current LED. 38 | ledsAudio[NUM_AUDIO_LEDS/2+i/2-1] = ColorFromPalette(currentPalette, index, sampleavg, NOBLEND); // With that value, look up the 8 bit colour palette value and assign it to the current LED. 39 | 40 | } // The higher the value of i => the higher up the palette index (see palette definition). 41 | showSegments(); 42 | 43 | } // noisefiretest() 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /Deevstock/DeevstockDMX/noisepal.h: -------------------------------------------------------------------------------- 1 | #ifndef NOISEPAL_H 2 | #define NOISEPAL_H 3 | 4 | void noisepal() { // Create fire based on noise and sampleavg. 5 | 6 | // Local definitions 7 | #define xscale 20 // How far apart they are 8 | #define yscale 3 // How fast they move 9 | 10 | // Temporary local variable 11 | uint16_t index = 0; // Current colour lookup value. 12 | 13 | timeval = 10; // Our EVERY_N_MILLIS_I timer value. 14 | 15 | /* currentPalette = CRGBPalette16(CHSV(0,255,2), CHSV(0,255,4), CHSV(0,255,8), CHSV(0, 255, 8), // Fire palette definition. Lower value = darker. 16 | CHSV(0, 255, 16), CRGB::Red, CRGB::Red, CRGB::Red, 17 | CRGB::DarkOrange,CRGB::DarkOrange, CRGB::Orange, CRGB::Orange, 18 | CRGB::Yellow, CRGB::Orange, CRGB::Yellow, CRGB::Yellow); 19 | */ 20 | 21 | 22 | for(int i = 0; i < NUM_AUDIO_LEDS; i++) { 23 | 24 | // Serial.print(i); 25 | // Serial.print(" "); 26 | index = inoise8(i*xscale,millis()*yscale*NUM_AUDIO_LEDS/255); // X location is constant, but we move along the Y at the rate of millis(). By Andrew Tuline. 27 | // Serial.print(index); 28 | // Serial.print(" "); 29 | 30 | // index = (255 - *i*128/NUM_AUDIO_LEDS); // Now we need to scale index so that it gets blacker as we get close to one of the ends 31 | 32 | index = (255 - i*256/NUM_AUDIO_LEDS) * index / 128; // Now we need to scale index so that it gets blacker as we get close to one of the ends 33 | 34 | 35 | // Serial.print(index); 36 | // Serial.println(" "); 37 | 38 | 39 | ledsAudio[NUM_AUDIO_LEDS/2-i/2+1] = ColorFromPalette(currentPalette, index, sampleavg, NOBLEND); // With that value, look up the 8 bit colour palette value and assign it to the current LED. 40 | ledsAudio[NUM_AUDIO_LEDS/2+i/2-1] = ColorFromPalette(currentPalette, index, sampleavg, NOBLEND); // With that value, look up the 8 bit colour palette value and assign it to the current LED. 41 | 42 | } // The higher the value of i => the higher up the palette index (see palette definition). 43 | showSegments(); 44 | 45 | } // noisepalt() 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /Deevstock/DeevstockDMX/noisewide.h: -------------------------------------------------------------------------------- 1 | #ifndef NOISEWIDE_H 2 | #define NOISEWIDE_H 3 | 4 | void noisewide() { 5 | 6 | timeval = 10; // Our EVERY_N_MILLIS_I timer value. 7 | 8 | uint8_t tempsamp = constrain(sampleavg/2,0,NUM_AUDIO_LEDS/2); 9 | 10 | memset(ledsAudio, 0, NUM_AUDIO_LEDS * 3); // Quick clearing of the LED's. 11 | 12 | for (int i=0; i> 4; // millis() can be used for so many things. 29 | 30 | for (int k=0; k ( NUM_LEDS - 1)) { 15 | p=0; 16 | hue = random(0,255); 17 | } 18 | } 19 | }; 20 | 21 | #define NUM_DSNAKES 40 22 | DSnake dsnakes[NUM_DSNAKES]; 23 | 24 | int dsnakesStarted = 0; 25 | int const dsnakeDelay = 20; 26 | int dsnakeGap = 0; 27 | 28 | void dsnake() { 29 | 30 | if (dsnakesStarted < NUM_DSNAKES) { 31 | if (dsnakeGap == dsnakeDelay) { 32 | dsnakesStarted++; 33 | dsnakeGap = 0; 34 | } 35 | else { 36 | dsnakeGap++; 37 | } 38 | } 39 | 40 | for (int i = 0; i < dsnakesStarted; i++) { 41 | dsnakes[i].snake(); 42 | } 43 | fadeToBlackBy(leds, NUM_LEDS, map(FADE,0,255, 100, 1)); 44 | // fadeLightBy(leds, NUM_LEDS, map(STEPS,0,255, 0, 100)); 45 | FastLED.delay(map(SPEEDO,0,255, 100, 10)); // TWEAK ME (was 40) 46 | } 47 | 48 | -------------------------------------------------------------------------------- /Deevstock/DeevstockDMX/p-ledTest.ino: -------------------------------------------------------------------------------- 1 | void ledtest() { 2 | int hue = 0; 3 | for (int y = 0; y < kMatrixHeight; y++) { 4 | for (int x = 0; x < kMatrixWidth; x++) { 5 | leds[ XY(x, y)] = ColorFromPalette(currentPalette, hue, 255, currentBlending); 6 | FastLED.delay(50); 7 | leds[ XY(x, y)] = CRGB::Black; 8 | hue += 5; 9 | if (hue > 255) hue = 0; 10 | } 11 | } 12 | // for (int i = 0; i < NUM_LEDS; i++) { 13 | // leds[i] = CHSV( 100, 255, 255); 14 | // FastLED.delay(100); 15 | // leds[i] = CRGB::Black; 16 | // hue += 5; 17 | // if (hue > 255) hue = 0; 18 | // } 19 | } 20 | 21 | 22 | -------------------------------------------------------------------------------- /Deevstock/DeevstockDMX/p-rainbow.ino: -------------------------------------------------------------------------------- 1 | // int STEPS = 4; //Wider or narrower bands of color 2 | // int SPEEDO = 10; //The speed of the animation 3 | 4 | // RAINBOW -------------------------------------------------- 5 | void FillLEDsFromPaletteColors( uint8_t colorIndex) 6 | { 7 | 8 | for( int i = 0; i < NUM_LEDS; i++) { 9 | leds[i] = ColorFromPalette( currentPalette, colorIndex, (BRIGHTNESS / 6), currentBlending); 10 | colorIndex += STEPS; 11 | } 12 | } 13 | 14 | void Rainbow() 15 | { 16 | currentPalette = RainbowColors_p; 17 | 18 | static uint8_t startIndex = 0; 19 | startIndex = startIndex + 1; 20 | 21 | FillLEDsFromPaletteColors( startIndex); 22 | 23 | FastLED.delay(map(SPEEDO,0,255, 200, 1)); // TWEAK ME (was 10) 24 | } 25 | 26 | 27 | -------------------------------------------------------------------------------- /Deevstock/DeevstockDMX/p-rainbowSweep.ino: -------------------------------------------------------------------------------- 1 | int hue = 0; 2 | int rsX = 0; 3 | int jump = 0; 4 | void rainbowSweep() { 5 | 6 | 7 | for (int y = 0; y < kMatrixHeight; y++) { 8 | leds[ XY(rsX, y)] = ColorFromPalette(currentPalette, hue, 255, currentBlending); 9 | } 10 | FastLED.delay(map(SPEEDO,0,255, 70, 1)); // TWEAK ME was 70 11 | fadeToBlackBy(leds, NUM_LEDS, map(FADE,0,255, 100, 0)); 12 | if(rsX < kMatrixWidth) { 13 | rsX++; 14 | hue += jump; 15 | if (hue > 255) hue = 0; 16 | } 17 | else { 18 | rsX = 0; 19 | hue = random(0, 255); // Audio ? 20 | jump = random(0, map(STEPS, 0, 255, 0, 80)); // TWEAK ME 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Deevstock/DeevstockDMX/p-rainbowWash.ino: -------------------------------------------------------------------------------- 1 | // Looks like oil on water 2 | 3 | void DrawOneFrame( byte startHue8, int8_t yHueDelta8, int8_t xHueDelta8) 4 | { 5 | byte lineStartHue = startHue8; 6 | for ( byte y = 0; y < kMatrixHeight; y++) { 7 | lineStartHue += yHueDelta8; 8 | byte pixelHue = lineStartHue; 9 | for ( byte x = 0; x < kMatrixWidth; x++) { 10 | pixelHue += xHueDelta8; 11 | leds[ XY(x, y)] = ColorFromPalette(currentPalette, pixelHue, 255, currentBlending); 12 | } 13 | } 14 | } 15 | 16 | 17 | void RainbowWash() 18 | { 19 | uint32_t ms = millis(); 20 | int32_t yHueDelta32 = ((int32_t)cos16( ms * (27 / 1) ) * (350 / kMatrixWidth)); 21 | int32_t xHueDelta32 = ((int32_t)cos16( ms * (39 / 1) ) * (310 / kMatrixHeight)); 22 | DrawOneFrame( ms / 65536, yHueDelta32 / 32768, xHueDelta32 / 32768); 23 | FastLED.delay(map(SPEEDO,0,255, 500, 0)); // TWEAK ME was 20 24 | } 25 | 26 | -------------------------------------------------------------------------------- /Deevstock/DeevstockDMX/p-ripple.ino: -------------------------------------------------------------------------------- 1 | int HUE = 0; //0-255, around the color wheel 2 | // int STEPS = 4; //Wider or narrower bands of color 3 | // int SPEEDO = 10; //The speed of the animation 4 | 5 | //RIPPLE VARIABLES 6 | uint8_t colour; // Ripple colour is randomized. 7 | int center = 0; // Center of the current ripple. 8 | int step = -1; // -1 is the initializing step. 9 | uint8_t myfade = 255; // Starting brightness. 10 | #define maxsteps 16 // Case statement wouldn't allow a variable. 11 | 12 | //RIPPLE -------------------------------------------------------------------------------- 13 | int wrap(int step) { 14 | if (step < 0) return NUM_LEDS + step; 15 | if (step > NUM_LEDS - 1) return step - NUM_LEDS; 16 | return step; 17 | } 18 | 19 | void Ripple() { 20 | HUE = 140; HUE++; 21 | if (HUE > 220) { 22 | HUE = 140; // constrain BG hue to blues and purples 23 | } 24 | for (int i = 0; i < NUM_LEDS; i++) leds[i] = CHSV(HUE++, 255, map(FADE,0,255, 50, 150)); // Rotate background colour. 25 | 26 | switch (step) { 27 | 28 | case -1: // Initialize ripple variables. 29 | center = random(NUM_LEDS); 30 | colour = random16(0, 256); 31 | step = 0; 32 | break; 33 | 34 | case 0: 35 | leds[center] = CHSV(colour, 255, 255); // Display the first pixel of the ripple. 36 | step ++; 37 | break; 38 | 39 | case maxsteps: // At the end of the ripples. 40 | step = -1; 41 | break; 42 | 43 | default: // Middle of the ripples. 44 | leds[wrap(center + step)] += CHSV(colour, 255, myfade / step * 2); // Display the next pixels in the range for one side. 45 | leds[wrap(center - step)] += CHSV(colour, 255, myfade / step * 2); // Display the next pixels in the range for the other side. 46 | step ++; // Next step. 47 | break; 48 | } // switch step 49 | 50 | FastLED.delay(map(SPEEDO,0,255, 100, 20)); // TWEAK ME 51 | } 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /Deevstock/DeevstockDMX/p-shimmer.ino: -------------------------------------------------------------------------------- 1 | boolean xrand = false; 2 | boolean irand = true; 3 | 4 | unsigned int l = 0; 5 | int i = 1; 6 | int x = 1; 7 | 8 | void shimmer() { 9 | for (int dot = -1; dot < NUM_LEDS; dot += i) { 10 | leds[dot].setHue(x); 11 | // leds[dot] = CRGB::Blue; 12 | FastLED.delay(map(SPEEDO,0,255, 200, 5)); // TWEAK ME was 10 13 | // clear this led for the next time around the loop 14 | // leds[dot] = CRGB::Black; 15 | } 16 | 17 | if (irand) { 18 | i = random(2, 40); 19 | } 20 | else { 21 | if (i < 40) { 22 | i++; 23 | } else { 24 | i = 1; 25 | } 26 | } 27 | 28 | if (xrand) { 29 | x = random(1, 255); 30 | } 31 | else { 32 | if (x < 255) { 33 | x++; 34 | } else { 35 | x = 1; 36 | } 37 | 38 | } 39 | } 40 | 41 | 42 | -------------------------------------------------------------------------------- /Deevstock/DeevstockDMX/p-sinwave_1.ino: -------------------------------------------------------------------------------- 1 | // SIN WAVE SETUP 2 | 3 | // SINWAVE VARIABLES -- change these numbers to modify Sinwave mode 4 | uint8_t wavebright = 255; // You can change the brightness of the waves/bars rolling across the screen. 5 | uint8_t thishue = 30; // You can change the starting hue value for the first wave. 6 | uint8_t thisrot = 1; // You can change how quickly the hue rotates for this wave. 0= color stays the same 7 | uint8_t allsat = 255; // I like 'em fully saturated with colour. 8 | bool thisdirSine = 0; // You can change direction. 9 | int8_t thisspeed = 4; // You can change the speed, and use negative values. 10 | uint8_t allfreq = 25; // You can change the frequency, thus overall width of bars. 11 | int thisphase = 0; // Phase change value gets calculated. 12 | uint8_t thiscutoff = 192; // You can change the cutoff value to display this wave. Lower value = longer wave. 13 | int loopdelay = 4; // You can change the delay. Also you can change the allspeed variable above. 14 | uint8_t bgclr = 0; // A rotating background colour. 15 | uint8_t bgbright = 55; // Background color brightness 16 | 17 | 18 | void one_sin() { // This is the heart of this program. Sure is short. 19 | if (thisdirSine == 0) thisphase += thisspeed; else thisphase -= thisspeed; // You can change direction and speed individually. 20 | thishue = thishue + thisrot; // Hue rotation is fun for thiswave. 21 | for (int k = 0; k < NUM_LEDS; k++) { 22 | int thisbright = qsubd(cubicwave8((k * allfreq) + thisphase), thiscutoff); // qsub sets a minimum value called thiscutoff. If < thiscutoff, then bright = 0. Otherwise, bright = 128 (as defined in qsub).. 23 | leds[k] = CHSV(bgclr, 255, bgbright); 24 | leds[k] += CHSV(thishue, allsat, thisbright); // Assigning hues and brightness to the led array. 25 | } 26 | bgclr++; 27 | } 28 | 29 | void sinwave_1() { 30 | one_sin(); 31 | FastLED.delay(map(SPEEDO,0,255, 50, 0)); // TWEAK ME 32 | } 33 | 34 | -------------------------------------------------------------------------------- /Deevstock/DeevstockDMX/p-snake.ino: -------------------------------------------------------------------------------- 1 | class Snake { 2 | int x = 0; 3 | int y = 0; 4 | int right = 1; 5 | int up = 0; 6 | int w = kMatrixWidth - 1; 7 | int h = kMatrixHeight - 1; 8 | int margin = 0; 9 | int hue; 10 | 11 | public: 12 | Snake() { 13 | 14 | } 15 | 16 | void snake() { 17 | leds[ XY(x, y)] = ColorFromPalette(currentPalette, hue, 255, currentBlending); 18 | // End of right 19 | if ((x >= (w - margin)) && (up == 0)) { 20 | up = 1; 21 | right = 0; 22 | // snakeHue += 15; 23 | } 24 | // End of up 25 | else if ((y >= (h - margin)) && (up == 1)) { 26 | up = 0; 27 | right = -1; 28 | // snakeHue += 15; 29 | } 30 | // End of left 31 | else if ((x == (0 + margin)) && (up == 0 && right == -1)) { 32 | up = -1; 33 | right = 0; 34 | // snakeHue += 15; 35 | } 36 | // End of down 37 | else if ((x == (0 + margin) && y == (1 + margin)) && (up == -1 && right == 0)) { 38 | y += up; 39 | up = 0; 40 | right = 1; 41 | hue += 15; 42 | margin++; 43 | y++; 44 | } 45 | 46 | // Final LED 47 | if (right == 0 && up == -1 && margin == 3) { 48 | //delay(1500); 49 | hue = random(0, 255); 50 | margin = 0; 51 | x = -1; 52 | y = 0; 53 | right = 1; 54 | up = 0; 55 | } 56 | 57 | // Option toggle? 58 | fadeToBlackBy(leds, (kMatrixWidth * kMatrixHeight), map(SPEEDO,0,255, 0, 100)); // TWEAK ME 59 | // fadeLightBy(leds, (kMatrixWidth * kMatrixHeight), 20); 60 | x += right; 61 | y += up; 62 | } 63 | }; 64 | 65 | #define NUM_SNAKES 3 66 | Snake snakes[NUM_SNAKES]; 67 | 68 | int snakesStarted = 1; 69 | // int const snakeDelay = ((kMatrixWidth * 2) + (kMatrixHeight * 2) - 1); 70 | int const snakeDelay = 10; 71 | int snakeGap = 0; 72 | 73 | void snake() { 74 | 75 | if (snakesStarted < NUM_SNAKES) { 76 | if (snakeGap == snakeDelay) { 77 | snakesStarted++; 78 | snakeGap = 0; 79 | } 80 | else { 81 | snakeGap++; 82 | } 83 | } 84 | 85 | for (i = 0; i < snakesStarted; i++) { 86 | snakes[i].snake(); 87 | } 88 | FastLED.delay(map(SPEEDO,0,255, 0, 1000)); // TWEAK ME was 155 89 | } 90 | 91 | 92 | -------------------------------------------------------------------------------- /Deevstock/DeevstockDMX/pixel.h: -------------------------------------------------------------------------------- 1 | #ifndef PIXEL_H 2 | #define PIXEL_H 3 | 4 | void pixel() { 5 | 6 | // Persistent local variable 7 | static uint16_t currLED; // Persistent local value to count the current LED location. 8 | 9 | timeval = 0; // Our EVERY_N_MILLIS_I timer value. 10 | 11 | currLED = (currLED+1) % (NUM_AUDIO_LEDS); // Cycle through all the LED's. By Andrew Tuline. 12 | 13 | CRGB newcolour = ColorFromPalette(currentPalette, oldsample, oldsample, currentBlending); // Colour of the LED will be based on oldsample, while brightness is based on sampleavg. 14 | nblend(ledsAudio[currLED], newcolour, 192); // Blend the old value and the new value for a gradual transitioning. 15 | showSegments(); 16 | } // pixel() 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /Deevstock/DeevstockDMX/pixels.h: -------------------------------------------------------------------------------- 1 | #ifndef PIXELS_H 2 | #define PIXELS_H 3 | 4 | void pixels() { 5 | 6 | // Persistent local variable 7 | static uint16_t currLED; // Persistent local value to count the current LED location. 8 | 9 | timeval = 50; // Our EVERY_N_MILLIS_I timer value. 10 | 11 | currLED = beatsin8(16,0,10); 12 | 13 | for (int i=0; i 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | AudioInputI2S audioInput; 12 | AudioAnalyzeFFT256 fft; 13 | AudioControlSGTL5000 audioShield; 14 | AudioConnection patchCord1(audioInput, 0, fft, 0); 15 | 16 | void soundmems() { // Here's where we capture sound. It provides an average, a current sample as well as a peak trigger. 17 | if (fft.available()) { // I tried some fancier math, but never came up with anything that really worked all that well. Must . . work. . harder. 18 | // Local definitions 19 | #define sensitivity 100 // Define maximum cutoff of potentiometer for cutting off sounds. 20 | #define NSAMPLES 64 // Creating an array of lots of samples for decent averaging. 21 | 22 | // Persistent local variables (saved for next iteration) 23 | static int16_t samplearray[NSAMPLES]; // Array of samples. 24 | static uint16_t samplesum = 0; // Sum of the last 64 samples. This had better be positive. 25 | static uint8_t samplecount = 0; // A rollover counter to cycle through the array. 26 | 27 | // Temporary local variables 28 | int16_t sample = 0; // Current sample. Starts with negative values, which is why it's signed. 29 | uint16_t potin; // Our scaled potentiometer value. 30 | 31 | samplepeak = 0; // Reset the global sample peak. 32 | 33 | potin = 50; // map(analogRead(POT_PIN), 0, 1023, 0, sensitivity); // Read the potentiometer and scale it to our sensitivity setting, which is scaled to our microphone readings. 34 | 35 | sample = map(fft.read(2, 127), 0 , 1, 0, 500); // TODO: check range of fft 36 | //Serial.println(sample); 37 | if (sample < potin) sample = 0; // Filter ambient noise, which is adjustable via the potentiometer. 38 | 39 | samplesum += sample - samplearray[samplecount]; // Add the new sample and remove the oldest sample in the array. No 'for' loops required here for extra speed. 40 | sampleavg = samplesum / NSAMPLES; // Get an average. 41 | samplearray[samplecount] = sample; // Update oldest sample in the array with new sample. By Andrew Tuline. 42 | samplecount = (samplecount + 1) % NSAMPLES; // Update the counter for the array and rollover if we hit the max. 43 | 44 | if (sample > (sampleavg + potin) && (sample < oldsample)) samplepeak = 1; // We're on the down swing, so we just peaked. 45 | 46 | oldsample = sample; // We'll use oldsample globally as our 'current' sample. 47 | } 48 | } // soundmems() 49 | 50 | 51 | 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /Deevstock/DeevstockDMX/support.h: -------------------------------------------------------------------------------- 1 | #ifndef SUPPORT_H 2 | #define SUPPORT_H 3 | 4 | // Supporting general function ------------------------------------------------------------------------------------------- 5 | 6 | void showfps() { // Show rames per seocond on the serial monitor. 7 | 8 | // Temporary local variable 9 | uint32_t currentMillis; 10 | 11 | // Persistent local variable 12 | static uint32_t lastMillis = 0; 13 | 14 | currentMillis = millis(); 15 | loops++; // Keep on incrementing this each time it's called until (currentMillis - lastMillis) > 1000 16 | 17 | if (currentMillis - lastMillis > 1000) { // If 1 second has passed, then. . 18 | Serial.println(loops); // Print the value of loops (which is loops per second). 19 | lastMillis = currentMillis; // Reset everything and start counting all over again. By Andrew Tuline. 20 | loops = 0; 21 | } 22 | 23 | } // showfps() 24 | 25 | 26 | 27 | // Supporting visual functions ---------------------------------------------------------------------------------------------- 28 | 29 | void lineit() { // Send the pixels one or the other direction down the line. 30 | 31 | if (thisdir == 0) { 32 | for (int i = NUM_AUDIO_LEDS - 1; i > 0 ; i-- ) ledsAudio[i] = ledsAudio[i - 1]; 33 | } else { 34 | for (int i = 0; i < NUM_AUDIO_LEDS - 1 ; i++ ) ledsAudio[i] = ledsAudio[i + 1]; 35 | } 36 | 37 | } // waveit() 38 | 39 | 40 | 41 | void waveit() { // Shifting pixels from the center to the left and right. 42 | 43 | for (int i = NUM_AUDIO_LEDS - 1; i > NUM_AUDIO_LEDS / 2; i--) { // Move to the right. 44 | ledsAudio[i] = ledsAudio[i - 1]; 45 | } 46 | 47 | for (int i = 0; i < NUM_AUDIO_LEDS / 2; i++) { // Move to the left. 48 | ledsAudio[i] = ledsAudio[i + 1]; 49 | } 50 | 51 | } // waveit() 52 | 53 | 54 | 55 | void addGlitter( fract8 chanceOfGlitter) { // Let's add some glitter, thanks to Mark 56 | 57 | if ( random8() < chanceOfGlitter) { 58 | ledsAudio[random16(NUM_AUDIO_LEDS)] += CRGB::White; 59 | } 60 | 61 | } // addGlitter() 62 | 63 | #endif 64 | 65 | uint16_t getPixel(int p) 66 | { 67 | uint16_t i; 68 | 69 | if ( kMatrixSerpentineLayout == false) { 70 | i = p; 71 | } 72 | 73 | if ( kMatrixSerpentineLayout == true) { 74 | float f = ((float)(p + 1) / (float) NUM_LEDS_PER_STRIP); 75 | int r = ceil(f); 76 | 77 | if (r & 0x01) { 78 | i = p; 79 | } else { 80 | i = ((NUM_LEDS_PER_STRIP * r) - (p % NUM_LEDS_PER_STRIP)) - 1; 81 | } 82 | } 83 | 84 | // if (i >= (NUM_LEDS - 1)) return 0; 85 | return i; 86 | } 87 | 88 | void showSegments() { 89 | for (int s = 0; s < NUM_STRIPS; s++) { 90 | for (int i = 0; i < NUM_AUDIO_LEDS; i++) { 91 | int p = (s * NUM_AUDIO_LEDS) + i; 92 | leds[getPixel(p)] = blend(ledsAudio[i], CRGB(RED, GREEN, BLUE), 125); 93 | } 94 | } 95 | FastLED.show(); 96 | } 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /Deevstock/DeevstockDMX/z-demoReel.ino: -------------------------------------------------------------------------------- 1 | void rainbow() 2 | { 3 | // FastLED's built-in rainbow generator 4 | fill_rainbow( leds, NUM_LEDS, gHue, map(SPEEDO,0,255, 1, 100)); 5 | fadeToBlackBy( leds, NUM_LEDS, 70); 6 | demoShow(); 7 | } 8 | 9 | void rainbowWithGlitter() 10 | { 11 | // built-in FastLED rainbow, plus some random sparkly glitter 12 | rainbow(); 13 | addGlitter(map(STEPS,0,255, 1, 100)); 14 | demoShow(); 15 | } 16 | 17 | void confetti() 18 | { 19 | // random colored speckles that blink in and fade smoothly 20 | fadeToBlackBy( leds, NUM_LEDS, map(STEPS,0,255, 1, 100)); 21 | int pos = random16(NUM_LEDS); 22 | leds[pos] += CHSV( gHue + random8(64), 200, 255); 23 | demoShow(); 24 | } 25 | 26 | void sinelon() 27 | { 28 | // a colored dot sweeping back and forth, with fading trails 29 | fadeToBlackBy( leds, NUM_LEDS, map(STEPS,0,255, 100, 1)); 30 | int pos = beatsin16( 13, 0, NUM_LEDS-1 ); 31 | leds[pos] += CHSV( gHue, 255, 192); 32 | demoShow(); 33 | } 34 | 35 | void bpm() 36 | { 37 | // colored stripes pulsing at a defined Beats-Per-Minute (BPM) 38 | uint8_t BeatsPerMinute = map(SPEEDO,0,255, 45, 180); 39 | CRGBPalette16 palette = PartyColors_p; 40 | uint8_t beat = beatsin8( BeatsPerMinute, 64, 255); 41 | for( int i = 0; i < NUM_LEDS; i++) { //9948 42 | leds[i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10)); 43 | } 44 | demoShow(); 45 | } 46 | 47 | void juggle() { 48 | // eight colored dots, weaving in and out of sync with each other 49 | fadeToBlackBy( leds, NUM_LEDS, map(STEPS,0,255, 1, 100)); 50 | byte dothue = 0; 51 | for( int i = 0; i < 8; i++) { 52 | leds[beatsin16( i+7, 0, NUM_LEDS-1 )] |= CHSV(dothue, 200, 255); 53 | dothue += 32; 54 | } 55 | demoShow(); 56 | } 57 | 58 | void demoShow() { 59 | // send the 'leds' array out to the actual LED strip 60 | FastLED.show(); 61 | // insert a delay to keep the framerate modest 62 | //FastLED.delay(1000/FRAMES_PER_SECOND); 63 | FastLED.delay(map(SPEEDO,0,255, 200, 0)); 64 | } 65 | 66 | -------------------------------------------------------------------------------- /Deevstock/Test1/p-snake.ino: -------------------------------------------------------------------------------- 1 | class Snake { 2 | int x = 0; 3 | int y = 0; 4 | int right = 1; 5 | int up = 0; 6 | int w = kMatrixWidth - 1; 7 | int h = kMatrixHeight - 1; 8 | int margin = 0; 9 | int hue; 10 | 11 | public: 12 | Snake() { 13 | 14 | } 15 | 16 | void snake() { 17 | leds[ XY(x, y)] = CHSV(hue, 255, 255); 18 | // End of right 19 | if ((x >= (w - margin)) && (up == 0)) { 20 | up = 1; 21 | right = 0; 22 | // snakeHue += 15; 23 | } 24 | // End of up 25 | else if ((y >= (h - margin)) && (up == 1)) { 26 | up = 0; 27 | right = -1; 28 | // snakeHue += 15; 29 | } 30 | // End of left 31 | else if ((x == (0 + margin)) && (up == 0 && right == -1)) { 32 | up = -1; 33 | right = 0; 34 | // snakeHue += 15; 35 | } 36 | // End of down 37 | else if ((x == (0 + margin) && y == (1 + margin)) && (up == -1 && right == 0)) { 38 | y += up; 39 | up = 0; 40 | right = 1; 41 | hue += 15; 42 | margin++; 43 | y++; 44 | } 45 | 46 | // Final LED 47 | if (right == 0 && up == -1 && margin == ( (kMatrixHeight / 2) - 1)) { // >= 48 | //delay(5000); 49 | hue = random(0, 255); 50 | margin = 0; 51 | x = -1; 52 | y = 0; 53 | right = 1; 54 | up = 0; 55 | } 56 | 57 | // Option toggle? 58 | // fadeLightBy(leds, (kMatrixWidth * kMatrixHeight), 20); 59 | x += right; 60 | y += up; 61 | } 62 | }; 63 | 64 | #define SNAKE_GAP 30 65 | #define NUM_SNAKES (NUM_LEDS / SNAKE_GAP) 66 | Snake snakes[NUM_SNAKES]; 67 | 68 | int snakesStarted = 1; 69 | //int const snakeDelay = ((kMatrixWidth * 2) + (kMatrixHeight * 2) - 1); 70 | int const snakeDelay = SNAKE_GAP; 71 | int snakeGap = 0; 72 | 73 | void snake() { 74 | 75 | if (snakesStarted < NUM_SNAKES) { 76 | if (snakeGap == snakeDelay) { 77 | snakesStarted++; 78 | snakeGap = 0; 79 | } 80 | else { 81 | snakeGap++; 82 | } 83 | } 84 | 85 | for (int i = 0; i < snakesStarted; i++) { 86 | snakes[i].snake(); 87 | } 88 | fadeToBlackBy(leds, (kMatrixWidth * kMatrixHeight), 25); // TWEAK ME 89 | FastLED.delay(100); 90 | EVERY_N_SECONDS(10) { 91 | Serial.println(FastLED.getFPS()); 92 | } 93 | } 94 | 95 | 96 | -------------------------------------------------------------------------------- /DiodTest/Diod_Visualizer_ESP/data/images/hsvChart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netmindz/arduino/cd38e9ad891cc1fd425c579b49174e67f939052e/DiodTest/Diod_Visualizer_ESP/data/images/hsvChart.png -------------------------------------------------------------------------------- /DiodTest/Diod_Visualizer_ESP/data/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Project Control Panel 5 | 6 | 7 | 8 | 9 | 10 |

Project
Control Panel

11 |

12 |

13 |

Current Pattern is:
14 | %CURRENTPATTERN%

15 |
16 |

Brightness Control (0 - 150): 17 |

18 |

Brightness is set at: %INPUTMASTERBRIGHTNESS%

19 |
20 |

Audio Sensitivity Multiplier (will be divided by 100): 21 |

22 |

Audio Multiplier is set at: %INPUTAUDIOCONTROL%

23 |
24 |

Music Visualizing Patterns:

25 |

26 |


27 | 28 | 29 | 30 | 31 | 32 |

33 |
34 |

35 | 36 | 37 | 38 | 39 | 40 |

41 |
42 |
43 |

Ambient Patterns:

44 |

45 | 46 | 47 | 48 | 49 |

50 |
51 |
52 |

Solid Color:

53 |
54 | 55 |

To choose a solid color to display, you have the following 3 controls:

56 |

Hue Input (0-255): 57 |

58 |

Saturation Input (0-255): 59 |

60 |

Brightness Input (0-255): 61 |

62 |

63 |
64 |

Modes Descriptions

65 | Music Visualizing Modes:
66 | 1:
67 | 2:
68 | 3:
69 | 4:
70 | 5:
71 | 6:
72 | 7:
73 | 8:
74 | 9:
75 | 10:
76 | 77 | 78 | -------------------------------------------------------------------------------- /DiodTest/Diod_Visualizer_ESP/data/style.css: -------------------------------------------------------------------------------- 1 | html { 2 | font-family: Helvetica; 3 | display: inline-block; 4 | margin: 0px auto; 5 | text-align: center; 6 | } 7 | * { 8 | margin: 0; 9 | padding: 0; 10 | } 11 | h1{ 12 | color: #0F3376; 13 | padding:2vh; 14 | padding-top: 5px; 15 | } 16 | h2 { 17 | padding: 0vh; 18 | } 19 | p{ 20 | font-size: 1.5rem; 21 | } 22 | .button { 23 | display: inline-block; 24 | background-color: #008CBA; 25 | color: white; 26 | padding: 1px 40px; 27 | text-decoration: none; 28 | font-size: 20px; 29 | margin: 10px; 30 | } 31 | .button2 { 32 | background-color: #f44336; 33 | } 34 | .button3 { 35 | background-color: #FFA500; 36 | } 37 | .button4 { 38 | display: inline-table; 39 | background-color: #0BA500; 40 | color: white; 41 | padding: 1px 20px; 42 | font-size: 10px; 43 | margin: 0px; 44 | } 45 | -------------------------------------------------------------------------------- /DiodTest/Diod_Visualizer_Teensy/DDGradients.h: -------------------------------------------------------------------------------- 1 | // DDGradients.h 2 | // There are lots of common gradients that FastLED uses, but they aren't included here because they have "darker" spots in the palettes 3 | // These palettes do not have any darker regions 4 | 5 | // COLOR PALLETTE STUFF 6 | uint8_t currentPaletteNumber; 7 | TBlendType currentBlending; 8 | 9 | DEFINE_GRADIENT_PALETTE(Blue_Cyan_Yellow_gp) { 10 | 0, 0, 0, 255, 11 | 63, 0, 55, 255, 12 | 127, 0, 255, 255, 13 | 191, 42, 255, 45, 14 | 255, 255, 255, 0 15 | }; 16 | 17 | 18 | DEFINE_GRADIENT_PALETTE(usa_p) { 19 | 0, 255, 0, 0, //red 20 | 128, 255, 255, 255, //white 21 | 255, 0, 0, 255 // blue 22 | }; 23 | 24 | DEFINE_GRADIENT_PALETTE(redBlueRed_p) { 25 | 0, 255, 0, 0, //red 26 | 128, 0, 0, 255, // blue 27 | 255, 255, 0, 0, //red 28 | }; 29 | 30 | DEFINE_GRADIENT_PALETTE(redGreenRed_p) { 31 | 0, 255, 0, 0, //red 32 | 128, 0, 255, 0, // blue 33 | 255, 255, 0, 0, //red 34 | }; 35 | 36 | DEFINE_GRADIENT_PALETTE(purpleGreenPurple_p) { 37 | 0, 255, 0, 255, //red 38 | 128, 0, 255, 0, // blue 39 | 255, 255, 0, 255, //red 40 | }; 41 | 42 | DEFINE_GRADIENT_PALETTE(yellowPurpleYellow_p) { 43 | 0, 255, 255, 0, //yellow 44 | 128, 255, 0, 255, // purple 45 | 255, 255, 255, 0, // yellow 46 | }; 47 | 48 | DEFINE_GRADIENT_PALETTE(orangeRed_p) { 49 | 0, 255, 160, 0, // orange 50 | 255, 255, 0, 0, // red 51 | }; 52 | 53 | DEFINE_GRADIENT_PALETTE(blueGreen_p) { 54 | 0, 0, 0, 255, // blue 55 | 255, 0, 255, 0, // green 56 | }; 57 | 58 | DEFINE_GRADIENT_PALETTE(blueWhite_p) { 59 | 0, 0, 0, 170, // blue 60 | 255, 170, 170, 170, 61 | }; 62 | 63 | DEFINE_GRADIENT_PALETTE(justWhite_p) { 64 | 0, 255, 255, 255, // blue 65 | 255, 255, 255, 255, 66 | }; 67 | 68 | DEFINE_GRADIENT_PALETTE(normal_p) { 69 | 0, 255, 0, 0, 70 | 42, 128, 128, 0, 71 | 85, 0, 255, 0, 72 | 128, 0, 128, 128, 73 | 171, 0, 0, 255, 74 | 213, 128, 0, 128, 75 | 255, 255, 0, 0 76 | }; 77 | 78 | 79 | // This list of color palettes can be called upon in the main code 80 | // The order only matters if you'd like to scroll through them sequentially 81 | // Otherwise, they can be called by their number on this list: 0, 1, 2, etc.. 82 | const TProgmemRGBGradientPalettePtr gGradientPalettes[] = { 83 | usa_p, 84 | redBlueRed_p, 85 | purpleGreenPurple_p, 86 | orangeRed_p, 87 | yellowPurpleYellow_p, 88 | Blue_Cyan_Yellow_gp, 89 | normal_p, 90 | blueGreen_p 91 | }; 92 | 93 | // Count of how many gradients are defined: 94 | const uint8_t gGradientPaletteCount = 95 | sizeof(gGradientPalettes) / sizeof(TProgmemRGBGradientPalettePtr); 96 | -------------------------------------------------------------------------------- /DiodTest/Diod_Visualizer_Teensy/DDPatternLists.h: -------------------------------------------------------------------------------- 1 | // DDPatternLists.h 2 | // This file holds the lists of functions that can be chosen from during different song scenarios (beat present, no beat present, no music) 3 | 4 | uint8_t musicWithNoBeatPatternNumber = 0; 5 | uint8_t currentLowBeatPatternNumber = 0; 6 | uint8_t currentSpectrumPatternNumber = 0; 7 | uint8_t currentPatternNumber = 0; 8 | uint8_t currentAmbPatternNumber = 0; 9 | uint8_t musicWithConstBeatPatternNumber = 0; 10 | uint8_t allPatternsNumber = 0; 11 | 12 | // These are lists of functions that will be displayed during different types of music / no music. 13 | 14 | // Ambient patterns for when no music is playing 15 | typedef void(*ambientPatternList[])(); 16 | ambientPatternList ambientPatterns = { 17 | placeHolder 18 | }; 19 | 20 | // Patterns for when there is no beat detected in the song 21 | typedef void(*musicWithNoBeatPatternsList[])(); 22 | musicWithNoBeatPatternsList musicWithNoBeatPatterns = { 23 | fullSparkles, 24 | fallingMusic 25 | }; 26 | 27 | // Patterns for when a beat is detected in the low frequency 28 | typedef void(*lowBeatPatternList[])(); 29 | lowBeatPatternList lowBeatPatterns = { 30 | drawCircles 31 | }; 32 | 33 | // Patterns for when a constant beat is detected 34 | typedef void(*constBeatPatternList[])(); 35 | constBeatPatternList constBeatPatterns = { 36 | drawCircles 37 | }; 38 | 39 | // A list of all the patterns 40 | typedef void(*allPatternsList[])(); 41 | allPatternsList allPatterns = { 42 | drawCircles, 43 | fullSparkles, 44 | fallingMusic 45 | }; 46 | 47 | // Cycle to the next pattern in 'AllPatterns' 48 | void nextAllPatterns() { 49 | allPatternsNumber++; 50 | if (allPatternsNumber >= ARRAY_SIZE(allPatterns)) 51 | allPatternsNumber = 0; 52 | } 53 | 54 | // These functions choose a random pattern within the lists above 55 | 56 | void nextMusicWithConstBeatPattern() { 57 | // add one to the current pattern number, and wrap around at the end 58 | //musicWithNoBeatPatternNumber = (musicWithNoBeatPatternNumber + 1) % ARRAY_SIZE(musicWithNoBeatPatterns); 59 | musicWithConstBeatPatternNumber = random8(ARRAY_SIZE(constBeatPatterns)); 60 | } 61 | 62 | void nextMusicWithNoBeatPattern() { 63 | // add one to the current pattern number, and wrap around at the end 64 | //musicWithNoBeatPatternNumber = (musicWithNoBeatPatternNumber + 1) % ARRAY_SIZE(musicWithNoBeatPatterns); 65 | musicWithNoBeatPatternNumber = random8(ARRAY_SIZE(musicWithNoBeatPatterns)); 66 | } 67 | 68 | void nextAmbPattern() { 69 | //currentAmbPatternNumber = (currentAmbPatternNumber + 1) % ARRAY_SIZE(ambientPatterns); 70 | currentAmbPatternNumber = random8(ARRAY_SIZE(ambientPatterns)); 71 | } 72 | 73 | void nextLowBeatPattern() { 74 | //currentLowBeatPatternNumber = (currentLowBeatPatternNumber + 1) % ARRAY_SIZE(lowBeatPatterns); 75 | currentLowBeatPatternNumber = random8(ARRAY_SIZE(lowBeatPatterns)); 76 | } 77 | -------------------------------------------------------------------------------- /E131DMX/E131DMX.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | #define UNIVERSE 1 // First DMX Universe to listen for 7 | #define UNIVERSE_COUNT 1 // Total number of Universes to listen for, starting at UNIVERSE 8 | #define CHANNELS 512 9 | 10 | ESPAsyncE131 e131(UNIVERSE_COUNT); 11 | 12 | #include "wifi.h" 13 | const char ssid[] = SECRET_SSID; 14 | const char passphrase[] = SECRET_PSK; 15 | 16 | DMXESPSerial dmx; 17 | 18 | void setup() { 19 | Serial.begin(115200); 20 | 21 | // Make sure you're in station mode 22 | WiFi.mode(WIFI_STA); 23 | 24 | Serial.println(""); 25 | Serial.print(F("Connecting to ")); 26 | Serial.print(ssid); 27 | 28 | if (passphrase != NULL) 29 | WiFi.begin(ssid, passphrase); 30 | else 31 | WiFi.begin(ssid); 32 | 33 | Serial.print("Waiting on wifi "); 34 | while (WiFi.status() != WL_CONNECTED) { 35 | delay(500); 36 | Serial.print("w"); 37 | } 38 | Serial.println("\nDone"); 39 | Serial.print("IP address: "); 40 | Serial.println(WiFi.localIP()); 41 | delay(2000); 42 | // Choose one to begin listening for E1.31 data 43 | //if (e131.begin(E131_UNICAST)) { 44 | if (e131.begin(E131_MULTICAST, UNIVERSE, UNIVERSE_COUNT)) { // Listen via Multicast 45 | Serial.println(F("Listening for data...")); 46 | } 47 | else { 48 | Serial.println(F("*** e131.begin failed ***")); 49 | } 50 | dmx.init(CHANNELS); 51 | 52 | pinMode(LED_BUILTIN, OUTPUT); // Initialize the LED_BUILTIN pin as an output 53 | } 54 | 55 | int led = 0; 56 | void loop() { 57 | if (!e131.isEmpty()) { 58 | led = !led; 59 | digitalWrite(LED_BUILTIN, led); 60 | 61 | e131_packet_t packet; 62 | e131.pull(&packet); // Pull packet from ring buffer 63 | 64 | // EVERY_N_SECONDS( 2 ) { 65 | Serial.printf("Universe %u / %u Channels | Packet#: %u / Errors: %u / CH1: %u\n", 66 | htons(packet.universe), // The Universe for this packet 67 | htons(packet.property_value_count) - 1, // Start code is ignored, we're interested in dimmer data 68 | e131.stats.num_packets, // Packet counter 69 | e131.stats.packet_errors, // Packet error counter 70 | packet.property_values[1]); // Dimmer data for Channel 1 71 | //} 72 | 73 | /* Parse a packet and update pixels */ 74 | for (int i = 1; i <= CHANNELS; i++) { 75 | int v = packet.property_values[i]; 76 | dmx.write(i, v); 77 | } 78 | dmx.update(); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /ESP8266/ESP8266_Blink/ESP8266_Blink.ino: -------------------------------------------------------------------------------- 1 | #define ESP8266_LED 0 2 | 3 | void setup() 4 | { 5 | pinMode(ESP8266_LED, OUTPUT); 6 | } 7 | 8 | void loop() 9 | { 10 | digitalWrite(ESP8266_LED, HIGH); 11 | delay(500); 12 | digitalWrite(ESP8266_LED, LOW); 13 | delay(500); 14 | } 15 | -------------------------------------------------------------------------------- /ESP8266/WIFIMood/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 38 | 39 | 40 | 41 |
42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /ESP8266/WifiTest/WifiTest.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Simple HTTP get webclient test 3 | */ 4 | 5 | #include 6 | 7 | const char* ssid = ""; 8 | const char* password = ""; 9 | 10 | const char* host = "wifitest.adafruit.com"; 11 | 12 | void setup() { 13 | Serial.begin(115200); 14 | delay(100); 15 | 16 | // We start by connecting to a WiFi network 17 | 18 | Serial.println("**************************************"); 19 | Serial.println(); 20 | Serial.print("Connecting to "); 21 | Serial.println(ssid); 22 | 23 | WiFi.begin(ssid, password); 24 | 25 | while (WiFi.status() != WL_CONNECTED) { 26 | delay(500); 27 | Serial.print("."); 28 | } 29 | 30 | Serial.println(""); 31 | Serial.println("WiFi connected"); 32 | Serial.println("IP address: "); 33 | Serial.println(WiFi.localIP()); 34 | } 35 | 36 | int value = 0; 37 | 38 | void loop() { 39 | delay(5000); 40 | ++value; 41 | 42 | Serial.print("connecting to "); 43 | Serial.println(host); 44 | 45 | // Use WiFiClient class to create TCP connections 46 | WiFiClient client; 47 | const int httpPort = 80; 48 | if (!client.connect(host, httpPort)) { 49 | Serial.println("connection failed"); 50 | return; 51 | } 52 | 53 | // We now create a URI for the request 54 | String url = "/testwifi/index.html"; 55 | Serial.print("Requesting URL: "); 56 | Serial.println(url); 57 | 58 | // This will send the request to the server 59 | client.print(String("GET ") + url + " HTTP/1.1\r\n" + 60 | "Host: " + host + "\r\n" + 61 | "Connection: close\r\n\r\n"); 62 | delay(500); 63 | 64 | // Read all the lines of the reply from server and print them to Serial 65 | while(client.available()){ 66 | String line = client.readStringUntil('\r'); 67 | Serial.print(line); 68 | } 69 | 70 | Serial.println(); 71 | Serial.println("closing connection"); 72 | } 73 | -------------------------------------------------------------------------------- /ESP8266_Rings/Clock.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | uint8_t flipClock = 0; 4 | 5 | WiFiUDP ntpUDP; 6 | NTPClient timeClient(ntpUDP, "europe.pool.ntp.org", 3600, 60000); 7 | 8 | void drawHand(uint16_t angle, uint8_t endRing, CRGB color) 9 | { 10 | // rotate 90 degrees counter-clockwise 11 | angle += 270; 12 | 13 | while (angle >= 360) 14 | angle -= 360; 15 | 16 | uint8_t index = 0; 17 | 18 | for (uint8_t ringIndex = 0; ringIndex <= endRing; ringIndex++) 19 | { 20 | index = angleToPixel360(angle, ringIndex); 21 | 22 | leds[index] |= color; 23 | } 24 | } 25 | 26 | void drawHandArc(uint16_t endAngle, uint8_t ringIndex, CRGB color) 27 | { 28 | static const uint16_t startAngle = 270; 29 | 30 | // rotate 90 degrees counter-clockwise 31 | endAngle += 270; 32 | 33 | while (endAngle >= 360) 34 | endAngle -= 360; 35 | 36 | uint8_t startIndex = angleToPixel360(startAngle, ringIndex); 37 | uint8_t endIndex = angleToPixel360(endAngle, ringIndex); 38 | if (startIndex == endIndex) 39 | { 40 | leds[endIndex] = color; 41 | } 42 | else 43 | { 44 | fillRing360(ringIndex, color, startAngle, endAngle); 45 | } 46 | } 47 | 48 | void drawHandDot(uint16_t angle, uint8_t ringIndex, CRGB color) 49 | { 50 | // rotate 90 degrees counter-clockwise 51 | angle += 270; 52 | 53 | while (angle >= 360) 54 | angle -= 360; 55 | 56 | uint8_t index = 0; 57 | 58 | index = angleToPixel360(angle, ringIndex); 59 | 60 | leds[index] |= color; 61 | } 62 | 63 | uint16_t hourAngle = 0; 64 | uint16_t minuteAngle = 0; 65 | uint16_t secondAngle = 0; 66 | 67 | void updateClock() 68 | { 69 | hourAngle = timeClient.getHours(); 70 | if (hourAngle >= 12) 71 | hourAngle -= 12; 72 | hourAngle *= 30; 73 | 74 | minuteAngle = timeClient.getMinutes() * 6; 75 | secondAngle = timeClient.getSeconds() * 6; 76 | } 77 | 78 | void handClock() 79 | { 80 | // dimAll(240); 81 | 82 | // hour 83 | drawHand(hourAngle, 4, CRGB::Red); 84 | 85 | // minute 86 | drawHand(minuteAngle, 6, CRGB::Green); 87 | 88 | // second 89 | drawHand(secondAngle, 8, CRGB::Blue); 90 | 91 | updateClock(); 92 | } 93 | 94 | void arcClock() 95 | { 96 | EVERY_N_SECONDS( 1 ) { 97 | 98 | // hour 99 | drawHandArc(hourAngle, 6, CRGB::Red); 100 | 101 | // minute 102 | drawHandArc(minuteAngle, 7, CRGB::Green); 103 | 104 | // second 105 | drawHandArc(secondAngle, 8, CRGB::Blue); 106 | 107 | updateClock(); 108 | 109 | FastLED.show(); 110 | fill_solid(leds, NUM_LEDS, CRGB::Black); 111 | } 112 | } 113 | 114 | void rimClock() 115 | { 116 | EVERY_N_SECONDS( 1 ) { 117 | // dimAll(240); 118 | 119 | // hour 120 | drawHandDot(hourAngle, 8, CRGB::Red); 121 | 122 | // minute 123 | drawHandDot(minuteAngle, 8, CRGB::Green); 124 | 125 | // second 126 | drawHandDot(secondAngle, 8, CRGB::Blue); 127 | 128 | updateClock(); 129 | 130 | FastLED.show(); 131 | fill_solid(leds, NUM_LEDS, CRGB::Black); 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /FastLED-Patterns/Concentric_Squares/Concentric_Squares.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // Params for width and height 4 | const uint8_t kMatrixWidth = 30; 5 | const uint8_t kMatrixHeight = 30; 6 | 7 | #define LED_PIN 7 8 | 9 | #define COLOR_ORDER RGB 10 | #define CHIPSET APA102 11 | 12 | #define BRIGHTNESS 5 13 | 14 | // Param for different pixel layouts 15 | const bool kMatrixSerpentineLayout = true; 16 | 17 | 18 | uint16_t XY( uint8_t x, uint8_t y) 19 | { 20 | uint16_t i; 21 | 22 | if ( kMatrixSerpentineLayout == false) { 23 | i = (y * kMatrixWidth) + x; 24 | } 25 | 26 | if ( kMatrixSerpentineLayout == true) { 27 | if ( y & 0x01) { 28 | // Odd rows run backwards 29 | uint8_t reverseX = (kMatrixWidth - 1) - x; 30 | i = (y * kMatrixWidth) + reverseX; 31 | } else { 32 | // Even rows run forwards 33 | i = (y * kMatrixWidth) + x; 34 | } 35 | } 36 | 37 | return i; 38 | } 39 | 40 | #define NUM_LEDS (kMatrixWidth * kMatrixHeight) 41 | CRGB leds[NUM_LEDS]; 42 | 43 | void setup() { 44 | FastLED.addLeds(leds, NUM_LEDS).setCorrection(TypicalSMD5050); 45 | FastLED.setBrightness( BRIGHTNESS ); 46 | } 47 | 48 | int hue = 0; 49 | void loop() { 50 | FastLED.clear(); 51 | for(int i = 0; i < (kMatrixWidth / 2); i++) { 52 | square(i, CHSV(hue, 255, 255)); 53 | hue += 15; 54 | } 55 | FastLED.delay(100); 56 | } 57 | 58 | void square(int s, CRGB color) { 59 | int p = (kMatrixWidth - 1) - s; 60 | for(int i = s; i <= p; i++) { 61 | leds[XY(i,s)] = color; 62 | } 63 | for(int i = s; i <= p; i++) { 64 | leds[XY(s,i)] = color; 65 | } 66 | for(int i = s; i <= p; i++) { 67 | leds[XY(p,i)] = color; 68 | } 69 | for(int i = s; i <= p; i++) { 70 | leds[XY(i,p)] = color; 71 | } 72 | } 73 | 74 | -------------------------------------------------------------------------------- /FastLED-Patterns/Concentric_Squares/README.md: -------------------------------------------------------------------------------- 1 | Pattern for square matrix, concentric squares into center 2 | 3 | https://photos.app.goo.gl/wJuNCqDjPJwRQJM66 4 | -------------------------------------------------------------------------------- /FastLED-Patterns/Datchet/Datchet.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define LED_PIN 6 4 | 5 | #define COLOR_ORDER RGB 6 | #define CHIPSET WS2811 7 | 8 | #define NUM_LEDS 400 9 | 10 | CRGB leds[NUM_LEDS]; //naming our LED array 11 | 12 | void setup() { 13 | FastLED.addLeds(leds, NUM_LEDS).setCorrection(TypicalSMD5050); 14 | FastLED.setBrightness( 255 ); 15 | } 16 | 17 | void loop() { 18 | // chase(); 19 | snake(); 20 | } 21 | 22 | int p = 0; 23 | int hue = 0; 24 | void chase() { 25 | leds[p] = CHSV( hue, 255, 255); 26 | FastLED.show(); 27 | delay(1); 28 | hue += random(0,20); 29 | if (hue > 255) hue = 0; 30 | p++; 31 | if(p > ( NUM_LEDS - 1)) p=0; 32 | for(int i = 0; i < NUM_LEDS; i++) { 33 | // leds[i].fadeToBlackBy(10); 34 | leds[i].fadeLightBy(10); 35 | } 36 | } 37 | 38 | 39 | class Snake { 40 | int p = 0; 41 | int hue = random(0,255); 42 | int v = random(50,255); 43 | 44 | public: 45 | Snake() { 46 | 47 | } 48 | 49 | void snake() { 50 | leds[p] = CHSV(hue, 255, v); 51 | p++; 52 | if(p > ( NUM_LEDS - 1)) { 53 | p=0; 54 | hue = random(0,255); 55 | } 56 | } 57 | }; 58 | 59 | #define NUM_SNAKES 30 60 | Snake snakes[NUM_SNAKES]; 61 | 62 | int snakesStarted = 0; 63 | int const snakeDelay = 20; 64 | int snakeGap = 0; 65 | 66 | void snake() { 67 | 68 | if (snakesStarted < NUM_SNAKES) { 69 | if (snakeGap == snakeDelay) { 70 | snakesStarted++; 71 | snakeGap = 0; 72 | } 73 | else { 74 | snakeGap++; 75 | } 76 | } 77 | 78 | for (int i = 0; i < snakesStarted; i++) { 79 | snakes[i].snake(); 80 | } 81 | fadeToBlackBy(leds, NUM_LEDS, 20); 82 | // fadeLightBy(leds, NUM_LEDS, 2); 83 | FastLED.delay(40); 84 | } 85 | 86 | 87 | -------------------------------------------------------------------------------- /FastLED-Patterns/Datchet/README.md: -------------------------------------------------------------------------------- 1 | Chase of multiple trails, each of own colour 2 | 3 | https://photos.app.goo.gl/KrUeoTFdMbVZFAmk8 4 | -------------------------------------------------------------------------------- /FastLED-Patterns/Stars/README.md: -------------------------------------------------------------------------------- 1 | Random pattern of points of light that fade 2 | 3 | https://photos.app.goo.gl/oBxF3ekqeGBMFYC68 4 | -------------------------------------------------------------------------------- /FastLED-Patterns/Stars/Stars.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define LED_PIN 6 4 | 5 | #define COLOR_ORDER RGB 6 | #define CHIPSET WS2811 7 | 8 | #define NUM_LEDS 900 9 | 10 | CRGB leds[NUM_LEDS]; //naming our LED array 11 | 12 | #include "stars.h" 13 | 14 | void setup() { 15 | // FastLED.addLeds(leds, NUM_LEDS).setCorrection(TypicalSMD5050); 16 | FastLED.addLeds(leds, NUM_LEDS).setCorrection( TypicalLEDStrip ); 17 | 18 | FastLED.setBrightness( 130 ); 19 | FastLED.setDither(0); 20 | 21 | for (int i = 0; i < NUM_LEDS; i++) { 22 | stars[i].setPixel(i); 23 | } 24 | } 25 | 26 | void loop() { 27 | showStars(); 28 | } 29 | 30 | int p = 0; 31 | int hue = 0; 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /FastLED-Patterns/Stars/stars.h: -------------------------------------------------------------------------------- 1 | class Star { 2 | int p = 0; 3 | int dir = 0; 4 | uint8_t hue = random(0, 255); 5 | int v = 0; 6 | int vary = random(1, 5); 7 | int r = 15; 8 | 9 | public: 10 | Star() { 11 | 12 | } 13 | 14 | void setPixel(int pixel) { 15 | p = pixel; 16 | } 17 | 18 | void sparkle() { 19 | // should we change colour? 20 | if (random(1, r) == 1) { 21 | if (dir > 0) { 22 | hue += vary; 23 | } 24 | else { 25 | hue -= vary; 26 | } 27 | // should we change direction? 28 | if (random(1, 25) == 1) { 29 | dir = random(0, 1); 30 | if (v == 0) v = 255; 31 | } 32 | } 33 | if (v >= 1) v--; 34 | leds[p] = CHSV(hue, 255, v); 35 | } 36 | }; 37 | 38 | 39 | 40 | Star stars[NUM_LEDS]; 41 | 42 | void showStars() { 43 | for (int i = 0; i < NUM_LEDS; i++) { 44 | stars[i].sparkle(); 45 | } 46 | FastLED.delay(0); 47 | } 48 | 49 | 50 | -------------------------------------------------------------------------------- /FastLED-Patterns/Table_EQ/Table_EQ.ino: -------------------------------------------------------------------------------- 1 | // Example 48.3 - tronixstuff.com/tutorials > chapter 48 - 30 Jan 2013 2 | // MSGEQ7 spectrum analyser shield with a Freetronics DMD 3 | // for DMD 4 | #include "SPI.h" // SPI.h must be included as DMD is written by SPI (the IDE complains otherwise) 5 | #include 6 | #include "MSGEQ7.h" 7 | #define pinAnalogLeft A0 8 | #define pinAnalogRight A1 9 | #define pinReset 5 10 | #define pinStrobe 4 11 | #define MSGEQ7_INTERVAL ReadsPerSecond(80) 12 | #define MSGEQ7_SMOOTH true 13 | 14 | CMSGEQ7 MSGEQ7; 15 | 16 | int strobe = 4; // strobe pins on digital 4 17 | int res = 5; // reset pins on digital 5 18 | 19 | int band; 20 | 21 | #define LED_PIN 2 22 | #define CLOCK_PIN 6 23 | 24 | #define COLOR_ORDER BGR 25 | #define CHIPSET DOTSTAR 26 | 27 | #define BRIGHTNESS 20 28 | 29 | #define WIDTH 15 30 | #define HEIGHT 7 31 | 32 | #define NUM_LEDS 225 33 | 34 | CRGB leds[NUM_LEDS]; 35 | 36 | void setup() 37 | { 38 | 39 | MSGEQ7.begin(); 40 | 41 | // LEDS 42 | LEDS.setBrightness(BRIGHTNESS); 43 | FastLED.addLeds(leds, NUM_LEDS).setCorrection( TypicalLEDStrip ); 44 | 45 | } 46 | 47 | void loop() 48 | { 49 | int xpos; 50 | // analyze without delay 51 | bool newReading = MSGEQ7.read(MSGEQ7_INTERVAL); 52 | 53 | // Led strip output 54 | if (newReading) { 55 | // display values of left channel on DMD 56 | for ( band = 0; band < 7; band++ ) 57 | { 58 | xpos = map((band + 1), 1, 7, 7, 1); 59 | int count = map(MSGEQ7.get(band), 0, 255, 0, HEIGHT); 60 | for (int i = 1; i <= WIDTH; i++) { 61 | if (i <= count) { 62 | leds[xytopixel(xpos, i)] = CRGB::Red; 63 | } 64 | else { 65 | leds[xytopixel(xpos, i)] = CRGB::Black; 66 | } 67 | } 68 | } 69 | 70 | // display values of left channel on DMD 71 | for ( band = 0; band < 7; band++ ) 72 | { 73 | xpos = 7 + band + 1; 74 | int count = map(MSGEQ7.get(band), 0, 255, 0, HEIGHT); 75 | for (int i = 1; i <= WIDTH; i++) { 76 | if (i <= count) { 77 | leds[xytopixel(xpos, i)] = CRGB::Green; 78 | } 79 | else { 80 | leds[xytopixel(xpos, i)] = CRGB::Black; 81 | } 82 | } 83 | } 84 | 85 | // leds[50] = CRGB::Red; 86 | 87 | FastLED.show(); 88 | } 89 | } 90 | 91 | 92 | int xytopixel(int x, int y) { 93 | return ((y - 1) * WIDTH) + (x - 1); 94 | } 95 | -------------------------------------------------------------------------------- /MSEQ7_vu_matrix/MSEQ7_vu_matrix.ino: -------------------------------------------------------------------------------- 1 | /**************************************** 2 | * Scrolling Sound Meter Sketch for the 3 | * Adafruit Microphone Amplifier 4 | ****************************************/ 5 | 6 | #include 7 | 8 | #include "MSGEQ7.h" 9 | #define pinAnalogLeft A0 10 | #define pinAnalogRight A1 11 | #define pinReset 5 12 | #define pinStrobe 4 13 | #define MSGEQ7_INTERVAL ReadsPerSecond(20) 14 | #define MSGEQ7_SMOOTH true 15 | 16 | CMSGEQ7 MSGEQ7; 17 | 18 | #define LED_PIN 2 19 | #define CLOCK_PIN 6 20 | 21 | #define COLOR_ORDER BGR 22 | #define CHIPSET DOTSTAR 23 | 24 | #define BRIGHTNESS 50 25 | #define DITHER 255 // try 0 to disable flickering 26 | 27 | #define WIDTH 8 28 | #define HEIGHT 15 29 | 30 | CRGB leds[(WIDTH * HEIGHT)]; 31 | 32 | CRGB color; 33 | 34 | const boolean gay = false; 35 | 36 | void setup() { 37 | Serial.begin(9600); 38 | FastLED.setBrightness(BRIGHTNESS); 39 | FastLED.setDither(DITHER); 40 | FastLED.addLeds(leds, (WIDTH * HEIGHT)).setCorrection( TypicalLEDStrip ); 41 | } 42 | 43 | 44 | void loop() { 45 | bool newReading = MSGEQ7.read(MSGEQ7_INTERVAL); 46 | 47 | // Led strip output 48 | if (newReading) { 49 | 50 | int displayPeakL = map(MSGEQ7.get(MSGEQ7_LOW, 0), 0, 255, 0, round(HEIGHT / 2)); 51 | int displayPeakR = map(MSGEQ7.get(MSGEQ7_LOW, 1), 0, 255, 0, round(HEIGHT / 2)); 52 | Serial.print("Display peak: "); 53 | Serial.println(displayPeakL); 54 | 55 | moveRight(); 56 | int offset = round(HEIGHT / 2); 57 | 58 | for (int i = 1; i <= HEIGHT; i++){ 59 | drawPixel(1, i, CRGB::Black); 60 | } 61 | 62 | for (int i = 1; i <= HEIGHT; i++){ 63 | drawPixel(1, offset, CRGB::Blue); 64 | } 65 | 66 | for(int i=1; i <= displayPeakL; i++) { 67 | if(gay) { 68 | color = CHSV(map(i, 1, (HEIGHT/2), 0, 230), 255, 255); 69 | } 70 | else { 71 | unsigned int g = map(i, 1, HEIGHT, 254, 0); 72 | color = CRGB(map(i , 1, HEIGHT, 0, 254), g, 0); 73 | } 74 | drawPixel(1, (offset - i), color); 75 | } 76 | for(int i=1; i <= displayPeakR; i++) { 77 | if(gay) { 78 | color = CHSV(map(i, 1, (HEIGHT/2), 230, 0), 255, 255); 79 | } 80 | else { 81 | unsigned int g = map(i, 1, (HEIGHT/2), 254, 0); 82 | color = CRGB(map(i , 1, (HEIGHT/2), 0, 254), g, 0); 83 | } 84 | drawPixel(1, (offset + i), color); 85 | } 86 | 87 | FastLED.show(); 88 | } 89 | } 90 | 91 | /* 92 | 1,1 = 0 93 | 1,2 = 1 94 | 2,1 = 15 95 | */ 96 | 97 | int xytopixel(int x, int y) { 98 | int p = ((x - 1) * HEIGHT) + (y - 1); 99 | return p; 100 | } 101 | 102 | void drawPixel(int x, int y, CRGB color) { 103 | leds[xytopixel(x, y)] = color; 104 | } 105 | 106 | void moveRight() { 107 | // Update the display: 108 | for (int i = HEIGHT; i >= 1; i--) { 109 | for (int j = WIDTH; j >= 1; j--) { 110 | int src = xytopixel((j - 1), i); 111 | int dst = xytopixel(j, i); 112 | leds[dst] = leds[src]; 113 | } 114 | } 115 | } 116 | 117 | 118 | -------------------------------------------------------------------------------- /MSGEQ7_FastLED/MSGEQ7_FastLED.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014-2015 NicoHood 3 | See the readme for credit to other people. 4 | 5 | MSGEQ7 FastLED example 6 | Output via Led strip and FastLED library 7 | 8 | Reads MSGEQ7 IC with 7 different frequencies from range 0-255 9 | 63Hz, 160Hz, 400Hz, 1kHz, 2.5kHz, 6.25KHz, 16kHz 10 | */ 11 | 12 | // FastLED 13 | #include "FastLED.h" 14 | 15 | #define LED_PIN 1 16 | #define CLOCK_PIN 6 17 | 18 | #define COLOR_ORDER BGR 19 | #define CHIPSET WS2812 20 | #define NUM_LEDS 120 21 | 22 | #define BRIGHTNESS 55 // reduce power consumption 23 | #define DITHER 255 // try 0 to disable flickering 24 | #define CORRECTION TypicalLEDStrip 25 | 26 | CRGB leds[NUM_LEDS]; // Define the array of leds 27 | 28 | // MSGEQ7 29 | #include "MSGEQ7.h" 30 | //#define pinAnalogLeft A0 31 | //#define pinAnalogRight A1 32 | //#define pinReset 5 33 | //#define pinStrobe 4 34 | 35 | // ESP32 36 | #define LED_PIN 19 37 | #define pinAnalogLeft 4 38 | #define pinAnalogRight 4 39 | #define pinReset 34 40 | #define pinStrobe 35 41 | 42 | #define MSGEQ7_INTERVAL ReadsPerSecond(50) 43 | #define MSGEQ7_SMOOTH true 44 | 45 | CMSGEQ7 MSGEQ7; 46 | 47 | void setup() { 48 | // FastLED setup 49 | FastLED.addLeds(leds, NUM_LEDS).setCorrection(CORRECTION); 50 | FastLED.setBrightness( BRIGHTNESS ); 51 | FastLED.setDither(DITHER); 52 | FastLED.show(); // needed to reset leds to zero 53 | 54 | // this will set the IC ready for reading 55 | MSGEQ7.begin(); 56 | } 57 | 58 | void loop() { 59 | // analyze without delay 60 | bool newReading = MSGEQ7.read(MSGEQ7_INTERVAL); 61 | 62 | // Led strip output 63 | if (newReading) { 64 | // visualize the average bass of both channels 65 | uint8_t val = MSGEQ7.get(MSGEQ7_BASS); 66 | 67 | // reduce noise 68 | // val = MSGEQ7.map(val); 69 | 70 | // visualize leds to the beat 71 | CRGB color = CRGB::Blue; 72 | color.nscale8_video(val); 73 | fill_solid(leds, NUM_LEDS, color); 74 | 75 | // update Leds 76 | FastLED.show(); 77 | } 78 | } 79 | 80 | -------------------------------------------------------------------------------- /MSGEQ7_FastLED_Rings/MSGEQ7_FastLED_Rings.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014-2016 NicoHood 3 | See the readme for credit to other people. 4 | 5 | MSGEQ7 FastLED example 6 | Output via Led strip and FastLED library 7 | 8 | Reads MSGEQ7 IC with 7 different frequencies from range 0-255 9 | 63Hz, 160Hz, 400Hz, 1kHz, 2.5kHz, 6.25KHz, 16kHz 10 | */ 11 | 12 | // FastLED 13 | #include "FastLED.h" 14 | 15 | #define COLOR_ORDER GRB 16 | #define CHIPSET WS2812B // WS2811 LPD8806 17 | #define NUM_LEDS 241 18 | 19 | #define BRIGHTNESS 255 // reduce power consumption 20 | #define LED_DITHER 255 // try 0 to disable flickering 21 | #define CORRECTION TypicalLEDStrip 22 | 23 | CRGB leds[NUM_LEDS]; // Define the array of leds 24 | 25 | // MSGEQ7 26 | #include "MSGEQ7.h" 27 | #define MSGEQ7_INTERVAL ReadsPerSecond(50) 28 | #define MSGEQ7_SMOOTH true 29 | 30 | // ESP8266 31 | //#define LED_PIN D4 32 | //#define pinAnalogLeft A0 33 | //#define pinAnalogRight A0 34 | //#define pinReset D3 35 | //#define pinStrobe D2 36 | 37 | // ESP32 38 | #define LED_PIN 19 39 | #define pinAnalogLeft 4 40 | #define pinAnalogRight 4 41 | #define pinReset 34 42 | #define pinStrobe 35 43 | 44 | 45 | 46 | CMSGEQ7 MSGEQ7; 47 | 48 | CRGBPalette16 currentPalette; 49 | TBlendType currentBlending; 50 | 51 | void setup() { 52 | 53 | currentPalette = RainbowColors_p; 54 | currentBlending = LINEARBLEND; 55 | 56 | // FastLED setup 57 | FastLED.addLeds(leds, NUM_LEDS).setCorrection(CORRECTION); 58 | FastLED.setBrightness( BRIGHTNESS ); 59 | FastLED.setDither(LED_DITHER); 60 | FastLED.show(); // needed to reset leds to zero 61 | 62 | leds[0] = CRGB::Red; 63 | FastLED.delay(2000); 64 | 65 | // This will set the IC ready for reading 66 | MSGEQ7.begin(); 67 | } 68 | 69 | void loop() { 70 | // Analyze without delay 71 | bool newReading = MSGEQ7.read(MSGEQ7_INTERVAL); 72 | 73 | // Led strip output 74 | if (newReading) { 75 | for(int i = 0; i < 7; i++) { 76 | // visualize the average bass of both channels 77 | uint8_t val = MSGEQ7.get(i); 78 | 79 | // Reduce noise 80 | val = mapNoise(val); 81 | 82 | // Visualize leds to the beat 83 | CRGB color = ColorFromPalette(currentPalette, val, 255, currentBlending); 84 | color.nscale8_video(val); 85 | setRing(i, color); 86 | } 87 | 88 | // Update Leds 89 | FastLED.show(); 90 | } 91 | } 92 | 93 | 94 | void setRing(int ring, CRGB colour) { 95 | int offset = 0; 96 | int count = 0; 97 | switch (ring) { 98 | case 1: 99 | count = 1; 100 | break; 101 | case 2: 102 | offset = 1; 103 | count = 8; 104 | break; 105 | case 3: 106 | offset = 9; 107 | count = 12; 108 | break; 109 | case 4: 110 | offset = 21; 111 | count = 16; 112 | break; 113 | case 5: 114 | offset = 37; 115 | count = 24; 116 | break; 117 | case 6: 118 | offset = 61; 119 | count = 32; 120 | break; 121 | case 7: 122 | offset = 93; 123 | count = 40; 124 | break; 125 | case 8: 126 | offset =133; 127 | count = 48; 128 | break; 129 | case 9: 130 | offset = 181; 131 | count = 60; 132 | break; 133 | } 134 | for (int i = 0; i < count; i++) { 135 | leds[(offset + i)] = colour; 136 | } 137 | } 138 | 139 | -------------------------------------------------------------------------------- /SegmentMirror/SegmentMirror.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define NUM_LEDS_PER_STRIP 50 4 | #define NUM_STRIPS 8 5 | const uint8_t kMatrixWidth = 50; // length of string 6 | const uint8_t kMatrixHeight = 16; // number of strings 7 | #define LED_TYPE WS2811 8 | #define LED_PIN D4 9 | #define COLOR_ORDER BGR 10 | 11 | CRGB ledSegment[NUM_LEDS_PER_STRIP]; 12 | 13 | #define NUM_LEDS (NUM_STRIPS * NUM_LEDS_PER_STRIP) 14 | CRGB leds[NUM_LEDS]; 15 | 16 | const bool kMatrixSerpentineLayout = true; 17 | 18 | void setup() { 19 | FastLED.addLeds(leds, NUM_LEDS).setCorrection( TypicalLEDStrip ); 20 | // FastLED.addLeds(leds, NUM_LEDS).setCorrection( TypicalLEDStrip ); 21 | } 22 | 23 | void loop() { 24 | FillLEDsFromPaletteColors(0); 25 | showSegments(); 26 | //FastLED.show(); 27 | } 28 | 29 | void FillLEDsFromPaletteColors( uint8_t colorIndex) 30 | { 31 | uint8_t brightness = 255; 32 | for ( int i = 0; i < NUM_LEDS_PER_STRIP; i++) { 33 | ledSegment[i] = ColorFromPalette( RainbowColors_p, colorIndex, brightness, LINEARBLEND); 34 | colorIndex += 3; 35 | } 36 | } 37 | 38 | 39 | void showSegments() { 40 | for (int s = 0; s < NUM_STRIPS; s++) { 41 | for (int i = 0; i < NUM_LEDS_PER_STRIP; i++) { 42 | int p = (s * NUM_LEDS_PER_STRIP) + i; 43 | leds[getPixel(p)] = ledSegment[i]; 44 | } 45 | } 46 | FastLED.delay(1000); 47 | } 48 | 49 | 50 | uint16_t getPixel(int p) 51 | { 52 | uint16_t i; 53 | 54 | if ( kMatrixSerpentineLayout == false) { 55 | i = p; 56 | } 57 | 58 | if ( kMatrixSerpentineLayout == true) { 59 | float f = ((float)(p + 1) / (float) kMatrixWidth); 60 | int r = ceil(f); 61 | 62 | if (r & 0x01) { 63 | i = p; 64 | } else { 65 | i = ((kMatrixWidth * r) - (p % kMatrixWidth)) - 1; 66 | } 67 | } 68 | 69 | if (i >= (NUM_LEDS - 1)) return 0; 70 | return i; 71 | } 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /Shimmer/Shimmer.ino: -------------------------------------------------------------------------------- 1 | #include "FastLED.h" 2 | #define NUM_LEDS 64 3 | CRGB leds[NUM_LEDS]; 4 | void setup() { 5 | Serial.begin(9600); 6 | FastLED.setBrightness(30); 7 | FastLED.addLeds(leds, NUM_LEDS); 8 | } 9 | void loop() { 10 | int i = 1; 11 | int x = 1; 12 | 13 | boolean xrand = true; 14 | boolean irand = true; 15 | 16 | unsigned int l = 0; 17 | 18 | while(true) { 19 | 20 | /* 21 | if(l > 500) { 22 | l = 0; 23 | if(random(1,2) == 1) { 24 | xrand = true; 25 | } 26 | else { 27 | xrand = false; 28 | } 29 | if(random(1,2) == 1) { 30 | irand = true; 31 | } 32 | else { 33 | irand = false; 34 | } 35 | Serial.print("Mode change xrand="); 36 | Serial.print(xrand); 37 | Serial.print(" irand="); 38 | Serial.println(irand); 39 | } 40 | l++; 41 | /*/ 42 | 43 | 44 | for(int dot = -1; dot < NUM_LEDS; dot += i) { 45 | leds[dot].setHue(x); 46 | // leds[dot] = CRGB::Blue; 47 | FastLED.show(); 48 | // clear this led for the next time around the loop 49 | // leds[dot] = CRGB::Black; 50 | delay(10); 51 | } 52 | 53 | if(irand) { 54 | i = random(2, 40); 55 | } 56 | else { 57 | if(i < 40) { i++; } else { i = 1; } 58 | } 59 | 60 | if(xrand) { 61 | x = random(1,255); 62 | } 63 | else { 64 | if(x < 255) { x++; } else { x = 1; } 65 | 66 | } 67 | } 68 | } 69 | 70 | 71 | -------------------------------------------------------------------------------- /SmartMatrixTests/DemoReel100SmartMatrix/DemoReel100SmartMatrix.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | FASTLED_USING_NAMESPACE 4 | 5 | // FastLED "100-lines-of-code" demo reel, showing just a few 6 | // of the kinds of animation patterns you can quickly and easily 7 | // compose using FastLED. 8 | // 9 | // This example also shows one easy way to define multiple 10 | // animations patterns and have them automatically rotate. 11 | // 12 | // -Mark Kriegsman, December 2014 13 | 14 | #if defined(FASTLED_VERSION) && (FASTLED_VERSION < 3001000) 15 | #warning "Requires FastLED 3.1 or later; check github for latest code." 16 | #endif 17 | 18 | 19 | #define BRIGHTNESS 125 20 | #define FRAMES_PER_SECOND 120 21 | 22 | #define USE_SMART_MATRIX 23 | 24 | #if defined(USE_SMART_MATRIX) 25 | #include "smartmatrixControl.h" 26 | #else 27 | #include "default.h" 28 | #endif 29 | 30 | 31 | 32 | void setup() { 33 | delay(3000); // 3 second delay for recovery 34 | controlSetup(); 35 | } 36 | 37 | 38 | // List of patterns to cycle through. Each is defined as a separate function below. 39 | typedef void (*SimplePatternList[])(); 40 | SimplePatternList gPatterns = { rainbow, rainbowWithGlitter, confetti, sinelon, juggle, bpm }; 41 | 42 | uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current 43 | uint8_t gHue = 0; // rotating "base color" used by many of the patterns 44 | 45 | void loop() 46 | { 47 | // Call the current pattern function once, updating the 'leds' array 48 | gPatterns[gCurrentPatternNumber](); 49 | 50 | controlLoop(); 51 | 52 | // do some periodic updates 53 | EVERY_N_MILLISECONDS( 20 ) { gHue++; } // slowly cycle the "base color" through the rainbow 54 | EVERY_N_SECONDS( 10 ) { nextPattern(); } // change patterns periodically 55 | } 56 | 57 | #define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0])) 58 | 59 | void nextPattern() 60 | { 61 | // add one to the current pattern number, and wrap around at the end 62 | gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE( gPatterns); 63 | } 64 | 65 | void rainbow() 66 | { 67 | // FastLED's built-in rainbow generator 68 | fill_rainbow( leds, NUM_LEDS, gHue, 7); 69 | } 70 | 71 | void rainbowWithGlitter() 72 | { 73 | // built-in FastLED rainbow, plus some random sparkly glitter 74 | rainbow(); 75 | addGlitter(80); 76 | } 77 | 78 | void addGlitter( fract8 chanceOfGlitter) 79 | { 80 | if( random8() < chanceOfGlitter) { 81 | leds[ random16(NUM_LEDS) ] += CRGB::White; 82 | } 83 | } 84 | 85 | void confetti() 86 | { 87 | // random colored speckles that blink in and fade smoothly 88 | fadeToBlackBy( leds, NUM_LEDS, 10); 89 | int pos = random16(NUM_LEDS); 90 | leds[pos] += CHSV( gHue + random8(64), 200, 255); 91 | } 92 | 93 | void sinelon() 94 | { 95 | // a colored dot sweeping back and forth, with fading trails 96 | fadeToBlackBy( leds, NUM_LEDS, 20); 97 | int pos = beatsin16( 13, 0, NUM_LEDS-1 ); 98 | leds[pos] += CHSV( gHue, 255, 192); 99 | } 100 | 101 | void bpm() 102 | { 103 | // colored stripes pulsing at a defined Beats-Per-Minute (BPM) 104 | uint8_t BeatsPerMinute = 62; 105 | CRGBPalette16 palette = PartyColors_p; 106 | uint8_t beat = beatsin8( BeatsPerMinute, 64, 255); 107 | for( int i = 0; i < NUM_LEDS; i++) { //9948 108 | leds[i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10)); 109 | } 110 | } 111 | 112 | void juggle() { 113 | // eight colored dots, weaving in and out of sync with each other 114 | fadeToBlackBy( leds, NUM_LEDS, 20); 115 | byte dothue = 0; 116 | for( int i = 0; i < 8; i++) { 117 | leds[beatsin16( i+7, 0, NUM_LEDS-1 )] |= CHSV(dothue, 200, 255); 118 | dothue += 32; 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /SmartMatrixTests/DemoReel100SmartMatrix/default.h: -------------------------------------------------------------------------------- 1 | /* 2 | Default config file with normal FastLED stuff 3 | */ 4 | #define FASTLED_ALLOW_INTERRUPTS 0 5 | #define DATA_PIN 2 6 | //#define CLK_PIN 4 7 | #define LED_TYPE WS2811 8 | #define COLOR_ORDER GRB 9 | #define NUM_LEDS 64 10 | CRGB leds[NUM_LEDS]; 11 | 12 | void controlSetup() { 13 | // tell FastLED about the LED strip configuration 14 | FastLED.addLeds(leds, NUM_LEDS).setCorrection(TypicalLEDStrip); 15 | //FastLED.addLeds(leds, NUM_LEDS).setCorrection(TypicalLEDStrip); 16 | 17 | // set master brightness control 18 | FastLED.setBrightness(BRIGHTNESS); 19 | } 20 | 21 | void controlLoop() { 22 | // send the 'leds' array out to the actual LED strip 23 | FastLED.show(); 24 | // insert a delay to keep the framerate modest 25 | FastLED.delay(1000 / FRAMES_PER_SECOND); 26 | } 27 | -------------------------------------------------------------------------------- /SmartMatrixTests/DemoReel100SmartMatrix/smartmatrixControl.h: -------------------------------------------------------------------------------- 1 | #include // comment out this line for if you're not using SmartLED Shield V4 hardware (this line needs to be before #include ) 2 | #include 3 | #include 4 | 5 | #define COLOR_DEPTH 24 // This sketch and FastLED uses type `rgb24` directly, COLOR_DEPTH must be 24 6 | const uint8_t kMatrixWidth = 64; // known working: 32, 64, 96, 128 7 | const uint8_t kMatrixHeight = 64; // known working: 16, 32, 48, 64 8 | const uint8_t kRefreshDepth = 36; // known working: 24, 36, 48 9 | const uint8_t kDmaBufferRows = 4; // known working: 2-4, use 2 to save memory, more to keep from dropping frames and automatically lowering refresh rate 10 | const uint8_t kPanelType = SMARTMATRIX_HUB75_64ROW_MOD32SCAN; // use SMARTMATRIX_HUB75_16ROW_MOD8SCAN for common 16x32 panels 11 | const uint8_t kMatrixOptions = (SMARTMATRIX_OPTIONS_NONE); // see http://docs.pixelmatix.com/SmartMatrix for options 12 | const uint8_t kBackgroundLayerOptions = (SM_BACKGROUND_OPTIONS_NONE); 13 | const uint8_t kScrollingLayerOptions = (SM_SCROLLING_OPTIONS_NONE); 14 | 15 | SMARTMATRIX_ALLOCATE_BUFFERS(matrix, kMatrixWidth, kMatrixHeight, kRefreshDepth, kDmaBufferRows, kPanelType, kMatrixOptions); 16 | SMARTMATRIX_ALLOCATE_BACKGROUND_LAYER(backgroundLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kBackgroundLayerOptions); 17 | SMARTMATRIX_ALLOCATE_SCROLLING_LAYER(scrollingLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kScrollingLayerOptions); 18 | 19 | #define NUM_LEDS (kMatrixWidth * kMatrixHeight) 20 | CRGB leds[NUM_LEDS]; 21 | 22 | void controlSetup() { 23 | matrix.addLayer(&backgroundLayer); 24 | matrix.addLayer(&scrollingLayer); 25 | matrix.begin(); 26 | matrix.setBrightness( BRIGHTNESS ); 27 | } 28 | 29 | void controlLoop() { 30 | rgb24 *buffer = backgroundLayer.backBuffer(); 31 | for (int i = 0; i < NUM_LEDS; i++) { 32 | buffer[i].red = leds[i].r; 33 | buffer[i].green = leds[i].g; 34 | buffer[i].blue = leds[i].b; 35 | } 36 | backgroundLayer.swapBuffers(); 37 | delay(1000 / FRAMES_PER_SECOND); 38 | } 39 | -------------------------------------------------------------------------------- /SmartMatrixTests/FeatureDemoTeensy4/gimpbitmap.h: -------------------------------------------------------------------------------- 1 | #ifndef _GIMPBITMAP_ 2 | #define _GIMPBITMAP_ 3 | 4 | // this structre can hold up to a 32x32 pixel RGB bitmap 5 | typedef struct { 6 | unsigned int width; 7 | unsigned int height; 8 | unsigned int bytes_per_pixel; /* 2:RGB16, 3:RGB, 4:RGBA */ 9 | unsigned char pixel_data[32*32*3 + 1]; 10 | } gimp32x32bitmap; 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /Snakes/Snakes.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define LED_PIN 6 4 | 5 | #define COLOR_ORDER RGB 6 | #define CHIPSET WS2811 7 | 8 | int kMatrixWidth = 30; 9 | int kMatrixHeight = 30; 10 | 11 | #define NUM_LEDS 900 12 | 13 | #define NUM_SNAKES 10 14 | 15 | 16 | CRGB leds[NUM_LEDS]; //naming our LED array 17 | 18 | bool kMatrixSerpentineLayout = true; 19 | uint16_t XY( uint8_t x, uint8_t y) 20 | { 21 | uint16_t i; 22 | if (x > kMatrixWidth) return 0; 23 | if (y > kMatrixHeight) return 0; 24 | 25 | if ( kMatrixSerpentineLayout == false) { 26 | i = (y * kMatrixWidth) + x; 27 | } 28 | 29 | if ( kMatrixSerpentineLayout == true) { 30 | if ( y & 0x01) { 31 | // Odd rows run backwards 32 | uint8_t reverseX = (kMatrixWidth - 1) - x; 33 | i = (y * kMatrixWidth) + reverseX; 34 | } else { 35 | // Even rows run forwards 36 | i = (y * kMatrixWidth) + x; 37 | } 38 | } 39 | 40 | if (i >= (NUM_LEDS - 1)) return 0; 41 | return i; 42 | } 43 | 44 | 45 | 46 | class Snake { 47 | int dir = 0; 48 | uint8_t hue = random(0, 255); 49 | int v = 255; 50 | int r = random(1,20); 51 | int rskip = r; 52 | 53 | int x = 0; 54 | int y = 0; 55 | 56 | int moveX = random(-1, 1); 57 | int moveY = random(-1, 1); 58 | 59 | public: 60 | Snake() { 61 | 62 | } 63 | 64 | void setXY(int newX, int newY) { 65 | x = newX; 66 | y = newY; 67 | if (moveX == 0 && moveY == 0) { 68 | moveX = 1; 69 | moveY = 1; 70 | } 71 | } 72 | 73 | void moveSnake() { 74 | 75 | rskip--; 76 | if (rskip == 0) { 77 | rskip = r; 78 | 79 | x += moveX; 80 | y += moveY; 81 | 82 | if (x > kMatrixWidth) { 83 | Serial.println("x > kMatrixWidth"); 84 | x -= moveX; 85 | moveX = -1; 86 | // if(random(0,1) == 1) { 87 | moveY = random(-1, 1); 88 | // } 89 | } 90 | if (y > kMatrixHeight) { 91 | Serial.println("y > kMatrixHeight"); 92 | y -= moveY; 93 | moveY = -1; 94 | // if(random(0,1) == 1) { 95 | moveX = random(-1, 1); 96 | // } 97 | } 98 | 99 | 100 | if (x < 0) { 101 | Serial.println("x < 1"); 102 | x += moveX; 103 | moveX = 1; 104 | //if(random(0,1) == 1) { 105 | moveY = random(-1, 1); 106 | // } 107 | } 108 | if (y < 0) { 109 | Serial.println("y < 1"); 110 | y += moveY; 111 | moveY = 1; 112 | //if(random(0,1) == 1) { 113 | moveX = random(-1, 1); 114 | // } 115 | } 116 | } 117 | leds[XY(x, y)] = CHSV(hue, 255, v); 118 | } 119 | }; 120 | 121 | 122 | 123 | Snake snakes[NUM_SNAKES]; 124 | 125 | void setup() { 126 | FastLED.addLeds(leds, NUM_LEDS).setCorrection(TypicalSMD5050); 127 | FastLED.setBrightness( 30 ); 128 | FastLED.setDither(0); 129 | 130 | randomSeed(analogRead(0)); 131 | Serial.begin(115200); 132 | 133 | for (int i = 0; i < NUM_SNAKES; i++) { 134 | snakes[i].setXY(random(1, kMatrixWidth), random(1, kMatrixHeight)); 135 | } 136 | } 137 | 138 | void loop() { 139 | snake(); 140 | } 141 | 142 | void snake() { 143 | 144 | for (int i = 0; i < NUM_SNAKES; i++) { 145 | snakes[i].moveSnake(); 146 | } 147 | FastLED.delay(0); 148 | // FastLED.clear(); 149 | fadeToBlackBy( leds, NUM_LEDS, 40); 150 | } 151 | 152 | 153 | -------------------------------------------------------------------------------- /Vortex/README.md: -------------------------------------------------------------------------------- 1 | Chasing trails, spiralling into centre 2 | 3 | https://photos.app.goo.gl/EvPeGW8sUEQ3hbbs6 4 | -------------------------------------------------------------------------------- /Vortex/Vortex.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // Params for width and height 4 | const uint8_t kMatrixWidth = 30; 5 | const uint8_t kMatrixHeight = 30; 6 | 7 | #define LED_PIN 1 8 | 9 | #define COLOR_ORDER RGB 10 | #define CHIPSET WS2812 11 | 12 | #define BRIGHTNESS 55 13 | 14 | // Param for different pixel layouts 15 | const bool kMatrixSerpentineLayout = true; 16 | 17 | 18 | uint16_t XY( uint8_t x, uint8_t y) 19 | { 20 | uint16_t i; 21 | 22 | if ( kMatrixSerpentineLayout == false) { 23 | i = (y * kMatrixWidth) + x; 24 | } 25 | 26 | if ( kMatrixSerpentineLayout == true) { 27 | if ( y & 0x01) { 28 | // Odd rows run backwards 29 | uint8_t reverseX = (kMatrixWidth - 1) - x; 30 | i = (y * kMatrixWidth) + reverseX; 31 | } else { 32 | // Even rows run forwards 33 | i = (y * kMatrixWidth) + x; 34 | } 35 | } 36 | 37 | return i; 38 | } 39 | 40 | 41 | #define NUM_LEDS (kMatrixWidth * kMatrixHeight) 42 | CRGB leds_plus_safety_pixel[ NUM_LEDS + 1]; 43 | CRGB* const leds( leds_plus_safety_pixel + 1); 44 | 45 | 46 | void loop() 47 | { 48 | vortex(); 49 | } 50 | 51 | 52 | void ledtest() { 53 | int hue = 0; 54 | for (int y = 0; y < kMatrixHeight; y++) { 55 | for (int x = 0; x < kMatrixWidth; x++) { 56 | leds[ XY(x, y)] = CHSV( hue, 255, 255); 57 | FastLED.show(); 58 | delay(10); 59 | leds[ XY(x, y)] = CRGB::Black; 60 | hue += 5; 61 | if (hue > 255) hue = 0; 62 | } 63 | } 64 | 65 | } 66 | 67 | void setup() { 68 | // FastLED.addLeds(leds, NUM_LEDS).setCorrection(TypicalSMD5050); 69 | FastLED.addLeds(leds, NUM_LEDS).setCorrection(TypicalSMD5050); 70 | FastLED.setBrightness( BRIGHTNESS ); 71 | // ledtest(); 72 | } 73 | -------------------------------------------------------------------------------- /Vortex/p-vortex.ino: -------------------------------------------------------------------------------- 1 | class Vortex { 2 | int x = 0; 3 | int y = 0; 4 | int right = 1; 5 | int up = 0; 6 | int w = kMatrixWidth - 1; 7 | int h = kMatrixHeight - 1; 8 | int margin = 0; 9 | int hue; 10 | 11 | public: 12 | Vortex() { 13 | 14 | } 15 | 16 | void vortex() { 17 | leds[ XY(x, y)] = CHSV(hue, 255, 255); 18 | // End of right 19 | if ((x >= (w - margin)) && (up == 0)) { 20 | up = 1; 21 | right = 0; 22 | // vortexHue += 15; 23 | } 24 | // End of up 25 | else if ((y >= (h - margin)) && (up == 1)) { 26 | up = 0; 27 | right = -1; 28 | // vortexHue += 15; 29 | } 30 | // End of left 31 | else if ((x == (0 + margin)) && (up == 0 && right == -1)) { 32 | up = -1; 33 | right = 0; 34 | // vortexHue += 15; 35 | } 36 | // End of down 37 | else if ((x == (0 + margin) && y == (1 + margin)) && (up == -1 && right == 0)) { 38 | y += up; 39 | up = 0; 40 | right = 1; 41 | hue += 15; 42 | margin++; 43 | y++; 44 | } 45 | 46 | // Final LED 47 | if (right == 0 && up == -1 && margin == ( (kMatrixHeight / 2) - 1)) { // >= 48 | //delay(5000); 49 | hue = random(0, 255); 50 | margin = 0; 51 | x = -1; 52 | y = 0; 53 | right = 1; 54 | up = 0; 55 | } 56 | 57 | // Option toggle? 58 | // fadeLightBy(leds, (kMatrixWidth * kMatrixHeight), 20); 59 | x += right; 60 | y += up; 61 | } 62 | }; 63 | 64 | #define SNAKE_GAP 30 65 | #define NUM_SNAKES ((NUM_LEDS / SNAKE_GAP) / 2) 66 | Vortex vortexs[NUM_SNAKES]; 67 | 68 | int vortexsStarted = 1; 69 | //int const vortexDelay = ((kMatrixWidth * 2) + (kMatrixHeight * 2) - 1); 70 | int const vortexDelay = SNAKE_GAP * 2; 71 | int vortexGap = 0; 72 | 73 | void vortex() { 74 | 75 | if (vortexsStarted < NUM_SNAKES) { 76 | if (vortexGap == vortexDelay) { 77 | vortexsStarted++; 78 | vortexGap = 0; 79 | } 80 | else { 81 | vortexGap++; 82 | } 83 | } 84 | 85 | for (int i = 0; i < vortexsStarted; i++) { 86 | vortexs[i].vortex(); 87 | } 88 | fadeToBlackBy(leds, (kMatrixWidth * kMatrixHeight), 55); // TWEAK ME 89 | FastLED.delay(20); 90 | EVERY_N_SECONDS(10) { 91 | Serial.println(FastLED.getFPS()); 92 | } 93 | } 94 | 95 | 96 | -------------------------------------------------------------------------------- /VortexSmartMatrix/README.md: -------------------------------------------------------------------------------- 1 | Chasing trails, spiralling into centre 2 | 3 | https://photos.app.goo.gl/EvPeGW8sUEQ3hbbs6 4 | -------------------------------------------------------------------------------- /VortexSmartMatrix/VortexSmartMatrix.ino: -------------------------------------------------------------------------------- 1 | #include // comment out this line for if you're not using SmartLED Shield V4 hardware (this line needs to be before #include ) 2 | #include 3 | #include 4 | 5 | #define COLOR_DEPTH 24 // This sketch and FastLED uses type `rgb24` directly, COLOR_DEPTH must be 24 6 | const uint8_t kMatrixWidth = 64; // known working: 32, 64, 96, 128 7 | const uint8_t kMatrixHeight = 64; // known working: 16, 32, 48, 64 8 | const uint8_t kRefreshDepth = 36; // known working: 24, 36, 48 9 | const uint8_t kDmaBufferRows = 4; // known working: 2-4, use 2 to save memory, more to keep from dropping frames and automatically lowering refresh rate 10 | const uint8_t kPanelType = SMARTMATRIX_HUB75_64ROW_MOD32SCAN; // use SMARTMATRIX_HUB75_16ROW_MOD8SCAN for common 16x32 panels 11 | const uint8_t kMatrixOptions = (SMARTMATRIX_OPTIONS_NONE); // see http://docs.pixelmatix.com/SmartMatrix for options 12 | const uint8_t kBackgroundLayerOptions = (SM_BACKGROUND_OPTIONS_NONE); 13 | const uint8_t kScrollingLayerOptions = (SM_SCROLLING_OPTIONS_NONE); 14 | 15 | SMARTMATRIX_ALLOCATE_BUFFERS(matrix, kMatrixWidth, kMatrixHeight, kRefreshDepth, kDmaBufferRows, kPanelType, kMatrixOptions); 16 | SMARTMATRIX_ALLOCATE_BACKGROUND_LAYER(backgroundLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kBackgroundLayerOptions); 17 | SMARTMATRIX_ALLOCATE_SCROLLING_LAYER(scrollingLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kScrollingLayerOptions); 18 | 19 | #define BRIGHTNESS 55 20 | 21 | // Param for different pixel layouts 22 | const bool kMatrixSerpentineLayout = false; 23 | 24 | 25 | uint16_t XY( uint8_t x, uint8_t y) 26 | { 27 | uint16_t i; 28 | 29 | if ( kMatrixSerpentineLayout == false) { 30 | i = (y * kMatrixWidth) + x; 31 | } 32 | 33 | if ( kMatrixSerpentineLayout == true) { 34 | if ( y & 0x01) { 35 | // Odd rows run backwards 36 | uint8_t reverseX = (kMatrixWidth - 1) - x; 37 | i = (y * kMatrixWidth) + reverseX; 38 | } else { 39 | // Even rows run forwards 40 | i = (y * kMatrixWidth) + x; 41 | } 42 | } 43 | 44 | return i; 45 | } 46 | 47 | 48 | #define NUM_LEDS (kMatrixWidth * kMatrixHeight) 49 | 50 | void loop() 51 | { 52 | vortex(); 53 | } 54 | 55 | 56 | void ledtest() { 57 | int hue = 0; 58 | for (int y = 0; y < kMatrixHeight; y++) { 59 | for (int x = 0; x < kMatrixWidth; x++) { 60 | rgb24 *buffer = backgroundLayer.backBuffer(); 61 | buffer[ XY(x, y)] = CRGB(CHSV( hue, 255, 255)); 62 | backgroundLayer.swapBuffers(); 63 | delay(10); 64 | buffer = backgroundLayer.backBuffer(); 65 | buffer[ XY(x, y)] = CRGB(CRGB::Black); 66 | hue += 5; 67 | if (hue > 255) hue = 0; 68 | } 69 | } 70 | 71 | } 72 | 73 | void setup() { 74 | // FastLED.addLeds(leds, NUM_LEDS).setCorrection(TypicalSMD5050); 75 | // FastLED.addLeds(leds, NUM_LEDS).setCorrection(TypicalSMD5050); 76 | matrix.addLayer(&backgroundLayer); 77 | matrix.addLayer(&scrollingLayer); 78 | matrix.begin(); 79 | matrix.setBrightness( BRIGHTNESS ); 80 | // ledtest(); 81 | } 82 | -------------------------------------------------------------------------------- /VortexSmartMatrix/p-vortex.ino: -------------------------------------------------------------------------------- 1 | class Vortex { 2 | int x = 0; 3 | int y = 0; 4 | int right = 1; 5 | int up = 0; 6 | int w = kMatrixWidth - 1; 7 | int h = kMatrixHeight - 1; 8 | int margin = 0; 9 | int hue; 10 | 11 | public: 12 | Vortex() { 13 | 14 | } 15 | 16 | void vortex() { 17 | rgb24 *buffer = backgroundLayer.backBuffer(); 18 | buffer[ XY(x, y)] = CRGB(CHSV(hue, 255, 255)); 19 | // End of right 20 | if ((x >= (w - margin)) && (up == 0)) { 21 | up = 1; 22 | right = 0; 23 | // vortexHue += 15; 24 | } 25 | // End of up 26 | else if ((y >= (h - margin)) && (up == 1)) { 27 | up = 0; 28 | right = -1; 29 | // vortexHue += 15; 30 | } 31 | // End of left 32 | else if ((x == (0 + margin)) && (up == 0 && right == -1)) { 33 | up = -1; 34 | right = 0; 35 | // vortexHue += 15; 36 | } 37 | // End of down 38 | else if ((x == (0 + margin) && y == (1 + margin)) && (up == -1 && right == 0)) { 39 | y += up; 40 | up = 0; 41 | right = 1; 42 | hue += 15; 43 | margin++; 44 | y++; 45 | } 46 | 47 | // Final LED 48 | if (right == 0 && up == -1 && margin == ( (kMatrixHeight / 2) - 1)) { // >= 49 | //delay(5000); 50 | hue = random(0, 255); 51 | margin = 0; 52 | x = -1; 53 | y = 0; 54 | right = 1; 55 | up = 0; 56 | } 57 | 58 | // Option toggle? 59 | // fadeLightBy(leds, (kMatrixWidth * kMatrixHeight), 20); 60 | x += right; 61 | y += up; 62 | } 63 | }; 64 | 65 | #define SNAKE_GAP 30 66 | #define NUM_SNAKES ((NUM_LEDS / SNAKE_GAP) / 2) 67 | Vortex vortexs[NUM_SNAKES]; 68 | 69 | int vortexsStarted = 1; 70 | //int const vortexDelay = ((kMatrixWidth * 2) + (kMatrixHeight * 2) - 1); 71 | int const vortexDelay = SNAKE_GAP * 2; 72 | int vortexGap = 0; 73 | 74 | void vortex() { 75 | rgb24 *buffer = backgroundLayer.backBuffer(); 76 | if (vortexsStarted < NUM_SNAKES) { 77 | if (vortexGap == vortexDelay) { 78 | vortexsStarted++; 79 | vortexGap = 0; 80 | } 81 | else { 82 | vortexGap++; 83 | } 84 | } 85 | 86 | for (int i = 0; i < vortexsStarted; i++) { 87 | vortexs[i].vortex(); 88 | } 89 | fadeToBlackBy((CRGB*)buffer, (kMatrixWidth * kMatrixHeight), 10); // TWEAK ME 90 | backgroundLayer.swapBuffers(); 91 | delay(3); 92 | EVERY_N_SECONDS(10) { 93 | Serial.println(FastLED.getFPS()); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /hhukgrid/hhukgrid.ino: -------------------------------------------------------------------------------- 1 | // Adafruit_NeoMatrix example for single NeoPixel Shield. 2 | // Scrolls 'Howdy' across the matrix in a portrait (vertical) orientation. 3 | 4 | #include 5 | #include 6 | #include 7 | #ifndef PSTR 8 | #define PSTR // Make Arduino Due happy 9 | #endif 10 | 11 | #define PIN 6 12 | 13 | // MATRIX DECLARATION: 14 | // Parameter 1 = width of NeoPixel matrix 15 | // Parameter 2 = height of matrix 16 | // Parameter 3 = pin number (most are valid) 17 | // Parameter 4 = matrix layout flags, add together as needed: 18 | // NEO_MATRIX_TOP, NEO_MATRIX_BOTTOM, NEO_MATRIX_LEFT, NEO_MATRIX_RIGHT: 19 | // Position of the FIRST LED in the matrix; pick two, e.g. 20 | // NEO_MATRIX_TOP + NEO_MATRIX_LEFT for the top-left corner. 21 | // NEO_MATRIX_ROWS, NEO_MATRIX_COLUMNS: LEDs are arranged in horizontal 22 | // rows or in vertical columns, respectively; pick one or the other. 23 | // NEO_MATRIX_PROGRESSIVE, NEO_MATRIX_ZIGZAG: all rows/columns proceed 24 | // in the same order, or alternate lines reverse direction; pick one. 25 | // See example below for these values in action. 26 | // Parameter 5 = pixel type flags, add together as needed: 27 | // NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) 28 | // NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) 29 | // NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) 30 | // NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) 31 | 32 | 33 | // Example for NeoPixel Shield. In this application we'd like to use it 34 | // as a 5x8 tall matrix, with the USB port positioned at the top of the 35 | // Arduino. When held that way, the first pixel is at the top right, and 36 | // lines are arranged in columns, progressive order. The shield uses 37 | // 800 KHz (v2) pixels that expect GRB color data. 38 | Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(8, 8, PIN, 39 | NEO_MATRIX_TOP + NEO_MATRIX_RIGHT + 40 | NEO_MATRIX_COLUMNS + NEO_MATRIX_PROGRESSIVE, 41 | NEO_GRB + NEO_KHZ800); 42 | 43 | const uint16_t colors[] = { 44 | matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(0, 0, 255) }; 45 | 46 | void setup() { 47 | matrix.begin(); 48 | matrix.setTextWrap(false); 49 | matrix.setTextSize(1); 50 | matrix.setBrightness(30); 51 | matrix.setTextColor(colors[0]); 52 | } 53 | 54 | int pass = 0; 55 | String message = "HardHouseUK.net "; 56 | int x = 0; 57 | 58 | void loop() { 59 | 60 | matrix.fillScreen(0); 61 | matrix.setCursor(0, 0); 62 | matrix.setTextColor(colors[pass]); 63 | matrix.print(message.substring(x, (x+1))); 64 | x++; 65 | if(x > message.length() -1) { 66 | x = 0; 67 | pass++; 68 | if(pass > (sizeof(colors) - 1)) { 69 | pass = 0; 70 | } 71 | } 72 | matrix.show(); 73 | delay(387); 74 | } 75 | -------------------------------------------------------------------------------- /libraries/Adafruit_GFX_Library/Adafruit_GFX.h: -------------------------------------------------------------------------------- 1 | #ifndef _ADAFRUIT_GFX_H 2 | #define _ADAFRUIT_GFX_H 3 | 4 | #if ARDUINO >= 100 5 | #include "Arduino.h" 6 | #include "Print.h" 7 | #else 8 | #include "WProgram.h" 9 | #endif 10 | 11 | #define swap(a, b) { int16_t t = a; a = b; b = t; } 12 | 13 | class Adafruit_GFX : public Print { 14 | 15 | public: 16 | 17 | Adafruit_GFX(int16_t w, int16_t h); // Constructor 18 | 19 | // This MUST be defined by the subclass: 20 | virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0; 21 | 22 | // These MAY be overridden by the subclass to provide device-specific 23 | // optimized code. Otherwise 'generic' versions are used. 24 | virtual void 25 | drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color), 26 | drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color), 27 | drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color), 28 | drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color), 29 | fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color), 30 | fillScreen(uint16_t color), 31 | invertDisplay(boolean i); 32 | 33 | // These exist only with Adafruit_GFX (no subclass overrides) 34 | void 35 | drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color), 36 | drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, 37 | uint16_t color), 38 | fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color), 39 | fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, 40 | int16_t delta, uint16_t color), 41 | drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, 42 | int16_t x2, int16_t y2, uint16_t color), 43 | fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, 44 | int16_t x2, int16_t y2, uint16_t color), 45 | drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, 46 | int16_t radius, uint16_t color), 47 | fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, 48 | int16_t radius, uint16_t color), 49 | drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, 50 | int16_t w, int16_t h, uint16_t color), 51 | drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, 52 | uint16_t bg, uint8_t size), 53 | setCursor(int16_t x, int16_t y), 54 | setTextColor(uint16_t c), 55 | setTextColor(uint16_t c, uint16_t bg), 56 | setTextSize(uint8_t s), 57 | setTextWrap(boolean w), 58 | setRotation(uint8_t r); 59 | 60 | #if ARDUINO >= 100 61 | virtual size_t write(uint8_t); 62 | #else 63 | virtual void write(uint8_t); 64 | #endif 65 | 66 | int16_t 67 | height(void), 68 | width(void); 69 | 70 | uint8_t getRotation(void); 71 | 72 | protected: 73 | const int16_t 74 | WIDTH, HEIGHT; // This is the 'raw' display w/h - never changes 75 | int16_t 76 | _width, _height, // Display w/h as modified by current rotation 77 | cursor_x, cursor_y; 78 | uint16_t 79 | textcolor, textbgcolor; 80 | uint8_t 81 | textsize, 82 | rotation; 83 | boolean 84 | wrap; // If set, 'wrap' text at right edge of display 85 | }; 86 | 87 | #endif // _ADAFRUIT_GFX_H 88 | -------------------------------------------------------------------------------- /libraries/Adafruit_GFX_Library/README.txt: -------------------------------------------------------------------------------- 1 | This is the core graphics library for all our displays, providing a common set of graphics primitives (points, lines, circles, etc.). It needs to be paired with a hardware-specific library for each display device we carry (to handle the lower-level functions). 2 | 3 | Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit! 4 | 5 | Written by Limor Fried/Ladyada for Adafruit Industries. 6 | BSD license, check license.txt for more information. 7 | All text above must be included in any redistribution. 8 | 9 | To download, click the DOWNLOAD ZIP button, uncompress and rename the uncompressed folder Adafruit_GFX. Confirm that the Adafruit_GFX folder contains Adafruit_GFX.cpp and Adafruit_GFX.h 10 | 11 | Place the Adafruit_GFX library folder your /Libraries/ folder. You may need to create the Libraries subfolder if its your first library. Restart the IDE. 12 | -------------------------------------------------------------------------------- /libraries/Adafruit_GFX_Library/license.txt: -------------------------------------------------------------------------------- 1 | Software License Agreement (BSD License) 2 | 3 | Copyright (c) 2012 Adafruit Industries. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | - Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | - Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /libraries/Adafruit_NeoMatrix/README.md: -------------------------------------------------------------------------------- 1 | Adafruit_NeoMatrix. Whoa. 2 | ========================= 3 | 4 | Adafruit_GFX-compatible library for NeoPixel matrices and grids. Controls single and tiled NeoPixel displays such as the [Adafruit NeoPixel Shield][shield] or grids assembled from [Adafruit 60 LED/meter Digital LED strip][strip]. Requires Adafruit_NeoPixel and Adafruit_GFX libraries. 5 | 6 | After downloading, rename folder to 'Adafruit_NeoMatrix' and install in Arduino Libraries folder. Restart Arduino IDE, then open File->Sketchbook->Library->Adafruit_NeoMatrix->matrixtest sketch. 7 | 8 | [shield]: http://adafruit.com/products/1430 9 | [strip]: http://adafruit.com/products/1138 10 | -------------------------------------------------------------------------------- /libraries/Adafruit_NeoMatrix/examples/matrixtest/matrixtest.pde: -------------------------------------------------------------------------------- 1 | // Adafruit_NeoMatrix example for single NeoPixel Shield. 2 | // Scrolls 'Howdy' across the matrix in a portrait (vertical) orientation. 3 | 4 | #include 5 | #include 6 | #include 7 | #ifndef PSTR 8 | #define PSTR // Make Arduino Due happy 9 | #endif 10 | 11 | #define PIN 6 12 | 13 | // MATRIX DECLARATION: 14 | // Parameter 1 = width of NeoPixel matrix 15 | // Parameter 2 = height of matrix 16 | // Parameter 3 = pin number (most are valid) 17 | // Parameter 4 = matrix layout flags, add together as needed: 18 | // NEO_MATRIX_TOP, NEO_MATRIX_BOTTOM, NEO_MATRIX_LEFT, NEO_MATRIX_RIGHT: 19 | // Position of the FIRST LED in the matrix; pick two, e.g. 20 | // NEO_MATRIX_TOP + NEO_MATRIX_LEFT for the top-left corner. 21 | // NEO_MATRIX_ROWS, NEO_MATRIX_COLUMNS: LEDs are arranged in horizontal 22 | // rows or in vertical columns, respectively; pick one or the other. 23 | // NEO_MATRIX_PROGRESSIVE, NEO_MATRIX_ZIGZAG: all rows/columns proceed 24 | // in the same order, or alternate lines reverse direction; pick one. 25 | // See example below for these values in action. 26 | // Parameter 5 = pixel type flags, add together as needed: 27 | // NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) 28 | // NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) 29 | // NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) 30 | // NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) 31 | 32 | 33 | // Example for NeoPixel Shield. In this application we'd like to use it 34 | // as a 5x8 tall matrix, with the USB port positioned at the top of the 35 | // Arduino. When held that way, the first pixel is at the top right, and 36 | // lines are arranged in columns, progressive order. The shield uses 37 | // 800 KHz (v2) pixels that expect GRB color data. 38 | Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(5, 8, PIN, 39 | NEO_MATRIX_TOP + NEO_MATRIX_RIGHT + 40 | NEO_MATRIX_COLUMNS + NEO_MATRIX_PROGRESSIVE, 41 | NEO_GRB + NEO_KHZ800); 42 | 43 | const uint16_t colors[] = { 44 | matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(0, 0, 255) }; 45 | 46 | void setup() { 47 | matrix.begin(); 48 | matrix.setTextWrap(false); 49 | matrix.setBrightness(40); 50 | matrix.setTextColor(colors[0]); 51 | } 52 | 53 | int x = matrix.width(); 54 | int pass = 0; 55 | 56 | void loop() { 57 | matrix.fillScreen(0); 58 | matrix.setCursor(x, 0); 59 | matrix.print(F("Howdy")); 60 | if(--x < -36) { 61 | x = matrix.width(); 62 | if(++pass >= 3) pass = 0; 63 | matrix.setTextColor(colors[pass]); 64 | } 65 | matrix.show(); 66 | delay(100); 67 | } 68 | -------------------------------------------------------------------------------- /libraries/Adafruit_NeoMatrix/extras/gamma.c: -------------------------------------------------------------------------------- 1 | // THIS IS NOT ARDUINO CODE -- DON'T INCLUDE IN YOUR SKETCH. It's a 2 | // command-line tool that outputs a gamma correction table to stdout; 3 | // redirect or copy and paste the results into header file for the 4 | // NeoMatrix library code. 5 | // Optional 1 parameter: bit depth (default=5, for 32 output levels). 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #define GAMMA 2.6 12 | 13 | int planes = 5; 14 | 15 | int main(int argc, char *argv[]) 16 | { 17 | int i, maxval; 18 | 19 | if(argc > 1) planes = atoi(argv[1]); 20 | 21 | maxval = (1 << planes) - 1; 22 | 23 | (void)printf( 24 | "#ifndef _GAMMA_H_\n" 25 | "#define _GAMMA_H_\n" 26 | "\n" 27 | "#ifdef __AVR\n" 28 | " #include \n" 29 | "#else\n" 30 | " #ifndef PROGMEM\n" 31 | " #define PROGMEM\n" 32 | " #endif\n" 33 | "#endif\n" 34 | "\n" 35 | "static const uint8_t PROGMEM\n" 36 | " gamma%d[] = {\n" 37 | " ", planes); 38 | 39 | for(i=0; i<=maxval; i++) { 40 | (void)printf("%3d", 41 | (int)(pow((float)i / (float)maxval, GAMMA) * 42 | (float)255.0 + 0.5)); 43 | if(i < maxval) (void)printf(((i & 15) == 15) ? ",\n " : ","); 44 | } 45 | 46 | (void)puts( 47 | "\n};\n\n" 48 | "#endif // _GAMMA_H_"); 49 | 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /libraries/Adafruit_NeoMatrix/gamma.h: -------------------------------------------------------------------------------- 1 | #ifndef _GAMMA_H_ 2 | #define _GAMMA_H_ 3 | 4 | #ifdef __AVR 5 | #include 6 | #else 7 | #ifndef PROGMEM 8 | #define PROGMEM 9 | #endif 10 | #endif 11 | 12 | static const uint8_t PROGMEM 13 | gamma5[] = { 14 | 0x00,0x01,0x02,0x03,0x05,0x07,0x09,0x0b, 15 | 0x0e,0x11,0x14,0x18,0x1d,0x22,0x28,0x2e, 16 | 0x36,0x3d,0x46,0x4f,0x59,0x64,0x6f,0x7c, 17 | 0x89,0x97,0xa6,0xb6,0xc7,0xd9,0xeb,0xff }, 18 | gamma6[] = { 19 | 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x08, 20 | 0x09,0x0a,0x0b,0x0d,0x0e,0x10,0x12,0x13, 21 | 0x15,0x17,0x19,0x1b,0x1d,0x20,0x22,0x25, 22 | 0x27,0x2a,0x2d,0x30,0x33,0x37,0x3a,0x3e, 23 | 0x41,0x45,0x49,0x4d,0x52,0x56,0x5b,0x5f, 24 | 0x64,0x69,0x6e,0x74,0x79,0x7f,0x85,0x8b, 25 | 0x91,0x97,0x9d,0xa4,0xab,0xb2,0xb9,0xc0, 26 | 0xc7,0xcf,0xd6,0xde,0xe6,0xee,0xf7,0xff }; 27 | 28 | #endif // _GAMMA_H_ 29 | -------------------------------------------------------------------------------- /libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------- 2 | This file is part of the Adafruit NeoPixel library. 3 | 4 | NeoPixel is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as 6 | published by the Free Software Foundation, either version 3 of 7 | the License, or (at your option) any later version. 8 | 9 | NeoPixel is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with NeoPixel. If not, see 16 | . 17 | --------------------------------------------------------------------*/ 18 | 19 | #ifndef ADAFRUIT_NEOPIXEL_H 20 | #define ADAFRUIT_NEOPIXEL_H 21 | 22 | #if (ARDUINO >= 100) 23 | #include 24 | #else 25 | #include 26 | #include 27 | #endif 28 | 29 | // 'type' flags for LED pixels (third parameter to constructor): 30 | #define NEO_RGB 0x00 // Wired for RGB data order 31 | #define NEO_GRB 0x01 // Wired for GRB data order 32 | #define NEO_COLMASK 0x01 33 | #define NEO_KHZ800 0x02 // 800 KHz datastream 34 | #define NEO_SPDMASK 0x02 35 | // Trinket flash space is tight, v1 NeoPixels aren't handled by default. 36 | // Remove the ifndef/endif to add support -- but code will be bigger. 37 | // Conversely, can comment out the #defines to save space on other MCUs. 38 | #ifndef __AVR_ATtiny85__ 39 | #define NEO_KHZ400 0x00 // 400 KHz datastream 40 | #endif 41 | 42 | class Adafruit_NeoPixel { 43 | 44 | public: 45 | 46 | // Constructor: number of LEDs, pin number, LED type 47 | Adafruit_NeoPixel(uint16_t n, uint8_t p=6, uint8_t t=NEO_GRB + NEO_KHZ800); 48 | ~Adafruit_NeoPixel(); 49 | 50 | void 51 | begin(void), 52 | show(void), 53 | setPin(uint8_t p), 54 | setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b), 55 | setPixelColor(uint16_t n, uint32_t c), 56 | setBrightness(uint8_t); 57 | uint8_t 58 | *getPixels(void) const; 59 | uint16_t 60 | numPixels(void) const; 61 | static uint32_t 62 | Color(uint8_t r, uint8_t g, uint8_t b); 63 | uint32_t 64 | getPixelColor(uint16_t n) const; 65 | 66 | private: 67 | 68 | const uint16_t 69 | numLEDs, // Number of RGB LEDs in strip 70 | numBytes; // Size of 'pixels' buffer below 71 | uint8_t 72 | pin, // Output pin number 73 | brightness, 74 | *pixels, // Holds LED color values (3 bytes each) 75 | rOffset, // Index of red byte within each 3-byte pixel 76 | gOffset, // Index of green byte 77 | bOffset; // Index of blue byte 78 | const uint8_t 79 | type; // Pixel flags (400 vs 800 KHz, RGB vs GRB color) 80 | uint32_t 81 | endTime; // Latch timing reference 82 | #ifdef __AVR__ 83 | const volatile uint8_t 84 | *port; // Output PORT register 85 | uint8_t 86 | pinMask; // Output PORT bitmask 87 | #endif 88 | 89 | }; 90 | 91 | #endif // ADAFRUIT_NEOPIXEL_H 92 | -------------------------------------------------------------------------------- /libraries/Adafruit_NeoPixel/README.md: -------------------------------------------------------------------------------- 1 | Adafruit NeoPixel library 2 | ========================= 3 | 4 | Arduino library for controlling single-wire-based LED pixels and strip such as the [Adafruit 60 LED/meter Digital LED strip][strip], the [Adafruit FLORA RGB Smart Pixel][flora], the [Adafruit Breadboard-friendly RGB Smart Pixel][pixel], the [Adafruit NeoPixel Stick][stick], and the [Adafruit NeoPixel Shield][shield]. 5 | 6 | After downloading, rename folder to 'Adafruit_NeoPixel' and install in Arduino Libraries folder. Restart Arduino IDE, then open File->Sketchbook->Library->Adafruit_NeoPixel->strandtest sketch. 7 | 8 | [flora]: http://adafruit.com/products/1060 9 | [strip]: http://adafruit.com/products/1138 10 | [pixel]: http://adafruit.com/products/1312 11 | [stick]: http://adafruit.com/products/1426 12 | [shield]: http://adafruit.com/products/1430 13 | -------------------------------------------------------------------------------- /libraries/Adafruit_nRF8001/Adafruit_BLE_UART.h: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | This is a library for our nRF8001 Bluetooth Low Energy Breakout 3 | 4 | Pick one up today in the adafruit shop! 5 | ------> http://www.adafruit.com/products/1697 6 | 7 | These displays use SPI to communicate, 4 or 5 pins are required to 8 | interface 9 | 10 | Adafruit invests time and resources providing this open source code, 11 | please support Adafruit and open-source hardware by purchasing 12 | products from Adafruit! 13 | 14 | Written by Kevin Townsend/KTOWN for Adafruit Industries. 15 | MIT license, check LICENSE for more information 16 | All text above, and the splash screen below must be included in any redistribution 17 | *********************************************************************/ 18 | 19 | #if ARDUINO >= 100 20 | #include "Arduino.h" 21 | #else 22 | #include "WProgram.h" 23 | #endif 24 | 25 | #ifndef _ADAFRUIT_BLE_UART_H_ 26 | #define _ADAFRUIT_BLE_UART_H_ 27 | 28 | #include "utility/aci_evts.h" 29 | 30 | #define BLE_RW_DEBUG 31 | 32 | extern "C" 33 | { 34 | /* Callback prototypes */ 35 | typedef void (*aci_callback)(aci_evt_opcode_t event); 36 | typedef void (*rx_callback) (uint8_t *buffer, uint8_t len); 37 | } 38 | 39 | class Adafruit_BLE_UART : public Stream 40 | { 41 | public: 42 | Adafruit_BLE_UART (int8_t req, int8_t rdy, int8_t rst); 43 | 44 | bool begin ( uint16_t advTimeout = 0, uint16_t advInterval = 80 ); 45 | void pollACI ( void ); 46 | size_t write ( uint8_t * buffer, uint8_t len ); 47 | size_t write ( uint8_t buffer); 48 | 49 | size_t println(const char * thestr); 50 | size_t print(const char * thestr); 51 | size_t print(String thestr); 52 | size_t print(int theint); 53 | size_t print(const __FlashStringHelper *ifsh); 54 | 55 | void setACIcallback(aci_callback aciEvent = NULL); 56 | void setRXcallback(rx_callback rxEvent = NULL); 57 | void setDeviceName(const char * deviceName); 58 | 59 | // Stream compatibility 60 | int available(void); 61 | int read(void); 62 | int peek(void); 63 | void flush(void); 64 | 65 | aci_evt_opcode_t getState(void); 66 | 67 | private: 68 | void defaultACICallback(aci_evt_opcode_t event); 69 | void defaultRX(uint8_t *buffer, uint8_t len); 70 | 71 | // callbacks you can set with setCallback function for user extension 72 | aci_callback aci_event; 73 | rx_callback rx_event; 74 | 75 | bool debugMode; 76 | uint16_t adv_timeout; 77 | uint16_t adv_interval; 78 | char device_name[8]; 79 | 80 | aci_evt_opcode_t currentStatus; 81 | 82 | // pins usd 83 | int8_t _REQ, _RDY, _RST; 84 | }; 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /libraries/Adafruit_nRF8001/README.md: -------------------------------------------------------------------------------- 1 | # Adafruit_nRF8001 # 2 | 3 | Driver and example code for Adafruit's nRF8001 Bluetooth Low Energy Breakout. 4 | 5 | ## PINOUT ## 6 | 7 | The pin locations are defined in **ble_system.h**, the supported systems are defined in **hal_aci_tl.cpp**. The following pinout is used by default for the Arduino Uno: 8 | 9 | * SCK -> Pin 13 10 | * MISO -> Pin 12 11 | * MOSI -> Pin 11 12 | * REQ -> Pin 10 13 | * RDY -> Pin 2 (HW interrupt) 14 | * ACT -> Not connected 15 | * RST -> Pin 9 16 | * 3V0 - > Not connected 17 | * GND -> GND 18 | * VIN -> 5V 19 | 20 | RDY must be on pin 2 since this pin requires a HW interrupt. 21 | 22 | 3V0 is an optional pin that exposes the output of the on-board 3.3V regulator. You can use this to supply 3.3V to other peripherals, but normally it will be left unconnected. 23 | 24 | ACT is not currently used in any of the existing examples, and can be left unconnected if necessary. 25 | 26 | # Examples # 27 | 28 | The following examples are included for the Adafruit nRF8001 Breakout 29 | 30 | ## UART ## 31 | 32 | This example creates a UART-style bridge between the Arduino and any BLE capable device. 33 | 34 | You can send and receive up to 20 bytes at a time between your BLE-enabled phone or tablet and the Arduino. 35 | 36 | Any data sent to the Arduino will be displayed in the Serial Monitor output, and echo'ed back to the phone or tablet on the mobile device's RX channel. 37 | 38 | This demo creates a custom UART service, with one characteristic for TX and one for RX using the following UUIDs: 39 | 40 | * 6E400001-B5A3-F393-E0A9-E50E24DCCA9E for the Service 41 | * 6E400002-B5A3-F393-E0A9-E50E24DCCA9E for the TX Characteristic (Property = Notify) 42 | * 6E400003-B5A3-F393-E0A9-E50E24DCCA9E for the RX Characteristic (Property = Write without response) 43 | 44 | You can test the UART service with the free nRF UART apps from Nordic Semiconductors, available for both iOS and Android: 45 | 46 | * Compatible iOS devices: https://itunes.apple.com/us/app/nrf-uart/id614594903?mt=8 47 | * Compatible Android 4.3 and higher devices: https://play.google.com/store/apps/details?id=com.nordicsemi.nrfUARTv2 48 | * Compatible pre Android 4.3 Samsung devices (uses a proprietary Samsung BLE stack): https://play.google.com/store/apps/details?id=com.nordicsemi.nrfUART 49 | -------------------------------------------------------------------------------- /libraries/Adafruit_nRF8001/examples/callbackEcho/callbackEcho.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | This is an example for our nRF8001 Bluetooth Low Energy Breakout 3 | 4 | Pick one up today in the adafruit shop! 5 | ------> http://www.adafruit.com/products/1697 6 | 7 | Adafruit invests time and resources providing this open source code, 8 | please support Adafruit and open-source hardware by purchasing 9 | products from Adafruit! 10 | 11 | Written by Kevin Townsend/KTOWN for Adafruit Industries. 12 | MIT license, check LICENSE for more information 13 | All text above, and the splash screen below must be included in any redistribution 14 | *********************************************************************/ 15 | 16 | // This version uses call-backs on the event and RX so there's no data handling in the main loop! 17 | 18 | #include 19 | #include "Adafruit_BLE_UART.h" 20 | 21 | #define ADAFRUITBLE_REQ 10 22 | #define ADAFRUITBLE_RDY 2 23 | #define ADAFRUITBLE_RST 9 24 | 25 | Adafruit_BLE_UART uart = Adafruit_BLE_UART(ADAFRUITBLE_REQ, ADAFRUITBLE_RDY, ADAFRUITBLE_RST); 26 | 27 | /**************************************************************************/ 28 | /*! 29 | This function is called whenever select ACI events happen 30 | */ 31 | /**************************************************************************/ 32 | void aciCallback(aci_evt_opcode_t event) 33 | { 34 | switch(event) 35 | { 36 | case ACI_EVT_DEVICE_STARTED: 37 | Serial.println(F("Advertising started")); 38 | break; 39 | case ACI_EVT_CONNECTED: 40 | Serial.println(F("Connected!")); 41 | break; 42 | case ACI_EVT_DISCONNECTED: 43 | Serial.println(F("Disconnected or advertising timed out")); 44 | break; 45 | default: 46 | break; 47 | } 48 | } 49 | 50 | /**************************************************************************/ 51 | /*! 52 | This function is called whenever data arrives on the RX channel 53 | */ 54 | /**************************************************************************/ 55 | void rxCallback(uint8_t *buffer, uint8_t len) 56 | { 57 | Serial.print(F("Received ")); 58 | Serial.print(len); 59 | Serial.print(F(" bytes: ")); 60 | for(int i=0; i high, 0 -> low). 55 | * @param io_name Output to change. 56 | * @param io_state Level to set. 57 | */ 58 | #define HAL_IO_SET_STATE(io_name, io_state) digitalWrite(io_name, io_state) 59 | 60 | /**@brief Macro that reads the current state of an input. 61 | * @details 62 | * This macro reads the current state of a logical input. 63 | * @param io_name Input to read. 64 | * @return Input state level (1 if high, 0 if low). 65 | */ 66 | #define HAL_IO_READ(io_name) digitalRead(io_name) 67 | 68 | 69 | #endif //HAL_IO_H__ 70 | 71 | /** @} */ 72 | -------------------------------------------------------------------------------- /libraries/Adafruit_nRF8001/utility/hal_platform.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRENTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | * $LastChangedRevision$ 12 | */ 13 | 14 | #ifndef PLATFORM_H__ 15 | #define PLATFORM_H__ 16 | 17 | /** @file 18 | * @brief 19 | */ 20 | #include "Arduino.h" 21 | 22 | 23 | #define hal_pltf_clear_spi_master_config() do { SPCR = 0; } while(0) 24 | 25 | //SPI2X=1 SPS0=1 SPR0=1 -> 250KHz 26 | //DORD=1 LSBit first 27 | //SPE=1 Enable the SPI 28 | //MSTR=1 Enable master mode 29 | //CPOL=0 See Section 7 in the nRF8001 PS (Clock Polarity) 30 | //CPHA=0 See Section 7 in the nRF8001 PS (Clock Phase) 31 | /* 32 | Atmega328 33 | Table 18-5. Relationship Between SCK and the Oscillator Frequency 34 | SPI2X SPR1 SPR0 SCK Frequency 35 | 0 0 0 fosc/4 36 | 0 0 1 fosc/16 37 | 0 1 0 fosc/64 38 | 0 1 1 fosc/128 39 | 1 0 0 fosc/2 40 | 1 0 1 fosc/8 41 | 1 1 0 fosc/32 42 | 1 1 1 fosc/64 43 | */ 44 | /* 45 | #define hal_pltf_spi_master_config() do { \ 46 | pinMode(SCK, OUTPUT);\ 47 | pinMode(MOSI, OUTPUT);\ 48 | pinMode(SS, OUTPUT);\ 49 | pinMode(MISO, INPUT);\ 50 | digitalWrite(SCK, LOW);\ 51 | digitalWrite(MOSI, LOW);\ 52 | digitalWrite(SS, HIGH);\ 53 | SPCR = 0; \ 54 | SPSR = 0; \ 55 | SPSR = (1<"); 8 | Serial.println(" Gobo"); 9 | for(int p = 0; p < pcount; p++) { 10 | Serial.printf(" %s\n", addrMin, (addrMin + width), gPatterns[p].name.c_str()); 11 | addrMin += width + 1; 12 | } 13 | Serial.println(" "); 14 | 15 | Serial.println(" "); 16 | Serial.println(" Colour"); 17 | for(int p = 0; p < ARRAY_SIZE(palettes); p++) { 18 | CRGB color = ColorFromPalette(palettes[p].palette, 125); 19 | char hexout[8]; 20 | sprintf(hexout,"#%02x%02x%02x",color.r, color.g, color.b); 21 | Serial.printf(" %s\n", p, p, hexout, palettes[p].name.c_str()); 22 | } 23 | Serial.println(" "); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /libraries/readme.txt: -------------------------------------------------------------------------------- 1 | For information on installing libraries, see: http://arduino.cc/en/Guide/Libraries 2 | -------------------------------------------------------------------------------- /libraries/update-all-libraries.sh: -------------------------------------------------------------------------------- 1 | dirs=`find -maxdepth 1 -type d` 2 | for dir in $dirs; do 3 | pushd $dir > /dev/null 4 | if [ ! -d .git ]; then 5 | echo -n "$dir " 6 | git pull 7 | else 8 | echo "WARNING $dir is not a git-module" 9 | fi 10 | popd > /dev/null 11 | done 12 | -------------------------------------------------------------------------------- /patterns/p-EQ.ino: -------------------------------------------------------------------------------- 1 | // EQ vars 2 | 3 | int eq_hue = 0; 4 | int eq_hue_wait = 10; 5 | 6 | void EQ() { 7 | 8 | int xpos; 9 | // analyze without delay 10 | bool newReading = MSGEQ7.read(MSGEQ7_INTERVAL); 11 | 12 | // Led strip output 13 | if (newReading) { 14 | eq_hue_wait++; 15 | if(eq_hue_wait > 1) { 16 | eq_hue += 10; 17 | if(eq_hue > 255) eq_hue = 0; 18 | eq_hue_wait = 0; 19 | } 20 | // display values of left channel on DMD 21 | for ( band = 0; band < 7; band++ ) 22 | { 23 | xpos = map((band + 1), 1, 7, 7, 1); 24 | int count = map(MSGEQ7.get(band), 0, 255, 0, kMatrixHeight); 25 | for (int i = 1; i <= kMatrixWidth; i++) { 26 | if (i <= count) { 27 | // unsigned int g = map(band, 0, 6, 254, 0); 28 | // CRGB color = CRGB(map(i , 1, WIDTH, 254, 0), g, 0); 29 | CRGB color = CHSV(eq_hue + (band * 20), 255,255); 30 | safeSetPixel(XY(xpos, i), color); 31 | } 32 | else { 33 | safeSetPixel(XY(xpos, i) ,CRGB::Black); 34 | } 35 | } 36 | } 37 | 38 | // display values of left channel on DMD 39 | for ( band = 0; band < 7; band++ ) 40 | { 41 | xpos = 8 + band + 1; 42 | int count = map(MSGEQ7.get(band), 0, 255, 0, kMatrixHeight); 43 | for (int i = 1; i <= kMatrixWidth; i++) { 44 | if (i <= count) { 45 | // unsigned int g = map(band, 0, 6, 254, 0); 46 | // CRGB color = CRGB(map(i , 1, WIDTH, 254, 0), g, 0); 47 | CRGB color = CHSV(eq_hue + (band * 20), 255,255); 48 | safeSetPixel(XY(xpos, i), color); 49 | } 50 | else { 51 | safeSetPixel(XY(xpos, i), CRGB::Black); 52 | } 53 | } 54 | } 55 | 56 | FastLED.show(); 57 | } 58 | } 59 | 60 | void safeSetPixel(int pos, CRGB value) { 61 | if(pos > (NUM_LEDS -1)) { 62 | Serial.print("IXP "); 63 | Serial.println(pos); 64 | } 65 | else { 66 | leds[pos] = value; 67 | } 68 | } 69 | 70 | 71 | -------------------------------------------------------------------------------- /patterns/p-VU.ino: -------------------------------------------------------------------------------- 1 | int HEIGHTP = kMatrixWidth; 2 | int WIDTHP = kMatrixHeight; 3 | 4 | void VU() { 5 | CRGB color; 6 | 7 | const boolean gay = false; 8 | 9 | bool newReading = MSGEQ7.read(ReadsPerSecond(20)); 10 | 11 | // Led strip output 12 | if (newReading) { 13 | 14 | int displayPeakL = map(MSGEQ7.get(MSGEQ7_LOW, 0), 0, 255, 0, round(HEIGHTP / 2)); 15 | int displayPeakR = map(MSGEQ7.get(MSGEQ7_LOW, 1), 0, 255, 0, round(HEIGHTP / 2)); 16 | Serial.print("Display peak: "); 17 | Serial.println(displayPeakL); 18 | 19 | moveRight(); 20 | int offset = round(HEIGHTP / 2); 21 | 22 | for (int i = 1; i <= HEIGHTP; i++){ 23 | drawPixelP(1, i, CRGB::Black); 24 | } 25 | 26 | for (int i = 1; i <= HEIGHTP; i++){ 27 | drawPixelP(1, offset, CRGB::Blue); 28 | } 29 | 30 | for(int i=1; i <= displayPeakL; i++) { 31 | if(gay) { 32 | color = CHSV(map(i, 1, (HEIGHTP/2), 0, 230), 255, 255); 33 | } 34 | else { 35 | unsigned int g = map(i, 1, HEIGHTP, 254, 0); 36 | color = CRGB(map(i , 1, HEIGHTP, 0, 254), g, 0); 37 | } 38 | drawPixelP(1, (offset - i), color); 39 | } 40 | for(int i=1; i <= displayPeakR; i++) { 41 | if(gay) { 42 | color = CHSV(map(i, 1, (HEIGHTP/2), 230, 0), 255, 255); 43 | } 44 | else { 45 | unsigned int g = map(i, 1, (HEIGHTP/2), 254, 0); 46 | color = CRGB(map(i , 1, (HEIGHTP/2), 0, 254), g, 0); 47 | } 48 | drawPixelP(1, (offset + i), color); 49 | } 50 | 51 | FastLED.show(); 52 | } 53 | } 54 | 55 | void drawPixelP(int x, int y, CRGB color) { 56 | leds[xytopixelP(x, y)] = color; 57 | } 58 | 59 | int xytopixelP(int x, int y) { 60 | int p = ((x - 1) * HEIGHTP) + (y - 1); 61 | return p; 62 | } 63 | 64 | 65 | void moveRight() { 66 | // Update the display: 67 | for (int i = HEIGHTP; i >= 1; i--) { 68 | for (int j = WIDTHP; j >= 1; j--) { 69 | int src = xytopixelP((j - 1), i); 70 | int dst = xytopixelP(j, i); 71 | leds[dst] = leds[src]; 72 | } 73 | } 74 | } 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /patterns/p-ledTest.ino: -------------------------------------------------------------------------------- 1 | void ledtest() { 2 | int hue = 0; 3 | for (int y = 0; y < kMatrixHeight; y++) { 4 | for (int x = 0; x < kMatrixWidth; x++) { 5 | leds[ XY(x, y)] = CHSV( hue, 255, 255); 6 | FastLED.delay(100); 7 | leds[ XY(x, y)] = CRGB::Black; 8 | hue += 5; 9 | if (hue > 255) hue = 0; 10 | } 11 | } 12 | } 13 | 14 | 15 | -------------------------------------------------------------------------------- /patterns/p-rainbow.ino: -------------------------------------------------------------------------------- 1 | // int STEPS = 4; //Wider or narrower bands of color 2 | // int SPEEDO = 10; //The speed of the animation 3 | 4 | CRGBPalette16 currentPalette; 5 | TBlendType currentBlending; 6 | 7 | // RAINBOW -------------------------------------------------- 8 | void FillLEDsFromPaletteColors( uint8_t colorIndex) 9 | { 10 | 11 | for( int i = 0; i < NUM_LEDS; i++) { 12 | leds[i] = ColorFromPalette( currentPalette, colorIndex, BRIGHTNESS, currentBlending); 13 | colorIndex += STEPS; 14 | } 15 | } 16 | 17 | void Rainbow() 18 | { 19 | currentPalette = RainbowColors_p; 20 | 21 | static uint8_t startIndex = 0; 22 | startIndex = startIndex + 1; 23 | 24 | FillLEDsFromPaletteColors( startIndex); 25 | 26 | FastLED.delay(10); 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /patterns/p-rainbowSweep.ino: -------------------------------------------------------------------------------- 1 | int hue = 0; 2 | void rainbowSweep() { 3 | int jump = random(0, 25); 4 | int hue = random(0, 255); 5 | for (int x = 0; x < kMatrixWidth; x++) { 6 | for (int y = 0; y < kMatrixHeight; y++) { 7 | leds[ XY(x, y)] = CHSV( hue, 255, 255); 8 | } 9 | FastLED.delay(70); 10 | hue += jump; 11 | if (hue > 255) hue = 0; 12 | fadeToBlackBy(leds, (kMatrixWidth * kMatrixHeight), 90); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /patterns/p-rainbowWash.ino: -------------------------------------------------------------------------------- 1 | void DrawOneFrame( byte startHue8, int8_t yHueDelta8, int8_t xHueDelta8) 2 | { 3 | byte lineStartHue = startHue8; 4 | for ( byte y = 0; y < kMatrixHeight; y++) { 5 | lineStartHue += yHueDelta8; 6 | byte pixelHue = lineStartHue; 7 | for ( byte x = 0; x < kMatrixWidth; x++) { 8 | pixelHue += xHueDelta8; 9 | leds[ XY(x, y)] = CHSV( pixelHue, 255, 255); 10 | } 11 | } 12 | } 13 | 14 | 15 | // Demo that USES "XY" follows code below 16 | 17 | void RainbowWash() 18 | { 19 | uint32_t ms = millis(); 20 | int32_t yHueDelta32 = ((int32_t)cos16( ms * (27 / 1) ) * (350 / kMatrixWidth)); 21 | int32_t xHueDelta32 = ((int32_t)cos16( ms * (39 / 1) ) * (310 / kMatrixHeight)); 22 | DrawOneFrame( ms / 65536, yHueDelta32 / 32768, xHueDelta32 / 32768); 23 | /* if ( ms < 5000 ) { 24 | FastLED.setBrightness( scale8( BRIGHTNESS, (ms * 256) / 5000)); 25 | } else { 26 | FastLED.setBrightness(BRIGHTNESS); 27 | }*/ 28 | FastLED.delay(20); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /patterns/p-ripple.ino: -------------------------------------------------------------------------------- 1 | int HUE = 0; //0-255, around the color wheel 2 | // int STEPS = 4; //Wider or narrower bands of color 3 | // int SPEEDO = 10; //The speed of the animation 4 | 5 | //RIPPLE VARIABLES 6 | uint8_t colour; // Ripple colour is randomized. 7 | int center = 0; // Center of the current ripple. 8 | int step = -1; // -1 is the initializing step. 9 | uint8_t myfade = 255; // Starting brightness. 10 | #define maxsteps 16 // Case statement wouldn't allow a variable. 11 | 12 | //RIPPLE -------------------------------------------------------------------------------- 13 | int wrap(int step) { 14 | if (step < 0) return NUM_LEDS + step; 15 | if (step > NUM_LEDS - 1) return step - NUM_LEDS; 16 | return step; 17 | } 18 | 19 | void Ripple() { 20 | HUE = 140; HUE++; 21 | if (HUE > 220) { 22 | HUE = 140; // constrain BG hue to blues and purples 23 | } 24 | for (int i = 0; i < NUM_LEDS; i++) leds[i] = CHSV(HUE++, 255, 50); // Rotate background colour. 25 | 26 | switch (step) { 27 | 28 | case -1: // Initialize ripple variables. 29 | center = random(NUM_LEDS); 30 | colour = random16(0, 256); 31 | step = 0; 32 | break; 33 | 34 | case 0: 35 | leds[center] = CHSV(colour, 255, 255); // Display the first pixel of the ripple. 36 | step ++; 37 | break; 38 | 39 | case maxsteps: // At the end of the ripples. 40 | step = -1; 41 | break; 42 | 43 | default: // Middle of the ripples. 44 | leds[wrap(center + step)] += CHSV(colour, 255, myfade / step * 2); // Display the next pixels in the range for one side. 45 | leds[wrap(center - step)] += CHSV(colour, 255, myfade / step * 2); // Display the next pixels in the range for the other side. 46 | step ++; // Next step. 47 | break; 48 | } // switch step 49 | 50 | FastLED.delay(SPEEDO * 2.5); 51 | } 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /patterns/p-shimmer.ino: -------------------------------------------------------------------------------- 1 | boolean xrand = false; 2 | boolean irand = true; 3 | 4 | unsigned int l = 0; 5 | int i = 1; 6 | int x = 1; 7 | 8 | void shimmer() { 9 | for (int dot = -1; dot < NUM_LEDS; dot += i) { 10 | leds[dot].setHue(x); 11 | // leds[dot] = CRGB::Blue; 12 | FastLED.delay(10); 13 | // clear this led for the next time around the loop 14 | //leds[dot] = CRGB::Black; 15 | } 16 | 17 | if (irand) { 18 | i = random(2, 40); 19 | } 20 | else { 21 | if (i < 40) { 22 | i++; 23 | } else { 24 | i = 1; 25 | } 26 | } 27 | 28 | if (xrand) { 29 | x = random(1, 255); 30 | } 31 | else { 32 | if (x < 255) { 33 | x++; 34 | } else { 35 | x = 1; 36 | } 37 | 38 | } 39 | } 40 | 41 | 42 | -------------------------------------------------------------------------------- /patterns/p-sinwave_1.ino: -------------------------------------------------------------------------------- 1 | // SIN WAVE SETUP 2 | 3 | #define qsubd(x, b) ((x>b)?wavebright:0) // Digital unsigned subtraction macro. if result <0, then => 0. Otherwise, take on fixed value. 4 | #define qsuba(x, b) ((x>b)?x-b:0) // Analog Unsigned subtraction macro. if result <0, then => 0 5 | 6 | // SINWAVE VARIABLES -- change these numbers to modify Sinwave mode 7 | uint8_t wavebright = 255; // You can change the brightness of the waves/bars rolling across the screen. 8 | uint8_t thishue = 30; // You can change the starting hue value for the first wave. 9 | uint8_t thisrot = 1; // You can change how quickly the hue rotates for this wave. 0= color stays the same 10 | uint8_t allsat = 255; // I like 'em fully saturated with colour. 11 | bool thisdir = 0; // You can change direction. 12 | int8_t thisspeed = 4; // You can change the speed, and use negative values. 13 | uint8_t allfreq = 25; // You can change the frequency, thus overall width of bars. 14 | int thisphase = 0; // Phase change value gets calculated. 15 | uint8_t thiscutoff = 192; // You can change the cutoff value to display this wave. Lower value = longer wave. 16 | int loopdelay = 4; // You can change the delay. Also you can change the allspeed variable above. 17 | uint8_t bgclr = 0; // A rotating background colour. 18 | uint8_t bgbright = 55; // Background color brightness 19 | 20 | 21 | void one_sin() { // This is the heart of this program. Sure is short. 22 | if (thisdir == 0) thisphase += thisspeed; else thisphase -= thisspeed; // You can change direction and speed individually. 23 | thishue = thishue + thisrot; // Hue rotation is fun for thiswave. 24 | for (int k = 0; k < NUM_LEDS; k++) { 25 | int thisbright = qsubd(cubicwave8((k * allfreq) + thisphase), thiscutoff); // qsub sets a minimum value called thiscutoff. If < thiscutoff, then bright = 0. Otherwise, bright = 128 (as defined in qsub).. 26 | leds[k] = CHSV(bgclr, 255, bgbright); 27 | leds[k] += CHSV(thishue, allsat, thisbright); // Assigning hues and brightness to the led array. 28 | } 29 | bgclr++; 30 | } 31 | 32 | void sinwave_1() { 33 | one_sin(); 34 | FastLED.delay(loopdelay * 2.5); 35 | Serial.println(LEDS.getFPS()); 36 | } 37 | 38 | -------------------------------------------------------------------------------- /patterns/p-snake.ino: -------------------------------------------------------------------------------- 1 | class Snake { 2 | int x = 0; 3 | int y = 0; 4 | int right = 1; 5 | int up = 0; 6 | int w = kMatrixWidth - 1; 7 | int h = kMatrixHeight - 1; 8 | int margin = 0; 9 | int hue; 10 | 11 | public: 12 | Snake() { 13 | 14 | } 15 | 16 | void snake() { 17 | leds[ XY(x, y)] = CHSV(hue, 255, 255); 18 | // End of right 19 | if ((x >= (w - margin)) && (up == 0)) { 20 | up = 1; 21 | right = 0; 22 | // snakeHue += 15; 23 | } 24 | // End of up 25 | else if ((y >= (h - margin)) && (up == 1)) { 26 | up = 0; 27 | right = -1; 28 | // snakeHue += 15; 29 | } 30 | // End of left 31 | else if ((x == (0 + margin)) && (up == 0 && right == -1)) { 32 | up = -1; 33 | right = 0; 34 | // snakeHue += 15; 35 | } 36 | // End of down 37 | else if ((x == (0 + margin) && y == (1 + margin)) && (up == -1 && right == 0)) { 38 | y += up; 39 | up = 0; 40 | right = 1; 41 | hue += 15; 42 | margin++; 43 | y++; 44 | } 45 | 46 | // Final LED 47 | if (right == 0 && up == -1 && margin == 3) { 48 | //delay(1500); 49 | hue = random(0, 255); 50 | margin = 0; 51 | x = -1; 52 | y = 0; 53 | right = 1; 54 | up = 0; 55 | } 56 | 57 | fadeToBlackBy(leds, (kMatrixWidth * kMatrixHeight), 10); 58 | // fadeLightBy(leds, (kMatrixWidth * kMatrixHeight), 20); 59 | x += right; 60 | y += up; 61 | } 62 | }; 63 | 64 | #define NUM_SNAKES 3 65 | Snake snakes[NUM_SNAKES]; 66 | 67 | int snakesStarted = 1; 68 | // int const snakeDelay = ((kMatrixWidth * 2) + (kMatrixHeight * 2) - 1); 69 | int const snakeDelay = 10; 70 | int snakeGap = 0; 71 | 72 | void snake() { 73 | 74 | if (snakesStarted < NUM_SNAKES) { 75 | if (snakeGap == snakeDelay) { 76 | snakesStarted++; 77 | snakeGap = 0; 78 | } 79 | else { 80 | snakeGap++; 81 | } 82 | } 83 | 84 | for (i = 0; i < snakesStarted; i++) { 85 | snakes[i].snake(); 86 | } 87 | FastLED.delay(155); 88 | } 89 | 90 | 91 | -------------------------------------------------------------------------------- /pulse/pulse.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #define LED_PIN 15 3 | #define NUM_LEDS 32 4 | #define BRIGHTNESS 10 5 | #define LED_TYPE NEOPIXEL 6 | CRGB leds[NUM_LEDS]; 7 | class Pixel { 8 | int p = 0; 9 | int v = 0; 10 | int h = 0; 11 | bool locked = false; 12 | 13 | public: 14 | void set(int i) { 15 | p = i; 16 | } 17 | 18 | boolean isLocked() { 19 | return locked; 20 | } 21 | 22 | void hue(int hue) { 23 | if (locked) return; 24 | h = hue; 25 | } 26 | 27 | void fade(int value) { 28 | if (locked) return; 29 | v = v + value; 30 | } 31 | 32 | void setV(int value) { 33 | if (locked) return; 34 | v = value; 35 | } 36 | 37 | void render() { 38 | leds[p] = CHSV(h, 255, v); 39 | } 40 | 41 | void lock() { 42 | hue(random(0, 255)); 43 | locked = true; 44 | } 45 | 46 | void rst() { 47 | v = 0; 48 | locked = false; 49 | h = 0; 50 | } 51 | }; 52 | Pixel pixels[NUM_LEDS]; 53 | 54 | void setup() { 55 | FastLED.setBrightness( 55 ); 56 | FastLED.addLeds(leds, NUM_LEDS); 57 | for (int i = 0; i < NUM_LEDS; i++) { 58 | pixels[i].set(i); 59 | } 60 | Serial.begin(115200); 61 | } 62 | 63 | void loop() { 64 | pulse(); 65 | } 66 | 67 | int frame = 0; 68 | int v = 0; 69 | void pulse() { 70 | frame++; 71 | if (frame < 50) { 72 | // fadeup 73 | fade(1); 74 | } 75 | else if (frame < 100) { 76 | // fadedown 77 | fade(-1); 78 | } 79 | else if (frame < 150) { 80 | // fadeup 81 | fade(1); 82 | } 83 | else { 84 | 85 | frame = 0; 86 | 87 | int sanity = 0; 88 | while (sanity < 10000) { 89 | sanity++; 90 | int p = random(0, NUM_LEDS); 91 | if (pixels[p].isLocked()) { 92 | continue; 93 | } 94 | else { 95 | pixels[p].lock(); 96 | break; 97 | } 98 | } 99 | 100 | // Are we all locked 101 | boolean allLocked = true; 102 | for (int i = 0; i < NUM_LEDS; i++) { 103 | if (!pixels[i].isLocked()) { 104 | allLocked = false; 105 | break; 106 | } 107 | } 108 | Serial.println("End of loop"); 109 | if (allLocked) { 110 | Serial.println("Reset"); 111 | for (int i = 0; i < NUM_LEDS; i++) { 112 | pixels[i].rst(); 113 | } 114 | } 115 | for (int i = 0; i < NUM_LEDS; i++) { 116 | pixels[i].setV(0); 117 | pixels[i].hue(random(0, 255)); 118 | } 119 | 120 | } 121 | 122 | for (int i = 0; i < NUM_LEDS; i++) { 123 | pixels[i].render(); 124 | } 125 | 126 | FastLED.delay(10); 127 | } 128 | 129 | void fade(int v) { 130 | for (int i = 0; i < NUM_LEDS; i++) { 131 | pixels[i].fade(v); 132 | } 133 | } 134 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /table/table-900/p-snake.ino: -------------------------------------------------------------------------------- 1 | class Snake { 2 | int x = 0; 3 | int y = 0; 4 | int right = 1; 5 | int up = 0; 6 | int w = kMatrixWidth - 1; 7 | int h = kMatrixHeight - 1; 8 | int margin = 0; 9 | int hue; 10 | 11 | public: 12 | Snake() { 13 | 14 | } 15 | 16 | void snake() { 17 | leds[ XY(x, y)] = CHSV(hue, 255, 255); 18 | // End of right 19 | if ((x >= (w - margin)) && (up == 0)) { 20 | up = 1; 21 | right = 0; 22 | // snakeHue += 15; 23 | } 24 | // End of up 25 | else if ((y >= (h - margin)) && (up == 1)) { 26 | up = 0; 27 | right = -1; 28 | // snakeHue += 15; 29 | } 30 | // End of left 31 | else if ((x == (0 + margin)) && (up == 0 && right == -1)) { 32 | up = -1; 33 | right = 0; 34 | // snakeHue += 15; 35 | } 36 | // End of down 37 | else if ((x == (0 + margin) && y == (1 + margin)) && (up == -1 && right == 0)) { 38 | y += up; 39 | up = 0; 40 | right = 1; 41 | hue += 15; 42 | margin++; 43 | y++; 44 | } 45 | 46 | // Final LED 47 | if (right == 0 && up == -1 && margin == ((kMatrixWidth/2)-1)) { 48 | //delay(1500); 49 | hue = random(0, 255); 50 | margin = 0; 51 | x = -1; 52 | y = 0; 53 | right = 1; 54 | up = 0; 55 | } 56 | 57 | fadeToBlackBy(leds, (kMatrixWidth * kMatrixHeight), 5); 58 | // fadeLightBy(leds, (kMatrixWidth * kMatrixHeight), 20); 59 | x += right; 60 | y += up; 61 | } 62 | }; 63 | 64 | #define NUM_SNAKES 15 65 | Snake snakes[NUM_SNAKES]; 66 | 67 | int snakesStarted = 1; 68 | int const snakeDelay = ((kMatrixWidth * 2) + (kMatrixHeight * 2) - 1); 69 | //int const snakeDelay = 10; 70 | int snakeGap = 0; 71 | 72 | void snake() { 73 | 74 | if (snakesStarted < NUM_SNAKES) { 75 | if (snakeGap == snakeDelay) { 76 | snakesStarted++; 77 | snakeGap = 0; 78 | } 79 | else { 80 | snakeGap++; 81 | } 82 | } 83 | 84 | for (int i = 0; i < snakesStarted; i++) { 85 | snakes[i].snake(); 86 | } 87 | FastLED.delay(25); 88 | } 89 | 90 | 91 | -------------------------------------------------------------------------------- /tests/SPH0645/SPH0645.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define SAMPLE_RATE 32000 4 | #define BLOCK_SIZE 512 5 | 6 | const i2s_port_t I2S_PORT = I2S_NUM_0; 7 | 8 | #define I2S_WS 15 // LRCL 9 | #define I2S_SD 32 // DOUT 10 | #define I2S_SCK 14 // BCLK 11 | 12 | void setup() { 13 | // put your setup code here, to run once: 14 | Serial.begin(115200); 15 | esp_err_t err; 16 | 17 | const i2s_config_t i2s_config = { 18 | .mode = i2s_mode_t(I2S_MODE_MASTER | I2S_MODE_RX), 19 | .sample_rate = SAMPLE_RATE, 20 | .bits_per_sample = I2S_BITS_PER_SAMPLE_32BIT, 21 | .channel_format = I2S_CHANNEL_FMT_ONLY_LEFT, 22 | // .channel_format = I2S_CHANNEL_FMT_ONLY_RIGHT, 23 | .communication_format = i2s_comm_format_t(I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB), 24 | .intr_alloc_flags = ESP_INTR_FLAG_LEVEL1, 25 | .dma_buf_count = 8, 26 | .dma_buf_len = BLOCK_SIZE, 27 | .use_apll = true, 28 | }; 29 | const i2s_pin_config_t pin_config = { 30 | .bck_io_num = I2S_SCK, 31 | .ws_io_num = I2S_WS, 32 | .data_out_num = -1, 33 | .data_in_num = I2S_SD 34 | }; 35 | 36 | err = i2s_driver_install(I2S_PORT, &i2s_config, 0, nullptr); 37 | if (err != ESP_OK) { 38 | Serial.printf("Failed installing driver: %d\n", err); 39 | } 40 | 41 | err = i2s_set_pin(I2S_PORT, &pin_config); 42 | if (err != ESP_OK) { 43 | Serial.printf("Failed setting pins: %d\n", err); 44 | } 45 | 46 | 47 | // REG_SET_BIT(I2S_TIMING_REG(I2S_PORT), BIT(9)); 48 | // REG_SET_BIT(I2S_CONF_REG(I2S_PORT), I2S_RX_MSB_SHIFT); 49 | 50 | i2s_set_sample_rates(I2S_PORT, SAMPLE_RATE); //set sample rates 51 | } 52 | 53 | 54 | void loop() { 55 | 56 | size_t bytes_read; 57 | int32_t samples[BLOCK_SIZE]; 58 | int32_t read_samples = 0; 59 | // unsigned long before = micros(); 60 | // unsigned long after = 0; 61 | unsigned long before = micros(); 62 | while (read_samples < BLOCK_SIZE) { 63 | esp_err_t err = i2s_read(I2S_PORT, (void *)samples, BLOCK_SIZE * 4, &bytes_read, portMAX_DELAY); 64 | if (err != ESP_OK) { 65 | Serial.printf("Error reading bytes: %d\n", err); 66 | } 67 | if (bytes_read <= 0 || bytes_read % 4 != 0) { 68 | Serial.printf("Invalid amount of bytes read: %d\n", bytes_read); 69 | } 70 | else 71 | { 72 | for (int i = 0; i < bytes_read / 4; i++) { 73 | if (read_samples == BLOCK_SIZE) 74 | break; 75 | // vReal[read_samples] = (double)(abs(samples[i] >> 14)); 76 | // vReal[read_samples] 77 | double value = (double)(samples[i] >> 14); 78 | Serial.print("0 "); 79 | Serial.println(value); 80 | // Serial.printf( "%.2f ",(double)(samples[i] >> 14)); 81 | // vImag[read_samples] = 0; 82 | // x1[read_samples] = abs(samples[i] >> 14); 83 | // x2[read_samples] = 0.0f; 84 | read_samples++; 85 | } 86 | // Serial.printf("\n"); 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /tests/beattest2/beattest2.ino: -------------------------------------------------------------------------------- 1 | // Arduino Beat Detector By Damian Peckett 2015 2 | // http://damian.pecke.tt/beat-detection-on-the-arduino 3 | // License: Public Domain. 4 | 5 | // Our Global Sample Rate, 5000hz 6 | #define SAMPLEPERIODUS 200 7 | 8 | #define LED 13 9 | 10 | // defines for setting and clearing register bits 11 | #ifndef cbi 12 | #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) 13 | #endif 14 | #ifndef sbi 15 | #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) 16 | #endif 17 | 18 | void setup() { 19 | Serial.begin(9600); 20 | //The pin with the LED 21 | pinMode(LED, OUTPUT); 22 | } 23 | 24 | // 20 - 200hz Single Pole Bandpass IIR Filter 25 | float bassFilter(float sample) { 26 | static float xv[3] = {0, 0, 0}, yv[3] = {0, 0, 0}; 27 | xv[0] = xv[1]; xv[1] = xv[2]; 28 | xv[2] = sample / 9.1f; 29 | yv[0] = yv[1]; yv[1] = yv[2]; 30 | yv[2] = (xv[2] - xv[0]) 31 | + (-0.7960060012f * yv[0]) + (1.7903124146f * yv[1]); 32 | return yv[2]; 33 | } 34 | 35 | // 10hz Single Pole Lowpass IIR Filter 36 | float envelopeFilter(float sample) { //10hz low pass 37 | static float xv[2] = {0, 0}, yv[2] = {0, 0}; 38 | xv[0] = xv[1]; 39 | xv[1] = sample / 160.f; 40 | yv[0] = yv[1]; 41 | yv[1] = (xv[0] + xv[1]) + (0.9875119299f * yv[0]); 42 | return yv[1]; 43 | } 44 | 45 | // 1.7 - 3.0hz Single Pole Bandpass IIR Filter 46 | float beatFilter(float sample) { 47 | static float xv[3] = {0, 0, 0}, yv[3] = {0, 0, 0}; 48 | xv[0] = xv[1]; xv[1] = xv[2]; 49 | xv[2] = sample / 7.015f; 50 | yv[0] = yv[1]; yv[1] = yv[2]; 51 | yv[2] = (xv[2] - xv[0]) 52 | + (-0.7169861741f * yv[0]) + (1.4453653501f * yv[1]); 53 | return yv[2]; 54 | } 55 | 56 | void loop() { 57 | unsigned long time = micros(); // Used to track rate 58 | float sample, value, envelope, beat, thresh; 59 | unsigned char i; 60 | 61 | for (i = 0;; ++i) { 62 | // Read ADC and center so +-512 63 | sample = (float)analogRead(0) - 503.f; 64 | // Serial.print("sample = "); 65 | // Serial.println(sample); 66 | // Filter only bass component 67 | value = bassFilter(sample); 68 | 69 | // Take signal amplitude and filter 70 | if (value < 0)value = -value; 71 | envelope = envelopeFilter(value); 72 | 73 | // Every 200 samples (25hz) filter the envelope 74 | if (i == 200) { 75 | // Filter out repeating bass sounds 100 - 180bpm 76 | beat = beatFilter(envelope); 77 | 78 | // Threshold it based on potentiometer on A0 79 | thresh = 0.02f * (float)analogRead(A0); 80 | 81 | // If we are above threshold, light up LED 82 | if (beat > thresh) { 83 | Serial.println("beat"); 84 | digitalWrite(LED, HIGH); 85 | } 86 | else { 87 | digitalWrite(LED, LOW); 88 | } 89 | 90 | //Reset sample counter 91 | i = 0; 92 | } 93 | 94 | // Consume excess clock cycles, to keep at 5000 hz 95 | for (unsigned long up = time + SAMPLEPERIODUS; time > 20 && time < up; time = micros()); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /tests/neomatrixTest/EQ.ino: -------------------------------------------------------------------------------- 1 | // EQ vars 2 | 3 | int eq_hue = 0; 4 | int eq_hue_wait = 10; 5 | void EQ() { 6 | 7 | int xpos; 8 | // analyze without delay 9 | bool newReading = MSGEQ7.read(MSGEQ7_INTERVAL); 10 | 11 | // Led strip output 12 | if (newReading) { 13 | eq_hue_wait++; 14 | if(eq_hue_wait > 1) { 15 | eq_hue += 10; 16 | if(eq_hue > 255) eq_hue = 0; 17 | eq_hue_wait = 0; 18 | } 19 | // display values of left channel on DMD 20 | for ( band = 0; band < 7; band++ ) 21 | { 22 | xpos = map((band + 1), 1, 7, 7, 1); 23 | int count = map(MSGEQ7.get(band), 0, 255, 0, kMatrixHeight); 24 | for (int i = 1; i <= kMatrixWidth; i++) { 25 | if (i <= count) { 26 | // unsigned int g = map(band, 0, 6, 254, 0); 27 | // CRGB color = CRGB(map(i , 1, WIDTH, 254, 0), g, 0); 28 | CRGB color = CHSV(eq_hue + (band * 20), 255,255); 29 | safeSetPixel(XY(xpos, i), color); 30 | } 31 | else { 32 | safeSetPixel(XY(xpos, i) ,CRGB::Black); 33 | } 34 | } 35 | } 36 | 37 | // display values of left channel on DMD 38 | for ( band = 0; band < 7; band++ ) 39 | { 40 | xpos = 8 + band + 1; 41 | int count = map(MSGEQ7.get(band), 0, 255, 0, kMatrixHeight); 42 | for (int i = 1; i <= kMatrixWidth; i++) { 43 | if (i <= count) { 44 | // unsigned int g = map(band, 0, 6, 254, 0); 45 | // CRGB color = CRGB(map(i , 1, WIDTH, 254, 0), g, 0); 46 | CRGB color = CHSV(eq_hue + (band * 20), 255,255); 47 | safeSetPixel(XY(xpos, i), color); 48 | } 49 | else { 50 | safeSetPixel(XY(xpos, i), CRGB::Black); 51 | } 52 | } 53 | } 54 | 55 | FastLED.show(); 56 | } 57 | } 58 | 59 | void safeSetPixel(int pos, CRGB value) { 60 | if(pos > (NUM_LEDS -1)) { 61 | Serial.print("IXP "); 62 | Serial.println(pos); 63 | } 64 | else { 65 | leds[pos] = value; 66 | } 67 | } 68 | 69 | 70 | -------------------------------------------------------------------------------- /tests/neomatrixTest/VU.ino: -------------------------------------------------------------------------------- 1 | int HEIGHTP = kMatrixWidth; 2 | int WIDTHP = kMatrixHeight; 3 | 4 | void VU() { 5 | CRGB color; 6 | 7 | const boolean gay = false; 8 | 9 | bool newReading = MSGEQ7.read(ReadsPerSecond(20)); 10 | 11 | // Led strip output 12 | if (newReading) { 13 | 14 | int displayPeakL = map(MSGEQ7.get(MSGEQ7_LOW, 0), 0, 255, 0, round(HEIGHTP / 2)); 15 | int displayPeakR = map(MSGEQ7.get(MSGEQ7_LOW, 1), 0, 255, 0, round(HEIGHTP / 2)); 16 | Serial.print("Display peak: "); 17 | Serial.println(displayPeakL); 18 | 19 | moveRight(); 20 | int offset = round(HEIGHTP / 2); 21 | 22 | for (int i = 1; i <= HEIGHTP; i++){ 23 | drawPixelP(1, i, CRGB::Black); 24 | } 25 | 26 | for (int i = 1; i <= HEIGHTP; i++){ 27 | drawPixelP(1, offset, CRGB::Blue); 28 | } 29 | 30 | for(int i=1; i <= displayPeakL; i++) { 31 | if(gay) { 32 | color = CHSV(map(i, 1, (HEIGHTP/2), 0, 230), 255, 255); 33 | } 34 | else { 35 | unsigned int g = map(i, 1, HEIGHTP, 254, 0); 36 | color = CRGB(map(i , 1, HEIGHTP, 0, 254), g, 0); 37 | } 38 | drawPixelP(1, (offset - i), color); 39 | } 40 | for(int i=1; i <= displayPeakR; i++) { 41 | if(gay) { 42 | color = CHSV(map(i, 1, (HEIGHTP/2), 230, 0), 255, 255); 43 | } 44 | else { 45 | unsigned int g = map(i, 1, (HEIGHTP/2), 254, 0); 46 | color = CRGB(map(i , 1, (HEIGHTP/2), 0, 254), g, 0); 47 | } 48 | drawPixelP(1, (offset + i), color); 49 | } 50 | 51 | FastLED.show(); 52 | } 53 | } 54 | 55 | void drawPixelP(int x, int y, CRGB color) { 56 | leds[xytopixelP(x, y)] = color; 57 | } 58 | 59 | int xytopixelP(int x, int y) { 60 | int p = ((x - 1) * HEIGHTP) + (y - 1); 61 | return p; 62 | } 63 | 64 | 65 | void moveRight() { 66 | // Update the display: 67 | for (int i = HEIGHTP; i >= 1; i--) { 68 | for (int j = WIDTHP; j >= 1; j--) { 69 | int src = xytopixelP((j - 1), i); 70 | int dst = xytopixelP(j, i); 71 | leds[dst] = leds[src]; 72 | } 73 | } 74 | } 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /tests/neomatrixTest/ledTest.ino: -------------------------------------------------------------------------------- 1 | void ledtest() { 2 | int hue = 0; 3 | for (int y = 0; y < kMatrixHeight; y++) { 4 | for (int x = 0; x < kMatrixWidth; x++) { 5 | leds[ XY(x, y)] = CHSV( hue, 255, 255); 6 | FastLED.show(); 7 | delay(100); 8 | leds[ XY(x, y)] = CRGB::Black; 9 | hue += 5; 10 | if (hue > 255) hue = 0; 11 | } 12 | } 13 | } 14 | 15 | 16 | -------------------------------------------------------------------------------- /tests/neomatrixTest/ripple.ino: -------------------------------------------------------------------------------- 1 | int HUE = 0; //0-255, around the color wheel 2 | int STEPS = 4; //Wider or narrower bands of color 3 | int SPEEDO = 10; //The speed of the animation 4 | 5 | //RIPPLE VARIABLES 6 | uint8_t colour; // Ripple colour is randomized. 7 | int center = 0; // Center of the current ripple. 8 | int step = -1; // -1 is the initializing step. 9 | uint8_t myfade = 255; // Starting brightness. 10 | #define maxsteps 16 // Case statement wouldn't allow a variable. 11 | 12 | //RIPPLE -------------------------------------------------------------------------------- 13 | void ripple() { 14 | HUE = 140;HUE++; 15 | if (HUE > 220) {HUE = 140;} // constrain BG hue to blues and purples 16 | for (int i = 0; i < NUM_LEDS; i++) leds[i] = CHSV(HUE++, 255, 50); // Rotate background colour. 17 | 18 | switch (step) { 19 | 20 | case -1: // Initialize ripple variables. 21 | center = random(NUM_LEDS); 22 | colour = random16(0,256); 23 | step = 0; 24 | break; 25 | 26 | case 0: 27 | leds[center] = CHSV(colour, 255, 255); // Display the first pixel of the ripple. 28 | step ++; 29 | break; 30 | 31 | case maxsteps: // At the end of the ripples. 32 | step = -1; 33 | break; 34 | 35 | default: // Middle of the ripples. 36 | leds[wrap(center + step)] += CHSV(colour, 255, myfade/step*2); // Display the next pixels in the range for one side. 37 | leds[wrap(center - step)] += CHSV(colour, 255, myfade/step*2); // Display the next pixels in the range for the other side. 38 | step ++; // Next step. 39 | break; 40 | } // switch step 41 | 42 | show_at_max_brightness_for_power(); 43 | delay_at_max_brightness_for_power(SPEEDO*2.5); 44 | } // ripple() 45 | 46 | 47 | 48 | int wrap(int step) { 49 | if(step < 0) return NUM_LEDS + step; 50 | if(step > NUM_LEDS - 1) return step - NUM_LEDS; 51 | return step; 52 | } // wrap() 53 | 54 | 55 | -------------------------------------------------------------------------------- /tests/neomatrixTest/snake.ino: -------------------------------------------------------------------------------- 1 | int snakeX = 0; 2 | int snakeY = 0; 3 | int snakeRight = 1; 4 | int snakeUp = 0; 5 | int snakeW = kMatrixWidth - 1; 6 | int snakeH = kMatrixHeight - 1; 7 | int snakeMargin = 0; 8 | int hue; 9 | 10 | void snake() { 11 | leds[ XY(snakeX, snakeY)] = CHSV( hue, 255, 255); 12 | FastLED.show(); 13 | // End of right 14 | if ((snakeX >= (snakeW - snakeMargin)) && (snakeUp == 0)) { 15 | snakeUp = 1; 16 | snakeRight = 0; 17 | // hue += 15; 18 | } 19 | // End of up 20 | else if ((snakeY >= (snakeH - snakeMargin)) && (snakeUp == 1)) { 21 | snakeUp = 0; 22 | snakeRight = -1; 23 | // hue += 15; 24 | } 25 | // End of left 26 | else if ((snakeX == (0 + snakeMargin)) && (snakeUp == 0 && snakeRight == -1)) { 27 | snakeUp = -1; 28 | snakeRight = 0; 29 | // hue += 15; 30 | } 31 | // End of down 32 | else if ((snakeX == (0 + snakeMargin) && snakeY == (1 + snakeMargin)) && (snakeUp == -1 && snakeRight == 0)) { 33 | snakeY += snakeUp; 34 | snakeUp = 0; 35 | snakeRight = 1; 36 | hue += 15; 37 | snakeMargin++; 38 | snakeY++; 39 | } 40 | 41 | // Final LED 42 | if (snakeRight == 0 && snakeUp == -1 && snakeMargin == 3) { 43 | //delay(1500); 44 | hue = random(0, 255); 45 | snakeMargin = 0; 46 | snakeX = -1; 47 | snakeY = 0; 48 | snakeRight = 1; 49 | snakeUp = 0; 50 | } 51 | 52 | delay(15); 53 | fadeToBlackBy(leds, (kMatrixWidth * kMatrixHeight), 10); 54 | // fadeLightBy(leds, (kMatrixWidth * kMatrixHeight), 20); 55 | snakeX += snakeRight; 56 | snakeY += snakeUp; 57 | } 58 | 59 | -------------------------------------------------------------------------------- /tests/rings/rings.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // Basic test of Rings 4 | 5 | #define LED_PIN D4 6 | 7 | #define COLOR_ORDER GBR 8 | #define CHIPSET WS2811 9 | 10 | #define RINGS 9 11 | 12 | #define JUMP 20 13 | #define SPEED 80 14 | 15 | #define NUM_LEDS 241 16 | 17 | CRGB leds[NUM_LEDS]; //naming our LED array 18 | int hue[RINGS]; 19 | 20 | void setup() { 21 | FastLED.addLeds(leds, NUM_LEDS).setCorrection(TypicalSMD5050); 22 | FastLED.setBrightness( 15 ); 23 | int h = 0; 24 | for(int r=0; r < RINGS; r++) { 25 | hue[r] = h; 26 | h += JUMP; 27 | } 28 | } 29 | 30 | void loop() { 31 | rings(); 32 | } 33 | 34 | void rings() { 35 | for(int r=1; r<= RINGS; r++) { 36 | setRing(r, CHSV(hue[(r - 1)], 255,255)); 37 | } 38 | FastLED.delay(SPEED); 39 | if(false) { 40 | for(int r=2; r < RINGS; r++) { 41 | hue[(r - 1)] = hue[r]; 42 | } 43 | hue[(RINGS - 1)] += JUMP; 44 | } 45 | else { 46 | for(int r=(RINGS - 1); r > 1; r--) { 47 | hue[r] = hue[(r - 1)]; 48 | } 49 | // if(random(0,10) > 2) { 50 | hue[1] += JUMP; 51 | // } 52 | // else { 53 | // hue[1] += random(0,255); 54 | // } 55 | } 56 | } 57 | 58 | void setRing(int ring, CRGB colour) { 59 | int offset = 0; 60 | int count = 0; 61 | switch (ring) { 62 | case 1: 63 | count = 1; 64 | break; 65 | case 2: 66 | offset = 1; 67 | count = 8; 68 | break; 69 | case 3: 70 | offset = 9; 71 | count = 12; 72 | break; 73 | case 4: 74 | offset = 21; 75 | count = 16; 76 | break; 77 | case 5: 78 | offset = 37; 79 | count = 24; 80 | break; 81 | case 6: 82 | offset = 61; 83 | count = 32; 84 | break; 85 | case 7: 86 | offset = 93; 87 | count = 40; 88 | break; 89 | case 8: 90 | offset =133; 91 | count = 48; 92 | break; 93 | case 9: 94 | offset = 181; 95 | count = 60; 96 | break; 97 | } 98 | for (int i = 0; i < count; i++) { 99 | leds[(offset + i)] = colour; 100 | } 101 | } 102 | 103 | -------------------------------------------------------------------------------- /vu_matrix/vu_matrix.ino: -------------------------------------------------------------------------------- 1 | /**************************************** 2 | * Scrolling Sound Meter Sketch for the 3 | * Adafruit Microphone Amplifier 4 | ****************************************/ 5 | 6 | #include 7 | #include 8 | 9 | #define WIDTH 8 10 | #define HEIGHT 8 11 | #define DATA_PIN 6 12 | 13 | CRGB leds[(WIDTH * HEIGHT)]; 14 | 15 | CRGB color; 16 | 17 | const int sampleWindow = 50; // Sample window width in mS (50 mS = 20Hz) 18 | unsigned int sample; 19 | unsigned int maxPeak = 0; 20 | const boolean gay = true; 21 | 22 | void setup() { 23 | Serial.begin(9600); 24 | FastLED.setBrightness(100); 25 | FastLED.addLeds(leds, (WIDTH * HEIGHT)); 26 | } 27 | 28 | 29 | void loop() { 30 | unsigned long startMillis= millis(); // Start of sample window 31 | unsigned int peakToPeak = 0; // peak-to-peak level 32 | 33 | unsigned int signalMax = 0; 34 | unsigned int signalMin = 1024; 35 | 36 | while (millis() - startMillis < sampleWindow) { 37 | sample = analogRead(0); 38 | if (sample < 1024) // toss out spurious readings 39 | { 40 | if (sample > signalMax) 41 | { 42 | signalMax = sample; // save just the max levels 43 | } 44 | else if (sample < signalMin) 45 | { 46 | signalMin = sample; // save just the min levels 47 | } 48 | } 49 | } 50 | Serial.print("peakToPeak="); 51 | Serial.println(peakToPeak); 52 | peakToPeak = signalMax - signalMin; 53 | 54 | if(peakToPeak > maxPeak) { 55 | maxPeak = peakToPeak; 56 | } 57 | 58 | // map 1v p-p level to the max scale of the display 59 | int displayPeak = map(peakToPeak, 0, maxPeak, 0, HEIGHT); 60 | Serial.print("Display peak: "); 61 | Serial.println(displayPeak); 62 | 63 | moveLeft(); 64 | 65 | // draw the new sample 66 | for (int i = 1; i <= HEIGHT; i++) 67 | { 68 | if (i > displayPeak) // blank these pixels 69 | { 70 | drawPixel(i, 1, CRGB::Black); 71 | } 72 | else 73 | { 74 | 75 | if(gay) { 76 | unsigned int v = map(displayPeak, 1, HEIGHT, 50, 254); 77 | color = CHSV(map(i, 1, HEIGHT, 230, 0), 255, v); 78 | } 79 | else { 80 | unsigned int g = map(i, 1, HEIGHT, 254, 0); 81 | color = CRGB(map(i ,1, HEIGHT, 0, 254), g, 0); 82 | } 83 | 84 | drawPixel(i, 1, color); 85 | } 86 | } 87 | FastLED.show(); 88 | } 89 | 90 | 91 | int xytopixel(int x, int y) { 92 | int p = ((y -1) * WIDTH) + (x -1); 93 | return p; 94 | } 95 | 96 | void drawPixel(int x, int y, CRGB color) { 97 | leds[xytopixel(x, y)] = color; 98 | } 99 | 100 | void moveLeft() { 101 | // Update the display: 102 | for(int i=HEIGHT; i > 1; i--) { 103 | for(int j=WIDTH; j >= 1; j--) { 104 | int src = xytopixel(j,(i -1)); 105 | int dst = xytopixel(j,i); 106 | leds[dst] = leds[src]; 107 | } 108 | } 109 | } 110 | 111 | 112 | --------------------------------------------------------------------------------