make Shure prettier

This commit is contained in:
sparks-alec
2022-12-29 10:48:55 -05:00
parent 83ca5aed73
commit e48c982700
3 changed files with 103 additions and 45 deletions
+27 -13
View File
@@ -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>');
};
+41 -8
View File
@@ -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 {
+35 -24
View File
@@ -6,40 +6,51 @@
<% for(let i=1; i<=4; i++){ %> <% let ch = data.channels[i]; %>
<table class="channel">
<tr>
<td colspan="2"><%= i %></td>
<td colspan="3"><small><%= i %></small></td>
</tr>
<tr>
<td colspan="2" class="chan_name"><%= ch.chan_name %></td>
<td colspan="3" class="chan_name"><%= ch.chan_name %></td>
</tr>
<tr>
<td><%= ch.audio_gain %>db</td>
<td><%= ch.audio_lvl %></td>
</tr>
<tr>
<td colspan="2">
<% if(ch.audio_mute=="ON" || ch.tx_mute_button_status=="PRESSED"){ %>
<div class="mute-button red">
<% if(ch.audio_mute=="ON"){ %>
<span>Receiver Muted</span>
<% } %>
<span></span>
<% if(ch.tx_mute_button_status=="PRESSED"){ %>
<span>TRANSMITTER MUTE PRESSED</span>
<% } %>
<td>
<small>rf</small>
<div class="bar-wrapper orange">
<div
class="bar"
style="height: <%= 90- ((ch.rx_rf_lvl + 90) * 2) %>"></div>
</div>
<small><%= ch.rx_rf_lvl %><br />dBm</small>
</td>
<td>
<small>audio</small>
<div class="bar-wrapper green">
<div class="bar" style="height: <%= 90- (ch.audio_lvl * 2) %>"></div>
</div>
<small><%= ch.audio_lvl %><br />dBFS</small>
</td>
<td>
<small>gain</small>
<div class="bar-wrapper pink">
<div class="bar" style="height: <%= 60- (ch.audio_gain * 1.4) %>"></div>
</div>
<small><%= ch.audio_gain %><br />dB</small>
</td>
</tr>
<tr>
<td colspan="3">
<% if(ch.batt_bars==255){ %>
<div class="batt-wrapper"></div>
<% }else{ %>
<div class="mute-button">NOT MUTED</div>
<div class="batt-wrapper green">
<div class="batt-bar" style="width: <%= ch.batt_bars * 16 %>"></div>
</div>
<% } %>
</td>
</tr>
<tr>
<td colspan="2"><small>RF Level</small><br /><%= ch.rx_rf_lvl %>dbm</td>
</tr>
<tr>
<td colspan="2">
<br /><small>Time: </small><%= ch.batt_run_time %> <br /><small
>Health: </small
><%= ch.batt_health %> <br /><small>Temp: </small><%= ch.batt_temp_f %>F
<td colspan="3">
<% if(ch.tx_type=="UNKN"){ %> &nbsp;<small>No Transmitter</small>&nbsp; <%
}else{ %> <%= ch.tx_type %> <% } %>
</td>
</tr>
</table>