We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hey! I was able to get this code to work on two computers, but it's not working at all when I try to run the sketch independent of the browser on my tablet. I'm wondering if this has something to do with the port number or android mode?
Here is the code on my tablet:
import oscP5.*;
import netP5.*;
Buttons button1;
Buttons button2;
OscP5 oscP5;
NetAddress myRemoteLocation;
void setup() {
size(600,800);
frameRate(25);
/* start oscP5, listening for incoming messages at port 12000 */
oscP5 = new OscP5(this,12000);
myRemoteLocation = new NetAddress("192.168.1.179",12000);
button1 = new Buttons();
button1.x = 100;
button1.y = 100;
button1.w = 100;
button1.h = 100;
button2 = new Buttons();
button2.x = 250;
button2.y = 100;
button2.w = 100;
button2.h = 100;
}
void draw() {
background(0);
rectMode(CENTER);
fill(squareColor, 0, 0);
button1.display("hello");
button2.display("fractured");
}
void mousePressed() {
button1.clicked("hello");
button2.clicked("testing");
}
void clicked(String wordMessage){
float d = dist(x, y, mouseX, mouseY);
if (d < 50) {
boxBackground = 255;
OscMessage myMessage = new OscMessage(wordMessage);
oscP5.send(myMessage, myRemoteLocation);
println(myMessage);
}
Here is the code on my computer:
import oscP5.*;
import netP5.*;
int circleColor = 200;
OscP5 oscP5;
NetAddress myRemoteLocation;
void setup() {
size(400,400);
frameRate(25);
oscP5 = new OscP5(this,12000);
myRemoteLocation = new NetAddress("192.168.1.128",12000);
}
void draw() {
background(0);
rectMode(CENTER);
fill(circleColor, 0, 0);
ellipse(width/2, height/2, 100, 100);
}
void oscEvent(OscMessage theOscMessage) {
print("### received an osc message.");
//print(" addrpattern: "+theOscMessage.addrPattern());
println(" typetag: "+theOscMessage.typetag());
if(theOscMessage.checkAddrPattern("poopin")==true) {
println("it worked!");
} else if (theOscMessage.checkAddrPattern("hello")==true) {
println("yay, it worked!");
}
}
Answers
The Button in your tablet code is a class that you defined yourself? Is that code located in another tab?
I will suggest doing the following modification in your tablet code:
This would make more sense but it will not work as yet because of the conditional placed inside your Clicked() function, line 57. It would be important to see how you implement your Button class to be able to get your code work properly.
Kf
Thanks so much for your comment! Yes, the button is located in another tab, sorry I missed that. Thanks for looking at that and your suggestion.
I'm realizing that issue is perhaps with android mode, as I'm unable to get the emulator running, and getting this series of errors.
I don't have much experience with emulators. I understand you need to have them running before you execute any processing code. I would suggest making sure you have your emulator working first before trying to work in this task. For example, use a simpler example that you know it works on a real device. Regarding your code, it will help if you post your entire code.
Kf