diff --git a/.gitignore b/.gitignore index d936712c..442c2cf4 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ .pio/ .vscode/ .code-workspace -.helper/ /sd-card/htm./.vscode/ /code/build diff --git a/README.md b/README.md index e30ea6c8..92565a85 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,19 @@ If you would like to support the developer with a cup of coffee you can do that +##### 6.2.0 Image Processing in Memory - (2021-03-08) + +* Determination of fixed illumination settings during startup - speed up of 5s in each run +* Update digital CNN to v8.1.1 (additional digital images trained) +* Extended error message in MQTT error message + + +* Image brightness is now adjustable + + +* Bug fixing: minor topics + + ##### 6.1.0 Image Processing in Memory - (2021-01-20) * Disabling of analog / digital counters in configuration diff --git a/code/.helper/makezip.bat b/code/.helper/makezip.bat new file mode 100644 index 00000000..05664841 --- /dev/null +++ b/code/.helper/makezip.bat @@ -0,0 +1 @@ +powershell Compress-Archive "C:\Users\Muell\Documents\Programmieren\GitHub\AI-on-the-edge-device\sd-card\html\*.*" "C:\Users\Muell\Documents\Programmieren\GitHub\AI-on-the-edge-device\firmware\html.zip" \ No newline at end of file diff --git a/code/components/connect_wlan/connect_wlan._cpp_ b/code/components/connect_wlan/connect_wlan._cpp_ new file mode 100644 index 00000000..eab7a500 --- /dev/null +++ b/code/components/connect_wlan/connect_wlan._cpp_ @@ -0,0 +1,539 @@ +#include "connect_wlan.h" + +#include +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "freertos/event_groups.h" +#include "esp_wifi.h" +#include "esp_log.h" + +#include +#include +#include + +#include "Helper.h" + +static const char *TAG = "connect_wlan"; + +std::string ssid = ""; +std::string passphrase = ""; +std::string hostname = ""; +std::string ipaddress = ""; +std::string gw = ""; +std::string netmask = ""; +std::string dns = ""; + +std::string std_hostname = "watermeter"; + +#define BLINK_GPIO GPIO_NUM_33 + +static EventGroupHandle_t s_wifi_event_group; + +#define WIFI_CONNECTED_BIT BIT0 +#define WIFI_FAIL_BIT BIT1 +static int s_retry_num = 0; + + +std::vector ZerlegeZeile(std::string input, std::string _delimiter = "") +{ + std::vector Output; + std::string delimiter = " =,"; + if (_delimiter.length() > 0){ + delimiter = _delimiter; + } + + input = trim(input, delimiter); + size_t pos = findDelimiterPos(input, delimiter); + std::string token; + while (pos != std::string::npos) { + token = input.substr(0, pos); + token = trim(token, delimiter); + Output.push_back(token); + input.erase(0, pos + 1); + input = trim(input, delimiter); + pos = findDelimiterPos(input, delimiter); + } + Output.push_back(input); + + return Output; +} + + +void blinkstatus(int dauer, int _anzahl) +{ + gpio_reset_pin(BLINK_GPIO); + gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT); + for (int i = 0; i < _anzahl; ++i) + { + gpio_set_level(BLINK_GPIO, 0); + vTaskDelay(dauer / portTICK_PERIOD_MS); + gpio_set_level(BLINK_GPIO, 1); + vTaskDelay(dauer / portTICK_PERIOD_MS); + } +} + + + + +void strinttoip4(std::string ip, int &a, int &b, int &c, int &d) { + std::stringstream s(ip); + char ch; //to temporarily store the '.' + s >> a >> ch >> b >> ch >> c >> ch >> d; +} + + + + +static void event_handler_neu(void* arg, esp_event_base_t event_base, + int32_t event_id, void* event_data) +{ + if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) { + blinkstatus(200, 1); + esp_wifi_connect(); + } else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) { + blinkstatus(200, 5); + esp_wifi_connect(); + s_retry_num++; + ESP_LOGI(TAG, "retry to connect to the AP"); + } else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) { + blinkstatus(1000, 3); + ip_event_got_ip_t* event = (ip_event_got_ip_t*) event_data; + ESP_LOGI(TAG, "got ip:" IPSTR, IP2STR(&event->ip_info.ip)); + s_retry_num = 0; + xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT); + } +} + + +void initialise_wifi() +{ + s_wifi_event_group = xEventGroupCreate(); + ESP_ERROR_CHECK(esp_netif_init()); + ESP_ERROR_CHECK(esp_event_loop_create_default()); + esp_netif_create_default_wifi_sta(); + + wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); + ESP_ERROR_CHECK(esp_wifi_init(&cfg)); + + esp_event_handler_instance_t instance_any_id; + esp_event_handler_instance_t instance_got_ip; + ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT, + ESP_EVENT_ANY_ID, + &event_handler_neu, + NULL, + &instance_any_id)); + ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT, + IP_EVENT_STA_GOT_IP, + &event_handler_neu, + NULL, + &instance_got_ip)); + + + wifi_config_t wifi_config = { }; + strcpy((char*)wifi_config.sta.ssid, (const char*)ssid.c_str()); + strcpy((char*)wifi_config.sta.password, (const char*)passphrase.c_str()); + + ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA) ); + ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config) ); + ESP_ERROR_CHECK(esp_wifi_start() ); + + ESP_LOGI(TAG, "wifi_init_sta finished."); + + // Waiting until either the connection is established (WIFI_CONNECTED_BIT) or connection failed for the maximum + // number of re-tries (WIFI_FAIL_BIT). The bits are set by event_handler() (see above) + EventBits_t bits = xEventGroupWaitBits(s_wifi_event_group, + WIFI_CONNECTED_BIT | WIFI_FAIL_BIT, + pdFALSE, + pdFALSE, + portMAX_DELAY); + + // xEventGroupWaitBits() returns the bits before the call returned, hence we can test which event actually + // happened. + if (bits & WIFI_CONNECTED_BIT) { + ESP_LOGI(TAG, "connected to ap SSID:%s password:%s", + ssid.c_str(), passphrase.c_str()); + } else if (bits & WIFI_FAIL_BIT) { + ESP_LOGI(TAG, "Failed to connect to SSID:%s, password:%s", + ssid.c_str(), passphrase.c_str()); + } else { + ESP_LOGE(TAG, "UNEXPECTED EVENT"); + } + + // The event will not be processed after unregister + ESP_ERROR_CHECK(esp_event_handler_instance_unregister(IP_EVENT, IP_EVENT_STA_GOT_IP, instance_got_ip)); + ESP_ERROR_CHECK(esp_event_handler_instance_unregister(WIFI_EVENT, ESP_EVENT_ANY_ID, instance_any_id)); + vEventGroupDelete(s_wifi_event_group); + + tcpip_adapter_ip_info_t ip_info; + ESP_ERROR_CHECK(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip_info)); + ipaddress = std::string(ip4addr_ntoa(&ip_info.ip)); + netmask = std::string(ip4addr_ntoa(&ip_info.netmask)); + gw = std::string(ip4addr_ntoa(&ip_info.gw)); + printf("IPv4 : %s\n", ip4addr_ntoa(&ip_info.ip)); + printf("HostName : %s\n", hostname.c_str()); +} + + +void initialise_wifi_fixed_ip2() +{ + s_wifi_event_group = xEventGroupCreate(); + ESP_ERROR_CHECK(esp_netif_init()); + ESP_ERROR_CHECK(esp_event_loop_create_default()); + esp_netif_t *my_sta = esp_netif_create_default_wifi_sta(); + + esp_netif_dhcpc_stop(my_sta); + + esp_netif_ip_info_t ip_info; + + int a, b, c, d; + + strinttoip4(ipaddress, a, b, c, d); + IP4_ADDR(&ip_info.ip, a, b, c, d); + + strinttoip4(gw, a, b, c, d); + IP4_ADDR(&ip_info.gw, a, b, c, d); + + strinttoip4(netmask, a, b, c, d); + IP4_ADDR(&ip_info.netmask, a, b, c, d); + + esp_netif_set_ip_info(my_sta, &ip_info); + + + wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); + ESP_ERROR_CHECK(esp_wifi_init(&cfg)); + + if (dns.length() > 0) { + esp_netif_dns_info_t dns_info; + ip4_addr_t ip; + ip.addr = esp_ip4addr_aton(dns.c_str()); + ip_addr_set_ip4_u32(&dns_info.ip, ip.addr); + ESP_ERROR_CHECK(esp_netif_set_dns_info(my_sta, ESP_NETIF_DNS_MAIN, &dns_info)); + } + + + esp_event_handler_instance_t instance_any_id; + esp_event_handler_instance_t instance_got_ip; + ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT, + ESP_EVENT_ANY_ID, + &event_handler_neu, + NULL, + &instance_any_id)); + ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT, + IP_EVENT_STA_GOT_IP, + &event_handler_neu, + NULL, + &instance_got_ip)); + + + wifi_config_t wifi_config = { }; + strcpy((char*)wifi_config.sta.ssid, (const char*)ssid.c_str()); + strcpy((char*)wifi_config.sta.password, (const char*)passphrase.c_str()); + + ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA) ); + ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config) ); + ESP_ERROR_CHECK(esp_wifi_start() ); + + ESP_LOGI(TAG, "wifi_init_sta finished."); + + // Waiting until either the connection is established (WIFI_CONNECTED_BIT) or connection failed for the maximum + // number of re-tries (WIFI_FAIL_BIT). The bits are set by event_handler() (see above) + EventBits_t bits = xEventGroupWaitBits(s_wifi_event_group, + WIFI_CONNECTED_BIT | WIFI_FAIL_BIT, + pdFALSE, + pdFALSE, + portMAX_DELAY); + + // xEventGroupWaitBits() returns the bits before the call returned, hence we can test which event actually + // happened. + if (bits & WIFI_CONNECTED_BIT) { + ESP_LOGI(TAG, "connected to ap SSID:%s password:%s", + ssid.c_str(), passphrase.c_str()); + } else if (bits & WIFI_FAIL_BIT) { + ESP_LOGI(TAG, "Failed to connect to SSID:%s, password:%s", + ssid.c_str(), passphrase.c_str()); + } else { + ESP_LOGE(TAG, "UNEXPECTED EVENT"); + } + + // The event will not be processed after unregister + ESP_ERROR_CHECK(esp_event_handler_instance_unregister(IP_EVENT, IP_EVENT_STA_GOT_IP, instance_got_ip)); + ESP_ERROR_CHECK(esp_event_handler_instance_unregister(WIFI_EVENT, ESP_EVENT_ANY_ID, instance_any_id)); + vEventGroupDelete(s_wifi_event_group); + + tcpip_adapter_ip_info_t ip_info2; + ESP_ERROR_CHECK(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip_info2)); + ipaddress = std::string(ip4addr_ntoa(&ip_info2.ip)); + netmask = std::string(ip4addr_ntoa(&ip_info2.netmask)); + gw = std::string(ip4addr_ntoa(&ip_info2.gw)); +} + +void ConnectToWLAN() +{ + if (ipaddress.length() == 0 || gw.length() == 0 || netmask.length() == 0) + { + printf("Connect to WLAN with dyn. IP\n"); + initialise_wifi(); + } + else + { + printf("Connect to WLAN with fixed IP\n"); + initialise_wifi_fixed_ip2(); + } +} + + +bool ChangeHostName(std::string fn, std::string _newhostname) +{ + if (_newhostname == hostname) + return false; + + string line = ""; + std::vector zerlegt; + + bool found = false; + + std::vector neuesfile; + + FILE* pFile; + fn = FormatFileName(fn); + pFile = OpenFileAndWait(fn.c_str(), "r"); + + printf("file loaded\n"); + + if (pFile == NULL) + return false; + + char zw[1024]; + fgets(zw, 1024, pFile); + line = std::string(zw); + + while ((line.size() > 0) || !(feof(pFile))) + { + printf("%s", line.c_str()); + zerlegt = ZerlegeZeile(line, "="); + zerlegt[0] = trim(zerlegt[0], " "); + + if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "HOSTNAME")){ + line = "hostname = \"" + _newhostname + "\"\n"; + found = true; + } + + neuesfile.push_back(line); + + if (fgets(zw, 1024, pFile) == NULL) + { + line = ""; + } + else + { + line = std::string(zw); + } + } + + if (!found) + { + line = "hostname = \"" + _newhostname + "\"\n"; + neuesfile.push_back(line); + } + + fclose(pFile); + + pFile = OpenFileAndWait(fn.c_str(), "w+"); + + for (int i = 0; i < neuesfile.size(); ++i) + { + fputs(neuesfile[i].c_str(), pFile); + } + + fclose(pFile); + + return true; +} + + +void LoadWlanFromFile(std::string fn) +{ + string line = ""; + std::vector zerlegt; + hostname = std_hostname; + + FILE* pFile; + fn = FormatFileName(fn); + + pFile = OpenFileAndWait(fn.c_str(), "r"); + printf("file loaded\n"); + + if (pFile == NULL) + return; + + char zw[1024]; + fgets(zw, 1024, pFile); + line = std::string(zw); + + while ((line.size() > 0) || !(feof(pFile))) + { + printf("%s", line.c_str()); + zerlegt = ZerlegeZeile(line, "="); + zerlegt[0] = trim(zerlegt[0], " "); + for (int i = 2; i < zerlegt.size(); ++i) + zerlegt[i] = zerlegt[i-1] + zerlegt[i]; + + if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "HOSTNAME")){ + hostname = trim(zerlegt[1]); + if ((hostname[0] == '"') && (hostname[hostname.length()-1] == '"')){ + hostname = hostname.substr(1, hostname.length()-2); + } + } + + if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "SSID")){ + ssid = trim(zerlegt[1]); + if ((ssid[0] == '"') && (ssid[ssid.length()-1] == '"')){ + ssid = ssid.substr(1, ssid.length()-2); + } + } + + if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "PASSWORD")){ + passphrase = zerlegt[1]; + if ((passphrase[0] == '"') && (passphrase[passphrase.length()-1] == '"')){ + passphrase = passphrase.substr(1, passphrase.length()-2); + } + } + + if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "IP")){ + ipaddress = zerlegt[1]; + if ((ipaddress[0] == '"') && (ipaddress[ipaddress.length()-1] == '"')){ + ipaddress = ipaddress.substr(1, ipaddress.length()-2); + } + } + + if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "GATEWAY")){ + gw = zerlegt[1]; + if ((gw[0] == '"') && (gw[gw.length()-1] == '"')){ + gw = gw.substr(1, gw.length()-2); + } + } + + if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "NETMASK")){ + netmask = zerlegt[1]; + if ((netmask[0] == '"') && (netmask[netmask.length()-1] == '"')){ + netmask = netmask.substr(1, netmask.length()-2); + } + } + + if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "DNS")){ + dns = zerlegt[1]; + if ((dns[0] == '"') && (dns[dns.length()-1] == '"')){ + dns = dns.substr(1, dns.length()-2); + } + } + + + if (fgets(zw, 1024, pFile) == NULL) + { + line = ""; + } + else + { + line = std::string(zw); + } + } + + fclose(pFile); + + // Check if Hostname was empty in .ini if yes set to std_hostname + if(hostname.length() <= 0){ + hostname = std_hostname; + } + + printf("\nWLan: %s, %s\n", ssid.c_str(), passphrase.c_str()); + printf("Hostename: %s\n", hostname.c_str()); + printf("Fixed IP: %s, Gateway %s, Netmask %s, DNS %s\n", ipaddress.c_str(), gw.c_str(), netmask.c_str(), dns.c_str()); + +} + +void LoadNetConfigFromFile(std::string _fn, std::string &_ip, std::string &_gw, std::string &_netmask, std::string &_dns) +{ + string line = ""; + std::vector zerlegt; + + + + FILE* pFile; + _fn = FormatFileName(_fn); + pFile = OpenFileAndWait(_fn.c_str(), "r"); + + if (pFile == NULL) + return; + + char zw[1024]; + fgets(zw, 1024, pFile); + line = std::string(zw); + + while ((line.size() > 0) || !(feof(pFile))) + { + printf("%s", line.c_str()); + zerlegt = ZerlegeZeile(line, "="); + zerlegt[0] = trim(zerlegt[0], " "); + + if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "IP")){ + _ip = zerlegt[1]; + if ((_ip[0] == '"') && (_ip[_ip.length()-1] == '"')){ + _ip = _ip.substr(1, _ip.length()-2); + } + } + + if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "GATEWAY")){ + _gw = zerlegt[1]; + if ((_gw[0] == '"') && (_gw[_gw.length()-1] == '"')){ + _gw = _gw.substr(1, _gw.length()-2); + } + } + + if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "NETMASK")){ + _netmask = zerlegt[1]; + if ((_netmask[0] == '"') && (_netmask[_netmask.length()-1] == '"')){ + _netmask = _netmask.substr(1, _netmask.length()-2); + } + } + + if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "DNS")){ + _dns = zerlegt[1]; + if ((_dns[0] == '"') && (_dns[_dns.length()-1] == '"')){ + _dns = _dns.substr(1, _dns.length()-2); + } + } + + if (fgets(zw, 1024, pFile) == NULL) + { + line = ""; + } + else + { + line = std::string(zw); + } + } + + fclose(pFile); +} + + +std::string getHostname(){ + return hostname; +} + +std::string getIPAddress(){ + return ipaddress; +} + +std::string getSSID(){ + return ssid; +} + +std::string getNetMask(){ + return netmask; +} + +std::string getGW(){ + return gw; +} + diff --git a/code/components/connect_wlan/connect_wlan._h_ b/code/components/connect_wlan/connect_wlan._h_ new file mode 100644 index 00000000..f71962c3 --- /dev/null +++ b/code/components/connect_wlan/connect_wlan._h_ @@ -0,0 +1,21 @@ +//#ifndef CONNECT_WLAN_H +//#define CONNECT_WLAN_H + +#include +#include "driver/gpio.h" + +const int CONNECTED_BIT = BIT0; + +void ConnectToWLAN(); + +void LoadWlanFromFile(std::string fn); + +bool ChangeHostName(std::string fn, std::string _newhostname); + +std::string getHostname(); +std::string getIPAddress(); +std::string getSSID(); +std::string getNetMask(); +std::string getGW(); + +//#endif \ No newline at end of file diff --git a/code/components/connect_wlan/connect_wlan.cpp b/code/components/connect_wlan/connect_wlan.cpp index c9f334f6..aa2ea5d9 100644 --- a/code/components/connect_wlan/connect_wlan.cpp +++ b/code/components/connect_wlan/connect_wlan.cpp @@ -23,14 +23,13 @@ static const char *MAIN_TAG = "connect_wlan"; -std::string ssid; -std::string passphrase; -std::string hostname; -std::string ipaddress; -std::string gw; -std::string netmask; -std::string dns; - +std::string ssid = ""; +std::string passphrase = ""; +std::string hostname = ""; +std::string ipaddress = ""; +std::string gw = ""; +std::string netmask = ""; +std::string dns = ""; std::string std_hostname = "watermeter"; static EventGroupHandle_t wifi_event_group; @@ -76,6 +75,8 @@ void wifi_connect(){ ESP_ERROR_CHECK( esp_wifi_connect() ); } + + void blinkstatus(int dauer, int _anzahl) { gpio_reset_pin(BLINK_GPIO); @@ -111,13 +112,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) return ESP_OK; } -void initialise_wifi(std::string _ssid, std::string _passphrase, std::string _hostname) +void initialise_wifi() { ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL) ); wifi_event_group = xEventGroupCreate(); - ssid = _ssid; - passphrase = _passphrase; - hostname = _hostname; + esp_log_level_set("wifi", ESP_LOG_NONE); // disable wifi driver logging tcpip_adapter_init(); wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); @@ -147,14 +146,9 @@ void strinttoip4(std::string ip, int &a, int &b, int &c, int &d) { s >> a >> ch >> b >> ch >> c >> ch >> d; } -void initialise_wifi_fixed_ip(std::string _ip, std::string _gw, std::string _netmask, std::string _ssid, std::string _passphrase, std::string _hostname, std::string _dns) +void initialise_wifi_fixed_ip() { - ssid = _ssid; - passphrase = _passphrase; - hostname = _hostname; - dns = _dns; - wifi_event_group = xEventGroupCreate(); ESP_ERROR_CHECK(esp_netif_init()); @@ -168,13 +162,13 @@ void initialise_wifi_fixed_ip(std::string _ip, std::string _gw, std::string _net int a, b, c, d; - strinttoip4(_ip, a, b, c, d); + strinttoip4(ipaddress, a, b, c, d); IP4_ADDR(&ip_info.ip, a, b, c, d); - strinttoip4(_gw, a, b, c, d); + strinttoip4(gw, a, b, c, d); IP4_ADDR(&ip_info.gw, a, b, c, d); - strinttoip4(_netmask, a, b, c, d); + strinttoip4(netmask, a, b, c, d); IP4_ADDR(&ip_info.netmask, a, b, c, d); esp_netif_set_ip_info(my_sta, &ip_info); @@ -221,6 +215,23 @@ void initialise_wifi_fixed_ip(std::string _ip, std::string _gw, std::string _net } + +void ConnectToWLAN() +{ + if (ipaddress.length() == 0 || gw.length() == 0 || netmask.length() == 0) + { + printf("Connect to WLAN with dyn. IP\n"); + initialise_wifi(); + } + else + { + printf("Connect to WLAN with fixed IP\n"); + initialise_wifi_fixed_ip(); + } +} + + + bool ChangeHostName(std::string fn, std::string _newhostname) { if (_newhostname == hostname) @@ -290,16 +301,16 @@ bool ChangeHostName(std::string fn, std::string _newhostname) } -void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphrase, std::string &_hostname) +void LoadWlanFromFile(std::string fn) { string line = ""; std::vector zerlegt; - _hostname = std_hostname; + hostname = std_hostname; FILE* pFile; fn = FormatFileName(fn); - pFile = OpenFileAndWait(fn.c_str(), "r"); + pFile = OpenFileAndWait(fn.c_str(), "r"); printf("file loaded\n"); if (pFile == NULL) @@ -318,26 +329,55 @@ void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphra zerlegt[i] = zerlegt[i-1] + zerlegt[i]; if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "HOSTNAME")){ - _hostname = trim(zerlegt[1]); - if ((_hostname[0] == '"') && (_hostname[_hostname.length()-1] == '"')){ - _hostname = _hostname.substr(1, _hostname.length()-2); + hostname = trim(zerlegt[1]); + if ((hostname[0] == '"') && (hostname[hostname.length()-1] == '"')){ + hostname = hostname.substr(1, hostname.length()-2); } } if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "SSID")){ - _ssid = trim(zerlegt[1]); - if ((_ssid[0] == '"') && (_ssid[_ssid.length()-1] == '"')){ - _ssid = _ssid.substr(1, _ssid.length()-2); + ssid = trim(zerlegt[1]); + if ((ssid[0] == '"') && (ssid[ssid.length()-1] == '"')){ + ssid = ssid.substr(1, ssid.length()-2); } } if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "PASSWORD")){ - _passphrase = zerlegt[1]; - if ((_passphrase[0] == '"') && (_passphrase[_passphrase.length()-1] == '"')){ - _passphrase = _passphrase.substr(1, _passphrase.length()-2); + passphrase = zerlegt[1]; + if ((passphrase[0] == '"') && (passphrase[passphrase.length()-1] == '"')){ + passphrase = passphrase.substr(1, passphrase.length()-2); } } + if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "IP")){ + ipaddress = zerlegt[1]; + if ((ipaddress[0] == '"') && (ipaddress[ipaddress.length()-1] == '"')){ + ipaddress = ipaddress.substr(1, ipaddress.length()-2); + } + } + + if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "GATEWAY")){ + gw = zerlegt[1]; + if ((gw[0] == '"') && (gw[gw.length()-1] == '"')){ + gw = gw.substr(1, gw.length()-2); + } + } + + if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "NETMASK")){ + netmask = zerlegt[1]; + if ((netmask[0] == '"') && (netmask[netmask.length()-1] == '"')){ + netmask = netmask.substr(1, netmask.length()-2); + } + } + + if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "DNS")){ + dns = zerlegt[1]; + if ((dns[0] == '"') && (dns[dns.length()-1] == '"')){ + dns = dns.substr(1, dns.length()-2); + } + } + + if (fgets(zw, 1024, pFile) == NULL) { line = ""; @@ -351,9 +391,14 @@ void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphra fclose(pFile); // Check if Hostname was empty in .ini if yes set to std_hostname - if(_hostname.length() <= 0){ - _hostname = std_hostname; + if(hostname.length() <= 0){ + hostname = std_hostname; } + + printf("\nWLan: %s, %s\n", ssid.c_str(), passphrase.c_str()); + printf("Hostename: %s\n", hostname.c_str()); + printf("Fixed IP: %s, Gateway %s, Netmask %s, DNS %s\n", ipaddress.c_str(), gw.c_str(), netmask.c_str(), dns.c_str()); + } void LoadNetConfigFromFile(std::string fn, std::string &_ip, std::string &_gw, std::string &_netmask, std::string &_dns) diff --git a/code/components/connect_wlan/connect_wlan.h b/code/components/connect_wlan/connect_wlan.h index 94cc126f..827f32d2 100644 --- a/code/components/connect_wlan/connect_wlan.h +++ b/code/components/connect_wlan/connect_wlan.h @@ -5,13 +5,9 @@ #include "driver/gpio.h" const int CONNECTED_BIT = BIT0; +void ConnectToWLAN(); -void initialise_wifi(std::string _ssid, std::string _passphrase, std::string _hostname); -void initialise_wifi_fixed_ip(std::string _ip, std::string _gw, std::string _netmask, std::string _ssid, std::string _passphrase, std::string _hostname, std::string _dns = ""); - - -void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphrase, std::string &_hostname); -void LoadNetConfigFromFile(std::string fn, std::string &_ip, std::string &_gw, std::string &_netmask, std::string &_dns); +void LoadWlanFromFile(std::string fn); bool ChangeHostName(std::string fn, std::string _newhostname); diff --git a/code/components/esp32-camera-master/driver/camera.c b/code/components/esp32-camera-master/driver/camera.c index 1fe43871..b89dd37a 100644 --- a/code/components/esp32-camera-master/driver/camera.c +++ b/code/components/esp32-camera-master/driver/camera.c @@ -750,7 +750,7 @@ static void IRAM_ATTR dma_filter_buffer(size_t buf_idx) if(s_state->sensor.pixformat == PIXFORMAT_JPEG) { uint32_t sig = *((uint32_t *)s_state->fb->buf) & 0xFFFFFF; if(sig != 0xffd8ff) { - ets_printf("bh 0x%08x\n", sig); + ESP_LOGD(TAG,"unexpected JPEG signature 0x%08x\n", sig); s_state->fb->bad = 1; return; } diff --git a/code/components/esp32-camera-master/driver/sccb.c b/code/components/esp32-camera-master/driver/sccb.c index 8befb7c2..cb615bbc 100644 --- a/code/components/esp32-camera-master/driver/sccb.c +++ b/code/components/esp32-camera-master/driver/sccb.c @@ -7,6 +7,7 @@ * */ #include +#include #include #include #include "sccb.h" @@ -42,6 +43,7 @@ int SCCB_Init(int pin_sda, int pin_scl) ESP_LOGI(TAG, "pin_sda %d pin_scl %d\n", pin_sda, pin_scl); //log_i("SCCB_Init start"); i2c_config_t conf; + memset(&conf, 0, sizeof(i2c_config_t)); conf.mode = I2C_MODE_MASTER; conf.sda_io_num = pin_sda; conf.sda_pullup_en = GPIO_PULLUP_ENABLE; diff --git a/code/components/esp32-camera-master/examples/take_picture.c b/code/components/esp32-camera-master/examples/take_picture.c index 6bd3f822..96b224fd 100644 --- a/code/components/esp32-camera-master/examples/take_picture.c +++ b/code/components/esp32-camera-master/examples/take_picture.c @@ -6,7 +6,7 @@ // 1. Board setup (Uncomment): // #define BOARD_WROVER_KIT -#define BOARD_ESP32CAM_AITHINKER +// #define BOARD_ESP32CAM_AITHINKER /** * 2. Kconfig setup diff --git a/code/components/jomjol_controlcamera/ClassControllCamera.cpp b/code/components/jomjol_controlcamera/ClassControllCamera.cpp index dfd693a6..d2e044b3 100644 --- a/code/components/jomjol_controlcamera/ClassControllCamera.cpp +++ b/code/components/jomjol_controlcamera/ClassControllCamera.cpp @@ -136,6 +136,35 @@ static size_t jpg_encode_stream(void * arg, size_t index, const void* data, size return len; } +bool CCamera::SetBrightnessContrastSaturation(int _brightness, int _contrast, int _saturation) +{ + bool result = false; + sensor_t * s = esp_camera_sensor_get(); + _brightness = min(2, max(-2, _brightness)); + _contrast = min(2, max(-2, _contrast)); +// _saturation = min(2, max(-2, _saturation)); + +// s->set_saturation(s, _saturation); + s->set_contrast(s, _contrast); + s->set_brightness(s, _brightness); + + if (_brightness != brightness) + result = true; + if (_contrast != contrast) + result = true; + if (_saturation != saturation) + result = true; + + brightness = _brightness; + contrast = _contrast; + saturation = _saturation; + + if (result && isFixedExposure) + EnableAutoExposure(waitbeforepicture_org); + + return result; +} + void CCamera::SetQualitySize(int qual, framesize_t resol) { @@ -181,6 +210,31 @@ void CCamera::SetQualitySize(int qual, framesize_t resol) } +void CCamera::EnableAutoExposure(int flashdauer) +{ + LEDOnOff(true); + LightOnOff(true); + const TickType_t xDelay = flashdauer / portTICK_PERIOD_MS; + vTaskDelay( xDelay ); + + camera_fb_t * fb = esp_camera_fb_get(); + if (!fb) { + ESP_LOGE(TAGCAMERACLASS, "Camera Capture Failed"); + } + esp_camera_fb_return(fb); + + sensor_t * s = esp_camera_sensor_get(); + s->set_gain_ctrl(s, 0); + s->set_exposure_ctrl(s, 0); + + + LEDOnOff(false); + LightOnOff(false); + isFixedExposure = true; + waitbeforepicture_org = flashdauer; +} + + esp_err_t CCamera::CaptureToBasisImage(CImageBasis *_Image, int delay) { @@ -223,7 +277,7 @@ esp_err_t CCamera::CaptureToBasisImage(CImageBasis *_Image, int delay) LogFile.WriteHeapInfo("CCamera::CaptureToBasisImage - After fb_get"); #endif - LEDOnOff(false); + LEDOnOff(false); if (delay > 0) LightOnOff(false); @@ -513,6 +567,10 @@ CCamera::CCamera() #ifdef DEBUG_DETAIL_ON printf("CreateClassCamera\n"); #endif + brightness = -5; + contrast = -5; + saturation = -5; + isFixedExposure = false; } esp_err_t CCamera::InitCam() diff --git a/code/components/jomjol_controlcamera/ClassControllCamera.h b/code/components/jomjol_controlcamera/ClassControllCamera.h index 7e4dd6bb..b4389b8a 100644 --- a/code/components/jomjol_controlcamera/ClassControllCamera.h +++ b/code/components/jomjol_controlcamera/ClassControllCamera.h @@ -23,6 +23,9 @@ class CCamera { protected: int ActualQuality; framesize_t ActualResolution; + int brightness, contrast, saturation; + bool isFixedExposure; + int waitbeforepicture_org; public: int image_height, image_width; @@ -34,8 +37,12 @@ class CCamera { void LEDOnOff(bool status); esp_err_t CaptureToHTTP(httpd_req_t *req, int delay = 0); void SetQualitySize(int qual, framesize_t resol); + bool SetBrightnessContrastSaturation(int _brightness, int _contrast, int _saturation); void GetCameraParameter(httpd_req_t *req, int &qual, framesize_t &resol); + void EnableAutoExposure(int flashdauer); + + framesize_t TextToFramesize(const char * text); esp_err_t CaptureToFile(std::string nm, int delay = 0); diff --git a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp b/code/components/jomjol_flowcontroll/ClassFlowControll.cpp index 3d24feab..3d846f6c 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowControll.cpp @@ -39,7 +39,8 @@ std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _ for (int i = 0; i < FlowControll.size(); ++i) if (FlowControll[i]->name().compare(_classname) == 0){ - FlowControll[i]->doFlow(""); + if (!(FlowControll[i]->name().compare("ClassFlowMakeImage") == 0)) // falls es ein MakeImage ist, braucht das Bild nicht extra aufgenommen zu werden, dass passiert bei html-Abfrage automatisch + FlowControll[i]->doFlow(""); result = FlowControll[i]->getHTMLSingleStep(_host); } diff --git a/code/components/jomjol_flowcontroll/ClassFlowMakeImage.cpp b/code/components/jomjol_flowcontroll/ClassFlowMakeImage.cpp index 3e18c71c..9b86f3da 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowMakeImage.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowMakeImage.cpp @@ -34,6 +34,7 @@ void ClassFlowMakeImage::SetInitialParameter(void) ImageSize = FRAMESIZE_VGA; SaveAllFiles = false; disabled = false; + FixedExposure = false; namerawimage = "/sdcard/img_tmp/raw.jpg"; } @@ -48,6 +49,9 @@ bool ClassFlowMakeImage::ReadParameter(FILE* pfile, string& aktparamgraph) std::vector zerlegt; aktparamgraph = trim(aktparamgraph); + int _brightness = 0; + int _contrast = 0; + int _saturation = 0; if (aktparamgraph.size() == 0) if (!this->GetNextParagraph(pfile, aktparamgraph)) @@ -79,14 +83,48 @@ bool ClassFlowMakeImage::ReadParameter(FILE* pfile, string& aktparamgraph) SaveAllFiles = true; } + if ((toUpper(zerlegt[0]) == "BRIGHTNESS") && (zerlegt.size() > 1)) + { + _brightness = stoi(zerlegt[1]); + } + + if ((toUpper(zerlegt[0]) == "CONTRAST") && (zerlegt.size() > 1)) + { + _contrast = stoi(zerlegt[1]); + } + + if ((toUpper(zerlegt[0]) == "SATURATION") && (zerlegt.size() > 1)) + { + _saturation = stoi(zerlegt[1]); + } + + if ((toUpper(zerlegt[0]) == "FIXEDEXPOSURE") && (zerlegt.size() > 1)) + { + if (toUpper(zerlegt[1]) == "TRUE") + FixedExposure = true; + } } + Camera.SetBrightnessContrastSaturation(_brightness, _contrast, _saturation); Camera.SetQualitySize(ImageQuality, ImageSize); + image_width = Camera.image_width; image_height = Camera.image_height; rawImage = new CImageBasis(); rawImage->CreateEmptyImage(image_width, image_height, 3); + waitbeforepicture_store = waitbeforepicture; + if (FixedExposure) + { + printf("Fixed Exposure enabled!\n"); + int flashdauer = (int) (waitbeforepicture * 1000); + Camera.EnableAutoExposure(flashdauer); + waitbeforepicture = 0.2; +// flashdauer = (int) (waitbeforepicture * 1000); +// takePictureWithFlash(flashdauer); +// rawImage->SaveToFile("/sdcard/init2.jpg"); + } + return true; } @@ -101,7 +139,7 @@ bool ClassFlowMakeImage::doFlow(string zwtime) { string logPath = CreateLogFolder(zwtime); - int flashdauer = (int) waitbeforepicture * 1000; + int flashdauer = (int) (waitbeforepicture * 1000); #ifdef DEBUG_DETAIL_ON LogFile.WriteHeapInfo("ClassFlowMakeImage::doFlow - Before takePictureWithFlash"); @@ -126,7 +164,7 @@ bool ClassFlowMakeImage::doFlow(string zwtime) esp_err_t ClassFlowMakeImage::SendRawJPG(httpd_req_t *req) { - int flashdauer = (int) waitbeforepicture * 1000; + int flashdauer = (int) (waitbeforepicture * 1000); return Camera.CaptureToHTTP(req, flashdauer); } @@ -135,7 +173,7 @@ ImageData* ClassFlowMakeImage::SendRawImage() { CImageBasis *zw = new CImageBasis(rawImage); ImageData *id; - int flashdauer = (int) waitbeforepicture * 1000; + int flashdauer = (int) (waitbeforepicture * 1000); Camera.CaptureToBasisImage(zw, flashdauer); id = zw->writeToMemoryAsJPG(); delete zw; diff --git a/code/components/jomjol_flowcontroll/ClassFlowMakeImage.h b/code/components/jomjol_flowcontroll/ClassFlowMakeImage.h index 744c2cd3..4150cf7f 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowMakeImage.h +++ b/code/components/jomjol_flowcontroll/ClassFlowMakeImage.h @@ -15,6 +15,7 @@ class ClassFlowMakeImage : { protected: float waitbeforepicture; + float waitbeforepicture_store; framesize_t ImageSize; bool isImageSize; int ImageQuality; @@ -22,6 +23,8 @@ protected: string namerawimage; int image_height, image_width; bool SaveAllFiles; + bool FixedExposure; + void CopyFile(string input, string output); @@ -29,6 +32,7 @@ protected: esp_err_t camera_capture(); void takePictureWithFlash(int flashdauer); + void SetInitialParameter(void); public: diff --git a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp index ced38fef..817126cf 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp @@ -361,14 +361,14 @@ bool ClassFlowPostProcessing::doFlow(string zwtime) if ((!AllowNegativeRates) && (Value < PreValue)) { - ErrorMessageText = ErrorMessageText + "Negative Rate - Returned old value - read value: " + zwvalue + " - raw value: " + ReturnRawValue; + ErrorMessageText = ErrorMessageText + "Negative Rate - Returned old value - read value: " + zwvalue + " - raw value: " + ReturnRawValue + " - checked value: " + std::to_string(Value) + " "; Value = PreValue; zwvalue = RundeOutput(Value, AnzahlAnalog - DecimalShift); } if (useMaxRateValue && (abs(Value - PreValue) > MaxRateValue)) { - ErrorMessageText = ErrorMessageText + "Rate too high - Returned old value - read value: " + zwvalue + " "; + ErrorMessageText = ErrorMessageText + "Rate too high - Returned old value - read value: " + zwvalue + " - checked value: " + std::to_string(Value) + " "; Value = PreValue; zwvalue = RundeOutput(Value, AnzahlAnalog - DecimalShift); } diff --git a/code/components/jomjol_tfliteclass/CTfLiteClass.cpp b/code/components/jomjol_tfliteclass/CTfLiteClass.cpp index fc0043d3..d0a529f5 100644 --- a/code/components/jomjol_tfliteclass/CTfLiteClass.cpp +++ b/code/components/jomjol_tfliteclass/CTfLiteClass.cpp @@ -140,7 +140,10 @@ bool CTfLiteClass::LoadInputImageBasis(CImageBasis *rs) void CTfLiteClass::MakeAllocate() { static tflite::AllOpsResolver resolver; + +// printf(LogFile.getESPHeapInfo().c_str()); printf("\n"); this->interpreter = new tflite::MicroInterpreter(this->model, resolver, this->tensor_arena, this->kTensorArenaSize, this->error_reporter); +// printf(LogFile.getESPHeapInfo().c_str()); printf("\n"); TfLiteStatus allocate_status = this->interpreter->AllocateTensors(); if (allocate_status != kTfLiteOk) { @@ -229,7 +232,7 @@ CTfLiteClass::CTfLiteClass() this->interpreter = nullptr; this->input = nullptr; this->output = nullptr; - this->kTensorArenaSize = 150 * 1024; /// laut testfile: 108000 - bisher 600 + this->kTensorArenaSize = 200 * 1024; /// laut testfile: 108000 - bisher 600 this->tensor_arena = new uint8_t[kTensorArenaSize]; } diff --git a/code/components/jomjol_tfliteclass/server_tflite.cpp b/code/components/jomjol_tfliteclass/server_tflite.cpp index b4ff5a25..f7f9e32a 100644 --- a/code/components/jomjol_tfliteclass/server_tflite.cpp +++ b/code/components/jomjol_tfliteclass/server_tflite.cpp @@ -403,11 +403,33 @@ esp_err_t handler_editflow(httpd_req_t *req) if (_task.compare("test_take") == 0) { std::string _host = ""; + std::string _bri = ""; + std::string _con = ""; + std::string _sat = ""; + int bri = 0; + int sat = 0; + int con = 0; + if (httpd_query_key_value(_query, "host", _valuechar, 30) == ESP_OK) { _host = std::string(_valuechar); } + if (httpd_query_key_value(_query, "bri", _valuechar, 30) == ESP_OK) { + _bri = std::string(_valuechar); + bri = stoi(_bri); + } + if (httpd_query_key_value(_query, "con", _valuechar, 30) == ESP_OK) { + _con = std::string(_valuechar); + con = stoi(_con); + } + if (httpd_query_key_value(_query, "sat", _valuechar, 30) == ESP_OK) { + _sat = std::string(_valuechar); + sat = stoi(_sat); + } + + // printf("Parameter host: "); printf(_host.c_str()); printf("\n"); // string zwzw = "Do " + _task + " start\n"; printf(zwzw.c_str()); + bool changed = Camera.SetBrightnessContrastSaturation(bri, con, sat); std::string zw = tfliteflow.doSingleStep("[MakeImage]", _host); httpd_resp_sendstr_chunk(req, zw.c_str()); } @@ -559,9 +581,12 @@ void task_autodoFlow(void *pvParameter) LogFile.WriteToFile(zwtemp); printf("CPU Temperature: %.2f\n", cputmp); fr_delta_ms = (esp_timer_get_time() - fr_start) / 1000; - const TickType_t xDelay = (auto_intervall - fr_delta_ms) / portTICK_PERIOD_MS; - printf("Autoflow: sleep for : %ldms\n", (long) xDelay); - vTaskDelay( xDelay ); + if (auto_intervall > fr_delta_ms) + { + const TickType_t xDelay = (auto_intervall - fr_delta_ms) / portTICK_PERIOD_MS; + printf("Autoflow: sleep for : %ldms\n", (long) xDelay); + vTaskDelay( xDelay ); + } } vTaskDelete(NULL); //Delete this task if it exits from the loop above xHandletask_autodoFlow = NULL; diff --git a/code/main/main.cpp b/code/main/main.cpp index 3097847a..187495a9 100644 --- a/code/main/main.cpp +++ b/code/main/main.cpp @@ -80,40 +80,13 @@ extern "C" void app_main(void) Camera.LightOnOff(false); Init_NVS_SDCard(); -// LogFile.WriteToFile("Startsequence 02"); + CheckOTAUpdate(); -// LogFile.WriteToFile("Startsequence 03"); - std::string ssid = ""; - std::string password = ""; - std::string hostname = ""; - std::string ip = ""; - std::string gw = ""; - std::string netmask = ""; - std::string dns = ""; -// LoadWlanFromFile("/sdcard/wlan.ini", ssid, password, hostname, ip, gw, netmask, dns); - LoadWlanFromFile("/sdcard/wlan.ini", ssid, password, hostname); - LoadNetConfigFromFile("/sdcard/wlan.ini", ip, gw, netmask, dns); - -// LogFile.WriteToFile("Startsequence 04"); - printf("To use WLan: %s, %s\n", ssid.c_str(), password.c_str()); - printf("To set Hostename: %s\n", hostname.c_str()); - printf("Fixed IP: %s, Gateway %s, Netmask %s, DNS %s\n", ip.c_str(), gw.c_str(), netmask.c_str(), dns.c_str()); - - if (ip.length() == 0 || gw.length() == 0 || netmask.length() == 0) - { - initialise_wifi(ssid, password, hostname); - } - else - { - initialise_wifi_fixed_ip(ip, gw, netmask, ssid, password, hostname, dns); - } - - printf("Netparameter: IP: %s - GW: %s - NetMask %s\n", getIPAddress().c_str(), getGW().c_str(), getNetMask().c_str()); + LoadWlanFromFile("/sdcard/wlan.ini"); + ConnectToWLAN(); + printf("\nNetparameter: IP: %s - GW: %s - NetMask %s\n", getIPAddress().c_str(), getGW().c_str(), getNetMask().c_str()); - -// LogFile.WriteToFile("Startsequence 05"); - TickType_t xDelay; xDelay = 2000 / portTICK_PERIOD_MS; printf("Autoflow: sleep for : %ldms\n", (long) xDelay); diff --git a/code/main/server_main.cpp b/code/main/server_main.cpp index 37802ebf..719e8d7a 100644 --- a/code/main/server_main.cpp +++ b/code/main/server_main.cpp @@ -209,6 +209,7 @@ esp_err_t hello_main_handler(httpd_req_t *req) return res; /* Respond with an empty chunk to signal HTTP response completion */ +// httpd_resp_sendstr(req, ""); httpd_resp_send_chunk(req, NULL, 0); #ifdef DEBUG_DETAIL_ON diff --git a/code/main/version.cpp b/code/main/version.cpp index 4328fc25..03085192 100644 --- a/code/main/version.cpp +++ b/code/main/version.cpp @@ -1,4 +1,4 @@ -const char* GIT_REV="46cfe45"; +const char* GIT_REV="4b6044d"; const char* GIT_TAG=""; -const char* GIT_BRANCH="master"; -const char* BUILD_TIME="2021-01-20 19:47"; \ No newline at end of file +const char* GIT_BRANCH="rolling"; +const char* BUILD_TIME="2021-03-08 20:16"; \ No newline at end of file diff --git a/code/main/version.h b/code/main/version.h index 94f63b98..02fa3f17 100644 --- a/code/main/version.h +++ b/code/main/version.h @@ -13,7 +13,7 @@ extern "C" #include "Helper.h" #include -const char* GIT_BASE_BRANCH = "master - v6.1.0 - 2020-01-20"; +const char* GIT_BASE_BRANCH = "master - v6.2.0 - 2020-03-08"; const char* git_base_branch(void) diff --git a/code/platformio.ini b/code/platformio.ini index 4af22de5..f42f3aa1 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -15,14 +15,13 @@ src_dir = main [env:esp32cam] platform = espressif32@2.1.0 +;platform = espressif32 board = esp32cam framework = espidf ;board_build.partitions = partitions_singleapp.csv board_build.partitions = partitions.csv - - lib_deps = jomjol_helper connect_wlan diff --git a/code/sdkconfig b/code/sdkconfig index 30ad0482..7028733c 100644 --- a/code/sdkconfig +++ b/code/sdkconfig @@ -173,95 +173,7 @@ CONFIG_BTDM_BLE_SLEEP_CLOCK_ACCURACY_INDEX_EFF=1 CONFIG_BT_RESERVE_DRAM=0 # end of Bluetooth -CONFIG_BLE_MESH=y -CONFIG_BLE_MESH_HCI_5_0=y -# CONFIG_BLE_MESH_ALLOC_FROM_PSRAM_FIRST is not set -# CONFIG_BLE_MESH_FAST_PROV is not set -# CONFIG_BLE_MESH_NODE is not set -# CONFIG_BLE_MESH_PROVISIONER is not set -CONFIG_BLE_MESH_PROV=y -CONFIG_BLE_MESH_PB_ADV=y -# CONFIG_BLE_MESH_PB_GATT is not set -CONFIG_BLE_MESH_PROXY=y -# CONFIG_BLE_MESH_GATT_PROXY_CLIENT is not set -CONFIG_BLE_MESH_NET_BUF_POOL_USAGE=y -# CONFIG_BLE_MESH_SETTINGS is not set -CONFIG_BLE_MESH_SUBNET_COUNT=3 -CONFIG_BLE_MESH_APP_KEY_COUNT=3 -CONFIG_BLE_MESH_MODEL_KEY_COUNT=3 -CONFIG_BLE_MESH_MODEL_GROUP_COUNT=3 -CONFIG_BLE_MESH_LABEL_COUNT=3 -CONFIG_BLE_MESH_CRPL=10 -CONFIG_BLE_MESH_MSG_CACHE_SIZE=10 -CONFIG_BLE_MESH_ADV_BUF_COUNT=60 -# CONFIG_BLE_MESH_SUPPORT_BLE_ADV is not set -CONFIG_BLE_MESH_IVU_DIVIDER=4 -CONFIG_BLE_MESH_TX_SEG_MSG_COUNT=1 -CONFIG_BLE_MESH_RX_SEG_MSG_COUNT=1 -CONFIG_BLE_MESH_RX_SDU_MAX=384 -CONFIG_BLE_MESH_TX_SEG_MAX=32 -# CONFIG_BLE_MESH_FRIEND is not set -# CONFIG_BLE_MESH_NO_LOG is not set - -# -# BLE Mesh STACK DEBUG LOG LEVEL -# -# CONFIG_BLE_MESH_TRACE_LEVEL_NONE is not set -# CONFIG_BLE_MESH_TRACE_LEVEL_ERROR is not set -CONFIG_BLE_MESH_TRACE_LEVEL_WARNING=y -# CONFIG_BLE_MESH_TRACE_LEVEL_INFO is not set -# CONFIG_BLE_MESH_TRACE_LEVEL_DEBUG is not set -# CONFIG_BLE_MESH_TRACE_LEVEL_VERBOSE is not set -CONFIG_BLE_MESH_STACK_TRACE_LEVEL=2 -# end of BLE Mesh STACK DEBUG LOG LEVEL - -# -# BLE Mesh NET BUF DEBUG LOG LEVEL -# -# CONFIG_BLE_MESH_NET_BUF_TRACE_LEVEL_NONE is not set -# CONFIG_BLE_MESH_NET_BUF_TRACE_LEVEL_ERROR is not set -CONFIG_BLE_MESH_NET_BUF_TRACE_LEVEL_WARNING=y -# CONFIG_BLE_MESH_NET_BUF_TRACE_LEVEL_INFO is not set -# CONFIG_BLE_MESH_NET_BUF_TRACE_LEVEL_DEBUG is not set -# CONFIG_BLE_MESH_NET_BUF_TRACE_LEVEL_VERBOSE is not set -CONFIG_BLE_MESH_NET_BUF_TRACE_LEVEL=2 -# end of BLE Mesh NET BUF DEBUG LOG LEVEL - -CONFIG_BLE_MESH_CLIENT_MSG_TIMEOUT=4000 - -# -# Support for BLE Mesh Client Models -# -# CONFIG_BLE_MESH_CFG_CLI is not set -# CONFIG_BLE_MESH_HEALTH_CLI is not set -# CONFIG_BLE_MESH_GENERIC_ONOFF_CLI is not set -# CONFIG_BLE_MESH_GENERIC_LEVEL_CLI is not set -# CONFIG_BLE_MESH_GENERIC_DEF_TRANS_TIME_CLI is not set -# CONFIG_BLE_MESH_GENERIC_POWER_ONOFF_CLI is not set -# CONFIG_BLE_MESH_GENERIC_POWER_LEVEL_CLI is not set -# CONFIG_BLE_MESH_GENERIC_BATTERY_CLI is not set -# CONFIG_BLE_MESH_GENERIC_LOCATION_CLI is not set -# CONFIG_BLE_MESH_GENERIC_PROPERTY_CLI is not set -# CONFIG_BLE_MESH_SENSOR_CLI is not set -# CONFIG_BLE_MESH_TIME_CLI is not set -# CONFIG_BLE_MESH_SCENE_CLI is not set -# CONFIG_BLE_MESH_SCHEDULER_CLI is not set -# CONFIG_BLE_MESH_LIGHT_LIGHTNESS_CLI is not set -# CONFIG_BLE_MESH_LIGHT_CTL_CLI is not set -# CONFIG_BLE_MESH_LIGHT_HSL_CLI is not set -# CONFIG_BLE_MESH_LIGHT_XYL_CLI is not set -# CONFIG_BLE_MESH_LIGHT_LC_CLI is not set -# end of Support for BLE Mesh Client Models - -# CONFIG_BLE_MESH_IV_UPDATE_TEST is not set - -# -# BLE Mesh specific test option -# -# CONFIG_BLE_MESH_SELF_TEST is not set -# CONFIG_BLE_MESH_SHELL is not set -# CONFIG_BLE_MESH_DEBUG is not set -# end of BLE Mesh specific test option +# CONFIG_BLE_MESH is not set # # CoAP Configuration diff --git a/code/version.cpp b/code/version.cpp index 4328fc25..03085192 100644 --- a/code/version.cpp +++ b/code/version.cpp @@ -1,4 +1,4 @@ -const char* GIT_REV="46cfe45"; +const char* GIT_REV="4b6044d"; const char* GIT_TAG=""; -const char* GIT_BRANCH="master"; -const char* BUILD_TIME="2021-01-20 19:47"; \ No newline at end of file +const char* GIT_BRANCH="rolling"; +const char* BUILD_TIME="2021-03-08 20:16"; \ No newline at end of file diff --git a/firmware/bootloader.bin b/firmware/bootloader.bin index 1d516fbd..753b6734 100644 Binary files a/firmware/bootloader.bin and b/firmware/bootloader.bin differ diff --git a/firmware/firmware.bin b/firmware/firmware.bin index 20567745..88e7382d 100644 Binary files a/firmware/firmware.bin and b/firmware/firmware.bin differ diff --git a/firmware/html.zip b/firmware/html.zip index e53bfa04..aeb0c666 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 822a5538..d1fc3e19 100644 --- a/sd-card/config/config.ini +++ b/sd-card/config/config.ini @@ -4,6 +4,8 @@ WaitBeforeTakingPicture = 5 ImageQuality = 5 ImageSize = VGA +Brightness = -2 +FixedExposure = true [Alignment] InitalRotate=180 @@ -15,7 +17,7 @@ AlignmentAlgo = Default [Digits] -Model = /config/dig0721s1.tflite +Model = /config/dig0811s1.tflite ;LogImageLocation = /log/digit ;LogfileRetentionInDays = 3 ModelInputSize = 20 32 diff --git a/sd-card/config/dig0810s3.tflite b/sd-card/config/dig0810s3.tflite new file mode 100644 index 00000000..d9464658 Binary files /dev/null and b/sd-card/config/dig0810s3.tflite differ diff --git a/sd-card/config/dig0811s1.tflite b/sd-card/config/dig0811s1.tflite new file mode 100644 index 00000000..8a78aed4 Binary files /dev/null and b/sd-card/config/dig0811s1.tflite differ diff --git a/sd-card/html/debug.log b/sd-card/html/debug.log deleted file mode 100644 index decfc8b3..00000000 --- a/sd-card/html/debug.log +++ /dev/null @@ -1,3 +0,0 @@ -[1204/185120.033:ERROR:directory_reader_win.cc(43)] FindFirstFile: Das System kann den angegebenen Pfad nicht finden. (0x3) -[0102/122131.430:ERROR:directory_reader_win.cc(43)] FindFirstFile: Das System kann den angegebenen Pfad nicht finden. (0x3) -[0118/210038.095:ERROR:directory_reader_win.cc(43)] FindFirstFile: Das System kann den angegebenen Pfad nicht finden. (0x3) diff --git a/sd-card/html/edit_config_param.html b/sd-card/html/edit_config_param.html index 329fca2f..ce30ed31 100644 --- a/sd-card/html/edit_config_param.html +++ b/sd-card/html/edit_config_param.html @@ -130,6 +130,67 @@ textarea { Picture size camera (default = "VGA") + + + + + Brightness + + + + + + Image Brightness (-2 .. 2 - default = "0") + + + + + + + FixedExposure + + + + + + Fixes the illumination setting of camera at the startup and uses this later --> individual round is faster + + + + + +

