 |
WiiLi.org a new revolution
|
| View previous topic :: View next topic |
| Author |
Message |
SilentShaddow
Joined: 10 Feb 2008 Posts: 33
Digg It |
Posted: Sun Feb 17, 2008 7:57 pm Post subject: Need help with Java and the wiimote. |
|
|
Basically im looking to do some programming in java. This would be really basic and run from the Command Prompt as I dont know any GUI stuff.
Basically I want to load the the different remote inputs in to java as variable and then from there I can manage. This is my lighting desk project, I will then manipulate the numbers to suitable outputs and try and work out how to send the info to DMX(the signal used to control lights)
How do I get the information into my java script?
Silent
p.s my GlovePIE isnt working ive posted about that, but i do have wii remote libary and wiinremote working well for me. |
|
| Back to top |
|
 |
SilentShaddow
Joined: 10 Feb 2008 Posts: 33
Digg It |
Posted: Sun Feb 17, 2008 10:55 pm Post subject: |
|
|
Perhaps I should expand a little more, this is the kind of thing im after with the gaps filled in and corrected...
/**
* Name: DMXControl
* Program to control lights with the wiimote
* Silent Shaddow
* 17th Feb
*/
import java.text.*;
import java.util.*;
public class DMXControl
{
public static void main (String [] args)
{
Scanner sc = new Scanner (System.in);
int channel_number=0;
channel_number = sc.nextFloat ();
System.out.println("select number of channels")
float [] DMX = new float [512]; /* DMX has 512 channels each with a value between 0and 255 that controls the lights*/
<some form of loading the values from the controller>
for(int count=1; count<=0;count++)
do{
<some form of loading the values from the controller>
<Normalising the data using mostly arrays>
<Converting data from the normalised inputs to the outputs of the DMX arrays>
for(int w=0;w<=channel_number;w++);
{
system.out.print(" "+DMX[w]);
}
system.out.print("/n/n")
<send values to DMX>
}while(buttonb!=0);
}
}
You get the idea, same sort of basis as GlovePIE but in java which is more suitable if I want to get help from other locations and it actually works on my computer....
The plan is to create an infinite loop in which the program constantly checks for the pressing of 'b' which unlocks the controlling of the light. Then command prompt would read a stream of number going down which is fine, as thats all I need to understand what the lights are doing.
The current state of my wiimote is that it connects to my computer and works fine with lots of different programs such as wiinremote and virtual whiteboard. I'm not using blue soliel as the wiimote works fine with out it and id rather not have to make it work.
@chaos ive been looking at your wiiremoteJ which looks like just what I need... ... in there somewhere and am in no way close to really understanding whats going on. My java abilities have yet to venture outside the single class 'main'. This is becuase im a maths student and so had to do some Java in my first year of Uni, the actual data handling and the turning round into usable DMX will be fine for me on my own
If it works, I promise a 'wiibot' type video. except better because they only had one bot... ... I have access to huge amount of lights and have some fun plans, please help!
Who needs a £8000 lighting desk? Ive a wiimote and java
some many lights that one time I when I went overboard, and puts lots up that when I turned the main breaker on, I tripped the power out for the university. |
|
| Back to top |
|
 |
Cha0s Site Admin
Joined: 17 Jan 2007 Posts: 421
Digg It |
Posted: Mon Feb 18, 2008 3:31 am Post subject: |
|
|
Well, basically, I recommend you look at the sample class WRLImpl. If you have any questions, feel free to ask. I think this is what you're looking for though (note, simple hackish code. You probably want a try-catch instead of having main throw an Exception and you might want to make the listener a separate class, depending on how much code is involved ):
| Code: | public static void main(String args[]) throws Exception
{
WiiRemote remote = WiiRemoteJ.findRemote();
remote.setLEDIlluminated(0, true);
WiiRemoteAdapter listener = new WiiRemoteAdapter()
{
public void buttonInputReceived(WRButtonEvent evt)
{
if (evt.wasPressed(WRButtonEvent.B));//do something!
}
}
remote.addWiiRemoteListener(listener);
} |
There are ways to get multiple remotes besides calling findRemote() a million times. I recommend you browse the API and see if that helps at all. Good luck with your project and please keep us up to date on how it's going. _________________ Cha0s |
|
| Back to top |
|
 |
