Mise à jour capteur bruit: ancien I2C → NSRT MK4 USB
- Nouveau script sound_meter/read.py pour lecture à la demande (JSON) - launcher.php: appel du script Python au lieu de l'ancien binaire C - sensors.html: carte USB, suppression boutons start/stop, affichage JSON - Traductions fr/en: I2C → USB, NSRT MK4 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -265,35 +265,43 @@
|
||||
|
||||
|
||||
function getNoise_values() {
|
||||
console.log("Data from I2C Noise Sensor:");
|
||||
console.log("Data from NSRT MK4 Noise Sensor:");
|
||||
$("#loading_noise").show();
|
||||
|
||||
$.ajax({
|
||||
url: 'launcher.php?type=noise',
|
||||
dataType: 'text',
|
||||
method: 'GET', // Use GET or POST depending on your needs
|
||||
dataType: 'json',
|
||||
method: 'GET',
|
||||
success: function (response) {
|
||||
console.log(response);
|
||||
const tableBody = document.getElementById("data-table-body_noise");
|
||||
tableBody.innerHTML = "";
|
||||
$("#loading_noise").hide();
|
||||
|
||||
// Create an array of the desired keys
|
||||
const keysToShow = ["Noise"];
|
||||
// Add only the specified elements to the table
|
||||
keysToShow.forEach(key => {
|
||||
if (response !== undefined) { // Check if the key exists in the response
|
||||
const value = response;
|
||||
$("#data-table-body_noise").append(`
|
||||
<tr>
|
||||
<td>${key}</td>
|
||||
<td>${value} DB</td>
|
||||
</tr>
|
||||
`);
|
||||
}
|
||||
if (response.error) {
|
||||
$("#data-table-body_noise").append(`
|
||||
<tr><td colspan="2" class="text-danger">${response.error}</td></tr>
|
||||
`);
|
||||
return;
|
||||
}
|
||||
|
||||
const rows = [
|
||||
{ label: "LEQ", value: response.LEQ + " dB" },
|
||||
{ label: "dB(A)", value: response.dBA + " dBA" },
|
||||
{ label: "Weighting", value: response.weighting },
|
||||
{ label: "Tau", value: response.tau + " s" }
|
||||
];
|
||||
rows.forEach(row => {
|
||||
$("#data-table-body_noise").append(`
|
||||
<tr>
|
||||
<td>${row.label}</td>
|
||||
<td>${row.value}</td>
|
||||
</tr>
|
||||
`);
|
||||
});
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
$("#loading_noise").hide();
|
||||
console.error('AJAX request failed:', status, error);
|
||||
}
|
||||
});
|
||||
@@ -496,21 +504,18 @@
|
||||
container.innerHTML += i2C_BME_HTML; // Add the I2C card if condition is met
|
||||
}
|
||||
|
||||
//creates i2c sound card
|
||||
//creates NSRT MK4 noise sensor card (USB)
|
||||
if (config.NOISE) {
|
||||
const i2C_HTML = `
|
||||
const noiseHTML = `
|
||||
<div class="col-sm-3">
|
||||
<div class="card">
|
||||
<div class="card-header" data-i18n="sensors.noise.headerI2c">
|
||||
Port I2C
|
||||
<div class="card-header" data-i18n="sensors.noise.headerUsb">
|
||||
Port USB
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h5 class="card-title" data-i18n="sensors.noise.title">Decibel Meter</h5>
|
||||
<p class="card-text" data-i18n="sensors.noise.description">Capteur bruit sur le port I2C.</p>
|
||||
<h5 class="card-title" data-i18n="sensors.noise.title">NSRT MK4</h5>
|
||||
<p class="card-text" data-i18n="sensors.noise.description">Sonomètre NSRT MK4 sur port USB.</p>
|
||||
<button class="btn btn-primary mb-1" onclick="getNoise_values()" data-i18n="common.getData">Get Data</button>
|
||||
<br>
|
||||
<button class="btn btn-success" onclick="startNoise()" data-i18n="common.startRecording">Start recording</button>
|
||||
<button class="btn btn-danger" onclick="stopNoise()" data-i18n="common.stopRecording">Stop recording</button>
|
||||
<div id="loading_noise" class="spinner-border spinner-border-sm" style="display: none;" role="status"></div>
|
||||
<table class="table table-striped-columns">
|
||||
<tbody id="data-table-body_noise"></tbody>
|
||||
@@ -519,7 +524,7 @@
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
container.innerHTML += i2C_HTML; // Add the I2C card if condition is met
|
||||
container.innerHTML += noiseHTML;
|
||||
}
|
||||
|
||||
//creates MH-Z19 CO2 card
|
||||
|
||||
Reference in New Issue
Block a user