From e48c982700c7153eaeef35b218afd6bd81df139a Mon Sep 17 00:00:00 2001 From: sparks-alec Date: Thu, 29 Dec 2022 10:48:55 -0500 Subject: [PATCH] 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 %> <% } %>