Skip to content

Commit be773d0

Browse files
committed
git commit -m "Initial commit for meeting status indicator"
0 parents  commit be773d0

File tree

9 files changed

+175
-0
lines changed

9 files changed

+175
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
blog_post/

.vscode/arduino.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"port": "COM3",
3+
"board": "adafruit:nrf52:cplaynrf52840",
4+
"configuration": "softdevice=s140v6,debug=l1",
5+
"sketch": "arduino\\Blink\\Blink.ino"
6+
}

.vscode/c_cpp_properties.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Win32",
5+
"includePath": [
6+
"C:\\Users\\matth\\AppData\\Local\\Arduino15\\packages\\adafruit\\tools\\**",
7+
"C:\\Users\\matth\\AppData\\Local\\Arduino15\\packages\\adafruit\\hardware\\nrf52\\0.19.0\\**"
8+
],
9+
"forcedInclude": [],
10+
"intelliSenseMode": "msvc-x64",
11+
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe",
12+
"cStandard": "c11",
13+
"cppStandard": "c++17"
14+
}
15+
],
16+
"version": 4
17+
}

arduino/Blink/Blink.ino

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
*/
3+
4+
#include <Adafruit_NeoPixel.h>
5+
6+
#define PIN 8
7+
#define NUMPIXELS 10
8+
#define DELAYVAL 100 // Time (in milliseconds) to pause between pixels
9+
10+
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
11+
12+
char receivedChar;
13+
boolean newData = false;
14+
uint32_t available = pixels.Color(0, 50, 0);
15+
uint32_t busy = pixels.Color(50, 0, 0);
16+
17+
// the setup function runs once when you press reset or power the board
18+
void setup() {
19+
// initialize digital pin LED_BUILTIN as an output.
20+
Serial.begin(9600);
21+
Serial.println("<Arduino is ready>");
22+
pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
23+
}
24+
25+
void loop() {
26+
recvOneChar();
27+
showNewData();
28+
}
29+
30+
void recvOneChar() {
31+
if (Serial.available() > 0) {
32+
receivedChar = Serial.read();
33+
newData = true;
34+
}
35+
}
36+
37+
void showNewData() {
38+
if (newData == true) {
39+
pixels.clear(); // Set all pixel colors to 'off'
40+
Serial.print("This just in ... ");
41+
Serial.println(receivedChar);
42+
43+
bool shouldUpdate = false;
44+
uint32_t newColor;
45+
46+
if (receivedChar == 'n') {
47+
digitalWrite(LED_BUILTIN, HIGH);
48+
newColor = busy;
49+
shouldUpdate = true;
50+
} else if (receivedChar == 'f') {
51+
digitalWrite(LED_BUILTIN, LOW);
52+
newColor = available;
53+
shouldUpdate = true;
54+
}
55+
newData = false;
56+
if (shouldUpdate) {
57+
for (int i = 0; i < NUMPIXELS; i++) { // For each pixel...
58+
59+
// pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255
60+
// Here we're using a moderately bright green color:
61+
pixels.setPixelColor(i, newColor);
62+
63+
pixels.show(); // Send the updated pixel colors to the hardware.
64+
65+
delay(DELAYVAL); // Pause before next pass through loop
66+
}
67+
}
68+
}
69+
}

arduino/Blink/code.py

Whitespace-only changes.

chrome_extension/background.js

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
'use strict';
2+
3+
const HANGOUTS_PREFIX = "https://hangouts.google.com/call/";
4+
const DEFAULT_SIGN_ENDPOINT = "http://192.168.1.22:5000";
5+
6+
function handleRemovedTab(tabId, existingHangouts, signEndpoint) {
7+
const tabIdx = existingHangouts.indexOf(tabId);
8+
if (tabIdx >= 0) {
9+
existingHangouts.splice(tabIdx)
10+
if (existingHangouts.length === 0) {
11+
fetch(signEndpoint + "/off", {
12+
mode: "no-cors"
13+
});
14+
}
15+
}
16+
}
17+
18+
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
19+
if (changeInfo.url) {
20+
chrome.storage.local.get(null, (value) => {
21+
const existingHangouts = value ? value.hangouts || [] : [];
22+
const signEndpoint = value ? value.endpoint || DEFAULT_SIGN_ENDPOINT : DEFAULT_SIGN_ENDPOINT;
23+
if (changeInfo.url.startsWith(HANGOUTS_PREFIX)) {
24+
if (existingHangouts.length === 0) {
25+
fetch(signEndpoint + "/on", {
26+
mode: "no-cors"
27+
});
28+
}
29+
existingHangouts.push(tabId);
30+
} else {
31+
handleRemovedTab(tabId, existingHangouts, signEndpoint);
32+
}
33+
chrome.storage.local.set({hangouts: Array.from(new Set(existingHangouts))});
34+
});
35+
}
36+
});
37+
38+
chrome.tabs.onRemoved.addListener((tabId) => {
39+
chrome.storage.local.get(null, (value) => {
40+
const existingHangouts = value ? value.hangouts || [] : [];
41+
const signEndpoint = value ? value.endpoint || DEFAULT_SIGN_ENDPOINT : DEFAULT_SIGN_ENDPOINT;
42+
handleRemovedTab(tabId, existingHangouts, signEndpoint);
43+
chrome.storage.local.set({hangouts: existingHangouts});
44+
});
45+
});

chrome_extension/manifest.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "Meeting Status Notifier",
3+
"version": "1.0",
4+
"description": "notify people of the meeting status",
5+
"permissions": ["tabs", "storage"],
6+
"background" : {
7+
"scripts": ["background.js"],
8+
"persistent": false
9+
},
10+
"browser_action": {
11+
"default_popup": "popup.html"
12+
},
13+
"manifest_version": 2
14+
}

chrome_extension/popup.html

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
</head>
5+
<body>
6+
<input type="text" id="endpoint">
7+
<button id="setEndpoint">Set Endpoint</button>
8+
<script src="popup.js"></script>
9+
</body>
10+
</html>

chrome_extension/popup.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
let setEndpoint = document.getElementById('setEndpoint');
2+
let endpointElement = document.getElementById('endpoint');
3+
4+
setEndpoint.onclick = () => {
5+
let endpoint = endpointElement.value;
6+
chrome.storage.local.set({endpoint: endpoint});
7+
};
8+
9+
chrome.storage.local.get(null, (data)=>{
10+
if (data && data.endpoint) {
11+
endpointElement.innerText = data.endpoint;
12+
}
13+
})

0 commit comments

Comments
 (0)