From 7fd202a8573a8dbedad38b4803cc759bc10d9f1b Mon Sep 17 00:00:00 2001 From: kitschpatrol Date: Sat, 18 Jan 2014 18:51:06 -0500 Subject: [PATCH] Add packet received counter. --- BrainGrapher.pde | 2 +- ConnectionLight.pde | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/BrainGrapher.pde b/BrainGrapher.pde index 6f6d868..5b87e1e 100644 --- a/BrainGrapher.pde +++ b/BrainGrapher.pde @@ -83,7 +83,7 @@ void setup() { graph = new Graph(0, 0, width, height / 2); // Set yup the connection light - connectionLight = new ConnectionLight(width - 105, 10, 20); + connectionLight = new ConnectionLight(width - 140, 10, 20); } void draw() { diff --git a/ConnectionLight.pde b/ConnectionLight.pde index 9979bb3..407c0d3 100644 --- a/ConnectionLight.pde +++ b/ConnectionLight.pde @@ -8,6 +8,7 @@ class ConnectionLight { int badColor = color(255, 255, 0); int noColor = color(255, 0, 0); Textlabel label; + Textlabel packetsRecievedLabel; ConnectionLight(int _x, int _y, int _diameter) { x = _x; @@ -15,9 +16,13 @@ class ConnectionLight { diameter = _diameter; // Set up the text label - label = new Textlabel(controlP5, "CONNECTION QUALITY", 32, 6, 60, 30); + label = new Textlabel(controlP5, "CONNECTION QUALITY", 32, 11, 200, 30); label.setMultiline(true); label.setColorValue(color(0)); + + packetsRecievedLabel = new Textlabel(controlP5, "PACKETS RECEIVED: 0", 5, 35, 200, 30); + packetsRecievedLabel.setMultiline(false); + packetsRecievedLabel.setColorValue(color(0)); } void update() { @@ -32,6 +37,9 @@ class ConnectionLight { if (latestConnectionValue == 200) currentColor = noColor; if (latestConnectionValue < 200) currentColor = badColor; if (latestConnectionValue == 00) currentColor = goodColor; + + packetsRecievedLabel.setText("PACKETS RECIEVED: " + packetCount); + } void draw() { @@ -40,14 +48,15 @@ class ConnectionLight { noStroke(); fill(255, 150); - rect(0, 0, 95, 28); + rect(0, 0, 132, 50); noStroke(); fill(currentColor); ellipseMode(CORNER); ellipse(5, 4, diameter, diameter); - label.draw(); + label.draw(); + packetsRecievedLabel.draw(); popMatrix(); } }