Alignment

@@ -767,7 +828,11 @@ function UpdateInput() { WriteParameter(param, category, "MakeImage", "LogfileRetentionInDays", true); WriteParameter(param, category, "MakeImage", "WaitBeforeTakingPicture", false); WriteParameter(param, category, "MakeImage", "ImageQuality", false); + WriteParameter(param, category, "MakeImage", "Brightness", false); +// WriteParameter(param, category, "MakeImage", "Contrast", false); +// WriteParameter(param, category, "MakeImage", "Saturation", false); WriteParameter(param, category, "MakeImage", "ImageSize", false, true, true); + WriteParameter(param, category, "MakeImage", "FixedExposure", false, true, true); WriteParameter(param, category, "Alignment", "SearchFieldX", false); WriteParameter(param, category, "Alignment", "SearchFieldY", false); @@ -820,7 +885,11 @@ function ReadParameterAll() ReadParameter(param, "MakeImage", "LogfileRetentionInDays", true); ReadParameter(param, "MakeImage", "WaitBeforeTakingPicture", false); ReadParameter(param, "MakeImage", "ImageQuality", false); + ReadParameter(param, "MakeImage", "Brightness", false); +// ReadParameter(param, "MakeImage", "Contrast", false); +// ReadParameter(param, "MakeImage", "Saturation", false); ReadParameter(param, "MakeImage", "ImageSize", false, true); + ReadParameter(param, "MakeImage", "FixedExposure", false, true); ReadParameter(param, "Alignment", "SearchFieldX", false); ReadParameter(param, "Alignment", "SearchFieldY", false); diff --git a/sd-card/html/edit_reference.html b/sd-card/html/edit_reference.html index aac815e2..4c7f55b4 100644 --- a/sd-card/html/edit_reference.html +++ b/sd-card/html/edit_reference.html @@ -34,7 +34,7 @@ table {

Create Reference out of Raw Image

- + @@ -42,17 +42,32 @@ table { - - + + + + - + +
Degrees + Brightness: + +
Degrees
@@ -68,6 +83,9 @@ table { + + +