Merge pull request #3 from jomjol/rolling

Pull Rolling
This commit is contained in:
phlupp
2020-09-28 22:21:07 +02:00
committed by GitHub
36 changed files with 745 additions and 682 deletions

View File

@@ -19,9 +19,7 @@ A 3d-printable housing can be found here: https://www.thingiverse.com/thing:4571
### Known Issues
* Parts of the web page only works correctly in **Firefox** and Chrome!
With **Edge** not all parts (especially the configuration) are **not full functional**.
* spontaneous reboot, especially in case of intensive web server access (improved since v2.0.0)
* spontaneous reboot, especially in case of intensive web server access (improved since v2.1.0)
------
@@ -29,30 +27,42 @@ A 3d-printable housing can be found here: https://www.thingiverse.com/thing:4571
##### Rolling - (2020-09-20)
##### Rolling - (2020-09-28)
* Update HTML-Backround (thanks to michaeljoos72)
* based on v2.2.1 (2020-09-28)
2020-09-16
* Impovements in hostname
2020-09-14
* Implementation of hostname in wlan.ini (`hostname = "HOSTNAME")` - Parameter is optional
* Bug correction DecimalShift
2020-09-13
* Bug fixing DecimalShift (digits after comma)
* Implementation of decimal shift (New Parameter "DecimalShift = 1" in [PostProcessing])
DecimalShift = 2 --> Result: 123.456 --> 12345.6
DecimalShift = -1 --> Result: 123.456 --> 12.3456
The shift is done at the very first step of merging digital and analog, so all following number already will work on the shifted number.
* based on v2.0.0 (2020-09-12)
##### 2.2.1 Version Control (2020-09-27)
* Bug-Fixing (hostname in wlan.ini and error handling inside flow)
##### 2.2.0 Version Control (2020-09-27)
* Integrated automated versioning system (menu: SYSTEM --> INFO)
* Update Build-System to PlatformIO - Espressif 32 v2.0.0 (ESP-IDF 4.1)
##### 2.1.0 Decimal Shift, Chrome & Edge (2020-09-25)
* Implementation of Decimal Shift
* Update default CNN for digits to v6.4.0
* Improvement HTML
* Support for Chrome and Edge
* Reduce logging to minimum - extended logging on demand
* Implementation of hostname in wlan.ini (`hostname = "HOSTNAME")`
* Bug fixing, code corrections

View File

@@ -4,5 +4,12 @@ list(APPEND EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/proto
set(PROJECT_VER "0.0.9.3")
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version.cpp
${CMAKE_CURRENT_BINARY_DIR}/_version.cpp
COMMAND ${CMAKE_COMMAND} -P
${CMAKE_CURRENT_SOURCE_DIR}/version.cmake)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(esp32cam-server-only)

View File

@@ -143,7 +143,6 @@ void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphra
char zw[1024];
fgets(zw, 1024, pFile);
// printf("%s", zw);
line = std::string(zw);
while ((line.size() > 0) || !(feof(pFile)))
@@ -151,21 +150,16 @@ void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphra
// printf("%s", line.c_str());
zerlegt = ZerlegeZeile(line, "=");
zerlegt[0] = trim(zerlegt[0], " ");
zerlegt[1] = trim(zerlegt[1], " ");
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "HOSTNAME")){
_hostname = zerlegt[1];
_hostname = trim(zerlegt[1]);
if ((_hostname[0] == '"') && (_hostname[_hostname.length()-1] == '"')){
_hostname = _hostname.substr(1, _hostname.length()-2);
}
// Check if Hostname was empty in .ini if yes set to std_hostname
if(_hostname.length() <= 0){
_hostname = std_hostname;
}
}
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "SSID")){
_ssid = zerlegt[1];
_ssid = trim(zerlegt[1]);
if ((_ssid[0] == '"') && (_ssid[_ssid.length()-1] == '"')){
_ssid = _ssid.substr(1, _ssid.length()-2);
}
@@ -189,6 +183,11 @@ 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;
}
}

View File

