├── .gitignore ├── README.md ├── pixelpusher_arrayscanner ├── Mapping.txt └── pixelpusher_arrayscanner.pde ├── pixelpusher_colourcycle ├── AndroidManifest.xml ├── pixelpusher_colourcycle.pde └── sketch.properties ├── pixelpusher_colourcycle_fast ├── AndroidManifest.xml ├── pixelpusher_colourcycle_fast.pde └── sketch.properties ├── pixelpusher_colourcycle_halloween ├── AndroidManifest.xml ├── pixelpusher_colourcycle_halloween.pde └── sketch.properties ├── pixelpusher_colourpicker ├── AndroidManifest.xml ├── pixelpusher_colourpicker.pde └── sketch.properties ├── pixelpusher_colourwaves ├── .classpath ├── .project ├── observer.pde ├── pixelpusher_colourwaves.pde ├── scraper.pde └── sketch.properties ├── pixelpusher_config_tool ├── GUI_BUILDER_DATA │ └── gui.ser.2.3 ├── gui.pde ├── pixelpusher_config_tool.pde └── serialdetect.pde ├── pixelpusher_configurator ├── GUI_BUILDER_DATA │ └── gui.ser.2.3 ├── data │ ├── list_200593 │ ├── list_369108 │ ├── list_382677 │ ├── list_439725 │ ├── list_481405 │ ├── list_531216 │ ├── list_565113 │ ├── list_750214 │ ├── list_787941 │ ├── list_818673 │ ├── list_841569 │ ├── list_919384 │ ├── list_932479 │ ├── list_939168 │ ├── list_954858 │ └── list_997118 ├── gui.pde ├── model.pde └── pixelpusher_configurator.pde ├── pixelpusher_conways_life ├── .classpath ├── .project ├── observer.pde ├── pixelpusher_conways_life.pde ├── scraper.pde └── sketch.properties ├── pixelpusher_daylight_cycle ├── .classpath ├── .project ├── AndroidManifest.xml ├── observer.pde ├── pixelpusher_daylight_cycle.pde ├── scraper.pde └── sketch.properties ├── pixelpusher_example ├── AndroidManifest.xml ├── pixelpusher_example.pde └── sketch.properties ├── pixelpusher_fftriver ├── .classpath ├── .project ├── data │ ├── 0.png │ ├── 1.png │ ├── 2.png │ ├── 3.png │ ├── 4.png │ ├── 5.png │ ├── 6.png │ ├── 7.png │ ├── 8.png │ └── 9.png ├── gui.pde ├── image_beat_pusher.pde ├── observer.pde ├── pixelpusher_fftriver.pde └── scraper.pde ├── pixelpusher_fftriver_liveperformance ├── .classpath ├── .project ├── data │ ├── 0.png │ ├── 1.png │ ├── 2.png │ ├── 3.png │ ├── 4.png │ ├── 5.png │ ├── 6.png │ ├── 7.png │ ├── 8.png │ ├── 9.png │ ├── a.png │ ├── d.png │ ├── e.png │ ├── f.png │ ├── g.png │ ├── q.png │ ├── r.png │ ├── s.png │ ├── t.png │ ├── u.png │ ├── w.png │ └── y.png ├── gui.pde ├── image_beat_pusher.pde ├── observer.pde ├── pixelpusher_fftriver_mattshacks_bak.pde └── scraper.pde ├── pixelpusher_fftriver_webcam ├── .classpath ├── .project ├── data │ ├── 0.png │ ├── 1.png │ ├── 2.png │ ├── 3.png │ ├── 4.png │ ├── 5.png │ ├── 6.png │ ├── 7.png │ ├── 8.png │ ├── 9.png │ ├── a.png │ ├── d.png │ ├── e.png │ ├── f.png │ ├── g.png │ ├── q.png │ ├── r.png │ ├── s.png │ ├── t.png │ ├── u.png │ ├── w.png │ └── y.png ├── gui.pde ├── image_beat_pusher.pde ├── observer.pde ├── pixelpusher_fftriver_webcam.pde └── scraper.pde ├── pixelpusher_highcri ├── AndroidManifest.xml ├── pixelpusher_highcri.pde └── sketch.properties ├── pixelpusher_lightning ├── .classpath ├── .project ├── AndroidManifest.xml ├── observer.pde ├── pixelpusher_lightning.pde ├── scraper.pde └── sketch.properties ├── pixelpusher_lightpainting ├── .classpath ├── .project ├── observer.pde ├── pixelpusher_lightpainting.pde ├── scraper.pde └── sketch.properties ├── pixelpusher_starfield ├── .classpath ├── .project ├── observer.pde ├── pixelpusher_starfield.pde ├── scraper.pde └── sketch.properties ├── pixelpusher_syphon_bare ├── .classpath ├── .project ├── data │ ├── 0.png │ ├── 1.png │ ├── 2.png │ ├── 3.png │ ├── 4.png │ ├── 5.png │ ├── 6.png │ ├── 7.png │ ├── 8.png │ ├── 9.png │ ├── a.png │ ├── d.png │ ├── e.png │ ├── f.png │ ├── g.png │ ├── q.png │ ├── r.png │ ├── s.png │ ├── t.png │ ├── u.png │ ├── w.png │ └── y.png ├── observer.pde ├── pixelpusher_syphon_bare.pde └── scraper.pde ├── pixelpusher_syphon_triplewide ├── .classpath ├── .project ├── data │ ├── 0.png │ ├── 1.png │ ├── 2.png │ ├── 3.png │ ├── 4.png │ ├── 5.png │ ├── 6.png │ ├── 7.png │ ├── 8.png │ ├── 9.png │ ├── a.png │ ├── d.png │ ├── e.png │ ├── f.png │ ├── g.png │ ├── q.png │ ├── r.png │ ├── s.png │ ├── t.png │ ├── u.png │ ├── w.png │ └── y.png ├── observer.pde ├── pixelpusher_syphon_triplewide.pde └── scraper.pde ├── pixelpusher_tester └── pixelpusher_tester.pde ├── pixelpusher_tester_irising ├── controller.pde └── pixelpusher_tester_irising.pde ├── pixelpusher_text ├── .classpath ├── .project ├── observer.pde ├── pixelpusher_text.pde ├── scraper.pde └── sketch.properties ├── pixelpusher_triangles4 ├── observer.pde ├── pixelpusher_triangles4.pde └── scraper.pde └── pixelpusher_video_player ├── observer.pde ├── pixelpusher_video_player.pde └── scraper.pde /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | .DS_Store 3 | 4 | # Package Files # 5 | *.jar 6 | *.war 7 | *.ear 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | PixelPusher-processing-sketches 2 | =============================== 3 | 4 | Sketches for PixelPusher -------------------------------------------------------------------------------- /pixelpusher_arrayscanner/Mapping.txt: -------------------------------------------------------------------------------- 1 | (0,3) -> (304,296) 2 | (0,9) -> (319,295) 3 | (0,10) -> (303,296) 4 | (0,11) -> (321,295) 5 | (0,31) -> (304,296) 6 | (0,34) -> (304,296) 7 | (0,35) -> (314,294) 8 | (0,36) -> (300,295) 9 | (0,37) -> (318,292) 10 | (0,38) -> (304,296) 11 | (0,59) -> (304,296) 12 | (0,4) -> (550,19) 13 | (0,5) -> (554,18) 14 | (0,13) -> (293,294) 15 | (0,15) -> (304,295) 16 | (0,21) -> (305,295) 17 | (0,31) -> (359,337) 18 | (0,32) -> (250,334) 19 | (0,33) -> (163,334) 20 | (0,34) -> (127,324) 21 | (0,35) -> (307,203) 22 | (0,36) -> (298,205) 23 | (0,37) -> (313,228) 24 | (0,38) -> (311,254) 25 | (0,39) -> (276,287) 26 | (0,40) -> (267,279) 27 | (0,41) -> (262,288) 28 | (0,42) -> (293,291) 29 | (0,43) -> (317,281) 30 | (0,44) -> (392,258) 31 | (0,45) -> (385,257) 32 | (0,46) -> (387,258) 33 | (0,47) -> (392,256) 34 | (0,48) -> (391,255) 35 | (0,49) -> (392,257) 36 | (0,50) -> (395,257) 37 | (0,51) -> (403,247) 38 | (0,52) -> (264,248) 39 | (0,53) -> (228,236) 40 | (0,54) -> (302,236) 41 | (0,55) -> (361,262) 42 | (0,56) -> (460,276) 43 | (0,57) -> (449,291) 44 | (0,58) -> (487,306) 45 | (0,59) -> (446,291) 46 | (0,0) -> (170,281) 47 | (0,1) -> (190,265) 48 | (0,2) -> (194,264) 49 | (0,3) -> (194,270) 50 | (0,4) -> (195,268) 51 | (0,5) -> (188,274) 52 | (0,6) -> (187,271) 53 | (0,7) -> (191,259) 54 | (0,8) -> (208,226) 55 | (0,9) -> (195,229) 56 | (0,10) -> (200,253) 57 | (0,11) -> (186,284) 58 | (0,12) -> (175,275) 59 | (0,13) -> (155,266) 60 | (0,14) -> (153,264) 61 | (0,15) -> (154,260) 62 | (0,16) -> (159,257) 63 | (0,17) -> (159,261) 64 | (0,18) -> (160,262) 65 | (0,19) -> (160,261) 66 | (0,20) -> (159,261) 67 | (0,21) -> (161,260) 68 | (0,22) -> (160,261) 69 | (0,23) -> (158,262) 70 | (0,24) -> (159,262) 71 | (0,25) -> (157,263) 72 | (0,26) -> (153,266) 73 | (0,27) -> (151,266) 74 | (0,28) -> (145,267) 75 | (0,29) -> (141,268) 76 | (0,30) -> (138,269) 77 | (0,31) -> (135,269) 78 | (0,32) -> (135,269) 79 | (0,33) -> (136,269) 80 | (0,34) -> (136,269) 81 | (0,35) -> (135,269) 82 | (0,36) -> (135,269) 83 | (0,37) -> (135,268) 84 | (0,38) -> (135,268) 85 | (0,39) -> (134,268) 86 | (0,40) -> (133,268) 87 | (0,41) -> (133,267) 88 | (0,42) -> (134,267) 89 | (0,43) -> (133,266) 90 | (0,44) -> (133,266) 91 | (0,45) -> (132,266) 92 | (0,46) -> (132,267) 93 | (0,47) -> (132,267) 94 | (0,48) -> (132,268) 95 | (0,49) -> (133,268) 96 | (0,50) -> (136,268) 97 | (0,51) -> (136,268) 98 | (0,52) -> (135,268) 99 | (0,53) -> (135,267) 100 | (0,54) -> (135,267) 101 | (0,55) -> (134,268) 102 | (0,56) -> (134,267) 103 | (0,57) -> (134,266) 104 | (0,58) -> (133,266) 105 | (0,59) -> (133,266) 106 | (0,0) -> (349,287) 107 | (0,1) -> (352,285) 108 | (0,2) -> (270,299) 109 | (0,3) -> (157,310) 110 | (0,4) -> (45,290) 111 | (0,5) -> (83,252) 112 | (0,6) -> (87,239) 113 | (0,7) -> (83,237) 114 | (0,8) -> (77,238) 115 | (0,9) -> (70,235) 116 | (0,10) -> (67,227) 117 | (0,11) -> (70,215) 118 | (0,12) -> (73,204) 119 | (0,13) -> (73,193) 120 | (0,14) -> (81,174) 121 | (0,15) -> (112,157) 122 | (0,16) -> (127,140) 123 | (0,17) -> (148,131) 124 | (0,18) -> (173,129) 125 | (0,19) -> (161,91) 126 | (0,20) -> (187,88) 127 | (0,21) -> (213,78) 128 | (0,22) -> (241,72) 129 | (0,23) -> (236,50) 130 | (0,24) -> (251,48) 131 | (0,25) -> (336,27) 132 | (0,27) -> (2,115) 133 | (0,28) -> (18,60) 134 | (0,29) -> (59,92) 135 | (0,30) -> (56,112) 136 | (0,31) -> (89,160) 137 | (0,32) -> (95,151) 138 | (0,33) -> (118,144) 139 | (0,34) -> (118,127) 140 | (0,35) -> (132,122) 141 | (0,36) -> (156,119) 142 | (0,37) -> (168,110) 143 | (0,38) -> (191,107) 144 | (0,39) -> (207,110) 145 | (0,40) -> (213,110) 146 | (0,41) -> (206,100) 147 | (0,42) -> (207,98) 148 | (0,43) -> (214,101) 149 | (0,44) -> (209,94) 150 | (0,45) -> (216,98) 151 | (0,46) -> (218,99) 152 | (0,47) -> (217,99) 153 | (0,48) -> (172,84) 154 | (0,49) -> (169,75) 155 | (0,50) -> (165,72) 156 | (0,51) -> (165,72) 157 | (0,52) -> (175,76) 158 | (0,53) -> (176,76) 159 | (0,54) -> (177,77) 160 | (0,55) -> (177,76) 161 | (0,56) -> (178,76) 162 | (0,57) -> (178,76) 163 | (0,58) -> (184,79) 164 | (0,59) -> (184,79) 165 | -------------------------------------------------------------------------------- /pixelpusher_arrayscanner/pixelpusher_arrayscanner.pde: -------------------------------------------------------------------------------- 1 | 2 | // Automatic mapping generator for PixelPusher 3 | // by jas@heroicrobot.com 4 | // 5 | 6 | import com.heroicrobot.dropbit.registry.*; 7 | import com.heroicrobot.dropbit.devices.pixelpusher.Pixel; 8 | import com.heroicrobot.dropbit.devices.pixelpusher.Strip; 9 | import java.util.*; 10 | import java.io.*; 11 | import processing.core.*; 12 | import processing.video.*; 13 | 14 | 15 | DeviceRegistry registry; 16 | 17 | Capture video; 18 | 19 | PImage darkframe; 20 | PImage lightframe; 21 | PImage difference; 22 | 23 | int w=800, h=600; 24 | 25 | class Position { 26 | int x; 27 | int y; 28 | public Position(int ix, int iy) { 29 | this.x=ix; 30 | this.y=iy; 31 | } 32 | } 33 | 34 | class Mapping { 35 | int strip; 36 | int pixel; 37 | int x; 38 | int y; 39 | public Mapping(int is, int ip, int ix, int iy) { 40 | this.strip = is; 41 | this.pixel = ip; 42 | this.x = ix; 43 | this.y = iy; 44 | } 45 | } 46 | 47 | class TestObserver implements Observer { 48 | public boolean hasStrips = false; 49 | public void update(Observable registry, Object updatedDevice) { 50 | println("Registry changed!"); 51 | if (updatedDevice != null) { 52 | println("Device change: " + updatedDevice); 53 | } 54 | this.hasStrips = true; 55 | } 56 | }; 57 | 58 | TestObserver testObserver; 59 | 60 | int current_strip; 61 | int current_pixel; 62 | int number_of_strips; 63 | int length_of_strip; 64 | color colour; 65 | 66 | int colourIndex = 0; 67 | 68 | ArrayList display_map; 69 | 70 | public int chooseNextColour() { 71 | if (colourIndex > 1) { 72 | colourIndex = 0; 73 | } 74 | switch (colourIndex++) { 75 | case 1: return color(0, 0, 0); 76 | case 0: return color(255, 255, 255); 77 | default: return color(127, 127, 0); 78 | } 79 | } 80 | 81 | ArrayList scanForLights(PImage d) { 82 | color c; 83 | ArrayList hits = new ArrayList(); 84 | 85 | for (int y=0; y 150) 89 | hits.add(new Position(x,y)); 90 | } 91 | } 92 | return hits; 93 | } 94 | 95 | void setup() { 96 | size(w, h); 97 | registry = new DeviceRegistry(); 98 | testObserver = new TestObserver(); 99 | registry.addObserver(testObserver); 100 | background(0); 101 | colorMode(RGB, 255, 255, 255, 255); 102 | colour = chooseNextColour(); 103 | rectMode(CORNERS); 104 | String[] cameras = Capture.list(); 105 | println("Available cameras:"); 106 | for (int i = 0; i < cameras.length; i++) { 107 | println(cameras[i]); 108 | } 109 | 110 | video = new Capture(this, cameras[3]); 111 | video.start(); 112 | darkframe=createImage(w, h, RGB); 113 | lightframe= createImage(w,h, RGB); 114 | difference= createImage(w, h, RGB); 115 | current_pixel = 0; 116 | current_strip = 0; 117 | display_map = new ArrayList(); 118 | } 119 | 120 | void draw() { 121 | 122 | if (current_pixel == 0 && current_strip == 0) { 123 | fill(0,0,0,255); 124 | noStroke(); 125 | rect(0,0,w,h); 126 | } 127 | 128 | fill(255,255,255,255); 129 | 130 | // scrape for the strips 131 | if (testObserver.hasStrips) { 132 | //registry.setExtraDelay(0); 133 | registry.startPushing(); 134 | registry.setAutoThrottle(true); 135 | 136 | 137 | List strips = registry.getStrips(); 138 | number_of_strips = strips.size(); 139 | if (current_strip >= number_of_strips) { 140 | current_strip = 0; 141 | println("Off of strips."); 142 | } 143 | Strip current_strip_o = strips.get(current_strip); 144 | length_of_strip = current_strip_o.getLength(); 145 | if (current_pixel >= length_of_strip) { 146 | current_pixel = 0; 147 | println("Off of strip."); 148 | } 149 | current_strip_o.setPixel(colour, current_pixel); 150 | 151 | // if we're at the beginning of a dark frame, take a new dark frame 152 | if (current_strip == 0 && current_pixel == 0) { 153 | if (colour == color(0,0,0)) { 154 | // we were doing the dark frame 155 | while (!video.available()) { 156 | Thread.yield(); 157 | } 158 | video.read(); 159 | darkframe.set(0,0, video); 160 | } 161 | colour = chooseNextColour(); 162 | } 163 | 164 | 165 | if (colour == color(255,255,255)) { 166 | while (!video.available()) { 167 | Thread.yield(); 168 | } 169 | video.read(); 170 | lightframe.set(0,0, video); 171 | 172 | difference.set(0,0, video); 173 | difference.blend(darkframe, 0, 0, w, h, 0, 0, w, h, SUBTRACT); 174 | 175 | ArrayList hits = scanForLights(difference); 176 | 177 | // compute the centroid 178 | int cx, cy, n; 179 | cx = cy = n = 0; 180 | if (hits.size() > 0) { 181 | for (Position p : hits) { 182 | n++; 183 | cx += p.x; 184 | cy += p.y; 185 | } 186 | 187 | cx /= n; 188 | cy /= n; 189 | println("For strip ("+current_strip+","+current_pixel+") centroid is ("+cx+","+cy+")"); 190 | display_map.add(new Mapping(current_strip, current_pixel, cx, cy)); 191 | point(cx, cy); 192 | } 193 | } 194 | // turn off the pixel we just did 195 | current_strip_o.setPixel(color(0,0,0), current_pixel); 196 | 197 | // move on to the next 198 | current_pixel++; 199 | if (current_pixel >= length_of_strip) { 200 | current_pixel = 0; 201 | current_strip++; 202 | 203 | if (current_strip == number_of_strips) { 204 | try { 205 | OutputStream saveout = createOutput("Mapping.txt"); 206 | PrintStream ps = new PrintStream(saveout); 207 | for (Mapping m : display_map) { 208 | ps.println("("+m.strip+","+m.pixel+") -> ("+m.x+","+m.y+")"); 209 | } 210 | ps.close(); 211 | saveout.close(); 212 | } catch (IOException ioe) { 213 | ioe.printStackTrace(); 214 | } 215 | } 216 | } 217 | } 218 | } 219 | 220 | -------------------------------------------------------------------------------- /pixelpusher_colourcycle/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /pixelpusher_colourcycle/pixelpusher_colourcycle.pde: -------------------------------------------------------------------------------- 1 | 2 | 3 | import com.heroicrobot.dropbit.registry.*; 4 | import com.heroicrobot.dropbit.devices.pixelpusher.Pixel; 5 | import com.heroicrobot.dropbit.devices.pixelpusher.Strip; 6 | import java.util.*; 7 | 8 | private Random random = new Random(); 9 | 10 | DeviceRegistry registry; 11 | 12 | int[][] colors = { 13 | { 14 | 127, 0, 0 15 | } 16 | , 17 | { 18 | 0, 127, 0 19 | } 20 | , 21 | { 22 | 0, 0, 127 23 | } 24 | }; 25 | 26 | public Pixel generateRandomPixel() { 27 | //return new Pixel((byte)(random.nextInt(scaling)),(byte)(random.nextInt(scaling)),(byte)(random.nextInt(scaling))); 28 | //return new Pixel((byte)(15), (byte)0, (byte)0); 29 | int[] colour = colors[random.nextInt(colors.length)]; 30 | return new Pixel((byte)colour[0], (byte)colour[1], (byte)colour[2]); 31 | } 32 | 33 | class TestObserver implements Observer { 34 | public boolean hasStrips = false; 35 | public void update(Observable registry, Object updatedDevice) { 36 | println("Registry changed!"); 37 | if (updatedDevice != null) { 38 | println("Device change: " + updatedDevice); 39 | } 40 | this.hasStrips = true; 41 | } 42 | } 43 | 44 | TestObserver testObserver; 45 | int c = 0; 46 | 47 | void setup() { 48 | registry = new DeviceRegistry(); 49 | testObserver = new TestObserver(); 50 | registry.addObserver(testObserver); 51 | colorMode(HSB, 100); 52 | size(640, 640); 53 | prepareExitHandler(); 54 | } 55 | 56 | void draw() { 57 | int x=0; 58 | int y=0; 59 | if (testObserver.hasStrips) { 60 | registry.startPushing(); 61 | registry.setExtraDelay(0); 62 | registry.setAutoThrottle(true); 63 | int stripy = 0; 64 | List strips = registry.getStrips(); 65 | 66 | if (++c > 99) 67 | c = 0; 68 | int numStrips = strips.size(); 69 | //println("Strips total = "+numStrips); 70 | if (numStrips == 0) 71 | return; 72 | for (int stripNo = 0; stripNo < numStrips; stripNo++) { 73 | fill(c+(stripNo*2), 100, 100); 74 | rect(0, stripNo * (height/numStrips), width/2, (stripNo+1) * (height/numStrips)); 75 | fill(c+((numStrips - stripNo)*2), 100, 100); 76 | rect(width/2, stripNo * (height/numStrips), width, (stripNo+1) * (height/numStrips)); 77 | } 78 | 79 | 80 | int yscale = height / strips.size(); 81 | for (Strip strip : strips) { 82 | int xscale = width / strip.getLength(); 83 | for (int stripx = 0; stripx < strip.getLength(); stripx++) { 84 | x = stripx*xscale + 1; 85 | y = stripy*yscale + 1; 86 | color c = get(x, y); 87 | 88 | strip.setPixel(c, stripx); 89 | } 90 | stripy++; 91 | } 92 | } 93 | } 94 | 95 | private void prepareExitHandler () { 96 | 97 | Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { 98 | 99 | public void run () { 100 | 101 | System.out.println("Shutdown hook running"); 102 | 103 | List strips = registry.getStrips(); 104 | for (Strip strip : strips) { 105 | for (int i=0; i 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /pixelpusher_colourcycle_fast/pixelpusher_colourcycle_fast.pde: -------------------------------------------------------------------------------- 1 | 2 | 3 | import com.heroicrobot.dropbit.registry.*; 4 | import com.heroicrobot.dropbit.devices.pixelpusher.Pixel; 5 | import com.heroicrobot.dropbit.devices.pixelpusher.Strip; 6 | import java.util.*; 7 | 8 | private Random random = new Random(); 9 | 10 | DeviceRegistry registry; 11 | 12 | int[][] colors = { 13 | {127, 0, 0}, 14 | {0, 127, 0}, 15 | {0, 0, 127} 16 | }; 17 | 18 | public Pixel generateRandomPixel() { 19 | //return new Pixel((byte)(random.nextInt(scaling)),(byte)(random.nextInt(scaling)),(byte)(random.nextInt(scaling))); 20 | //return new Pixel((byte)(15), (byte)0, (byte)0); 21 | int[] colour = colors[random.nextInt(colors.length)]; 22 | return new Pixel((byte)colour[0], (byte)colour[1], (byte)colour[2]); 23 | } 24 | 25 | class TestObserver implements Observer { 26 | public boolean hasStrips = false; 27 | public void update(Observable registry, Object updatedDevice) { 28 | println("Registry changed!"); 29 | if (updatedDevice != null) { 30 | println("Device change: " + updatedDevice); 31 | } 32 | this.hasStrips = true; 33 | } 34 | } 35 | 36 | TestObserver testObserver; 37 | int c = 0; 38 | 39 | void setup() { 40 | registry = new DeviceRegistry(); 41 | testObserver = new TestObserver(); 42 | registry.addObserver(testObserver); 43 | colorMode(HSB, 100); 44 | size(480, 64); 45 | frameRate(300); 46 | } 47 | 48 | void draw() { 49 | int x=0; 50 | int y=0; 51 | if (testObserver.hasStrips) { 52 | registry.setFrameLimit(1000); 53 | registry.startPushing(); 54 | registry.setExtraDelay(0); 55 | registry.setAutoThrottle(false); 56 | int stripy = 0; 57 | List strips = registry.getStrips(); 58 | 59 | if (++c > 99) 60 | c = 0; 61 | int numStrips = strips.size(); 62 | //println("Strips total = "+numStrips); 63 | if (numStrips == 0) 64 | return; 65 | for (int stripNo = 0; stripNo < numStrips; stripNo++) { 66 | fill(c+(stripNo*2), 100, 100); 67 | rect(0, stripNo * (height/numStrips), width/2, (stripNo+1) * (height/numStrips)); 68 | fill(c+((numStrips - stripNo)*2), 100, 100); 69 | rect(width/2, stripNo * (height/numStrips), width, (stripNo+1) * (height/numStrips)); 70 | } 71 | 72 | 73 | int yscale = height / strips.size(); 74 | for(Strip strip : strips) { 75 | int xscale = width / strip.getLength(); 76 | for (int stripx = 0; stripx < strip.getLength(); stripx++) { 77 | x = stripx*xscale + 1; 78 | y = stripy*yscale + 1; 79 | color c = get(x, y); 80 | 81 | strip.setPixel(c, stripx); 82 | } 83 | stripy++; 84 | } 85 | } 86 | } 87 | 88 | -------------------------------------------------------------------------------- /pixelpusher_colourcycle_fast/sketch.properties: -------------------------------------------------------------------------------- 1 | mode.id=processing.mode.java.JavaMode 2 | mode=Java 3 | -------------------------------------------------------------------------------- /pixelpusher_colourcycle_halloween/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /pixelpusher_colourcycle_halloween/pixelpusher_colourcycle_halloween.pde: -------------------------------------------------------------------------------- 1 | 2 | 3 | import com.heroicrobot.dropbit.registry.*; 4 | import com.heroicrobot.dropbit.devices.pixelpusher.Pixel; 5 | import com.heroicrobot.dropbit.devices.pixelpusher.Strip; 6 | import java.util.*; 7 | 8 | private Random random = new Random(); 9 | 10 | DeviceRegistry registry; 11 | 12 | int[][] colors = { 13 | { 14 | 0, 255, 0 15 | } 16 | , 17 | { 18 | 255, 131, 6 19 | } 20 | // You can add more colours here if you want: 21 | , 22 | { 23 | 128, 0, 128 24 | } 25 | 26 | }; 27 | 28 | class TestObserver implements Observer { 29 | public boolean hasStrips = false; 30 | public void update(Observable registry, Object updatedDevice) { 31 | println("Registry changed!"); 32 | if (updatedDevice != null) { 33 | println("Device change: " + updatedDevice); 34 | } 35 | this.hasStrips = true; 36 | } 37 | } 38 | 39 | TestObserver testObserver; 40 | int c = 0, d = 0; 41 | int direction = 1, d_direction = 1; 42 | 43 | void setup() { 44 | registry = new DeviceRegistry(); 45 | testObserver = new TestObserver(); 46 | registry.addObserver(testObserver); 47 | colorMode(RGB, 255); 48 | size(640, 640); 49 | prepareExitHandler(); 50 | } 51 | 52 | void draw() { 53 | int x=0; 54 | int y=0; 55 | if (testObserver.hasStrips) { 56 | registry.startPushing(); 57 | registry.setExtraDelay(0); 58 | registry.setAutoThrottle(true); 59 | registry.setAntiLog(true); 60 | int stripy = 0; 61 | List strips = registry.getStrips(); 62 | 63 | c += direction; 64 | 65 | if (c > 255) { 66 | direction=-direction; 67 | d+=d_direction; 68 | } 69 | if (c<1) { 70 | direction=-direction; 71 | d+=d_direction; 72 | } 73 | 74 | if (d > colors.length || d < 0) { 75 | d_direction = -d_direction; 76 | } 77 | 78 | 79 | int numStrips = strips.size(); 80 | //println("Strips total = "+numStrips); 81 | if (numStrips == 0) 82 | return; 83 | for (int stripNo = 0; stripNo < numStrips; stripNo++) { 84 | int offset = (d+stripNo) % colors.length; 85 | color fillcol = color(colors[offset][0], colors[offset][1], colors[offset][2]); 86 | int nextoffset = (d+stripNo+1) % colors.length; 87 | color nextfillcol = color(colors[nextoffset][0], colors[nextoffset][1], colors[nextoffset][2]); 88 | 89 | fill(lerpColor(fillcol, nextfillcol, c/256.0)); 90 | rect(0, stripNo * (height/numStrips), width/2, (stripNo+1) * (height/numStrips)); 91 | fillcol = color(colors[offset][0], colors[offset][1], colors[offset][2]); 92 | fill(lerpColor(nextfillcol, fillcol, c/256.0)); 93 | rect(width/2, stripNo * (height/numStrips), width, (stripNo+1) * (height/numStrips)); 94 | } 95 | 96 | 97 | int yscale = height / strips.size(); 98 | for (Strip strip : strips) { 99 | int xscale = width / strip.getLength(); 100 | for (int stripx = 0; stripx < strip.getLength(); stripx++) { 101 | x = stripx*xscale + 1; 102 | y = stripy*yscale + 1; 103 | color c = get(x, y); 104 | 105 | strip.setPixel(c, stripx); 106 | } 107 | stripy++; 108 | } 109 | } 110 | } 111 | 112 | private void prepareExitHandler () { 113 | 114 | Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { 115 | 116 | public void run () { 117 | 118 | System.out.println("Shutdown hook running"); 119 | 120 | List strips = registry.getStrips(); 121 | for (Strip strip : strips) { 122 | for (int i=0; i 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /pixelpusher_colourpicker/pixelpusher_colourpicker.pde: -------------------------------------------------------------------------------- 1 | 2 | 3 | import com.heroicrobot.dropbit.registry.*; 4 | import com.heroicrobot.dropbit.devices.pixelpusher.Pixel; 5 | import com.heroicrobot.dropbit.devices.pixelpusher.Strip; 6 | import java.util.*; 7 | 8 | private Random random = new Random(); 9 | 10 | DeviceRegistry registry; 11 | ColorPicker cp; 12 | 13 | int[][] colors = { 14 | {127, 0, 0}, 15 | {0, 127, 0}, 16 | {0, 0, 127} 17 | }; 18 | 19 | public Pixel generateRandomPixel() { 20 | //return new Pixel((byte)(random.nextInt(scaling)),(byte)(random.nextInt(scaling)),(byte)(random.nextInt(scaling))); 21 | //return new Pixel((byte)(15), (byte)0, (byte)0); 22 | int[] colour = colors[random.nextInt(colors.length)]; 23 | return new Pixel((byte)colour[0], (byte)colour[1], (byte)colour[2]); 24 | } 25 | 26 | class TestObserver implements Observer { 27 | public boolean hasStrips = false; 28 | public void update(Observable registry, Object updatedDevice) { 29 | println("Registry changed!"); 30 | if (updatedDevice != null) { 31 | println("Device change: " + updatedDevice); 32 | } 33 | this.hasStrips = true; 34 | } 35 | } 36 | 37 | TestObserver testObserver; 38 | int c = 0; 39 | 40 | void setup() { 41 | registry = new DeviceRegistry(); 42 | testObserver = new TestObserver(); 43 | registry.addObserver(testObserver); 44 | 45 | size( 500, 500 ); 46 | frameRate( 30 ); 47 | registry.setAntiLog(true); 48 | cp = new ColorPicker( 10, 10, 400, 400, 255 ); 49 | } 50 | 51 | void draw() { 52 | int x=0; 53 | int y=0; 54 | cp.render(); 55 | if (testObserver.hasStrips) { 56 | registry.startPushing(); 57 | registry.setAutoThrottle(true); 58 | int stripy = 0; 59 | List strips = registry.getStrips(); 60 | 61 | int numStrips = strips.size(); 62 | // println("Strips total = "+numStrips); 63 | if (numStrips == 0) 64 | return; 65 | 66 | for(Strip strip : strips) { 67 | // Uncomment this for the high-CRI strips. 68 | //strip.setRGBOW(true); 69 | for (int stripx = 0; stripx < strip.getLength(); stripx++) { 70 | strip.setPixel(cp.c, stripx); 71 | } 72 | stripy++; 73 | } 74 | } 75 | } 76 | 77 | public class ColorPicker 78 | { 79 | int x, y, w, h, c; 80 | PImage cpImage; 81 | 82 | public ColorPicker ( int x, int y, int w, int h, int c ) 83 | { 84 | this.x = x; 85 | this.y = y; 86 | this.w = w; 87 | this.h = h; 88 | this.c = c; 89 | 90 | cpImage = new PImage( w, h ); 91 | 92 | init(); 93 | } 94 | 95 | private void init () 96 | { 97 | // draw color. 98 | int cw = w - 60; 99 | for( int i=0; i= x && 153 | mouseX < x + w && 154 | mouseY >= y && 155 | mouseY < y + h ) 156 | { 157 | c = get( mouseX, mouseY ); 158 | } 159 | fill( c ); 160 | rect( x, y+h+10, 20, 20 ); 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /pixelpusher_colourpicker/sketch.properties: -------------------------------------------------------------------------------- 1 | mode.id=processing.mode.java.JavaMode 2 | mode=Java 3 | -------------------------------------------------------------------------------- /pixelpusher_colourwaves/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /pixelpusher_colourwaves/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | pixelpusher_fftriver 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | processing.plugin.core.sketchBuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | processing.plugin.core.sketchNature 22 | 23 | 24 | -------------------------------------------------------------------------------- /pixelpusher_colourwaves/observer.pde: -------------------------------------------------------------------------------- 1 | class TestObserver implements Observer { 2 | public boolean hasStrips = false; 3 | public void update(Observable registry, Object updatedDevice) { 4 | println("Registry changed!"); 5 | if (updatedDevice != null) { 6 | println("Device change: " + updatedDevice); 7 | } 8 | this.hasStrips = true; 9 | } 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /pixelpusher_colourwaves/pixelpusher_colourwaves.pde: -------------------------------------------------------------------------------- 1 | 2 | 3 | import com.heroicrobot.dropbit.registry.*; 4 | import com.heroicrobot.dropbit.devices.pixelpusher.Pixel; 5 | import com.heroicrobot.dropbit.devices.pixelpusher.Strip; 6 | 7 | import processing.core.*; 8 | import java.util.*; 9 | 10 | DeviceRegistry registry; 11 | 12 | int stride = 240; 13 | boolean use_weighted_get = true; 14 | 15 | boolean ready_to_go = true; 16 | 17 | int canvasW = 480; 18 | int canvasH = 32; 19 | float phase = 0; 20 | TestObserver testObserver; 21 | color pixels[][] = new color[480][32]; 22 | 23 | float SLOW_COLOR_ADJUST = 0.02; 24 | float DISCON_CHANCE = 0.001; 25 | //float DISCON_JUMP = 0.15; 26 | 27 | void setup() { 28 | size(canvasW, canvasH, P3D); 29 | registry = new DeviceRegistry(); 30 | testObserver = new TestObserver(); 31 | registry.addObserver(testObserver); 32 | registry.setAntiLog(true); 33 | //background(#000000); 34 | // stroke(#ffffff); 35 | noStroke(); 36 | fill(#ffffff); 37 | rectMode(CORNER); 38 | background(0); 39 | frameRate(60); 40 | fillPixels(); 41 | 42 | } 43 | 44 | void fillPixels() { 45 | color column = color(random(255), random(255), random(255)); 46 | for(int i = 0; i < canvasW; i++){ 47 | for(int j = 0; j< canvasH; j++){ 48 | if(i == 0) { 49 | pixels[i][j] = column; 50 | } else { 51 | pixels[i][j] = pixels[i - 1][j]; 52 | } 53 | } 54 | } 55 | } 56 | 57 | void adjustPixels() { 58 | color adjustedRow = adjustPixel(pixels[0][0]); 59 | for(int i = canvasW - 1; i > -1; i--){ 60 | for(int j = 0; j< canvasH; j++){ 61 | if(i == 0){ 62 | pixels[i][j] = adjustedRow; 63 | } else { 64 | pixels[i][j] = pixels[i - 1][j]; 65 | } 66 | } 67 | } 68 | } 69 | 70 | color adjustPixel(color input) { 71 | if(random(1) > DISCON_CHANCE) { // 95% of slight adjust 72 | return color(adjustColor(red(input)), adjustColor(green(input)), adjustColor(blue(input))); 73 | } else { 74 | return color(random(255), random(255), random(255)); 75 | } 76 | } 77 | 78 | int adjustColor(float floatInput) { 79 | int input = int(floatInput); 80 | int sign = 1 * random(1) > 0.5 ? -1 : 1; 81 | int adjust = int(255 * random(SLOW_COLOR_ADJUST)); 82 | return input + (sign * adjust); 83 | } 84 | 85 | void draw() { 86 | background(0); 87 | for(int i = 0; i < canvasW; i++){ 88 | for(int j = 0; j< canvasH; j++){ 89 | stroke(pixels[i][j]); 90 | point(i,j); 91 | } 92 | } 93 | adjustPixels(); 94 | scrape(); 95 | } 96 | 97 | void stop() 98 | { 99 | super.stop(); 100 | } 101 | 102 | -------------------------------------------------------------------------------- /pixelpusher_colourwaves/scraper.pde: -------------------------------------------------------------------------------- 1 | 2 | color weighted_get(int xpos, int ypos, int radius) { 3 | int red, green, blue; 4 | int xoffset, yoffset; 5 | int pixels_counted; 6 | 7 | color thispixel; 8 | 9 | 10 | red = green = blue = pixels_counted = 0; 11 | 12 | for (xoffset=-radius; xoffset strips = registry.getStrips(); 32 | boolean phase = false; 33 | // for every strip: 34 | int currenty = 0; 35 | int stripy = 0; 36 | for(Strip strip : strips) { 37 | int strides_per_strip = strip.getLength() / stride; 38 | 39 | int xscale = width / stride; 40 | int yscale = height / (strides_per_strip * strips.size()); 41 | 42 | // for every pixel in the physical strip 43 | for (int stripx = 0; stripx < strip.getLength(); stripx++) { 44 | int xpixel = stripx % stride; 45 | int stridenumber = stripx / stride; 46 | int xpos,ypos; 47 | 48 | if ((stridenumber & 1) == 0) { // we are going left to right 49 | xpos = xpixel * xscale; 50 | ypos = ((stripy*strides_per_strip) + stridenumber) * yscale; 51 | } else { // we are going right to left 52 | xpos = ((stride - 1)-xpixel) * xscale; 53 | ypos = ((stripy*strides_per_strip) + stridenumber) * yscale; 54 | } 55 | 56 | color c = 0; 57 | //c = weighted_get(xpos, ypos, int((xscale+yscale) / 3)); 58 | c=get(xpos,ypos); 59 | // c=weighted_get(xpos,ypos,1); 60 | strip.setPixel(c, stripx); 61 | 62 | } 63 | stripy++; 64 | } 65 | } 66 | updatePixels(); 67 | } 68 | -------------------------------------------------------------------------------- /pixelpusher_colourwaves/sketch.properties: -------------------------------------------------------------------------------- 1 | mode.id=processing.mode.experimental.ExperimentalMode 2 | mode=Experimental 3 | -------------------------------------------------------------------------------- /pixelpusher_config_tool/GUI_BUILDER_DATA/gui.ser.2.3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_config_tool/GUI_BUILDER_DATA/gui.ser.2.3 -------------------------------------------------------------------------------- /pixelpusher_config_tool/gui.pde: -------------------------------------------------------------------------------- 1 | /* ========================================================= 2 | * ==== WARNING === 3 | * ========================================================= 4 | * The code in this tab has been generated from the GUI form 5 | * designer and care should be taken when editing this file. 6 | * Only add/edit code inside the event handlers i.e. only 7 | * use lines between the matching comment tags. e.g. 8 | 9 | void myBtnEvents(GButton button) { //_CODE_:button1:12356: 10 | // It is safe to enter your event code here 11 | } //_CODE_:button1:12356: 12 | 13 | * Do not rename this tab! 14 | * ========================================================= 15 | */ 16 | 17 | public void detectBtnClick(GButton source, GEvent event) { //_CODE_:detectBtn:397567: 18 | portLabel.setText("Detecting pusher, please wait..."); 19 | pusher = DetectPusher(); 20 | if (pusher != null) { 21 | portLabel.setText("Port: " + pusher.port); 22 | verLabel.setText("Version: " + pusher.ver); 23 | configPanel.setVisible(true); 24 | } else { 25 | portLabel.setText("Pusher not found"); 26 | verLabel.setText(""); 27 | configPanel.setVisible(false); 28 | } 29 | } //_CODE_:detectBtn:397567: 30 | 31 | public void panel1_Click1(GPanel source, GEvent event) { //_CODE_:configPanel:481018: 32 | 33 | } //_CODE_:configPanel:481018: 34 | 35 | public void saveButtonClick(GButton source, GEvent event) { //_CODE_:saveButton:202835: 36 | writeConfig(pusher); 37 | } //_CODE_:saveButton:202835: 38 | 39 | public void custom_slider1_change1(GCustomSlider source, GEvent event) { //_CODE_:usbHoldoffSlider:271887: 40 | holdoffValueLabel.setText(usbHoldoffSlider.getValueS()); 41 | } //_CODE_:usbHoldoffSlider:271887: 42 | 43 | public void fileselect_button1_click1(GButton source, GEvent event) { //_CODE_:fileselect_button1:368389: 44 | println("fileselect_button1 - GButton event occured " + System.currentTimeMillis()%10000000 ); 45 | 46 | final JFileChooser fc = new JFileChooser(); 47 | println("Selecting a file."); 48 | println("Selecting a file."); 49 | // in response to a button click: 50 | int returnVal = fc.showOpenDialog(this); 51 | 52 | if (returnVal == JFileChooser.APPROVE_OPTION) { 53 | try { 54 | File file = fc.getSelectedFile(); 55 | println(file.getCanonicalPath()); 56 | filename = file.getCanonicalPath(); 57 | pathLabel.setText(filename); 58 | } 59 | catch (IOException ioe) { 60 | // 61 | } 62 | } 63 | } //_CODE_:fileselect_button1:368389: 64 | 65 | public void reflash_button1_click1(GButton source, GEvent event) { //_CODE_:reflash_button1:952778: 66 | println("reflash_button1 - GButton event occured " + System.currentTimeMillis()%10000000 ); 67 | enterReflash(pusher); 68 | reflashLabel.setText("In reflash mode"); 69 | } //_CODE_:reflash_button1:952778: 70 | 71 | public void remove_button1_click1(GButton source, GEvent event) { //_CODE_:remove_button1:409098: 72 | println("remove_button1 - GButton event occured " + System.currentTimeMillis()%10000000 ); 73 | eraseConfig(pusher); 74 | } //_CODE_:remove_button1:409098: 75 | 76 | public void reboot_button1_click1(GButton source, GEvent event) { //_CODE_:reboot_button1:322829: 77 | println("reboot_button1 - GButton event occured " + System.currentTimeMillis()%10000000 ); 78 | reboot(pusher); 79 | } //_CODE_:reboot_button1:322829: 80 | 81 | 82 | 83 | // Create all the GUI controls. 84 | // autogenerated do not edit 85 | public void createGUI(){ 86 | G4P.messagesEnabled(false); 87 | G4P.setGlobalColorScheme(GCScheme.BLUE_SCHEME); 88 | G4P.setCursor(ARROW); 89 | if(frame != null) 90 | frame.setTitle("PixelPusher Configuration Tool"); 91 | detectBtn = new GButton(this, 10, 10, 130, 30); 92 | detectBtn.setText("Detect PixelPusher"); 93 | detectBtn.addEventHandler(this, "detectBtnClick"); 94 | portLabel = new GLabel(this, 150, 20, 340, 20); 95 | portLabel.setTextAlign(GAlign.LEFT, GAlign.MIDDLE); 96 | portLabel.setOpaque(false); 97 | verLabel = new GLabel(this, 500, 20, 130, 20); 98 | verLabel.setTextAlign(GAlign.LEFT, GAlign.MIDDLE); 99 | verLabel.setOpaque(false); 100 | configPanel = new GPanel(this, 12, 60, 620, 410, "Pusher Config"); 101 | configPanel.setCollapsible(false); 102 | configPanel.setDraggable(false); 103 | configPanel.setText("Pusher Config"); 104 | configPanel.setOpaque(true); 105 | configPanel.addEventHandler(this, "panel1_Click1"); 106 | label1 = new GLabel(this, 10, 30, 140, 20); 107 | label1.setTextAlign(GAlign.LEFT, GAlign.MIDDLE); 108 | label1.setText("USB Reset Holdoff (ms)"); 109 | label1.setOpaque(false); 110 | saveButton = new GButton(this, 524, 371, 80, 30); 111 | saveButton.setText("Save"); 112 | saveButton.setTextBold(); 113 | saveButton.addEventHandler(this, "saveButtonClick"); 114 | usbHoldoffSlider = new GCustomSlider(this, 160, 30, 350, 20, "grey_blue"); 115 | usbHoldoffSlider.setLimits(1020, 0, 1020); 116 | usbHoldoffSlider.setNbrTicks(255); 117 | usbHoldoffSlider.setStickToTicks(true); 118 | usbHoldoffSlider.setNumberFormat(G4P.INTEGER, 0); 119 | usbHoldoffSlider.setOpaque(false); 120 | usbHoldoffSlider.addEventHandler(this, "custom_slider1_change1"); 121 | holdoffValueLabel = new GLabel(this, 520, 30, 90, 20); 122 | holdoffValueLabel.setTextAlign(GAlign.LEFT, GAlign.MIDDLE); 123 | holdoffValueLabel.setText("1020"); 124 | holdoffValueLabel.setOpaque(false); 125 | fileselect_button1 = new GButton(this, 484, 324, 120, 30); 126 | fileselect_button1.setText("Select pixel.rc file"); 127 | fileselect_button1.addEventHandler(this, "fileselect_button1_click1"); 128 | pathLabel = new GLabel(this, 161, 329, 309, 20); 129 | pathLabel.setText("No file selected"); 130 | pathLabel.setOpaque(false); 131 | reflash_button1 = new GButton(this, 484, 276, 120, 30); 132 | reflash_button1.setText("Enter reflash mode"); 133 | reflash_button1.addEventHandler(this, "reflash_button1_click1"); 134 | reflashLabel = new GLabel(this, 161, 281, 310, 20); 135 | reflashLabel.setOpaque(false); 136 | remove_button1 = new GButton(this, 485, 227, 119, 30); 137 | remove_button1.setText("Remove pixel.rc"); 138 | remove_button1.addEventHandler(this, "remove_button1_click1"); 139 | reboot_button1 = new GButton(this, 485, 180, 120, 30); 140 | reboot_button1.setText("Reboot"); 141 | reboot_button1.addEventHandler(this, "reboot_button1_click1"); 142 | configPanel.addControl(label1); 143 | configPanel.addControl(saveButton); 144 | configPanel.addControl(usbHoldoffSlider); 145 | configPanel.addControl(holdoffValueLabel); 146 | configPanel.addControl(fileselect_button1); 147 | configPanel.addControl(pathLabel); 148 | configPanel.addControl(reflash_button1); 149 | configPanel.addControl(reflashLabel); 150 | configPanel.addControl(remove_button1); 151 | configPanel.addControl(reboot_button1); 152 | } 153 | 154 | // Variable declarations 155 | // autogenerated do not edit 156 | GButton detectBtn; 157 | GLabel portLabel; 158 | GLabel verLabel; 159 | GPanel configPanel; 160 | GLabel label1; 161 | GButton saveButton; 162 | GCustomSlider usbHoldoffSlider; 163 | GLabel holdoffValueLabel; 164 | GButton fileselect_button1; 165 | GLabel pathLabel; 166 | GButton reflash_button1; 167 | GLabel reflashLabel; 168 | GButton remove_button1; 169 | GButton reboot_button1; 170 | 171 | -------------------------------------------------------------------------------- /pixelpusher_config_tool/pixelpusher_config_tool.pde: -------------------------------------------------------------------------------- 1 | import g4p_controls.*; 2 | 3 | import processing.serial.*; 4 | import java.util.regex.Matcher; 5 | import java.util.regex.Pattern; 6 | import java.io.*; 7 | import javax.swing.*; 8 | 9 | DetectedPusher pusher = null; 10 | String filename = null; 11 | 12 | // The serial port: 13 | void setup() { 14 | size(640, 480); 15 | createGUI(); 16 | customizeGUI(); 17 | } 18 | 19 | void draw() { 20 | background(200, 220, 200); 21 | } 22 | 23 | void customizeGUI() { 24 | configPanel.setVisible(false); 25 | } 26 | -------------------------------------------------------------------------------- /pixelpusher_config_tool/serialdetect.pde: -------------------------------------------------------------------------------- 1 | class DetectedPusher { 2 | String port; 3 | String ver; 4 | 5 | DetectedPusher(String port, String ver) { 6 | this.port = port; 7 | this.ver = ver; 8 | } 9 | } 10 | 11 | void eraseConfig(DetectedPusher dp) { 12 | Serial s = new Serial(this, dp.port, 115200); 13 | 14 | try { 15 | s.write("\r\nConfig"); 16 | s.write(255); 17 | s.write(255); 18 | s.write(255); 19 | } finally { 20 | s.stop(); 21 | } 22 | } 23 | 24 | void reboot(DetectedPusher dp) { 25 | Serial s = new Serial(this, dp.port, 115200); 26 | 27 | try { 28 | s.write("\r\nReboot"); 29 | } finally { 30 | s.stop(); 31 | } 32 | } 33 | 34 | void writeConfig(DetectedPusher dp) { 35 | Serial s = new Serial(this, dp.port, 115200); 36 | s.write("\r\nHoldoff"+Integer.toString(usbHoldoffSlider.getValueI()/4, 16)); 37 | 38 | if (filename != null) { 39 | try { 40 | s.write("\r\nConfig"); 41 | BufferedReader reader = new BufferedReader(new FileReader(filename)); 42 | for (int i=0; i<1023; i++) { 43 | int c = reader.read(); 44 | if (c == -1) { 45 | s.write(255); 46 | break; 47 | } 48 | s.write(c); 49 | } 50 | } catch (FileNotFoundException fnfe) { 51 | s.write(255); // just in case 52 | } catch (IOException ioe) { 53 | s.write(255); 54 | } finally { 55 | s.stop(); 56 | } 57 | } 58 | } 59 | 60 | void enterReflash(DetectedPusher dp) { 61 | Serial s = new Serial(this, dp.port, 115200); 62 | s.write("\r\nOrange"); 63 | } 64 | 65 | DetectedPusher DetectPusher() { 66 | Serial s; 67 | char lf = '\n'; 68 | Pattern vrx = Pattern.compile("PixelPusher (.*) ready and waiting"); 69 | String pusherPort = null; 70 | String pusherVersion = null; 71 | 72 | // List all the available serial ports: 73 | for (String pn : Serial.list()) { 74 | try { 75 | //println("Attempting to detect PixelPusher on port " + pn); 76 | s = new Serial(this, pn, 115200); 77 | s.write("\r\nReboot"); 78 | s.clear(); 79 | delay(2000); 80 | while (s.available () > 0) { 81 | String r = s.readString(); 82 | if (r != null) { 83 | Matcher m = vrx.matcher(r); 84 | if (m.find()) { 85 | pusherVersion = m.group(1); 86 | pusherPort = pn; 87 | } 88 | } 89 | } 90 | s.stop(); 91 | } 92 | catch (Exception ex) { 93 | //println("Couldn't open port " + pn); 94 | } 95 | } 96 | if (pusherPort != null) { 97 | println("PixelPusher found on " + pusherPort + ". Version: " + pusherVersion); 98 | return new DetectedPusher(pusherPort, pusherVersion); 99 | } 100 | 101 | println("No PixelPusher found. Unplug, wait 5 seconds, and plug back in and try again"); 102 | return null; 103 | } 104 | 105 | -------------------------------------------------------------------------------- /pixelpusher_configurator/GUI_BUILDER_DATA/gui.ser.2.3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_configurator/GUI_BUILDER_DATA/gui.ser.2.3 -------------------------------------------------------------------------------- /pixelpusher_configurator/data/list_200593: -------------------------------------------------------------------------------- 1 | rgb 2 | rbg 3 | grb 4 | gbr 5 | brg 6 | bgr 7 | -------------------------------------------------------------------------------- /pixelpusher_configurator/data/list_369108: -------------------------------------------------------------------------------- 1 | rgb 2 | rbg 3 | grb 4 | gbr 5 | brg 6 | bgr 7 | -------------------------------------------------------------------------------- /pixelpusher_configurator/data/list_382677: -------------------------------------------------------------------------------- 1 | lpd8806 2 | lpd6803 3 | ws2801 4 | ws2811 5 | tlc59711 6 | p9813 7 | sd600a 8 | -------------------------------------------------------------------------------- /pixelpusher_configurator/data/list_439725: -------------------------------------------------------------------------------- 1 | lpd8806 2 | lpd6803 3 | ws2801 4 | ws2811 5 | tlc59711 6 | p9813 7 | sd600a 8 | -------------------------------------------------------------------------------- /pixelpusher_configurator/data/list_481405: -------------------------------------------------------------------------------- 1 | rgb 2 | rbg 3 | grb 4 | gbr 5 | brg 6 | bgr 7 | -------------------------------------------------------------------------------- /pixelpusher_configurator/data/list_531216: -------------------------------------------------------------------------------- 1 | lpd8806 2 | lpd6803 3 | ws2801 4 | ws2811 5 | tlc59711 6 | p9813 7 | sd600a 8 | -------------------------------------------------------------------------------- /pixelpusher_configurator/data/list_565113: -------------------------------------------------------------------------------- 1 | lpd8806 2 | lpd6803 3 | ws2801 4 | ws2811 5 | tlc59711 6 | p9813 7 | sd600a 8 | -------------------------------------------------------------------------------- /pixelpusher_configurator/data/list_750214: -------------------------------------------------------------------------------- 1 | lpd8806 2 | lpd6803 3 | ws2801 4 | ws2811 5 | tlc59711 6 | p9813 7 | sd600a 8 | -------------------------------------------------------------------------------- /pixelpusher_configurator/data/list_787941: -------------------------------------------------------------------------------- 1 | rgb 2 | rbg 3 | grb 4 | gbr 5 | brg 6 | bgr 7 | -------------------------------------------------------------------------------- /pixelpusher_configurator/data/list_818673: -------------------------------------------------------------------------------- 1 | rgb 2 | rbg 3 | grb 4 | gbr 5 | brg 6 | bgr 7 | -------------------------------------------------------------------------------- /pixelpusher_configurator/data/list_841569: -------------------------------------------------------------------------------- 1 | lpd8806 2 | lpd6803 3 | ws2801 4 | ws2811 5 | tlc59711 6 | p9813 7 | sd600a 8 | -------------------------------------------------------------------------------- /pixelpusher_configurator/data/list_919384: -------------------------------------------------------------------------------- 1 | rgb 2 | rbg 3 | grb 4 | gbr 5 | brg 6 | bgr 7 | -------------------------------------------------------------------------------- /pixelpusher_configurator/data/list_932479: -------------------------------------------------------------------------------- 1 | lpd8806 2 | lpd6803 3 | ws2801 4 | ws2811 5 | tlc59711 6 | p9813 7 | sd600a 8 | -------------------------------------------------------------------------------- /pixelpusher_configurator/data/list_939168: -------------------------------------------------------------------------------- 1 | rgb 2 | rbg 3 | grb 4 | gbr 5 | brg 6 | bgr 7 | -------------------------------------------------------------------------------- /pixelpusher_configurator/data/list_954858: -------------------------------------------------------------------------------- 1 | lpd8806 2 | lpd6803 3 | ws2801 4 | ws2811 5 | tlc59711 6 | p9813 7 | sd600a 8 | -------------------------------------------------------------------------------- /pixelpusher_configurator/data/list_997118: -------------------------------------------------------------------------------- 1 | rgb 2 | rbg 3 | grb 4 | gbr 5 | brg 6 | bgr 7 | -------------------------------------------------------------------------------- /pixelpusher_configurator/model.pde: -------------------------------------------------------------------------------- 1 | 2 | class ConfigModel { 3 | int group; 4 | int controller; 5 | boolean turbo_mode; 6 | int turbo_speed; 7 | int strips_attached; 8 | int pixelsperstrip; 9 | boolean blank_on_idle; 10 | int[] stripType; 11 | boolean[] swap; 12 | int[] order; 13 | int[] blank; 14 | boolean dhcp; 15 | int retries; 16 | int artnet_universe; 17 | int artnet_channel; 18 | String ether; 19 | String netmask; 20 | String gateway; 21 | 22 | String filename; 23 | 24 | private String[] stripTypes = { "lpd8806", "lpd6803", "ws2801", "ws2811", "tlc59711", "p9813", "sd600a" }; 25 | private String[] orders = {"rgb", "rbg", "grb", "gbr", "brg", "bgr" }; 26 | 27 | ConfigModel() { 28 | stripType = new int[8]; 29 | swap = new boolean[8]; 30 | 31 | blank = new int[8]; 32 | stripType = new int[8]; 33 | order = new int[8]; 34 | 35 | order[0] = order[1] = order[2] = order[3] = order[4] = order[5] = order[6] = order[7] = 1; 36 | 37 | dhcp = true; 38 | retries = 5; 39 | 40 | for (boolean swp : swap) 41 | swp = false; 42 | 43 | for (int blk : blank) 44 | blk = 0; 45 | 46 | ether = new String("192.168.1.137"); 47 | netmask = new String("255.255.255.0"); 48 | gateway = new String("192.168.1.1"); 49 | 50 | blank_on_idle = false; 51 | pixelsperstrip = 240; 52 | strips_attached = 8; 53 | } 54 | String toString() { 55 | StringBuilder s = new StringBuilder(); 56 | if (group != 0) 57 | s.append("group="+Integer.toString(group)+"\n"); 58 | if (controller != 0) 59 | s.append("controller="+Integer.toString(controller)+"\n"); 60 | if (artnet_universe != 0) 61 | s.append("artnet_universe="+Integer.toString(artnet_universe)+"\n"); 62 | if (artnet_channel != 0) 63 | s.append("artnet_channel="+Integer.toString(artnet_channel)+"\n"); 64 | 65 | 66 | if (turbo_mode) 67 | s.append("turbo_mode="+Integer.toString(turbo_speed)+"\n"); 68 | if (strips_attached != 8) 69 | s.append("strips_attached="+Integer.toString(strips_attached)+"\n"); 70 | if (pixelsperstrip != 240) 71 | s.append("pixels="+Integer.toString(pixelsperstrip)+"\n"); 72 | for (int i=0; i<8; i++) 73 | if (stripType[i]!=0) 74 | s.append("strip"+Integer.toString(i+1)+"="+stripTypes[stripType[i]]+"\n"); 75 | 76 | for (int i=0; i<8; i++) 77 | if (order[i]!=1) 78 | s.append("strip"+Integer.toString(i+1)+"="+orders[order[i]]+"\n"); 79 | 80 | for (int i=0; i<8; i++) 81 | if (blank[i]!=0) 82 | s.append("start"+Integer.toString(i+1)+"="+Integer.toString(blank[i],16)+"\n"); 83 | 84 | if (blank_on_idle) 85 | s.append("blank_strips_on_idle=1\n"); 86 | 87 | if (dhcp) { 88 | if (retries != 5) 89 | s.append("dhcp_timeout="+Integer.toString(retries)+"\n"); 90 | } else { 91 | s.append("ether="+ether+"\n"); 92 | s.append("netmask="+netmask+"\n"); 93 | s.append("gateway="+gateway+"\n"); 94 | } 95 | 96 | 97 | // this is ugly, but... 98 | boolean b=false; 99 | for (int i=0; i<8; i++) { 100 | if (swap[i]) 101 | b=true; 102 | } 103 | if (b) { 104 | s.append("swap="); 105 | for (int i=1; i<8; i++) { 106 | if (swap[i]) 107 | s.append(Integer.toString(i+1)); 108 | } 109 | s.append("\n"); 110 | } 111 | 112 | return s.toString(); 113 | } 114 | 115 | } 116 | -------------------------------------------------------------------------------- /pixelpusher_configurator/pixelpusher_configurator.pde: -------------------------------------------------------------------------------- 1 | // Need G4P library 2 | import g4p_controls.*; 3 | import java.io.*; 4 | import javax.swing.*; 5 | 6 | ConfigModel model; 7 | 8 | 9 | public void setup(){ 10 | size(800, 850, P3D); 11 | createGUI(); 12 | customGUI(); 13 | 14 | // Place your setup code here 15 | model = new ConfigModel(); 16 | 17 | } 18 | 19 | public void draw(){ 20 | background(230); 21 | } 22 | 23 | // Use this method to add additional statements 24 | // to customise the GUI controls 25 | public void customGUI(){ 26 | 27 | } 28 | -------------------------------------------------------------------------------- /pixelpusher_conways_life/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /pixelpusher_conways_life/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | pixelpusher_fftriver 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | processing.plugin.core.sketchBuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | processing.plugin.core.sketchNature 22 | 23 | 24 | -------------------------------------------------------------------------------- /pixelpusher_conways_life/observer.pde: -------------------------------------------------------------------------------- 1 | class TestObserver implements Observer { 2 | public boolean hasStrips = false; 3 | public void update(Observable registry, Object updatedDevice) { 4 | println("Registry changed!"); 5 | if (updatedDevice != null) { 6 | println("Device change: " + updatedDevice); 7 | } 8 | this.hasStrips = true; 9 | } 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /pixelpusher_conways_life/pixelpusher_conways_life.pde: -------------------------------------------------------------------------------- 1 | 2 | 3 | import com.heroicrobot.dropbit.registry.*; 4 | import com.heroicrobot.dropbit.devices.pixelpusher.Pixel; 5 | import com.heroicrobot.dropbit.devices.pixelpusher.Strip; 6 | 7 | import processing.core.*; 8 | import java.util.*; 9 | 10 | DeviceRegistry registry; 11 | 12 | int stride = 240; 13 | boolean use_weighted_get = true; 14 | 15 | boolean ready_to_go = true; 16 | 17 | int canvasW = 1280; 18 | int canvasH = 64; 19 | TestObserver testObserver; 20 | 21 | int arrayHeight = 8; 22 | int arrayWidth = 240; 23 | 24 | int[][] cells; 25 | int scaleX; 26 | int scaleY; 27 | 28 | void setup() { 29 | size(canvasW, canvasH, P3D); 30 | scaleX = width / arrayWidth; 31 | scaleY = height / arrayHeight; 32 | registry = new DeviceRegistry(); 33 | testObserver = new TestObserver(); 34 | registry.addObserver(testObserver); 35 | registry.setAntiLog(true); 36 | 37 | stroke(#000000); 38 | fill(#000000); 39 | colorMode(HSB, 100, 100, 100, 100); 40 | rectMode(CORNERS); 41 | 42 | cells = populate(); 43 | frameRate(60); 44 | background(0); 45 | } 46 | 47 | 48 | int[][] populate() { 49 | int[][] initCells = new int[arrayWidth][arrayHeight]; 50 | for (int x = 0; x < arrayWidth; x++) { 51 | for (int y = 0; y < arrayHeight; y++) { 52 | if (random(1) < .50) { 53 | initCells[x][y] = 1; 54 | } 55 | } 56 | } 57 | 58 | return initCells; 59 | } 60 | 61 | 62 | void render(int[][] cells) { 63 | //background(0); 64 | noStroke(); 65 | fill(color(0, 0, 10, 8)); 66 | rect(0, 0, width, height); 67 | for (int x = 0; x < arrayWidth; x++) { 68 | for (int y = 0; y < arrayHeight; y++) { 69 | if (cells[x][y] > 0) { 70 | fill(color(10*cells[x][y], 100, 30)); 71 | ellipseMode(CENTER); 72 | ellipse(x*(width / arrayWidth), y *(height/arrayHeight), height/arrayHeight/2, height/arrayHeight/2 ); 73 | } 74 | // else { 75 | // stroke(color(0, 0, 0, 25)); 76 | // point(x, y); 77 | // } 78 | } 79 | } 80 | } 81 | 82 | int wrapInc(int a, int maxVal) { 83 | if (a + 1 >= maxVal) { 84 | return 0; 85 | } 86 | else { 87 | return a + 1; 88 | } 89 | } 90 | 91 | int wrapDec(int a, int maxVal) { 92 | if (a - 1 < 0) { 93 | return maxVal - 1; 94 | } 95 | else { 96 | return a - 1; 97 | } 98 | } 99 | 100 | int getNeighbor(int[][] cells, int x, int y, int idx) { 101 | /* 102 | 0 3 5 103 | 1 x 6 104 | 2 4 7 105 | */ 106 | int neighborX; 107 | int neighborY; 108 | if (idx < 0 || idx > 7) { 109 | throw new RuntimeException("Neighbor index out of bounds"); 110 | } 111 | 112 | if (idx < 3) { 113 | neighborX = wrapDec(x, arrayWidth); 114 | } 115 | else if (idx >= 5) { 116 | neighborX = wrapInc(x, arrayWidth); 117 | } 118 | else { 119 | neighborX = x; 120 | } 121 | 122 | if (idx == 0 || idx == 3 || idx == 5) { 123 | neighborY = wrapDec(y, arrayHeight); 124 | } 125 | else if (idx == 2 || idx == 4 || idx == 7) { 126 | neighborY = wrapInc(y, arrayHeight); 127 | } 128 | else { 129 | neighborY = y; 130 | } 131 | 132 | return cells[neighborX][neighborY]; 133 | } 134 | 135 | int countNeighbors(int[][] cells, int x, int y) { 136 | int neighborCount = 0; 137 | for (int idx = 0; idx < 8; idx++) { 138 | if (getNeighbor(cells, x, y, idx) > 0) { 139 | neighborCount++; 140 | } 141 | } 142 | return neighborCount; 143 | } 144 | 145 | int tryBirth(int[][] cells, int x, int y) { 146 | if (countNeighbors(cells, x, y) == 3) { 147 | return 1; 148 | } 149 | else { 150 | return 0; 151 | } 152 | } 153 | 154 | int tryAge(int[][] cells, int x, int y) { 155 | if (countNeighbors(cells, x, y) == 2 || countNeighbors(cells, x, y) == 3) { 156 | return cells[x][y] + 1; 157 | } 158 | else { 159 | return 0; 160 | } 161 | } 162 | 163 | int[][] gen(int[][] cells) { 164 | int[][] nextGen = new int[arrayWidth][arrayHeight]; 165 | 166 | for (int x = 0; x < arrayWidth; x++) { 167 | for (int y = 0; y < arrayHeight; y++) { 168 | if (cells[x][y] == 0) { 169 | nextGen[x][y] = tryBirth(cells, x, y); 170 | } 171 | else { 172 | nextGen[x][y] = tryAge(cells, x, y); 173 | } 174 | } 175 | } 176 | return nextGen; 177 | } 178 | 179 | int frameIdx = 0; 180 | int genIdx = 30; 181 | void draw() { 182 | //background(0); 183 | //noStroke(); 184 | render(cells); 185 | 186 | if(frameIdx++ >= genIdx) { 187 | cells = gen(cells); 188 | frameIdx = 0; 189 | } 190 | scrape(); 191 | } 192 | 193 | 194 | boolean inBounds(int x, int y) { 195 | if (x < 0 || x >= arrayWidth || y < 0 || y >= arrayHeight) 196 | return false; 197 | return true; 198 | } 199 | 200 | void mousePressed() { 201 | int x = mouseX; 202 | int y = mouseY; 203 | if (inBounds(x/scaleX, y/scaleY)) 204 | cells[x/scaleX][y/scaleY]++; 205 | } 206 | 207 | void mouseDragged() { 208 | int x = mouseX; 209 | int y = mouseY; 210 | if (inBounds(x/scaleX, y/scaleY)) 211 | cells[x/scaleX][y/scaleY]++; 212 | } 213 | 214 | void stop() 215 | { 216 | super.stop(); 217 | } 218 | 219 | -------------------------------------------------------------------------------- /pixelpusher_conways_life/scraper.pde: -------------------------------------------------------------------------------- 1 | 2 | color weighted_get(int xpos, int ypos, int radius) { 3 | int red, green, blue; 4 | int xoffset, yoffset; 5 | int pixels_counted; 6 | 7 | color thispixel; 8 | 9 | 10 | red = green = blue = pixels_counted = 0; 11 | 12 | for (xoffset=-radius; xoffset strips = registry.getStrips(); 33 | boolean phase = false; 34 | // for every strip: 35 | int currenty = 0; 36 | int stripy = 0; 37 | for(Strip strip : strips) { 38 | int strides_per_strip = strip.getLength() / stride; 39 | 40 | int xscale = width / stride; 41 | int yscale = height / (strides_per_strip * strips.size()); 42 | 43 | // for every pixel in the physical strip 44 | for (int stripx = 0; stripx < strip.getLength(); stripx++) { 45 | int xpixel = stripx % stride; 46 | int stridenumber = stripx / stride; 47 | int xpos,ypos; 48 | 49 | if ((stridenumber & 1) == 0) { // we are going left to right 50 | xpos = xpixel * xscale; 51 | ypos = ((stripy*strides_per_strip) + stridenumber) * yscale; 52 | } else { // we are going right to left 53 | xpos = ((stride - 1)-xpixel) * xscale; 54 | ypos = ((stripy*strides_per_strip) + stridenumber) * yscale; 55 | } 56 | 57 | color c = 0; 58 | //c = weighted_get(xpos, ypos, int((xscale+yscale) / 3)); 59 | // c=weighted_get(xpos,ypos,1); 60 | c = get(xpos,ypos); 61 | strip.setPixel(c, stripx); 62 | 63 | } 64 | stripy++; 65 | } 66 | } 67 | updatePixels(); 68 | } 69 | -------------------------------------------------------------------------------- /pixelpusher_conways_life/sketch.properties: -------------------------------------------------------------------------------- 1 | mode.id=processing.mode.experimental.ExperimentalMode 2 | mode=Experimental 3 | -------------------------------------------------------------------------------- /pixelpusher_daylight_cycle/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /pixelpusher_daylight_cycle/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | pixelpusher_fftriver 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | processing.plugin.core.sketchBuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | processing.plugin.core.sketchNature 22 | 23 | 24 | -------------------------------------------------------------------------------- /pixelpusher_daylight_cycle/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /pixelpusher_daylight_cycle/observer.pde: -------------------------------------------------------------------------------- 1 | class TestObserver implements Observer { 2 | public boolean hasStrips = false; 3 | public void update(Observable registry, Object updatedDevice) { 4 | println("Registry changed!"); 5 | if (updatedDevice != null) { 6 | println("Device change: " + updatedDevice); 7 | } 8 | this.hasStrips = true; 9 | } 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /pixelpusher_daylight_cycle/pixelpusher_daylight_cycle.pde: -------------------------------------------------------------------------------- 1 | 2 | // like sands through the hourglass so are the days.. blahblah 3 | // by me 4 | 5 | 6 | import com.heroicrobot.dropbit.registry.*; 7 | import com.heroicrobot.dropbit.devices.pixelpusher.Pixel; 8 | import com.heroicrobot.dropbit.devices.pixelpusher.Strip; 9 | 10 | import processing.core.*; 11 | import java.util.*; 12 | 13 | DeviceRegistry registry; 14 | 15 | int stride = 240; 16 | boolean use_weighted_get = true; 17 | 18 | 19 | boolean ready_to_go = true; 20 | int lastPosition; 21 | int canvasW = 240; 22 | int canvasH = 240; 23 | TestObserver testObserver; 24 | 25 | int radius = 5; 26 | float theta = 3.0; 27 | int count = 0; 28 | Calendar cal; 29 | 30 | void setup() { 31 | size(canvasW, canvasH); 32 | registry = new DeviceRegistry(); 33 | testObserver = new TestObserver(); 34 | registry.addObserver(testObserver); 35 | registry.setAntiLog(true); 36 | registry.setAutoThrottle(true); 37 | frameRate(60); 38 | } 39 | 40 | 41 | color[] sky = { #000000, #000000, #5F5C83, #FF9008, #D89A7D, #FCFCF5, 42 | #FFFFFF, #FFFCE8, #FAE088, #FC0352, #5F5C83, #000000 }; 43 | 44 | float intermediate = 0; 45 | 46 | void draw() { 47 | cal = Calendar.getInstance(); 48 | cal.getTime(); 49 | 50 | count = cal.get(Calendar.HOUR_OF_DAY)/2; 51 | intermediate = cal.get(Calendar.MINUTE)/60.0; 52 | 53 | color nextColor = sky[(count+1) % sky.length]; 54 | 55 | background(lerpColor(sky[count], nextColor, intermediate)); 56 | scrape(); 57 | } 58 | 59 | 60 | -------------------------------------------------------------------------------- /pixelpusher_daylight_cycle/scraper.pde: -------------------------------------------------------------------------------- 1 | 2 | 3 | boolean first_scrape = true; 4 | void scrape() { 5 | // scrape for the strips 6 | loadPixels(); 7 | if (testObserver.hasStrips) { 8 | registry.startPushing(); 9 | List strips = registry.getStrips(); 10 | boolean phase = false; 11 | // for every strip: 12 | int currenty = 0; 13 | int stripy = 0; 14 | for(Strip strip : strips) { 15 | int strides_per_strip = strip.getLength() / stride; 16 | 17 | int xscale = width / stride; 18 | int yscale = height / (strides_per_strip * strips.size()); 19 | 20 | // for every pixel in the physical strip 21 | for (int stripx = 0; stripx < strip.getLength(); stripx++) { 22 | int xpixel = stripx % stride; 23 | int stridenumber = stripx / stride; 24 | int xpos,ypos; 25 | 26 | if ((stridenumber & 1) == 0) { // we are going left to right 27 | xpos = xpixel * xscale; 28 | ypos = ((stripy*strides_per_strip) + stridenumber) * yscale; 29 | } else { // we are going right to left 30 | xpos = ((stride - 1)-xpixel) * xscale; 31 | ypos = ((stripy*strides_per_strip) + stridenumber) * yscale; 32 | } 33 | 34 | color c = get(xpos, ypos); 35 | strip.setPixel(c, stripx); 36 | 37 | } 38 | stripy++; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /pixelpusher_daylight_cycle/sketch.properties: -------------------------------------------------------------------------------- 1 | mode.id=processing.mode.java.JavaMode 2 | mode=Java 3 | -------------------------------------------------------------------------------- /pixelpusher_example/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /pixelpusher_example/pixelpusher_example.pde: -------------------------------------------------------------------------------- 1 | 2 | import com.heroicrobot.dropbit.registry.*; 3 | import com.heroicrobot.dropbit.devices.pixelpusher.Pixel; 4 | import com.heroicrobot.dropbit.devices.pixelpusher.Strip; 5 | import java.util.*; 6 | 7 | private Random random = new Random(); 8 | 9 | DeviceRegistry registry; 10 | 11 | class TestObserver implements Observer { 12 | public boolean hasStrips = false; 13 | public void update(Observable registry, Object updatedDevice) { 14 | println("Registry changed!"); 15 | if (updatedDevice != null) { 16 | println("Device change: " + updatedDevice); 17 | } 18 | this.hasStrips = true; 19 | } 20 | } 21 | 22 | TestObserver testObserver; 23 | 24 | void setup() { 25 | size(640, 480, P2D); 26 | 27 | registry = new DeviceRegistry(); 28 | testObserver = new TestObserver(); 29 | registry.addObserver(testObserver); 30 | 31 | colorMode(RGB, 255); 32 | } 33 | 34 | void draw() { 35 | fill(0, 12); 36 | rect(0, 0, width, height); 37 | if (mouseX < width / 3) 38 | fill(255,0,0); 39 | if (mouseX > width / 3 && mouseX < (2*(width/3))) 40 | fill(0, 255, 0); 41 | if (mouseX > (2*(width/3))) 42 | fill(0,0,255); 43 | 44 | noStroke(); 45 | ellipse(mouseX, mouseY, 60, 60); 46 | 47 | if (testObserver.hasStrips) { 48 | registry.startPushing(); 49 | registry.setAutoThrottle(true); 50 | registry.setAntiLog(true); 51 | int stripy = 0; 52 | List strips = registry.getStrips(); 53 | 54 | if (strips.size() > 0) { 55 | int yscale = height / strips.size(); 56 | for(Strip strip : strips) { 57 | int xscale = width / strip.getLength(); 58 | for (int stripx = 0; stripx < strip.getLength(); stripx++) { 59 | color c = get(stripx*xscale, stripy*yscale); 60 | 61 | strip.setPixel(c, stripx); 62 | } 63 | stripy++; 64 | } 65 | } 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /pixelpusher_example/sketch.properties: -------------------------------------------------------------------------------- 1 | mode.id=processing.mode.java.JavaMode 2 | mode=Java 3 | -------------------------------------------------------------------------------- /pixelpusher_fftriver/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /pixelpusher_fftriver/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | pixelpusher_fftriver 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | processing.plugin.core.sketchBuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | processing.plugin.core.sketchNature 22 | 23 | 24 | -------------------------------------------------------------------------------- /pixelpusher_fftriver/data/0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver/data/0.png -------------------------------------------------------------------------------- /pixelpusher_fftriver/data/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver/data/1.png -------------------------------------------------------------------------------- /pixelpusher_fftriver/data/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver/data/2.png -------------------------------------------------------------------------------- /pixelpusher_fftriver/data/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver/data/3.png -------------------------------------------------------------------------------- /pixelpusher_fftriver/data/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver/data/4.png -------------------------------------------------------------------------------- /pixelpusher_fftriver/data/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver/data/5.png -------------------------------------------------------------------------------- /pixelpusher_fftriver/data/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver/data/6.png -------------------------------------------------------------------------------- /pixelpusher_fftriver/data/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver/data/7.png -------------------------------------------------------------------------------- /pixelpusher_fftriver/data/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver/data/8.png -------------------------------------------------------------------------------- /pixelpusher_fftriver/data/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver/data/9.png -------------------------------------------------------------------------------- /pixelpusher_fftriver/gui.pde: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver/gui.pde -------------------------------------------------------------------------------- /pixelpusher_fftriver/image_beat_pusher.pde: -------------------------------------------------------------------------------- 1 | class BeatListener implements AudioListener 2 | { 3 | private BeatDetect beat; 4 | private AudioInput source; 5 | 6 | BeatListener(BeatDetect beat, AudioInput source) 7 | { 8 | this.source = source; 9 | this.source.addListener(this); 10 | this.beat = beat; 11 | } 12 | 13 | void samples(float[] samps) 14 | { 15 | beat.detect(source.mix); 16 | } 17 | 18 | void samples(float[] sampsL, float[] sampsR) 19 | { 20 | beat.detect(source.mix); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /pixelpusher_fftriver/observer.pde: -------------------------------------------------------------------------------- 1 | class TestObserver implements Observer { 2 | public boolean hasStrips = false; 3 | public void update(Observable registry, Object updatedDevice) { 4 | println("Registry changed!"); 5 | if (updatedDevice != null) { 6 | println("Device change: " + updatedDevice); 7 | } 8 | this.hasStrips = true; 9 | } 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /pixelpusher_fftriver/pixelpusher_fftriver.pde: -------------------------------------------------------------------------------- 1 | // FFT for PixelPusher 2 | // by jas@heroicrobot.com 3 | // 4 | // refactored by Matt Stone 5 | // evil@heroicrobot.com 6 | // 7 | // then universally remonstered by jas again 8 | // 9 | // vaguely based on 10 | // 11 | // Fancy FFT of the song 12 | // Erin K 09/20/08 13 | // RobotGrrl.com 14 | // ------------------------ 15 | // Based off the code by Tom Gerhardt 16 | // thomas-gerhardt.com 17 | 18 | import com.heroicrobot.dropbit.registry.*; 19 | import com.heroicrobot.dropbit.devices.pixelpusher.Pixel; 20 | import com.heroicrobot.dropbit.devices.pixelpusher.Strip; 21 | import javax.sound.sampled.*; 22 | 23 | import java.awt.Frame; 24 | import java.awt.BorderLayout; 25 | 26 | import processing.core.*; 27 | import ddf.minim.analysis.*; 28 | import ddf.minim.*; 29 | import controlP5.*; 30 | import java.util.*; 31 | 32 | DeviceRegistry registry; 33 | 34 | AudioInput jingle; 35 | FFT fftLog; 36 | Minim minim; 37 | PImage osb; 38 | 39 | boolean ready_to_go = false; 40 | int lastPosition; 41 | int canvasW = 48 * 5; 42 | int canvasH = 240 * 4; 43 | int baseLine = 700; 44 | int sampleCount = 0; 45 | int spriteW = canvasW; 46 | int spriteH = canvasW; 47 | int scrollAmount = 4; 48 | float specScale = 4.0; 49 | 50 | float lowest = 255.0; 51 | float highest = 0.0; 52 | 53 | TestObserver testObserver; 54 | ControlP5 gui; 55 | ControlFrame controlwindow; 56 | 57 | // Images 58 | int numSprites = 10; 59 | PImage[] sprites; 60 | 61 | BeatListener beatListener; 62 | BeatDetect beatDetector; 63 | 64 | ControlFrame addControlFrame(String theName, int theWidth, int theHeight) { 65 | Frame f = new Frame(theName); 66 | ControlFrame p = new ControlFrame(this, theWidth, theHeight); 67 | f.add(p); 68 | p.init(); 69 | f.setTitle(theName); 70 | f.setSize(p.w, p.h); 71 | f.setLocation(100, 100); 72 | f.setResizable(false); 73 | f.setVisible(true); 74 | return p; 75 | } 76 | 77 | 78 | // an array of info objects describing all of 79 | // the mixers the AudioSystem has. we'll use 80 | // this to populate our gui scroll list and 81 | // also to obtain an actual Mixer when the 82 | // user clicks on an item in the list. 83 | Mixer.Info[] mixerInfo; 84 | 85 | public class ControlFrame extends PApplet { 86 | 87 | int w, h; 88 | 89 | int abc = 100; 90 | 91 | public void controlEvent(ControlEvent theEvent) { 92 | ready_to_go = false; 93 | int mixerIndex = (int)theEvent.controller().value(); 94 | 95 | println("User chose " + theEvent.controller().label()); 96 | println("Using mixer info " + mixerInfo[mixerIndex].getName()); 97 | 98 | Mixer mixer = AudioSystem.getMixer(mixerInfo[mixerIndex]); 99 | 100 | if ( jingle != null ) 101 | { 102 | jingle.close(); 103 | minim.stop(); 104 | minim=new Minim(this); 105 | } 106 | 107 | minim.setInputMixer(mixer); 108 | println("Set input mixer."); 109 | 110 | jingle = minim.getLineIn(Minim.STEREO, 512, 44100, 16); 111 | fftLog = new FFT(jingle.bufferSize(), jingle.sampleRate()); 112 | beatDetector = new BeatDetect(jingle.bufferSize(), jingle.sampleRate()); 113 | beatDetector.setSensitivity(3000); 114 | beatListener = new BeatListener(beatDetector, jingle); 115 | fftLog.window(FFT.HAMMING); 116 | println("Started FFT."); 117 | ready_to_go = true; 118 | } 119 | 120 | 121 | public void setup() { 122 | size(w, h); 123 | frameRate(30); 124 | mixerInfo = AudioSystem.getMixerInfo(); 125 | gui = new ControlP5(this); 126 | for (int i = 0; i < mixerInfo.length; i++) 127 | { 128 | controlP5.Button b = gui.addButton("item"+i, i); 129 | b.setLabel(mixerInfo[i].getName()); 130 | b.setPosition(5, i*20); 131 | b.setSize(480, 19); 132 | } 133 | } 134 | 135 | public void draw() { 136 | background(abc); 137 | } 138 | 139 | private ControlFrame() { 140 | } 141 | 142 | public ControlFrame(Object theParent, int theWidth, int theHeight) { 143 | parent = theParent; 144 | w = theWidth; 145 | h = theHeight; 146 | } 147 | 148 | 149 | public ControlP5 control() { 150 | return cp5; 151 | } 152 | 153 | 154 | ControlP5 cp5; 155 | Object parent; 156 | } 157 | 158 | 159 | void setup() { 160 | size(canvasW, canvasH); 161 | registry = new DeviceRegistry(); 162 | testObserver = new TestObserver(); 163 | registry.addObserver(testObserver); 164 | background(0); 165 | sprites = new PImage[numSprites]; 166 | for (int i = 0; i < sprites.length; i++) { 167 | sprites[i] = loadImage(str(i) + ".png"); 168 | } 169 | 170 | //size(640, 480); 171 | 172 | minim = new Minim(this); 173 | controlwindow = addControlFrame("controlwindow", 480, 280); 174 | } 175 | 176 | 177 | 178 | 179 | void draw() { 180 | 181 | if (ready_to_go) { 182 | fftLog.forward(jingle.mix); 183 | float xdispscale = ((float)width / (float)(fftLog.specSize()/specScale)); 184 | //ellipseMode(CENTER); 185 | noSmooth(); 186 | noStroke(); 187 | colorMode(HSB, 255); 188 | fill(color(0, 0, 0, 1)); 189 | rectMode(CORNER); 190 | rect(0, 0, width, height); 191 | 192 | double tics_per_sample = 255.0 / (double) (fftLog.specSize()/specScale); 193 | 194 | 195 | for (int i = 0; i < (fftLog.specSize()/specScale); i++) { 196 | 197 | float amp = (float)Math.log10((fftLog.getBand(i)*3000.0)); 198 | 199 | if (amp < 0) 200 | amp = lowest; 201 | 202 | lowest = (amp < lowest) ? amp : lowest; 203 | highest = (amp > highest) ? amp : highest; 204 | 205 | 206 | 207 | float h = (float)(i * tics_per_sample); 208 | float s = 255; 209 | float b = map(amp, lowest, highest, 0.0, 255.0); 210 | //float a = amp; 211 | // println(lowest+" : "+ highest+" : "+ amp +" : "+ b); 212 | 213 | float xpos = xdispscale * i; 214 | fill(color(h, s, b, 255)); 215 | rect(xpos, height-(scrollAmount+1), xdispscale, (float) scrollAmount+1); 216 | } 217 | 218 | // scroll the window downwards a little. 219 | osb = get(); 220 | set(0, -scrollAmount, osb); 221 | 222 | if (beatDetector != null) { 223 | if (beatDetector.isKick()) { 224 | tint(0, 255, 255); 225 | image(sprites[int(random(0, numSprites))], random(0, canvasW - spriteW), canvasH - spriteH, spriteW, spriteH); 226 | } 227 | if (beatDetector.isHat()) { 228 | tint(64, 255, 255); 229 | image(sprites[int(random(0, numSprites))], random(0, canvasW - spriteW), canvasH - spriteH, spriteW, spriteH); 230 | } 231 | if (beatDetector.isSnare()) { 232 | tint(124, 255, 255); 233 | image(sprites[int(random(0, numSprites))], random(0, canvasW - spriteW), canvasH - spriteH, spriteW, spriteH); 234 | } 235 | } 236 | scrape(); 237 | } 238 | } 239 | 240 | void stop() 241 | { 242 | jingle.close(); 243 | super.stop(); 244 | } 245 | 246 | -------------------------------------------------------------------------------- /pixelpusher_fftriver/scraper.pde: -------------------------------------------------------------------------------- 1 | void scrape() { 2 | // scrape for the strips 3 | loadPixels(); 4 | if (testObserver.hasStrips) { 5 | registry.startPushing(); 6 | List strips = registry.getStrips(); 7 | 8 | // our array is tall and narrow, so let's rotate this 90 degrees. 9 | // we can assume they're all the same length. 10 | 11 | // yscale = how many pixels of y == one led pixel. 12 | // xscale = how many pixels of x == one led strip. 13 | int yscale = height / strips.get(0).getLength(); 14 | int xscale = width / strips.size(); 15 | 16 | // for each strip (x-direction) 17 | int stripx = 0; 18 | for (Strip strip : strips) { 19 | for (int stripy = 0; stripy < strip.getLength(); stripy++) { 20 | color c = pixels[(stripx*xscale) + (stripy*yscale*width)]; 21 | Pixel p = new Pixel((byte)red(c), (byte)green(c), (byte)blue(c)); 22 | //Pixel p = new Pixel((byte)255, (byte)255, (byte)255); 23 | strip.setPixel(p, stripy); 24 | } 25 | stripx++; 26 | } 27 | } 28 | updatePixels(); 29 | } 30 | -------------------------------------------------------------------------------- /pixelpusher_fftriver_liveperformance/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /pixelpusher_fftriver_liveperformance/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | pixelpusher_fftriver 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | processing.plugin.core.sketchBuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | processing.plugin.core.sketchNature 22 | 23 | 24 | -------------------------------------------------------------------------------- /pixelpusher_fftriver_liveperformance/data/0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_liveperformance/data/0.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_liveperformance/data/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_liveperformance/data/1.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_liveperformance/data/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_liveperformance/data/2.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_liveperformance/data/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_liveperformance/data/3.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_liveperformance/data/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_liveperformance/data/4.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_liveperformance/data/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_liveperformance/data/5.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_liveperformance/data/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_liveperformance/data/6.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_liveperformance/data/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_liveperformance/data/7.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_liveperformance/data/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_liveperformance/data/8.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_liveperformance/data/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_liveperformance/data/9.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_liveperformance/data/a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_liveperformance/data/a.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_liveperformance/data/d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_liveperformance/data/d.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_liveperformance/data/e.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_liveperformance/data/e.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_liveperformance/data/f.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_liveperformance/data/f.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_liveperformance/data/g.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_liveperformance/data/g.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_liveperformance/data/q.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_liveperformance/data/q.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_liveperformance/data/r.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_liveperformance/data/r.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_liveperformance/data/s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_liveperformance/data/s.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_liveperformance/data/t.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_liveperformance/data/t.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_liveperformance/data/u.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_liveperformance/data/u.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_liveperformance/data/w.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_liveperformance/data/w.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_liveperformance/data/y.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_liveperformance/data/y.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_liveperformance/gui.pde: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /pixelpusher_fftriver_liveperformance/image_beat_pusher.pde: -------------------------------------------------------------------------------- 1 | class BeatListener implements AudioListener 2 | { 3 | private BeatDetect beat; 4 | private AudioInput source; 5 | 6 | BeatListener(BeatDetect beat, AudioInput source) 7 | { 8 | this.source = source; 9 | this.source.addListener(this); 10 | this.beat = beat; 11 | } 12 | 13 | void samples(float[] samps) 14 | { 15 | beat.detect(source.mix); 16 | } 17 | 18 | void samples(float[] sampsL, float[] sampsR) 19 | { 20 | beat.detect(source.mix); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /pixelpusher_fftriver_liveperformance/observer.pde: -------------------------------------------------------------------------------- 1 | class TestObserver implements Observer { 2 | public boolean hasStrips = false; 3 | public void update(Observable registry, Object updatedDevice) { 4 | println("Registry changed!"); 5 | if (updatedDevice != null) { 6 | println("Device change: " + updatedDevice); 7 | } 8 | this.hasStrips = true; 9 | } 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /pixelpusher_fftriver_liveperformance/pixelpusher_fftriver_mattshacks_bak.pde: -------------------------------------------------------------------------------- 1 | // FFT for PixelPusher 2 | // by jas@heroicrobot.com 3 | // 4 | // refactored by Matt Stone 5 | // evil@heroicrobot.com 6 | // 7 | // then universally remonstered by jas again 8 | // 9 | // vaguely based on 10 | // 11 | // Fancy FFT of the song 12 | // Erin K 09/20/08 13 | // RobotGrrl.com 14 | // ------------------------ 15 | // Based off the code by Tom Gerhardt 16 | // thomas-gerhardt.com 17 | 18 | import hypermedia.net.*; 19 | import com.heroicrobot.dropbit.registry.*; 20 | import com.heroicrobot.dropbit.devices.pixelpusher.Pixel; 21 | import com.heroicrobot.dropbit.devices.pixelpusher.Strip; 22 | import javax.sound.sampled.*; 23 | 24 | import java.awt.Frame; 25 | import java.awt.BorderLayout; 26 | 27 | import processing.core.*; 28 | import ddf.minim.analysis.*; 29 | import ddf.minim.*; 30 | import controlP5.*; 31 | import java.util.*; 32 | 33 | DeviceRegistry registry; 34 | 35 | AudioInput jingle; 36 | FFT fftLog; 37 | Minim minim; 38 | PImage osb; 39 | 40 | boolean ready_to_go = false; 41 | int lastPosition; 42 | int canvasW = 48 * 5; 43 | int canvasH = 240 * 4; 44 | int baseLine = 700; 45 | int sampleCount = 0; 46 | int spriteW = canvasW-10; 47 | int spriteH = canvasW-10; 48 | int scrollAmount = 4; 49 | float specScale = 4.0; 50 | 51 | float lowest = 255.0; 52 | float highest = 0.0; 53 | 54 | TestObserver testObserver; 55 | ControlP5 gui; 56 | ControlFrame controlwindow; 57 | 58 | // Images 59 | int numSprites = 10; 60 | PImage[] sprites; 61 | 62 | BeatListener beatListener; 63 | BeatDetect beatDetector; 64 | boolean useBeats; 65 | boolean useFft; 66 | boolean fftAtTop; 67 | boolean randomPixels; 68 | boolean useCircles; 69 | int randomPixelColor; 70 | boolean useRandomPixelColor; 71 | int loadSprite; 72 | char spriteName; 73 | int rot; 74 | 75 | HashMap spriteMap; 76 | 77 | ControlFrame addControlFrame(String theName, int theWidth, int theHeight) { 78 | Frame f = new Frame(theName); 79 | ControlFrame p = new ControlFrame(this, theWidth, theHeight); 80 | f.add(p); 81 | p.init(); 82 | f.setTitle(theName); 83 | f.setSize(p.w, p.h); 84 | f.setLocation(100, 100); 85 | f.setResizable(false); 86 | f.setVisible(true); 87 | return p; 88 | } 89 | 90 | 91 | // an array of info objects describing all of 92 | // the mixers the AudioSystem has. we'll use 93 | // this to populate our gui scroll list and 94 | // also to obtain an actual Mixer when the 95 | // user clicks on an item in the list. 96 | Mixer.Info[] mixerInfo; 97 | 98 | public class ControlFrame extends PApplet { 99 | 100 | int w, h; 101 | 102 | int abc = 100; 103 | 104 | public void controlEvent(ControlEvent theEvent) { 105 | ready_to_go = false; 106 | int mixerIndex = (int)theEvent.controller().value(); 107 | 108 | println("User chose " + theEvent.controller().label()); 109 | println("Using mixer info " + mixerInfo[mixerIndex].getName()); 110 | 111 | Mixer mixer = AudioSystem.getMixer(mixerInfo[mixerIndex]); 112 | 113 | if ( jingle != null ) 114 | { 115 | jingle.close(); 116 | minim.stop(); 117 | minim=new Minim(this); 118 | } 119 | 120 | minim.setInputMixer(mixer); 121 | println("Set input mixer."); 122 | 123 | jingle = minim.getLineIn(Minim.STEREO, 512, 44100, 16); 124 | fftLog = new FFT(jingle.bufferSize(), jingle.sampleRate()); 125 | beatDetector = new BeatDetect(jingle.bufferSize(), jingle.sampleRate()); 126 | beatDetector.setSensitivity(3000); 127 | beatListener = new BeatListener(beatDetector, jingle); 128 | fftLog.window(FFT.HAMMING); 129 | println("Started FFT."); 130 | ready_to_go = true; 131 | } 132 | 133 | 134 | public void setup() { 135 | size(w, h); 136 | frameRate(30); 137 | mixerInfo = AudioSystem.getMixerInfo(); 138 | gui = new ControlP5(this); 139 | for (int i = 0; i < mixerInfo.length; i++) 140 | { 141 | controlP5.Button b = gui.addButton("item"+i, i); 142 | b.setLabel(mixerInfo[i].getName()); 143 | b.setPosition(5, i*20); 144 | b.setSize(480, 19); 145 | } 146 | } 147 | 148 | public void draw() { 149 | background(abc); 150 | } 151 | 152 | private ControlFrame() { 153 | } 154 | 155 | public ControlFrame(Object theParent, int theWidth, int theHeight) { 156 | parent = theParent; 157 | w = theWidth; 158 | h = theHeight; 159 | } 160 | 161 | 162 | public ControlP5 control() { 163 | return cp5; 164 | } 165 | 166 | 167 | ControlP5 cp5; 168 | Object parent; 169 | } 170 | 171 | 172 | void setup() { 173 | size(canvasW, canvasH); 174 | registry = new DeviceRegistry(); 175 | testObserver = new TestObserver(); 176 | registry.addObserver(testObserver); 177 | background(0); 178 | sprites = new PImage[numSprites]; 179 | for (int i = 0; i < sprites.length; i++) { 180 | sprites[i] = loadImage(str(i) + ".png"); 181 | } 182 | 183 | //size(640, 480); 184 | useFft = true; 185 | fftAtTop = false; 186 | randomPixels = false; 187 | useCircles = false; 188 | randomPixelColor = 0; 189 | useRandomPixelColor = false; 190 | spriteName = ' '; 191 | spriteMap = new HashMap(); 192 | rot = 0; 193 | minim = new Minim(this); 194 | controlwindow = addControlFrame("controlwindow", 480, 280); 195 | } 196 | 197 | 198 | 199 | 200 | void draw() { 201 | 202 | if (ready_to_go) { 203 | fftLog.forward(jingle.mix); 204 | float xdispscale = ((float)width / (float)(fftLog.specSize()/specScale)); 205 | //ellipseMode(CENTER); 206 | noSmooth(); 207 | noStroke(); 208 | colorMode(HSB, 255); 209 | fill(color(0, 0, 0, 1)); 210 | rectMode(CORNER); 211 | rect(0, 0, width, height); 212 | 213 | double tics_per_sample = 255.0 / (double) (fftLog.specSize()/specScale); 214 | 215 | float h, s, b, amp; 216 | 217 | rot++; 218 | /** 219 | if (rot > 254) 220 | rot = 0; 221 | **/ 222 | if (useFft) { 223 | for (int i = 0; i < (fftLog.specSize()/specScale); i++) { 224 | 225 | amp = (float)Math.log10((fftLog.getBand(i))*50.0); 226 | 227 | if (amp < 0) 228 | amp = lowest; 229 | 230 | lowest = (amp < lowest) ? amp : lowest; 231 | highest = (amp > highest) ? amp : highest; 232 | 233 | 234 | 235 | h = ((float)(i * tics_per_sample) + rot) % 255; 236 | //println(h); 237 | s = 255; 238 | b = map(amp, lowest, highest, 0.0, 255.0); 239 | //float a = amp; 240 | // println(lowest+" : "+ highest+" : "+ amp +" : "+ b); 241 | 242 | float xpos = xdispscale * i; 243 | fill(color(h, s, b, 255)); 244 | if (scrollAmount > 0) { 245 | rect(xpos, height-(scrollAmount+1), xdispscale, (float) scrollAmount+1); 246 | } else { 247 | rect(xpos, 2, xdispscale, (float) scrollAmount+1); 248 | } 249 | } 250 | } 251 | // scroll the window downwards a little. 252 | osb = get(); 253 | set(0, -scrollAmount, osb); 254 | if (useBeats) { 255 | if (beatDetector != null) { 256 | if (beatDetector.isKick()) { 257 | tint(0, 255, 255); 258 | image(sprites[int(random(0, numSprites))], random(0, canvasW - spriteW), canvasH - spriteH, spriteW, spriteH); 259 | } 260 | if (beatDetector.isHat()) { 261 | tint(64, 255, 255); 262 | image(sprites[int(random(0, numSprites))], random(0, canvasW - spriteW), canvasH - spriteH, spriteW, spriteH); 263 | } 264 | if (beatDetector.isSnare()) { 265 | tint(124, 255, 255); 266 | image(sprites[int(random(0, numSprites))], random(0, canvasW - spriteW), canvasH - spriteH, spriteW, spriteH); 267 | } 268 | } 269 | } 270 | if (spriteName != ' ') { 271 | try { 272 | //tint(0, 255, 255); 273 | noTint(); 274 | if (!spriteMap.containsKey("" + spriteName)) 275 | spriteMap.put("" + spriteName, loadImage("" + spriteName + ".png")); 276 | if (scrollAmount < 0) { 277 | image(spriteMap.get("" + spriteName), random(0, canvasW - spriteW), 0, spriteW, spriteH); 278 | } else { 279 | image(spriteMap.get("" + spriteName), random(0, canvasW - spriteW), canvasH - spriteH, spriteW, spriteH); 280 | } 281 | } 282 | catch (Exception e) { 283 | // foo 284 | } 285 | spriteName = ' '; 286 | } 287 | if (randomPixels) { 288 | if (useRandomPixelColor) { 289 | fill(color(randomPixelColor % 255, 255, 255, 255)); 290 | //println(randomPixelColor % 255); 291 | } 292 | else { 293 | fill(color(random(0, 255), 255, 255, 255)); 294 | } 295 | if(useCircles) { 296 | ellipse(random(0, width), random(0, height), random(0, 40), random(0, 40)); 297 | } else { 298 | rect(random(0, width), random(0, height), random(0, 40), random(0, 40)); 299 | } 300 | } 301 | scrape(); 302 | } 303 | } 304 | 305 | void stop() 306 | { 307 | jingle.close(); 308 | super.stop(); 309 | } 310 | 311 | void keyTyped() { 312 | if (key == 'b') { 313 | useBeats = !useBeats; 314 | return; 315 | } 316 | if (key == 'v') { 317 | useFft = !useFft; 318 | return; 319 | } 320 | if (key == 'c') { 321 | fftAtTop = !fftAtTop; 322 | return; 323 | } 324 | if (key == 'n') { 325 | scrollAmount = -scrollAmount; 326 | return; 327 | } 328 | if (key == ',') { 329 | scrollAmount--; 330 | return; 331 | } 332 | if (key == '.') { 333 | scrollAmount++; 334 | return; 335 | } 336 | if (key == 'x') { 337 | randomPixels = !randomPixels; 338 | return; 339 | } 340 | if (key == '=') { 341 | useCircles = !useCircles; 342 | return; 343 | } 344 | if (key == 'z') { 345 | useRandomPixelColor = !useRandomPixelColor; 346 | return; 347 | } 348 | if (key == 'k') { 349 | randomPixelColor--; 350 | return; 351 | } 352 | if (key == 'l') { 353 | randomPixelColor++; 354 | return; 355 | } 356 | if (key == '[') { 357 | randomPixelColor = randomPixelColor + 10; 358 | return; 359 | } 360 | if (key == ']') { 361 | randomPixelColor = randomPixelColor - 10; 362 | return; 363 | } 364 | if (key == '/') { 365 | fill(color(0, 0, 0, 255)); 366 | rect(0, 0, canvasW, canvasH); 367 | return; 368 | } 369 | spriteName = key; 370 | } 371 | -------------------------------------------------------------------------------- /pixelpusher_fftriver_liveperformance/scraper.pde: -------------------------------------------------------------------------------- 1 | void scrape() { 2 | // scrape for the strips 3 | loadPixels(); 4 | if (testObserver.hasStrips) { 5 | registry.startPushing(); 6 | List strips = registry.getStrips(); 7 | 8 | // our array is tall and narrow, so let's rotate this 90 degrees. 9 | // we can assume they're all the same length. 10 | 11 | // yscale = how many pixels of y == one led pixel. 12 | // xscale = how many pixels of x == one led strip. 13 | int yscale = height / strips.get(0).getLength(); 14 | int xscale = width / strips.size(); 15 | 16 | // for each strip (x-direction) 17 | int stripx = 0; 18 | for (Strip strip : strips) { 19 | for (int stripy = 0; stripy < strip.getLength(); stripy++) { 20 | color c = pixels[((strips.size() - (stripx + 1))*xscale) + (stripy*yscale*width)]; 21 | Pixel p = new Pixel((byte)red(c), (byte)green(c), (byte)blue(c)); 22 | //Pixel p = new Pixel((byte)255, (byte)255, (byte)255); 23 | strip.setPixel(p, stripy); 24 | } 25 | stripx++; 26 | } 27 | } 28 | updatePixels(); 29 | } 30 | -------------------------------------------------------------------------------- /pixelpusher_fftriver_webcam/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /pixelpusher_fftriver_webcam/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | pixelpusher_fftriver 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | processing.plugin.core.sketchBuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | processing.plugin.core.sketchNature 22 | 23 | 24 | -------------------------------------------------------------------------------- /pixelpusher_fftriver_webcam/data/0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_webcam/data/0.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_webcam/data/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_webcam/data/1.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_webcam/data/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_webcam/data/2.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_webcam/data/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_webcam/data/3.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_webcam/data/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_webcam/data/4.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_webcam/data/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_webcam/data/5.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_webcam/data/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_webcam/data/6.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_webcam/data/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_webcam/data/7.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_webcam/data/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_webcam/data/8.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_webcam/data/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_webcam/data/9.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_webcam/data/a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_webcam/data/a.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_webcam/data/d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_webcam/data/d.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_webcam/data/e.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_webcam/data/e.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_webcam/data/f.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_webcam/data/f.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_webcam/data/g.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_webcam/data/g.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_webcam/data/q.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_webcam/data/q.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_webcam/data/r.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_webcam/data/r.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_webcam/data/s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_webcam/data/s.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_webcam/data/t.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_webcam/data/t.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_webcam/data/u.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_webcam/data/u.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_webcam/data/w.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_webcam/data/w.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_webcam/data/y.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_fftriver_webcam/data/y.png -------------------------------------------------------------------------------- /pixelpusher_fftriver_webcam/gui.pde: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /pixelpusher_fftriver_webcam/image_beat_pusher.pde: -------------------------------------------------------------------------------- 1 | class BeatListener implements AudioListener 2 | { 3 | private BeatDetect beat; 4 | private AudioInput source; 5 | 6 | BeatListener(BeatDetect beat, AudioInput source) 7 | { 8 | this.source = source; 9 | this.source.addListener(this); 10 | this.beat = beat; 11 | } 12 | 13 | void samples(float[] samps) 14 | { 15 | beat.detect(source.mix); 16 | } 17 | 18 | void samples(float[] sampsL, float[] sampsR) 19 | { 20 | beat.detect(source.mix); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /pixelpusher_fftriver_webcam/observer.pde: -------------------------------------------------------------------------------- 1 | class TestObserver implements Observer { 2 | public boolean hasStrips = false; 3 | public void update(Observable registry, Object updatedDevice) { 4 | println("Registry changed!"); 5 | if (updatedDevice != null) { 6 | println("Device change: " + updatedDevice); 7 | } 8 | this.hasStrips = true; 9 | } 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /pixelpusher_fftriver_webcam/pixelpusher_fftriver_webcam.pde: -------------------------------------------------------------------------------- 1 | // FFT for PixelPusher 2 | // by jas@heroicrobot.com 3 | // 4 | // refactored by Matt Stone 5 | // evil@heroicrobot.com 6 | // 7 | // then universally remonstered by jas again 8 | // 9 | // vaguely based on 10 | // 11 | // Fancy FFT of the song 12 | // Erin K 09/20/08 13 | // RobotGrrl.com 14 | // ------------------------ 15 | // Based off the code by Tom Gerhardt 16 | // thomas-gerhardt.com 17 | 18 | import com.heroicrobot.dropbit.registry.*; 19 | import com.heroicrobot.dropbit.devices.pixelpusher.Pixel; 20 | import com.heroicrobot.dropbit.devices.pixelpusher.Strip; 21 | import javax.sound.sampled.*; 22 | 23 | import java.awt.Frame; 24 | import java.awt.BorderLayout; 25 | 26 | import processing.core.*; 27 | import processing.video.*; 28 | import ddf.minim.analysis.*; 29 | import ddf.minim.*; 30 | import controlP5.*; 31 | import java.util.*; 32 | 33 | DeviceRegistry registry; 34 | 35 | AudioInput jingle; 36 | FFT fftLog; 37 | Minim minim; 38 | PImage osb; 39 | 40 | boolean ready_to_go = false; 41 | int lastPosition; 42 | int canvasW = 48 * 5; 43 | int canvasH = 240 * 4; 44 | int baseLine = 700; 45 | int sampleCount = 0; 46 | int spriteW = canvasW-10; 47 | int spriteH = canvasW-10; 48 | int scrollAmount = 4; 49 | float specScale = 4.0; 50 | 51 | float lowest = 255.0; 52 | float highest = 0.0; 53 | 54 | TestObserver testObserver; 55 | ControlP5 gui; 56 | ControlFrame controlwindow; 57 | 58 | // Images 59 | int numSprites = 10; 60 | PImage[] sprites; 61 | 62 | BeatListener beatListener; 63 | BeatDetect beatDetector; 64 | boolean useBeats; 65 | int loadSprite; 66 | char spriteName; 67 | 68 | Capture cam; 69 | 70 | ControlFrame addControlFrame(String theName, int theWidth, int theHeight) { 71 | Frame f = new Frame(theName); 72 | ControlFrame p = new ControlFrame(this, theWidth, theHeight); 73 | f.add(p); 74 | p.init(); 75 | f.setTitle(theName); 76 | f.setSize(p.w, p.h); 77 | f.setLocation(100, 100); 78 | f.setResizable(false); 79 | f.setVisible(true); 80 | return p; 81 | } 82 | 83 | 84 | // an array of info objects describing all of 85 | // the mixers the AudioSystem has. we'll use 86 | // this to populate our gui scroll list and 87 | // also to obtain an actual Mixer when the 88 | // user clicks on an item in the list. 89 | Mixer.Info[] mixerInfo; 90 | 91 | public class ControlFrame extends PApplet { 92 | 93 | int w, h; 94 | 95 | int abc = 100; 96 | 97 | public void controlEvent(ControlEvent theEvent) { 98 | ready_to_go = false; 99 | int mixerIndex = (int)theEvent.controller().value(); 100 | 101 | println("User chose " + theEvent.controller().label()); 102 | println("Using mixer info " + mixerInfo[mixerIndex].getName()); 103 | 104 | Mixer mixer = AudioSystem.getMixer(mixerInfo[mixerIndex]); 105 | 106 | if ( jingle != null ) 107 | { 108 | jingle.close(); 109 | minim.stop(); 110 | minim=new Minim(this); 111 | } 112 | 113 | minim.setInputMixer(mixer); 114 | println("Set input mixer."); 115 | 116 | jingle = minim.getLineIn(Minim.STEREO, 512, 44100, 16); 117 | fftLog = new FFT(jingle.bufferSize(), jingle.sampleRate()); 118 | beatDetector = new BeatDetect(jingle.bufferSize(), jingle.sampleRate()); 119 | beatDetector.setSensitivity(3000); 120 | beatListener = new BeatListener(beatDetector, jingle); 121 | fftLog.window(FFT.HAMMING); 122 | println("Started FFT."); 123 | ready_to_go = true; 124 | } 125 | 126 | 127 | public void setup() { 128 | size(w, h); 129 | frameRate(30); 130 | mixerInfo = AudioSystem.getMixerInfo(); 131 | gui = new ControlP5(this); 132 | for (int i = 0; i < mixerInfo.length; i++) 133 | { 134 | controlP5.Button b = gui.addButton("item"+i, i); 135 | b.setLabel(mixerInfo[i].getName()); 136 | b.setPosition(5, i*20); 137 | b.setSize(480, 19); 138 | } 139 | } 140 | 141 | public void draw() { 142 | background(abc); 143 | } 144 | 145 | private ControlFrame() { 146 | } 147 | 148 | public ControlFrame(Object theParent, int theWidth, int theHeight) { 149 | parent = theParent; 150 | w = theWidth; 151 | h = theHeight; 152 | } 153 | 154 | 155 | public ControlP5 control() { 156 | return cp5; 157 | } 158 | 159 | 160 | ControlP5 cp5; 161 | Object parent; 162 | } 163 | 164 | 165 | void setup() { 166 | size(canvasW, canvasH); 167 | registry = new DeviceRegistry(); 168 | testObserver = new TestObserver(); 169 | registry.addObserver(testObserver); 170 | background(0); 171 | sprites = new PImage[numSprites]; 172 | for (int i = 0; i < sprites.length; i++) { 173 | sprites[i] = loadImage(str(i) + ".png"); 174 | } 175 | 176 | //size(640, 480); 177 | spriteName = ' '; 178 | minim = new Minim(this); 179 | controlwindow = addControlFrame("controlwindow", 480, 280); 180 | String[] cameras = Capture.list(); 181 | 182 | if (cameras.length == 0) { 183 | println("There are no cameras available for capture."); 184 | exit(); 185 | } else { 186 | println("Available cameras:"); 187 | for (int i = 0; i < cameras.length; i++) { 188 | println(cameras[i]); 189 | } 190 | 191 | // The camera can be initialized directly using an 192 | // element from the array returned by list(): 193 | cam = new Capture(this, cameras[12]); 194 | cam.start(); 195 | } 196 | } 197 | 198 | 199 | 200 | 201 | void draw() { 202 | 203 | if (ready_to_go) { 204 | fftLog.forward(jingle.mix); 205 | float xdispscale = ((float)width / (float)(fftLog.specSize()/specScale)); 206 | //ellipseMode(CENTER); 207 | noSmooth(); 208 | noStroke(); 209 | colorMode(HSB, 255); 210 | fill(color(0, 0, 0, 1)); 211 | rectMode(CORNER); 212 | rect(0, 0, width, height); 213 | 214 | double tics_per_sample = 255.0 / (double) (fftLog.specSize()/specScale); 215 | 216 | 217 | for (int i = 0; i < (fftLog.specSize()/specScale); i++) { 218 | 219 | float amp = (float)Math.log10((fftLog.getBand(i))*50.0); 220 | 221 | if (amp < 0) 222 | amp = lowest; 223 | 224 | lowest = (amp < lowest) ? amp : lowest; 225 | highest = (amp > highest) ? amp : highest; 226 | 227 | 228 | 229 | float h = (float)(i * tics_per_sample); 230 | float s = 255; 231 | float b = map(amp, lowest, highest, 0.0, 255.0); 232 | //float a = amp; 233 | // println(lowest+" : "+ highest+" : "+ amp +" : "+ b); 234 | 235 | float xpos = xdispscale * i; 236 | fill(color(h, s, b, 255)); 237 | rect(xpos, height-(scrollAmount+1), xdispscale, (float) scrollAmount+1); 238 | } 239 | 240 | // scroll the window downwards a little. 241 | osb = get(); 242 | set(0, -scrollAmount, osb); 243 | if (useBeats) { 244 | if (beatDetector != null) { 245 | if (beatDetector.isKick()) { 246 | tint(0, 255, 255); 247 | image(sprites[int(random(0, numSprites))], random(0, canvasW - spriteW), canvasH - spriteH, spriteW, spriteH); 248 | } 249 | if (beatDetector.isHat()) { 250 | tint(64, 255, 255); 251 | image(sprites[int(random(0, numSprites))], random(0, canvasW - spriteW), canvasH - spriteH, spriteW, spriteH); 252 | } 253 | if (beatDetector.isSnare()) { 254 | tint(124, 255, 255); 255 | image(sprites[int(random(0, numSprites))], random(0, canvasW - spriteW), canvasH - spriteH, spriteW, spriteH); 256 | } 257 | } 258 | } 259 | if (spriteName != ' ') { 260 | try { 261 | //tint(0, 255, 255); 262 | noTint(); 263 | image(loadImage("" + spriteName + ".png"), random(0, canvasW - spriteW), canvasH - spriteH, spriteW, spriteH); 264 | } 265 | catch (Exception e) { 266 | // foo 267 | } 268 | spriteName = ' '; 269 | } 270 | if (cam.available() == true) { 271 | cam.read(); 272 | } 273 | image(cam, 0, 0, canvasW, canvasW); 274 | scrape(); 275 | } 276 | } 277 | 278 | void stop() 279 | { 280 | jingle.close(); 281 | super.stop(); 282 | } 283 | 284 | void keyTyped() { 285 | if (key == 'b') { 286 | useBeats = !useBeats; 287 | return; 288 | } 289 | spriteName = key; 290 | } 291 | -------------------------------------------------------------------------------- /pixelpusher_fftriver_webcam/scraper.pde: -------------------------------------------------------------------------------- 1 | void scrape() { 2 | // scrape for the strips 3 | loadPixels(); 4 | if (testObserver.hasStrips) { 5 | registry.startPushing(); 6 | List strips = registry.getStrips(); 7 | 8 | // our array is tall and narrow, so let's rotate this 90 degrees. 9 | // we can assume they're all the same length. 10 | 11 | // yscale = how many pixels of y == one led pixel. 12 | // xscale = how many pixels of x == one led strip. 13 | int yscale = height / strips.get(0).getLength(); 14 | int xscale = width / strips.size(); 15 | 16 | // for each strip (x-direction) 17 | int stripx = 0; 18 | for (Strip strip : strips) { 19 | for (int stripy = 0; stripy < strip.getLength(); stripy++) { 20 | color c = pixels[((strips.size() - stripx)*xscale) + (stripy*yscale*width)]; 21 | Pixel p = new Pixel((byte)red(c), (byte)green(c), (byte)blue(c)); 22 | //Pixel p = new Pixel((byte)255, (byte)255, (byte)255); 23 | strip.setPixel(p, stripy); 24 | } 25 | stripx++; 26 | } 27 | } 28 | updatePixels(); 29 | } 30 | -------------------------------------------------------------------------------- /pixelpusher_highcri/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /pixelpusher_highcri/pixelpusher_highcri.pde: -------------------------------------------------------------------------------- 1 | 2 | // Example of how to drive high CRI strips without 3 | // using the library support for them. 4 | // 5 | // Included as it serves as a description of the strip 6 | // architecture, rather than for actual use. Please use 7 | // strip.setRGBOW(true) instead of doing it this way! 8 | // 9 | // - jas. 10 | 11 | import com.heroicrobot.dropbit.registry.*; 12 | import com.heroicrobot.dropbit.devices.pixelpusher.Pixel; 13 | import com.heroicrobot.dropbit.devices.pixelpusher.Strip; 14 | import java.util.*; 15 | 16 | private Random random = new Random(); 17 | 18 | DeviceRegistry registry; 19 | 20 | 21 | class TestObserver implements Observer { 22 | public boolean hasStrips = false; 23 | public void update(Observable registry, Object updatedDevice) { 24 | println("Registry changed!"); 25 | if (updatedDevice != null) { 26 | println("Device change: " + updatedDevice); 27 | } 28 | this.hasStrips = true; 29 | } 30 | } 31 | 32 | TestObserver testObserver; 33 | int c = 0; 34 | 35 | void setup() { 36 | registry = new DeviceRegistry(); 37 | testObserver = new TestObserver(); 38 | registry.addObserver(testObserver); 39 | colorMode(HSB, 100); 40 | size(640, 640); 41 | } 42 | 43 | void draw() { 44 | int x=0; 45 | int y=0; 46 | if (testObserver.hasStrips) { 47 | registry.startPushing(); 48 | registry.setExtraDelay(0); 49 | registry.setAutoThrottle(true); 50 | int stripy = 0; 51 | List strips = registry.getStrips(); 52 | Pixel c = new Pixel((byte) 255, (byte) 255, (byte) 255); 53 | Pixel o = new Pixel((byte) 255, (byte) 255, (byte) 255); 54 | Pixel w = new Pixel((byte) 255, (byte) 255, (byte) 255); 55 | for(Strip strip : strips) { 56 | int xscale = width / strip.getLength(); 57 | for (int stripx = 0; stripx < strip.getLength(); stripx+=6) { 58 | strip.setPixel(c, stripx); 59 | strip.setPixel(o, stripx+1); 60 | strip.setPixel(w, stripx+2); 61 | strip.setPixel(c, stripx+3); 62 | strip.setPixel(w, stripx+4); 63 | strip.setPixel(o, stripx+5); 64 | } 65 | stripy++; 66 | } 67 | } 68 | } 69 | 70 | -------------------------------------------------------------------------------- /pixelpusher_highcri/sketch.properties: -------------------------------------------------------------------------------- 1 | mode.id=processing.mode.java.JavaMode 2 | mode=Java 3 | -------------------------------------------------------------------------------- /pixelpusher_lightning/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /pixelpusher_lightning/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | pixelpusher_fftriver 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | processing.plugin.core.sketchBuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | processing.plugin.core.sketchNature 22 | 23 | 24 | -------------------------------------------------------------------------------- /pixelpusher_lightning/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /pixelpusher_lightning/observer.pde: -------------------------------------------------------------------------------- 1 | class TestObserver implements Observer { 2 | public boolean hasStrips = false; 3 | public void update(Observable registry, Object updatedDevice) { 4 | println("Registry changed!"); 5 | if (updatedDevice != null) { 6 | println("Device change: " + updatedDevice); 7 | } 8 | this.hasStrips = true; 9 | } 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /pixelpusher_lightning/pixelpusher_lightning.pde: -------------------------------------------------------------------------------- 1 | 2 | // like sands through the hourglass so are the days.. blahblah 3 | // by me 4 | 5 | 6 | import com.heroicrobot.dropbit.registry.*; 7 | import com.heroicrobot.dropbit.devices.pixelpusher.Pixel; 8 | import com.heroicrobot.dropbit.devices.pixelpusher.Strip; 9 | 10 | import processing.core.*; 11 | import java.util.*; 12 | 13 | DeviceRegistry registry; 14 | 15 | int stride = 240; 16 | boolean use_weighted_get = true; 17 | 18 | 19 | boolean ready_to_go = true; 20 | int lastPosition; 21 | int canvasW = 480; 22 | int canvasH = 480; 23 | TestObserver testObserver; 24 | 25 | int radius = 5; 26 | float theta = 3.0; 27 | int count = 0; 28 | 29 | float x; 30 | float y; 31 | float diam; 32 | int age = 0; 33 | 34 | 35 | 36 | void setup() { 37 | size(canvasW, canvasH); 38 | registry = new DeviceRegistry(); 39 | testObserver = new TestObserver(); 40 | registry.addObserver(testObserver); 41 | registry.setAntiLog(true); 42 | registry.setAutoThrottle(true); 43 | frameRate(60); 44 | } 45 | 46 | 47 | void draw() { 48 | if (age == 0) { 49 | background(0); 50 | } 51 | 52 | if (age == 0 && random(100) > 99) { 53 | x=random(480); 54 | y=random(480); 55 | diam=random(480); 56 | fill(255); 57 | ellipse(x, y, diam, diam); 58 | age = int(diam / 15); 59 | } 60 | if (age > 0) { 61 | if (age % 2 == 0) 62 | background(0); 63 | else 64 | ellipse(x, y, diam, diam); 65 | age--; 66 | } 67 | scrape(); 68 | } 69 | 70 | 71 | -------------------------------------------------------------------------------- /pixelpusher_lightning/scraper.pde: -------------------------------------------------------------------------------- 1 | 2 | 3 | boolean first_scrape = true; 4 | void scrape() { 5 | // scrape for the strips 6 | loadPixels(); 7 | if (testObserver.hasStrips) { 8 | registry.startPushing(); 9 | List strips = registry.getStrips(); 10 | boolean phase = false; 11 | // for every strip: 12 | int currenty = 0; 13 | int stripy = 0; 14 | for(Strip strip : strips) { 15 | int strides_per_strip = strip.getLength() / stride; 16 | 17 | int xscale = width / stride; 18 | int yscale = height / (strides_per_strip * strips.size()); 19 | 20 | // for every pixel in the physical strip 21 | for (int stripx = 0; stripx < strip.getLength(); stripx++) { 22 | int xpixel = stripx % stride; 23 | int stridenumber = stripx / stride; 24 | int xpos,ypos; 25 | 26 | if ((stridenumber & 1) == 0) { // we are going left to right 27 | xpos = xpixel * xscale; 28 | ypos = ((stripy*strides_per_strip) + stridenumber) * yscale; 29 | } else { // we are going right to left 30 | xpos = ((stride - 1)-xpixel) * xscale; 31 | ypos = ((stripy*strides_per_strip) + stridenumber) * yscale; 32 | } 33 | 34 | color c = get(xpos, ypos); 35 | strip.setPixel(c, stripx); 36 | 37 | } 38 | stripy++; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /pixelpusher_lightning/sketch.properties: -------------------------------------------------------------------------------- 1 | mode.id=processing.mode.java.JavaMode 2 | mode=Java 3 | -------------------------------------------------------------------------------- /pixelpusher_lightpainting/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /pixelpusher_lightpainting/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | pixelpusher_fftriver 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | processing.plugin.core.sketchBuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | processing.plugin.core.sketchNature 22 | 23 | 24 | -------------------------------------------------------------------------------- /pixelpusher_lightpainting/observer.pde: -------------------------------------------------------------------------------- 1 | class TestObserver implements Observer { 2 | public boolean hasStrips = false; 3 | public void update(Observable registry, Object updatedDevice) { 4 | println("Registry changed!"); 5 | if (updatedDevice != null) { 6 | println("Device change: " + updatedDevice); 7 | } 8 | this.hasStrips = true; 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /pixelpusher_lightpainting/pixelpusher_lightpainting.pde: -------------------------------------------------------------------------------- 1 | 2 | import javax.swing.*; 3 | import com.heroicrobot.dropbit.registry.*; 4 | import com.heroicrobot.dropbit.devices.pixelpusher.Pixel; 5 | import com.heroicrobot.dropbit.devices.pixelpusher.Strip; 6 | 7 | import processing.core.*; 8 | import java.util.*; 9 | 10 | DeviceRegistry registry; 11 | 12 | boolean ready_to_go = true; 13 | 14 | TestObserver testObserver; 15 | PImage myImage; 16 | 17 | int xpos = 0; 18 | 19 | void setup() { 20 | registry = new DeviceRegistry(); 21 | testObserver = new TestObserver(); 22 | registry.addObserver(testObserver); 23 | registry.setAntiLog(true); 24 | registry.setFrameLimit(1000); 25 | frameRate(1000); 26 | 27 | // get a file to draw. 28 | 29 | try { 30 | UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 31 | } catch (Exception e) { 32 | e.printStackTrace(); 33 | } 34 | 35 | // create a file chooser 36 | final JFileChooser fc = new JFileChooser(); 37 | 38 | // in response to a button click: 39 | int returnVal = fc.showOpenDialog(this); 40 | 41 | if (returnVal == JFileChooser.APPROVE_OPTION) { 42 | File file = fc.getSelectedFile(); 43 | // see if it's an image 44 | // (better to write a function and check for all supported extensions) 45 | // load the image using the given file path 46 | myImage = loadImage(file.getPath()); 47 | image(myImage,0,0); 48 | size(myImage.width, myImage.height); 49 | } else { 50 | println("Open command cancelled by user."); 51 | exit(); 52 | } 53 | image(myImage,0,0); 54 | 55 | } 56 | 57 | 58 | 59 | 60 | void draw() { 61 | scrape(xpos++); 62 | if (xpos == width) 63 | xpos = 0; 64 | } 65 | 66 | void stop() 67 | { 68 | super.stop(); 69 | } 70 | -------------------------------------------------------------------------------- /pixelpusher_lightpainting/scraper.pde: -------------------------------------------------------------------------------- 1 | 2 | void scrape(int xpos) { 3 | // scrape for the strips 4 | if (testObserver.hasStrips) { 5 | registry.startPushing(); 6 | List strips = registry.getStrips(); 7 | // for only one strip: 8 | Strip strip1=strips.get(0); 9 | Strip strip2=strips.get(1); 10 | int stripy=0; 11 | float ystep = height / strip1.getLength(); 12 | for (float y=0; y 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /pixelpusher_starfield/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | pixelpusher_fftriver 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | processing.plugin.core.sketchBuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | processing.plugin.core.sketchNature 22 | 23 | 24 | -------------------------------------------------------------------------------- /pixelpusher_starfield/observer.pde: -------------------------------------------------------------------------------- 1 | class TestObserver implements Observer { 2 | public boolean hasStrips = false; 3 | public void update(Observable registry, Object updatedDevice) { 4 | println("Registry changed!"); 5 | if (updatedDevice != null) { 6 | println("Device change: " + updatedDevice); 7 | } 8 | this.hasStrips = true; 9 | } 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /pixelpusher_starfield/pixelpusher_starfield.pde: -------------------------------------------------------------------------------- 1 | 2 | 3 | import com.heroicrobot.dropbit.registry.*; 4 | import com.heroicrobot.dropbit.devices.pixelpusher.Pixel; 5 | import com.heroicrobot.dropbit.devices.pixelpusher.Strip; 6 | 7 | import processing.core.*; 8 | import java.util.*; 9 | 10 | DeviceRegistry registry; 11 | 12 | int stride = 240; 13 | boolean use_weighted_get = true; 14 | 15 | boolean ready_to_go = true; 16 | 17 | int canvasW = 480; 18 | int canvasH = 480; 19 | TestObserver testObserver; 20 | 21 | int numStars = 200; 22 | 23 | int radius = 5; 24 | float theta = 3.0; 25 | 26 | class Star { 27 | public int x; 28 | public int y; 29 | public int z; 30 | 31 | public Star() { 32 | x=0; 33 | y=int(random(height)); 34 | z=20+int(random(width-20)); 35 | } 36 | }; 37 | 38 | Star[] galaxy; 39 | 40 | void setup() { 41 | size(canvasW, canvasH, P3D); 42 | registry = new DeviceRegistry(); 43 | testObserver = new TestObserver(); 44 | registry.addObserver(testObserver); 45 | registry.setAntiLog(true); 46 | //background(#000000); 47 | stroke(#ffffff); 48 | fill(#ffffff); 49 | galaxy = new Star[numStars]; 50 | background(0); 51 | for (int i=0; i width) 64 | galaxy[i] = new Star(); 65 | } 66 | scrape(); 67 | } 68 | 69 | void stop() 70 | { 71 | super.stop(); 72 | } 73 | 74 | -------------------------------------------------------------------------------- /pixelpusher_starfield/scraper.pde: -------------------------------------------------------------------------------- 1 | 2 | color weighted_get(int xpos, int ypos, int radius) { 3 | int red, green, blue; 4 | int xoffset, yoffset; 5 | int pixels_counted; 6 | 7 | color thispixel; 8 | 9 | 10 | red = green = blue = pixels_counted = 0; 11 | 12 | for (xoffset=-radius; xoffset strips = registry.getStrips(); 32 | boolean phase = false; 33 | // for every strip: 34 | int currenty = 0; 35 | int stripy = 0; 36 | for(Strip strip : strips) { 37 | int strides_per_strip = strip.getLength() / stride; 38 | 39 | int xscale = width / stride; 40 | int yscale = height / (strides_per_strip * strips.size()); 41 | 42 | // for every pixel in the physical strip 43 | for (int stripx = 0; stripx < strip.getLength(); stripx++) { 44 | int xpixel = stripx % stride; 45 | int stridenumber = stripx / stride; 46 | int xpos,ypos; 47 | 48 | if ((stridenumber & 1) == 0) { // we are going left to right 49 | xpos = xpixel * xscale; 50 | ypos = ((stripy*strides_per_strip) + stridenumber) * yscale; 51 | } else { // we are going right to left 52 | xpos = ((stride - 1)-xpixel) * xscale; 53 | ypos = ((stripy*strides_per_strip) + stridenumber) * yscale; 54 | } 55 | 56 | color c = 0; 57 | //c = weighted_get(xpos, ypos, int((xscale+yscale) / 3)); 58 | c=get(xpos,ypos); 59 | strip.setPixel(c, stripx); 60 | 61 | } 62 | stripy++; 63 | } 64 | } 65 | updatePixels(); 66 | } 67 | -------------------------------------------------------------------------------- /pixelpusher_starfield/sketch.properties: -------------------------------------------------------------------------------- 1 | mode.id=processing.mode.experimental.ExperimentalMode 2 | mode=Experimental 3 | -------------------------------------------------------------------------------- /pixelpusher_syphon_bare/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /pixelpusher_syphon_bare/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | pixelpusher_fftriver 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | processing.plugin.core.sketchBuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | processing.plugin.core.sketchNature 22 | 23 | 24 | -------------------------------------------------------------------------------- /pixelpusher_syphon_bare/data/0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_bare/data/0.png -------------------------------------------------------------------------------- /pixelpusher_syphon_bare/data/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_bare/data/1.png -------------------------------------------------------------------------------- /pixelpusher_syphon_bare/data/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_bare/data/2.png -------------------------------------------------------------------------------- /pixelpusher_syphon_bare/data/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_bare/data/3.png -------------------------------------------------------------------------------- /pixelpusher_syphon_bare/data/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_bare/data/4.png -------------------------------------------------------------------------------- /pixelpusher_syphon_bare/data/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_bare/data/5.png -------------------------------------------------------------------------------- /pixelpusher_syphon_bare/data/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_bare/data/6.png -------------------------------------------------------------------------------- /pixelpusher_syphon_bare/data/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_bare/data/7.png -------------------------------------------------------------------------------- /pixelpusher_syphon_bare/data/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_bare/data/8.png -------------------------------------------------------------------------------- /pixelpusher_syphon_bare/data/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_bare/data/9.png -------------------------------------------------------------------------------- /pixelpusher_syphon_bare/data/a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_bare/data/a.png -------------------------------------------------------------------------------- /pixelpusher_syphon_bare/data/d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_bare/data/d.png -------------------------------------------------------------------------------- /pixelpusher_syphon_bare/data/e.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_bare/data/e.png -------------------------------------------------------------------------------- /pixelpusher_syphon_bare/data/f.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_bare/data/f.png -------------------------------------------------------------------------------- /pixelpusher_syphon_bare/data/g.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_bare/data/g.png -------------------------------------------------------------------------------- /pixelpusher_syphon_bare/data/q.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_bare/data/q.png -------------------------------------------------------------------------------- /pixelpusher_syphon_bare/data/r.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_bare/data/r.png -------------------------------------------------------------------------------- /pixelpusher_syphon_bare/data/s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_bare/data/s.png -------------------------------------------------------------------------------- /pixelpusher_syphon_bare/data/t.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_bare/data/t.png -------------------------------------------------------------------------------- /pixelpusher_syphon_bare/data/u.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_bare/data/u.png -------------------------------------------------------------------------------- /pixelpusher_syphon_bare/data/w.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_bare/data/w.png -------------------------------------------------------------------------------- /pixelpusher_syphon_bare/data/y.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_bare/data/y.png -------------------------------------------------------------------------------- /pixelpusher_syphon_bare/observer.pde: -------------------------------------------------------------------------------- 1 | class TestObserver implements Observer { 2 | public boolean hasStrips = false; 3 | public void update(Observable registry, Object updatedDevice) { 4 | println("Registry changed!"); 5 | if (updatedDevice != null) { 6 | println("Device change: " + updatedDevice); 7 | } 8 | this.hasStrips = true; 9 | } 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /pixelpusher_syphon_bare/pixelpusher_syphon_bare.pde: -------------------------------------------------------------------------------- 1 | // custom triple-wide scraper. 2 | // jas strong, 6th Dec 2013. 3 | 4 | import codeanticode.syphon.*; 5 | 6 | import com.heroicrobot.dropbit.registry.*; 7 | import com.heroicrobot.dropbit.devices.pixelpusher.Pixel; 8 | import com.heroicrobot.dropbit.devices.pixelpusher.Strip; 9 | 10 | import processing.core.*; 11 | import java.util.*; 12 | 13 | DeviceRegistry registry; 14 | 15 | SyphonClient client; 16 | PGraphics canvas; 17 | 18 | boolean ready_to_go = true; 19 | int lastPosition; 20 | int canvasW = 240 * 3; 21 | int canvasH = 40 * 4; 22 | TestObserver testObserver; 23 | 24 | 25 | 26 | void setup() { 27 | size(canvasW, canvasH, P3D); 28 | registry = new DeviceRegistry(); 29 | testObserver = new TestObserver(); 30 | registry.addObserver(testObserver); 31 | background(0); 32 | client = new SyphonClient(this, "Modul8", "Main View"); 33 | } 34 | 35 | 36 | 37 | 38 | void draw() { 39 | if (client.available()) { 40 | canvas = client.getGraphics(canvas); 41 | image(canvas, 0, 0, width, height); 42 | } 43 | scrape(); 44 | } 45 | 46 | void stop() 47 | { 48 | super.stop(); 49 | } 50 | 51 | -------------------------------------------------------------------------------- /pixelpusher_syphon_bare/scraper.pde: -------------------------------------------------------------------------------- 1 | 2 | void scrape() { 3 | // scrape for the strips 4 | loadPixels(); 5 | if (testObserver.hasStrips) { 6 | registry.startPushing(); 7 | List strips = registry.getStrips(); 8 | 9 | // yscale = how many pixels of y == one led strip. 10 | // xscale = how many pixels of x == one led pixel. 11 | float xscale = height / strips.get(0).getLength(); 12 | float yscale = ((width / strips.size()) ); 13 | 14 | // for each strip (y-direction) 15 | int stripy = 0; 16 | for (Strip strip : strips) { 17 | for (int stripx = 0; stripx < strip.getLength(); stripx++) { 18 | color c = get(int(stripx*xscale),int(stripy*yscale)); 19 | strip.setPixel(c, stripx); 20 | } 21 | stripy++; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /pixelpusher_syphon_triplewide/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /pixelpusher_syphon_triplewide/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | pixelpusher_fftriver 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | processing.plugin.core.sketchBuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | processing.plugin.core.sketchNature 22 | 23 | 24 | -------------------------------------------------------------------------------- /pixelpusher_syphon_triplewide/data/0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_triplewide/data/0.png -------------------------------------------------------------------------------- /pixelpusher_syphon_triplewide/data/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_triplewide/data/1.png -------------------------------------------------------------------------------- /pixelpusher_syphon_triplewide/data/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_triplewide/data/2.png -------------------------------------------------------------------------------- /pixelpusher_syphon_triplewide/data/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_triplewide/data/3.png -------------------------------------------------------------------------------- /pixelpusher_syphon_triplewide/data/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_triplewide/data/4.png -------------------------------------------------------------------------------- /pixelpusher_syphon_triplewide/data/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_triplewide/data/5.png -------------------------------------------------------------------------------- /pixelpusher_syphon_triplewide/data/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_triplewide/data/6.png -------------------------------------------------------------------------------- /pixelpusher_syphon_triplewide/data/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_triplewide/data/7.png -------------------------------------------------------------------------------- /pixelpusher_syphon_triplewide/data/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_triplewide/data/8.png -------------------------------------------------------------------------------- /pixelpusher_syphon_triplewide/data/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_triplewide/data/9.png -------------------------------------------------------------------------------- /pixelpusher_syphon_triplewide/data/a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_triplewide/data/a.png -------------------------------------------------------------------------------- /pixelpusher_syphon_triplewide/data/d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_triplewide/data/d.png -------------------------------------------------------------------------------- /pixelpusher_syphon_triplewide/data/e.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_triplewide/data/e.png -------------------------------------------------------------------------------- /pixelpusher_syphon_triplewide/data/f.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_triplewide/data/f.png -------------------------------------------------------------------------------- /pixelpusher_syphon_triplewide/data/g.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_triplewide/data/g.png -------------------------------------------------------------------------------- /pixelpusher_syphon_triplewide/data/q.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_triplewide/data/q.png -------------------------------------------------------------------------------- /pixelpusher_syphon_triplewide/data/r.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_triplewide/data/r.png -------------------------------------------------------------------------------- /pixelpusher_syphon_triplewide/data/s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_triplewide/data/s.png -------------------------------------------------------------------------------- /pixelpusher_syphon_triplewide/data/t.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_triplewide/data/t.png -------------------------------------------------------------------------------- /pixelpusher_syphon_triplewide/data/u.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_triplewide/data/u.png -------------------------------------------------------------------------------- /pixelpusher_syphon_triplewide/data/w.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_triplewide/data/w.png -------------------------------------------------------------------------------- /pixelpusher_syphon_triplewide/data/y.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robot-head/PixelPusher-processing-sketches/8e8d895f8a125b8202c56651b90a516b5cf74435/pixelpusher_syphon_triplewide/data/y.png -------------------------------------------------------------------------------- /pixelpusher_syphon_triplewide/observer.pde: -------------------------------------------------------------------------------- 1 | class TestObserver implements Observer { 2 | public boolean hasStrips = false; 3 | public void update(Observable registry, Object updatedDevice) { 4 | println("Registry changed!"); 5 | if (updatedDevice != null) { 6 | println("Device change: " + updatedDevice); 7 | } 8 | this.hasStrips = true; 9 | } 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /pixelpusher_syphon_triplewide/pixelpusher_syphon_triplewide.pde: -------------------------------------------------------------------------------- 1 | // custom triple-wide scraper. 2 | // jas strong, 6th Dec 2013. 3 | 4 | import codeanticode.syphon.*; 5 | import com.heroicrobot.dropbit.registry.*; 6 | import com.heroicrobot.dropbit.devices.pixelpusher.Pixel; 7 | import com.heroicrobot.dropbit.devices.pixelpusher.Strip; 8 | 9 | import processing.core.*; 10 | import java.util.*; 11 | 12 | DeviceRegistry registry; 13 | 14 | SyphonClient client; 15 | PGraphics canvas; 16 | 17 | boolean ready_to_go = true; 18 | int lastPosition; 19 | int canvasW = 240 * 3; 20 | int canvasH = 40 * 4; 21 | TestObserver testObserver; 22 | 23 | 24 | 25 | void setup() { 26 | size(canvasW, canvasH, P3D); 27 | registry = new DeviceRegistry(); 28 | testObserver = new TestObserver(); 29 | registry.addObserver(testObserver); 30 | background(0); 31 | client = new SyphonClient(this, "Modul8", "Main View"); 32 | } 33 | 34 | 35 | 36 | 37 | void draw() { 38 | if (client.available()) { 39 | canvas = client.getGraphics(canvas); 40 | image(canvas, 0, 0, width, height); 41 | } 42 | 43 | // since we have each "sub-screen" in its own group, scrape for all three. 44 | scrape(1); 45 | scrape(2); 46 | scrape(3); 47 | } 48 | 49 | void stop() 50 | { 51 | super.stop(); 52 | } 53 | 54 | -------------------------------------------------------------------------------- /pixelpusher_syphon_triplewide/scraper.pde: -------------------------------------------------------------------------------- 1 | 2 | void scrape(int segment) { 3 | // scrape for the strips 4 | loadPixels(); 5 | if (testObserver.hasStrips) { 6 | registry.startPushing(); 7 | List strips = registry.getStrips(segment); 8 | 9 | // yscale = how many pixels of y == one led strip. 10 | // xscale = how many pixels of x == one led pixel. 11 | int xscale = height / strips.get(0).getLength(); 12 | int yscale = ((width / strips.size()) / 3); 13 | int xoffset = (segment - 1) * (width / 3); 14 | 15 | // for each strip (y-direction) 16 | int stripy = 0; 17 | for (Strip strip : strips) { 18 | for (int stripx = 0; stripx < strip.getLength(); stripx++) { 19 | color c = pixels[((strips.size() - (stripx + 1))*xscale)+ xoffset + (stripy*yscale*width)]; 20 | strip.setPixel(c, stripy); 21 | } 22 | stripy++; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /pixelpusher_tester/pixelpusher_tester.pde: -------------------------------------------------------------------------------- 1 | // Test program for PixelPusher 2 | // by jas@heroicrobot.com 3 | // 4 | 5 | 6 | import com.heroicrobot.dropbit.registry.*; 7 | import com.heroicrobot.dropbit.devices.pixelpusher.Pixel; 8 | import com.heroicrobot.dropbit.devices.pixelpusher.Strip; 9 | import java.util.*; 10 | import processing.core.*; 11 | 12 | DeviceRegistry registry; 13 | 14 | int lastPosition; 15 | int canvasW = 1024; 16 | int canvasH = 600; 17 | int stride = 240; 18 | 19 | class TestObserver implements Observer { 20 | public boolean hasStrips = false; 21 | public void update(Observable registry, Object updatedDevice) { 22 | println("Registry changed!"); 23 | if (updatedDevice != null) { 24 | println("Device change: " + updatedDevice); 25 | } 26 | this.hasStrips = true; 27 | } 28 | }; 29 | 30 | TestObserver testObserver; 31 | 32 | float x=0,y=0; 33 | color colour; 34 | 35 | int colourIndex = 0; 36 | boolean testMode = false; 37 | int intensity = 255; 38 | 39 | color chooseNextColour() { 40 | if (colourIndex > 10) { 41 | colourIndex = 0; 42 | testMode = !testMode; 43 | } 44 | switch (colourIndex++) { 45 | case 0: return color(255, 0, 0); 46 | case 1: return color(0, 255, 0); 47 | case 2: return color(0, 0, 255); 48 | case 3: return color(127, 0, 0); 49 | case 4: return color(0, 127, 0); 50 | case 5: return color(0, 0, 127); 51 | case 6: return color(255, 255, 255); 52 | case 7: return color(127, 127, 127); 53 | case 8: return color(63, 63, 63); 54 | case 9: return color(10, 10, 10); 55 | case 10: return color(127, 127, 0); 56 | default: return color(127, 127, 0); 57 | } 58 | } 59 | 60 | void setup() { 61 | size(canvasW, canvasH); 62 | registry = new DeviceRegistry(); 63 | testObserver = new TestObserver(); 64 | registry.addObserver(testObserver); 65 | background(0); 66 | colorMode(RGB, 255, 255, 255, 255); 67 | colour = chooseNextColour(); 68 | rectMode(CORNER); 69 | 70 | } 71 | 72 | 73 | void draw() { 74 | 75 | fill(0,0,0); 76 | rect(0, 0, width, height); 77 | noStroke(); 78 | fill(colour); 79 | // scrape for the strips 80 | if (testObserver.hasStrips) { 81 | registry.setExtraDelay(0); 82 | registry.startPushing(); 83 | 84 | int stripy = 0; 85 | List strips = registry.getStrips(); 86 | int y_scale = height / (strips.size()); 87 | if (!testMode) { 88 | rect(x, y, width / 240, y_scale); 89 | } else { 90 | if ((intensity-=1) > 0) { 91 | fill(colour, intensity); 92 | } else { 93 | intensity = 255; 94 | } 95 | rect(0, 0, width, height); 96 | } 97 | if ((x+=16) > width) { 98 | x=0; y+=y_scale; 99 | } 100 | if (y>height) { 101 | y = 0; 102 | colour = chooseNextColour(); 103 | } 104 | 105 | 106 | 107 | // for every strip: 108 | int currenty = 0; 109 | for(Strip strip : strips) { 110 | int strides_per_strip = strip.getLength() / stride; 111 | 112 | int xscale = width / stride; 113 | int yscale = height / (strides_per_strip * strips.size()); 114 | 115 | // for every pixel in the physical strip 116 | for (int stripx = 0; stripx < strip.getLength(); stripx++) { 117 | int xpixel = stripx % stride; 118 | int stridenumber = stripx / stride; 119 | int xpos,ypos; 120 | 121 | if ((stridenumber & 1) == 0) { // we are going left to right 122 | xpos = xpixel * xscale; 123 | ypos = ((stripy*strides_per_strip) + stridenumber) * yscale; 124 | } else { // we are going right to left 125 | xpos = (stride-xpixel) * xscale; 126 | ypos = ((stripy*strides_per_strip) + stridenumber) * yscale; 127 | } 128 | 129 | color c = get(xpos, ypos); 130 | strip.setPixel(c, stripx); 131 | 132 | } 133 | stripy++; 134 | } 135 | } 136 | } 137 | 138 | 139 | -------------------------------------------------------------------------------- /pixelpusher_tester_irising/controller.pde: -------------------------------------------------------------------------------- 1 | 2 | import com.heroicrobot.dropbit.registry.*; 3 | import com.heroicrobot.dropbit.devices.pixelpusher.PixelPusher; 4 | import com.heroicrobot.dropbit.devices.pixelpusher.Pixel; 5 | import com.heroicrobot.dropbit.devices.pixelpusher.Strip; 6 | 7 | TestObserver testObserver; 8 | DeviceRegistry registry; 9 | 10 | IntList controllerFullList = new IntList(); 11 | IntList controllerActivationList = new IntList(); 12 | int intStartupTime = 0; 13 | int intStartupDelayMillis = 2000; 14 | 15 | 16 | void setupController() 17 | { 18 | controllerFullList = new IntList(); 19 | intStartupTime = millis() + intStartupDelayMillis; 20 | 21 | registry = new DeviceRegistry(); 22 | registry.setAntiLog(true); 23 | registry.setAutoThrottle(true); 24 | //registry.setExtraDelay(1000); 25 | testObserver = new TestObserver(); 26 | registry.addObserver(testObserver); 27 | } 28 | 29 | 30 | void updateController() 31 | { 32 | try 33 | { 34 | if (testObserver.hasStrips && millis() >= intStartupTime) 35 | { 36 | Map controllerMap = registry.getPusherMap(); 37 | 38 | for (Map.Entry ppMappedController : controllerMap.entrySet()) { 39 | PixelPusher ppController = (PixelPusher) ppMappedController.getValue(); 40 | List strips = ppController.getStrips(); 41 | int intControllerNo = ppController.getControllerOrdinal(); 42 | int stripNo = 0; 43 | for(Strip strip : strips) { 44 | color stripColor = cBlack; 45 | if(controllerActivationList.hasValue(intControllerNo)) 46 | { 47 | stripColor = aryColors[stripNo]; 48 | } 49 | 50 | for (int stripx = 0; stripx < strip.getLength(); stripx++) { 51 | strip.setPixel(stripColor, stripx); 52 | } 53 | 54 | stripNo++; 55 | } 56 | } 57 | 58 | registry.startPushing(); 59 | } 60 | } 61 | catch (Exception ex) 62 | { 63 | } 64 | } 65 | 66 | class TestObserver implements Observer { 67 | public boolean hasStrips = false; 68 | 69 | public void update(Observable registry, Object updatedDevice) { 70 | try 71 | { 72 | PixelPusher pusher = (PixelPusher)updatedDevice; 73 | int intControllerNo = pusher.getControllerOrdinal(); 74 | if(!controllerFullList.hasValue(intControllerNo)) 75 | { 76 | controllerFullList.append(intControllerNo); 77 | checkboxController.addItem("Controller " + intControllerNo, intControllerNo).activate(checkboxController.getItems().size() - 1); 78 | controllerActivationList.append(intControllerNo); 79 | this.hasStrips = true; 80 | } 81 | } 82 | catch (Exception regException) 83 | { 84 | setupController(); 85 | } 86 | } 87 | }; 88 | -------------------------------------------------------------------------------- /pixelpusher_tester_irising/pixelpusher_tester_irising.pde: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import processing.core.*; 3 | import controlP5.*; 4 | 5 | int canvasW = 500; 6 | int canvasH = 500; 7 | 8 | color cBlack = color(0, 0, 0); // Black 9 | color cWhite = color(255, 255, 255); // White 10 | String[] aryColorsString = {"Red", "Green", "Blue", "Yellow", "Magenta", "Cyan", "Orange", "White"}; 11 | color[] aryColors = {color(250,0,0), // Red 12 | color(0,255,0), // Green 13 | color(0,0,255), // Blue 14 | color(255,255,0), // Yellow 15 | color(255,0,255), // Magenta 16 | color(0,255,255), // Cyan 17 | color(255,191,0), // Orange 18 | color(255, 255, 255) // White 19 | }; 20 | 21 | ControlP5 cp5; 22 | Textlabel txtLblWhichPusher; // text label displaying which pusher to toggle 23 | ListBox pusherListbox; // list of available pushers 24 | 25 | ArrayList stripsColor = new ArrayList(); 26 | CheckBox checkboxController; 27 | color colorActiveCheckbox = color(255, 0, 0); 28 | color colorHighlightCheckbox = color(0, 0, 255); 29 | color colorLabelCheckbox = color(255, 255, 255); 30 | int intItemsPerRow = 3; 31 | int intCheckboxSpacing = 100; 32 | 33 | void setup() { 34 | size(canvasW, canvasH); 35 | background(0); 36 | colorMode(RGB, 255, 255, 255, 255); 37 | rectMode(CORNER); 38 | 39 | cp5 = new ControlP5(this); 40 | /* 41 | ControlP5 cp5_2 = new ControlP5(this); 42 | 43 | RadioButton rbColor1 = cp5.addRadio("strip1Color"); 44 | rbColor1.setId(1).setPosition(20, 20).setItemWidth(20).setItemHeight(20).setNoneSelectedAllowed(false); 45 | for(int colorCount = 0; colorCount < aryColors.length; colorCount++) 46 | { 47 | rbColor1.addItem(aryColorsString[colorCount], aryColors[colorCount]) 48 | .setColorLabel(aryColors[colorCount]); 49 | } 50 | rbColor1.activate(0); 51 | stripsColor.add(rbColor1); 52 | 53 | RadioButton rbColor2 = cp5.addRadio("strip2Color"); 54 | rbColor2.setId(2).setPosition(100, 20).setItemWidth(20).setItemHeight(20).setNoneSelectedAllowed(false); 55 | for(int colorCount = 0; colorCount < aryColors.length; colorCount++) 56 | { 57 | rbColor2.addItem(aryColorsString[colorCount], aryColors[colorCount]) 58 | .setColorLabel(aryColors[colorCount]); 59 | } 60 | rbColor2.activate(1); 61 | stripsColor.add(rbColor2); 62 | 63 | for(int rCount = 0; rCount < 8; rCount++) 64 | { 65 | RadioButton rbColor = cp5.addRadioButton("strip" + (rCount + 1) + "Color") 66 | .setPosition((20 * rCount) + 20,(20 * rCount) + 20) 67 | .setItemWidth(20) 68 | .setItemHeight(20); 69 | } 70 | */ 71 | 72 | checkboxController = cp5.addCheckBox("checkBox") 73 | .setPosition(30, width-100) 74 | .setColorForeground(colorHighlightCheckbox) 75 | .setColorActive(colorActiveCheckbox) 76 | .setColorLabel(colorLabelCheckbox) 77 | .setSize(40, 40) 78 | .setItemsPerRow(intItemsPerRow) 79 | .setSpacingColumn(intCheckboxSpacing) 80 | .setSpacingRow(20); 81 | 82 | setupController();; 83 | } 84 | 85 | 86 | void draw() { 87 | updateController(); 88 | } 89 | 90 | void controlEvent(ControlEvent theEvent) { 91 | if (theEvent.isFrom(checkboxController)) { 92 | // checkbox uses arrayValue to store the state of 93 | // individual checkbox-items. usage: 94 | int col = 0; 95 | controllerActivationList.clear(); 96 | for (int i=0;i 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /pixelpusher_text/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | pixelpusher_fftriver 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | processing.plugin.core.sketchBuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | processing.plugin.core.sketchNature 22 | 23 | 24 | -------------------------------------------------------------------------------- /pixelpusher_text/observer.pde: -------------------------------------------------------------------------------- 1 | class TestObserver implements Observer { 2 | public boolean hasStrips = false; 3 | public void update(Observable registry, Object updatedDevice) { 4 | println("Registry changed!"); 5 | if (updatedDevice != null) { 6 | println("Device change: " + updatedDevice); 7 | } 8 | this.hasStrips = true; 9 | } 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /pixelpusher_text/pixelpusher_text.pde: -------------------------------------------------------------------------------- 1 | 2 | 3 | import com.heroicrobot.dropbit.registry.*; 4 | import com.heroicrobot.dropbit.devices.pixelpusher.Pixel; 5 | import com.heroicrobot.dropbit.devices.pixelpusher.Strip; 6 | 7 | import processing.core.*; 8 | import java.util.*; 9 | 10 | DeviceRegistry registry; 11 | 12 | int stride = 240; 13 | boolean use_weighted_get = true; 14 | 15 | boolean ready_to_go = true; 16 | 17 | int canvasW = 480; 18 | int canvasH = 16; 19 | TestObserver testObserver; 20 | 21 | int numStars = 1; 22 | 23 | int radius = 5; 24 | float theta = 3.0; 25 | 26 | class Star { 27 | public int x; 28 | public int y; 29 | public int z; 30 | public color c; 31 | public String starText; 32 | 33 | public Star() { 34 | x=580; 35 | y= height-2;//int(random(height)); 36 | z=20+int(random(width-20)); 37 | c = color(random(100), 100, 100); 38 | 39 | switch(int(random(5))) { 40 | case 0: starText = "ORD Camp 2014"; 41 | break; 42 | case 1: starText = "PUSHING PIXELS AND TAKING NAMES"; 43 | break; 44 | case 2: starText = "HACK ME, I LIKE IT"; 45 | break; 46 | case 3: starText = "OH HAI! ORD CAMP 2014"; 47 | break; 48 | case 4: starText = "so led. much pixel. wow ord camp."; 49 | } 50 | } 51 | }; 52 | 53 | Star[] galaxy; 54 | PFont myFont; 55 | 56 | void setup() { 57 | size(canvasW, canvasH, P3D); 58 | registry = new DeviceRegistry(); 59 | testObserver = new TestObserver(); 60 | registry.addObserver(testObserver); 61 | registry.setAntiLog(true); 62 | myFont = createFont("Speccy", 16); 63 | textFont(myFont); 64 | textSize(16); 65 | 66 | //background(#000000); 67 | stroke(#ffffff); 68 | fill(#ffffff); 69 | colorMode(HSB,100,100,100,100); 70 | galaxy = new Star[numStars]; 71 | background(0); 72 | for (int i=0; i strips = registry.getStrips(); 33 | boolean phase = false; 34 | // for every strip: 35 | int currenty = 0; 36 | int stripy = 0; 37 | for(Strip strip : strips) { 38 | int strides_per_strip = strip.getLength() / stride; 39 | 40 | int xscale = width / stride; 41 | int yscale = height / (strides_per_strip * strips.size()); 42 | 43 | // for every pixel in the physical strip 44 | for (int stripx = 0; stripx < strip.getLength(); stripx++) { 45 | int xpixel = stripx % stride; 46 | int stridenumber = stripx / stride; 47 | int xpos,ypos; 48 | 49 | if ((stridenumber & 1) == 0) { // we are going left to right 50 | xpos = xpixel * xscale; 51 | ypos = ((stripy*strides_per_strip) + stridenumber) * yscale; 52 | } else { // we are going right to left 53 | xpos = ((stride - 1)-xpixel) * xscale; 54 | ypos = ((stripy*strides_per_strip) + stridenumber) * yscale; 55 | } 56 | 57 | color c = 0; 58 | //c = weighted_get(xpos, ypos, int((xscale+yscale) / 3)); 59 | // c=weighted_get(xpos,ypos,1); 60 | c = get(xpos,ypos); 61 | strip.setPixel(c, stripx); 62 | 63 | } 64 | stripy++; 65 | } 66 | } 67 | updatePixels(); 68 | } 69 | -------------------------------------------------------------------------------- /pixelpusher_text/sketch.properties: -------------------------------------------------------------------------------- 1 | mode.id=processing.mode.experimental.ExperimentalMode 2 | mode=Experimental 3 | -------------------------------------------------------------------------------- /pixelpusher_triangles4/observer.pde: -------------------------------------------------------------------------------- 1 | class TestObserver implements Observer { 2 | public boolean hasStrips = false; 3 | public void update(Observable registry, Object updatedDevice) { 4 | println("Registry changed!"); 5 | if (updatedDevice != null) { 6 | println("Device change: " + updatedDevice); 7 | } 8 | this.hasStrips = true; 9 | } 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /pixelpusher_triangles4/pixelpusher_triangles4.pde: -------------------------------------------------------------------------------- 1 | 2 | 3 | import com.heroicrobot.dropbit.registry.*; 4 | import com.heroicrobot.dropbit.devices.pixelpusher.Pixel; 5 | import com.heroicrobot.dropbit.devices.pixelpusher.Strip; 6 | 7 | import processing.core.*; 8 | import java.util.*; 9 | 10 | DeviceRegistry registry; 11 | 12 | int stride = 240; 13 | 14 | boolean ready_to_go = true; 15 | 16 | TestObserver testObserver; 17 | 18 | 19 | 20 | class ConfigHolder { 21 | float size; 22 | float step; 23 | float range; 24 | float hue_min; 25 | float hue_max; 26 | int height; 27 | int width; 28 | }; 29 | 30 | ConfigHolder config; 31 | 32 | class TrianglePoints { 33 | float x1, y1, 34 | x2, y2, 35 | x3, y3; 36 | 37 | public TrianglePoints(float x1, float y1, float x2, float y2, float x3, float y3) { 38 | this.x1 = x1; 39 | this.x2 = x2; 40 | this.x3 = x3; 41 | this.y1 = y1; 42 | this.y2 = y2; 43 | this.y3 = y3; 44 | } 45 | String toString() { 46 | return "["+this.x1+","+this.y1+"]"+ 47 | "["+this.x2+","+this.y2+"]"+ 48 | "["+this.x3+","+this.y3+"]"; 49 | } 50 | }; 51 | 52 | class Triangle { 53 | float center_x, center_y; 54 | TrianglePoints points; 55 | float hue, sat, bri; 56 | float random; 57 | } 58 | 59 | int rows; 60 | int cols; 61 | 62 | Triangle[][] triangles; 63 | 64 | TrianglePoints pointsFor(float s, float cX, float cY, boolean flip) { 65 | float r = s/2; 66 | if (flip) 67 | return new TrianglePoints(cX-r, cY-r, cX+r, cY-r, cX, cY+r); 68 | else 69 | return new TrianglePoints(cX, cY-r, cX+r, cY+r, cX-r, cY+r); 70 | } 71 | 72 | float normalize(float x, float min, float max) { 73 | 74 | float range = max - min; 75 | 76 | if (x < min) x = range + x; 77 | if (x > max) x = x - range; 78 | 79 | return x; 80 | } 81 | 82 | void setup() { 83 | config = new ConfigHolder(); 84 | 85 | registry = new DeviceRegistry(); 86 | testObserver = new TestObserver(); 87 | registry.addObserver(testObserver); 88 | registry.setAntiLog(true); 89 | registry.setAutoThrottle(true); 90 | 91 | config.size = 30; 92 | config.width = 240*3; 93 | config.height = 480; 94 | size(config.width, config.height, P3D); 95 | config.step = 1; 96 | config.range = 130; 97 | config.hue_min = 0; 98 | config.hue_max = 100; 99 | rows = int((config.height / config.size) + 1); 100 | cols = int(((config.width / config.size) * 2) + 1); 101 | colorMode(HSB, 100); 102 | noStroke(); 103 | 104 | 105 | triangles= new Triangle[rows][cols]; 106 | 107 | float leftHue = random(100); 108 | 109 | // initialize triangles 110 | for (int j=0; j 0 ? 0.5 : -0.5); 188 | }; 189 | 190 | 191 | -------------------------------------------------------------------------------- /pixelpusher_triangles4/scraper.pde: -------------------------------------------------------------------------------- 1 | 2 | boolean first_scrape = true; 3 | void scrape() { 4 | // scrape for the strips 5 | loadPixels(); 6 | if (testObserver.hasStrips) { 7 | registry.startPushing(); 8 | List strips = registry.getStrips(); 9 | boolean phase = false; 10 | // for every strip: 11 | int currenty = 0; 12 | int stripy = 0; 13 | for(Strip strip : strips) { 14 | int strides_per_strip = strip.getLength() / stride; 15 | 16 | int xscale = width / stride; 17 | int yscale = height / (strides_per_strip * strips.size()); 18 | 19 | // for every pixel in the physical strip 20 | for (int stripx = 0; stripx < strip.getLength(); stripx++) { 21 | int xpixel = stripx % stride; 22 | int stridenumber = stripx / stride; 23 | int xpos,ypos; 24 | 25 | if ((stridenumber & 1) == 0) { // we are going left to right 26 | xpos = xpixel * xscale; 27 | ypos = ((stripy*strides_per_strip) + stridenumber) * yscale; 28 | } else { // we are going right to left 29 | xpos = ((stride - 1)-xpixel) * xscale; 30 | ypos = ((stripy*strides_per_strip) + stridenumber) * yscale; 31 | } 32 | 33 | color c = get(xpos, ypos); 34 | strip.setPixel(c, stripx); 35 | 36 | } 37 | stripy++; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /pixelpusher_video_player/observer.pde: -------------------------------------------------------------------------------- 1 | class PusherObserver implements Observer { 2 | public boolean hasStrips = false; 3 | public void update(Observable registry, Object updatedDevice) { 4 | println("Registry changed!"); 5 | if (updatedDevice != null) { 6 | println("Device change: " + updatedDevice); 7 | } 8 | this.hasStrips = true; 9 | } 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /pixelpusher_video_player/pixelpusher_video_player.pde: -------------------------------------------------------------------------------- 1 | import javax.swing.*; 2 | import processing.video.*; 3 | import com.heroicrobot.dropbit.registry.*; 4 | import com.heroicrobot.dropbit.devices.pixelpusher.Pixel; 5 | import com.heroicrobot.dropbit.devices.pixelpusher.Strip; 6 | import java.util.*; 7 | 8 | Movie myMovie; 9 | DeviceRegistry registry; 10 | PusherObserver observer; 11 | 12 | void setup() { 13 | size(640,480); 14 | registry = new DeviceRegistry(); 15 | observer = new PusherObserver(); 16 | registry.addObserver(observer); 17 | registry.setAntiLog(true); 18 | 19 | // set system look and feel 20 | try { 21 | UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 22 | } catch (Exception e) { 23 | e.printStackTrace(); 24 | 25 | } 26 | 27 | // create a file chooser 28 | final JFileChooser fc = new JFileChooser(); 29 | 30 | // in response to a button click: 31 | int returnVal = fc.showOpenDialog(this); 32 | 33 | if (returnVal == JFileChooser.APPROVE_OPTION) { 34 | File file = fc.getSelectedFile(); 35 | // see if it's an image 36 | // (better to write a function and check for all supported extensions) 37 | // load the image using the given file path 38 | myMovie = new Movie(this, file.getPath()); 39 | myMovie.loop(); 40 | } else { 41 | println("Open command cancelled by user."); 42 | exit(); 43 | } 44 | } 45 | 46 | void draw() { 47 | image(myMovie, 0, 0, width, height); 48 | scrape(); 49 | } 50 | 51 | void movieEvent(Movie m) { 52 | m.read(); 53 | } 54 | -------------------------------------------------------------------------------- /pixelpusher_video_player/scraper.pde: -------------------------------------------------------------------------------- 1 | void scrape() { 2 | // scrape for the strips 3 | loadPixels(); 4 | if (observer.hasStrips) { 5 | registry.startPushing(); 6 | registry.setAntiLog(true); 7 | List strips = registry.getStrips(); 8 | 9 | // our array is tall and narrow, so let's rotate this 90 degrees. 10 | // we can assume they're all the same length. 11 | 12 | // yscale = how many pixels of y == one led pixel. 13 | // xscale = how many pixels of x == one led strip. 14 | int yscale = height / strips.get(0).getLength(); 15 | int xscale = width / strips.size(); 16 | 17 | // for each strip (x-direction) 18 | int stripx = 0; 19 | for (Strip strip : strips) { 20 | for (int stripy = 0; stripy < strip.getLength(); stripy++) { 21 | color c = pixels[((strips.size() - (stripx + 1))*xscale) + (stripy*yscale*width)]; 22 | strip.setPixel(c, stripy); 23 | } 24 | stripx++; 25 | } 26 | } 27 | updatePixels(); 28 | } 29 | --------------------------------------------------------------------------------