Skip to content

Commit

Permalink
Merge pull request #44 from OpenEarable/1.4.0
Browse files Browse the repository at this point in the history
1.4.0
  • Loading branch information
TobiasRoeddiger authored Aug 7, 2024
2 parents a1e3cf4 + e75f36a commit a6cd35f
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 34 deletions.
4 changes: 3 additions & 1 deletion assets/js/OpenEarable.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,9 @@ class SensorManager {
const view = new DataView(data);
view.setUint8(0, sensorId);
view.setFloat32(1, samplingRate, true);
view.setUint32(5, latency, true);
view.setUint32(5, latency, true);
console.log("Writing Sensor Config")
console.log(data)
await this.bleManager.writeCharacteristic(
SERVICES.SENSOR_SERVICE.UUID,
SERVICES.SENSOR_SERVICE.CHARACTERISTICS.SENSOR_CONFIGURATION_CHARACTERISTIC.UUID,
Expand Down
9 changes: 6 additions & 3 deletions assets/js/SensorManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ $(document).ready(function () {
var microphoneSamplingRate = $('#microphoneSamplingRate').val();
log("Setting sampling rate for microphone: " + microphoneSamplingRate + " Hz");
if (openEarable.firmwareVersion === "1.4.0") {
// set gain negative to disable mic
var gainInner = -1;
var gainOuter = -1;
if ($('#innerMicrophoneEnabled').is(':checked')) {
gainInner = $('#microphoneGain').val()
gainInner = $('#microphoneGainInner').val()
}
if ($('#outerMicrophoneEnabled').is(':checked')) {
gainOuter = $('#microphoneGain').val()
gainOuter = $('#microphoneGainOuter').val()
}

// Ensure gain values are in the range of int8 (-128 to 127)
Expand Down Expand Up @@ -72,9 +73,11 @@ $(document).ready(function () {
await openEarable.sensorManager.writeSensorConfig(2, 0, 0);

// Uncheck the checkboxes
$('#areSensorsEnabled, #isMicEnabled, #isPressureSensorEnabled').prop('checked', false);
$('#areSensorsEnabled, #isMicEnabled, #isPressureSensorEnabled, #innerMicrophoneEnabled, #outerMicrophoneEnabled').prop('checked', false);

// Reset the dropdowns to 0
$('#sensorSamplingRate, #microphoneSamplingRate, #pressureSensorSamplingRate').val('0');
$('#microphoneGainInner').val('40');
$('#microphoneGainOuter').val('40');
});
});
76 changes: 46 additions & 30 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ <h5 class="card-title">Device</h5>
<div class="card-text"><b></b><span id="connectedDevice" class=""
style="font-family: monospace;">OpenEarable-XXXX </span> (<span id="batteryLevel"
style="font-family: monospace;">XX</span><span style="font-size: 0.8em;">%<i
id="batteryChargingIndicator" class="bi bi-lightning-charge"></i><i
style="color: #77F2A1"
id="batteryChargedIndicator" class="bi bi-lightning-charge-fill"></i></span>)
id="batteryChargingIndicator" class="bi bi-lightning-charge"></i><i
style="color: #77F2A1" id="batteryChargedIndicator"
class="bi bi-lightning-charge-fill"></i></span>)
</div>
<div class="mt-1"><b>Firmware</b> <span style="font-family: monospace"
id="fwVersion">X.X.X</span> <b class="ms-2">Device</b> <span
Expand All @@ -227,7 +227,7 @@ <h5 class="card-title">Device</h5>
<div class="d-flex flex-row w-100 justify-content-between">
<h5 class="card-title">Sensor Control</h5>
<div class="tooltip-indicator" data-toggle="tooltip"
title="Enable and disable the sensors of OpenEarable. Note that sampling all sensors at the maximum sampling rate can lead to lag and/or audio play issues. Inner / outer microphone and gain control only available with hardware and firmware verison >= 1.4.">
title="Enable and disable the sensors of OpenEarable. Note that sampling all sensors at the maximum sampling rate can lead to lag and/or audio play issues. Inner / outer microphone and gain control (gdB) only available with hardware and firmware verison >= 1.4.">
<div>?</div>
</div>
</div>
Expand Down Expand Up @@ -298,32 +298,42 @@ <h5 class="card-title">Sensor Control</h5>
<option value="41667">41,667</option>
<option value="62500">62,500</option>
</select>

</div>

</div>
<div class="ms-1">Hz</div>



<!-- Fourth Row -->
<div class="1-4-0-controls"></div>
<div class="d-flex flex-row 1-4-0-controls justify-content-between">

<div class="d-flex flex-row 1-4-0-controls">
<div class="1-4-0-controls"></div>
<div class="ms-3 1-4-0-controls"><input id="innerMicrophoneEnabled" type="checkbox" disabled class="is-connect-enabled 1-4-0-controls"></input> Inner</div>
<div class="ms-3 1-4-0-controls"><input id="outerMicrophoneEnabled" type="checkbox" disabled class="is-connect-enabled 1-4-0-controls"></input> Outer</div>
</div>

<div class="1-4-0-controls">Gain</div>
<div class="d-flex flex-row 1-4-0-controls justify-content-between w-100 align-items-center"
style="grid-column: 1 / 5;">
<div class="1-4-0-controls"></div>
<!-- inner mic -->
<input id="innerMicrophoneEnabled" type="checkbox" disabled
class="is-connect-enabled 1-4-0-controls ms-3"></input>
<div class="ms-2 1-4-0-controls">In&nbsp;</div>
<div class="ms-1 1-4-0-controls">gdB</div>
<select disabled
class="is-connect-enabled ms-1 sampling-rate-input form-select 1-4-0-controls "
name="microphoneGainInner" id="microphoneGainInner">

</select>
<!-- outer mic -->
<input id="outerMicrophoneEnabled" type="checkbox" disabled
class="is-connect-enabled 1-4-0-controls ms-3"></input>
<div class="ms-2 1-4-0-controls">Out&nbsp;</div>
<div class="ms-1 1-4-0-controls">gdB</div>
<select disabled
class="is-connect-enabled ms-1 sampling-rate-input form-select 1-4-0-controls "
name="microphoneGainOuter" id="microphoneGainOuter">
</select>
</div>
<select disabled
class="w-100 is-connect-enabled ms-1 sampling-rate-input form-select 1-4-0-controls "
name="microphoneGain" id="microphoneGain">
</select>
<div class="ms-1 1-4-0-controls ">dB</div>





</div>
<!-- Grid Layout Ends Here -->

Expand Down Expand Up @@ -414,7 +424,8 @@ <h5 class="card-title">Audio Control </h5>

<div class="d-flex w-100 justify-content-between align-items-center mt-2">
<div>
<button id="button-set-source" class="btn btn-control is-connect-enabled">Set Source</button>
<button id="button-set-source" class="btn btn-control is-connect-enabled">Set
Source</button>
<button id="button-play-audio" class="btn btn-play btn-block ms-2 is-connect-enabled"
disabled><i class="bi bi-play"></i></button>
<button id="button-pause-audio" class="btn btn-pause btn-block ms-2 is-connect-enabled"
Expand Down Expand Up @@ -697,7 +708,8 @@ <h5 class="card-title">Recorder</h5>
log('Your browser does not support WebBLE. Enable it or download a browser that supports WebBLE (e.g., Chrome version ≥ 56)!', "ERROR");
}

const select = document.getElementById('microphoneGain');
const selectInner = document.getElementById('microphoneGainInner');
const selectOuter = document.getElementById('microphoneGainOuter');
const minDb = -20;
const maxDb = 20;
const step = 0.5;
Expand All @@ -709,12 +721,16 @@ <h5 class="card-title">Recorder</h5>
const option = document.createElement('option');
option.value = linearValue.toFixed(0);
option.textContent = `${db.toFixed(1)}`;
select.appendChild(option);
const option1 = document.createElement('option');
option1.value = linearValue.toFixed(0);
option1.textContent = `${db.toFixed(1)}`;
selectInner.appendChild(option);
selectOuter.appendChild(option1);
}
select.selectedIndex = 40;

selectInner.selectedIndex = 40;
selectOuter.selectedIndex = 40;
});
</script>
</body>

</html>
</html>

0 comments on commit a6cd35f

Please sign in to comment.