Skip to content

Commit

Permalink
app optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
fra589 committed Jul 4, 2024
1 parent febb9bd commit b7f6c8c
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 43 deletions.
Binary file modified FreeCAD/WeThermicDev.FCStd
Binary file not shown.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,16 @@ release: firmware littlefs
cp $(FIRMWARE) $(RELEASES)/WeThermic.firmware.$(VERSION).bin
cp $(LITTLEFS) $(RELEASES)/WeThermic.application.$(VERSION).bin

# flash_firmware : flash le programme et efface les credentials wifi (erase_region 0x3FC000 0x4000)
flash_firmware: firmware
$(ESPTOOL) --chip $(CHIP) --port $(PORT) --baud $(BAUD) erase_region 0x3FC000 0x4000
$(ESPTOOL) --chip $(CHIP) --port $(PORT) --baud $(BAUD) write_flash --flash_size detect 0x0 $(FIRMWARE)

flash_littlefs: littlefs
$(ESPTOOL) --chip $(CHIP) --port $(PORT) --baud $(BAUD) write_flash --flash_size detect 0x200000 $(LITTLEFS)

flash: firmware littlefs
$(ESPTOOL) --chip $(CHIP) --port $(PORT) --baud $(BAUD) write_flash --flash_size detect 0x0 $(FIRMWARE) 0x200000 $(LITTLEFS)
$(ESPTOOL) --chip $(CHIP) --port $(PORT) --baud $(BAUD) write_flash --flash_size detect --erase-all 0x0 $(FIRMWARE) 0x200000 $(LITTLEFS)

clean:
rm -rf WeThermic/build/*
Expand Down
2 changes: 1 addition & 1 deletion WeThermic/WeThermic.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
#define APP_NAME "WeThermic"
#define APP_VERSION_MAJOR "0"
#define APP_VERSION_MINOR "9"
#define APP_VERSION_DATE "20240605"
#define APP_VERSION_DATE "20240704"
#define APP_VERSION_STRING "v" APP_VERSION_MAJOR "." APP_VERSION_MINOR "." APP_VERSION_DATE
#define APP_NAME_VERSION APP_NAME " - " APP_VERSION_STRING "\0"

Expand Down
Empty file removed WeThermic/build/vide.txt
Empty file.
4 changes: 3 additions & 1 deletion WeThermic/data.src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
<div id="fullScreenButton" onclick="toggleFullscreen()"><br />View in full screen<br />&nbsp;</div>
<hr />
<p>
<span id="bottomSSID"></span><br />
WeThermic <span id="version">v0.0.00000000</span> - Copyright © Gauthier Brière (<a href="https://github.com/fra589">fra589</a>) - 2024-2024
</p>
<!--------------------------------------------------------------------------------------->
Expand Down Expand Up @@ -102,12 +103,13 @@ <h1>Settings :</h1>
<p class="leftAlign">
<input type="checkbox" id="showT1" name="showT1" onclick="visuCourbes();" checked />
<label for="showT1">Show CTN temperature</label>
&nbsp;
<!--&nbsp;
<input type="checkbox" id="showPressL" name="showPressL" onclick="visuCourbes();" />
<label for="showPressL">Show atmospheric pressure</label>
&nbsp;
<input type="checkbox" id="showT2" name="showT2" onclick="visuCourbes();" />
<label for="showT2">Show BMP180 temperature</label>
-->
</p>
<p class="leftAlign">
Temperature scale:&nbsp;
Expand Down
85 changes: 62 additions & 23 deletions WeThermic/data.src/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ var largeurMoyTemp = 180; // Moyenne sur 1 minute 30s
// Visibilité des courbes
var showWind = true;
var showT1 = true;
var showT2 = false;
/*var showT2 = false;*/
var showPressU = true;
var showPressL = false;
/*var showPressL = false;*/
var showPressGrid = false;
// Autre
var soundOn = true;
Expand All @@ -42,7 +42,8 @@ var soundOn = true;


