tare procedure improved, webdata cleaned up

This commit is contained in:
nightflyer88 2019-01-26 17:21:06 +01:00
parent 26cc38c350
commit 6dcdf52955
13 changed files with 88 additions and 709 deletions

View File

@ -4,7 +4,7 @@
(c) 2019 by M. Lehmann (c) 2019 by M. Lehmann
------------------------------------------------------------------ ------------------------------------------------------------------
*/ */
#define CGSCALE_VERSION "1.0.62" #define CGSCALE_VERSION "1.0.63"
/* /*
****************************************************************** ******************************************************************
@ -204,7 +204,11 @@ char curModelName[MAX_MODELNAME_LENGHT + 1] = "";
// Restart CPU // Restart CPU
#if defined(__AVR__)
void(* resetCPU) (void) = 0; void(* resetCPU) (void) = 0;
#elif defined(ESP8266)
void resetCPU(){}
#endif
// save calibration factor // save calibration factor
@ -375,61 +379,85 @@ void setup() {
oledDisplay.print(F("(c) 2019 M. Lehmann")); oledDisplay.print(F("(c) 2019 M. Lehmann"));
} while ( oledDisplay.nextPage() ); } while ( oledDisplay.nextPage() );
// init Loadcells // init & tare Loadcells
LoadCell_1.begin(); LoadCell_1.begin();
LoadCell_1.start(STABILISINGTIME);
LoadCell_2.begin(); LoadCell_2.begin();
LoadCell_2.start(STABILISINGTIME);
if (LoadCell_1.getTareTimeoutFlag()) {
errMsg[++errMsgCnt] = "ERROR: Timeout TARE Lc1\n";
}
else {
LoadCell_1.setCalFactor(calFactorLoadcell1);
}
if (LoadCell_2.getTareTimeoutFlag()) {
errMsg[++errMsgCnt] = "ERROR: Timeout TARE Lc2\n";
}
else {
LoadCell_2.setCalFactor(calFactorLoadcell2);
}
if (nLoadcells > 2) { if (nLoadcells > 2) {
LoadCell_3.begin(); LoadCell_3.begin();
} LoadCell_3.start(STABILISINGTIME);
// tare if (LoadCell_3.getTareTimeoutFlag()) {
byte loadcell_1_rdy = 0; errMsg[++errMsgCnt] = "ERROR: Timeout TARE Lc3\n";
byte loadcell_2_rdy = 0;
byte loadcell_3_rdy = 0;
lastTimeLoadcell = millis();
while ((loadcell_1_rdy + loadcell_2_rdy + loadcell_3_rdy) < 3) {
loadcell_1_rdy = LoadCell_1.startMultiple(STABILISINGTIME);
loadcell_2_rdy = LoadCell_2.startMultiple(STABILISINGTIME);
if (nLoadcells == 3) {
loadcell_3_rdy = LoadCell_3.startMultiple(STABILISINGTIME);
} else {
loadcell_3_rdy = 1;
} }
// timeout else {
if ((millis() - lastTimeLoadcell) > TARE_TIMEOUT) { LoadCell_3.setCalFactor(calFactorLoadcell3);
errMsg[++errMsgCnt] = "ERROR: Timeout TARE\n";
break;
} }
} }
// check loadcells if error /*
if (!loadcell_1_rdy) { // init Loadcells
errMsg[++errMsgCnt] = "ERROR: Loadcell 1 not ready\n"; LoadCell_1.begin();
} LoadCell_2.begin();
if (!loadcell_2_rdy) {
errMsg[++errMsgCnt] = "ERROR: Loadcell 2 not ready\n";
}
if (!loadcell_3_rdy) {
errMsg[++errMsgCnt] = "ERROR: Loadcell 3 not ready\n";
}
// set calibration factor
LoadCell_1.setCalFactor(calFactorLoadcell1);
LoadCell_2.setCalFactor(calFactorLoadcell2);
if (nLoadcells > 2) {
LoadCell_3.setCalFactor(calFactorLoadcell3);
}
// stabilize scale values
for (int i = 0; i <= 5; i++) {
LoadCell_1.update();
LoadCell_2.update();
if (nLoadcells > 2) { if (nLoadcells > 2) {
LoadCell_3.update(); LoadCell_3.begin();
} }
delay(200);
} // tare
byte loadcell_1_rdy = 0;
byte loadcell_2_rdy = 0;
byte loadcell_3_rdy = 0;
lastTimeLoadcell = millis();
while ((loadcell_1_rdy + loadcell_2_rdy + loadcell_3_rdy) < 3) {
loadcell_1_rdy = LoadCell_1.startMultiple(STABILISINGTIME);
loadcell_2_rdy = LoadCell_2.startMultiple(STABILISINGTIME);
if (nLoadcells == 3) {
loadcell_3_rdy = LoadCell_3.startMultiple(STABILISINGTIME);
} else {
loadcell_3_rdy = 1;
}
// timeout
if ((millis() - lastTimeLoadcell) > TARE_TIMEOUT) {
errMsg[++errMsgCnt] = "ERROR: Timeout TARE\n";
break;
}
}
// check loadcells if error
if (!loadcell_1_rdy) {
errMsg[++errMsgCnt] = "ERROR: Loadcell 1 not ready\n";
}
if (!loadcell_2_rdy) {
errMsg[++errMsgCnt] = "ERROR: Loadcell 2 not ready\n";
}
if (!loadcell_3_rdy) {
errMsg[++errMsgCnt] = "ERROR: Loadcell 3 not ready\n";
}
// set calibration factor
LoadCell_1.setCalFactor(calFactorLoadcell1);
LoadCell_2.setCalFactor(calFactorLoadcell2);
if (nLoadcells > 2) {
LoadCell_3.setCalFactor(calFactorLoadcell3);
}
*/
#if defined(ESP8266) #if defined(ESP8266)
while (WiFi.status() != WL_CONNECTED) { while (WiFi.status() != WL_CONNECTED) {
@ -459,7 +487,7 @@ void setup() {
oledDisplay.setCursor(0, 64); oledDisplay.setCursor(0, 64);
oledDisplay.print(WiFi.localIP()); oledDisplay.print(WiFi.localIP());
} while ( oledDisplay.nextPage() ); } while ( oledDisplay.nextPage() );
delay(5000); //delay(5000);
} else { } else {
// if WiFi not connected, switch to access point mode // if WiFi not connected, switch to access point mode
WiFi.mode(WIFI_AP); WiFi.mode(WIFI_AP);
@ -493,6 +521,17 @@ void setup() {
server.send(404, "text/plain", "404: Not Found"); server.send(404, "text/plain", "404: Not Found");
}); });
#endif #endif
// stabilize scale values
for (int i = 0; i <= 15; i++) {
LoadCell_1.update();
LoadCell_2.update();
if (nLoadcells > 2) {
LoadCell_3.update();
}
delay(200);
}
} }
@ -528,6 +567,7 @@ void loop() {
// update display and serial menu // update display and serial menu
if ((millis() - lastTimeMenu) > UPDATE_INTERVAL_OLED_MENU) { if ((millis() - lastTimeMenu) > UPDATE_INTERVAL_OLED_MENU) {
lastTimeMenu = millis(); lastTimeMenu = millis();
// total model weight // total model weight

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,180 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="M. Lehmann">
<title>CG scale by M. Lehmann</title>
<link href="/bootstrap.min.css" rel="stylesheet">
<script src="/bootstrap.min.js"></script>
<script>
var CG_trans_visible = true;
var batVolt_visible = true;
var curModelName = "";
function getHead(){
var request = new XMLHttpRequest();
request.onreadystatechange = function(){
if(this.readyState == 4 && this.status == 200){
if(this.responseText != null){
var responseString = this.responseText;
var value = responseString.split("&");
document.getElementById("ssid").innerHTML = value[0];
document.getElementById("errMsg").innerHTML = value[1];
document.getElementById("cgscaleVersion").innerHTML = value[2];
}
}
}
request.open("GET", "getHead", true);
request.send();
}
function getParameter(){
var request = new XMLHttpRequest();
request.onreadystatechange = function(){
if(this.readyState == 4 && this.status == 200){
if(this.responseText != null){
var responseString = this.responseText;
var value = responseString.split("&");
if(value[0] == "2"){
CG_trans_visible = false;
document.getElementById("cglrContainer").outerHTML = "";
}
if(value[11] == "OFF"){
batVolt_visible = false;
document.getElementById("batContainer").outerHTML = "";
}
curModelName = value[16];
if (curModelName != "") {
document.getElementById("modelName").innerHTML = curModelName;
document.getElementById("saveButton").classList.remove('disabled');
document.getElementById("weightTotalSaved").innerHTML = value[17];
document.getElementById("CG_lengthSaved").innerHTML = value[18];
if(CG_trans_visible == true){
document.getElementById("CG_transSaved").innerHTML = value[19];
}
}
}
}
}
request.open("GET", "getParameter", true);
request.send();
}
function getValue(){
var request = new XMLHttpRequest();
request.onreadystatechange = function(){
if(this.readyState == 4 && this.status == 200){
if(this.responseText != null){
var responseString = this.responseText;
var value = responseString.split("&");
document.getElementById("weightTotal").innerHTML = value[0];
document.getElementById("CG_length").innerHTML = value[1];
if(CG_trans_visible == true){
document.getElementById("CG_trans").innerHTML = value[2];
}
if(batVolt_visible == true){
document.getElementById("batVolt").innerHTML = value[3];
}
}
}
}
request.open("GET", "getValue", true);
request.send();
setTimeout('getValue()', 1000);
}
function saveModel(){
if (curModelName != "") {
var request = new XMLHttpRequest();
request.onreadystatechange = function(){
if(this.readyState == 4 && this.status == 200){
alert(curModelName + " saved");
location.reload();
}else if(this.readyState == 4 && this.status == 404){
alert("Model not saved !");
}
}
request.open("GET", "saveModel?modelname=" + curModelName, true);
request.send();
}
}
</script>
</head>
<body>
<nav class="navbar navbar-dark fixed-top bg-dark">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#"><span id="ssid"></span></a>
</div>
<ul class="nav navbar-nav navbar-right">
<form class="form-inline">
<button type="button" onclick="location.href = '/models.html'" class="btn btn-primary navbar-btn mx-2">
<img src="airplane.png" alt="" style="width:auto;height:30px">
<span id="modelName"></span>
</button>
<button type="button" onclick="location.href = '/settings.html'" class="btn btn-danger navbar-btn">
<img src="settings.png" alt="" style="width:auto;height:30px">
</button>
</form>
</ul>
</div>
</nav>
<main role="main" class="container" style="margin-top:100px">
<div class="jumbotron">
<div class="container" id="wgContainer">
<div class="row mt-3">
<div class="col-xs-6"><img src="weight.png" class="pull-left mr-4" alt="Weight" style="width:auto;height:50px"></div>
<div class="col-xs-6 d-flex align-items-center">
<font size="6">
<span class="ml-4 mr-4" id="weightTotal">-</span>
</font>
<small class="form-text text-muted" id="weightTotalSaved"></small>
</div>
</div>
</div>
<div class="container" id="cgContainer">
<div class="row mt-3">
<div class="col-xs-6"><img src="cg.png" class="pull-left mr-4" alt="CG" style="width:auto;height:50px"></div>
<div class="col-xs-6 d-flex align-items-center">
<font size="6">
<span class="ml-4 mr-4" id="CG_length">-</span>
</font>
<small class="form-text text-muted" id="CG_lengthSaved"></small>
</div>
</div>
</div>
<div class="container" id="cglrContainer">
<div class="row mt-3">
<div class="col-xs-6"><img src="cglr.png" class="pull-left mr-4" alt="CG left/right" style="width:auto;height:50px"></div>
<div class="col-xs-6 d-flex align-items-center">
<font size="6">
<span class="ml-4 mr-4" id="CG_trans">-</span>
</font>
<small class="form-text text-muted" id="CG_transSaved"></small>
</div>
</div>
</div>
<div class="container" id="batContainer">
<div class="row mt-3">
<div class="col-xs-6"><img src="battery.png" class="pull-left mr-4" alt="Battery" style="width:auto;height:50px"></div>
<div class="col-xs-6 d-flex align-items-center">
<font size="6">
<span class="ml-4 mr-4" id="batVolt">-</span>
</font>
</div>
</div>
</div>
<div class="container"><font size="6"><span id="errMsg"></span></font></div>
</div>
<div class="text-center">
<button class="btn btn-success btn-lg disabled" onclick="saveModel()" id="saveButton">Save</button>
</div>
</main>
<p><font size="2"><center>(c) 2019 M. Lehmann - Version: <span id="cgscaleVersion">0.0</span></center></font></p>
<script>
getHead();
getParameter();
getValue();
</script>
</body>
</html>

BIN
data/index.html.gz Executable file

Binary file not shown.

View File

@ -1,199 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="M. Lehmann">
<title>CG scale by M. Lehmann</title>
<link href="/bootstrap.min.css" rel="stylesheet">
<script src="/bootstrap.min.js"></script>
<script src="/jquery-3.3.1.slim.min.js"></script>
<script>
var CG_trans_visible = true;
var curModelName = "";
function getHead(){
var request = new XMLHttpRequest();
request.onreadystatechange = function(){
if(this.readyState == 4 && this.status == 200){
if(this.responseText != null){
var responseString = this.responseText;
var value = responseString.split("&");
document.getElementById("ssid").innerHTML = value[0];
document.getElementById("cgscaleVersion").innerHTML = value[2];
}
}
}
request.open("GET", "getHead", true);
request.send();
}
function getParameter(){
var request = new XMLHttpRequest();
request.onreadystatechange = function(){
if(this.readyState == 4 && this.status == 200){
if(this.responseText != null){
var responseString = this.responseText;
var value = responseString.split("&");
if(value[0] == "2"){
CG_trans_visible = false;
}
curModelName = value[16];
}
}
}
request.open("GET", "getParameter", true);
request.send();
}
function getModels(){
var request = new XMLHttpRequest();
request.onreadystatechange = function(){
if(this.readyState == 4 && this.status == 200){
var root = JSON.parse(this.responseText);
var table = document.getElementById("models");
if(CG_trans_visible == false){
document.getElementById("cgLRrow").outerHTML = "";
}
for (name in root) {
var row = table.insertRow();
var cellName = row.insertCell(0);
var cellWeight = row.insertCell(1);
var cellCG = row.insertCell(2);
cellName.innerHTML = name;
cellWeight.innerHTML = root[name].wt;
cellCG.innerHTML = root[name].cg;
if(CG_trans_visible == true){
var cellcglr = row.insertCell(3);
var cellButton = row.insertCell(4);
cellcglr.innerHTML = root[name].cglr;
}else{
var cellButton = row.insertCell(3);
}
if(name != curModelName){
var htmlbutton = '<div class="btn-group"><button type="button" onclick="openModel(\'';
htmlbutton += name;
htmlbutton += '\')" class="btn btn-success">Open</button><button type="button" onclick="deleteModel(\'';
htmlbutton += name;
htmlbutton += '\')" class="btn btn-danger">Delete</button></div>';
cellButton.innerHTML = htmlbutton;
}else{
row.setAttribute("class", "table-active");
}
}
}else if(this.readyState == 4 && this.status == 404){
document.getElementById("backup").outerHTML = "";
//alert("No models saved !");
}
}
request.open("GET", "models.json", true);
request.send();
}
function saveModel(){
var modelname = prompt("Please enter new model name:");
if (modelname != "") {
var request = new XMLHttpRequest();
request.onreadystatechange = function(){
if(this.readyState == 4 && this.status == 200){
location.reload();
}else if(this.readyState == 4 && this.status == 404){
alert("Model not saved !");
}
}
request.open("GET", "saveModel?modelname=" + modelname, true);
request.send();
}
}
function openModel(modelname){
if (modelname != "") {
var request = new XMLHttpRequest();
request.onreadystatechange = function(){
if(this.readyState == 4 && this.status == 200){
location.reload();
}else if(this.readyState == 4 && this.status == 404){
alert("Model not open !");
}
}
request.open("GET", "openModel?modelname=" + modelname, true);
request.send();
}
}
function deleteModel(modelname){
if (modelname != "" && confirm("Do you want to delete: " + modelname + "?")){
var request = new XMLHttpRequest();
request.onreadystatechange = function(){
if(this.readyState == 4 && this.status == 200){
location.reload();
}else if(this.readyState == 4 && this.status == 404){
alert("Model not deleted !");
}
}
request.open("GET", "deleteModel?modelname=" + modelname, true);
request.send();
}
}
function download(file)
{
window.location=file;
}
</script>
</head>
<body>
<nav class="navbar navbar-dark fixed-top bg-dark">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#"><span id="ssid"></span></a>
</div>
<ul class="nav navbar-nav navbar-right">
<form class="form-inline">
<button type="button" onclick="location.href = '/'" class="btn btn-danger navbar-btn mx-2">
<img src="home.png" alt="" style="width:auto;height:30px">
</button>
<button type="button" onclick="location.href = '/settings.html'" class="btn btn-danger navbar-btn">
<img src="settings.png" alt="" style="width:auto;height:30px">
</button>
</form>
</ul>
</div>
</nav>
<main role="main" class="container" style="margin-top:100px">
<table class="table" id="models">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Weight [g]</th>
<th scope="col">CG [mm]</th>
<th scope="col" id="cgLRrow">CG left-right [mm]</th>
<th scope="col"></th>
</tr>
</thead>
</table>
<button type="button" onclick="saveModel()" class="btn btn-primary btn-lg">New model</button>
<form method="post" enctype="multipart/form-data">
<div class="custom-file mt-5">
<input type="file" class="custom-file-input" id="customFile" name="filename">
<label class="custom-file-label" for="customFile">Restore file...</label>
</div>
<script>
$('.custom-file-input').on('change', function() {
let fileName = $(this).val().split('\\').pop();
$(this).next('.custom-file-label').addClass("selected").html(fileName);
});
</script>
<div class="mt-4">
<a class="btn btn-outline-success btn-lg" id="backup" role="button" href="models.json" download="models.json">Backup</a>
<button type="submit" class="btn btn-outline-danger btn-lg">Restore</button>
</div>
</form>
</main>
<p><font size="2"><center>(c) 2019 M. Lehmann - Version: <span id="cgscaleVersion">0.0</span></center></font></p>
<script>
getHead();
getParameter();
getModels();
</script>
</body>
</html>

BIN
data/models.html.gz Executable file

Binary file not shown.

View File

@ -1,280 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="M. Lehmann">
<title>CG scale by M. Lehmann</title>
<link href="/bootstrap.min.css" rel="stylesheet">
<script src="/bootstrap.min.js"></script>
<script>
var CG_trans_visible = true;
function getHead(){
var request = new XMLHttpRequest();
request.onreadystatechange = function(){
if(this.readyState == 4 && this.status == 200){
if(this.responseText != null){
var responseString = this.responseText;
var value = responseString.split("&");
document.getElementById("ssid").innerHTML = value[0];
document.getElementById("cgscaleVersion").innerHTML = value[2];
}
}
}
request.open("GET", "getHead", true);
request.send();
}
function getRawValue(){
var request = new XMLHttpRequest();
request.onreadystatechange = function(){
if(this.readyState == 4 && this.status == 200){
if(this.responseText != null){
var responseString = this.responseText;
var value = responseString.split("&");
document.getElementById("lc1").innerHTML = value[0];
document.getElementById("lc2").innerHTML = value[1];
if(CG_trans_visible == true){
document.getElementById("lc3").innerHTML = value[2];
}
}
}
}
request.open("GET", "getRawValue", true);
request.send();
setTimeout('getRawValue()', 1000);
}
function getParameter(){
var request = new XMLHttpRequest();
request.onreadystatechange = function(){
if(this.readyState == 4 && this.status == 200){
if(this.responseText != null){
var responseString = this.responseText;
var value = responseString.split("&");
setValue("nLoadcells", value[0]);
setValue("distanceX1", value[1]);
setValue("distanceX2", value[2]);
setValue("distanceX3", value[3]);
setValue("refWeight", value[4]);
setValue("refCG", value[5]);
setValue("calFactorLoadcell1", value[6]);
setValue("calFactorLoadcell2", value[7]);
setValue("calFactorLoadcell3", value[8]);
setValue("resistorR1", value[9]);
setValue("resistorR2", value[10]);
setValue("enableBatVolt", value[11]);
setValue("ssid_STA", value[12]);
setValue("password_STA", value[13]);
setValue("ssid_AP", value[14]);
setValue("password_AP", value[15]);
document.getElementById("modelName").innerHTML = value[16];
if(value[0] == "2"){
CG_trans_visible = false;
document.getElementById("lc3_div").outerHTML = "";
}
}
}
}
request.open("GET", "getParameter", true);
request.send();
}
function getWiFiNetworks(){
var request = new XMLHttpRequest();
request.onreadystatechange = function(){
if(this.readyState == 4 && this.status == 200){
if(this.responseText != null){
var responseString = this.responseText;
var value = responseString.split("&");
var select = document.getElementById('ssid_STA');
for (var i = 0; i<value.length; ++i){
var opt = document.createElement('option');
opt.value = value[i];
opt.innerHTML = value[i];
select.appendChild(opt);
}
}
}
}
request.open("GET", "getWiFiNetworks", true);
request.send();
}
function saveParameter(){
var data = "?";
data += "nLoadcells=" + document.getElementById("nLoadcells").value;
data += "&distanceX1=" + document.getElementById("distanceX1").value;
data += "&distanceX2=" + document.getElementById("distanceX2").value;
data += "&distanceX3=" + document.getElementById("distanceX3").value;
data += "&refWeight=" + document.getElementById("refWeight").value;
data += "&refCG=" + document.getElementById("refCG").value;
data += "&calFactorLoadcell1=" + document.getElementById("calFactorLoadcell1").value;
data += "&calFactorLoadcell2=" + document.getElementById("calFactorLoadcell2").value;
data += "&calFactorLoadcell3=" + document.getElementById("calFactorLoadcell3").value;
data += "&resistorR1=" + document.getElementById("resistorR1").value;
data += "&resistorR2=" + document.getElementById("resistorR2").value;
data += "&enableBatVolt=" + document.getElementById("enableBatVolt").value;
data += "&ssid_STA=" + document.getElementById("ssid_STA").value;
data += "&password_STA=" + document.getElementById("password_STA").value;
data += "&ssid_AP=" + document.getElementById("ssid_AP").value;
data += "&password_AP=" + document.getElementById("password_AP").value;
var request = new XMLHttpRequest();
request.onreadystatechange = function(){
if(this.readyState == 4 && this.status == 200){
alert("Parameters saved");
getParameter();
}else if(this.readyState == 4 && this.status == 404){
alert("Save parameter failed !");
}
}
request.open("GET", "saveParameter" + data, true);
request.send();
}
function autoCalibrate(){
alert("Please put the reference weight on the scale.");
var request = new XMLHttpRequest();
request.onreadystatechange = function(){
if(this.readyState == 4 && this.status == 200){
alert("Calibration successful");
getParameter();
}else if(this.readyState == 4 && this.status == 404){
alert("Calibration failed !");
}
}
request.open("GET", "autoCalibrate", true);
request.send();
}
function setValue(id, value)
{
var element = document.getElementById(id);
element.value = value;
}
function getValue(id)
{
return document.getElementById(id).value;
}
</script>
</head>
<body>
<nav class="navbar navbar-dark fixed-top bg-dark">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#"><span id="ssid"></span></a>
</div>
<ul class="nav navbar-nav navbar-right">
<form class="form-inline">
<button type="button" onclick="location.href = '/models.html'" class="btn btn-primary navbar-btn mx-2">
<img src="airplane.png" alt="" style="width:auto;height:30px">
<span id="modelName"></span>
</button>
<button type="button" onclick="location.href = '/'" class="btn btn-danger navbar-btn">
<img src="home.png" alt="" style="width:auto;height:30px">
</button>
</form>
</ul>
</div>
</nav>
<main role="main" class="container" style="margin-top:100px">
<h3>WiFi settings</h3>
<div class="form-group">
<label>Home WiFi name (SSID):</label>
<select class="form-control" id="ssid_STA">
</select>
<small class="form-text text-muted">Connect to existing network</small>
</div>
<div class="form-group">
<label>WiFi password:</label>
<input type="password" class="form-control" id="password_STA" value="-">
</div>
<br>
<div class="form-group">
<label>Access point WiFi name (SSID):</label>
<input type="text" class="form-control" id="ssid_AP" value="-">
<small class="form-text text-muted">If no network is present, a private network is created</small>
</div>
<div class="form-group">
<label>WiFi password:</label>
<input type="password" class="form-control" id="password_AP" value="-">
<small class="form-text text-muted">At least 8 characters</small>
</div>
<br><br>
<h3>CG scale settings</h3>
<div class="form-group">
<label>Number of load cells:</label>
<select class="form-control" id="nLoadcells">
<option value="2">2</option>
<option value="3">3</option>
</select>
</div>
<div class="form-group">
<label>Distance X1 [mm]:</label>
<input type="text" class="form-control" id="distanceX1" value="-">
</div>
<div class="form-group">
<label>Distance X2 [mm]:</label>
<input type="text" class="form-control" id="distanceX2" value="-">
</div>
<div class="form-group">
<label>Distance X3 [mm]:</label>
<input type="text" class="form-control" id="distanceX3" value="-">
</div>
<div class="form-group">
<label>Reference weight [g]:</label>
<input type="text" class="form-control" id="refWeight" value="-">
</div>
<div class="form-group">
<label>Reference CG [mm]:</label>
<input type="text" class="form-control" id="refCG" value="-">
</div>
<div class="form-group">
<label>Calibration factor of load cell 1:</label>
<input type="text" class="form-control" id="calFactorLoadcell1" value="-">
</div>
<div class="form-group">
<label>Calibration factor of load cell 2:</label>
<input type="text" class="form-control" id="calFactorLoadcell2" value="-">
</div>
<div class="form-group">
<label>Calibration factor of load cell 3:</label>
<input type="text" class="form-control" id="calFactorLoadcell3" value="-">
</div>
<div class="form-group">
<label>Value of resistor R1 [ohm]:</label>
<input type="text" class="form-control" id="resistorR1" value="-">
</div>
<div class="form-group">
<label>Value of resistor R2 [ohm]:</label>
<input type="text" class="form-control" id="resistorR2" value="-">
</div>
<div class="form-group">
<label>Voltage measurement:</label>
<select class="form-control" id="enableBatVolt">
<option value="ON">ON</option>
<option value="OFF">OFF</option>
</select>
</div>
<br><br>
<button class="btn btn-success btn-lg" onclick="saveParameter()">Save</button>
<button class="btn btn-primary btn-lg" onclick="autoCalibrate()">Auto calibrate</button>
<img src="CG_scale_mechanics.png" class="pull-left mr-4" alt="mechanics" style="width:100%">
<font size="4">
<div>
<p><center>Lc1: <span id="lc1">-</span></center></p>
</div>
<div>
<p><center>Lc2: <span id="lc2">-</span></center></p>
</div>
<div id="lc3_div">
<p><center>Lc3: <span id="lc3">-</span></center></p>
</div>
</font>
<br><br>
</main>
<p><font size="2"><center>(c) 2019 M. Lehmann - Version: <span id="cgscaleVersion">0.0</span></center></font></p>
<script>
getHead();
getWiFiNetworks();
getParameter();
getRawValue();
</script>
</body>
</html>

BIN
data/settings.html.gz Executable file

Binary file not shown.

View File

@ -59,7 +59,6 @@ CG scale with 3 Loadcells:
// **** Measurement settings **** // **** Measurement settings ****
#define STABILISINGTIME 3000 // ms #define STABILISINGTIME 3000 // ms
#define TARE_TIMEOUT 4000 // ms
#define UPDATE_INTERVAL_OLED_MENU 500 // ms #define UPDATE_INTERVAL_OLED_MENU 500 // ms
#define UPDATE_INTERVAL_LOADCELL 100 // ms #define UPDATE_INTERVAL_LOADCELL 100 // ms

View File

@ -58,8 +58,7 @@ CG scale with 3 Loadcells:
// **** Measurement settings **** // **** Measurement settings ****
#define STABILISINGTIME 3000 // ms #define STABILISINGTIME 2000 // ms
#define TARE_TIMEOUT 4000 // ms
#define UPDATE_INTERVAL_OLED_MENU 500 // ms #define UPDATE_INTERVAL_OLED_MENU 500 // ms
#define UPDATE_INTERVAL_LOADCELL 100 // ms #define UPDATE_INTERVAL_LOADCELL 100 // ms
@ -141,6 +140,6 @@ const char ip[4] = {1,1,1,1}; // default IP address
// **** Model memory settings **** // **** Model memory settings ****
#define MAX_MODELNAME_LENGHT 15 // max chars #define MAX_MODELNAME_LENGHT 32 // max chars
#define MODEL_FILE "/models.json" // file to store models #define MODEL_FILE "/models.json" // file to store models
#define JSONBUFFER_SIZE 20000 // max file size in bytes #define JSONBUFFER_SIZE 20000 // max file size in bytes