Skip to content

Commit 1963aa5

Browse files
Improve connection indicator
1 parent a59e624 commit 1963aa5

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
A dedicated browser-based app for viewing the camera feed from the WPIlib Camera Server on the RoboRIO.
33

44
# Building
5+
You can build the most recent version locally, but the latest release is also available as an executable in the Releases tab.
56
## Windows
67
This project uses the [yarn](https://yarnpkg.com/en/) package manager to handle all dependencies. Simply run `yarn install` to gather all the dependencies, and run `yarn start` to test the app. To build for distribution, simply run `yarn dist` to build a single binary as well as an application installer.
78

@@ -10,6 +11,14 @@ This project uses the [yarn](https://yarnpkg.com/en/) package manager to handle
1011
* The application currently uses the same width, height, and screen position everytime on startup, and is intended for 1080p screens. This can be adjusted by editing the "main.js" file and modifying the arguments passed to the BrowserWindow object creator.
1112
* The camera, when connected, is given a HUD with a simple crosshair to improve precision.
1213

14+
## Connection Indicator
15+
Color | Meaning
16+
--------------------------- | --------------------------------------
17+
Red | Waiting for connection
18+
Green | Connected
19+
Flashing Magenta and Yellow | Previously connected, now disconnected
20+
Yellow | Previously disconnected, now connected
21+
1322
# License
1423
This project is licensed under the MIT License.
1524

index.html

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
const statusIndicator = document.getElementById("status-indicator");
5555
let stCtx = statusIndicator.getContext('2d');
5656
stCtx.canvas.width = 25;
57-
stCtx.canvas.height = 200;
57+
stCtx.canvas.height = 400;
5858

5959
stCtx.fillStyle = "rgb(255, 0, 0)";
6060
stCtx.fillRect(0, 0, stCtx.canvas.width, stCtx.canvas.height);
@@ -77,6 +77,8 @@
7777

7878
let source = "";
7979

80+
let disconnected = false;
81+
8082
// Connect to the camera
8183
(async () => {
8284
let sourceMain = "http://10." + team_ip + ".2:1181"; // IP is team number dependent
@@ -119,10 +121,22 @@
119121

120122
try {
121123
camCtx.drawImage(img, imageX, imageY);
124+
125+
if (disconnected) {
126+
stCtx.fillStyle = "rgb(255, 255, 0)";
127+
stCtx.fillRect(0, 0, stCtx.canvas.width, stCtx.canvas.height);
128+
129+
disconnected = false;
130+
}
122131
} catch {
123132
img.src = source;
124133
console.log(source);
125134
console.log("stream unavailable");
135+
136+
disconnected = true;
137+
138+
stCtx.fillStyle = "rgb(255, 0, 255)";
139+
stCtx.fillRect(0, 0, stCtx.canvas.width, stCtx.canvas.height);
126140
}
127141

128142
camCtx.globalCompositeOperation = "difference";

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"email": "[email protected]",
88
"url": "http://phyxtgears.org"
99
},
10-
"version": "v0.3.0",
10+
"version": "v0.4.0",
1111
"main": "main.js",
1212
"scripts": {
1313
"start": "electron .",

0 commit comments

Comments
 (0)