diff --git a/code/components/jomjol_controlGPIO/server_GPIO.cpp b/code/components/jomjol_controlGPIO/server_GPIO.cpp index 43423f44..19953b85 100644 --- a/code/components/jomjol_controlGPIO/server_GPIO.cpp +++ b/code/components/jomjol_controlGPIO/server_GPIO.cpp @@ -14,13 +14,14 @@ #include //#include +#include "defines.h" + #include "server_GPIO.h" #include "ClassLogFile.h" #include "configFile.h" #include "Helper.h" #include "interface_mqtt.h" -#include "ClassFlowMQTT.h" static const char *TAG_SERVERGPIO = "server_GPIO"; QueueHandle_t gpio_queue_handle = NULL; @@ -481,3 +482,37 @@ gpio_int_type_t GpioHandler::resolveIntType(std::string input) return GPIO_INTR_DISABLE; } + +static GpioHandler *gpioHandler = NULL; + +void gpio_handler_create(httpd_handle_t server) +{ + if (gpioHandler == NULL) + gpioHandler = new GpioHandler(CONFIG_FILE, server); +} + +void gpio_handler_init() +{ + if (gpioHandler != NULL) { + gpioHandler->init(); + } +} + +void gpio_handler_deinit() { + if (gpioHandler != NULL) { + gpioHandler->deinit(); + } +} + +void gpio_handler_destroy() +{ + if (gpioHandler != NULL) { + delete gpioHandler; + gpioHandler = NULL; + } +} + +GpioHandler* gpio_handler_get() +{ + return gpioHandler; +} diff --git a/code/components/jomjol_controlGPIO/server_GPIO.h b/code/components/jomjol_controlGPIO/server_GPIO.h index 90e8f4c9..5745579b 100644 --- a/code/components/jomjol_controlGPIO/server_GPIO.h +++ b/code/components/jomjol_controlGPIO/server_GPIO.h @@ -84,6 +84,12 @@ private: gpio_int_type_t resolveIntType(std::string input); }; -void GpioHandlerStart(); +void gpio_handler_create(httpd_handle_t server); +void gpio_handler_init(); +void gpio_handler_deinit(); +void gpio_handler_destroy(); +GpioHandler* gpio_handler_get(); + + #endif //SERVER_GPIO_H \ No newline at end of file diff --git a/code/components/jomjol_flowcontroll/ClassFlowAnalog.cpp b/code/components/jomjol_flowcontroll/ClassFlowAnalog.cpp index a23d8b42..c5b26d08 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowAnalog.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowAnalog.cpp @@ -284,7 +284,11 @@ bool ClassFlowAnalog::doNeuralNetwork(string time) string zwcnn = "/sdcard" + cnnmodelfile; zwcnn = FormatFileName(zwcnn); printf(zwcnn.c_str());printf("\n"); - tflite->LoadModel(zwcnn); + if (!tflite->LoadModel(zwcnn)) { + printf("Can't read model file /sdcard%s\n", cnnmodelfile.c_str()); + delete tflite; + return false; + } tflite->MakeAllocate(); #endif diff --git a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp b/code/components/jomjol_flowcontroll/ClassFlowControll.cpp index b266ed1a..2b7565d3 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowControll.cpp @@ -209,7 +209,7 @@ bool ClassFlowControll::doFlow(string time) int repeat = 0; #ifdef DEBUG_DETAIL_ON - LogFile.WriteHeapInfo("ClassFlowAnalog::doFlow - Start"); + LogFile.WriteHeapInfo("ClassFlowControll::doFlow - Start"); #endif for (int i = 0; i < FlowControll.size(); ++i) @@ -238,7 +238,7 @@ bool ClassFlowControll::doFlow(string time) } #ifdef DEBUG_DETAIL_ON - LogFile.WriteHeapInfo("ClassFlowAnalog::doFlow"); + LogFile.WriteHeapInfo("ClassFlowControll::doFlow"); #endif } diff --git a/code/components/jomjol_flowcontroll/ClassFlowDigit.cpp b/code/components/jomjol_flowcontroll/ClassFlowDigit.cpp index 97671362..f0511487 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowDigit.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowDigit.cpp @@ -243,6 +243,7 @@ bool ClassFlowDigit::doNeuralNetwork(string time) printf(zwcnn.c_str());printf("\n"); if (!tflite->LoadModel(zwcnn)) { printf("Can't read model file /sdcard%s\n", cnnmodelfile.c_str()); + delete tflite; return false; } diff --git a/code/components/jomjol_logfile/ClassLogFile.cpp b/code/components/jomjol_logfile/ClassLogFile.cpp index 71825ca7..a026d985 100644 --- a/code/components/jomjol_logfile/ClassLogFile.cpp +++ b/code/components/jomjol_logfile/ClassLogFile.cpp @@ -12,7 +12,7 @@ ClassLogFile LogFile("/sdcard/log/message", "log_%Y-%m-%d.txt"); void ClassLogFile::WriteHeapInfo(std::string _id) { -std::string _zw = "\t" + _id; + std::string _zw = "\t" + _id; if (loglevel > 0) _zw = _zw + "\t" + getESPHeapInfo(); diff --git a/code/components/jomjol_tfliteclass/CMakeLists.txt b/code/components/jomjol_tfliteclass/CMakeLists.txt index f03cc95a..7c2c5594 100644 --- a/code/components/jomjol_tfliteclass/CMakeLists.txt +++ b/code/components/jomjol_tfliteclass/CMakeLists.txt @@ -2,6 +2,6 @@ FILE(GLOB_RECURSE app_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.*) idf_component_register(SRCS ${app_sources} INCLUDE_DIRS "." - REQUIRES main jomjol_image_proc jomjol_logfile esp_http_server esp32-camera-master jomjol_controlcamera jomjol_flowcontroll jomjol_helper) + REQUIRES jomjol_image_proc jomjol_logfile esp_http_server esp32-camera-master jomjol_controlcamera jomjol_flowcontroll jomjol_helper) diff --git a/code/components/jomjol_tfliteclass/server_tflite.cpp b/code/components/jomjol_tfliteclass/server_tflite.cpp index 0edea02b..e2968cba 100644 --- a/code/components/jomjol_tfliteclass/server_tflite.cpp +++ b/code/components/jomjol_tfliteclass/server_tflite.cpp @@ -18,7 +18,7 @@ #include "ClassFlowControll.h" #include "ClassLogFile.h" -#include "server_main.h" +#include "server_GPIO.h" #define DEBUG_DETAIL_ON diff --git a/code/main/main.cpp b/code/main/main.cpp index cbc2d550..23f55c15 100644 --- a/code/main/main.cpp +++ b/code/main/main.cpp @@ -137,9 +137,7 @@ void task_NoSDBlink(void *pvParameter) esp_err_t handler_gpio(httpd_req_t *req) { - printf("freemem -3-: %u\n", esp_get_free_heap_size()); gpio_handler_init(); - printf("freemem -4-: %u\n", esp_get_free_heap_size()); char resp_str [30]; sprintf(resp_str, "OK. freemem %u", esp_get_free_heap_size()); @@ -219,7 +217,7 @@ extern "C" void app_main(void) camuri.user_ctx = (void*)server; httpd_register_uri_handler(server, &camuri); - gpio_handler_create(); + gpio_handler_create(server); printf("vor reg server main\n"); register_server_main_uri(server, "/sdcard"); diff --git a/code/main/server_main.cpp b/code/main/server_main.cpp index 300f8c3e..94a41191 100644 --- a/code/main/server_main.cpp +++ b/code/main/server_main.cpp @@ -25,9 +25,6 @@ std::string starttime = ""; static const char *TAG_SERVERMAIN = "server-main"; -static GpioHandler *gpioHandler = NULL; - - /* An HTTP GET handler */ esp_err_t info_get_handler(httpd_req_t *req) { @@ -454,35 +451,3 @@ void connect_handler(void* arg, esp_event_base_t event_base, *server = start_webserver(); } } - -void gpio_handler_create() -{ - if (gpioHandler == NULL) - gpioHandler = new GpioHandler(CONFIG_FILE, server); -} - -void gpio_handler_init() -{ - if (gpioHandler != NULL) { - gpioHandler->init(); - } -} - -void gpio_handler_deinit() { - if (gpioHandler != NULL) { - gpioHandler->deinit(); - } -} - -void gpio_handler_destroy() -{ - if (gpioHandler != NULL) { - delete gpioHandler; - gpioHandler = NULL; - } -} - -GpioHandler* gpio_handler_get() -{ - return gpioHandler; -} diff --git a/code/main/server_main.h b/code/main/server_main.h index ac43ee61..00033b66 100644 --- a/code/main/server_main.h +++ b/code/main/server_main.h @@ -16,12 +16,6 @@ extern httpd_handle_t server; -void gpio_handler_create(); -void gpio_handler_init(); -void gpio_handler_deinit(); -void gpio_handler_destroy(); -GpioHandler* gpio_handler_get(); - httpd_handle_t start_webserver(void); void register_server_main_uri(httpd_handle_t server, const char *base_path); diff --git a/code/main/version.cpp b/code/main/version.cpp index 79c153d4..d0b6f0e6 100644 --- a/code/main/version.cpp +++ b/code/main/version.cpp @@ -1,4 +1,4 @@ -const char* GIT_REV="7b8f10a"; +const char* GIT_REV="b205326"; const char* GIT_TAG=""; const char* GIT_BRANCH="gpio-handler"; -const char* BUILD_TIME="2021-07-03 00:47"; \ No newline at end of file +const char* BUILD_TIME="2021-07-05 23:02"; \ No newline at end of file diff --git a/code/version.cpp b/code/version.cpp index a92ef974..d0b6f0e6 100644 --- a/code/version.cpp +++ b/code/version.cpp @@ -1,4 +1,4 @@ -const char* GIT_REV="7b8f10a"; +const char* GIT_REV="b205326"; const char* GIT_TAG=""; const char* GIT_BRANCH="gpio-handler"; -const char* BUILD_TIME="2021-07-03 00:46"; \ No newline at end of file +const char* BUILD_TIME="2021-07-05 23:02"; \ No newline at end of file diff --git a/firmware/bootloader.bin b/firmware/bootloader.bin index 1451c42e..9b93fde5 100644 Binary files a/firmware/bootloader.bin and b/firmware/bootloader.bin differ diff --git a/firmware/firmware.bin b/firmware/firmware.bin index 737dba82..acbab1c9 100644 Binary files a/firmware/firmware.bin and b/firmware/firmware.bin differ diff --git a/firmware/html.zip b/firmware/html.zip index 3662fc19..6c4e285e 100644 Binary files a/firmware/html.zip and b/firmware/html.zip differ diff --git a/sd-card/config/config.ini b/sd-card/config/config.ini index e631a1b6..0830c121 100644 --- a/sd-card/config/config.ini +++ b/sd-card/config/config.ini @@ -59,7 +59,13 @@ CheckDigitIncreaseConsistency = false ;password = PASSWORD ;[GPIO] -;IO16 = input +;MainTopicMQTT = watermeter2/GPIO +;IO1 = input disabled false false +;IO0 = input disabled false false +;IO3 = input disabled false false +;IO4 = built-in-led disabled 10 false false +;IO12 = input-pullup disabled 10 false false +;IO13 = input-pullup disabled 10 false false [AutoTimer] AutoStart = true diff --git a/sd-card/html/edit_config_param.html b/sd-card/html/edit_config_param.html index 402baf49..a93ab15d 100644 --- a/sd-card/html/edit_config_param.html +++ b/sd-card/html/edit_config_param.html @@ -36,6 +36,10 @@ textarea { .invalid-input { background-color: #FFAA00; } + +.hidden { + display: none; +} @@ -676,7 +680,7 @@ textarea { - + @@ -692,7 +696,7 @@ textarea { - + @@ -718,7 +722,7 @@ textarea { Pin is used to activate flash mode and must therefore be HIGH when booting. - + GPIO 0 use interrupt @@ -739,7 +743,7 @@ textarea { GPIO 0 enable interrupt trigger - + GPIO 0 PWM duty resolution @@ -751,7 +755,7 @@ textarea { GPIO 0 LEDC PWM duty resolution in bit - + GPIO 0 enable MQTT @@ -763,7 +767,7 @@ textarea { GPIO 0 enable MQTT publishing/subscribing - + GPIO 0 enable HTTP @@ -775,7 +779,7 @@ textarea { GPIO 0 enable HTTP write/read - + GPIO 0 name @@ -790,7 +794,7 @@ textarea { - + @@ -814,7 +818,7 @@ textarea { GPIO 1
Used by default for serial communication as TX pin.
Required for seriales monitor.
- + GPIO 1 use interrupt @@ -835,7 +839,7 @@ textarea { GPIO 1 enable interrupt trigger - + GPIO 1 PWM duty resolution @@ -847,7 +851,7 @@ textarea { GPIO 1 LEDC PWM duty resolution in bit - + GPIO 1 enable MQTT @@ -859,7 +863,7 @@ textarea { GPIO 1 enable MQTT publishing/subscribing - + GPIO 1 enable HTTP @@ -871,7 +875,7 @@ textarea { GPIO 1 enable HTTP write/read - + GPIO 1 name @@ -886,7 +890,7 @@ textarea { - + @@ -910,7 +914,7 @@ textarea { GPIO 3 Used by default for serial communication as RX pin. - + GPIO 3 use interrupt @@ -931,7 +935,7 @@ textarea { GPIO 3 Used by default for serial communication as RX pin. - + GPIO 3 PWM duty resolution @@ -943,7 +947,7 @@ textarea { GPIO 3 LEDC PWM duty resolution in bit - + GPIO 3 enable MQTT @@ -955,7 +959,7 @@ textarea { GPIO 3 enable MQTT publishing/subscribing - + GPIO 3 enable HTTP @@ -967,7 +971,7 @@ textarea { GPIO 3 enable HTTP write/read - + GPIO 3 name @@ -982,9 +986,9 @@ textarea { - + - + GPIO 4 state @@ -1008,7 +1012,7 @@ textarea { Pin is used for build-in flash light. - + GPIO 4 use interrupt @@ -1029,7 +1033,7 @@ textarea { GPIO 4 enable interrupt trigger - + GPIO 4 PWM duty resolution @@ -1041,7 +1045,7 @@ textarea { GPIO 4 LEDC PWM duty resolution in bit - + GPIO 4 enable MQTT @@ -1053,7 +1057,7 @@ textarea { GPIO 4 enable MQTT publishing/subscribing - + GPIO 4 enable HTTP @@ -1065,7 +1069,7 @@ textarea { GPIO 4 enable HTTP write/read - + GPIO 4 name @@ -1080,7 +1084,7 @@ textarea { - + @@ -1104,7 +1108,7 @@ textarea { GPIO 12 is usable without restrictions - + GPIO 12 use interrupt @@ -1125,7 +1129,7 @@ textarea { GPIO 12 enable interrupt trigger - + GPIO 12 PWM duty resolution @@ -1137,7 +1141,7 @@ textarea { GPIO 12 LEDC PWM duty resolution in bit - + GPIO 12 enable MQTT @@ -1149,7 +1153,7 @@ textarea { GPIO 12 enable MQTT publishing/subscribing - + GPIO 12 enable HTTP @@ -1161,7 +1165,7 @@ textarea { GPIO 12 enable HTTP write/read - + GPIO 12 name @@ -1176,7 +1180,7 @@ textarea { - + @@ -1200,7 +1204,7 @@ textarea { GPIO 13 is usable without restrictions - + GPIO 13 use interrupt @@ -1221,7 +1225,7 @@ textarea { GPIO 13 enable interrupt trigger - + GPIO 13 PWM duty resolution @@ -1233,7 +1237,7 @@ textarea { GPIO 13 LEDC PWM duty resolution in bit - + GPIO 13 enable MQTT @@ -1245,7 +1249,7 @@ textarea { GPIO 13 enable MQTT publishing/subscribing - + GPIO 13 enable HTTP @@ -1257,7 +1261,7 @@ textarea { GPIO 13 enable HTTP write/read - + GPIO 13 name @@ -1518,6 +1522,17 @@ function setEnabled(className, enabled) { } } +function setVisible(className, visible) { + let elements = document.getElementsByClassName(className); + for (i = 0; i < elements.length; i++) { + if (visible) { + elements[i].classList.remove("hidden"); + } else { + elements[i].classList.add("hidden"); + } + } +} + function EnDisableItem(_status, _param, _category, _cat, _name, _optional) { _status = _param[_cat][_name]["found"] && _category[_cat]["enabled"]; @@ -1582,6 +1597,7 @@ function UpdateInput() { document.getElementById("Category_Digits_enabled").checked = category["Digits"]["enabled"]; document.getElementById("Category_MQTT_enabled").checked = category["MQTT"]["enabled"]; document.getElementById("Category_GPIO_enabled").checked = category["GPIO"]["enabled"]; + setVisible("GPIO_item", category["GPIO"]["enabled"]); WriteParameter(param, category, "MakeImage", "LogImageLocation", true); WriteParameter(param, category, "MakeImage", "LogfileRetentionInDays", true);