├── LICENSE ├── README.md ├── assets ├── LED_pick.png ├── LED_pick2.png ├── LEDselector1.png ├── arduino1.png ├── fade.png ├── interval.png ├── led_16.png ├── led_60.png ├── paste1.png ├── paste2.png ├── pin0.png ├── pin6.png ├── playhead.png ├── sequencer_screen1.png ├── speedSlider.png ├── timeline1.png ├── timeline2.png └── timeline3.png ├── neo_pixel_player └── neo_pixel_player.ino └── neo_pixel_sequencer ├── ColorMatrix.pde ├── LED.pde ├── colorPicker.pde └── neo_pixel_sequencer.pde /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Christopher Coleman 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | neoPixel_Sequencer 2 | ================== 3 | 4 | A digital music style sequencer built in Processing for designing patterns for neoPixel rings (WS2812 LEDs) and then Arduino code for playing them back in a loop. 5 | Getting Started 6 | ------------------------ 7 | Please note, this is a sequencer for designing patterns that you load onto an arduino compatible device, not for direct real-time serial control of the LEDs. The Processing sketch creates a .txt file already formatted for using in the accompanying arduino file. The instructions assume you have the [Processing](http://processing.org) and [Arduino](http://arduino.cc) IDEs already installed and [Arduino is set for your particular board](http://arduino.cc/en/Guide/MacOSX#toc7). 8 | Setup Processing 9 | -------------------------- 10 | - [Download the project files](https://github.com/digitalcoleman/neoPixel_Sequencer/archive/master.zip) and move the neo_pixel_sequencer folder to your Processing sketches folder (Usually called Processing and in your Documents folder) 11 | - Open Processing 12 | - In the Processing select Menu Sketch -> Import Library -> Add Library 13 | - Search for and install the "ControlP5" library 14 | - Open the neo_pixel_sequencer.pde file and hit Play 15 | 16 | ![Screenshot>Sequencer1](assets/sequencer_screen1.png) 17 | 18 | Using the Sequencer 19 | --------------------------------- 20 | - First set the number of pixels in your ring using the slider just below the color picker 21 | 22 | ![Screenshot>LED#](assets/LEDselector1.png) 23 | - The interface is divided into the top and bottom half. The top is for adding colors and the bottom is for controlling time and playback. 24 | - To begin, first click on an LED that you would like to set the color for. it will then be highlighted and filled with the current color in the color picker. 25 | 26 | ![Screenshot>LEDselect](assets/LED_pick.png) 27 | 28 | - If you want to set other LEDs to the same color, select them one by one. 29 | - Each time you change the color in the color picker, it will also change the LED that is currently selected. 30 | 31 | ![Screenshot>LEDselect2](assets/LED_pick2.png) 32 | 33 | - You will notice the colors of the LEDs are also represented in the timeline in the bottom half of the program as the first column in the sequence. 34 | 35 | ![Screenshot>LEDtimeline](assets/timeline1.png) 36 | 37 | - Select the next slice of time by moving the playhead one column to the right. The playhead is a small blue triangle. 38 | 39 | ![Screenshot>playhead](assets/playhead.png) 40 | 41 | - Now select LEDs and set their colors for the new time slice. As a default the sequencer uses 16 slices (4/4 with 4 measures) but if you look at the code you will easily see how to change that number. 42 | - Note that another method is to choose a color you would like to use thoughout the timeline and set each LED with the color in every time slice. For example here we have set a blue color which will move around the ring: 43 | 44 | ![Screenshot>LEDtimeline2](assets/timeline2.png) 45 | 46 | - We can then move back and forth in time, adding colors as needed. 47 | 48 | ![Screenshot>LEDtimeline3](assets/timeline3.png) 49 | 50 | - When you are ready to see your LEDs in action, you can press the Play_Pause toggle button. The playhead will then move and loop through the sequence. You can adjust the speed using the Speed slider in realtime. It adjusts the number of milliseconds between each time slice, ranging from 75 to 625 milliseconds. 51 | 52 | ![Screenshot>speed](assets/speedSlider.png) 53 | 54 | - Once you are satisfied with the sequence, hit the "Save Sequence" button and it will export a text file with your sequence called "ledSequence.txt" Please note that every time you hit this button it will write over your previous version so re-name the file if you want to keep it. To quickly find the file go back to the Processing IDE and click Sketch -> Show Sketch Folder 55 | 56 | Setup Arduino 57 | --------------------------------- 58 | - First move the neo_pixel_player folder to your Arduino sketches folder (Usually called Arduino and in your Documents folder) 59 | - Download the driver and follow the instructions on this page to install the driver and then wire your neopixels to your Arduino board. [Adafruit Neo-Pixel Library](https://learn.adafruit.com/adafruit-neopixel-uberguide/arduino-library) 60 | - Open the Arduino IDE 61 | - In the Arduino IDE select File->Open and select "neo_pixel_player.ino" 62 | 63 | ![Screenshot>arduino1](assets/arduino1.png) 64 | 65 | - The first change you will need to make is for the pin number you are using on your arduino as the data pin for the neo pixels. As a default it is set to pin 0 but if you follow the instructions on the Adafruit page you will need to change this to pin 6. Simply change the number after "#define PIN" to match your setup. 66 | 67 | ![Screenshot>pin0](assets/pin0.png) 68 | ![Screenshot>pin6](assets/pin6.png) 69 | 70 | - Next you need to adjust the number of LEDs on your ring. The default is 16 but you will need to adjust for whatever ring you bought. Simply change the number after "#define LED_QUANTITY" to the number of LED's on your hardware. 71 | 72 | ![Screenshot>pin0](assets/led_16.png) 73 | ![Screenshot>pin6](assets/led_60.png) 74 | 75 | - The last edit you have to do is to add the text from your "ledSequence.txt" file to the arduino sketch where it is indicated. (See the screenshots below) You must open the "ledSequence.txt" file in a basic text editor like wordpad or textedit and select all of the text and copy it. Then go to the part of the code on line 18 where it says "//paste contents of the txt file from the sequencer here.", select that line, and paste the text from your txt file there in it's place. 76 | 77 | ![Screenshot>pin0](assets/paste1.png) 78 | ![Screenshot>pin6](assets/paste2.png) 79 | 80 | - At this point you can verify your code by hitting the checkmark in the upper left corner. Be sure that you have selected your board and your serial port under the "Tools" menu. Then you can Upload the code to your board and watch it go by pressing the Upload arrow to the right of the Verify checkmark. 81 | - If you want to adjust the speed, there is a variable for the interval or number of "cycles" you want to wait before changing the LED to the next color called "interval" and it is set to 50 as a default. Lower values will speed up your patterns. 82 | 83 | ![Screenshot>pin0](assets/interval.png) 84 | 85 | - You might also notice that the LEDs are fading out and do not turn off instantly. This is an aesthetic decision I like, but you can easily adjust it to fade slower or quicker by changing the number on the variable called "fadefraction." For a slow fade try changing it to .99 or for almost no fade try .50. 86 | 87 | ![Screenshot>pin0](assets/fade.png) 88 | 89 | - Hopefully you have it up and running, but if you are having troubles, make sure you can run some of the NeoPixel example files before using the neo-pixel player. -------------------------------------------------------------------------------- /assets/LED_pick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalcoleman/neoPixel_Sequencer/773252a9d2045bcc9626a8a871c42e7d183ca166/assets/LED_pick.png -------------------------------------------------------------------------------- /assets/LED_pick2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalcoleman/neoPixel_Sequencer/773252a9d2045bcc9626a8a871c42e7d183ca166/assets/LED_pick2.png -------------------------------------------------------------------------------- /assets/LEDselector1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalcoleman/neoPixel_Sequencer/773252a9d2045bcc9626a8a871c42e7d183ca166/assets/LEDselector1.png -------------------------------------------------------------------------------- /assets/arduino1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalcoleman/neoPixel_Sequencer/773252a9d2045bcc9626a8a871c42e7d183ca166/assets/arduino1.png -------------------------------------------------------------------------------- /assets/fade.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalcoleman/neoPixel_Sequencer/773252a9d2045bcc9626a8a871c42e7d183ca166/assets/fade.png -------------------------------------------------------------------------------- /assets/interval.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalcoleman/neoPixel_Sequencer/773252a9d2045bcc9626a8a871c42e7d183ca166/assets/interval.png -------------------------------------------------------------------------------- /assets/led_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalcoleman/neoPixel_Sequencer/773252a9d2045bcc9626a8a871c42e7d183ca166/assets/led_16.png -------------------------------------------------------------------------------- /assets/led_60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalcoleman/neoPixel_Sequencer/773252a9d2045bcc9626a8a871c42e7d183ca166/assets/led_60.png -------------------------------------------------------------------------------- /assets/paste1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalcoleman/neoPixel_Sequencer/773252a9d2045bcc9626a8a871c42e7d183ca166/assets/paste1.png -------------------------------------------------------------------------------- /assets/paste2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalcoleman/neoPixel_Sequencer/773252a9d2045bcc9626a8a871c42e7d183ca166/assets/paste2.png -------------------------------------------------------------------------------- /assets/pin0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalcoleman/neoPixel_Sequencer/773252a9d2045bcc9626a8a871c42e7d183ca166/assets/pin0.png -------------------------------------------------------------------------------- /assets/pin6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalcoleman/neoPixel_Sequencer/773252a9d2045bcc9626a8a871c42e7d183ca166/assets/pin6.png -------------------------------------------------------------------------------- /assets/playhead.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalcoleman/neoPixel_Sequencer/773252a9d2045bcc9626a8a871c42e7d183ca166/assets/playhead.png -------------------------------------------------------------------------------- /assets/sequencer_screen1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalcoleman/neoPixel_Sequencer/773252a9d2045bcc9626a8a871c42e7d183ca166/assets/sequencer_screen1.png -------------------------------------------------------------------------------- /assets/speedSlider.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalcoleman/neoPixel_Sequencer/773252a9d2045bcc9626a8a871c42e7d183ca166/assets/speedSlider.png -------------------------------------------------------------------------------- /assets/timeline1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalcoleman/neoPixel_Sequencer/773252a9d2045bcc9626a8a871c42e7d183ca166/assets/timeline1.png -------------------------------------------------------------------------------- /assets/timeline2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalcoleman/neoPixel_Sequencer/773252a9d2045bcc9626a8a871c42e7d183ca166/assets/timeline2.png -------------------------------------------------------------------------------- /assets/timeline3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digitalcoleman/neoPixel_Sequencer/773252a9d2045bcc9626a8a871c42e7d183ca166/assets/timeline3.png -------------------------------------------------------------------------------- /neo_pixel_player/neo_pixel_player.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define PIN 0 5 | #define LED_QUANTITY 16 6 | 7 | Adafruit_NeoPixel strip = Adafruit_NeoPixel(LED_QUANTITY, PIN, NEO_GRB + NEO_KHZ800); 8 | 9 | //store the led values for fading 10 | struct led{ 11 | byte hue; 12 | byte sat; 13 | byte light; 14 | }; 15 | 16 | //load the sequence into PROGMEM because otherwise it overloads RAM 17 | const byte ledSeq [16][LED_QUANTITY][3] PROGMEM = { 18 | //paste contents of the txt file from the sequencer here. 19 | }; 20 | 21 | 22 | float fadefraction = .95; //adjust the fade out speed. typically .9-.99 23 | int interval = 50; //the speed of the animation, lower is faster 24 | 25 | //store colors for conversion from HSB 26 | byte col[3] = {0,0,0}; 27 | //count loops 28 | int counter = 0; 29 | //current frame of the sequence 30 | int frame = 0; 31 | 32 | led myLeds[LED_QUANTITY]; 33 | 34 | void setup() { 35 | strip.begin(); 36 | strip.show(); // Initialize all pixels to 'off' 37 | } 38 | 39 | void loop() { 40 | //step thru the sequence 41 | if(frame < 16) { 42 | if(counter%interval==0) { 43 | for(int x = 0; x= 0 && x < _myCellX && y >= 0 && y < _myCellY) { 28 | p.fill(_myCells[x][y] == 1 ? -0.2 : -0.5); 29 | p.rect(x * stepX, y * stepY, stepX - gapX, stepY - gapY); 30 | } 31 | } 32 | p.fill(-1); 33 | p.rect(cnt * stepX, 0, 1, height - gapY); 34 | } 35 | } 36 | ); 37 | } 38 | 39 | ColorMatrix setGrid(int theCellX, int theCellY) { 40 | _myCellX = theCellX; 41 | _myCellY = theCellY; 42 | sum = _myCellX * _myCellY; 43 | stepX = getWidth() / _myCellX; 44 | stepY = getHeight() / _myCellY; 45 | _myCells = new int[_myCellX][_myCellY]; 46 | _myCellColor = new int[_myCellX][_myCellY]; 47 | for (int x = 0; x < _myCellX; x++) { 48 | for (int y = 0; y < _myCellY; y++) { 49 | _myCells[x][y] = 1; 50 | _myCellColor[x][y] = 0; 51 | } 52 | } 53 | return this; 54 | } 55 | 56 | void updatecnt(int column) { 57 | cnt = column; 58 | } 59 | 60 | ColorMatrix setBackground(int c) { 61 | bkg = 0x00000000; 62 | if ((c >> 24 & 0xff) > 0) { 63 | bkg = (c >> 24) << 24 | (c >> 16) << 16 | (c >> 8) << 8 | (c >> 0) << 0; 64 | } 65 | return this; 66 | } 67 | 68 | ColorMatrix setCellColor(int theX, int theY, int theValue) { 69 | _myCellColor[theX][theY] = theValue; 70 | return this; 71 | } 72 | 73 | int getCellColor(int theX, int theY) { 74 | return _myCellColor[theX][theY]; 75 | } 76 | 77 | ColorMatrix clear() { 78 | for (int x = 0; x < _myCells.length; x++) { 79 | for (int y = 0; y < _myCells[x].length; y++) { 80 | _myCells[x][y] = 1; 81 | _myCellColor[x][y] = 0; 82 | } 83 | } 84 | return this; 85 | } 86 | } -------------------------------------------------------------------------------- /neo_pixel_sequencer/LED.pde: -------------------------------------------------------------------------------- 1 | class LED { 2 | 3 | color ledColor; 4 | float rotation, space; 5 | PVector pos; 6 | color strokeColor; 7 | boolean select = false; 8 | int strokeW = 1; 9 | 10 | LED(float rot, PVector posit, float spaceTemp) { 11 | rotation = rot; 12 | pos = posit; 13 | ledColor = color(.5, 0, 0); 14 | strokeColor = 0; 15 | space = spaceTemp; 16 | } 17 | 18 | boolean update() { 19 | if (select) { 20 | strokeColor = color(0, 0, 1); 21 | strokeW = 2; 22 | } else { 23 | strokeColor = color(0, 0, .4); 24 | strokeW = 1; 25 | } 26 | float far = dist(mouseX, mouseY, pos.x, pos.y); 27 | float angle = atan2(mouseY-pos.y, mouseX-pos.x); 28 | if (angle<-slice) angle += TAU; 29 | if (mousePressed && far>space-10 && far < space+10 && angle < slice+rotation && angle> rotation-slice) { 30 | return true; 31 | } else { 32 | return false; 33 | } 34 | } 35 | 36 | void display() { 37 | fill(ledColor); 38 | strokeWeight(strokeW); 39 | stroke(strokeColor); 40 | pushMatrix(); 41 | translate(pos.x, pos.y); 42 | rotate(rotation); 43 | rect(space, 0, 20, 20); 44 | popMatrix(); 45 | } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /neo_pixel_sequencer/colorPicker.pde: -------------------------------------------------------------------------------- 1 | 2 | class ColorPicker { 3 | 4 | int 5 | ColorPickerX, //color picker horizontal position 6 | ColorPickerY, //color picker vertical position 7 | LineY; //hue line vertical position 8 | float 9 | CrossX, //saturation+brightness cross horizontal position 10 | CrossY, //saturation+brightness cross horizontal position 11 | ColorSelectorX = 100, //color selector button horizontal position <------------------------------------------- CHANGE 12 | ColorSelectorY = 100; //color selector button vertical position <------------------------------------------- CHANGE 13 | 14 | boolean 15 | isDraggingCross = false, //check if mouse is dragging the cross 16 | isDraggingLine = false, //check if mouse is dragging the line 17 | ShowColorPicker = true; //toggle color picker visibility (even = not visible, odd = visible) 18 | 19 | color 20 | activeColor = color(PI, 0.5, 0.5), //contain the selected color 21 | interfaceColor = color(2*PI, 1.0, 1.0); //change as you want <------------------------------------------- CHANGE 22 | 23 | ColorPicker(int pickx, int picky) { 24 | ColorPickerX = pickx; 25 | ColorPickerY = picky; 26 | LineY = ColorPickerY + int(hue(activeColor)); //set initial Line position 27 | CrossX = ColorPickerX + saturation(activeColor)*255; //set initial Line position 28 | CrossY = ColorPickerY + brightness(activeColor)*255; //set initial Line position 29 | } 30 | 31 | void update() { 32 | checkMouse(); 33 | activeColor = color( (LineY - ColorPickerY)/40.58 , (CrossX - ColorPickerX)/255.0 , (255 - ( CrossY - ColorPickerY ))/255.0 ); //set current active color 34 | } 35 | 36 | void display() { 37 | drawColorSelector(); 38 | drawColorPicker(); 39 | drawLine(); 40 | drawCross(); 41 | drawActiveColor(); 42 | drawValues(); 43 | //drawOK(); 44 | } 45 | 46 | void drawColorSelector() 47 | 48 | { 49 | 50 | stroke( interfaceColor ); 51 | strokeWeight( 1 ); 52 | fill( 0 ); 53 | rect( ColorSelectorX , ColorSelectorY , 20 , 20 ); //draw color selector border at its x y position 54 | stroke( 0 ); 55 | fill( activeColor ); 56 | rect( ColorSelectorX + 1 , ColorSelectorY + 1 , 18 , 18 ); //draw the color selector fill 1px inside the border 57 | 58 | } 59 | 60 | void drawOK() 61 | 62 | { 63 | 64 | if ( mouseX > ColorPickerX + 285 && mouseX < ColorPickerX + 305 && mouseY > ColorPickerY + 240 && mouseY < ColorPickerY + 260 ) //check if the cross is on the darker color 65 | fill(0); //optimize visibility on ligher colors 66 | else 67 | fill(100); //optimize visibility on darker colors 68 | 69 | text( "OK", ColorPickerX + 285, ColorPickerY + 250 ); 70 | } 71 | 72 | 73 | void drawValues() 74 | 75 | { 76 | 77 | fill( 2*PI ); 78 | //fill( 0 ); 79 | textSize( 10 ); 80 | 81 | text( "H: " + int( ( LineY - ColorPickerY ) * 1.417647 ) + "°", ColorPickerX + 285, ColorPickerY +15); 82 | text( "S: " + int( ( CrossX - ColorPickerX ) * 0.39215 + 0.5 ) + "%", ColorPickerX + 286, ColorPickerY + 30 ); 83 | text( "B: " + int( 100 - ( ( CrossY - ColorPickerY ) * 0.39215 ) ) + "%", ColorPickerX + 285, ColorPickerY + 45 ); 84 | 85 | text( "R: " + int( red( activeColor )*40.85 ), ColorPickerX + 285, ColorPickerY + 70 ); 86 | text( "G: " + int( green( activeColor )*255 ), ColorPickerX + 285, ColorPickerY + 85 ); 87 | text( "B: " + int( blue( activeColor )*255 ), ColorPickerX + 285, ColorPickerY + 100 ); 88 | 89 | text( hex( activeColor, 6 ), ColorPickerX + 285, ColorPickerY + 125 ); 90 | } 91 | 92 | void drawCross() 93 | 94 | { 95 | 96 | if ( brightness( activeColor ) < 0.35 ) 97 | stroke( 2*PI ); 98 | else 99 | stroke( 0 ); 100 | 101 | line( CrossX - 5, CrossY, CrossX + 5, CrossY ); 102 | line( CrossX, CrossY - 5, CrossX, CrossY + 5 ); 103 | } 104 | 105 | 106 | void drawLine() 107 | 108 | { 109 | 110 | stroke(0); 111 | line( ColorPickerX + 259, LineY, ColorPickerX + 276, LineY ); 112 | } 113 | 114 | 115 | void drawColorPicker() 116 | 117 | { 118 | 119 | stroke( interfaceColor ); 120 | for ( int j = 0; j < 255; j++ ) //draw a row of pixel with the same brightness but progressive saturation 121 | 122 | { 123 | 124 | for ( int i = 0; i < 255; i++ ) //draw a column of pixel with the same saturation but progressive brightness 125 | 126 | set( ColorPickerX + j, ColorPickerY + i, color((LineY - ColorPickerY)/40.58, j/255.0, (255 - i)/255.0 ) ); 127 | } 128 | 129 | 130 | for ( int j = 0; j < 255; j++ ) 131 | 132 | { 133 | 134 | for ( int i = 0; i < 20; i++ ) 135 | 136 | set( ColorPickerX + 258 + i, ColorPickerY + j, color( j/40.58, 1.0, 1.0 ) ); 137 | } 138 | } 139 | 140 | void drawActiveColor() 141 | 142 | { 143 | 144 | fill( activeColor ); 145 | stroke( 0 ); 146 | strokeWeight( 1 ); 147 | rect( ColorPickerX + 258, ColorPickerY+280, 40, 40 ); 148 | } 149 | 150 | 151 | void checkMouse() 152 | 153 | { 154 | 155 | if ( mousePressed ) 156 | 157 | { 158 | 159 | if (mouseX>ColorPickerX+258&&mouseXColorPickerY-1&&mouseYColorPickerX-1&&mouseXColorPickerY-1&&mouseY leds; 6 | PFont myFontType; 7 | ColorPicker colorPicker; 8 | int colorPickerTop = 10, colorPickerLeft = 10; 9 | float MAX_BRIGHTNESS = 1.0; 10 | float MAX_SATURATION = 1.0; 11 | float MAX_HUE = TWO_PI; 12 | float MAX_ALPHA = 1; 13 | PGraphics mainWin; 14 | int selected = -1; 15 | int currentFrame = 0; 16 | int SEQUENCE_LENGTH = 16; 17 | int NUMBER_OF_LED = 16; 18 | float slice; 19 | 20 | void setup() { 21 | size(920, 1000); 22 | //setup color picker 23 | colorMode(HSB, MAX_HUE, MAX_SATURATION, MAX_BRIGHTNESS, MAX_ALPHA); 24 | //colorMode(HSB); 25 | colorPicker = new ColorPicker(colorPickerLeft, colorPickerTop); 26 | mainWin = createGraphics(300, 280); 27 | myFontType = createFont("arial", 16); 28 | textFont(myFontType); 29 | slice = PI/NUMBER_OF_LED; 30 | //setup neo-pixel ring gui 31 | rectMode(CENTER); 32 | leds = new ArrayList(); 33 | for (int i = 0; i 2 && NUMBER_OF_LED!=newled) { 210 | float spacing = newled*(8-newled/15.0); 211 | if(NUMBER_OF_LED < newled) { 212 | for (int i = NUMBER_OF_LED; inewled; i--) { 231 | leds.remove(i); 232 | } 233 | } 234 | NUMBER_OF_LED = newled; 235 | slice = PI/NUMBER_OF_LED; 236 | cp5.get(ColorMatrix.class, "LED_sequence").setGrid(SEQUENCE_LENGTH, NUMBER_OF_LED); 237 | } 238 | } --------------------------------------------------------------------------------