@@ -258,7 +258,7 @@ static esp_err_t download_get_handler(httpd_req_t *req)
return ESP_FAIL;
}
esp_err_t res = httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
ESP_LOGI(TAG, "Sending file : %s (%ld bytes)...", filename, file_stat.st_size);
set_content_type_from_file(req, filename);
@@ -437,7 +437,6 @@ static esp_err_t delete_post_handler(httpd_req_t *req)
//////////////////////////////////////////////////////////////
char _query[200];
char _filename[30];
char _valuechar[30];
std::string fn = "/sdcard/firmware/";
std::string _task;
@@ -576,8 +575,6 @@ void unzip(std::string _in_zip_file, std::string _target_directory){
size_t uncomp_size;
mz_zip_archive zip_archive;
void* p;
const int N = 50;
char data[2048];
char archive_filename[64];
std::string zw;
// static const char* s_Test_archive_filename = "testhtml.zip";

View File

@@ -10,6 +10,8 @@
#include "CTfLiteClass.h"
#endif
#include "ClassLogFile.h"
ClassFlowAnalog::ClassFlowAnalog()
{
isLogImage = false;
@@ -106,6 +108,7 @@ bool ClassFlowAnalog::ReadParameter(FILE* pfile, string& aktparamgraph)
neuroi->posy = std::stoi(zerlegt[2]);
neuroi->deltax = std::stoi(zerlegt[3]);
neuroi->deltay = std::stoi(zerlegt[4]);
neuroi->result = -1;
ROI.push_back(neuroi);
}
}
@@ -140,7 +143,10 @@ string ClassFlowAnalog::getHTMLSingleStep(string host)
bool ClassFlowAnalog::doFlow(string time)
{
doAlignAndCut(time);
if (!doAlignAndCut(time)){
return false;
};
doNeuralNetwork(time);
return true;
@@ -160,8 +166,21 @@ bool ClassFlowAnalog::doAlignAndCut(string time)
CImageBasis *img_roi = NULL;
CAlignAndCutImage *caic = new CAlignAndCutImage(input);
if (input_roi.length() > 0)
img_roi = new CImageBasis(input_roi);
if (!caic->ImageOkay()){
LogFile.WriteToFile("ClassFlowAnalog::doAlignAndCut not okay!");
delete caic;
return false;
}
if (input_roi.length() > 0){
img_roi = new CImageBasis(input_roi);
if (!img_roi->ImageOkay()){
LogFile.WriteToFile("ClassFlowAnalog::doAlignAndCut ImageRoi not okay!");
delete caic;
delete img_roi;
return false;
}
}
for (int i = 0; i < ROI.size(); ++i)
{

View File

@@ -6,7 +6,6 @@
#include "server_ota.h"
std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _host){
bool found = false;
std::string _classname = "";
std::string result = "";
if (_stepname.compare("[MakeImage]") == 0){
@@ -29,7 +28,6 @@ std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _
// printf(FlowControll[i]->name().c_str()); printf("\n");
FlowControll[i]->doFlow("");
result = FlowControll[i]->getHTMLSingleStep(_host);
found = true;
}
return result;
@@ -74,15 +72,15 @@ ClassFlow* ClassFlowControll::CreateClassFlow(std::string _type)
_type = trim(_type);
if (_type.compare("[MakeImage]") == 0)
if (toUpper(_type).compare("[MAKEIMAGE]") == 0)
cfc = new ClassFlowMakeImage(&FlowControll);
if (_type.compare("[Alignment]") == 0)
if (toUpper(_type).compare("[ALIGNMENT]") == 0)
cfc = new ClassFlowAlignment(&FlowControll);
if (_type.compare("[Analog]") == 0)
if (toUpper(_type).compare("[ANALOG]") == 0)
cfc = new ClassFlowAnalog(&FlowControll);
if (_type.compare("[Digits]") == 0)
if (toUpper(_type).compare("[DIGITS]") == 0)
cfc = new ClassFlowDigit(&FlowControll);
if (_type.compare("[PostProcessing]") == 0)
if (toUpper(_type).compare("[POSTPROCESSING]") == 0)
{
cfc = new ClassFlowPostProcessing(&FlowControll);
flowpostprocessing = (ClassFlowPostProcessing*) cfc;
@@ -91,9 +89,12 @@ ClassFlow* ClassFlowControll::CreateClassFlow(std::string _type)
if (cfc) // Wird nur angehangen, falls es nicht [AutoTimer] ist, denn dieses ist für FlowControll
FlowControll.push_back(cfc);
if (_type.compare("[AutoTimer]") == 0)
if (toUpper(_type).compare("[AUTOTIMER]") == 0)
cfc = this;
if (toUpper(_type).compare("[DEBUG]") == 0)
cfc = this;
return cfc;
}
@@ -156,7 +157,7 @@ bool ClassFlowControll::doFlow(string time)
if (!FlowControll[i]->doFlow(time)){
repeat++;
LogFile.WriteToFile("Fehler im vorheriger Schritt - wird zum " + to_string(repeat) + ". Mal wiederholt");
i = i-2; // vorheriger Schritt muss wiederholt werden (vermutlich Bilder aufnehmen)
i = -1; // vorheriger Schritt muss wiederholt werden (vermutlich Bilder aufnehmen)
result = false;
if (repeat > 5) {
LogFile.WriteToFile("Wiederholung 5x nicht erfolgreich --> reboot");
@@ -230,7 +231,7 @@ std::string ClassFlowControll::UpdatePrevalue(std::string _newvalue)
if (flowpostprocessing)
{
flowpostprocessing->SavePreValue(zw);
return to_string(zw);
return _newvalue;
}
return std::string();
@@ -247,23 +248,34 @@ bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph)
return false;
if (aktparamgraph.compare("[AutoTimer]") != 0) // Paragraph passt nich zu MakeImage
if ((toUpper(aktparamgraph).compare("[AUTOTIMER]") != 0) && (toUpper(aktparamgraph).compare("[DEBUG]") != 0)) // Paragraph passt nicht zu MakeImage
return false;
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
{
zerlegt = this->ZerlegeZeile(aktparamgraph);
if ((zerlegt[0] == "AutoStart") && (zerlegt.size() > 1))
if ((toUpper(zerlegt[0]) == "AUTOSTART") && (zerlegt.size() > 1))
{
if (toUpper(zerlegt[1]) == "TRUE")
{
AutoStart = true;
}
}
if ((zerlegt[0] == "Intervall") && (zerlegt.size() > 1))
if ((toUpper(zerlegt[0]) == "INTERVALL") && (zerlegt.size() > 1))
{
AutoIntervall = std::stof(zerlegt[1]);
}
if ((toUpper(zerlegt[0]) == "LOGFILE") && (zerlegt.size() > 1))
{
if (toUpper(zerlegt[1]) == "TRUE")
{
LogFile.SwitchOnOff(true);
}
if (toUpper(zerlegt[1]) == "FALSE")
{
LogFile.SwitchOnOff(false);
}
}
}
return true;
}

View File

@@ -11,6 +11,8 @@
// #include "bitmap_image.hpp"
#include "ClassLogFile.h"
ClassFlowDigit::ClassFlowDigit()
{
isLogImage = false;
@@ -84,6 +86,7 @@ bool ClassFlowDigit::ReadParameter(FILE* pfile, string& aktparamgraph)
neuroi->posy = std::stoi(zerlegt[2]);
neuroi->deltax = std::stoi(zerlegt[3]);
neuroi->deltay = std::stoi(zerlegt[4]);
neuroi->resultklasse = -1;
ROI.push_back(neuroi);
}
}
@@ -119,7 +122,10 @@ string ClassFlowDigit::getHTMLSingleStep(string host)
bool ClassFlowDigit::doFlow(string time)
{
doAlignAndCut(time);
if (!doAlignAndCut(time)){
return false;
};
doNeuralNetwork(time);
return true;
@@ -138,9 +144,22 @@ bool ClassFlowDigit::doAlignAndCut(string time)
CResizeImage *rs;
CImageBasis *img_roi = NULL;
CAlignAndCutImage *caic = new CAlignAndCutImage(input);
if (!caic->ImageOkay()){
LogFile.WriteToFile("ClassFlowDigit::doAlignAndCut not okay!");
delete caic;
return false;
}
if (input_roi.length() > 0)
if (input_roi.length() > 0){
img_roi = new CImageBasis(input_roi);
if (!img_roi->ImageOkay()){
LogFile.WriteToFile("ClassFlowDigit::doAlignAndCut ImageRoi not okay!");
delete caic;
delete img_roi;
return false;
}
}
for (int i = 0; i < ROI.size(); ++i)

View File

@@ -171,9 +171,6 @@ bool ClassFlowPostProcessing::ReadParameter(FILE* pfile, string& aktparamgraph)
if ((toUpper(zerlegt[0]) == "DECIMALSHIFT") && (zerlegt.size() > 1))
{
DecimalShift = stoi(zerlegt[1]);
if (PreValueUse){
PreValueOkay = LoadPreValue();
}
}
if ((toUpper(zerlegt[0]) == "PREVALUEUSE") && (zerlegt.size() > 1))
@@ -181,7 +178,6 @@ bool ClassFlowPostProcessing::ReadParameter(FILE* pfile, string& aktparamgraph)
if (toUpper(zerlegt[1]) == "TRUE")
{
PreValueUse = true;
PreValueOkay = LoadPreValue();
}
}
if ((toUpper(zerlegt[0]) == "CHECKDIGITINCREASECONSISTENCY") && (zerlegt.size() > 1))
@@ -209,6 +205,10 @@ bool ClassFlowPostProcessing::ReadParameter(FILE* pfile, string& aktparamgraph)
MaxRateValue = std::stof(zerlegt[1]);
}
}
if (PreValueUse) {
PreValueOkay = LoadPreValue();
}
return true;
}
@@ -329,26 +329,15 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
return true;
}
/*
if (isdigit)
{
int lastanalog = -1;
if (isanalog)
lastanalog = analog[0] - 48;
digit = ErsetzteN(digit, lastanalog);
zw = digit;
}
zw = ErsetzteN(ReturnRawValue);
if (isdigit && isanalog)
zw = zw + ".";
if (isanalog)
zw = zw + analog;
zw = ShiftDecimal(zw, DecimalShift);
*/
zw = ErsetzteN(ReturnRawValue);
Value = std::stof(zw);
if (checkDigitIncreaseConsistency)
{
// Value = checkDigitConsistency(Value, DecimalShift, isanalog);
}
zwvalue = RundeOutput(Value, AnzahlAnalog - DecimalShift);
if ((!AllowNegativeRates) && (Value < PreValue))
@@ -430,39 +419,40 @@ string ClassFlowPostProcessing::ErsetzteN(string input)
return input;
}
string ClassFlowPostProcessing::checkDigitConsistency(string input, int _decilamshift, int lastvalueanalog){
/*
if (checkDigitIncreaseConsistency && lastvalueanalog > -1)
{
int zifferIST;
// int substrakt = 0;
bool lastcorrected = false;
for (int i = input.length() - 1; i >= 0; --i)
{
zifferIST = input[i] - 48; //std::stoi(std::string(input[i]));
if (lastcorrected)
{
zifferIST--;
input[i] = zifferIST + 48;
lastcorrected = false;
}
float ClassFlowPostProcessing::checkDigitConsistency(float input, int _decilamshift, bool _isanalog){
int aktdigit, olddigit;
int aktdigit_before, olddigit_before;
int pot, pot_max;
float zw;
pot = posPunkt - i - 1;
zw = PreValue / pow(10, pot);
ziffer = ((int) zw) % 10;
if (zifferIST < ziffer)
{
if (lastvalueanalog >= 7)
{
input[i] = ziffer + 48;
lastvalueanalog = ziffer;
lastcorrected = true;
}
}
}
pot = _decilamshift;
if (!_isanalog) // falls es keine analogwerte gibt, kann die letzte nicht bewerte werden
{
pot++;
}
*/
pot_max = ((int) log10(input)) + 1;
while (pot <= pot_max)
{
zw = input / pow(10, pot-1);
aktdigit_before = ((int) zw) % 10;
zw = PreValue / pow(10, pot-1);
olddigit_before = ((int) zw) % 10;
zw = input / pow(10, pot);
aktdigit = ((int) zw) % 10;
zw = PreValue / pow(10, pot);
olddigit = ((int) zw) % 10;
if (aktdigit != olddigit) {
if (olddigit_before <= aktdigit_before) // stelle vorher hat noch keinen Nulldurchgang --> nachfolgestelle sollte sich nicht verändern
{
input = input + ((float) (olddigit - aktdigit)) * pow(10, pot); // Neue Digit wird durch alte Digit ersetzt;
}
}
pot++;
}
return input;
}

