Skip to content

Instantly share code, notes, and snippets.

@narner
Created July 24, 2017 12:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save narner/cde902cd7451f9a7b2590dc16433425f to your computer and use it in GitHub Desktop.
Save narner/cde902cd7451f9a7b2590dc16433425f to your computer and use it in GitHub Desktop.
ORIGINAL sketch
import processing.net.*; // include the networking library
Server server; // will receive predictions from ESP
String messageText;
PFont f;
void setup()
{
fullScreen();
//size(200,200);
server = new Server(this, 5204); // listen on port 5204
messageText = "";
f = createFont("Arial",16,true); // Arial, 16 point, anti-aliasing on
}
void draw()
{
// check for incoming data
Client client = server.available();
if (client != null) {
// check for a full line of incoming data
String line = client.readStringUntil('\n');
if (line != null) {
println(line);
int val = int(trim(line)); // extract the predicted class
println(val);
if (val == 1) {
messageText = "VAL 1";
} else if (val == 2) {
messageText = "VAL 2";
} else if (val == 3) {
messageText = "VAL 3";
}
}
}
// draw
background(0);
textFont(f,64);
fill(255);
textAlign(CENTER);
text(messageText, width/2, height/2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment