diff --git a/espem/espem.cpp b/espem/espem.cpp index b47e3c5..dae9ed9 100644 --- a/espem/espem.cpp +++ b/espem/espem.cpp @@ -272,8 +272,8 @@ bool ESPEM::tsSet(size_t size, uint32_t interval){ //tsc.addTS(300, esp_timer_get_time() >> 20, 10, "per10sec", 2); //tsc.addTS(300, esp_timer_get_time() >> 20, 60, "permin", 2); - LOG(printf, "SRAM: heap %d, free %d\n", ESP.getHeapSize(), ESP.getFreeHeap()); - LOG(printf, "SPI-RAM: heap %d, free %d\n", ESP.getPsramSize(), ESP.getFreePsram()); + LOG(printf, "SRAM: heap %u, free %u\n", ESP.getHeapSize(), ESP.getFreeHeap()); + LOG(printf, "SPI-RAM: heap %u, free %u\n", ESP.getPsramSize(), ESP.getFreePsram()); return (bool)tsc.getTScap(); } diff --git a/espem/interface.cpp b/espem/interface.cpp index 03c90d2..899ee1a 100644 --- a/espem/interface.cpp +++ b/espem/interface.cpp @@ -21,30 +21,30 @@ static const char* chart_css = "graphwide"; * */ void create_parameters(){ - LOG(println, F("UI: Creating application vars")); + LOG(println, "UI: Creating application vars"); /** * регистрируем свои переменные */ - embui.var_create(FPSTR(V_UI_UPDRT), DEFAULT_WS_UPD_RATE); // WebUI update rate - embui.var_create(FPSTR(V_SMPL_PERIOD), 1); // - embui.var_create(FPSTR(V_EPOOLSIZE), ESPEM_MEMPOOL); // metrics collector mem pool size, KiB - embui.var_create(FPSTR(V_UART), 0x1); // default UART port UART_NUM_1 - embui.var_create(FPSTR(V_RX), -1); // RX pin (default) - embui.var_create(FPSTR(V_TX), -1); // TX pin (default) - embui.var_create(FPSTR(V_TX), -1); // TX pin (default) - embui.var_create(FPSTR(V_EOFFSET), 0.0); // Energy counter offset + embui.var_create(V_UI_UPDRT, DEFAULT_WS_UPD_RATE); // WebUI update rate + embui.var_create(V_SMPL_PERIOD, 1); // + embui.var_create(V_EPOOLSIZE, ESPEM_MEMPOOL); // metrics collector mem pool size, KiB + embui.var_create(V_UART, 0x1); // default UART port UART_NUM_1 + embui.var_create(V_RX, -1); // RX pin (default) + embui.var_create(V_TX, -1); // TX pin (default) + embui.var_create(V_TX, -1); // TX pin (default) + embui.var_create(V_EOFFSET, 0.0); // Energy counter offset //Metrics collector run/pause - //embui.var_create(FPSTR(V_ECOLLECTORSTATE), 1); // Collector state + //embui.var_create(V_ECOLLECTORSTATE, 1); // Collector state /** * обработчики действий */ // вывод WebUI секций - embui.section_handle_add(FPSTR(B_ESPEM), block_page_main); // generate "main" info page - embui.section_handle_add(FPSTR(B_ESPEMSET), block_page_espemset); // generate "ESPEM settings" page + embui.section_handle_add(B_ESPEM, block_page_main); // generate "main" info page + embui.section_handle_add(B_ESPEMSET, block_page_espemset); // generate "ESPEM settings" page /** @@ -54,12 +54,12 @@ void create_parameters(){ // активности - embui.section_handle_add(FPSTR(A_SET_ESPEM), set_sampler_opts); - embui.section_handle_add(FPSTR(A_SET_UART), set_uart_opts); - embui.section_handle_add(FPSTR(A_SET_PZOPTS), set_pzopts); + embui.section_handle_add(A_SET_ESPEM, set_sampler_opts); + embui.section_handle_add(A_SET_UART, set_uart_opts); + embui.section_handle_add(A_SET_PZOPTS, set_pzopts); // direct controls - embui.section_handle_add(FPSTR(A_DIRECT_CTL), set_directctrls); // process direct update controls + embui.section_handle_add(A_DIRECT_CTL, set_directctrls); // process direct update controls } @@ -81,23 +81,22 @@ void sync_parameters(){} void section_main_frame(Interface *interf, JsonObject *data){ if (!interf) return; - interf->json_frame_interface(FPSTR(C_DICT[lang][CD::ESPEM_H])); // HEADLINE for WebUI + interf->json_frame_interface(); + + // application manifest + interf->json_section_manifest(C_DICT[lang][CD::ESPEM_H], 0, FW_VERSION_STRING); // HEADLINE for WebUI + interf->json_section_end(); // json_section_manifest + block_menu(interf, data); // Строим UI блок с меню выбора других секций - interf->json_frame_flush(); + interf->json_frame_flush(); // send frame if(!(WiFi.getMode() & WIFI_MODE_STA)){ // если контроллер не подключен к внешней AP, сразу открываем вкладку с настройками WiFi - LOG(println, F("UI: Opening network setup section")); + LOG(println, "UI: Opening network setup section"); basicui::block_settings_netw(interf, data); } else { block_page_main(interf, data); // Строим основной блок } - interf->json_frame_flush(); // Close interface section - - // Publish firmware version (visible under menu section) - interf->json_frame_value(); - interf->value(F("fwver"), F(FW_VERSION_STRING), true); - interf->json_frame_flush(); } /** @@ -108,8 +107,8 @@ void block_menu(Interface *interf, JsonObject *data){ if (!interf) return; // создаем меню interf->json_section_menu(); // открываем секцию "меню" - interf->option(FPSTR(B_ESPEM), FPSTR(C_DICT[lang][CD::ESPEM_DB])); // пункт меню "ESPEM Info" - interf->option(FPSTR(B_ESPEMSET), FPSTR(C_DICT[lang][CD::ESPEMSet])); // пункт меню "ESPEM Setup" + interf->option(B_ESPEM, C_DICT[lang][CD::ESPEM_DB]); // пункт меню "ESPEM Info" + interf->option(B_ESPEMSET, C_DICT[lang][CD::ESPEMSet]); // пункт меню "ESPEM Setup" /** * добавляем в меню пункт - настройки, @@ -127,13 +126,13 @@ void block_menu(Interface *interf, JsonObject *data){ void block_page_main(Interface *interf, JsonObject *data){ if (!interf) return; interf->json_frame_interface(); - interf->json_section_main(FPSTR(B_ESPEM), FPSTR(C_DICT[lang][CD::ESPEM_H])); + interf->json_section_main(B_ESPEM, C_DICT[lang][CD::ESPEM_H]); interf->json_section_line(); // "Live controls" - interf->checkbox(FPSTR(V_EPOLLENA), (bool)espem->get_uirate(), F("Live update"), true); // Meter poller status + interf->checkbox(V_EPOLLENA, (bool)espem->get_uirate(), "Live update", true); // Meter poller status // UI update rate range slider - interf->range(V_UI_UPDRT, embui.paramVariant(V_UI_UPDRT).as(), 0, MAX_UI_UPDATE_RATE, 1, F("UI update rate, sec"), true); + interf->range(V_UI_UPDRT, embui.paramVariant(V_UI_UPDRT).as(), 0, MAX_UI_UPDATE_RATE, 1, "UI update rate, sec", true); interf->json_section_end(); // end of line // Plain values display @@ -141,9 +140,9 @@ void block_page_main(Interface *interf, JsonObject *data){ auto *m = espem->pz->getMetricsPZ004(); // Widgets & left side menu // id, type, value, label, param - interf->display(F("pwr"), m->power/10 ); // Power - interf->display(F("cur"), m->asFloat(pzmbus::meter_t::cur)); // Current - interf->display(F("enrg"), m->energy/1000); // Energy + interf->display("pwr", m->power/10 ); // Power + interf->display("cur", m->asFloat(pzmbus::meter_t::cur)); // Current + interf->display("enrg", m->energy/1000); // Energy interf->json_section_end(); // end of line @@ -156,11 +155,11 @@ void block_page_main(Interface *interf, JsonObject *data){ interf->jscall("gaugePF", C_mkchart, C_DICT[lang][CD::PowerF], chart_css); // Power Factor interf->json_section_end(); // end of line - params[F("arg1")] = embui.paramVariant(V_SMPLCNT); // samples counter + params["arg1"] = embui.paramVariant(V_SMPLCNT); // samples counter interf->jscall("gsmini", C_mkchart, "Power chart", chart_css, params); // Power chart // slider for the amount of metric samples to be plotted on a chart - interf->range(FPSTR(V_SMPLCNT), embui.paramVariant(FPSTR(V_SMPLCNT)).as(), 0, (int)espem->getMetricsCap(), 10, FPSTR(C_DICT[lang][CD::MScale]), true); + interf->range(V_SMPLCNT, embui.paramVariant(V_SMPLCNT).as(), 0, (int)espem->getMetricsCap(), 10, C_DICT[lang][CD::MScale], true); interf->json_frame_flush(); // flush frame } @@ -174,54 +173,54 @@ void block_page_espemset(Interface *interf, JsonObject *data){ interf->json_frame_interface(); // replacing page with a new one with settings - //interf->json_section_main(FPSTR(A_SET_ESPEM), FPSTR(C_DICT[lang][CD::ESPEMSet])); - interf->json_section_main("", FPSTR(C_DICT[lang][CD::ESPEMSet])); + //interf->json_section_main(A_SET_ESPEM, C_DICT[lang][CD::ESPEMSet]); + interf->json_section_main("", C_DICT[lang][CD::ESPEMSet]); // Poller Line block /* interf->json_section_line(""); - interf->checkbox(FPSTR(V_EPOLLENA), espem->meterPolling(), F("Meter Polling"), true); // Meter poller status + interf->checkbox(V_EPOLLENA, espem->meterPolling(), "Meter Polling", true); // Meter poller status // UI update Rate range slider - interf->range(FPSTR(V_UI_UPDRT), embui.paramVariant(FPSTR(V_UI_UPDRT)).as(), 0, MAX_UI_UPDATE_RATE, 1, F("UI refresh rate, sec"), true); + interf->range(V_UI_UPDRT, embui.paramVariant(V_UI_UPDRT).as(), 0, MAX_UI_UPDATE_RATE, 1, "UI refresh rate, sec", true); interf->json_section_end(); // end of line */ - interf->json_section_begin(FPSTR(A_SET_UART)); + interf->json_section_begin(A_SET_UART); - interf->json_section_line(""); - interf->number_constrained(V_UART, "Uart port", 1, 0, SOC_UART_NUM); - interf->number_constrained(V_RX, "RX pin (-1 default)", 1, -1, NUM_OUPUT_PINS); - interf->number_constrained(V_TX, "TX pin (-1 default)", 1, -1, NUM_OUPUT_PINS); - interf->json_section_end(); // end of line + interf->json_section_line(); + interf->number_constrained(V_UART, embui.paramVariant(V_UART).as(), "Uart port", 1, 0, SOC_UART_NUM); + interf->number_constrained(V_RX, embui.paramVariant(V_RX).as(), "RX pin (-1 default)", 1, -1, NUM_OUPUT_PINS); + interf->number_constrained(V_TX, embui.paramVariant(V_TX).as(), "TX pin (-1 default)", 1, -1, NUM_OUPUT_PINS); + interf->json_section_end(); // end of line - interf->button_submit(FPSTR(A_SET_UART), FPSTR(T_DICT[lang][TD::D_Apply]), F("blue")); + interf->button(button_t::submit, A_SET_UART, T_DICT[lang][TD::D_Apply]); interf->json_section_end(); // end of "uart" // counter opts - interf->spacer(F("Energy counter options")); - interf->json_section_begin(FPSTR(A_SET_PZOPTS)); - interf->number(FPSTR(V_EOFFSET), espem->getEnergyOffset(), "Energy counter offset"); - interf->button_submit(FPSTR(A_SET_PZOPTS), FPSTR(T_DICT[lang][TD::D_Apply]), F("blue")); + interf->spacer("Energy counter options"); + interf->json_section_begin(A_SET_PZOPTS); + interf->number(V_EOFFSET, espem->getEnergyOffset(), "Energy counter offset"); + interf->button(button_t::submit, A_SET_PZOPTS, T_DICT[lang][TD::D_Apply]); interf->json_section_end(); // end of "energy" - interf->spacer(F("Metrics collector options")); - String _msg(F("Metrics pool capacity: ")); + interf->spacer("Metrics collector options"); + String _msg("Metrics pool capacity: "); _msg += espem->getMetricsSize(); _msg += "/"; _msg += espem->getMetricsCap(); // current number of metrics samples - _msg += F(" samples"); + _msg += " samples"; - interf->constant(F("mcap"), _msg); + interf->constant("mcap", _msg); - interf->json_section_line(FPSTR(A_SET_ESPEM)); - interf->number(FPSTR(V_EPOOLSIZE), F("RAM pool size, samples")); // Memory pool for metrics data, samples - interf->number(FPSTR(V_SMPL_PERIOD), "Sampling period"); // sampling period, sec + interf->json_section_line(A_SET_ESPEM); + interf->number(V_EPOOLSIZE, embui.paramVariant(V_EPOOLSIZE).as(), "RAM pool size, samples"); // Memory pool for metrics data, samples + interf->number(V_SMPL_PERIOD, embui.paramVariant(V_SMPL_PERIOD).as(), "Sampling period"); // sampling period, sec interf->json_section_end(); // end of line // Button "Apply Metrics pool settings" - interf->button_submit(FPSTR(A_SET_ESPEM), FPSTR(T_DICT[lang][TD::D_Apply]), F("blue")); + interf->button(button_t::submit, A_SET_ESPEM, T_DICT[lang][TD::D_Apply]); /* * Define metrics collector state @@ -230,9 +229,9 @@ void block_page_espemset(Interface *interf, JsonObject *data){ * 2: Paused, collecting but not storing, memory reserved */ interf->select(V_ECOLLECTORSTATE, (uint8_t)espem->get_collector_state(), "Metrics collector status", true); - interf->option(0, F("Disabled")); - interf->option(1, F("Running")); - interf->option(2, F("Paused")); + interf->option(0, "Disabled"); + interf->option(1, "Running"); + interf->option(2, "Paused"); interf->json_section_end(); // select interf->json_frame_flush(); // flush frame @@ -255,10 +254,10 @@ void pubCallback(Interface *interf){ void set_sampler_opts(Interface *interf, JsonObject *data){ if (!data) return; - SETPARAM(FPSTR(V_EPOOLSIZE)); - SETPARAM(FPSTR(V_SMPL_PERIOD)); + SETPARAM(V_EPOOLSIZE); + SETPARAM(V_SMPL_PERIOD); - espem->tsSet((*data)[FPSTR(V_EPOOLSIZE)].as(), (*data)[FPSTR(V_SMPL_PERIOD)].as()); + espem->tsSet((*data)[V_EPOOLSIZE].as(), (*data)[V_SMPL_PERIOD].as()); // display main page if (interf) block_page_main(interf, nullptr); } @@ -275,13 +274,13 @@ void set_directctrls(Interface *interf, JsonObject *data){ //LOG(printf_P, PSTR("Iterating Key:%s Value:%s\n"), kv.key().c_str(), kv.value().as() ); - String _s(FPSTR(V_EPFFIX)); + String _s(V_EPFFIX); String _k(kv.key().c_str()); - _s=FPSTR(V_EPOLLENA); + _s=V_EPOLLENA; if (!_s.compareTo(_k)){ if(kv.value()){ - espem->set_uirate(embui.paramVariant(FPSTR(V_UI_UPDRT))); + espem->set_uirate(embui.paramVariant(V_UI_UPDRT)); } else { espem->set_uirate(0); } @@ -289,20 +288,20 @@ void set_directctrls(Interface *interf, JsonObject *data){ continue; } - _s=FPSTR(V_UI_UPDRT); + _s=V_UI_UPDRT; if (!_s.compareTo(_k)){ espem->set_uirate(kv.value().as()); - SETPARAM(FPSTR(V_UI_UPDRT)); + SETPARAM(V_UI_UPDRT); LOG( printf_P, PSTR("ESPEM: Set UI update rate to: %d\n"), espem->get_uirate() ); continue; } - _s=FPSTR(V_ECOLLECTORSTATE); + _s=V_ECOLLECTORSTATE; if (!_s.compareTo(_k)){ uint8_t new_state = kv.value().as(); // reset TS Container if empty and we need to start it - if (espem->get_collector_state() == mcstate_t::MC_DISABLE && new_state >0) espem->tsSet(embui.paramVariant(FPSTR(V_EPOOLSIZE)), embui.paramVariant(FPSTR(V_SMPL_PERIOD))); + if (espem->get_collector_state() == mcstate_t::MC_DISABLE && new_state >0) espem->tsSet(embui.paramVariant(V_EPOOLSIZE), embui.paramVariant(V_SMPL_PERIOD)); espem->set_collector_state((mcstate_t)new_state); //embui.var(_k, (uint8_t)espem->set_collector_state((mcstate_t)new_state), true); // no need to set this var, it's a run-time state @@ -312,13 +311,13 @@ void set_directctrls(Interface *interf, JsonObject *data){ // Set amount of samples displayed on chart (TODO: replace with js internal var) - _s=FPSTR(V_SMPLCNT); + _s=V_SMPLCNT; if (!_s.compareTo(_k)){ - SETPARAM(FPSTR(V_SMPLCNT)); + SETPARAM(V_SMPLCNT); if (interf){ interf->json_frame("rawdata"); - interf->value(F("scntr"), kv.value()); + interf->value("scntr", kv.value()); interf->json_frame_flush(); } } @@ -332,22 +331,22 @@ void set_directctrls(Interface *interf, JsonObject *data){ void set_uart_opts(Interface *interf, JsonObject *data){ if (!data) return; - uint8_t p = (*data)[FPSTR(V_UART)].as(); + uint8_t p = (*data)[V_UART].as(); if ( p <= SOC_UART_NUM ){ - SETPARAM(FPSTR(V_UART)); + SETPARAM(V_UART); } else return; - int r = (*data)[FPSTR(V_RX)].as(); + int r = (*data)[V_RX].as(); if (r <= NUM_OUPUT_PINS && r >0) { - SETPARAM(FPSTR(V_RX)); + SETPARAM(V_RX); } else return; - int t = (*data)[FPSTR(V_TX)].as(); + int t = (*data)[V_TX].as(); if (t <= NUM_OUPUT_PINS && r >0){ - SETPARAM(FPSTR(V_TX)); + SETPARAM(V_TX); } else return; - espem->begin(embui.paramVariant(FPSTR(V_UART)), embui.paramVariant(FPSTR(V_RX)), embui.paramVariant(FPSTR(V_TX))); + espem->begin(embui.paramVariant(V_UART), embui.paramVariant(V_RX), embui.paramVariant(V_TX)); // display main page if (interf) block_page_main(interf, nullptr); } @@ -361,8 +360,8 @@ void set_uart_opts(Interface *interf, JsonObject *data){ void set_pzopts(Interface *interf, JsonObject *data){ if (!data) return; - SETPARAM(FPSTR(V_EOFFSET)); - espem->setEnergyOffset(embui.paramVariant(FPSTR(V_EOFFSET))); + SETPARAM(V_EOFFSET); + espem->setEnergyOffset(embui.paramVariant(V_EOFFSET)); // display main page if (interf) block_page_main(interf, nullptr); diff --git a/espem/main.h b/espem/main.h index 9d6851e..4d0cbed 100644 --- a/espem/main.h +++ b/espem/main.h @@ -23,7 +23,7 @@ #define BAUD_RATE 115200 // serial debug port baud rate -#define HTTP_VER_BUFSIZE 200 +#define HTTP_VER_BUFSIZE 256 #define WEBUI_PUBLISH_INTERVAL 20 diff --git a/espem/ui_i18n.h b/espem/ui_i18n.h index 4f9e658..43f97b4 100644 --- a/espem/ui_i18n.h +++ b/espem/ui_i18n.h @@ -25,18 +25,18 @@ enum CD : uint8_t { // Infoclock - English Strings (order does not matther) // ИнфоЧасики - Русские тексты (порядок значения не имеет) -static const char T_EN_ESPEM[] PROGMEM = "ESP Energy Monitor"; -static const char T_RU_ESPEM[] PROGMEM = "ESP Энергометр"; -static const char T_EN_ESPEM_DB[] PROGMEM = "ESPEM Dashboard"; -static const char T_RU_ESPEM_DB[] PROGMEM = "ESPEM Индикаторы"; -static const char T_EN_ESPEMSet[] PROGMEM = "ESPEM Setup"; -static const char T_RU_ESPEMSet[] PROGMEM = "ESPEM Параметры"; -static const char T_EN_MScale[] PROGMEM = "Metrics scale"; -static const char T_RU_MScale[] PROGMEM = "Масштаб выборки"; -static const char T_EN_Voltage[] PROGMEM = "Voltage meter"; -static const char T_RU_Voltage[] PROGMEM = "Напряжение сети"; -static const char T_EN_PowerF[] PROGMEM = "Power Factor"; -static const char T_RU_PowerF[] PROGMEM = "Коэффициент мощности"; +static constexpr const char T_EN_ESPEM[] PROGMEM = "ESP Energy Monitor"; +static constexpr const char T_RU_ESPEM[] PROGMEM = "ESP Энергометр"; +static constexpr const char T_EN_ESPEM_DB[] PROGMEM = "ESPEM Dashboard"; +static constexpr const char T_RU_ESPEM_DB[] PROGMEM = "ESPEM Индикаторы"; +static constexpr const char T_EN_ESPEMSet[] PROGMEM = "ESPEM Setup"; +static constexpr const char T_RU_ESPEMSet[] PROGMEM = "ESPEM Параметры"; +static constexpr const char T_EN_MScale[] PROGMEM = "Metrics scale"; +static constexpr const char T_RU_MScale[] PROGMEM = "Масштаб выборки"; +static constexpr const char T_EN_Voltage[] PROGMEM = "Voltage meter"; +static constexpr const char T_RU_Voltage[] PROGMEM = "Напряжение сети"; +static constexpr const char T_EN_PowerF[] PROGMEM = "Power Factor"; +static constexpr const char T_RU_PowerF[] PROGMEM = "Коэффициент мощности"; /** @@ -47,7 +47,7 @@ static const char T_RU_PowerF[] PROGMEM = "Коэффициент мощност * Messages indexes of each lang must match each other * it is possible to reuse untraslated mesages from other lang's */ -static const char *const C_DICT[][UI_DICT_SIZE] PROGMEM = { +static constexpr const char *const C_DICT[][UI_DICT_SIZE] PROGMEM = { // Index 0 - English lang { T_EN_ESPEM, T_EN_ESPEM_DB, diff --git a/espem/uistrings.h b/espem/uistrings.h index 04b6beb..e99e71c 100644 --- a/espem/uistrings.h +++ b/espem/uistrings.h @@ -3,40 +3,40 @@ // Set of flash-strings that might be reused multiple times within the code // General -static const char C_ONE[] PROGMEM = "1"; -static const char C_mkchart[] PROGMEM = "mkchart"; -static const char C_js[] PROGMEM = "js"; +static constexpr const char C_ONE[] PROGMEM = "1"; +static constexpr const char C_mkchart[] PROGMEM = "mkchart"; +static constexpr const char C_js[] PROGMEM = "js"; ////////////////////// // Configuration variables names - V_ prefix for 'Variable' -static const char V_EPOOLSIZE[] = "emplsz"; // sample pool size -static const char V_SMPL_PERIOD[] = "ems_prd"; // sampling period -static const char V_RX[] = "rx"; // rx pin -static const char V_TX[] = "tx"; // tx ping -static const char V_UART[] = "uart"; // uart interface -static const char V_EOFFSET[] = "eoffset"; // energy offset +static constexpr const char V_EPOOLSIZE[] = "emplsz"; // sample pool size +static constexpr const char V_SMPL_PERIOD[] = "ems_prd"; // sampling period +static constexpr const char V_RX[] = "rx"; // rx pin +static constexpr const char V_TX[] = "tx"; // tx ping +static constexpr const char V_UART[] = "uart"; // uart interface +static constexpr const char V_EOFFSET[] = "eoffset"; // energy offset // directly changed vars -static const char V_EPOLLENA[] PROGMEM = "dctlpoll"; // Enable/disable poller -static const char V_EPFFIX[] PROGMEM = "dctlpffix"; // PowerFactor value correction -static const char V_UI_UPDRT[] = "dctlupdrt"; // UI update rate -static const char V_ECOLLECTORSTATE[] = "dctlmtrx"; // Metrics collector run/pause -static const char V_SMPLCNT[] = "dctlscnt"; // Metrics graph - number of samples to draw in a small power chart +static constexpr const char V_EPOLLENA[] PROGMEM = "dctlpoll"; // Enable/disable poller +static constexpr const char V_EPFFIX[] PROGMEM = "dctlpffix"; // PowerFactor value correction +static constexpr const char V_UI_UPDRT[] = "dctlupdrt"; // UI update rate +static constexpr const char V_ECOLLECTORSTATE[] = "dctlmtrx"; // Metrics collector run/pause +static constexpr const char V_SMPLCNT[] = "dctlscnt"; // Metrics graph - number of samples to draw in a small power chart // UI blocks - B_ prefix for 'web Block' -static const char B_ESPEM[] PROGMEM = "b_espem"; -static const char B_ESPEMSET[] PROGMEM = "b_emset"; -static const char B_WEATHER[] PROGMEM = "b_wthr"; -static const char B_MORE[] PROGMEM = "b_more"; +static constexpr const char B_ESPEM[] PROGMEM = "b_espem"; +static constexpr const char B_ESPEMSET[] PROGMEM = "b_emset"; +static constexpr const char B_WEATHER[] PROGMEM = "b_wthr"; +static constexpr const char B_MORE[] PROGMEM = "b_more"; // direct control elements -static const char A_DIRECT_CTL[] PROGMEM = "dctl*"; // checkboxes/controls that should be processed in real-time +static constexpr const char A_DIRECT_CTL[] PROGMEM = "dctl*"; // checkboxes/controls that should be processed in real-time // UI handlers - A_ prefix for 'Action' -static const char A_SET_ESPEM[] PROGMEM = "a_setem"; // ESPEM settings update -static const char A_SET_UART[] PROGMEM = "a_uart"; -static const char A_SET_PZOPTS[] PROGMEM = "a_pzopt"; +static constexpr const char A_SET_ESPEM[] PROGMEM = "a_setem"; // ESPEM settings update +static constexpr const char A_SET_UART[] PROGMEM = "a_uart"; +static constexpr const char A_SET_PZOPTS[] PROGMEM = "a_pzopt"; // other constants diff --git a/flags.py b/flags.py index 91b9834..860916d 100644 --- a/flags.py +++ b/flags.py @@ -3,16 +3,15 @@ # print("OS: %s" % os.name) if os.name == 'nt': - print("-DFW_VER='\"unknown\"'") + print("-DGIT_REV='\"n/a\"'") quit() # PIO build flags # https://docs.platformio.org/en/latest/projectconf/section_env_build.html#src-build-flags -revision = ( - subprocess.check_output(["git", "describe", "--abbrev=4", "--always", "--tags", "--long"]) - .strip() - .decode("utf-8") -) -print("-DFW_VER='\"%s\"'" % revision) - +try: + #revision = subprocess.check_output(["git", "describe", "--abbrev=4", "--always", "--tags", "--long"], stderr=subprocess.DEVNULL).strip().decode("utf-8") + revision = subprocess.check_output(["git", "describe", "--abbrev=7", "--always"], stderr=subprocess.DEVNULL).strip().decode("utf-8") + print ("-DGIT_REV='\"%s\"'" % revision) +except: + print ("-DGIT_REV='\"n/a\"'") diff --git a/platformio.ini b/platformio.ini index fed3b5e..0e8e8e4 100644 --- a/platformio.ini +++ b/platformio.ini @@ -10,15 +10,15 @@ board_build.filesystem = littlefs framework = arduino build_flags = -DFZ_WITH_ASYNCSRV + -DNO_GLOBAL_UPDATE ; -DCOUNTRY="ru" build_src_flags = !python flags.py - -std=gnu++14 + -std=gnu++17 src_build_unflags = -std=gnu++11 lib_deps = - https://github.com/vortigont/EmbUI.git#v2.7.2 - ;https://github.com/vortigont/EmbUI.git + https://github.com/vortigont/EmbUI.git#v2.8.1 lib_ignore = ESPAsyncTCP monitor_speed = 115200 @@ -115,28 +115,9 @@ build_flags = ;upload_port = http://espem/update ;upload_flags = compress - -; ########## -; DEPRECATED -; Arduino core 1.5.x based on ESP32 IDF v3.x -;[esp32_pio350] +;[env:espem_s3] ;extends = esp32_base -;platform = espressif32@3.5.0 -;build_flags = -; -DUSE_LittleFS -; -DCONFIG_LITTLEFS_FOR_IDF_3_2 -;extra_scripts = replace_fs.py - -; build with esp32 arduino core 1.5.x -;[env:espem_pio350] -;extends = esp32_pio350 +;board = lolin_s3 ;lib_deps = ; ${esp32_base.lib_deps} -; https://github.com/lorol/LITTLEFS.git ; https://github.com/vortigont/pzem-edl -;build_flags = -; ${esp32_base.build_flags} -; -DCOUNTRY="ru" -;lib_ignore = -; ESPAsyncTCP - diff --git a/replace_fs.py b/replace_fs.py deleted file mode 100644 index b7f7ca5..0000000 --- a/replace_fs.py +++ /dev/null @@ -1,9 +0,0 @@ -Import("env") -import platform - -if platform.system() == 'Windows': - print("Replace MKSPIFFSTOOL with mklittlefs.exe") - env.Replace (MKSPIFFSTOOL = "./mklittlefs.exe") -else: - print("Replace MKSPIFFSTOOL with mklittlefs") - env.Replace (MKSPIFFSTOOL = "./mklittlefs") diff --git a/resources/html/index.html b/resources/html/index.html index cbf2908..d7d8310 100644 --- a/resources/html/index.html +++ b/resources/html/index.html @@ -37,44 +37,20 @@
-
- Voltage:{{value.U}} -
-
- Current:{{value.I}} -
-
- Power:{{value.P}} -
-
- Energy:{{value.W}} -
-
- Power Factor:{{value.Pf}} -
-
- Frequency:{{value.freq}} -
+
Voltage:{{value.U}}
+
Current:{{value.I}}
+
Power:{{value.P}}
+
Energy:{{value.W}}
+
Power Factor:{{value.Pf}}
+
Frequency:{{value.freq}}
-
- Time:{{value.pTime}} -
-
- Memory:{{value.pMem}} -
-
- Uptime:{{value.pUptime}} -
-
- ChipID:{{mc}} -
-
- EmbUI ver:{{ver}} -
-
- Firmware ver:{{value.fwver}} -
+
Time:{{value.pTime}}
+
Memory:{{value.pMem}}
+
Uptime:{{value.pUptime}}
+
ChipID:{{macid}}
+
EmbUI ver:{{uiver}}
+
FirmWare ver:{{appver}}
Theme: [C] diff --git a/resources/respack.sh b/resources/respack.sh index d3ded63..80c354c 100755 --- a/resources/respack.sh +++ b/resources/respack.sh @@ -4,7 +4,7 @@ USAGE="Usage: `basename $0` [-h] [-t embuitag] [-f]" # embui branch/tag name to fetch embuirepo='https://github.com/vortigont/EmbUI' -embuitag="v2.7.0" +embuitag="v2.8.1" ##### # no changes below this point!