View File

@@ -9,7 +9,7 @@ class ClassFlowPostProcessing :
{
protected:
bool PreValueUse;
int PreValueAgeStartup;
int PreValueAgeStartup;
bool AllowNegativeRates;
float MaxRateValue;
bool useMaxRateValue;
@@ -29,7 +29,7 @@ protected:
string ShiftDecimal(string in, int _decShift);
string ErsetzteN(string);
string checkDigitConsistency(string, int _decilamshift, int lastvalueanalog = -1);
float checkDigitConsistency(float input, int _decilamshift, bool _isanalog);
string RundeOutput(float _in, int _anzNachkomma);
public:

View File

@@ -528,8 +528,6 @@ void CAlignAndCutImage::CutAndSave(std::string _template1, int x1, int y1, int d
int memsize = dx * dy * this->channels;
uint8_t* odata = (unsigned char*)GET_MEMORY(memsize);
int x_source, y_source;
stbi_uc* p_target;
stbi_uc* p_source;

View File

@@ -8,6 +8,10 @@ void ClassLogFile::WriteToDedicatedFile(std::string _fn, std::string info, bool
FILE* pFile;
std::string zwtime;
if (!doLogFile){
return;
}
pFile = fopen(_fn.c_str(), "a+");
if (_time)
@@ -30,6 +34,11 @@ void ClassLogFile::WriteToDedicatedFile(std::string _fn, std::string info, bool
fclose(pFile);
}
void ClassLogFile::SwitchOnOff(bool _doLogFile){
doLogFile = _doLogFile;
};
void ClassLogFile::WriteToFile(std::string info, bool _time)
{
WriteToDedicatedFile(logfile, info, _time);
@@ -37,5 +46,6 @@ void ClassLogFile::WriteToFile(std::string info, bool _time)
ClassLogFile::ClassLogFile(std::string _logfile)
{
logfile = _logfile;
logfile = _logfile;
doLogFile = true;
}

View File

@@ -6,9 +6,12 @@ class ClassLogFile
{
private:
std::string logfile;
bool doLogFile;
public:
ClassLogFile(std::string _logfile);
void SwitchOnOff(bool _doLogFile);
void WriteToFile(std::string info, bool _time = true);
void WriteToDedicatedFile(std::string _fn, std::string info, bool _time = true);
};

View File

@@ -123,8 +123,8 @@ CONFIG_PARTITION_TABLE_MD5=y
#
CONFIG_EXAMPLE_CONNECT_WIFI=y
# CONFIG_EXAMPLE_CONNECT_ETHERNET is not set
CONFIG_EXAMPLE_WIFI_SSID="SSID"
CONFIG_EXAMPLE_WIFI_PASSWORD="passwd"
CONFIG_EXAMPLE_WIFI_SSID="myssid"
CONFIG_EXAMPLE_WIFI_PASSWORD="mypassword"
CONFIG_EXAMPLE_CONNECT_IPV6=y
# end of Example Connection Configuration
@@ -435,8 +435,8 @@ CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=y
#
# HTTP Server
#
CONFIG_HTTPD_MAX_REQ_HDR_LEN=512
CONFIG_HTTPD_MAX_URI_LEN=512
CONFIG_HTTPD_MAX_REQ_HDR_LEN=1024
CONFIG_HTTPD_MAX_URI_LEN=1024
CONFIG_HTTPD_ERR_RESP_NO_DELAY=y
CONFIG_HTTPD_PURGE_BUF_LEN=32
# CONFIG_HTTPD_LOG_PURGE_DATA is not set

File diff suppressed because it is too large Load Diff

View File

@@ -1,14 +1,58 @@
# This file was automatically generated for projects
# without default 'CMakeLists.txt' file.
if(NOT CMAKE_BUILD_EARLY_EXPANSION)
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version.cpp
${CMAKE_CURRENT_BINARY_DIR}/_version.cpp
COMMAND ${CMAKE_COMMAND} -P
${CMAKE_CURRENT_SOURCE_DIR}/version.cmake)
##################################################################
##################################################################
execute_process(COMMAND git log --pretty=format:'%h' -n 1
OUTPUT_VARIABLE GIT_REV
ERROR_QUIET)
string(TIMESTAMP BUILD_TIME "%Y-%m-%d %H:%M")
# Check whether we got any revision (which isn't
# always the case, e.g. when someone downloaded a zip
# file from Github instead of a checkout)
if ("${GIT_REV}" STREQUAL "")
set(GIT_REV "N/A")
set(GIT_DIFF "")
set(GIT_TAG "N/A")
set(GIT_BRANCH "N/A")
else()
execute_process(
COMMAND bash -c "git diff --quiet --exit-code || echo +"
OUTPUT_VARIABLE GIT_DIFF)
execute_process(
COMMAND git describe --exact-match --tags
OUTPUT_VARIABLE GIT_TAG ERROR_QUIET)
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
OUTPUT_VARIABLE GIT_BRANCH)
string(STRIP "${GIT_REV}" GIT_REV)
string(SUBSTRING "${GIT_REV}" 1 7 GIT_REV)
string(STRIP "${GIT_DIFF}" GIT_DIFF)
string(STRIP "${GIT_TAG}" GIT_TAG)
string(STRIP "${GIT_BRANCH}" GIT_BRANCH)
endif()
set(VERSION "const char* GIT_REV=\"${GIT_REV}${GIT_DIFF}\";
const char* GIT_TAG=\"${GIT_TAG}\";
const char* GIT_BRANCH=\"${GIT_BRANCH}\";
const char* BUILD_TIME=\"${BUILD_TIME}\";")
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp)
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp VERSION_)
else()
set(VERSION_ "")
endif()
if (NOT "${VERSION}" STREQUAL "${VERSION_}")
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp "${VERSION}")
endif()
#######################################################################
#######################################################################
FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/src/*.*)
# idf_component_register(SRCS ${app_sources})

24
code/src/gitversion.cmake Normal file
View File

@@ -0,0 +1,24 @@
# cmake/gitversion.cmake
cmake_minimum_required(VERSION 3.0.0)
message(STATUS "Resolving GIT Version")
set(_build_version "unknown")
find_package(Git)
if(GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
WORKING_DIRECTORY "${local_dir}"
OUTPUT_VARIABLE _build_version
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message( STATUS "GIT hash: ${_build_version}")
else()
message(STATUS "GIT not found")
endif()
string(TIMESTAMP _time_stamp)
configure_file(${local_dir}/cmake/gitversion.h.in ${output_dir}/gitversion.h @ONLY)

View File

@@ -107,31 +107,31 @@ extern "C" void app_main()
{
printf("Do Reset Camera\n");
PowerResetCamera();
// LogFile.WriteToFile("Startsequence 01");
Init_NVS_SDCard();
LogFile.WriteToFile("Startsequence 02");
// LogFile.WriteToFile("Startsequence 02");
CheckOTAUpdate();
LogFile.WriteToFile("Startsequence 03");
// LogFile.WriteToFile("Startsequence 03");
std::string ssid = "";
std::string password = "";
std::string hostname = "";
LoadWlanFromFile("/sdcard/wlan.ini", ssid, password, hostname);
LogFile.WriteToFile("Startsequence 04");
// 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());
initialise_wifi(ssid, password, hostname);
LogFile.WriteToFile("Startsequence 05");
// LogFile.WriteToFile("Startsequence 05");
TickType_t xDelay;
xDelay = 2000 / portTICK_PERIOD_MS;
printf("Autoflow: sleep for : %ldms\n", (long) xDelay);
LogFile.WriteToFile("Startsequence 06");
// LogFile.WriteToFile("Startsequence 06");
vTaskDelay( xDelay );
LogFile.WriteToFile("Startsequence 07");
// LogFile.WriteToFile("Startsequence 07");
setup_time();
LogFile.WriteToFile("======================== Main Started ================================");
LogFile.SwitchOnOff(false);
std::string zw = gettimestring("%Y%m%d-%H%M%S");
printf("time %s\n", zw.c_str());

View File

@@ -3,9 +3,12 @@
#include <string>
#include "server_help.h"
#include "ClassLogFile.h"
#include "time_sntp.h"
#include "version.h"
httpd_handle_t server = NULL;
@@ -14,80 +17,73 @@ std::string starttime = "";
/* An HTTP GET handler */
esp_err_t hello_get_handler(httpd_req_t *req)
esp_err_t info_get_handler(httpd_req_t *req)
{
char* buf;
size_t buf_len;
printf("req uri:\n");
printf(req->uri);
printf("\n");
LogFile.WriteToFile("info_get_handler");
char _query[200];
char _valuechar[30];
std::string _task;
/* Get header value string length and allocate memory for length + 1,
* extra byte for null termination */
buf_len = httpd_req_get_hdr_value_len(req, "Host") + 1;
if (buf_len > 1) {
buf = (char*) malloc(buf_len);
/* Copy null terminated value string into buffer */
if (httpd_req_get_hdr_value_str(req, "Host", buf, buf_len) == ESP_OK) {
ESP_LOGI(TAG, "Found header => Host: %s", buf);
if (httpd_req_get_url_query_str(req, _query, 200) == ESP_OK)
{
printf("Query: "); printf(_query); printf("\n");
if (httpd_query_key_value(_query, "type", _valuechar, 30) == ESP_OK)
{
printf("type is found"); printf(_valuechar); printf("\n");
_task = std::string(_valuechar);
}
free(buf);
};
if (_task.compare("GitBranch") == 0)
{
std::string zw;
zw = std::string(libfive_git_branch());
httpd_resp_sendstr_chunk(req, zw.c_str());
httpd_resp_sendstr_chunk(req, NULL);
return ESP_OK;
}
buf_len = httpd_req_get_hdr_value_len(req, "Test-Header-2") + 1;
if (buf_len > 1) {
buf = (char*) malloc(buf_len);
if (httpd_req_get_hdr_value_str(req, "Test-Header-2", buf, buf_len) == ESP_OK) {
ESP_LOGI(TAG, "Found header => Test-Header-2: %s", buf);
}
free(buf);
if (_task.compare("GitTag") == 0)
{
std::string zw;
zw = std::string(libfive_git_version());
httpd_resp_sendstr_chunk(req, zw.c_str());
httpd_resp_sendstr_chunk(req, NULL);
return ESP_OK;
}
buf_len = httpd_req_get_hdr_value_len(req, "Test-Header-1") + 1;
if (buf_len > 1) {
buf = (char*) malloc(buf_len);
if (httpd_req_get_hdr_value_str(req, "Test-Header-1", buf, buf_len) == ESP_OK) {
ESP_LOGI(TAG, "Found header => Test-Header-1: %s", buf);
}
free(buf);
if (_task.compare("GitRevision") == 0)
{
std::string zw;
zw = std::string(libfive_git_revision());
httpd_resp_sendstr_chunk(req, zw.c_str());
httpd_resp_sendstr_chunk(req, NULL);
return ESP_OK;
}
/* Read URL query string length and allocate memory for length + 1,
* extra byte for null termination */
buf_len = httpd_req_get_url_query_len(req) + 1;
if (buf_len > 1) {
buf = (char*) malloc(buf_len);
if (httpd_req_get_url_query_str(req, buf, buf_len) == ESP_OK) {
ESP_LOGI(TAG, "Found URL query => %s", buf);
char param[32];
/* Get value of expected key from query string */
if (httpd_query_key_value(buf, "query1", param, sizeof(param)) == ESP_OK) {
ESP_LOGI(TAG, "Found URL query parameter => query1=%s", param);
}
if (httpd_query_key_value(buf, "query3", param, sizeof(param)) == ESP_OK) {
ESP_LOGI(TAG, "Found URL query parameter => query3=%s", param);
}
if (httpd_query_key_value(buf, "query2", param, sizeof(param)) == ESP_OK) {
ESP_LOGI(TAG, "Found URL query parameter => query2=%s", param);
}
}
free(buf);
if (_task.compare("BuildTime") == 0)
{
std::string zw;
zw = std::string(build_time());
httpd_resp_sendstr_chunk(req, zw.c_str());
httpd_resp_sendstr_chunk(req, NULL);
return ESP_OK;
}
/* Set some custom headers */
httpd_resp_set_hdr(req, "Custom-Header-1", "Custom-Value-1");
httpd_resp_set_hdr(req, "Custom-Header-2", "Custom-Value-2");
/* Send response with custom headers and body set as the
* string passed in user context*/
const char* resp_str = (const char*) req->user_ctx;
httpd_resp_send(req, resp_str, strlen(resp_str));
/* After sending the HTTP response the old HTTP request
* headers are lost. Check if HTTP request headers can be read now. */
if (httpd_req_get_hdr_value_len(req, "Host") == 0) {
ESP_LOGI(TAG, "Request headers lost");
if (_task.compare("GitBaseBranch") == 0)
{
std::string zw;
zw = std::string(git_base_branch());
httpd_resp_sendstr_chunk(req, zw.c_str());
httpd_resp_sendstr_chunk(req, NULL);
return ESP_OK;
}
return ESP_OK;
}
@@ -205,6 +201,15 @@ esp_err_t img_tmp_handler(httpd_req_t *req)
void register_server_main_uri(httpd_handle_t server, const char *base_path)
{
httpd_uri_t info_get_handle = {
.uri = "/version", // Match all URIs of type /path/to/file
.method = HTTP_GET,
.handler = info_get_handler,
.user_ctx = (void*) base_path // Pass server data as context
};
httpd_register_uri_handler(server, &info_get_handle);
httpd_uri_t starttime_tmp_handle = {
.uri = "/starttime", // Match all URIs of type /path/to/file
.method = HTTP_GET,
@@ -260,14 +265,6 @@ httpd_handle_t start_webserver(void)
// config.uri_match_fn = NULL;
config.uri_match_fn = httpd_uri_match_wildcard;
httpd_uri_t hll = {};
hll.uri = "/hello";
hll.method = HTTP_GET;
hll.handler = hello_get_handler;
hll.user_ctx = (void*) "Hello World!";
starttime = gettimestring("%Y%m%d-%H%M%S");
// Start the httpd server
@@ -275,7 +272,6 @@ httpd_handle_t start_webserver(void)
if (httpd_start(&server, &config) == ESP_OK) {
// Set URI handlers
ESP_LOGI(TAG, "Registering URI handlers");
httpd_register_uri_handler(server, &hll);
return server;
}

View File

@@ -468,7 +468,7 @@ void task_autodoFlow(void *pvParameter)
LogFile.WriteToFile("task_autodoFlow - round done");
//CPU Temp
float cputmp = temperatureRead();
LogFile.WriteToFile("CPU Temperature: %.2f", cputmp);
// LogFile.WriteToFile("CPU Temperature: %.2f", cputmp);
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;

View File

@@ -1,43 +0,0 @@
execute_process(COMMAND git log --pretty=format:'%h' -n 1
OUTPUT_VARIABLE GIT_REV
ERROR_QUIET)
# Check whether we got any revision (which isn't
# always the case, e.g. when someone downloaded a zip
# file from Github instead of a checkout)
if ("${GIT_REV}" STREQUAL "")
set(GIT_REV "N/A")
set(GIT_DIFF "")
set(GIT_TAG "N/A")
set(GIT_BRANCH "N/A")
else()
execute_process(
COMMAND bash -c "git diff --quiet --exit-code || echo +"
OUTPUT_VARIABLE GIT_DIFF)
execute_process(
COMMAND git describe --exact-match --tags
OUTPUT_VARIABLE GIT_TAG ERROR_QUIET)
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
OUTPUT_VARIABLE GIT_BRANCH)
string(STRIP "${GIT_REV}" GIT_REV)
string(SUBSTRING "${GIT_REV}" 1 7 GIT_REV)
string(STRIP "${GIT_DIFF}" GIT_DIFF)
string(STRIP "${GIT_TAG}" GIT_TAG)
string(STRIP "${GIT_BRANCH}" GIT_BRANCH)
endif()
set(VERSION "const char* GIT_REV=\"${GIT_REV}${GIT_DIFF}\";
const char* GIT_TAG=\"${GIT_TAG}\";
const char* GIT_BRANCH=\"${GIT_BRANCH}\";")
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp)
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp VERSION_)
else()
set(VERSION_ "")
endif()
if (NOT "${VERSION}" STREQUAL "${VERSION_}")
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp "${VERSION}")
endif()

4
code/src/version.cpp Normal file
View File

@@ -0,0 +1,4 @@
const char* GIT_REV="bafd67b";
const char* GIT_TAG="";
const char* GIT_BRANCH="master";
const char* BUILD_TIME="2020-09-28 19:57";

38
code/src/version.h Normal file
View File

@@ -0,0 +1,38 @@
// These variables are autogenerated and compiled
// into the library by the version.cmake script
extern "C"
{
extern const char* GIT_TAG;
extern const char* GIT_REV;
extern const char* GIT_BRANCH;
extern const char* BUILD_TIME;
}
const char* GIT_BASE_BRANCH = "master - v2.1.1 - 2020-09-28";
const char* git_base_branch(void)
{
return GIT_BASE_BRANCH;
}
const char* build_time(void)
{
return BUILD_TIME;
}
const char* libfive_git_version(void)
{
return GIT_TAG;
}
const char* libfive_git_revision(void)
{
return GIT_REV;
}
const char* libfive_git_branch(void)
{
return GIT_BRANCH;
}

4
code/version.cpp Normal file
View File

@@ -0,0 +1,4 @@
const char* GIT_REV="bafd67b";
const char* GIT_TAG="";
const char* GIT_BRANCH="master";
const char* BUILD_TIME="2020-09-28 19:57";

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -11,9 +11,9 @@ InitalRotate=180
SearchFieldX = 20
SearchFieldY = 20
[Digits]
;Model=/config/dig0622.tfl
Model=/config/dig0630s3.tflite
Model=/config/dig0640s3.tflite
LogImageLocation = /log/digit
ModelInputSize 20, 32
digit1, 306, 120, 37, 67
@@ -21,7 +21,6 @@ digit2, 355, 120, 37, 67
digit3, 404, 120, 37, 67
[Analog]
;Model=/config/ana0622.tfl
Model=/config/ana0630s2.tflite
LogImageLocation = /log/analog
ModelInputSize 32, 32
@@ -37,11 +36,14 @@ PreValueAgeStartup = 30
AllowNegativeRates = False
MaxRateValue = 0.1
ErrorMessage = True
CheckDigitIncreaseConsistency = True
CheckDigitIncreaseConsistency = False
[AutoTimer]
AutoStart= True
Intervall = 4.85
[Debug]
Logfile = False
[Ende]

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -29,12 +29,15 @@ textarea {
<tr><td><h2>Config.ini:</h2></td></tr>
<tr>
<td colspan="3">
<textarea id="inputTextToSave" cols="117" rows="38"></textarea>
<textarea id="inputTextToSave" cols="100" rows="33"></textarea>
</td>
</tr>
<tr>
<td><button class="button" onclick="saveTextAsFile()">Update Config.ini</button></td>
</tr>
<td><button class="button" onclick="saveTextAsFile()">Update Config.ini</button></td>
</tr>
<tr>
<td><button class="button" id="reboot" type="button" onclick="doReboot()">Reboot to activate updates</button></td>
</tr>
</table>
<script type="text/javascript" src="./gethost.js"></script>
@@ -59,6 +62,17 @@ function saveTextAsFile()
FileSendContent(textToSave, "/config/config.ini", basepath);
}
}
function doReboot() {
if (confirm("Are you sure you want to reboot the ESP32?")) {
var stringota = "/reboot";
window.location = stringota;
window.location.href = stringota;
window.location.assign(stringota);
window.location.replace(stringota);
}
}
LoadConfigNeu();

View File

@@ -85,7 +85,7 @@ th, td {
<tr>
<td>x: <input type="number" name="refx" id="refx" step=1 onchange="valuemanualchanged()"></td>
<td>dx: <input type="number" name="refdx" id="refdx" step=1 onchange="valuemanualchangeddx()"></td>
<td rowspan="2"><label for="lockAR"> lock aspect ratio </label><input type="checkbox" id="lockAR" name="lockAR" value="1" onclick="changelockAR()" checked></td>
<td rowspan="2"><label for="lockAR"> Lock aspect ratio </label><input type="checkbox" id="lockAR" name="lockAR" value="1" onclick="changelockAR()" checked></td>
</tr>
<tr>
<td>y: <input type="number" name="refy" id="refy" step=1 onchange="valuemanualchanged()"></td>

View File

@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html>
<html style="width: fit-content">
<head>
<title>jomjol - AI on the edge</title>
<meta charset="utf-8">
@@ -85,13 +85,15 @@ li.dropdown {
<a href="index_configure.html">Edit Configuration</a>
</div>
</li>
<li><a href="#"onclick="document.getElementById('maincontent').src = '/wasserzaehler.html?full';">Watermeter</a></li>
<li><a href="#"onclick="document.getElementById('maincontent').src = '/wasserzaehler.html?full';">Recognition</a></li>
<li><a href="#"onclick="document.getElementById('maincontent').src = '/fileserver/';">File Server</a></li>
<li class="dropdown">
<a href="javascript:void(0)" class="dropbtn">System</a>
<div class="dropdown-content">
<a href="#"onclick="document.getElementById('maincontent').src = '/ota_page.html';">OTA Update</a>
<a href="#"onclick="document.getElementById('maincontent').src = '/fileserver/log.txt';">Log Viewer</a>
<a href="#"onclick="document.getElementById('maincontent').src = '/reboot_page.html';">Reboot</a>
<a href="#"onclick="document.getElementById('maincontent').src = '/info.html';">Info</a>
</div>
</ul>
<p>

79
sd-card/html/info.html Normal file
View File

@@ -0,0 +1,79 @@
<!DOCTYPE html>
<html>
<head>
<title>Set PreValue</title>
<meta charset="utf-8">
<style>
h1 {font-size: 2em;}
h2 {font-size: 1.5em;}
h3 {font-size: 1.2em;}
p {font-size: 1em;}
div {
width: 250px;
padding: 10px 5px;
border: 1px solid #ccc;
font-family: arial;
font-size: 16px;
max-height: 35px;
}
</style>
</head>
<body style="font-family: arial; padding: 0px 10px;">
<h3>Version Info</h3>
<table style="font-family: arial">
<tr>
<td>
Git-Branch:
</td>
<td>
<div id="gitbranch">
<object data="/version?type=GitBranch"></object>
</div>
</td>
</tr>
<tr>
<td>
Git-Base-Branch:
</td>
<td>
<div>
<object data="/version?type=GitBaseBranch"></object>
</div>
</td>
</tr>
<tr>
<td>
Git-Version:
</td>
<td>
<div>
<object data="/version?type=GitVersion"></object>
</div>
</td>
</tr>
<tr>
<td>
Build Time:
</td>
<td>
<div>
<object data="/version?type=BuildTime"></object>
</div>
</td>
</tr>
</table>
</body>
</html>

View File

@@ -8,7 +8,7 @@
.tg {border-collapse:collapse;border-spacing:0;width:100%;color: darkslategray;border: inset;height:585px;}
.tg td{font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;}
.tg th{height: 55px;font-size:24px;font-weight:bold;text-align:left;padding:0px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#f0f0f0}
.tg .tg-1{width:78%;font-size:20px;font-family:Arial, Helvetica, sans-serif !important;border: inset;}
.tg .tg-1{width:77%;font-size:20px;font-family:Arial, Helvetica, sans-serif !important;border: inset;}
.tg .tg-2{font-size:20px;font-family:Arial, Helvetica, sans-serif !important;border: inset;}
.tg .tg-3{height: 15px;font-size:14px;font-family:Arial, Helvetica, sans-serif !important;border: inset;}
</style>
@@ -31,7 +31,7 @@
var m = addZero(d.getMinutes());
var s = addZero(d.getSeconds());
$('#img').html('<img src="/img_tmp/alg_roi.jpg" style="width:740px;max-height:100%"></img>');
$('#img').html('<img src="/img_tmp/alg_roi.jpg" style="width:100%; max-height:555px;"></img>');
$("#raw").load("/wasserzaehler.html?rawvalue=true");
$("#corrected").load("/wasserzaehler.html");
$("#checked").load("/setPreValue.html");
@@ -49,7 +49,7 @@
var m = addZero(d.getMinutes());
var s = addZero(d.getSeconds());
// reassign the url to be like alg_roi.jpg?timestamp=456784512 based on timestamp
$('#img').html('<img src="/img_tmp/alg_roi.jpg?timestamp='+ timestamp +'" style="width:740px;max-height:100%"></img>');
$('#img').html('<img src="/img_tmp/alg_roi.jpg?timestamp='+ timestamp +'" style="width:100%; max-height:555px;"></img>');
$("#raw").load("/wasserzaehler.html?rawvalue=true");
$("#corrected").load("/wasserzaehler.html");
$("#checked").load("/setPreValue.html");