From 09f396c85347cd922fc93cd2d638a4af6f918a3c Mon Sep 17 00:00:00 2001 From: sparks-alec Date: Thu, 29 Dec 2022 08:01:09 -0500 Subject: [PATCH 01/14] initial commit adding Shure Wireless --- plugins/shure/icon.png | Bin 0 -> 3793 bytes plugins/shure/info.html | 0 plugins/shure/main.js | 111 +++++++++++++++++++++++++++++++++++++ plugins/shure/styles.css | 34 ++++++++++++ plugins/shure/template.ejs | 47 ++++++++++++++++ src/device.js | 2 +- 6 files changed, 193 insertions(+), 1 deletion(-) create mode 100644 plugins/shure/icon.png create mode 100644 plugins/shure/info.html create mode 100644 plugins/shure/main.js create mode 100644 plugins/shure/styles.css create mode 100644 plugins/shure/template.ejs diff --git a/plugins/shure/icon.png b/plugins/shure/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..1ef31f09495a10210ad2e38edc00404d2182d9e8 GIT binary patch literal 3793 zcmc&%dsGu=79T{YqF9QG(G?hi>!UcC$>cpIQbV)^i6XL!E8ERvW&(rBOqdK1T(wGt zqKl8JZGBIJb)}+Wt*EEEJwB?7b$8ubA8V@>$L#zx&ByIn2@~`D~31vw6~(0ycfVz|5RKEr*&v zk228m)QM3>9{~W|j7Y*hw~O-R*5YC${K?E=? zjF%EvkI3>IEMbxkzF0KL^hdSWz$vgN+&y$pGw*Ri~c6al}D^4x}Oaxi& z=1#{3-kdTIgJv^czF44`$t8e}~Q)?o%@l3zt)jj&39nGBaN764Q1F~Mw>e*C=@ zj;mNIh+l9l@CffT$?cSxZiTdYA&2K(Cix_((cr9(dV+DK0*A-iNQ&j83LEF&Ub3=*hM`H34DEs=N*uxU zIk=M0=n16;!8BcW0YtLSvR-Q2Y=niUilt(=S~|Lv<|&pYI`d<2XjK|DrU%hsDnw&Y zYY~H9M}sAe8Jv_(>!hg;cLAW4^NJ)#F%lpMK*0hqT(8loRZ1;_YaJ>?t)sLEiE9mr zTBFxsj8m(k9EL6s(*+ic8`9O)HwlUcPzj7gf{`R)uuq_mRy%d1)}TXFjM9myflmmjSJ4Qr#%LW$YIPc2pmTy4 z{L}J>N<*|G)^ye@@yI#K)udkOB$LbVl%+EmuW zoh&#-%L0cOjKjDBQv}Bl3kSGA>Fe z&917d&bA+JY-nz1gpb;f!CThn<+aFSS{fI}gA;ziCz0~uGR3#$r!rdG%Fg|6?}A5h z+T9z3SwAQA-+u~~W)v3TXJv!nxnp+d4Z}`o!#-F$V0p&kTYcfV`wqSX9o+)aza0`5 z-;YMaJ~)?jD;_S1UAi!G*XU6vhM!mj(E~g%)YEZT8%}Z;}FOOYqzR^~Ga{H<8t79XY z%F8$BMBHfms{D&J=jHJcXAaV)_=x22wD8qL)`hg{MrXP-g)vI3t>%aJ_PdkY+uMIN@Wb{&;f+g1LSYXJD~w0-zXX3I`g_vncp+%OVCe~i zHg1+dP@hDrWl~Q1vfE$Us%%BFrh8`&+&MVJX8FteRoOTD{dLE#gLKT)Y1+8hi@&@u zqeMG+z_^ccH?MGHu3PbX#c^|focX)BS((leq;uu5_JliMjrQKHnJ}yM^5)jm8^(oa zTEBaFOX{8Do*Xz=hZHGqb~7AU2%Qlyytws&ujIJnP106 zF0P1F<~=`)O+b%)GrTgcrGLWiraR-Rr`&UIY2+ducfN?q8ZRo4pt zafztDRM&s%J;-ETcgWS}(Z0fS#y?iBjlQ(%Yi+H((H_ebPu`YOoC+_kfA007z6brb+;Jay8lGH2rm=!zUE=r1CF zcO6aG+)x?U@XXm7%f+UT%^Ut!G~q$i!#|JDe9vH8{7ljKW%XA-Hm|o_JTvO#9r8`= zQ0>;lLTZQVkVrO@#>XfBVYXWfi<7+-1xHxuhqSJ`P;Td zxnt{V@i!>z+LkHnt`FTp&G|zg?pVo&jN~I(4=YZ`&RV}AdD`CN6(v8`)hmW>+hSeS z}7tuYMR~tW3IA)e8KYzIH+DfeTGY g>;96c=6BEXzZp`!JB51BBK;G!PM&6|HQUSo4XJYdD*ylh literal 0 HcmV?d00001 diff --git a/plugins/shure/info.html b/plugins/shure/info.html new file mode 100644 index 0000000..e69de29 diff --git a/plugins/shure/main.js b/plugins/shure/main.js new file mode 100644 index 0000000..7811d00 --- /dev/null +++ b/plugins/shure/main.js @@ -0,0 +1,111 @@ +const _ = require('lodash'); + +exports.config = { + defaultName: 'Shure Wireless', + connectionType: 'TCPsocket', + heartbeatInterval: 10000, + heartbeatTimeout: 15000, + defaultPort: 2202, + mayChangePort: false, + searchOptions: { + type: 'UDPsocket', + searchBuffer: Buffer.from([0x25, 0x32, 0x53, 0x52, 0x43, 0x48, 0x0d]), + devicePort: 4352, + listenPort: 4352, + validateResponse(msg, info) { + console.log(msg.toString()); + return msg.toString().indexOf('%2ACKN=') >= 0; + }, + }, +}; + +let blankChannel = { + chan_name: '?', + batt_bars: '', + batt_charge: '', + batt_cycle: '', + batt_health: '', + batt_run_time: '', + batt_temp_c: '', + batt_temp_f: '', + batt_type: '', + audio_gain: '', + audio_mute: '', + tx_mute_button_status: '', + audio_lvl: 0, + rx_rf_lvl: 0, +}; + +exports.ready = function ready(device) { + device.data.channels = [ + {}, + _.clone(blankChannel), + _.clone(blankChannel), + _.clone(blankChannel), + _.clone(blankChannel), + ]; +}; + +exports.data = function data(device, message) { + let msgStr = message.toString(); + + if (!msgStr.startsWith('< ')) { + return; + } + + msgStr = msgStr.slice(2).slice(0, -1); + let msgs = msgStr.split('><'); + + msgs.forEach((msg, i) => { + msg = msg.trim(); + let m = msg.split(' '); + + // console.log(msg); + + let ch = device.data.channels[Number(m[1])]; + + //console.log(m); + + if (m[0] == 'REP') { + if (m[2] == 'CHAN_NAME') { + ch.chan_name = msg.substring(17).slice(0, -2).trim(); + } else if (m[2] == 'BATT_RUN_TIME') { + ch.batt_run_time = Number(m[3]); + } else if (m[2] == 'BATT_TEMP_F') { + ch.batt_temp_f = Number(m[3]); + } else if (m[2] == 'BATT_HEALTH') { + ch.batt_health = Number(m[3]); + } else if (m[2] == 'AUDIO_GAIN') { + ch.audio_gain = Number(m[3]); + } else if (m[2] == 'AUDIO_MUTE') { + ch.audio_mute = m[3]; + } else if (m[2] == 'TX_MUTE_BUTTON_STATUS') { + ch.tx_mute_button_status = m[3]; + } else if (m[2] == 'AUDIO_LVL') { + ch.audio_lvl = Number(m[3]); + } else if (m[2] == 'RX_RF_LVL') { + ch.rx_rf_lvl = Number(m[3]); + } else if (m[2] == 'RF_ANTENNA') { + ch.rf_antenna = m[3]; + } else if (m[1] == 'DEVICE_ID') { + let id = msg.substring(15).slice(0, -1).trim(); + this.deviceInfoUpdate(device, 'defaultName', id); + } else if (m[1] == 'FW_VER') { + device.data.version = m[2].substring(1); + } + } else if (m[0] == 'SAMPLE') { + ch.rf_antenna = m[3]; + ch.rx_rf_lvl = Number(m[4]); + ch.audio_lvl = Number(m[5]); + } + }); + + device.draw(); +}; + +exports.heartbeat = function heartbeat(device) { + device.send('< GET 0 ALL >'); + device.send('< GET MODEL >'); + //device.send('< SET 0 METER_RATE 00000 >'); + //device.send('< SAMPLE 0 AUDIO_LVL>'); +}; diff --git a/plugins/shure/styles.css b/plugins/shure/styles.css new file mode 100644 index 0000000..3d7dc92 --- /dev/null +++ b/plugins/shure/styles.css @@ -0,0 +1,34 @@ +table.channel { + width: 120px; + height: 400px; + background-color: black; + border: gray 1px solid; + border-collapse: collapse; + color: white; + text-align: center; + float: left; +} +table td { + border: #666 1px solid; +} + +.chan_name { + width: 100px; + color: #b2ff33 !important; + font-size: 18px; + font-weight: bold; +} + +.mute-button { + background-color: #222; + padding: 10px; + margin: 5px; + border-radius: 4px; +} +.mute-button.red { + background-color: red; +} + +small { + color: gray; +} diff --git a/plugins/shure/template.ejs b/plugins/shure/template.ejs new file mode 100644 index 0000000..01ae442 --- /dev/null +++ b/plugins/shure/template.ejs @@ -0,0 +1,47 @@ +
+

<%= listName %>

+

<%= data.version || "" %>

+
+ +<% for(let i=1; i<=4; i++){ %> <% let ch = data.channels[i]; %> + + + + + + + + + + + + + + + + + + + + +
<%= i %>
<%= ch.chan_name %>
<%= ch.audio_gain %>db<%= ch.audio_lvl %>
+ <% if(ch.audio_mute=="ON" || ch.tx_mute_button_status=="PRESSED"){ %> +
+ <% if(ch.audio_mute=="ON"){ %> + Receiver Muted + <% } %> + + <% if(ch.tx_mute_button_status=="PRESSED"){ %> + TRANSMITTER MUTE PRESSED + <% } %> +
+ <% }else{ %> +
NOT MUTED
+ <% } %> +
RF Level
<%= ch.rx_rf_lvl %>dbm
+
Time: <%= ch.batt_run_time %>
Health: <%= ch.batt_health %>
Temp: <%= ch.batt_temp_f %>F +
+ +<% } %> diff --git a/src/device.js b/src/device.js index db4e67c..754fecf 100644 --- a/src/device.js +++ b/src/device.js @@ -232,7 +232,7 @@ module.exports.deleteActive = function deleteActive() { module.exports.changeActiveType = function changeActiveType(newType) { const device = VIEW.getActiveDevice(); device.type = newType; - device.fields = {}; + device.fields = []; device.plugin = PLUGINS.all[newType]; if (PLUGINS.all[device.type].config.fields) { From 83ca5aed7336828abb665986a5cd1cd541d9c1b0 Mon Sep 17 00:00:00 2001 From: sparks-alec Date: Thu, 29 Dec 2022 09:12:15 -0500 Subject: [PATCH 02/14] add search by TCP port --- plugins/shure/main.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/plugins/shure/main.js b/plugins/shure/main.js index 7811d00..b9f37ac 100644 --- a/plugins/shure/main.js +++ b/plugins/shure/main.js @@ -8,13 +8,11 @@ exports.config = { defaultPort: 2202, mayChangePort: false, searchOptions: { - type: 'UDPsocket', - searchBuffer: Buffer.from([0x25, 0x32, 0x53, 0x52, 0x43, 0x48, 0x0d]), - devicePort: 4352, - listenPort: 4352, + type: 'TCPport', + searchBuffer: Buffer.from('< GET DEVICE_ID >', 'ascii'), + testPort: 3032, validateResponse(msg, info) { - console.log(msg.toString()); - return msg.toString().indexOf('%2ACKN=') >= 0; + return msg.toString().indexOf('DEVICE_ID'); }, }, }; From e48c982700c7153eaeef35b218afd6bd81df139a Mon Sep 17 00:00:00 2001 From: sparks-alec Date: Thu, 29 Dec 2022 10:48:55 -0500 Subject: [PATCH 03/14] make Shure prettier --- plugins/shure/main.js | 40 +++++++++++++++++--------- plugins/shure/styles.css | 49 +++++++++++++++++++++++++------ plugins/shure/template.ejs | 59 ++++++++++++++++++++++---------------- 3 files changed, 103 insertions(+), 45 deletions(-) diff --git a/plugins/shure/main.js b/plugins/shure/main.js index b9f37ac..f63b0e6 100644 --- a/plugins/shure/main.js +++ b/plugins/shure/main.js @@ -15,11 +15,22 @@ exports.config = { return msg.toString().indexOf('DEVICE_ID'); }, }, + fields: [ + { + key: 'chanCount', + label: 'Chan', + type: 'textinput', + value: '4', + action(device) { + // device.plugin.heartbeat(device); + }, + }, + ], }; -let blankChannel = { +const blankChannel = { chan_name: '?', - batt_bars: '', + batt_bars: 255, batt_charge: '', batt_cycle: '', batt_health: '', @@ -52,17 +63,17 @@ exports.data = function data(device, message) { } msgStr = msgStr.slice(2).slice(0, -1); - let msgs = msgStr.split('><'); + const msgs = msgStr.split('><'); msgs.forEach((msg, i) => { msg = msg.trim(); - let m = msg.split(' '); + const m = msg.split(' '); // console.log(msg); - let ch = device.data.channels[Number(m[1])]; + const ch = device.data.channels[Number(m[1])]; - //console.log(m); + // console.log(m); if (m[0] == 'REP') { if (m[2] == 'CHAN_NAME') { @@ -73,8 +84,10 @@ exports.data = function data(device, message) { ch.batt_temp_f = Number(m[3]); } else if (m[2] == 'BATT_HEALTH') { ch.batt_health = Number(m[3]); + } else if (m[2] == 'BATT_BARS') { + ch.batt_bars = Number(m[3]); } else if (m[2] == 'AUDIO_GAIN') { - ch.audio_gain = Number(m[3]); + ch.audio_gain = Number(m[3]) - 18; } else if (m[2] == 'AUDIO_MUTE') { ch.audio_mute = m[3]; } else if (m[2] == 'TX_MUTE_BUTTON_STATUS') { @@ -82,18 +95,20 @@ exports.data = function data(device, message) { } else if (m[2] == 'AUDIO_LVL') { ch.audio_lvl = Number(m[3]); } else if (m[2] == 'RX_RF_LVL') { - ch.rx_rf_lvl = Number(m[3]); + ch.rx_rf_lvl = Number(m[3]) - 128; } else if (m[2] == 'RF_ANTENNA') { ch.rf_antenna = m[3]; + } else if (m[2] == 'TX_TYPE') { + ch.tx_type = m[3]; } else if (m[1] == 'DEVICE_ID') { - let id = msg.substring(15).slice(0, -1).trim(); + const id = msg.substring(15).slice(0, -1).trim(); this.deviceInfoUpdate(device, 'defaultName', id); } else if (m[1] == 'FW_VER') { device.data.version = m[2].substring(1); } } else if (m[0] == 'SAMPLE') { ch.rf_antenna = m[3]; - ch.rx_rf_lvl = Number(m[4]); + ch.rx_rf_lvl = Number(m[4]) - 128; ch.audio_lvl = Number(m[5]); } }); @@ -103,7 +118,6 @@ exports.data = function data(device, message) { exports.heartbeat = function heartbeat(device) { device.send('< GET 0 ALL >'); - device.send('< GET MODEL >'); - //device.send('< SET 0 METER_RATE 00000 >'); - //device.send('< SAMPLE 0 AUDIO_LVL>'); + device.send('< SET 0 METER_RATE 00200 >'); + device.send('< SAMPLE 0 AUDIO_LVL>'); }; diff --git a/plugins/shure/styles.css b/plugins/shure/styles.css index 3d7dc92..ccc51c5 100644 --- a/plugins/shure/styles.css +++ b/plugins/shure/styles.css @@ -1,12 +1,14 @@ table.channel { width: 120px; - height: 400px; + height: 300px; background-color: black; border: gray 1px solid; border-collapse: collapse; color: white; text-align: center; float: left; + margin: 2px; + margin-bottom: 20px; } table td { border: #666 1px solid; @@ -19,14 +21,45 @@ table td { font-weight: bold; } -.mute-button { - background-color: #222; - padding: 10px; - margin: 5px; - border-radius: 4px; +.bar-wrapper { + width: 20px; + height: 90px; + margin: 0px auto; + + border-radius: 7px; + border: #111 1px solid; + overflow: hidden; } -.mute-button.red { - background-color: red; +.bar-wrapper.green { + background: linear-gradient(0deg, greenyellow, yellow 80%, red); +} +.bar-wrapper.pink { + background: linear-gradient(0deg, hotpink, hotpink 80%, red); +} +.bar-wrapper.orange { + background: linear-gradient(0deg, orange, yellow 80%); +} +.bar { + width: 20px; + background-color: #333; + border-bottom: white 1px solid; +} + +.batt-wrapper { + width: 84px; + height: 35px; + margin: 0px auto; + border: #333 2px solid; + border-radius: 5px; + padding: 2px; +} +.batt-wrapper.green { + border-color: greenyellow; +} +.batt-bar { + height: 100%; + background-color: greenyellow; + border-radius: 2px; } small { diff --git a/plugins/shure/template.ejs b/plugins/shure/template.ejs index 01ae442..cdae973 100644 --- a/plugins/shure/template.ejs +++ b/plugins/shure/template.ejs @@ -6,40 +6,51 @@ <% for(let i=1; i<=4; i++){ %> <% let ch = data.channels[i]; %> - + - + - - - - - + + + + + - - - -
<%= i %><%= i %>
<%= ch.chan_name %><%= ch.chan_name %>
<%= ch.audio_gain %>db<%= ch.audio_lvl %>
- <% if(ch.audio_mute=="ON" || ch.tx_mute_button_status=="PRESSED"){ %> -
- <% if(ch.audio_mute=="ON"){ %> - Receiver Muted - <% } %> - - <% if(ch.tx_mute_button_status=="PRESSED"){ %> - TRANSMITTER MUTE PRESSED - <% } %> +
+ rf +
+
+ <%= ch.rx_rf_lvl %>
dBm
+
+ audio +
+
+
+ <%= ch.audio_lvl %>
dBFS
+
+ gain +
+
+
+ <%= ch.audio_gain %>
dB
+
+ <% if(ch.batt_bars==255){ %> +
<% }else{ %> -
NOT MUTED
+
+
+
<% } %>
RF Level
<%= ch.rx_rf_lvl %>dbm
-
Time: <%= ch.batt_run_time %>
Health: <%= ch.batt_health %>
Temp: <%= ch.batt_temp_f %>F +
+ <% if(ch.tx_type=="UNKN"){ %>  No Transmitter  <% + }else{ %> <%= ch.tx_type %> <% } %>
From 075f6370d45bf9c11cdf1a0af76489a583e0510d Mon Sep 17 00:00:00 2001 From: sparks-alec Date: Thu, 29 Dec 2022 12:17:56 -0500 Subject: [PATCH 04/14] style tweaks --- plugins/shure/styles.css | 2 ++ plugins/shure/template.ejs | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/shure/styles.css b/plugins/shure/styles.css index ccc51c5..059175d 100644 --- a/plugins/shure/styles.css +++ b/plugins/shure/styles.css @@ -25,6 +25,8 @@ table td { width: 20px; height: 90px; margin: 0px auto; + margin-top: 5px; + margin-bottom: 5px; border-radius: 7px; border: #111 1px solid; diff --git a/plugins/shure/template.ejs b/plugins/shure/template.ejs index cdae973..3698419 100644 --- a/plugins/shure/template.ejs +++ b/plugins/shure/template.ejs @@ -3,7 +3,7 @@

<%= data.version || "" %>

-<% for(let i=1; i<=4; i++){ %> <% let ch = data.channels[i]; %> +<% for(let i=1; i<=data.channelCount; i++){ %> <% let ch = data.channels[i]; %> @@ -19,21 +19,21 @@ class="bar" style="height: <%= 90- ((ch.rx_rf_lvl + 90) * 2) %>"> - <%= ch.rx_rf_lvl %>
dBm
+ <%= ch.rx_rf_lvl %>
dBm
From a89d48106b55c64606856a3c0b956687dc981487 Mon Sep 17 00:00:00 2001 From: sparks-alec Date: Thu, 29 Dec 2022 12:18:10 -0500 Subject: [PATCH 05/14] delint --- plugins/shure/main.js | 73 +++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 40 deletions(-) diff --git a/plugins/shure/main.js b/plugins/shure/main.js index f63b0e6..13f2134 100644 --- a/plugins/shure/main.js +++ b/plugins/shure/main.js @@ -15,17 +15,6 @@ exports.config = { return msg.toString().indexOf('DEVICE_ID'); }, }, - fields: [ - { - key: 'chanCount', - label: 'Chan', - type: 'textinput', - value: '4', - action(device) { - // device.plugin.heartbeat(device); - }, - }, - ], }; const blankChannel = { @@ -45,7 +34,9 @@ const blankChannel = { rx_rf_lvl: 0, }; -exports.ready = function ready(device) { +exports.ready = function ready(_device) { + const device = _device; + device.data.channelCount = 0; device.data.channels = [ {}, _.clone(blankChannel), @@ -55,7 +46,8 @@ exports.ready = function ready(device) { ]; }; -exports.data = function data(device, message) { +exports.data = function data(_device, message) { + const device = _device; let msgStr = message.toString(); if (!msgStr.startsWith('< ')) { @@ -65,59 +57,60 @@ exports.data = function data(device, message) { msgStr = msgStr.slice(2).slice(0, -1); const msgs = msgStr.split('><'); - msgs.forEach((msg, i) => { - msg = msg.trim(); + msgs.forEach((ms, i) => { + const msg = ms.trim(); const m = msg.split(' '); + const chi = Number(m[1]); + const ch = device.data.channels[chi]; - // console.log(msg); - - const ch = device.data.channels[Number(m[1])]; - - // console.log(m); - - if (m[0] == 'REP') { - if (m[2] == 'CHAN_NAME') { + if (m[0] === 'REP') { + if (m[2] === 'CHAN_NAME') { ch.chan_name = msg.substring(17).slice(0, -2).trim(); - } else if (m[2] == 'BATT_RUN_TIME') { + if (device.data.channelCount < chi) { + device.data.channelCount = chi; + } + device.draw(); + } else if (m[2] === 'BATT_RUN_TIME') { ch.batt_run_time = Number(m[3]); - } else if (m[2] == 'BATT_TEMP_F') { + } else if (m[2] === 'BATT_TEMP_F') { ch.batt_temp_f = Number(m[3]); - } else if (m[2] == 'BATT_HEALTH') { + } else if (m[2] === 'BATT_HEALTH') { ch.batt_health = Number(m[3]); - } else if (m[2] == 'BATT_BARS') { + } else if (m[2] === 'BATT_BARS') { ch.batt_bars = Number(m[3]); - } else if (m[2] == 'AUDIO_GAIN') { + } else if (m[2] === 'AUDIO_GAIN') { ch.audio_gain = Number(m[3]) - 18; - } else if (m[2] == 'AUDIO_MUTE') { + } else if (m[2] === 'AUDIO_MUTE') { ch.audio_mute = m[3]; - } else if (m[2] == 'TX_MUTE_BUTTON_STATUS') { + } else if (m[2] === 'TX_MUTE_BUTTON_STATUS') { ch.tx_mute_button_status = m[3]; - } else if (m[2] == 'AUDIO_LVL') { + } else if (m[2] === 'AUDIO_LVL') { ch.audio_lvl = Number(m[3]); - } else if (m[2] == 'RX_RF_LVL') { + } else if (m[2] === 'RX_RF_LVL') { ch.rx_rf_lvl = Number(m[3]) - 128; - } else if (m[2] == 'RF_ANTENNA') { + } else if (m[2] === 'RF_ANTENNA') { ch.rf_antenna = m[3]; - } else if (m[2] == 'TX_TYPE') { + } else if (m[2] === 'TX_TYPE') { ch.tx_type = m[3]; - } else if (m[1] == 'DEVICE_ID') { + } else if (m[1] === 'DEVICE_ID') { const id = msg.substring(15).slice(0, -1).trim(); this.deviceInfoUpdate(device, 'defaultName', id); - } else if (m[1] == 'FW_VER') { + } else if (m[1] === 'FW_VER') { device.data.version = m[2].substring(1); } - } else if (m[0] == 'SAMPLE') { + } else if (m[0] === 'SAMPLE') { ch.rf_antenna = m[3]; ch.rx_rf_lvl = Number(m[4]) - 128; ch.audio_lvl = Number(m[5]); + if (chi === 4) { + device.draw(); + } } }); - - device.draw(); }; exports.heartbeat = function heartbeat(device) { device.send('< GET 0 ALL >'); - device.send('< SET 0 METER_RATE 00200 >'); + device.send('< SET 0 METER_RATE 00100 >'); device.send('< SAMPLE 0 AUDIO_LVL>'); }; From b222617745800e11154e7c7e2af882215e6a87d9 Mon Sep 17 00:00:00 2001 From: sparks-alec Date: Thu, 29 Dec 2022 12:41:38 -0500 Subject: [PATCH 06/14] remove unavailable vars --- plugins/shure/main.js | 49 ++++++++++++++----------------------------- 1 file changed, 16 insertions(+), 33 deletions(-) diff --git a/plugins/shure/main.js b/plugins/shure/main.js index 13f2134..88e1e23 100644 --- a/plugins/shure/main.js +++ b/plugins/shure/main.js @@ -20,18 +20,11 @@ exports.config = { const blankChannel = { chan_name: '?', batt_bars: 255, - batt_charge: '', - batt_cycle: '', - batt_health: '', - batt_run_time: '', - batt_temp_c: '', - batt_temp_f: '', - batt_type: '', - audio_gain: '', - audio_mute: '', - tx_mute_button_status: '', + audio_gain: 0, audio_lvl: 0, rx_rf_lvl: 0, + rf_antenna: 0, + tx_type: 0, }; exports.ready = function ready(_device) { @@ -70,29 +63,19 @@ exports.data = function data(_device, message) { device.data.channelCount = chi; } device.draw(); - } else if (m[2] === 'BATT_RUN_TIME') { - ch.batt_run_time = Number(m[3]); - } else if (m[2] === 'BATT_TEMP_F') { - ch.batt_temp_f = Number(m[3]); - } else if (m[2] === 'BATT_HEALTH') { - ch.batt_health = Number(m[3]); - } else if (m[2] === 'BATT_BARS') { - ch.batt_bars = Number(m[3]); - } else if (m[2] === 'AUDIO_GAIN') { - ch.audio_gain = Number(m[3]) - 18; - } else if (m[2] === 'AUDIO_MUTE') { - ch.audio_mute = m[3]; - } else if (m[2] === 'TX_MUTE_BUTTON_STATUS') { - ch.tx_mute_button_status = m[3]; - } else if (m[2] === 'AUDIO_LVL') { - ch.audio_lvl = Number(m[3]); - } else if (m[2] === 'RX_RF_LVL') { - ch.rx_rf_lvl = Number(m[3]) - 128; - } else if (m[2] === 'RF_ANTENNA') { - ch.rf_antenna = m[3]; - } else if (m[2] === 'TX_TYPE') { - ch.tx_type = m[3]; - } else if (m[1] === 'DEVICE_ID') { + } else if (msgParts[2] === 'BATT_BARS') { + channel.batt_bars = Number(msgParts[3]); + } else if (msgParts[2] === 'AUDIO_GAIN') { + channel.audio_gain = Number(msgParts[3]) - 18; + } else if (msgParts[2] === 'AUDIO_LVL') { + channel.audio_lvl = Number(msgParts[3]); + } else if (msgParts[2] === 'RX_RF_LVL') { + channel.rx_rf_lvl = Number(msgParts[3]) - 128; + } else if (msgParts[2] === 'RF_ANTENNA') { + channel.rf_antenna = msgParts[3]; + } else if (msgParts[2] === 'TX_TYPE') { + channel.tx_type = msgParts[3]; + } else if (msgParts[1] === 'DEVICE_ID') { const id = msg.substring(15).slice(0, -1).trim(); this.deviceInfoUpdate(device, 'defaultName', id); } else if (m[1] === 'FW_VER') { From cb51bfaf728501a52bbd4b9079ec559ab83feb8e Mon Sep 17 00:00:00 2001 From: sparks-alec Date: Thu, 29 Dec 2022 12:41:45 -0500 Subject: [PATCH 07/14] improve clarity --- plugins/shure/main.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/plugins/shure/main.js b/plugins/shure/main.js index 88e1e23..9836a89 100644 --- a/plugins/shure/main.js +++ b/plugins/shure/main.js @@ -52,15 +52,15 @@ exports.data = function data(_device, message) { msgs.forEach((ms, i) => { const msg = ms.trim(); - const m = msg.split(' '); - const chi = Number(m[1]); - const ch = device.data.channels[chi]; + const msgParts = msg.split(' '); + const channelNumber = Number(msgParts[1]); + const channel = device.data.channels[channelNumber]; - if (m[0] === 'REP') { - if (m[2] === 'CHAN_NAME') { - ch.chan_name = msg.substring(17).slice(0, -2).trim(); - if (device.data.channelCount < chi) { - device.data.channelCount = chi; + if (msgParts[0] === 'REP') { + if (msgParts[2] === 'CHAN_NAME') { + channel.chan_name = msg.substring(17).slice(0, -2).trim(); + if (device.data.channelCount < channelNumber) { + device.data.channelCount = channelNumber; } device.draw(); } else if (msgParts[2] === 'BATT_BARS') { @@ -78,14 +78,14 @@ exports.data = function data(_device, message) { } else if (msgParts[1] === 'DEVICE_ID') { const id = msg.substring(15).slice(0, -1).trim(); this.deviceInfoUpdate(device, 'defaultName', id); - } else if (m[1] === 'FW_VER') { - device.data.version = m[2].substring(1); + } else if (msgParts[1] === 'FW_VER') { + device.data.version = msgParts[2].substring(1); } - } else if (m[0] === 'SAMPLE') { - ch.rf_antenna = m[3]; - ch.rx_rf_lvl = Number(m[4]) - 128; - ch.audio_lvl = Number(m[5]); - if (chi === 4) { + } else if (msgParts[0] === 'SAMPLE') { + channel.rf_antenna = msgParts[3]; + channel.rx_rf_lvl = Number(msgParts[4]) - 128; + channel.audio_lvl = Number(msgParts[5]); + if (channelNumber === 4) { device.draw(); } } From f8aad4785829be654f76cf022ce344976e847ec3 Mon Sep 17 00:00:00 2001 From: sparks-alec Date: Tue, 3 Jan 2023 23:05:20 -0500 Subject: [PATCH 08/14] accept templates inside HTML style attributes --- .vscode/settings.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index eb83d0e..3c1a1bb 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,5 +4,6 @@ "editor.codeActionsOnSave": { "source.fixAll.eslint": true }, - "eslint.validate": ["javascript"] + "eslint.validate": ["javascript"], + "html.validate.styles": false // accept templates inside HTML style attributes } From af0e1eb8b8931217e163eef87c8b690e8ce870b7 Mon Sep 17 00:00:00 2001 From: sparks-alec Date: Tue, 3 Jan 2023 23:51:23 -0500 Subject: [PATCH 09/14] make prettier --- plugins/shure/styles.css | 47 ++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/plugins/shure/styles.css b/plugins/shure/styles.css index 059175d..8e8a336 100644 --- a/plugins/shure/styles.css +++ b/plugins/shure/styles.css @@ -1,8 +1,8 @@ table.channel { width: 120px; height: 300px; - background-color: black; - border: gray 1px solid; + background-color: #1a1a1d; + border: #3b3c42 1px solid; border-collapse: collapse; color: white; text-align: center; @@ -11,7 +11,7 @@ table.channel { margin-bottom: 20px; } table td { - border: #666 1px solid; + border: #3b3c42 1px solid; } .chan_name { @@ -28,23 +28,24 @@ table td { margin-top: 5px; margin-bottom: 5px; - border-radius: 7px; - border: #111 1px solid; + border-radius: 6px; + outline: #1a1a1d 2px solid; + outline-offset: -1px; overflow: hidden; } .bar-wrapper.green { - background: linear-gradient(0deg, greenyellow, yellow 80%, red); + background: linear-gradient(0deg, #4742af, #554ed4 30%, #554ed4 80%, #df664d); } .bar-wrapper.pink { - background: linear-gradient(0deg, hotpink, hotpink 80%, red); + background: linear-gradient(0deg, #383943, #4e505d 40%); } .bar-wrapper.orange { - background: linear-gradient(0deg, orange, yellow 80%); + background: linear-gradient(0deg, #50c3c3, #5bdfe0 30%, #5bdfe0 80%); } .bar { width: 20px; - background-color: #333; - border-bottom: white 1px solid; + background-color: #202124; + outline: rgba(255, 255, 255, 0.1) 1px solid; } .batt-wrapper { @@ -54,16 +55,34 @@ table td { border: #333 2px solid; border-radius: 5px; padding: 2px; + position: relative; } .batt-wrapper.green { border-color: greenyellow; } -.batt-bar { - height: 100%; - background-color: greenyellow; +.batt-knob { + background-color: #333; + position: absolute; + right: -5px; + top: 10px; + width: 5px; + height: 16px; border-radius: 2px; } +.batt-knob.green { + background-color: greenyellow; +} +.batt-bar { + height: 26px; + background: linear-gradient(0deg, rgb(145, 220, 33), greenyellow 100%); + border-radius: 2px; + color: #1a1a1d; + padding-top: 9px; +} small { - color: gray; + color: dimgray; +} +small small { + color: #444; } From 1b6a3ce1b4b817ee59f2d53240d5eeaae12e91e0 Mon Sep 17 00:00:00 2001 From: sparks-alec Date: Tue, 3 Jan 2023 23:51:39 -0500 Subject: [PATCH 10/14] add runtime for transmitters that support it --- plugins/shure/template.ejs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/shure/template.ejs b/plugins/shure/template.ejs index 3698419..d76a786 100644 --- a/plugins/shure/template.ejs +++ b/plugins/shure/template.ejs @@ -39,10 +39,14 @@ From 9f9fc8cca22727c8d43ff333704849b523897e43 Mon Sep 17 00:00:00 2001 From: sparks-alec Date: Tue, 3 Jan 2023 23:51:49 -0500 Subject: [PATCH 11/14] add runtime for transmitters that support it --- plugins/shure/main.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/shure/main.js b/plugins/shure/main.js index 9836a89..7f9e42d 100644 --- a/plugins/shure/main.js +++ b/plugins/shure/main.js @@ -20,6 +20,7 @@ exports.config = { const blankChannel = { chan_name: '?', batt_bars: 255, + batt_run_time: 65535, audio_gain: 0, audio_lvl: 0, rx_rf_lvl: 0, @@ -65,6 +66,8 @@ exports.data = function data(_device, message) { device.draw(); } else if (msgParts[2] === 'BATT_BARS') { channel.batt_bars = Number(msgParts[3]); + } else if (msgParts[2] === 'BATT_RUN_TIME') { + channel.batt_run_time = Number(msgParts[3]); } else if (msgParts[2] === 'AUDIO_GAIN') { channel.audio_gain = Number(msgParts[3]) - 18; } else if (msgParts[2] === 'AUDIO_LVL') { From b5e93cb5ce433c31ec9da88f19bf934a7c0160bd Mon Sep 17 00:00:00 2001 From: sparks-alec Date: Wed, 4 Jan 2023 00:52:17 -0500 Subject: [PATCH 12/14] smarter updates, fewer full draws --- plugins/shure/main.js | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/plugins/shure/main.js b/plugins/shure/main.js index 7f9e42d..da84e6b 100644 --- a/plugins/shure/main.js +++ b/plugins/shure/main.js @@ -3,8 +3,8 @@ const _ = require('lodash'); exports.config = { defaultName: 'Shure Wireless', connectionType: 'TCPsocket', - heartbeatInterval: 10000, - heartbeatTimeout: 15000, + heartbeatInterval: 30000, + heartbeatTimeout: 35000, defaultPort: 2202, mayChangePort: false, searchOptions: { @@ -78,6 +78,7 @@ exports.data = function data(_device, message) { channel.rf_antenna = msgParts[3]; } else if (msgParts[2] === 'TX_TYPE') { channel.tx_type = msgParts[3]; + device.draw(); } else if (msgParts[1] === 'DEVICE_ID') { const id = msg.substring(15).slice(0, -1).trim(); this.deviceInfoUpdate(device, 'defaultName', id); @@ -89,12 +90,48 @@ exports.data = function data(_device, message) { channel.rx_rf_lvl = Number(msgParts[4]) - 128; channel.audio_lvl = Number(msgParts[5]); if (channelNumber === 4) { - device.draw(); + device.update('updateSample', { + channels: device.data.channels, + }); } } }); }; +exports.update = function update(device, doc, updateType, data) { + for (let i = 1; i < data.channels.length; i++) { + const channel = data.channels[i]; + + const $rf = doc.getElementById(`ch-${i}-rf`); + if ($rf) { + $rf.style.height = 90 - (channel.rx_rf_lvl + 90) * 2; + } + + const $audio = doc.getElementById(`ch-${i}-audio`); + if ($audio) { + $audio.style.height = 90 - channel.audio_lvl * 2; + } + + const $rfA = doc.getElementById(`ch-${i}-a`); + const $rfB = doc.getElementById(`ch-${i}-b`); + + if ($rfA) { + if (channel.rf_antenna.charAt(0) === 'A') { + $rfA.style.color = '#53c3c3'; + } else { + $rfA.style.color = '#333'; + } + } + if ($rfB) { + if (channel.rf_antenna.charAt(1) === 'B') { + $rfB.style.color = '#53c3c3'; + } else { + $rfB.style.color = '#333'; + } + } + } +}; + exports.heartbeat = function heartbeat(device) { device.send('< GET 0 ALL >'); device.send('< SET 0 METER_RATE 00100 >'); From 7eeec9bc502cf55cf69dde9030b6325487e2e594 Mon Sep 17 00:00:00 2001 From: sparks-alec Date: Wed, 4 Jan 2023 00:52:34 -0500 Subject: [PATCH 13/14] add rf antenna A/B indicators --- plugins/shure/styles.css | 15 ++++++++++++++- plugins/shure/template.ejs | 18 ++++++++++++++---- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/plugins/shure/styles.css b/plugins/shure/styles.css index 8e8a336..c7a46b0 100644 --- a/plugins/shure/styles.css +++ b/plugins/shure/styles.css @@ -1,6 +1,6 @@ table.channel { width: 120px; - height: 300px; + height: 320px; background-color: #1a1a1d; border: #3b3c42 1px solid; border-collapse: collapse; @@ -12,6 +12,7 @@ table.channel { } table td { border: #3b3c42 1px solid; + vertical-align: top; } .chan_name { @@ -55,6 +56,7 @@ table td { border: #333 2px solid; border-radius: 5px; padding: 2px; + margin: 10px auto; position: relative; } .batt-wrapper.green { @@ -80,6 +82,17 @@ table td { padding-top: 9px; } +.rf-indicator-wrapper { + line-height: 8px; + margin-bottom: 4px; + font-size: 6px; + padding-top: 4px; + letter-spacing: 1px; +} +.rf-indicator { + color: #333; +} + small { color: dimgray; } diff --git a/plugins/shure/template.ejs b/plugins/shure/template.ejs index d76a786..d989f75 100644 --- a/plugins/shure/template.ejs +++ b/plugins/shure/template.ejs @@ -12,23 +12,33 @@ - - -
<%= i %> audio
- <%= ch.audio_lvl %>
dBFS
+ <%= ch.audio_lvl %>
dBFS
gain
- <%= ch.audio_gain %>
dB
+ <%= ch.audio_gain %>
dB
<% if(ch.batt_bars==255){ %> -
+
<% }else{ %>
-
+
+ <% if(ch.batt_run_time<=65532){ %> <%= Math.floor(ch.batt_run_time/60) + %>: <%= ch.batt_run_time%60 %> <% } %> +
+
<% } %>
<%= ch.chan_name %>
+ +
+ + +
rf
<%= ch.rx_rf_lvl %>
dBm
+ +
 
audio
-
+
<%= ch.audio_lvl %>
dBFS
+ +
 
gain
From ce2d493216141a9f51af79347cab30dc0ff13d2d Mon Sep 17 00:00:00 2001 From: Joel Wetzell Date: Wed, 4 Jan 2023 08:53:11 -0600 Subject: [PATCH 14/14] move channel to class --- plugins/shure/channel.js | 14 ++++++++++++++ plugins/shure/main.js | 21 +++++---------------- 2 files changed, 19 insertions(+), 16 deletions(-) create mode 100644 plugins/shure/channel.js diff --git a/plugins/shure/channel.js b/plugins/shure/channel.js new file mode 100644 index 0000000..dbdaf05 --- /dev/null +++ b/plugins/shure/channel.js @@ -0,0 +1,14 @@ +class Channel { + constructor() { + this.chan_name = '?'; + this.batt_bars = 255; + this.batt_run_time = 65535; + this.audio_gain = 0; + this.audio_lvl = 0; + this.rx_rf_lvl = 0; + this.rf_antenna = 0; + this.tx_type = 0; + } +} + +module.exports = Channel; diff --git a/plugins/shure/main.js b/plugins/shure/main.js index da84e6b..047411c 100644 --- a/plugins/shure/main.js +++ b/plugins/shure/main.js @@ -1,4 +1,4 @@ -const _ = require('lodash'); +const Channel = require('./channel'); exports.config = { defaultName: 'Shure Wireless', @@ -17,26 +17,15 @@ exports.config = { }, }; -const blankChannel = { - chan_name: '?', - batt_bars: 255, - batt_run_time: 65535, - audio_gain: 0, - audio_lvl: 0, - rx_rf_lvl: 0, - rf_antenna: 0, - tx_type: 0, -}; - exports.ready = function ready(_device) { const device = _device; device.data.channelCount = 0; device.data.channels = [ {}, - _.clone(blankChannel), - _.clone(blankChannel), - _.clone(blankChannel), - _.clone(blankChannel), + new Channel(), + new Channel(), + new Channel(), + new Channel(), ]; };