Skip to content

Commit

Permalink
Add packet received counter.
Browse files Browse the repository at this point in the history
  • Loading branch information
kitschpatrol committed Jan 18, 2014
1 parent b3b347e commit 7fd202a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion BrainGrapher.pde
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
15 changes: 12 additions & 3 deletions ConnectionLight.pde
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,21 @@ 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;
y = _y;
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() {
Expand All @@ -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() {
Expand All @@ -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();
}
}
Expand Down

0 comments on commit 7fd202a

Please sign in to comment.