// pour debug du developpement, adresse IP de la Wemos connectée au wifi
var netDevURL = 'http://192.168.1.107'; // domopassaduy
var netDevURL = 'http://192.168.1.107'; // domopassaduy GB1
//var netDevURL = 'http://192.168.1.80'; // domopassaduy GB2
//var netDevURL = 'http://192.168.1.68'; // BlancheNeige
//var netDevURL = 'http://192.168.1.60'; // La Gouffrerie
//var netDevURL = 'http://192.168.8.111'; // Cohabit
Expand All @@ -66,9 +67,9 @@ var couleurGrid = 'rgb(63, 63, 63)';
var couleurVent = 'rgb(0, 0, 160)';
var couleurFillVent = 'rgba(0, 0, 160, 0.3)';
var couleurMoyVent = 'rgb(0, 0, 200)';
var couleurPression = 'rgb(0, 80, 120)';
var couleurFillPression = 'rgba(0, 80, 120, 0.2)';
var couleurMoyPres = 'rgb(0, 80, 80)';
var couleurPression = 'rgb(0, 140, 32)';
var couleurFillPression = 'rgba(0, 140, 32, 0.2)';
var couleurMoyPres = 'rgb(0, 80, 32)';
var couleurTempBmp180 = 'rgb(0, 150, 0)';
var couleurMoyBmp180 = 'rgb(0, 127, 0)';
var couleurTempCtn = 'rgb(230, 0, 0)';
Expand All @@ -85,9 +86,11 @@ var histTCtnMoy = new Array();
var tempctn = 0.0;
var ctnSuggestedMax = 0.0;
var ctnSuggestedMin = 0.0;
/*
var histBmp180Data = new Array();
histBmp180Moy = new Array();
var tempBmp180 = 0.0;
*/
var histPression = new Array();
var histPresMoy = new Array();
var pression = 0.0;
Expand Down Expand Up @@ -183,27 +186,31 @@ async function index_onload() {
if (visiPref !== null) {
showT1 = visiPref === "true";
}
/*
var visiPref = localStorage.getItem("showT2");
if (visiPref !== null) {
showT2 = visiPref === "true";
}
*/
var visiPref = localStorage.getItem("showPressU");
if (visiPref !== null) {
showPressU = visiPref === "true";
}
/*
var visiPref = localStorage.getItem("showPressL");
if (visiPref !== null) {
showPressL = visiPref === "true";
}
*/
var visiPref = localStorage.getItem("showPressGrid");
if (visiPref !== null) {
showPressGrid = visiPref === "true";
}
document.getElementById("showWind").checked = showWind;
document.getElementById("showT1").checked = showT1;
document.getElementById("showT2").checked = showT2;
/*document.getElementById("showT2").checked = showT2;*/
document.getElementById("showPressU").checked = showPressU;
document.getElementById("showPressL").checked = showPressL;
/*document.getElementById("showPressL").checked = showPressL;*/
document.getElementById("showPressGrid").checked = showPressGrid;

var soundPref = localStorage.getItem("sound");
Expand Down Expand Up @@ -406,6 +413,7 @@ async function index_onload() {
tension: 0.4,
yAxisID: 'y'
},
/*
{
cubicInterpolationMode: 'default',
data: histBmp180Data,
Expand Down Expand Up @@ -450,6 +458,7 @@ async function index_onload() {
tension: 0.4,
yAxisID: 'y1'
}
*/
]
};
var tempOptions = {
Expand Down Expand Up @@ -480,6 +489,7 @@ async function index_onload() {
x: Date.now(),
y: ctnMoyen
});
/*
chart.data.datasets[2].data.push({
x: Date.now(),
y: tempBmp180
Expand All @@ -495,7 +505,8 @@ async function index_onload() {
chart.data.datasets[5].data.push({
x: Date.now(),
y: presMoyen
});
});
*/
}
},
ticks: {
Expand All @@ -519,6 +530,7 @@ async function index_onload() {
color: couleurGrid
}
},
/*
y1: {
type: 'linear',
beginAtZero: false,
Expand All @@ -533,6 +545,7 @@ async function index_onload() {
color: couleurGrid
}
}
*/
},
responsive: true,
maintainAspectRatio: false
Expand All @@ -557,10 +570,12 @@ async function index_onload() {
Window.graphVent.setDatasetVisibility(2, false);
Window.graphTemp.setDatasetVisibility(0, false);
Window.graphTemp.setDatasetVisibility(1, false);
/*
Window.graphTemp.setDatasetVisibility(2, false);
Window.graphTemp.setDatasetVisibility(3, false);
Window.graphTemp.setDatasetVisibility(4, false);
Window.graphTemp.setDatasetVisibility(5, false);
*/
Window.graphTemp.update();
// Affiche les courbes visibles en fonction des préférences
visuCourbes();
Expand All @@ -579,6 +594,9 @@ async function index_onload() {
var attente = document.getElementById("attente0")
attente.classList.add("noshow");

// récupère la config AP
getAPconfig();

/* A compléter...
* cf. https://developer.mozilla.org/en-US/docs/Web/API/Screen_Wake_Lock_API
* cf. https://mdn.github.io/dom-examples/screen-wake-lock-api/
Expand All @@ -588,7 +606,7 @@ async function index_onload() {
}
*/

}
} // index_onload()

function loadStyle() {

Expand Down Expand Up @@ -636,10 +654,17 @@ function echelleTemperature(scaleTemp) {

function recalePression() {
// On recalle le graph de pression
Window.graphVent.options.scales['y1'].suggestedMax = pression + 0.5;
Window.graphVent.options.scales['y1'].suggestedMin = pression;
/*
Window.graphTemp.options.scales['y1'].suggestedMax = pression + 0.5;
Window.graphTemp.options.scales['y1'].suggestedMin = pression;
*/
// Mise à jour du graphe
Window.graphVent.update();
/*
Window.graphTemp.update();
*/
}

function XMLHttpRequest_get(requette) {
Expand Down Expand Up @@ -688,17 +713,19 @@ function XMLHttpResult(requette, xml, text) {
} else {
tempctn = ctnMoyen;
}
tempBmp180 = Number(xml.getElementsByTagName("b")[0].childNodes[0].nodeValue);
/*tempBmp180 = Number(xml.getElementsByTagName("b")[0].childNodes[0].nodeValue);*/
calculMoyenneTemperature();

var showT1 = document.getElementById("showT1").checked;

var doc_temp = document.getElementById("valeurTemp");
doc_temp.innerHTML = ""
/*
if (showT2) {
doc_temp.innerHTML += '<span class="couleurMoyBmp180">moy = ' + Number.parseFloat(bmp180Moyen).toFixed(1) + '</span>&nbsp;';
doc_temp.innerHTML += '<span class="couleurTempBmp180">inst = ' + Number.parseFloat(tempBmp180).toFixed(2) + '°C</span><br />';
}
*/
if (showT1) {
doc_temp.innerHTML += '<span class="couleurMoyCtn">moy = ' + Number.parseFloat(ctnMoyen).toFixed(1) + '</span>&nbsp;';
doc_temp.innerHTML += '<span class="couleurTempCtn">inst = ' + Number.parseFloat(tempctn).toFixed(2) + '°C</span>'
Expand Down Expand Up @@ -727,8 +754,10 @@ function XMLHttpResult(requette, xml, text) {
var pwd = xml.getElementsByTagName("pwd")[0].textContent;
var apSSID = document.getElementById('apSSID');
var apPwd1 = document.getElementById('apPwd1');
var bottomSSID = document.getElementById('bottomSSID');
apSSID.value = ssid;
apPwd1.value = pwd;
bottomSSID.textContent = ssid;
apConfigChange = false;
inputConfigAP();
}
Expand Down Expand Up @@ -771,15 +800,17 @@ function graphHistoryintegration(xml) {
// Elimination des points abérants, on les remplace par la valeur moyenne
tempctn = ctnMoyen;
}
tempBmp180 = Number(h.getElementsByTagName("b")[0].childNodes[0].nodeValue);
/*tempBmp180 = Number(h.getElementsByTagName("b")[0].childNodes[0].nodeValue);*/
calculMoyenneTemperature();
// Envoie les données d'historique dans les graphiques
histVentData.push ({x: tX, y: vent});
histVentMoy.push ({x: tX, y: ventMoyen});
histTempCtn.push ({x: tX, y: tempctn});
histTCtnMoy.push ({x: tX, y: ctnMoyen});
/*
histBmp180Data.push({x: tX, y: tempBmp180});
histBmp180Moy.push ({x: tX, y: bmp180Moyen});
*/
histPression.push ({x: tX, y: pression});
histPresMoy.push ({x: tX, y: presMoyen});
}
Expand Down Expand Up @@ -890,17 +921,17 @@ function calculPressionDouce(pBrute) {
function calculMoyenneTemperature() {

// Remplace l'élément pointé par l'indexe et recalcul le total
if (isNaN(tblTemp[tblTempIdx])) {
if (isNaN(tblCtn[tblTempIdx])) {
// Initialise l'élément du tableau pour la première fois
tblTemp[tblTempIdx] = 0
/*tblTemp[tblTempIdx] = 0*/
tblCtn[tblTempIdx] = 0
}

bmp180Total = bmp180Total - tblTemp[tblTempIdx];
/*bmp180Total = bmp180Total - tblTemp[tblTempIdx];*/
ctnTotal = ctnTotal - tblCtn[tblTempIdx];
tblTemp[tblTempIdx] = tempBmp180;
/*tblTemp[tblTempIdx] = tempBmp180;*/
tblCtn[tblTempIdx] = tempctn;
bmp180Total = bmp180Total + tblTemp[tblTempIdx];
/*bmp180Total = bmp180Total + tblTemp[tblTempIdx];*/
ctnTotal = ctnTotal + tblCtn[tblTempIdx];

// Avance l'indexe du tableau
Expand All @@ -912,11 +943,11 @@ function calculMoyenneTemperature() {

if (largeurTempFull) {
// calcul la moyenne sur l'ensemble du tableau
bmp180Moyen = Math.round(bmp180Total / largeurMoyTemp * 100)/100;
/*bmp180Moyen = Math.round(bmp180Total / largeurMoyTemp * 100)/100;*/
ctnMoyen = Math.round(ctnTotal / largeurMoyTemp * 100)/100;
} else {
// calcul la moyenne jusqu'à l'indexe (le tableau n'est pas complet).
bmp180Moyen = Math.round(bmp180Total / tblTempIdx * 100)/100;
/*bmp180Moyen = Math.round(bmp180Total / tblTempIdx * 100)/100;*/
ctnMoyen = Math.round(ctnTotal / tblTempIdx * 100)/100;
}

Expand Down Expand Up @@ -988,6 +1019,8 @@ function appliqueTheme() {
couleurMoyBmp180 = style.getPropertyValue('--couleurMoyBmp180');
couleurGrid = style.getPropertyValue('--couleurGrid');

Window.graphVent.options.scales['x'].grid.color = couleurGrid;
Window.graphVent.options.scales['y'].grid.color = couleurGrid;
Window.graphVent.options.scales['y'].ticks.color = couleurVent;
Window.graphVent.data.datasets[0].borderColor = couleurVent;
Window.graphVent.data.datasets[0].fill.above = couleurFillVent;
Expand All @@ -998,24 +1031,24 @@ function appliqueTheme() {
Window.graphVent.data.datasets[2].fill.above = couleurFillPression;
Window.graphVent.data.datasets[2].fill.below = couleurFillPression;
Window.graphVent.data.datasets[3].borderColor = couleurMoyPres;
Window.graphVent.options.scales['x'].grid.color = couleurGrid;
Window.graphVent.options.scales['y'].grid.color = couleurGrid;
Window.graphVent.options.scales['y1'].grid.color = couleurGrid;

Window.graphTemp.options.scales['x'].grid.color = couleurGrid;
Window.graphTemp.options.scales['y'].grid.color = couleurGrid;
Window.graphTemp.options.scales['y'].ticks.color = couleurTempCtn;
Window.graphTemp.data.datasets[0].borderColor = couleurTempCtn;
Window.graphTemp.data.datasets[0].fill.above = couleurFillCtn;
Window.graphTemp.data.datasets[0].fill.below = couleurFillCtn;
Window.graphTemp.data.datasets[1].borderColor = couleurMoyCtn;
/*
Window.graphTemp.data.datasets[2].borderColor = couleurTempBmp180;
Window.graphTemp.data.datasets[3].borderColor = couleurMoyBmp180;
Window.graphTemp.options.scales['y1'].ticks.color = couleurPression;
Window.graphTemp.data.datasets[4].borderColor = couleurPression;
Window.graphTemp.data.datasets[4].fill.above = couleurFillPression;
Window.graphTemp.data.datasets[4].fill.below = couleurFillPression;
Window.graphTemp.options.scales['x'].grid.color = couleurGrid;
Window.graphTemp.options.scales['y'].grid.color = couleurGrid;
Window.graphTemp.options.scales['y1'].grid.color = couleurGrid;
*/

}, 500);

Expand Down Expand Up @@ -1053,6 +1086,7 @@ function visuCourbes() {
Window.graphTemp.setDatasetVisibility(0, showT1);
Window.graphTemp.setDatasetVisibility(1, showT1);

/*
newValue = document.getElementById("showPressL").checked;
if (newValue != showPressL) {
showPressL = newValue;
Expand All @@ -1068,6 +1102,7 @@ function visuCourbes() {
}
Window.graphTemp.setDatasetVisibility(2, showT2);
Window.graphTemp.setDatasetVisibility(3, showT2);
*/

// Grilles de pression athmosphérique
newValue = document.getElementById("showPressGrid").checked;
Expand All @@ -1077,8 +1112,10 @@ function visuCourbes() {
}
Window.graphVent.options.scales['y1'].ticks.display = showPressGrid;
Window.graphVent.options.scales['y1'].grid.display = showPressGrid;
/*
Window.graphTemp.options.scales['y1'].ticks.display = showPressGrid;
Window.graphTemp.options.scales['y1'].grid.display = showPressGrid;
*/

}

Expand Down Expand Up @@ -1435,7 +1472,9 @@ function changeLargeurTemp() {
ctnMoyen = 0.0;
// Efface les moyennes précédentes
Window.graphTemp.data.datasets[1].data = [];
/*
Window.graphTemp.data.datasets[3].data = [];
*/
// Stocke la préférence dans le localStorage
localStorage.setItem("largeurMoyTemp", largeurMoyTemp);
}
Expand Down
Loading

0 comments on commit b7f6c8c

Please sign in to comment.