html optimized: data is loaded with javascript, Wifi mode added
This commit is contained in:
parent
cf64e3b901
commit
7f62fc479d
785
CG_scale.ino
785
CG_scale.ino
@ -4,7 +4,7 @@
|
|||||||
(c) 2019 by M. Lehmann
|
(c) 2019 by M. Lehmann
|
||||||
------------------------------------------------------------------
|
------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#define CGSCALE_VERSION "1.0.55"
|
#define CGSCALE_VERSION "1.0.58"
|
||||||
/*
|
/*
|
||||||
|
|
||||||
******************************************************************
|
******************************************************************
|
||||||
@ -58,12 +58,13 @@
|
|||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
#include <WiFiClient.h>
|
#include <WiFiClient.h>
|
||||||
#include <ESP8266WebServer.h>
|
#include <ESP8266WebServer.h>
|
||||||
#include "settings_ESP8266.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// settings for AVR
|
// load settings
|
||||||
#if defined(__AVR__)
|
#if defined(__AVR__)
|
||||||
#include "settings_AVR.h"
|
#include "settings_AVR.h"
|
||||||
|
#elif defined(ESP8266)
|
||||||
|
#include "settings_ESP8266.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// HX711 constructor (dout pin, sck pint):
|
// HX711 constructor (dout pin, sck pint):
|
||||||
@ -78,8 +79,7 @@ IPAddress apIP(ip[0], ip[1], ip[2], ip[3]);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// serial menu
|
// serial menu
|
||||||
enum
|
enum {
|
||||||
{
|
|
||||||
MENU_HOME,
|
MENU_HOME,
|
||||||
MENU_LOADCELLS,
|
MENU_LOADCELLS,
|
||||||
MENU_DISTANCE_X1,
|
MENU_DISTANCE_X1,
|
||||||
@ -99,9 +99,7 @@ enum
|
|||||||
};
|
};
|
||||||
|
|
||||||
// EEprom parameter addresses
|
// EEprom parameter addresses
|
||||||
#define EEPROM_SIZE 120
|
enum {
|
||||||
enum
|
|
||||||
{
|
|
||||||
P_NUMBER_LOADCELLS = 1,
|
P_NUMBER_LOADCELLS = 1,
|
||||||
P_DISTANCE_X1 = 2,
|
P_DISTANCE_X1 = 2,
|
||||||
P_DISTANCE_X2 = P_DISTANCE_X1 + sizeof(float),
|
P_DISTANCE_X2 = P_DISTANCE_X1 + sizeof(float),
|
||||||
@ -113,7 +111,16 @@ enum
|
|||||||
P_REF_WEIGHT = P_ENABLE_BATVOLT + sizeof(float),
|
P_REF_WEIGHT = P_ENABLE_BATVOLT + sizeof(float),
|
||||||
P_REF_CG = P_REF_WEIGHT + sizeof(float),
|
P_REF_CG = P_REF_WEIGHT + sizeof(float),
|
||||||
P_RESISTOR_R1 = P_REF_CG + sizeof(float),
|
P_RESISTOR_R1 = P_REF_CG + sizeof(float),
|
||||||
P_RESISTOR_R2 = P_RESISTOR_R1 + sizeof(float)
|
P_RESISTOR_R2 = P_RESISTOR_R1 + sizeof(float),
|
||||||
|
#if defined(__AVR__)
|
||||||
|
EEPROM_SIZE = P_RESISTOR_R2 + sizeof(float)
|
||||||
|
#elif defined(ESP8266)
|
||||||
|
P_SSID_STA = P_RESISTOR_R2 + sizeof(float),
|
||||||
|
P_PASSWORD_STA = P_SSID_STA + MAX_SSID_PW_LENGHT + 1,
|
||||||
|
P_SSID_AP = P_PASSWORD_STA + MAX_SSID_PW_LENGHT + 1,
|
||||||
|
P_PASSWORD_AP = P_SSID_AP + MAX_SSID_PW_LENGHT + 1,
|
||||||
|
EEPROM_SIZE = P_PASSWORD_AP + MAX_SSID_PW_LENGHT + 1
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
// battery image 12x6
|
// battery image 12x6
|
||||||
@ -164,6 +171,12 @@ float resistorR2 = RESISTOR_R2;
|
|||||||
bool enableBatVolt = ENABLE_VOLTAGE;
|
bool enableBatVolt = ENABLE_VOLTAGE;
|
||||||
float refWeight = REF_WEIGHT;
|
float refWeight = REF_WEIGHT;
|
||||||
float refCG = REF_CG;
|
float refCG = REF_CG;
|
||||||
|
#if defined(ESP8266)
|
||||||
|
char ssid_STA[MAX_SSID_PW_LENGHT + 1] = SSID_STA;
|
||||||
|
char password_STA[MAX_SSID_PW_LENGHT + 1] = PASSWORD_STA;
|
||||||
|
char ssid_AP[MAX_SSID_PW_LENGHT + 1] = SSID_AP;
|
||||||
|
char password_AP[MAX_SSID_PW_LENGHT + 1] = PASSWORD_AP;
|
||||||
|
#endif
|
||||||
|
|
||||||
// declare variables
|
// declare variables
|
||||||
float weightLoadCell1 = 0;
|
float weightLoadCell1 = 0;
|
||||||
@ -188,106 +201,42 @@ int errMsgCnt = 0;
|
|||||||
void(* resetCPU) (void) = 0;
|
void(* resetCPU) (void) = 0;
|
||||||
|
|
||||||
|
|
||||||
// save values to eeprom
|
// reset to factory defaults
|
||||||
void saveLoadcells() {
|
void resetDefault() {
|
||||||
EEPROM.put(P_NUMBER_LOADCELLS, nLoadcells);
|
// reset eeprom
|
||||||
#if defined(ESP8266)
|
for (int i = 0; i < EEPROM_SIZE; i++) {
|
||||||
EEPROM.commit();
|
EEPROM.write(i, 0xFF);
|
||||||
#endif
|
}
|
||||||
}
|
Serial.end();
|
||||||
|
|
||||||
|
|
||||||
void saveDistanceX1() {
|
|
||||||
EEPROM.put(P_DISTANCE_X1, distanceX1);
|
|
||||||
#if defined(ESP8266)
|
|
||||||
EEPROM.commit();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void saveDistanceX2() {
|
|
||||||
EEPROM.put(P_DISTANCE_X2, distanceX2);
|
|
||||||
#if defined(ESP8266)
|
|
||||||
EEPROM.commit();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void saveDistanceX3() {
|
|
||||||
EEPROM.put(P_DISTANCE_X3, distanceX3);
|
|
||||||
#if defined(ESP8266)
|
|
||||||
EEPROM.commit();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void saveRefWeight() {
|
|
||||||
EEPROM.put(P_REF_WEIGHT, refWeight);
|
|
||||||
#if defined(ESP8266)
|
|
||||||
EEPROM.commit();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void saveRefCG() {
|
|
||||||
EEPROM.put(P_REF_CG, refCG);
|
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
EEPROM.commit();
|
EEPROM.commit();
|
||||||
#endif
|
#endif
|
||||||
|
resetCPU();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// save calibration factor
|
||||||
void saveCalFactor1() {
|
void saveCalFactor1() {
|
||||||
LoadCell_1.setCalFactor(calFactorLoadcell1);
|
LoadCell_1.setCalFactor(calFactorLoadcell1);
|
||||||
EEPROM.put(P_LOADCELL1_CALIBRATION_FACTOR, calFactorLoadcell1);
|
EEPROM.put(P_LOADCELL1_CALIBRATION_FACTOR, calFactorLoadcell1);
|
||||||
#if defined(ESP8266)
|
|
||||||
EEPROM.commit();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void saveCalFactor2() {
|
void saveCalFactor2() {
|
||||||
LoadCell_2.setCalFactor(calFactorLoadcell2);
|
LoadCell_2.setCalFactor(calFactorLoadcell2);
|
||||||
EEPROM.put(P_LOADCELL2_CALIBRATION_FACTOR, calFactorLoadcell2);
|
EEPROM.put(P_LOADCELL2_CALIBRATION_FACTOR, calFactorLoadcell2);
|
||||||
#if defined(ESP8266)
|
|
||||||
EEPROM.commit();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void saveCalFactor3() {
|
void saveCalFactor3() {
|
||||||
LoadCell_3.setCalFactor(calFactorLoadcell3);
|
LoadCell_3.setCalFactor(calFactorLoadcell3);
|
||||||
EEPROM.put(P_LOADCELL3_CALIBRATION_FACTOR, calFactorLoadcell3);
|
EEPROM.put(P_LOADCELL3_CALIBRATION_FACTOR, calFactorLoadcell3);
|
||||||
#if defined(ESP8266)
|
|
||||||
EEPROM.commit();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void saveResistorR1() {
|
// run auto calibration
|
||||||
EEPROM.put(P_RESISTOR_R1, resistorR1);
|
bool runAutoCalibrate() {
|
||||||
#if defined(ESP8266)
|
Serial.print(F("\nAutocalibration is running"));
|
||||||
EEPROM.commit();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void saveResistorR2() {
|
|
||||||
EEPROM.put(P_RESISTOR_R2, resistorR2);
|
|
||||||
#if defined(ESP8266)
|
|
||||||
EEPROM.commit();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void saveEnableBatVolt() {
|
|
||||||
EEPROM.put(P_ENABLE_BATVOLT, enableBatVolt);
|
|
||||||
#if defined(ESP8266)
|
|
||||||
EEPROM.commit();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void auto_calibrate() {
|
|
||||||
Serial.print(F("Autocalibration is running"));
|
|
||||||
for (int i = 0; i <= 20; i++) {
|
for (int i = 0; i <= 20; i++) {
|
||||||
Serial.print(F("."));
|
Serial.print(F("."));
|
||||||
delay(100);
|
delay(100);
|
||||||
@ -316,49 +265,14 @@ void auto_calibrate() {
|
|||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
|
||||||
|
// init serial
|
||||||
|
Serial.begin(9600);
|
||||||
|
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
// init webserver
|
|
||||||
WiFi.mode(WIFI_AP);
|
|
||||||
WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
|
|
||||||
WiFi.softAP(ssid, password);
|
|
||||||
|
|
||||||
server.begin();
|
|
||||||
server.on("/", main_page);
|
|
||||||
server.on("/index.html", main_page);
|
|
||||||
server.on("/settings", settings_page);
|
|
||||||
server.on("/settings.png", settingsImg);
|
|
||||||
server.on("/weight.png", weightImg);
|
|
||||||
server.on("/cg.png", cgImg);
|
|
||||||
server.on("/cglr.png", cgLRimg);
|
|
||||||
server.on("/battery.png", batteryImg);
|
|
||||||
server.on("/CG_scale_mechanics.png", mechanicsImg);
|
|
||||||
server.on("/bootstrap.min.css", bootstrap);
|
|
||||||
server.on("bootstrap.min.css", bootstrap);
|
|
||||||
server.on("/popper.min.js", popper);
|
|
||||||
server.on("/bootstrap.min.js", bootstrapmin);
|
|
||||||
server.on("bootstrap.min.js", bootstrapmin);
|
|
||||||
|
|
||||||
SPIFFS.begin();
|
SPIFFS.begin();
|
||||||
EEPROM.begin(EEPROM_SIZE);
|
EEPROM.begin(EEPROM_SIZE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// init OLED display
|
|
||||||
oledDisplay.begin();
|
|
||||||
oledDisplay.firstPage();
|
|
||||||
do {
|
|
||||||
oledDisplay.drawXBMP(20, 12, 18, 18, CGImage);
|
|
||||||
oledDisplay.setFont(u8g2_font_helvR12_tr);
|
|
||||||
oledDisplay.setCursor(45, 28);
|
|
||||||
oledDisplay.print(F("CG scale"));
|
|
||||||
|
|
||||||
oledDisplay.setFont(u8g2_font_5x7_tr);
|
|
||||||
oledDisplay.setCursor(35, 55);
|
|
||||||
oledDisplay.print(F("Version: "));
|
|
||||||
oledDisplay.print(CGSCALE_VERSION);
|
|
||||||
oledDisplay.setCursor(20, 64);
|
|
||||||
oledDisplay.print(F("(c) 2019 M. Lehmann"));
|
|
||||||
} while ( oledDisplay.nextPage() );
|
|
||||||
|
|
||||||
// read settings from eeprom
|
// read settings from eeprom
|
||||||
if (EEPROM.read(P_NUMBER_LOADCELLS) != 0xFF) {
|
if (EEPROM.read(P_NUMBER_LOADCELLS) != 0xFF) {
|
||||||
nLoadcells = EEPROM.read(P_NUMBER_LOADCELLS);
|
nLoadcells = EEPROM.read(P_NUMBER_LOADCELLS);
|
||||||
@ -408,6 +322,47 @@ void setup() {
|
|||||||
EEPROM.get(P_RESISTOR_R2, resistorR2);
|
EEPROM.get(P_RESISTOR_R2, resistorR2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(ESP8266)
|
||||||
|
if (EEPROM.read(P_SSID_STA) != 0xFF) {
|
||||||
|
EEPROM.get(P_SSID_STA, ssid_STA);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (EEPROM.read(P_PASSWORD_STA) != 0xFF) {
|
||||||
|
EEPROM.get(P_PASSWORD_STA, password_STA);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (EEPROM.read(P_SSID_AP) != 0xFF) {
|
||||||
|
EEPROM.get(P_SSID_AP, ssid_AP);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (EEPROM.read(P_PASSWORD_AP) != 0xFF) {
|
||||||
|
EEPROM.get(P_PASSWORD_AP, password_AP);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start by connecting to a WiFi network
|
||||||
|
WiFi.mode(WIFI_STA);
|
||||||
|
WiFi.begin(ssid_STA, password_STA);
|
||||||
|
|
||||||
|
long timeoutWiFi = millis();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// init OLED display
|
||||||
|
oledDisplay.begin();
|
||||||
|
oledDisplay.firstPage();
|
||||||
|
do {
|
||||||
|
oledDisplay.drawXBMP(20, 12, 18, 18, CGImage);
|
||||||
|
oledDisplay.setFont(u8g2_font_helvR12_tr);
|
||||||
|
oledDisplay.setCursor(45, 28);
|
||||||
|
oledDisplay.print(F("CG scale"));
|
||||||
|
|
||||||
|
oledDisplay.setFont(u8g2_font_5x7_tr);
|
||||||
|
oledDisplay.setCursor(35, 55);
|
||||||
|
oledDisplay.print(F("Version: "));
|
||||||
|
oledDisplay.print(CGSCALE_VERSION);
|
||||||
|
oledDisplay.setCursor(20, 64);
|
||||||
|
oledDisplay.print(F("(c) 2019 M. Lehmann"));
|
||||||
|
} while ( oledDisplay.nextPage() );
|
||||||
|
|
||||||
// init Loadcells
|
// init Loadcells
|
||||||
LoadCell_1.begin();
|
LoadCell_1.begin();
|
||||||
LoadCell_2.begin();
|
LoadCell_2.begin();
|
||||||
@ -464,9 +419,61 @@ void setup() {
|
|||||||
delay(200);
|
delay(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
// init serial
|
#if defined(ESP8266)
|
||||||
Serial.begin(9600);
|
while (WiFi.status() != WL_CONNECTED) {
|
||||||
|
delay(500);
|
||||||
|
if (WiFi.status() == WL_NO_SSID_AVAIL) {
|
||||||
|
break;
|
||||||
|
} else if (WiFi.status() == WL_CONNECT_FAILED) {
|
||||||
|
break;
|
||||||
|
} else if ((millis() - timeoutWiFi) > TIMEOUT_CONNECT) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (WiFi.status() == WL_CONNECTED) {
|
||||||
|
// if connected, print status
|
||||||
|
oledDisplay.firstPage();
|
||||||
|
do {
|
||||||
|
oledDisplay.setFont(u8g2_font_5x7_tr);
|
||||||
|
oledDisplay.setCursor(0, 7);
|
||||||
|
oledDisplay.print(F("Connected to WiFi:"));
|
||||||
|
oledDisplay.setCursor(0, 43);
|
||||||
|
oledDisplay.print(F("IP address:"));
|
||||||
|
|
||||||
|
oledDisplay.setFont(u8g2_font_helvR12_tr);
|
||||||
|
oledDisplay.setCursor(0, 28);
|
||||||
|
oledDisplay.print(ssid_STA);
|
||||||
|
oledDisplay.setCursor(0, 64);
|
||||||
|
oledDisplay.print(WiFi.localIP());
|
||||||
|
} while ( oledDisplay.nextPage() );
|
||||||
|
delay(5000);
|
||||||
|
} else {
|
||||||
|
// if WiFi not connected, switch to access point mode
|
||||||
|
WiFi.mode(WIFI_AP);
|
||||||
|
WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
|
||||||
|
WiFi.softAP(ssid_AP, password_AP);
|
||||||
|
}
|
||||||
|
|
||||||
|
// init webserver
|
||||||
|
server.begin();
|
||||||
|
|
||||||
|
// When the client requests data
|
||||||
|
server.on("/getHead", getHead);
|
||||||
|
server.on("/getValue", getValue);
|
||||||
|
server.on("/getRawValue", getRawValue);
|
||||||
|
server.on("/getParameter", getParameter);
|
||||||
|
server.on("/getWiFiNetworks", getWiFiNetworks);
|
||||||
|
server.on("/saveParameter", saveParameter);
|
||||||
|
server.on("/resetDefault", resetDefault);
|
||||||
|
server.on("/autoCalibrate", autoCalibrate);
|
||||||
|
|
||||||
|
// If the client requests any URI
|
||||||
|
server.onNotFound([]() {
|
||||||
|
if (!handleFileRead(server.uri()))
|
||||||
|
server.send(404, "text/plain", "404: Not Found");
|
||||||
|
});
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -478,7 +485,6 @@ void loop() {
|
|||||||
LoadCell_3.update();
|
LoadCell_3.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// update loadcell values
|
// update loadcell values
|
||||||
if ((millis() - lastTimeLoadcell) > UPDATE_INTERVAL_LOADCELL) {
|
if ((millis() - lastTimeLoadcell) > UPDATE_INTERVAL_LOADCELL) {
|
||||||
lastTimeLoadcell = millis();
|
lastTimeLoadcell = millis();
|
||||||
@ -501,7 +507,6 @@ void loop() {
|
|||||||
lastWeightLoadCell3 = weightLoadCell3;
|
lastWeightLoadCell3 = weightLoadCell3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 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();
|
||||||
@ -543,7 +548,6 @@ void loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
oledDisplay.firstPage();
|
oledDisplay.firstPage();
|
||||||
do {
|
do {
|
||||||
if (errMsgCnt == 0) {
|
if (errMsgCnt == 0) {
|
||||||
@ -602,43 +606,43 @@ void loop() {
|
|||||||
break;
|
break;
|
||||||
case MENU_LOADCELLS:
|
case MENU_LOADCELLS:
|
||||||
nLoadcells = Serial.parseInt();
|
nLoadcells = Serial.parseInt();
|
||||||
saveLoadcells();
|
EEPROM.put(P_NUMBER_LOADCELLS, nLoadcells);
|
||||||
menuPage = 0;
|
menuPage = 0;
|
||||||
updateMenu = true;
|
updateMenu = true;
|
||||||
break;
|
break;
|
||||||
case MENU_DISTANCE_X1:
|
case MENU_DISTANCE_X1:
|
||||||
distanceX1 = Serial.parseFloat();
|
distanceX1 = Serial.parseFloat();
|
||||||
saveDistanceX1();
|
EEPROM.put(P_DISTANCE_X1, distanceX1);
|
||||||
menuPage = 0;
|
menuPage = 0;
|
||||||
updateMenu = true;
|
updateMenu = true;
|
||||||
break;
|
break;
|
||||||
case MENU_DISTANCE_X2:
|
case MENU_DISTANCE_X2:
|
||||||
distanceX2 = Serial.parseFloat();
|
distanceX2 = Serial.parseFloat();
|
||||||
saveDistanceX2();
|
EEPROM.put(P_DISTANCE_X2, distanceX2);
|
||||||
menuPage = 0;
|
menuPage = 0;
|
||||||
updateMenu = true;
|
updateMenu = true;
|
||||||
break;
|
break;
|
||||||
case MENU_DISTANCE_X3:
|
case MENU_DISTANCE_X3:
|
||||||
distanceX3 = Serial.parseFloat();
|
distanceX3 = Serial.parseFloat();
|
||||||
saveDistanceX3();
|
EEPROM.put(P_DISTANCE_X3, distanceX3);
|
||||||
menuPage = 0;
|
menuPage = 0;
|
||||||
updateMenu = true;
|
updateMenu = true;
|
||||||
break;
|
break;
|
||||||
case MENU_REF_WEIGHT:
|
case MENU_REF_WEIGHT:
|
||||||
refWeight = Serial.parseFloat();
|
refWeight = Serial.parseFloat();
|
||||||
saveRefWeight();
|
EEPROM.put(P_REF_WEIGHT, refWeight);
|
||||||
menuPage = 0;
|
menuPage = 0;
|
||||||
updateMenu = true;
|
updateMenu = true;
|
||||||
break;
|
break;
|
||||||
case MENU_REF_CG:
|
case MENU_REF_CG:
|
||||||
refCG = Serial.parseFloat();
|
refCG = Serial.parseFloat();
|
||||||
saveRefCG();
|
EEPROM.put(P_REF_CG, refCG);
|
||||||
menuPage = 0;
|
menuPage = 0;
|
||||||
updateMenu = true;
|
updateMenu = true;
|
||||||
break;
|
break;
|
||||||
case MENU_AUTO_CALIBRATE:
|
case MENU_AUTO_CALIBRATE:
|
||||||
if (Serial.read() == 'J') {
|
if (Serial.read() == 'J') {
|
||||||
auto_calibrate();
|
runAutoCalibrate();
|
||||||
menuPage = 0;
|
menuPage = 0;
|
||||||
updateMenu = true;
|
updateMenu = true;
|
||||||
}
|
}
|
||||||
@ -663,13 +667,13 @@ void loop() {
|
|||||||
break;
|
break;
|
||||||
case MENU_RESISTOR_R1:
|
case MENU_RESISTOR_R1:
|
||||||
resistorR1 = Serial.parseFloat();
|
resistorR1 = Serial.parseFloat();
|
||||||
saveResistorR1();
|
EEPROM.put(P_RESISTOR_R1, resistorR1);
|
||||||
menuPage = 0;
|
menuPage = 0;
|
||||||
updateMenu = true;
|
updateMenu = true;
|
||||||
break;
|
break;
|
||||||
case MENU_RESISTOR_R2:
|
case MENU_RESISTOR_R2:
|
||||||
resistorR2 = Serial.parseFloat();
|
resistorR2 = Serial.parseFloat();
|
||||||
saveResistorR2();
|
EEPROM.put(P_RESISTOR_R2, resistorR2);
|
||||||
menuPage = 0;
|
menuPage = 0;
|
||||||
updateMenu = true;
|
updateMenu = true;
|
||||||
break;
|
break;
|
||||||
@ -679,7 +683,7 @@ void loop() {
|
|||||||
} else {
|
} else {
|
||||||
enableBatVolt = false;
|
enableBatVolt = false;
|
||||||
}
|
}
|
||||||
saveEnableBatVolt();
|
EEPROM.put(P_ENABLE_BATVOLT, enableBatVolt);
|
||||||
menuPage = 0;
|
menuPage = 0;
|
||||||
updateMenu = true;
|
updateMenu = true;
|
||||||
break;
|
break;
|
||||||
@ -689,17 +693,8 @@ void loop() {
|
|||||||
updateMenu = true;
|
updateMenu = true;
|
||||||
break;
|
break;
|
||||||
case MENU_RESET_DEFAULT:
|
case MENU_RESET_DEFAULT:
|
||||||
//chr = Serial.read();
|
|
||||||
if (Serial.read() == 'J') {
|
if (Serial.read() == 'J') {
|
||||||
// reset eeprom
|
resetDefault();
|
||||||
for (int i = 0; i < EEPROM_SIZE; i++) {
|
|
||||||
EEPROM.write(i, 0xFF);
|
|
||||||
}
|
|
||||||
Serial.end();
|
|
||||||
#if defined(ESP8266)
|
|
||||||
EEPROM.commit();
|
|
||||||
#endif
|
|
||||||
resetCPU();
|
|
||||||
}
|
}
|
||||||
menuPage = 0;
|
menuPage = 0;
|
||||||
updateMenu = true;
|
updateMenu = true;
|
||||||
@ -875,157 +870,126 @@ void loop() {
|
|||||||
|
|
||||||
|
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
void main_page()
|
|
||||||
{
|
|
||||||
char buff[8];
|
|
||||||
String webPage = "<!doctype html>";
|
|
||||||
webPage += "<html lang=\"en\">";
|
|
||||||
webPage += "<head>";
|
|
||||||
webPage += "<meta charset=\"utf-8\">";
|
|
||||||
webPage += "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\">";
|
|
||||||
webPage += "<meta name=\"description\" content=\"\">";
|
|
||||||
webPage += "<meta name=\"author\" content=\"\">";
|
|
||||||
webPage += "<link rel=\"icon\" href=\"/favicon.ico\">";
|
|
||||||
webPage += "<title>CG scale by M. Lehmann</title>";
|
|
||||||
webPage += "<link href=\"/bootstrap.min.css\" rel=\"stylesheet\">";
|
|
||||||
webPage += "<link href=\"navbar-top-fixed.css\" rel=\"stylesheet\">";
|
|
||||||
webPage += "<meta http-equiv=\"refresh\" content=\"";
|
|
||||||
webPage += REFRESH_TIME;
|
|
||||||
webPage += "\">";
|
|
||||||
webPage += "</head>";
|
|
||||||
webPage += "<body>";
|
|
||||||
webPage += "<nav class=\"navbar navbar-dark fixed-top bg-dark\">";
|
|
||||||
webPage += "<div class=\"container-fluid\">";
|
|
||||||
webPage += "<div class=\"navbar-header\">";
|
|
||||||
webPage += "<a class=\"navbar-brand\" href=\"#\">";
|
|
||||||
webPage += ssid;
|
|
||||||
webPage += "</a>";
|
|
||||||
webPage += "</div>";
|
|
||||||
webPage += "<ul class=\"nav navbar-nav navbar-right\">";
|
|
||||||
webPage += "<button type=\"button\" onclick=\"location.href = '/settings'\" class=\"btn btn-danger\">";
|
|
||||||
webPage += "<img src=\"settings.png\" alt=\"\" style=\"width:auto;height:30px\">";
|
|
||||||
webPage += "</button>";
|
|
||||||
webPage += "</ul>";
|
|
||||||
webPage += "</div>";
|
|
||||||
webPage += "</nav>";
|
|
||||||
webPage += "<br><br><br>";
|
|
||||||
webPage += "<main role=\"main\" class=\"container\">";
|
|
||||||
webPage += "<div class=\"jumbotron\">";
|
|
||||||
if (errMsgCnt == 0) {
|
|
||||||
// print weight
|
|
||||||
webPage += "<div class=\"container\">";
|
|
||||||
webPage += "<div class=\"row mt-3\">";
|
|
||||||
webPage += "<div class=\"col-xs-6\"><img src=\"weight.png\" class=\"pull-left mr-4\" alt=\"weight\" style=\"width:auto;height:50px\"></div>";
|
|
||||||
webPage += "<div class=\"col-xs-6 d-flex align-items-center\"><font size=\"6\"> ";
|
|
||||||
dtostrf(weightTotal, 5, 1, buff);
|
|
||||||
webPage += buff;
|
|
||||||
webPage += "g</div>";
|
|
||||||
webPage += "</div>";
|
|
||||||
webPage += "</div>";
|
|
||||||
|
|
||||||
// print cg
|
// send headvalues to client
|
||||||
webPage += "<div class=\"container\">";
|
void getHead() {
|
||||||
webPage += "<div class=\"row mt-3\">";
|
String response = ssid_AP;
|
||||||
webPage += "<div class=\"col-xs-6\"><img src=\"cg.png\" class=\"pull-left mr-4\" alt=\"weight\" style=\"width:auto;height:50px\"></div>";
|
response += "&";
|
||||||
webPage += "<div class=\"col-xs-6 d-flex align-items-center\"><font size=\"6\"> ";
|
|
||||||
dtostrf(CG_length, 5, 1, buff);
|
|
||||||
webPage += buff;
|
|
||||||
webPage += "mm</div>";
|
|
||||||
webPage += "</div>";
|
|
||||||
webPage += "</div>";
|
|
||||||
|
|
||||||
// print cg trans
|
|
||||||
if (nLoadcells > 2) {
|
|
||||||
webPage += "<div class=\"container\">";
|
|
||||||
webPage += "<div class=\"row mt-3\">";
|
|
||||||
webPage += "<div class=\"col-xs-6\"><img src=\"cglr.png\" class=\"pull-left mr-4\" alt=\"weight\" style=\"width:auto;height:50px\"></div>";
|
|
||||||
webPage += "<div class=\"col-xs-6 d-flex align-items-center\"><font size=\"6\"> ";
|
|
||||||
dtostrf(CG_trans, 5, 1, buff);
|
|
||||||
webPage += buff;
|
|
||||||
webPage += "mm</div>";
|
|
||||||
webPage += "</div>";
|
|
||||||
webPage += "</div>";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// print battery
|
|
||||||
if (enableBatVolt) {
|
|
||||||
webPage += "<div class=\"container\">";
|
|
||||||
webPage += "<div class=\"row mt-3\">";
|
|
||||||
webPage += "<div class=\"col-xs-6\"><img src=\"battery.png\" class=\"pull-left mr-4\" alt=\"weight\" style=\"width:auto;height:50px\"></div>";
|
|
||||||
webPage += "<div class=\"col-xs-6 d-flex align-items-center\"><font size=\"6\"> ";
|
|
||||||
webPage += batVolt;
|
|
||||||
webPage += "V</div>";
|
|
||||||
webPage += "</div>";
|
|
||||||
webPage += "</div>";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
webPage += "<div class=\"container\">";
|
|
||||||
webPage += "<font size=\"6\"> ";
|
|
||||||
for (int i = 1; i <= errMsgCnt; i++) {
|
for (int i = 1; i <= errMsgCnt; i++) {
|
||||||
webPage += errMsg[i];
|
response += errMsg[i];
|
||||||
}
|
}
|
||||||
webPage += "</div>";
|
response += "&";
|
||||||
}
|
response += CGSCALE_VERSION;
|
||||||
webPage += "</div>";
|
server.send(200, "text/html", response);
|
||||||
webPage += "</main>";
|
|
||||||
webPage += "<p><font size=\"2\"><center>(c) 2019 M. Lehmann - Version: ";
|
|
||||||
webPage += CGSCALE_VERSION;
|
|
||||||
webPage += "</center></font></p>";
|
|
||||||
webPage += "<script src=\"/bootstrap.min.js\"></script>";
|
|
||||||
webPage += "</body>";
|
|
||||||
webPage += "</html>";
|
|
||||||
|
|
||||||
server.send(200, "text/html", webPage);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void settings_page()
|
|
||||||
{
|
// send values to client
|
||||||
if ( server.hasArg("nLoadcells")) {
|
void getValue() {
|
||||||
nLoadcells = server.arg("nLoadcells").toFloat();
|
char buff[8];
|
||||||
saveLoadcells();
|
String response = "";
|
||||||
|
dtostrf(weightTotal, 5, 1, buff);
|
||||||
|
response += buff;
|
||||||
|
response += "g&";
|
||||||
|
dtostrf(CG_length, 5, 1, buff);
|
||||||
|
response += buff;
|
||||||
|
response += "mm&";
|
||||||
|
dtostrf(CG_trans, 5, 1, buff);
|
||||||
|
response += buff;
|
||||||
|
response += "mm&";
|
||||||
|
dtostrf(batVolt, 5, 2, buff);
|
||||||
|
response += buff;
|
||||||
|
response += "V";
|
||||||
|
server.send(200, "text/html", response);
|
||||||
}
|
}
|
||||||
if ( server.hasArg("distanceX1")) {
|
|
||||||
distanceX1 = server.arg("distanceX1").toFloat();
|
|
||||||
saveDistanceX1();
|
// send raw values to client
|
||||||
|
void getRawValue() {
|
||||||
|
char buff[8];
|
||||||
|
String response = "";
|
||||||
|
dtostrf(weightLoadCell1, 5, 1, buff);
|
||||||
|
response += buff;
|
||||||
|
response += "g&";
|
||||||
|
dtostrf(weightLoadCell2, 5, 1, buff);
|
||||||
|
response += buff;
|
||||||
|
response += "g&";
|
||||||
|
dtostrf(weightLoadCell3, 5, 1, buff);
|
||||||
|
response += buff;
|
||||||
|
response += "g";
|
||||||
|
server.send(200, "text/html", response);
|
||||||
}
|
}
|
||||||
if ( server.hasArg("distanceX2")) {
|
|
||||||
distanceX2 = server.arg("distanceX2").toFloat();
|
|
||||||
saveDistanceX2();
|
// send parameters to client
|
||||||
|
void getParameter() {
|
||||||
|
String response = "";
|
||||||
|
response += nLoadcells;
|
||||||
|
response += "&";
|
||||||
|
response += distanceX1;
|
||||||
|
response += "&";
|
||||||
|
response += distanceX2;
|
||||||
|
response += "&";
|
||||||
|
response += distanceX3;
|
||||||
|
response += "&";
|
||||||
|
response += refWeight;
|
||||||
|
response += "&";
|
||||||
|
response += refCG;
|
||||||
|
response += "&";
|
||||||
|
response += calFactorLoadcell1;
|
||||||
|
response += "&";
|
||||||
|
response += calFactorLoadcell2;
|
||||||
|
response += "&";
|
||||||
|
response += calFactorLoadcell3;
|
||||||
|
response += "&";
|
||||||
|
response += resistorR1;
|
||||||
|
response += "&";
|
||||||
|
response += resistorR2;
|
||||||
|
response += "&";
|
||||||
|
if (enableBatVolt) {
|
||||||
|
response += "ON";
|
||||||
|
} else {
|
||||||
|
response += "OFF";
|
||||||
}
|
}
|
||||||
if ( server.hasArg("distanceX3")) {
|
response += "&";
|
||||||
distanceX3 = server.arg("distanceX3").toFloat();
|
response += ssid_STA;
|
||||||
saveDistanceX3();
|
response += "&";
|
||||||
|
response += password_STA;
|
||||||
|
response += "&";
|
||||||
|
response += ssid_AP;
|
||||||
|
response += "&";
|
||||||
|
response += password_AP;
|
||||||
|
server.send(200, "text/html", response);
|
||||||
}
|
}
|
||||||
if ( server.hasArg("refWeight")) {
|
|
||||||
refWeight = server.arg("refWeight").toFloat();
|
|
||||||
saveRefWeight();
|
// send available WiFi networks to client
|
||||||
|
void getWiFiNetworks() {
|
||||||
|
String response = "";
|
||||||
|
int n = WiFi.scanNetworks();
|
||||||
|
if (n > 0) {
|
||||||
|
for (int i = 0; i < n; ++i) {
|
||||||
|
response += WiFi.SSID(i);
|
||||||
|
if (i < n - 1) response += "&";
|
||||||
}
|
}
|
||||||
if ( server.hasArg("refCG")) {
|
|
||||||
refCG = server.arg("refCG").toFloat();
|
|
||||||
saveRefCG();
|
|
||||||
}
|
}
|
||||||
if ( server.hasArg("calFactorLoadcell1")) {
|
server.send(200, "text/html", response);
|
||||||
calFactorLoadcell1 = server.arg("calFactorLoadcell1").toFloat();
|
|
||||||
saveCalFactor1();
|
|
||||||
}
|
|
||||||
if ( server.hasArg("calFactorLoadcell2")) {
|
|
||||||
calFactorLoadcell2 = server.arg("calFactorLoadcell2").toFloat();
|
|
||||||
saveCalFactor2();
|
|
||||||
}
|
|
||||||
if ( server.hasArg("calFactorLoadcell3")) {
|
|
||||||
calFactorLoadcell3 = server.arg("calFactorLoadcell3").toFloat();
|
|
||||||
saveCalFactor3();
|
|
||||||
}
|
|
||||||
if ( server.hasArg("resistorR1")) {
|
|
||||||
resistorR1 = server.arg("resistorR1").toFloat();
|
|
||||||
saveResistorR1();
|
|
||||||
}
|
|
||||||
if ( server.hasArg("resistorR2")) {
|
|
||||||
resistorR2 = server.arg("resistorR2").toFloat();
|
|
||||||
saveResistorR2();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// save parameters
|
||||||
|
void saveParameter() {
|
||||||
|
if (server.hasArg("nLoadcells")) nLoadcells = server.arg("nLoadcells").toFloat();
|
||||||
|
if (server.hasArg("distanceX1")) distanceX1 = server.arg("distanceX1").toFloat();
|
||||||
|
if (server.hasArg("distanceX2")) distanceX2 = server.arg("distanceX2").toFloat();
|
||||||
|
if (server.hasArg("distanceX3")) distanceX3 = server.arg("distanceX3").toFloat();
|
||||||
|
if (server.hasArg("refWeight")) refWeight = server.arg("refWeight").toFloat();
|
||||||
|
if (server.hasArg("refCG")) refCG = server.arg("refCG").toFloat();
|
||||||
|
if (server.hasArg("calFactorLoadcell1")) calFactorLoadcell1 = server.arg("calFactorLoadcell1").toFloat();
|
||||||
|
if (server.hasArg("calFactorLoadcell2")) calFactorLoadcell2 = server.arg("calFactorLoadcell2").toFloat();
|
||||||
|
if (server.hasArg("calFactorLoadcell3")) calFactorLoadcell3 = server.arg("calFactorLoadcell3").toFloat();
|
||||||
|
if (server.hasArg("resistorR1")) resistorR1 = server.arg("resistorR1").toFloat();
|
||||||
|
if (server.hasArg("resistorR2")) resistorR2 = server.arg("resistorR2").toFloat();
|
||||||
if (server.hasArg("enableBatVolt")) {
|
if (server.hasArg("enableBatVolt")) {
|
||||||
if (server.arg("enableBatVolt") == "ON") {
|
if (server.arg("enableBatVolt") == "ON") {
|
||||||
enableBatVolt = true;
|
enableBatVolt = true;
|
||||||
@ -1033,208 +997,69 @@ void settings_page()
|
|||||||
enableBatVolt = false;
|
enableBatVolt = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( server.hasArg("calibrate")) {
|
if (server.hasArg("ssid_STA")) server.arg("ssid_STA").toCharArray(ssid_STA, MAX_SSID_PW_LENGHT + 1);
|
||||||
auto_calibrate();
|
if (server.hasArg("password_STA")) server.arg("password_STA").toCharArray(password_STA, MAX_SSID_PW_LENGHT + 1);
|
||||||
|
if (server.hasArg("ssid_AP")) server.arg("ssid_AP").toCharArray(ssid_AP, MAX_SSID_PW_LENGHT + 1);
|
||||||
|
if (server.hasArg("password_AP")) server.arg("password_AP").toCharArray(password_AP, MAX_SSID_PW_LENGHT + 1);
|
||||||
|
|
||||||
|
EEPROM.put(P_NUMBER_LOADCELLS, nLoadcells);
|
||||||
|
EEPROM.put(P_DISTANCE_X1, distanceX1);
|
||||||
|
EEPROM.put(P_DISTANCE_X2, distanceX2);
|
||||||
|
EEPROM.put(P_DISTANCE_X3, distanceX3);
|
||||||
|
EEPROM.put(P_REF_WEIGHT, refWeight);
|
||||||
|
EEPROM.put(P_REF_CG, refCG);
|
||||||
|
saveCalFactor1();
|
||||||
|
saveCalFactor2();
|
||||||
|
saveCalFactor3();
|
||||||
|
EEPROM.put(P_RESISTOR_R1, resistorR1);
|
||||||
|
EEPROM.put(P_RESISTOR_R2, resistorR2);
|
||||||
|
EEPROM.put(P_ENABLE_BATVOLT, enableBatVolt);
|
||||||
|
EEPROM.put(P_SSID_STA, ssid_STA);
|
||||||
|
EEPROM.put(P_PASSWORD_STA, password_STA);
|
||||||
|
EEPROM.put(P_SSID_AP, ssid_AP);
|
||||||
|
EEPROM.put(P_PASSWORD_AP, password_AP);
|
||||||
|
EEPROM.commit();
|
||||||
|
|
||||||
|
server.send(200, "text/html", "ok");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String webPage = "<!doctype html>";
|
// calibrate cg scale
|
||||||
webPage += "<html lang=\"en\">";
|
void autoCalibrate() {
|
||||||
webPage += "<head>";
|
while (!runAutoCalibrate());
|
||||||
webPage += "<meta charset=\"utf-8\">";
|
server.send(200, "text/html", "ok");
|
||||||
webPage += "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\">";
|
|
||||||
webPage += "<meta name=\"description\" content=\"\">";
|
|
||||||
webPage += "<meta name=\"author\" content=\"\">";
|
|
||||||
webPage += "<link rel=\"icon\" href=\"/favicon.ico\">";
|
|
||||||
webPage += "<title>CG scale by M. Lehmann</title>";
|
|
||||||
webPage += "<link href=\"/bootstrap.min.css\" rel=\"stylesheet\">";
|
|
||||||
webPage += "<link href=\"navbar-top-fixed.css\" rel=\"stylesheet\">";
|
|
||||||
webPage += "</head>";
|
|
||||||
webPage += "<body>";
|
|
||||||
webPage += "<nav class=\"navbar navbar-dark fixed-top bg-dark\">";
|
|
||||||
webPage += "<div class=\"container-fluid\">";
|
|
||||||
webPage += "<div class=\"navbar-header\">";
|
|
||||||
webPage += "<a class=\"navbar-brand\" href=\"#\">";
|
|
||||||
webPage += ssid;
|
|
||||||
webPage += "</a>";
|
|
||||||
webPage += "</div>";
|
|
||||||
webPage += "<ul class=\"nav navbar-nav navbar-right\">";
|
|
||||||
webPage += "<button type=\"button\" onclick=\"location.href = '/'\" class=\"btn btn-danger\">Home</button>";
|
|
||||||
webPage += "</ul>";
|
|
||||||
webPage += "</div>";
|
|
||||||
webPage += "</nav>";
|
|
||||||
webPage += "<br><br><br>";
|
|
||||||
webPage += "<main role=\"main\" class=\"container\">";
|
|
||||||
|
|
||||||
webPage += "<form action=\"/settings\" id=\"saveForm\">";
|
|
||||||
webPage += "<div class=\"form-group\">";
|
|
||||||
webPage += "<label>Number of load cells:</label>";
|
|
||||||
webPage += "<select class=\"form-control\" name=\"nLoadcells\">";
|
|
||||||
if (nLoadcells == 2) {
|
|
||||||
webPage += "<option selected>2</option>";
|
|
||||||
webPage += "<option>3</option>";
|
|
||||||
}
|
|
||||||
if (nLoadcells == 3) {
|
|
||||||
webPage += "<option>2</option>";
|
|
||||||
webPage += "<option selected>3</option>";
|
|
||||||
}
|
|
||||||
webPage += "</select>";
|
|
||||||
webPage += "</div>";
|
|
||||||
|
|
||||||
webPage += "<div class=\"form-group\">";
|
|
||||||
webPage += "<label>Distance X1 [mm]:</label>";
|
|
||||||
webPage += "<input type=\"text\" class=\"form-control\" name=\"distanceX1\" value=\"";
|
|
||||||
webPage += distanceX1;
|
|
||||||
webPage += "\">";
|
|
||||||
webPage += "</div>";
|
|
||||||
|
|
||||||
webPage += "<div class=\"form-group\">";
|
|
||||||
webPage += "<label>Distance X2 [mm]:</label>";
|
|
||||||
webPage += "<input type=\"text\" class=\"form-control\" name=\"distanceX2\" value=\"";
|
|
||||||
webPage += distanceX2;
|
|
||||||
webPage += "\">";
|
|
||||||
webPage += "</div>";
|
|
||||||
|
|
||||||
webPage += "<div class=\"form-group\">";
|
|
||||||
webPage += "<label>Distance X3 [mm]:</label>";
|
|
||||||
webPage += "<input type=\"text\" class=\"form-control\" name=\"distanceX3\" value=\"";
|
|
||||||
webPage += distanceX3;
|
|
||||||
webPage += "\">";
|
|
||||||
webPage += "</div>";
|
|
||||||
|
|
||||||
webPage += "<div class=\"form-group\">";
|
|
||||||
webPage += "<label>Reference weight [g]:</label>";
|
|
||||||
webPage += "<input type=\"text\" class=\"form-control\" name=\"refWeight\" value=\"";
|
|
||||||
webPage += refWeight;
|
|
||||||
webPage += "\">";
|
|
||||||
webPage += "</div>";
|
|
||||||
|
|
||||||
webPage += "<div class=\"form-group\">";
|
|
||||||
webPage += "<label>Reference CG [mm]:</label>";
|
|
||||||
webPage += "<input type=\"text\" class=\"form-control\" name=\"refCG\" value=\"";
|
|
||||||
webPage += refCG;
|
|
||||||
webPage += "\">";
|
|
||||||
webPage += "</div>";
|
|
||||||
|
|
||||||
webPage += "<div class=\"form-group\">";
|
|
||||||
webPage += "<label>Calibration factor of load cell 1:</label>";
|
|
||||||
webPage += "<input type=\"text\" class=\"form-control\" name=\"calFactorLoadcell1\" value=\"";
|
|
||||||
webPage += calFactorLoadcell1;
|
|
||||||
webPage += "\">";
|
|
||||||
webPage += "</div>";
|
|
||||||
|
|
||||||
webPage += "<div class=\"form-group\">";
|
|
||||||
webPage += "<label>Calibration factor of load cell 2:</label>";
|
|
||||||
webPage += "<input type=\"text\" class=\"form-control\" name=\"calFactorLoadcell2\" value=\"";
|
|
||||||
webPage += calFactorLoadcell2;
|
|
||||||
webPage += "\">";
|
|
||||||
webPage += "</div>";
|
|
||||||
|
|
||||||
webPage += "<div class=\"form-group\">";
|
|
||||||
webPage += "<label>Calibration factor of load cell 3:</label>";
|
|
||||||
webPage += "<input type=\"text\" class=\"form-control\" name=\"calFactorLoadcell3\" value=\"";
|
|
||||||
webPage += calFactorLoadcell3;
|
|
||||||
webPage += "\">";
|
|
||||||
webPage += "</div>";
|
|
||||||
|
|
||||||
webPage += "<div class=\"form-group\">";
|
|
||||||
webPage += "<label>Value of resistor R1 [ohm]:</label>";
|
|
||||||
webPage += "<input type=\"text\" class=\"form-control\" name=\"resistorR1\" value=\"";
|
|
||||||
webPage += resistorR1;
|
|
||||||
webPage += "\">";
|
|
||||||
webPage += "</div>";
|
|
||||||
|
|
||||||
webPage += "<div class=\"form-group\">";
|
|
||||||
webPage += "<label>Value of resistor R2 [ohm]:</label>";
|
|
||||||
webPage += "<input type=\"text\" class=\"form-control\" name=\"resistorR2\" value=\"";
|
|
||||||
webPage += resistorR2;
|
|
||||||
webPage += "\">";
|
|
||||||
webPage += "</div>";
|
|
||||||
|
|
||||||
webPage += "<div class=\"form-group\">";
|
|
||||||
webPage += "<label>Voltage measurement:</label>";
|
|
||||||
webPage += "<select class=\"form-control\" name=\"enableBatVolt\">";
|
|
||||||
if (enableBatVolt) {
|
|
||||||
webPage += "<option selected>ON</option>";
|
|
||||||
webPage += "<option>OFF</option>";
|
|
||||||
} else {
|
|
||||||
webPage += "<option>ON</option>";
|
|
||||||
webPage += "<option selected>OFF</option>";
|
|
||||||
}
|
|
||||||
webPage += "</select>";
|
|
||||||
webPage += "</div>";
|
|
||||||
|
|
||||||
webPage += "</form>";
|
|
||||||
|
|
||||||
webPage += "<div class=\"btn-group btn-group-lg\">";
|
|
||||||
webPage += "<button type=\"button submit\" class=\"btn btn-success btn-lg\" form=\"saveForm\">save parameters</button>";
|
|
||||||
webPage += "<form action=\"/settings\" method=\"POST\"><button type=\"button submit\" class=\"btn btn-primary btn-lg\" name=\"calibrate\" value=\"1\">auto calibrate</button></form>";
|
|
||||||
webPage += "</div>";
|
|
||||||
|
|
||||||
webPage += "<img src=\"CG_scale_mechanics.png\" class=\"pull-left mr-4\" alt=\"mechanics\" style=\"width:100%\">";
|
|
||||||
|
|
||||||
webPage += "</main>";
|
|
||||||
webPage += "<p><font size=\"2\"><center>(c) 2019 M. Lehmann - Version: ";
|
|
||||||
webPage += CGSCALE_VERSION;
|
|
||||||
webPage += "</center></font></p>";
|
|
||||||
webPage += "<script src=\"/bootstrap.min.js\"></script>";
|
|
||||||
webPage += "</body>";
|
|
||||||
webPage += "</html>";
|
|
||||||
|
|
||||||
server.send(200, "text/html", webPage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void settingsImg()
|
|
||||||
{
|
// convert the file extension to the MIME type
|
||||||
File file = SPIFFS.open("/settings.png", "r");
|
String getContentType(String filename) {
|
||||||
size_t sent = server.streamFile(file, "text/css");
|
if (filename.endsWith(".html")) return "text/html";
|
||||||
|
else if (filename.endsWith(".png")) return "text/css";
|
||||||
|
else if (filename.endsWith(".css")) return "text/css";
|
||||||
|
else if (filename.endsWith(".js")) return "application/javascript";
|
||||||
|
else if (filename.endsWith(".map")) return "application/json";
|
||||||
|
else if (filename.endsWith(".ico")) return "image/x-icon";
|
||||||
|
else if (filename.endsWith(".gz")) return "application/x-gzip";
|
||||||
|
return "text/plain";
|
||||||
}
|
}
|
||||||
|
|
||||||
void weightImg()
|
|
||||||
{
|
|
||||||
File file = SPIFFS.open("/weight.png", "r");
|
|
||||||
size_t sent = server.streamFile(file, "text/css");
|
|
||||||
}
|
|
||||||
|
|
||||||
void cgImg()
|
// send file to the client (if it exists)
|
||||||
{
|
bool handleFileRead(String path) {
|
||||||
File file = SPIFFS.open("/cg.png", "r");
|
// If a folder is requested, send the index file
|
||||||
size_t sent = server.streamFile(file, "text/css");
|
if (path.endsWith("/")) path += "index.html";
|
||||||
}
|
String contentType = getContentType(path);
|
||||||
|
String pathWithGz = path + ".gz";
|
||||||
|
|
||||||
void cgLRimg()
|
// If the file exists, either as a compressed archive, or normal
|
||||||
{
|
if (SPIFFS.exists(pathWithGz) || SPIFFS.exists(path)) {
|
||||||
File file = SPIFFS.open("/cglr.png", "r");
|
if (SPIFFS.exists(pathWithGz))
|
||||||
size_t sent = server.streamFile(file, "text/css");
|
path += ".gz";
|
||||||
|
File file = SPIFFS.open(path, "r");
|
||||||
|
size_t sent = server.streamFile(file, contentType);
|
||||||
|
file.close();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
void batteryImg()
|
|
||||||
{
|
|
||||||
File file = SPIFFS.open("/battery.png", "r");
|
|
||||||
size_t sent = server.streamFile(file, "text/css");
|
|
||||||
}
|
|
||||||
|
|
||||||
void mechanicsImg()
|
|
||||||
{
|
|
||||||
File file = SPIFFS.open("/CG_scale_mechanics.png", "r");
|
|
||||||
size_t sent = server.streamFile(file, "text/css");
|
|
||||||
}
|
|
||||||
|
|
||||||
void bootstrap()
|
|
||||||
{
|
|
||||||
File file = SPIFFS.open("/bootstrap.min.css.gz", "r");
|
|
||||||
size_t sent = server.streamFile(file, "text/css");
|
|
||||||
}
|
|
||||||
|
|
||||||
void popper()
|
|
||||||
{
|
|
||||||
File file = SPIFFS.open("/popper.min.js.gz", "r");
|
|
||||||
size_t sent = server.streamFile(file, "application/javascript");
|
|
||||||
}
|
|
||||||
|
|
||||||
void bootstrapmin()
|
|
||||||
{
|
|
||||||
File file = SPIFFS.open("/bootstrap.min.js.gz", "r");
|
|
||||||
size_t sent = server.streamFile(file, "application/javascript");
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
BIN
data/bootstrap.min.css.map.gz
Normal file
BIN
data/bootstrap.min.css.map.gz
Normal file
Binary file not shown.
124
data/index.html
Executable file
124
data/index.html
Executable file
@ -0,0 +1,124 @@
|
|||||||
|
<!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;
|
||||||
|
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 = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body onload=getValue()>
|
||||||
|
<script>
|
||||||
|
getHead();
|
||||||
|
getParameter();
|
||||||
|
</script>
|
||||||
|
<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">
|
||||||
|
<button type="button" onclick="location.href = '/settings.html'" class="btn btn-danger">
|
||||||
|
<img src="settings.png" alt="" style="width:auto;height:30px">
|
||||||
|
</button>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
<br><br><br>
|
||||||
|
<main role="main" class="container">
|
||||||
|
<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 id="weightTotal">-</span></font></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 id="CG_length">-</span></font></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 id="CG_trans">-</span></font></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 id="batVolt">-</span></font></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="container"><font size="6"><span id="errMsg"></span></font></div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
<p><font size="2"><center>(c) 2019 M. Lehmann - Version: <span id="cgscaleVersion">0.0</span></center></font></p>
|
||||||
|
</body>
|
||||||
|
</html>
|
295
data/settings.html
Executable file
295
data/settings.html
Executable file
@ -0,0 +1,295 @@
|
|||||||
|
<!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("errMsg").innerHTML = value[1];
|
||||||
|
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]);
|
||||||
|
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.open("GET", "saveParameter" + data, true);
|
||||||
|
request.onreadystatechange = function(){
|
||||||
|
if(this.readyState == 4 && this.status == 200){
|
||||||
|
if(this.responseText == "ok"){
|
||||||
|
alert("Parameters saved");
|
||||||
|
getParameter();
|
||||||
|
}else{
|
||||||
|
alert("Save parameter failed !");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
request.send();
|
||||||
|
}
|
||||||
|
function autoCalibrate(){
|
||||||
|
alert("Please put the reference weight on the scale.");
|
||||||
|
var request = new XMLHttpRequest();
|
||||||
|
request.open("GET", "autoCalibrate", true);
|
||||||
|
request.onreadystatechange = function(){
|
||||||
|
if(this.readyState == 4 && this.status == 200){
|
||||||
|
if(this.responseText == "ok"){
|
||||||
|
alert("Calibration successful");
|
||||||
|
getParameter();
|
||||||
|
}else{
|
||||||
|
alert("Calibration failed !");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
request.send();
|
||||||
|
}
|
||||||
|
function resetDefault(){
|
||||||
|
if (confirm("Reset to factory defaults ?")) {
|
||||||
|
var request = new XMLHttpRequest();
|
||||||
|
request.open("GET", "resetDefault", true);
|
||||||
|
request.onreadystatechange = function(){
|
||||||
|
if(this.readyState == 4 && this.status == 200){
|
||||||
|
if(this.responseText == "ok"){
|
||||||
|
alert("Reset to factory defaults successful");
|
||||||
|
getParameter();
|
||||||
|
}else{
|
||||||
|
alert("Reset to factory defaults failed !");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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 onload=getRawValue()>
|
||||||
|
<script>
|
||||||
|
getHead();
|
||||||
|
getWiFiNetworks();
|
||||||
|
getParameter();
|
||||||
|
</script>
|
||||||
|
<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">
|
||||||
|
<button type="button" onclick="location.href = '/'" class="btn btn-danger">Home</button>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
<br><br><br>
|
||||||
|
<main role="main" class="container">
|
||||||
|
<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>
|
||||||
|
<button class="btn btn-danger btn-lg" onclick="resetDefault()">reset</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>
|
||||||
|
<!--<p><font size="4"><center>Lc1: <span id="lc1">-</span> Lc2: <span id="lc2">-</span><div id="lc3_div"> Lc3: <span id="lc3">-</span></div></center></font></p>-->
|
||||||
|
</main>
|
||||||
|
<!--<div class="container"><font size="6"><span id="errMsg">-</span></font></div>-->
|
||||||
|
<p><font size="2"><center>(c) 2019 M. Lehmann - Version: <span id="cgscaleVersion">0.0</span></center></font></p>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -124,12 +124,16 @@ U8G2_SH1106_128X64_NONAME_1_HW_I2C oledDisplay(U8G2_R0, /* reset=*/ U8X8_PIN_NON
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// **** Web server settings ****
|
// **** Wifi settings ****
|
||||||
|
|
||||||
// Wifi works as an access point
|
#define MAX_SSID_PW_LENGHT 32
|
||||||
const char* ssid = "CG scale"; // wifi name
|
|
||||||
const char* password = ""; // wifi password
|
|
||||||
|
|
||||||
|
// Station mode: connect to available network
|
||||||
|
#define SSID_STA "myWiFi"
|
||||||
|
#define PASSWORD_STA ""
|
||||||
|
#define TIMEOUT_CONNECT 12000 //ms
|
||||||
|
|
||||||
|
// Access point mode: create own network
|
||||||
|
#define SSID_AP "CG scale"
|
||||||
|
#define PASSWORD_AP ""
|
||||||
const char ip[4] = {1,1,1,1}; // default IP address
|
const char ip[4] = {1,1,1,1}; // default IP address
|
||||||
|
|
||||||
#define REFRESH_TIME 3 // [s], reload the main page
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user