Skip to content

Commit 7fd202a

Browse files
committed
Add packet received counter.
1 parent b3b347e commit 7fd202a

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

BrainGrapher.pde

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void setup() {
8383
graph = new Graph(0, 0, width, height / 2);
8484

8585
// Set yup the connection light
86-
connectionLight = new ConnectionLight(width - 105, 10, 20);
86+
connectionLight = new ConnectionLight(width - 140, 10, 20);
8787
}
8888

8989
void draw() {

ConnectionLight.pde

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,21 @@ class ConnectionLight {
88
int badColor = color(255, 255, 0);
99
int noColor = color(255, 0, 0);
1010
Textlabel label;
11+
Textlabel packetsRecievedLabel;
1112

1213
ConnectionLight(int _x, int _y, int _diameter) {
1314
x = _x;
1415
y = _y;
1516
diameter = _diameter;
1617

1718
// Set up the text label
18-
label = new Textlabel(controlP5, "CONNECTION QUALITY", 32, 6, 60, 30);
19+
label = new Textlabel(controlP5, "CONNECTION QUALITY", 32, 11, 200, 30);
1920
label.setMultiline(true);
2021
label.setColorValue(color(0));
22+
23+
packetsRecievedLabel = new Textlabel(controlP5, "PACKETS RECEIVED: 0", 5, 35, 200, 30);
24+
packetsRecievedLabel.setMultiline(false);
25+
packetsRecievedLabel.setColorValue(color(0));
2126
}
2227

2328
void update() {
@@ -32,6 +37,9 @@ class ConnectionLight {
3237
if (latestConnectionValue == 200) currentColor = noColor;
3338
if (latestConnectionValue < 200) currentColor = badColor;
3439
if (latestConnectionValue == 00) currentColor = goodColor;
40+
41+
packetsRecievedLabel.setText("PACKETS RECIEVED: " + packetCount);
42+
3543
}
3644

3745
void draw() {
@@ -40,14 +48,15 @@ class ConnectionLight {
4048

4149
noStroke();
4250
fill(255, 150);
43-
rect(0, 0, 95, 28);
51+
rect(0, 0, 132, 50);
4452

4553
noStroke();
4654
fill(currentColor);
4755
ellipseMode(CORNER);
4856
ellipse(5, 4, diameter, diameter);
4957

50-
label.draw();
58+
label.draw();
59+
packetsRecievedLabel.draw();
5160
popMatrix();
5261
}
5362
}

0 commit comments

Comments
 (0)