mirror of https://github.com/arendst/Tasmota.git
Refactor Gui Configure Scale save settings
This commit is contained in:
parent
10484fbdce
commit
5db9b6f2c9
|
@ -445,7 +445,7 @@ void HxShow(bool json)
|
||||||
dtostrfd(weight, Settings.flag2.weight_resolution, weight_chr);
|
dtostrfd(weight, Settings.flag2.weight_resolution, weight_chr);
|
||||||
|
|
||||||
if (json) {
|
if (json) {
|
||||||
ResponseAppend_P(PSTR(",\"HX711\":{\"" D_JSON_WEIGHT "\":%s%s, \"" D_JSON_WEIGHT_RAW "\":%d}"), weight_chr, scount, Hx.raw);
|
ResponseAppend_P(PSTR(",\"HX711\":{\"" D_JSON_WEIGHT "\":%s%s,\"" D_JSON_WEIGHT_RAW "\":%d}"), weight_chr, scount, Hx.raw);
|
||||||
#ifdef USE_WEBSERVER
|
#ifdef USE_WEBSERVER
|
||||||
} else {
|
} else {
|
||||||
WSContentSend_PD(HTTP_HX711_WEIGHT, weight_chr);
|
WSContentSend_PD(HTTP_HX711_WEIGHT, weight_chr);
|
||||||
|
@ -492,30 +492,32 @@ void HandleHxAction(void)
|
||||||
|
|
||||||
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_HX711));
|
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_HX711));
|
||||||
|
|
||||||
|
char stemp1[20];
|
||||||
|
|
||||||
if (Webserver->hasArg("save")) {
|
if (Webserver->hasArg("save")) {
|
||||||
HxSaveSettings();
|
String cmnd = F("Sensor34 6 ");
|
||||||
|
WebGetArg("p2", stemp1, sizeof(stemp1));
|
||||||
|
cmnd += (!strlen(stemp1)) ? 0 : (unsigned long)(CharToFloat(stemp1) * 1000);
|
||||||
|
ExecuteWebCommand((char*)cmnd.c_str());
|
||||||
|
|
||||||
HandleConfiguration();
|
HandleConfiguration();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char stemp1[20];
|
|
||||||
|
|
||||||
if (Webserver->hasArg("reset")) {
|
if (Webserver->hasArg("reset")) {
|
||||||
snprintf_P(stemp1, sizeof(stemp1), PSTR("Sensor34 1")); // Reset
|
snprintf_P(stemp1, sizeof(stemp1), PSTR("Sensor34 1")); // Reset
|
||||||
ExecuteWebCommand(stemp1, SRC_WEBGUI);
|
ExecuteWebCommand(stemp1);
|
||||||
|
|
||||||
HandleRoot(); // Return to main screen
|
HandleRoot(); // Return to main screen
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Webserver->hasArg("calibrate")) {
|
if (Webserver->hasArg("calibrate")) {
|
||||||
|
String cmnd = F(D_CMND_BACKLOG "0 Sensor34 3 ");
|
||||||
WebGetArg("p1", stemp1, sizeof(stemp1));
|
WebGetArg("p1", stemp1, sizeof(stemp1));
|
||||||
Settings.weight_reference = (!strlen(stemp1)) ? 0 : (unsigned long)(CharToFloat(stemp1) * 1000);
|
cmnd += (!strlen(stemp1)) ? 0 : (unsigned long)(CharToFloat(stemp1) * 1000);
|
||||||
|
cmnd += F(";Sensor34 2"); // Start calibration
|
||||||
HxLogUpdates();
|
ExecuteWebCommand((char*)cmnd.c_str());
|
||||||
|
|
||||||
snprintf_P(stemp1, sizeof(stemp1), PSTR("Sensor34 2")); // Start calibration
|
|
||||||
ExecuteWebCommand(stemp1, SRC_WEBGUI);
|
|
||||||
|
|
||||||
HandleRoot(); // Return to main screen
|
HandleRoot(); // Return to main screen
|
||||||
return;
|
return;
|
||||||
|
@ -531,27 +533,6 @@ void HandleHxAction(void)
|
||||||
WSContentSpaceButton(BUTTON_CONFIGURATION);
|
WSContentSpaceButton(BUTTON_CONFIGURATION);
|
||||||
WSContentStop();
|
WSContentStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HxSaveSettings(void)
|
|
||||||
{
|
|
||||||
char tmp[100];
|
|
||||||
|
|
||||||
WebGetArg("p2", tmp, sizeof(tmp));
|
|
||||||
Settings.weight_item = (!strlen(tmp)) ? 0 : (unsigned long)(CharToFloat(tmp) * 10000);
|
|
||||||
|
|
||||||
HxLogUpdates();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HxLogUpdates(void)
|
|
||||||
{
|
|
||||||
char weigth_ref_chr[33];
|
|
||||||
dtostrfd((float)Settings.weight_reference / 1000, Settings.flag2.weight_resolution, weigth_ref_chr);
|
|
||||||
char weigth_item_chr[33];
|
|
||||||
dtostrfd((float)Settings.weight_item / 10000, 4, weigth_item_chr);
|
|
||||||
|
|
||||||
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_JSON_WEIGHT_REF " %s, " D_JSON_WEIGHT_ITEM " %s"), weigth_ref_chr, weigth_item_chr);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // USE_HX711_GUI
|
#endif // USE_HX711_GUI
|
||||||
#endif // USE_WEBSERVER
|
#endif // USE_WEBSERVER
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue