Problem with LED Wall / Jumbotron project make mag
Shop › Forum › Everything Else › Problem with LED Wall / Jumbotron project make mag
- This topic has 1 reply, 2 voices, and was last updated 8 years, 4 months ago by Dan.
-
AuthorPosts
-
2016-09-12 at 19:10 #10870AnonymousInactive
See post here: https://github.com/i-make-robots/LEDWall/issues/1
Following errors with Movie2Serial:
Exception in thread “AWT-EventQueue-0” java.lang.NullPointerException
at javax.swing.ToolTipManager.initiateToolTip(ToolTipManager.java:478)
at javax.swing.ToolTipManager.mouseEntered(ToolTipManager.java:435)
at processing.mode.java.pdex.JavaTextArea$MouseHandler.mouseEntered(JavaTextArea.java:898)
at java.awt.AWTEventMulticaster.mouseEntered(AWTEventMulticaster.java:300)
at java.awt.Component.processMouseEvent(Component.java:6544)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6300)
at java.awt.Container.processEvent(Container.java:2236)
at java.awt.Component.dispatchEventImpl(Component.java:4891)
at java.awt.Container.dispatchEventImpl(Container.java:2294)
at java.awt.Component.dispatchEvent(Component.java:4713)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
at java.awt.LightweightDispatcher.retargetMouseEnterExit(Container.java:4676)
at java.awt.LightweightDispatcher.trackMouseEnterExit(Container.java:4654)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4505)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
at java.awt.Container.dispatchEventImpl(Container.java:2280)
at java.awt.Window.dispatchEventImpl(Window.java:2750)
at java.awt.Component.dispatchEvent(Component.java:4713)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
error, disabling movieEvent() for /Users/jodysweitzer/Documents/TheArray/AviClub/mga.avi
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at processing.video.Movie.fireMovieEvent(Unknown Source)
at processing.video.Movie.invokeEvent(Unknown Source)
at processing.video.Movie$2.rgbFrame(Unknown Source)
at org.gstreamer.elements.RGBDataAppSink$AppSinkNewBufferListener.newBuffer(RGBDataAppSink.java:162)
at org.gstreamer.elements.AppSink$2.callback(AppSink.java:184)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.jna.CallbackReference$DefaultCallbackProxy.invokeCallback(CallbackReference.java:485)
at com.sun.jna.CallbackReference$DefaultCallbackProxy.callback(CallbackReference.java:515)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 2400
at movie2serial0516.image2data(movie2serial0516.java:193)
at movie2serial0516.movieEvent(movie2serial0516.java:130)
… 15 more********************************************************************************************************
CODE:
/* OctoWS2811 movie2serial.pde – Transmit video data to 1 or more
Teensy 3.0 boards running OctoWS2811 VideoDisplay.ino
http://www.pjrc.com/teensy/td_libs_OctoWS2811.html
Copyright (c) 2013 Paul Stoffregen, PJRC.COM, LLC
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/// To configure this program, edit the following sections:
//
// 1: change myMovie to open a video file of your choice ๐
//
// 2: edit the serialConfigure() lines in setup() for your
// serial device names (Mac, Linux) or COM ports (Windows)
//
// 3: if your LED strips have unusual color configuration,
// edit colorWiring(). Nearly all strips have GRB wiring,
// so normally you can leave this as-is.
//
// 4: if playing 50 or 60 Hz progressive video (or faster),
// edit framerate in movieEvent().import processing.video.*;
import processing.serial.*;
import java.awt.Rectangle;Movie myMovie = new Movie(this, “/Users/jodysweitzer/Documents/TheArray/AviClub/mga.avi”);
final int SCREEN_WIDTH = 50;
final int SCREEN_HEIGHT = 16;final int PANEL_WIDTH=100;
final int PANEL_HEIGHT=100;
final int PANELS_PER_PIN = 1;
final int LEDS_PER_STRIP = PANEL_WIDTH * PANEL_HEIGHT * PANELS_PER_PIN;float gamma = 1.7;
int numPorts=0; // the number of serial ports in use
int maxPorts=2; // maximum number of serial portsSerial[] ledSerial = new Serial[maxPorts]; // each port’s actual Serial port
Rectangle[] ledArea = new Rectangle[maxPorts]; // the area of the movie each port gets, in % (0-100)
boolean[] ledLayout = new boolean[maxPorts]; // layout of rows, true = even is left->right
PImage[] ledImage = new PImage[maxPorts]; // image sent to each port
int[] gammatable = new int[256];
int errorCount=0;
float framerate=0;void setup() {
String[] list = Serial.list();// Movie myMovie = new Movie(this, “/Users/jodysweitzer/Documents/TheArray/AviClub/dream5.avi”);
delay(20);
println(“Serial Ports List:”);
println(list);serialConfigure(“/dev/tty.usbmodem1508001”); // change these to your port names
// serialConfigure(“/dev/tty.usbmodemfd131”); // change these to your port names
if (errorCount > 0) exit();
for (int i=0; i < 256; i++) {// println(i);
gammatable[i] = (int)(pow((float)i / 255.0, gamma) * 255.0 + 0.5);
}size(1024,768); // create the window
myMovie.loop(); // start the movie ๐
}// movieEvent runs for each new frame of movie data
void movieEvent(Movie m) {
// read the movie’s next framem.read();
//if (framerate == 0) framerate = m.getSourceFrameRate();
framerate = 30.0; // TODO, how to read the frame rate???for (int i=0; i < numPorts; i++) {
// copy a portion of the movie’s image to the LED image
int xoffset = percentage(m.width, ledArea[i].x);
int yoffset = percentage(m.height, ledArea[i].y);
int xwidth = percentage(m.width, ledArea[i].width);
int yheight = percentage(m.height, ledArea[i].height);
ledImage[i].copy(m, xoffset, yoffset, xwidth, yheight,
0, 0, ledImage[i].width, ledImage[i].height);// convert the LED image to raw data
byte[] ledData = new byte[(ledImage[i].width * ledImage[i].height * 3) + 3];image2data(ledImage[i], ledData, ledLayout[i]);/*
if (i == 0) {
ledData[0] = ‘*’; // first Teensy is the frame sync master
int usec = (int)((1000000.0 / framerate) * 0.75);
ledData[1] = (byte)(usec); // request the frame sync pulse
ledData[2] = (byte)(usec >> 8); // at 75% of the frame time
} else {
ledData[0] = ‘%’; // others sync to the master board
ledData[1] = 0;
ledData[2] = 0;
}*/
// send the raw data to the LEDs ๐
ledSerial[i].write(ledData);}
}int led_map(int input) {
int row = input / LEDS_PER_STRIP;
input %= LEDS_PER_STRIP;int y = input / ( SCREEN_WIDTH );
int x = input % ( SCREEN_WIDTH );if((x%2)==1) {
y = 7-y;
}int output = row * LEDS_PER_STRIP
+ x * PANEL_HEIGHT
+ y;
return output;
}int led_map(int x,int y) {
return led_map(y * SCREEN_WIDTH + x);
}// image2data converts an image to OctoWS2811’s raw data format.
// The number of vertical pixels in the image must be a multiple
// of 8. The data array must be the proper size for the image.
void image2data(PImage image, byte[] data, boolean layout) {
int offset = 0;
int x, y, mask;
int pixel;
int i=0;for (y = 0; y < image.height; y++) {
for (x = 0; x < image.width; x++) {
pixel = image.pixels[i++];
int r = ( pixel ) >> 16;
int g = ( pixel ) >> 8;
int b = ( pixel );
offset = led_map(x,y)*3;
data[offset++] = (byte)(r & 0xfe);
data[offset++] = (byte)(g & 0xfe);
data[offset++] = (byte)(b & 0xfe);
}
}
offset=0;
data[offset++] |= (byte)0x01;
data[offset++] |= (byte)0x01;
data[offset++] |= (byte)0x01;
}// translate the 24 bit color from RGB to the actual
// order used by the LED wiring. GRB is the most common.
int colorWiring(int c) {
int red = (c & 0xFF0000) >> 16;
int green = (c & 0x00FF00) >> 8;
int blue = (c & 0x0000FF);
red = gammatable[red];
green = gammatable[green];
blue = gammatable[blue];
return (green << 16) | (red << 8) | (blue); // GRB – most common wiring
}// ask a Teensy board for its LED configuration, and set up the info for it.
void serialConfigure(String portName) {
if (numPorts >= maxPorts) {
println(“too many serial ports, please increase maxPorts”);
errorCount++;
return;
}
try {
ledSerial[numPorts] = new Serial(this, portName);
if (ledSerial[numPorts] == null) throw new NullPointerException();
ledSerial[numPorts].write(‘?’);
} catch (Throwable e) {
println(“Serial port ” + portName + ” does not exist or is non-functional”);
errorCount++;
return;
}
delay(50);/*
String line = ledSerial[numPorts].readStringUntil(10);
if (line == null) {
println(“Serial port ” + portName + ” is not responding.”);
println(“Is it really a Teensy 3.0 running VideoDisplay?”);
errorCount++;
return;
}
*/
print(“port “+numPorts+”: “);
String line = “32,24,0,0,0,0,0,100,100,0,0,0”;
String param[] = line.split(“,”);
if (param.length != 12) {
println(“Error: port ” + portName + ” did not respond to LED config query”);
errorCount++;
return;
}
// only store the info and increase numPorts if Teensy responds properly
ledImage[numPorts] = new PImage(Integer.parseInt(param[0]), Integer.parseInt(param[1]), RGB);
ledArea[numPorts] = new Rectangle(Integer.parseInt(param[5]), Integer.parseInt(param[6]),
Integer.parseInt(param[7]), Integer.parseInt(param[8]));
ledLayout[numPorts] = (Integer.parseInt(param[5]) == 0);
numPorts++;
}// draw runs every time the screen is redrawn – show the movie…
void draw() {
// show the original video
image(myMovie, 0, 80);// then try to show what was most recently sent to the LEDs
// by displaying all the images for each port.
for (int i=0; i < numPorts; i++) {
// compute the intended size of the entire LED array
int xsize = percentageInverse(ledImage[i].width, ledArea[i].width);
int ysize = percentageInverse(ledImage[i].height, ledArea[i].height);
// computer this image’s position within it
int xloc = percentage(xsize, ledArea[i].x);
int yloc = percentage(ysize, ledArea[i].y);
// show what should appear on the LEDs
image(ledImage[i], 240 – xsize / 2 + xloc, 10 + yloc);
}
}// respond to mouse clicks as pause/play
boolean isPlaying = true;
void mousePressed() {
if (isPlaying) {
myMovie.pause();
isPlaying = false;
} else {
myMovie.play();
isPlaying = true;
}
}// scale a number by a percentage, from 0 to 100
int percentage(int num, int percent) {
double mult = percentageFloat(percent);
double output = num * mult;
return (int)output;
}// scale a number by the inverse of a percentage, from 0 to 100
int percentageInverse(int num, int percent) {
double div = percentageFloat(percent);
double output = num / div;
return (int)output;
}// convert an integer from 0 to 100 to a float percentage
// from 0.0 to 1.0. Special cases for 1/3, 1/6, 1/7, etc
// are handled automatically to fix integer rounding.
double percentageFloat(int percent) {
if (percent == 33) return 1.0 / 3.0;
if (percent == 17) return 1.0 / 6.0;
if (percent == 14) return 1.0 / 7.0;
if (percent == 13) return 1.0 / 8.0;
if (percent == 11) return 1.0 / 9.0;
if (percent == 9) return 1.0 / 11.0;
if (percent == 8) return 1.0 / 12.0;
return (double)percent / 100.0;
}Running on Mac OS X 10.11.4, Processing 3.0.2
Help!!!
2016-09-12 at 19:31 #10871DanKeymasterThanks Dirk. No need to repost the code here. I’ll follow up on Github, which sends me notifications when people post issues there.
-
AuthorPosts
- You must be logged in to reply to this topic.