SilentShaddow
Joined: 10 Feb 2008 Posts: 33
Digg It |
Posted: Mon Feb 18, 2008 4:22 am Post subject: |
|
|
it can't find "symbol - class WiiRemote,"
which is confusing me no end I will admit, it seems to be in your API but I cant find it elsewhere or can find out how to target it. It seems to be something to do with "import java.lang.Object.*;" but apart from adding that statement I dont know what to do...
Also how do I load data into a variable that I know what im doing with? for example floats and doubles and ints? an example of a statment would be very useful.
Also, I guess whilst im here that I should express my concern if data is returned in hexidecimal form... :S If it is then I dont know how to handle it, preferably a statement converting it into decimals would be nice.
Silent
Last edited by SilentShaddow on Mon Feb 18, 2008 4:52 am; edited 1 time in total |
|
| Back to top |
|
 |
Cha0s Site Admin
Joined: 17 Jan 2007 Posts: 421
Digg It |
Posted: Mon Feb 18, 2008 4:52 am Post subject: |
|
|
You need these at the beginning of your code:
| Code: | import wiiremotej.*;
import wiiremotej.event.*; |
As for loading data into a variable... what do you mean? Where are you loading it from?
P.S. I'm moving this to the WiiRemoteJ forum, since it has become WiiRemoteJ-specific.
P.P.S. Did you get an implementation of JSR-82 as specified in the README? _________________ Cha0s |
|
| Back to top |
|
 |
SilentShaddow
Joined: 10 Feb 2008 Posts: 33
Digg It |
Posted: Mon Feb 18, 2008 5:10 am Post subject: |
|
|
Im taking the values from the WiiremoteJ and assigning them to values in an array (after some manipulation)
I think I have a JSR-82, but I dont know as im using a non standard bluetooth stack (the one that came on my usb dongle, all other programs work fine....)
So I add those 2 statements at the top with my lang.Math import statement as well. When I compile, it doesnt find package wiiremotej
I perhaps I should point that my experience in java hasnt gone beyond the class 'main' and have never used anything outside of it apart from java.lang.Math.*; and java.util.*; which seem hard to get wrong.
I do really need to beaten over the head with I_ACCELEROMETER etc, in the main classas I dont know anything about anything that goes on outside that class... ...I dont know, im feeling like im not getting very far... perhaps I should tell you the lighting side and it would all be done quicker... :S
Last edited by SilentShaddow on Mon Feb 18, 2008 5:28 am; edited 1 time in total |
|
| Back to top |
|
 |
mharkus
Joined: 15 Jan 2008 Posts: 7
Digg It |
Posted: Mon Feb 18, 2008 5:27 am Post subject: |
|
|
Hi Silent,
Looks like a classpath problem. Your code should look something like:
| Code: |
import wiiremotej.*;
import wiiremotej.event.*;
public class MyClass{
public static void main(String args[]) throws Exception
{
WiiRemote remote = WiiRemoteJ.findRemote();
remote.setLEDIlluminated(0, true);
WiiRemoteAdapter listener = new WiiRemoteAdapter()
{
public void buttonInputReceived(WRButtonEvent evt)
{
if (evt.wasPressed(WRButtonEvent.B));//do something!
}
};
remote.addWiiRemoteListener(listener);
}
}
|
and you need to specify your WiiRemoteJ.jar in the classpath switch which looks like:
| Code: |
javac -classpath WiiRemoteJ.jar MyClass.java
|
in this case, WiiRemoteJ.jar sits beside your MyClass.java
Hope this helps.
Marc |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|