diff --git a/CG_scale.ino b/CG_scale.ino index 2c5822b..b366014 100644 --- a/CG_scale.ino +++ b/CG_scale.ino @@ -4,7 +4,7 @@ (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 +#if defined(__AVR__) void(* resetCPU) (void) = 0; +#elif defined(ESP8266) +void resetCPU(){} +#endif // save calibration factor @@ -375,61 +379,85 @@ void setup() { oledDisplay.print(F("(c) 2019 M. Lehmann")); } while ( oledDisplay.nextPage() ); - // init Loadcells + // init & tare Loadcells LoadCell_1.begin(); + LoadCell_1.start(STABILISINGTIME); 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) { LoadCell_3.begin(); - } + LoadCell_3.start(STABILISINGTIME); - // 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; + if (LoadCell_3.getTareTimeoutFlag()) { + errMsg[++errMsgCnt] = "ERROR: Timeout TARE Lc3\n"; } - // timeout - if ((millis() - lastTimeLoadcell) > TARE_TIMEOUT) { - errMsg[++errMsgCnt] = "ERROR: Timeout TARE\n"; - break; + else { + LoadCell_3.setCalFactor(calFactorLoadcell3); } } - // 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); - } - - // stabilize scale values - for (int i = 0; i <= 5; i++) { - LoadCell_1.update(); - LoadCell_2.update(); + /* + // init Loadcells + LoadCell_1.begin(); + LoadCell_2.begin(); 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) while (WiFi.status() != WL_CONNECTED) { @@ -459,7 +487,7 @@ void setup() { oledDisplay.setCursor(0, 64); oledDisplay.print(WiFi.localIP()); } while ( oledDisplay.nextPage() ); - delay(5000); + //delay(5000); } else { // if WiFi not connected, switch to access point mode WiFi.mode(WIFI_AP); @@ -493,6 +521,17 @@ void setup() { server.send(404, "text/plain", "404: Not Found"); }); #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 if ((millis() - lastTimeMenu) > UPDATE_INTERVAL_OLED_MENU) { + lastTimeMenu = millis(); // total model weight diff --git a/data/CG_scale_mechanics.png.gz b/data/CG_scale_mechanics.png.gz index 4e4e5e2..d9e3a56 100644 Binary files a/data/CG_scale_mechanics.png.gz and b/data/CG_scale_mechanics.png.gz differ diff --git a/data/bootstrap.css.map.gz b/data/bootstrap.css.map.gz deleted file mode 100755 index 1ffe194..0000000 Binary files a/data/bootstrap.css.map.gz and /dev/null differ diff --git a/data/bootstrap.min.css.map.gz b/data/bootstrap.min.css.map.gz deleted file mode 100644 index c894b70..0000000 Binary files a/data/bootstrap.min.css.map.gz and /dev/null differ diff --git a/data/bootstrap.min.js.map.gz b/data/bootstrap.min.js.map.gz deleted file mode 100755 index 7ec8159..0000000 Binary files a/data/bootstrap.min.js.map.gz and /dev/null differ diff --git a/data/index.html b/data/index.html deleted file mode 100755 index 304f62b..0000000 --- a/data/index.html +++ /dev/null @@ -1,180 +0,0 @@ - - - - - - - - CG scale by M. Lehmann - - - - - - -
-
-
-
-
Weight
-
- - - - - -
-
-
-
-
-
CG
-
- - - - - -
-
-
-
-
-
CG left/right
-
- - - - - -
-
-
-
-
-
Battery
-
- - - - -
-
-
-
-
-
- -
-
-

(c) 2019 M. Lehmann - Version: 0.0

- - - \ No newline at end of file diff --git a/data/index.html.gz b/data/index.html.gz new file mode 100755 index 0000000..3c64014 Binary files /dev/null and b/data/index.html.gz differ diff --git a/data/models.html b/data/models.html deleted file mode 100755 index c20788f..0000000 --- a/data/models.html +++ /dev/null @@ -1,199 +0,0 @@ - - - - - - - - CG scale by M. Lehmann - - - - - - - -
- - - - - - - - - - -
NameWeight [g]CG [mm]CG left-right [mm]
- -
-
- - -
- - - -
- Backup - -
-
-
-

(c) 2019 M. Lehmann - Version: 0.0

- - - \ No newline at end of file diff --git a/data/models.html.gz b/data/models.html.gz new file mode 100755 index 0000000..2c67509 Binary files /dev/null and b/data/models.html.gz differ diff --git a/data/settings.html b/data/settings.html deleted file mode 100755 index f8b75b0..0000000 --- a/data/settings.html +++ /dev/null @@ -1,280 +0,0 @@ - - - - - - - - CG scale by M. Lehmann - - - - - - -
-

WiFi settings

-
- - - Connect to existing network -
-
- - -
-
-
- - - If no network is present, a private network is created -
-
- - - At least 8 characters -
-

-

CG scale settings

-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-

- - - mechanics - -
-

Lc1: -

-
-
-

Lc2: -

-
-
-

Lc3: -

-
-
-

-
-

(c) 2019 M. Lehmann - Version: 0.0

- - - \ No newline at end of file diff --git a/data/settings.html.gz b/data/settings.html.gz new file mode 100755 index 0000000..093078b Binary files /dev/null and b/data/settings.html.gz differ diff --git a/settings_AVR.h b/settings_AVR.h index 1802da3..0285de2 100644 --- a/settings_AVR.h +++ b/settings_AVR.h @@ -59,7 +59,6 @@ CG scale with 3 Loadcells: // **** Measurement settings **** #define STABILISINGTIME 3000 // ms -#define TARE_TIMEOUT 4000 // ms #define UPDATE_INTERVAL_OLED_MENU 500 // ms #define UPDATE_INTERVAL_LOADCELL 100 // ms diff --git a/settings_ESP8266.h b/settings_ESP8266.h index d014f18..eda725e 100644 --- a/settings_ESP8266.h +++ b/settings_ESP8266.h @@ -58,8 +58,7 @@ CG scale with 3 Loadcells: // **** Measurement settings **** -#define STABILISINGTIME 3000 // ms -#define TARE_TIMEOUT 4000 // ms +#define STABILISINGTIME 2000 // ms #define UPDATE_INTERVAL_OLED_MENU 500 // 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 **** -#define MAX_MODELNAME_LENGHT 15 // max chars +#define MAX_MODELNAME_LENGHT 32 // max chars #define MODEL_FILE "/models.json" // file to store models #define JSONBUFFER_SIZE 20000 // max file size in bytes