This commit is contained in:
jomjol
2021-01-01 10:13:00 +01:00
parent 9c8f64f602
commit c59826471c
28 changed files with 263 additions and 106 deletions

View File

@@ -16,6 +16,7 @@ A 3d-printable housing can be found here: https://www.thingiverse.com/thing:4571
## Donate ## Donate
------
If you would like to support the developer with a cup of coffee you can do that via [Paypal](https://www.paypal.com/donate?hosted_button_id=8TRSVYNYKDSWL). If you would like to support the developer with a cup of coffee you can do that via [Paypal](https://www.paypal.com/donate?hosted_button_id=8TRSVYNYKDSWL).
@@ -38,7 +39,11 @@ If you would like to support the developer with a cup of coffee you can do that
**General remark:** Beside the `firmware.bin`, typically also the content of `/html` needs to be updated! **General remark:** Beside the `firmware.bin`, typically also the content of `/html` needs to be updated!
##### Rolling - (2020-12-31) ##### Rolling - (2021-01-01)
* Increased stability (internal image handling)
2020-12-31
* Bug-Fixing: internal change of camera handling to avoid reboots * Bug-Fixing: internal change of camera handling to avoid reboots

View File

@@ -18,9 +18,13 @@
#include "Helper.h" #include "Helper.h"
#define DEBUG_DETAIL_ON
esp_err_t handler_switch_GPIO(httpd_req_t *req) esp_err_t handler_switch_GPIO(httpd_req_t *req)
{ {
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_switch_GPIO - Start"); #ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_switch_GPIO - Start");
#endif
LogFile.WriteToFile("handler_switch_GPIO"); LogFile.WriteToFile("handler_switch_GPIO");
char _query[200]; char _query[200];

View File

@@ -8,5 +8,3 @@ static const char *TAGPARTGPIO = "server_GPIO";
void register_server_GPIO_uri(httpd_handle_t server); void register_server_GPIO_uri(httpd_handle_t server);
extern bool debug_detail_heap;

View File

@@ -192,7 +192,7 @@ esp_err_t CCamera::CaptureToBasisImage(CImageBasis *_Image, int delay)
LEDOnOff(true); LEDOnOff(true);
#ifdef DEBUG_DETAIL_ON #ifdef DEBUG_DETAIL_ON
if (debug_detail_heap) LogFile.WriteHeapInfo("CCamera::CaptureToBasisImage - Start"); LogFile.WriteHeapInfo("CCamera::CaptureToBasisImage - Start");
#endif #endif
if (delay > 0) if (delay > 0)
@@ -203,7 +203,7 @@ esp_err_t CCamera::CaptureToBasisImage(CImageBasis *_Image, int delay)
} }
#ifdef DEBUG_DETAIL_ON #ifdef DEBUG_DETAIL_ON
if (debug_detail_heap) LogFile.WriteHeapInfo("CCamera::CaptureToBasisImage - After LightOn"); LogFile.WriteHeapInfo("CCamera::CaptureToBasisImage - After LightOn");
#endif #endif
camera_fb_t * fb = esp_camera_fb_get(); camera_fb_t * fb = esp_camera_fb_get();
@@ -220,7 +220,7 @@ esp_err_t CCamera::CaptureToBasisImage(CImageBasis *_Image, int delay)
esp_camera_fb_return(fb); esp_camera_fb_return(fb);
#ifdef DEBUG_DETAIL_ON #ifdef DEBUG_DETAIL_ON
if (debug_detail_heap) LogFile.WriteHeapInfo("CCamera::CaptureToBasisImage - After fb_get"); LogFile.WriteHeapInfo("CCamera::CaptureToBasisImage - After fb_get");
#endif #endif
LEDOnOff(false); LEDOnOff(false);
@@ -237,7 +237,9 @@ esp_err_t CCamera::CaptureToBasisImage(CImageBasis *_Image, int delay)
_zwImage.LoadFromMemory(zwischenspeicher, _size); _zwImage.LoadFromMemory(zwischenspeicher, _size);
free(zwischenspeicher); free(zwischenspeicher);
if (debug_detail_heap) LogFile.WriteHeapInfo("CCamera::CaptureToBasisImage - After LoadFromMemory"); #ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("CCamera::CaptureToBasisImage - After LoadFromMemory");
#endif
stbi_uc* p_target; stbi_uc* p_target;
stbi_uc* p_source; stbi_uc* p_source;
@@ -248,7 +250,7 @@ esp_err_t CCamera::CaptureToBasisImage(CImageBasis *_Image, int delay)
#ifdef DEBUG_DETAIL_ON #ifdef DEBUG_DETAIL_ON
std::string _zw = "Targetimage: " + std::to_string((int) _Image->rgb_image) + " Size: " + std::to_string(_Image->width) + ", " + std::to_string(_Image->height); std::string _zw = "Targetimage: " + std::to_string((int) _Image->rgb_image) + " Size: " + std::to_string(_Image->width) + ", " + std::to_string(_Image->height);
_zw = _zw + " _zwImage: " + std::to_string((int) _zwImage.rgb_image) + " Size: " + std::to_string(_zwImage.width) + ", " + std::to_string(_zwImage.height); _zw = _zw + " _zwImage: " + std::to_string((int) _zwImage.rgb_image) + " Size: " + std::to_string(_zwImage.width) + ", " + std::to_string(_zwImage.height);
if (debug_detail_heap) LogFile.WriteToFile(_zw); LogFile.WriteToFile(_zw);
#endif #endif
for (int x = 0; x < width; ++x) for (int x = 0; x < width; ++x)
@@ -262,13 +264,13 @@ esp_err_t CCamera::CaptureToBasisImage(CImageBasis *_Image, int delay)
} }
#ifdef DEBUG_DETAIL_ON #ifdef DEBUG_DETAIL_ON
if (debug_detail_heap) LogFile.WriteHeapInfo("CCamera::CaptureToBasisImage - After Copy To Target"); LogFile.WriteHeapInfo("CCamera::CaptureToBasisImage - After Copy To Target");
#endif #endif
free(buf); free(buf);
#ifdef DEBUG_DETAIL_ON #ifdef DEBUG_DETAIL_ON
if (debug_detail_heap) LogFile.WriteHeapInfo("CCamera::CaptureToBasisImage - Done"); LogFile.WriteHeapInfo("CCamera::CaptureToBasisImage - Done");
#endif #endif
return ESP_OK; return ESP_OK;
@@ -338,9 +340,7 @@ esp_err_t CCamera::CaptureToFile(std::string nm, int delay)
FILE * fp = OpenFileAndWait(nm.c_str(), "wb"); FILE * fp = OpenFileAndWait(nm.c_str(), "wb");
if (fp == NULL) /* If an error occurs during the file creation */ if (fp == NULL) /* If an error occurs during the file creation */
{ {
#ifdef DEBUG_DETAIL_ON
fprintf(stderr, "fopen() failed for '%s'\n", nm.c_str()); fprintf(stderr, "fopen() failed for '%s'\n", nm.c_str());
#endif
} }
else else
{ {

View File

@@ -45,6 +45,4 @@ class CCamera {
extern CCamera Camera; extern CCamera Camera;
extern bool debug_detail_heap;
#endif #endif

View File

@@ -11,7 +11,7 @@
#define SCRATCH_BUFSIZE2 8192 #define SCRATCH_BUFSIZE2 8192
char scratch2[SCRATCH_BUFSIZE2]; char scratch2[SCRATCH_BUFSIZE2];
// #define DEBUG_DETAIL_ON //#define DEBUG_DETAIL_ON
@@ -33,8 +33,7 @@ void PowerResetCamera(){
esp_err_t handler_lightOn(httpd_req_t *req) esp_err_t handler_lightOn(httpd_req_t *req)
{ {
#ifdef DEBUG_DETAIL_ON #ifdef DEBUG_DETAIL_ON
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_lightOn - Start"); LogFile.WriteHeapInfo("handler_lightOn - Start");
LogFile.WriteToFile("handler_lightOn");
printf("handler_lightOn uri:\n"); printf(req->uri); printf("\n"); printf("handler_lightOn uri:\n"); printf(req->uri); printf("\n");
#endif #endif
@@ -43,7 +42,7 @@ esp_err_t handler_lightOn(httpd_req_t *req)
httpd_resp_send(req, resp_str, strlen(resp_str)); httpd_resp_send(req, resp_str, strlen(resp_str));
#ifdef DEBUG_DETAIL_ON #ifdef DEBUG_DETAIL_ON
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_lightOn - Done"); LogFile.WriteHeapInfo("handler_lightOn - Done");
#endif #endif
return ESP_OK; return ESP_OK;
@@ -52,8 +51,7 @@ esp_err_t handler_lightOn(httpd_req_t *req)
esp_err_t handler_lightOff(httpd_req_t *req) esp_err_t handler_lightOff(httpd_req_t *req)
{ {
#ifdef DEBUG_DETAIL_ON #ifdef DEBUG_DETAIL_ON
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_lightOff - Start"); LogFile.WriteHeapInfo("handler_lightOff - Start");
LogFile.WriteToFile("handler_lightOff");
printf("handler_lightOff uri:\n"); printf(req->uri); printf("\n"); printf("handler_lightOff uri:\n"); printf(req->uri); printf("\n");
#endif #endif
Camera.LightOnOff(false); Camera.LightOnOff(false);
@@ -61,7 +59,7 @@ esp_err_t handler_lightOff(httpd_req_t *req)
httpd_resp_send(req, resp_str, strlen(resp_str)); httpd_resp_send(req, resp_str, strlen(resp_str));
#ifdef DEBUG_DETAIL_ON #ifdef DEBUG_DETAIL_ON
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_lightOff - Done"); LogFile.WriteHeapInfo("handler_lightOff - Done");
#endif #endif
return ESP_OK; return ESP_OK;
@@ -70,8 +68,7 @@ esp_err_t handler_lightOff(httpd_req_t *req)
esp_err_t handler_capture(httpd_req_t *req) esp_err_t handler_capture(httpd_req_t *req)
{ {
#ifdef DEBUG_DETAIL_ON #ifdef DEBUG_DETAIL_ON
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_capture - Start"); LogFile.WriteHeapInfo("handler_capture - Start");
LogFile.WriteToFile("handler_capture");
#endif #endif
int quality; int quality;
@@ -89,7 +86,7 @@ esp_err_t handler_capture(httpd_req_t *req)
ressult = Camera.CaptureToHTTP(req); ressult = Camera.CaptureToHTTP(req);
#ifdef DEBUG_DETAIL_ON #ifdef DEBUG_DETAIL_ON
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_capture - Done"); LogFile.WriteHeapInfo("handler_capture - Done");
#endif #endif
return ressult; return ressult;
@@ -98,7 +95,8 @@ esp_err_t handler_capture(httpd_req_t *req)
esp_err_t handler_capture_with_ligth(httpd_req_t *req) esp_err_t handler_capture_with_ligth(httpd_req_t *req)
{ {
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_capture_with_ligth - Start");
LogFile.WriteHeapInfo("handler_capture_with_ligth - Start");
LogFile.WriteToFile("handler_capture_with_ligth"); LogFile.WriteToFile("handler_capture_with_ligth");
char _query[100]; char _query[100];
@@ -140,7 +138,7 @@ esp_err_t handler_capture_with_ligth(httpd_req_t *req)
Camera.LightOnOff(false); Camera.LightOnOff(false);
#ifdef DEBUG_DETAIL_ON #ifdef DEBUG_DETAIL_ON
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_capture_with_ligth - Done"); LogFile.WriteHeapInfo("handler_capture_with_ligth - Done");
#endif #endif
return ressult; return ressult;
@@ -151,8 +149,7 @@ esp_err_t handler_capture_with_ligth(httpd_req_t *req)
esp_err_t handler_capture_save_to_file(httpd_req_t *req) esp_err_t handler_capture_save_to_file(httpd_req_t *req)
{ {
#ifdef DEBUG_DETAIL_ON #ifdef DEBUG_DETAIL_ON
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_capture_save_to_file - Start"); LogFile.WriteHeapInfo("handler_capture_save_to_file - Start");
LogFile.WriteToFile("handler_capture_save_to_file");
#endif #endif
char _query[100]; char _query[100];
@@ -206,7 +203,7 @@ esp_err_t handler_capture_save_to_file(httpd_req_t *req)
httpd_resp_send(req, resp_str, strlen(resp_str)); httpd_resp_send(req, resp_str, strlen(resp_str));
#ifdef DEBUG_DETAIL_ON #ifdef DEBUG_DETAIL_ON
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_capture_save_to_file - Done"); LogFile.WriteHeapInfo("handler_capture_save_to_file - Done");
#endif #endif
return ressult; return ressult;

View File

@@ -13,7 +13,4 @@ void register_server_camera_uri(httpd_handle_t server);
void PowerResetCamera(); void PowerResetCamera();
extern bool debug_detail_heap;
#endif #endif

View File

@@ -34,6 +34,8 @@
#include "Helper.h" #include "Helper.h"
// #define DEBUG_DETAIL_ON
#define BUFFSIZE 1024 #define BUFFSIZE 1024
#define HASH_LEN 32 /* SHA-256 digest length */ #define HASH_LEN 32 /* SHA-256 digest length */
@@ -303,7 +305,9 @@ void CheckOTAUpdate(void)
esp_err_t handler_ota_update(httpd_req_t *req) esp_err_t handler_ota_update(httpd_req_t *req)
{ {
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_ota_update - Start"); #ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_ota_update - Start");
#endif
LogFile.WriteToFile("handler_ota_update"); LogFile.WriteToFile("handler_ota_update");
char _query[200]; char _query[200];
@@ -381,7 +385,9 @@ esp_err_t handler_ota_update(httpd_req_t *req)
httpd_resp_send(req, resp_str, strlen(resp_str)); httpd_resp_send(req, resp_str, strlen(resp_str));
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_ota_update - Done"); #ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_ota_update - Done");
#endif
return ESP_OK; return ESP_OK;
}; };
@@ -418,7 +424,9 @@ void doReboot(){
esp_err_t handler_reboot(httpd_req_t *req) esp_err_t handler_reboot(httpd_req_t *req)
{ {
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_reboot - Start"); #ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_reboot - Start");
#endif
LogFile.WriteToFile("handler_reboot"); LogFile.WriteToFile("handler_reboot");
ESP_LOGI(TAGPARTOTA, "!!! System will restart within 5 sec!!!"); ESP_LOGI(TAGPARTOTA, "!!! System will restart within 5 sec!!!");
@@ -427,7 +435,10 @@ esp_err_t handler_reboot(httpd_req_t *req)
doReboot(); doReboot();
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_reboot - Done"); #ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_reboot - Done");
#endif
return ESP_OK; return ESP_OK;
} }

View File

@@ -10,4 +10,3 @@ void register_server_ota_sdcard_uri(httpd_handle_t server);
void CheckOTAUpdate(); void CheckOTAUpdate();
void doReboot(); void doReboot();
extern bool debug_detail_heap;

View File

@@ -11,6 +11,8 @@
#include "server_help.h" #include "server_help.h"
//#define DEBUG_DETAIL_ON
static const char* TAG = "flow_controll"; static const char* TAG = "flow_controll";
@@ -198,18 +200,20 @@ bool ClassFlowControll::doFlow(string time)
std::string zw_time; std::string zw_time;
int repeat = 0; int repeat = 0;
#ifdef DEBUG_DETAIL_ON
///////////////////////////////////////////////////// LogFile.WriteHeapInfo("ClassFlowAnalog::doFlow - Start");
if (debug_detail_heap) LogFile.WriteHeapInfo("ClassFlowAnalog::doFlow - Start"); #endif
/////////////////////////////////////////////////////////
for (int i = 0; i < FlowControll.size(); ++i) for (int i = 0; i < FlowControll.size(); ++i)
{ {
zw_time = gettimestring("%Y%m%d-%H%M%S"); zw_time = gettimestring("%Y%m%d-%H%M%S");
aktstatus = zw_time + ": " + FlowControll[i]->name(); aktstatus = zw_time + ": " + FlowControll[i]->name();
#ifdef DEBUG_DETAIL_ON
string zw = "FlowControll.doFlow - " + FlowControll[i]->name(); string zw = "FlowControll.doFlow - " + FlowControll[i]->name();
if (debug_detail_heap) LogFile.WriteHeapInfo(zw); LogFile.WriteHeapInfo(zw);
// LogFile.WriteToFile(zw); #endif
if (!FlowControll[i]->doFlow(time)){ if (!FlowControll[i]->doFlow(time)){
repeat++; repeat++;
LogFile.WriteToFile("Fehler im vorheriger Schritt - wird zum " + to_string(repeat) + ". Mal wiederholt"); LogFile.WriteToFile("Fehler im vorheriger Schritt - wird zum " + to_string(repeat) + ". Mal wiederholt");
@@ -225,8 +229,11 @@ bool ClassFlowControll::doFlow(string time)
{ {
result = true; result = true;
} }
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("ClassFlowAnalog::doFlow");
#endif
if (debug_detail_heap) LogFile.WriteHeapInfo("ClassFlowAnalog::doFlow");
} }
zw_time = gettimestring("%Y%m%d-%H%M%S"); zw_time = gettimestring("%Y%m%d-%H%M%S");
aktstatus = zw_time + ": Flow is done"; aktstatus = zw_time + ": Flow is done";

View File

@@ -56,5 +56,4 @@ public:
string name(){return "ClassFlowControll";}; string name(){return "ClassFlowControll";};
}; };
extern bool debug_detail_heap;

View File

@@ -7,6 +7,8 @@
#include <time.h> #include <time.h>
// #define DEBUG_DETAIL_ON
static const char* TAG = "flow_make_image"; static const char* TAG = "flow_make_image";
esp_err_t ClassFlowMakeImage::camera_capture(){ esp_err_t ClassFlowMakeImage::camera_capture(){
@@ -100,16 +102,23 @@ bool ClassFlowMakeImage::doFlow(string zwtime)
int flashdauer = (int) waitbeforepicture * 1000; int flashdauer = (int) waitbeforepicture * 1000;
if (debug_detail_heap) LogFile.WriteHeapInfo("ClassFlowMakeImage::doFlow - Before takePictureWithFlash"); #ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("ClassFlowMakeImage::doFlow - Before takePictureWithFlash");
#endif
takePictureWithFlash(flashdauer); takePictureWithFlash(flashdauer);
if (debug_detail_heap) LogFile.WriteHeapInfo("ClassFlowMakeImage::doFlow - After takePictureWithFlash"); #ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("ClassFlowMakeImage::doFlow - After takePictureWithFlash");
#endif
LogImage(logPath, "raw", NULL, NULL, zwtime, rawImage); LogImage(logPath, "raw", NULL, NULL, zwtime, rawImage);
RemoveOldLogs(); RemoveOldLogs();
if (debug_detail_heap) LogFile.WriteHeapInfo("ClassFlowMakeImage::doFlow - After RemoveOldLogs");
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("ClassFlowMakeImage::doFlow - After RemoveOldLogs");
#endif
return true; return true;
} }

View File

@@ -49,5 +49,3 @@ public:
}; };
extern bool debug_detail_heap;

View File

@@ -18,7 +18,9 @@ CAlignAndCutImage::CAlignAndCutImage(CImageBasis *_org, CImageBasis *_temp)
width = _org->width; width = _org->width;
height = _org->height; height = _org->height;
bpp = _org->bpp; bpp = _org->bpp;
externalImage = true; externalImage = true;
islocked = false;
ImageTMP = _temp; ImageTMP = _temp;
} }
@@ -110,6 +112,8 @@ void CAlignAndCutImage::CutAndSave(std::string _template1, int x1, int y1, int d
stbi_uc* p_target; stbi_uc* p_target;
stbi_uc* p_source; stbi_uc* p_source;
RGBImageLock();
for (int x = x1; x < x2; ++x) for (int x = x1; x < x2; ++x)
for (int y = y1; y < y2; ++y) for (int y = y1; y < y2; ++y)
{ {
@@ -122,6 +126,8 @@ void CAlignAndCutImage::CutAndSave(std::string _template1, int x1, int y1, int d
// stbi_write_jpg(_template1.c_str(), dx, dy, channels, odata, 0); // stbi_write_jpg(_template1.c_str(), dx, dy, channels, odata, 0);
stbi_write_bmp(_template1.c_str(), dx, dy, channels, odata); stbi_write_bmp(_template1.c_str(), dx, dy, channels, odata);
RGBImageRelease();
stbi_image_free(odata); stbi_image_free(odata);
} }
@@ -143,7 +149,8 @@ void CAlignAndCutImage::CutAndSave(int x1, int y1, int dx, int dy, CImageBasis *
return; return;
} }
uint8_t* odata = _target->rgb_image; uint8_t* odata = _target->RGBImageLock();
RGBImageLock();
stbi_uc* p_target; stbi_uc* p_target;
stbi_uc* p_source; stbi_uc* p_source;
@@ -156,6 +163,9 @@ void CAlignAndCutImage::CutAndSave(int x1, int y1, int dx, int dy, CImageBasis *
for (int _channels = 0; _channels < channels; ++_channels) for (int _channels = 0; _channels < channels; ++_channels)
p_target[_channels] = p_source[_channels]; p_target[_channels] = p_source[_channels];
} }
RGBImageRelease();
_target->RGBImageRelease();
} }
@@ -177,6 +187,8 @@ CImageBasis* CAlignAndCutImage::CutAndSave(int x1, int y1, int dx, int dy)
stbi_uc* p_target; stbi_uc* p_target;
stbi_uc* p_source; stbi_uc* p_source;
RGBImageLock();
for (int x = x1; x < x2; ++x) for (int x = x1; x < x2; ++x)
for (int y = y1; y < y2; ++y) for (int y = y1; y < y2; ++y)
{ {
@@ -187,6 +199,7 @@ CImageBasis* CAlignAndCutImage::CutAndSave(int x1, int y1, int dx, int dy)
} }
CImageBasis* rs = new CImageBasis(odata, channels, dx, dy, bpp); CImageBasis* rs = new CImageBasis(odata, channels, dx, dy, bpp);
RGBImageRelease();
rs->SetIndepended(); rs->SetIndepended();
return rs; return rs;
} }

View File

@@ -44,6 +44,8 @@ void CFindTemplate::FindTemplate(std::string _template, int* found_x, int* found
double aktSAD; double aktSAD;
double minSAD = pow(tpl_width * tpl_height * 255, 2); double minSAD = pow(tpl_width * tpl_height * 255, 2);
RGBImageLock();
for (int xouter = ow_start; xouter <= ow_stop; xouter++) for (int xouter = ow_start; xouter <= ow_stop; xouter++)
for (int youter = oh_start; youter <= oh_stop; ++youter) for (int youter = oh_start; youter <= oh_stop; ++youter)
{ {
@@ -66,6 +68,8 @@ void CFindTemplate::FindTemplate(std::string _template, int* found_x, int* found
} }
} }
RGBImageRelease();
stbi_write_bmp("sdcard\\find.bmp", ow, oh, channels, odata); stbi_write_bmp("sdcard\\find.bmp", ow, oh, channels, odata);
stbi_image_free(odata); stbi_image_free(odata);

View File

@@ -19,6 +19,43 @@ using namespace std;
static const char *TAG = "CImageBasis"; static const char *TAG = "CImageBasis";
//#define DEBUG_DETAIL_ON
uint8_t * CImageBasis::RGBImageLock(int _waitmaxsec)
{
if (islocked)
{
#ifdef DEBUG_DETAIL_ON
printf("Image is locked: sleep for : %ds\n", _waitmaxsec);
#endif
TickType_t xDelay;
xDelay = 1000 / portTICK_PERIOD_MS;
for (int i = 0; i <= _waitmaxsec; ++i)
{
vTaskDelay( xDelay );
if (!islocked)
break;
}
}
if (islocked)
return NULL;
return rgb_image;
}
void CImageBasis::RGBImageRelease()
{
islocked = false;
}
uint8_t * CImageBasis::RGBImageGet()
{
return rgb_image;
}
void writejpghelp(void *context, void *data, int size) void writejpghelp(void *context, void *data, int size)
@@ -42,7 +79,9 @@ ImageData* CImageBasis::writeToMemoryAsJPG(const int quality)
{ {
ImageData* ii = new ImageData; ImageData* ii = new ImageData;
RGBImageLock();
stbi_write_jpg_to_func(writejpghelp, ii, width, height, channels, rgb_image, quality); stbi_write_jpg_to_func(writejpghelp, ii, width, height, channels, rgb_image, quality);
RGBImageRelease();
return ii; return ii;
} }
@@ -83,7 +122,9 @@ esp_err_t CImageBasis::SendJPGtoHTTP(httpd_req_t *_req, const int quality)
ii.res = ESP_OK; ii.res = ESP_OK;
ii.size = 0; ii.size = 0;
RGBImageLock();
stbi_write_jpg_to_func(writejpgtohttphelp, &ii, width, height, channels, rgb_image, quality); stbi_write_jpg_to_func(writejpgtohttphelp, &ii, width, height, channels, rgb_image, quality);
RGBImageRelease();
if (ii.size > 0) if (ii.size > 0)
{ {
@@ -107,7 +148,10 @@ bool CImageBasis::CopyFromMemory(uint8_t* _source, int _size)
printf("Kann Bild nicht von Speicher kopierte - Größen passen nicht zusammen: soll %d, ist %d\n", _size, gr); printf("Kann Bild nicht von Speicher kopierte - Größen passen nicht zusammen: soll %d, ist %d\n", _size, gr);
return false; return false;
} }
RGBImageLock();
memCopy(_source, rgb_image, _size); memCopy(_source, rgb_image, _size);
RGBImageRelease();
return true; return true;
} }
@@ -145,6 +189,7 @@ void CImageBasis::setPixelColor(int x, int y, int r, int g, int b)
{ {
stbi_uc* p_source; stbi_uc* p_source;
RGBImageLock();
p_source = rgb_image + (channels * (y * width + x)); p_source = rgb_image + (channels * (y * width + x));
p_source[0] = r; p_source[0] = r;
if ( channels > 2) if ( channels > 2)
@@ -152,6 +197,7 @@ void CImageBasis::setPixelColor(int x, int y, int r, int g, int b)
p_source[1] = g; p_source[1] = g;
p_source[2] = b; p_source[2] = b;
} }
RGBImageRelease();
} }
void CImageBasis::drawRect(int x, int y, int dx, int dy, int r, int g, int b, int thickness) void CImageBasis::drawRect(int x, int y, int dx, int dy, int r, int g, int b, int thickness)
@@ -251,6 +297,7 @@ CImageBasis::CImageBasis()
width = 0; width = 0;
height = 0; height = 0;
channels = 0; channels = 0;
islocked = false;
} }
void CImageBasis::CreateEmptyImage(int _width, int _height, int _channels) void CImageBasis::CreateEmptyImage(int _width, int _height, int _channels)
@@ -260,6 +307,9 @@ void CImageBasis::CreateEmptyImage(int _width, int _height, int _channels)
height = _height; height = _height;
channels = _channels; channels = _channels;
RGBImageLock();
int memsize = width * height * channels; int memsize = width * height * channels;
rgb_image = (unsigned char*)GET_MEMORY(memsize); rgb_image = (unsigned char*)GET_MEMORY(memsize);
@@ -274,31 +324,38 @@ void CImageBasis::CreateEmptyImage(int _width, int _height, int _channels)
p_source[_channels] = (uint8_t) 0; p_source[_channels] = (uint8_t) 0;
} }
RGBImageRelease();
} }
void CImageBasis::LoadFromMemory(stbi_uc *_buffer, int len) void CImageBasis::LoadFromMemory(stbi_uc *_buffer, int len)
{ {
RGBImageLock();
if (rgb_image) if (rgb_image)
stbi_image_free(rgb_image); stbi_image_free(rgb_image);
rgb_image = stbi_load_from_memory(_buffer, len, &width, &height, &channels, 3); rgb_image = stbi_load_from_memory(_buffer, len, &width, &height, &channels, 3);
bpp = channels; bpp = channels;
printf("Image loaded from memory: %d, %d, %d\n", width, height, channels); printf("Image loaded from memory: %d, %d, %d\n", width, height, channels);
RGBImageRelease();
} }
CImageBasis::CImageBasis(CImageBasis *_copyfrom, int _anzrepeat) CImageBasis::CImageBasis(CImageBasis *_copyfrom, int _anzrepeat)
{ {
islocked = false;
externalImage = false; externalImage = false;
channels = _copyfrom->channels; channels = _copyfrom->channels;
width = _copyfrom->width; width = _copyfrom->width;
height = _copyfrom->height; height = _copyfrom->height;
bpp = _copyfrom->bpp; bpp = _copyfrom->bpp;
RGBImageLock();
int memsize = width * height * channels; int memsize = width * height * channels;
rgb_image = (unsigned char*)GET_MEMORY(memsize); rgb_image = (unsigned char*)GET_MEMORY(memsize);
int anz = 1;
TickType_t xDelay; TickType_t xDelay;
int anz = 1;
while (!rgb_image && (anz < _anzrepeat)) while (!rgb_image && (anz < _anzrepeat))
{ {
printf("Create Image from Copy - Speicher ist voll - Versuche es erneut: %d.\n", anz); printf("Create Image from Copy - Speicher ist voll - Versuche es erneut: %d.\n", anz);
@@ -312,14 +369,17 @@ CImageBasis::CImageBasis(CImageBasis *_copyfrom, int _anzrepeat)
{ {
printf(getESPHeapInfo().c_str()); printf(getESPHeapInfo().c_str());
printf("\nKein freier Speicher mehr!!!! Benötigt: %d %d %d %d\n", width, height, channels, memsize); printf("\nKein freier Speicher mehr!!!! Benötigt: %d %d %d %d\n", width, height, channels, memsize);
RGBImageRelease();
return; return;
} }
memCopy(_copyfrom->rgb_image, rgb_image, memsize); memCopy(_copyfrom->rgb_image, rgb_image, memsize);
RGBImageRelease();
} }
CImageBasis::CImageBasis(int _width, int _height, int _channels) CImageBasis::CImageBasis(int _width, int _height, int _channels)
{ {
islocked = false;
externalImage = false; externalImage = false;
channels = _channels; channels = _channels;
width = _width; width = _width;
@@ -327,6 +387,7 @@ CImageBasis::CImageBasis(int _width, int _height, int _channels)
bpp = _channels; bpp = _channels;
int memsize = width * height * channels; int memsize = width * height * channels;
rgb_image = (unsigned char*)GET_MEMORY(memsize); rgb_image = (unsigned char*)GET_MEMORY(memsize);
if (!rgb_image) if (!rgb_image)
{ {
@@ -339,13 +400,17 @@ CImageBasis::CImageBasis(int _width, int _height, int _channels)
CImageBasis::CImageBasis(std::string _image) CImageBasis::CImageBasis(std::string _image)
{ {
islocked = false;
channels = 3; channels = 3;
externalImage = false; externalImage = false;
filename = _image; filename = _image;
long zwld = esp_get_free_heap_size(); long zwld = esp_get_free_heap_size();
printf("freeheapsize before: %ld\n", zwld); printf("freeheapsize before: %ld\n", zwld);
RGBImageLock();
rgb_image = stbi_load(_image.c_str(), &width, &height, &bpp, channels); rgb_image = stbi_load(_image.c_str(), &width, &height, &bpp, channels);
RGBImageRelease();
zwld = esp_get_free_heap_size(); zwld = esp_get_free_heap_size();
printf("freeheapsize after : %ld\n", zwld); printf("freeheapsize after : %ld\n", zwld);
@@ -355,6 +420,7 @@ CImageBasis::CImageBasis(std::string _image)
zw = "CImageBasis after load " + _image + "\n"; zw = "CImageBasis after load " + _image + "\n";
printf(zw.c_str()); printf(zw.c_str());
printf("w %d, h %d, b %d, c %d\n", width, height, bpp, channels); printf("w %d, h %d, b %d, c %d\n", width, height, bpp, channels);
} }
bool CImageBasis::ImageOkay(){ bool CImageBasis::ImageOkay(){
@@ -363,6 +429,7 @@ bool CImageBasis::ImageOkay(){
CImageBasis::CImageBasis(uint8_t* _rgb_image, int _channels, int _width, int _height, int _bpp) CImageBasis::CImageBasis(uint8_t* _rgb_image, int _channels, int _width, int _height, int _bpp)
{ {
islocked = false;
rgb_image = _rgb_image; rgb_image = _rgb_image;
channels = _channels; channels = _channels;
width = _width; width = _width;
@@ -378,6 +445,9 @@ void CImageBasis::Contrast(float _contrast) //input range [-100..100]
float contrast = (_contrast/100) + 1; //convert to decimal & shift range: [0..2] float contrast = (_contrast/100) + 1; //convert to decimal & shift range: [0..2]
float intercept = 128 * (1 - contrast); float intercept = 128 * (1 - contrast);
RGBImageLock();
for (int x = 0; x < width; ++x) for (int x = 0; x < width; ++x)
for (int y = 0; y < height; ++y) for (int y = 0; y < height; ++y)
{ {
@@ -385,10 +455,13 @@ void CImageBasis::Contrast(float _contrast) //input range [-100..100]
for (int _channels = 0; _channels < channels; ++_channels) for (int _channels = 0; _channels < channels; ++_channels)
p_source[_channels] = (uint8_t) std::min(255, std::max(0, (int) (p_source[_channels] * contrast + intercept))); p_source[_channels] = (uint8_t) std::min(255, std::max(0, (int) (p_source[_channels] * contrast + intercept)));
} }
RGBImageRelease();
} }
CImageBasis::~CImageBasis() CImageBasis::~CImageBasis()
{ {
RGBImageLock();
if (!externalImage) if (!externalImage)
stbi_image_free(rgb_image); stbi_image_free(rgb_image);
} }
@@ -397,6 +470,8 @@ void CImageBasis::SaveToFile(std::string _imageout)
{ {
string typ = getFileType(_imageout); string typ = getFileType(_imageout);
RGBImageLock();
if ((typ == "jpg") || (typ == "JPG")) // ACHTUNG PROBLEMATISCH IM ESP32 if ((typ == "jpg") || (typ == "JPG")) // ACHTUNG PROBLEMATISCH IM ESP32
{ {
stbi_write_jpg(_imageout.c_str(), width, height, channels, rgb_image, 0); stbi_write_jpg(_imageout.c_str(), width, height, channels, rgb_image, 0);
@@ -406,6 +481,7 @@ void CImageBasis::SaveToFile(std::string _imageout)
{ {
stbi_write_bmp(_imageout.c_str(), width, height, channels, rgb_image); stbi_write_bmp(_imageout.c_str(), width, height, channels, rgb_image);
} }
RGBImageRelease();
} }
@@ -414,12 +490,17 @@ void CImageBasis::Resize(int _new_dx, int _new_dy)
int memsize = _new_dx * _new_dy * channels; int memsize = _new_dx * _new_dy * channels;
uint8_t* odata = (unsigned char*)GET_MEMORY(memsize); uint8_t* odata = (unsigned char*)GET_MEMORY(memsize);
RGBImageLock();
stbir_resize_uint8(rgb_image, width, height, 0, odata, _new_dx, _new_dy, 0, channels); stbir_resize_uint8(rgb_image, width, height, 0, odata, _new_dx, _new_dy, 0, channels);
stbi_image_free(rgb_image); stbi_image_free(rgb_image);
rgb_image = (unsigned char*)GET_MEMORY(memsize); rgb_image = (unsigned char*)GET_MEMORY(memsize);
memCopy(odata, rgb_image, memsize); memCopy(odata, rgb_image, memsize);
RGBImageRelease();
width = _new_dx; width = _new_dx;
height = _new_dy; height = _new_dy;
stbi_image_free(odata); stbi_image_free(odata);
@@ -433,7 +514,10 @@ void CImageBasis::Resize(int _new_dx, int _new_dy, CImageBasis *_target)
return; return;
} }
RGBImageLock();
uint8_t* odata = _target->rgb_image; uint8_t* odata = _target->rgb_image;
stbir_resize_uint8(rgb_image, width, height, 0, odata, _new_dx, _new_dy, 0, channels); stbir_resize_uint8(rgb_image, width, height, 0, odata, _new_dx, _new_dy, 0, channels);
RGBImageRelease();
} }

View File

@@ -40,11 +40,17 @@ class CImageBasis
void memCopy(uint8_t* _source, uint8_t* _target, int _size); void memCopy(uint8_t* _source, uint8_t* _target, int _size);
bool isInImage(int x, int y); bool isInImage(int x, int y);
bool islocked;
public: public:
uint8_t* rgb_image; uint8_t* rgb_image;
int channels; int channels;
int width, height, bpp; int width, height, bpp;
uint8_t * RGBImageLock(int _waitmaxsec = 60);
void RGBImageRelease();
uint8_t * RGBImageGet();
int getWidth(){return this->width;}; int getWidth(){return this->width;};
int getHeight(){return this->height;}; int getHeight(){return this->height;};
int getChannels(){return this->channels;}; int getChannels(){return this->channels;};

View File

@@ -10,6 +10,7 @@ CRotateImage::CRotateImage(CImageBasis *_org, CImageBasis *_temp)
bpp = _org->bpp; bpp = _org->bpp;
externalImage = true; externalImage = true;
ImageTMP = _temp; ImageTMP = _temp;
islocked = false;
} }
void CRotateImage::Mirror(){ void CRotateImage::Mirror(){
@@ -17,7 +18,7 @@ void CRotateImage::Mirror(){
uint8_t* odata; uint8_t* odata;
if (ImageTMP) if (ImageTMP)
{ {
odata = ImageTMP->rgb_image; odata = ImageTMP->RGBImageLock();
} }
else else
{ {
@@ -29,6 +30,8 @@ void CRotateImage::Mirror(){
stbi_uc* p_target; stbi_uc* p_target;
stbi_uc* p_source; stbi_uc* p_source;
RGBImageLock();
for (int x = 0; x < width; ++x) for (int x = 0; x < width; ++x)
for (int y = 0; y < height; ++y) for (int y = 0; y < height; ++y)
{ {
@@ -45,9 +48,12 @@ void CRotateImage::Mirror(){
// memcpy(rgb_image, odata, memsize); // memcpy(rgb_image, odata, memsize);
memCopy(odata, rgb_image, memsize); memCopy(odata, rgb_image, memsize);
if (!ImageTMP) if (!ImageTMP)
{
stbi_image_free(odata); stbi_image_free(odata);
}
if (ImageTMP)
ImageTMP->RGBImageRelease();
RGBImageRelease();
} }
void CRotateImage::Rotate(float _angle, int _centerx, int _centery) void CRotateImage::Rotate(float _angle, int _centerx, int _centery)
@@ -70,7 +76,7 @@ void CRotateImage::Rotate(float _angle, int _centerx, int _centery)
uint8_t* odata; uint8_t* odata;
if (ImageTMP) if (ImageTMP)
{ {
odata = ImageTMP->rgb_image; odata = ImageTMP->RGBImageLock();
} }
else else
{ {
@@ -82,6 +88,8 @@ void CRotateImage::Rotate(float _angle, int _centerx, int _centery)
stbi_uc* p_target; stbi_uc* p_target;
stbi_uc* p_source; stbi_uc* p_source;
RGBImageLock();
for (int x = 0; x < width; ++x) for (int x = 0; x < width; ++x)
for (int y = 0; y < height; ++y) for (int y = 0; y < height; ++y)
{ {
@@ -113,6 +121,10 @@ void CRotateImage::Rotate(float _angle, int _centerx, int _centery)
{ {
stbi_image_free(odata); stbi_image_free(odata);
} }
if (ImageTMP)
ImageTMP->RGBImageRelease();
RGBImageRelease();
} }
void CRotateImage::Rotate(float _angle) void CRotateImage::Rotate(float _angle)
@@ -127,7 +139,7 @@ void CRotateImage::Translate(int _dx, int _dy)
uint8_t* odata; uint8_t* odata;
if (ImageTMP) if (ImageTMP)
{ {
odata = ImageTMP->rgb_image; odata = ImageTMP->RGBImageLock();
} }
else else
{ {
@@ -140,6 +152,8 @@ void CRotateImage::Translate(int _dx, int _dy)
stbi_uc* p_target; stbi_uc* p_target;
stbi_uc* p_source; stbi_uc* p_source;
RGBImageLock();
for (int x = 0; x < width; ++x) for (int x = 0; x < width; ++x)
for (int y = 0; y < height; ++y) for (int y = 0; y < height; ++y)
{ {
@@ -167,5 +181,12 @@ void CRotateImage::Translate(int _dx, int _dy)
{ {
stbi_image_free(odata); stbi_image_free(odata);
} }
if (ImageTMP)
{
ImageTMP->RGBImageRelease();
}
RGBImageRelease();
} }

View File

@@ -4,7 +4,7 @@
#include <sys/stat.h> #include <sys/stat.h>
//#define DEBUG_DETAIL_ON // #define DEBUG_DETAIL_ON
float CTfLiteClass::GetOutputValue(int nr) float CTfLiteClass::GetOutputValue(int nr)
{ {
@@ -175,10 +175,8 @@ unsigned char* CTfLiteClass::ReadFileToCharArray(std::string _fn)
if (size == -1) if (size == -1)
{ {
#ifdef DEBUG_DETAIL_ON printf("\nFile existiert nicht.\n");
printf("\nFile existiert nicht.\n"); return NULL;
#endif
return NULL;
} }
unsigned char *result = (unsigned char*) malloc(size); unsigned char *result = (unsigned char*) malloc(size);

View File

@@ -131,10 +131,8 @@ void blink_task_doFlow(void *pvParameter)
esp_err_t handler_init(httpd_req_t *req) esp_err_t handler_init(httpd_req_t *req)
{ {
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_init - Start");
#ifdef DEBUG_DETAIL_ON #ifdef DEBUG_DETAIL_ON
LogFile.WriteToFile("handler_init"); LogFile.WriteHeapInfo("handler_init - Start");
printf("handler_doinit uri:\n"); printf(req->uri); printf("\n"); printf("handler_doinit uri:\n"); printf(req->uri); printf("\n");
#endif #endif
@@ -149,7 +147,7 @@ esp_err_t handler_init(httpd_req_t *req)
httpd_resp_send_chunk(req, NULL, 0); httpd_resp_send_chunk(req, NULL, 0);
#ifdef DEBUG_DETAIL_ON #ifdef DEBUG_DETAIL_ON
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_init - Done"); LogFile.WriteHeapInfo("handler_init - Done");
#endif #endif
return ESP_OK; return ESP_OK;
@@ -158,8 +156,7 @@ esp_err_t handler_init(httpd_req_t *req)
esp_err_t handler_doflow(httpd_req_t *req) esp_err_t handler_doflow(httpd_req_t *req)
{ {
#ifdef DEBUG_DETAIL_ON #ifdef DEBUG_DETAIL_ON
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_doflow - Start"); LogFile.WriteHeapInfo("handler_doflow - Start");
LogFile.WriteToFile("handler_doflow");
#endif #endif
char* resp_str; char* resp_str;
@@ -182,7 +179,7 @@ esp_err_t handler_doflow(httpd_req_t *req)
httpd_resp_send_chunk(req, NULL, 0); httpd_resp_send_chunk(req, NULL, 0);
#ifdef DEBUG_DETAIL_ON #ifdef DEBUG_DETAIL_ON
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_doflow - Done"); LogFile.WriteHeapInfo("handler_doflow - Done");
#endif #endif
return ESP_OK; return ESP_OK;
@@ -194,8 +191,7 @@ esp_err_t handler_doflow(httpd_req_t *req)
esp_err_t handler_wasserzaehler(httpd_req_t *req) esp_err_t handler_wasserzaehler(httpd_req_t *req)
{ {
#ifdef DEBUG_DETAIL_ON #ifdef DEBUG_DETAIL_ON
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_wasserzaehler - Start"); LogFile.WriteHeapInfo("handler_wasserzaehler - Start");
LogFile.WriteToFile("handler_wasserzaehler");
#endif #endif
bool _rawValue = false; bool _rawValue = false;
@@ -283,7 +279,7 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req)
httpd_resp_sendstr_chunk(req, NULL); httpd_resp_sendstr_chunk(req, NULL);
#ifdef DEBUG_DETAIL_ON #ifdef DEBUG_DETAIL_ON
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_wasserzaehler - Done"); LogFile.WriteHeapInfo("handler_wasserzaehler - Done");
#endif #endif
return ESP_OK; return ESP_OK;
}; };
@@ -292,8 +288,7 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req)
esp_err_t handler_editflow(httpd_req_t *req) esp_err_t handler_editflow(httpd_req_t *req)
{ {
#ifdef DEBUG_DETAIL_ON #ifdef DEBUG_DETAIL_ON
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_editflow - Start"); LogFile.WriteHeapInfo("handler_editflow - Start");
LogFile.WriteToFile("handler_editflow");
#endif #endif
printf("handler_editflow uri: "); printf(req->uri); printf("\n"); printf("handler_editflow uri: "); printf(req->uri); printf("\n");
@@ -459,7 +454,7 @@ esp_err_t handler_editflow(httpd_req_t *req)
httpd_resp_sendstr_chunk(req, NULL); httpd_resp_sendstr_chunk(req, NULL);
#ifdef DEBUG_DETAIL_ON #ifdef DEBUG_DETAIL_ON
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_editflow - Done"); LogFile.WriteHeapInfo("handler_editflow - Done");
#endif #endif
return ESP_OK; return ESP_OK;
@@ -469,8 +464,7 @@ esp_err_t handler_editflow(httpd_req_t *req)
esp_err_t handler_prevalue(httpd_req_t *req) esp_err_t handler_prevalue(httpd_req_t *req)
{ {
#ifdef DEBUG_DETAIL_ON #ifdef DEBUG_DETAIL_ON
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_prevalue - Start"); LogFile.WriteHeapInfo("handler_prevalue - Start");
LogFile.WriteToFile("handler_prevalue");
#endif #endif
const char* resp_str; const char* resp_str;
@@ -504,7 +498,7 @@ esp_err_t handler_prevalue(httpd_req_t *req)
httpd_resp_send_chunk(req, NULL, 0); httpd_resp_send_chunk(req, NULL, 0);
#ifdef DEBUG_DETAIL_ON #ifdef DEBUG_DETAIL_ON
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_prevalue - Start"); LogFile.WriteHeapInfo("handler_prevalue - Start");
#endif #endif
return ESP_OK; return ESP_OK;

View File

@@ -18,5 +18,3 @@ bool isSetupModusActive();
esp_err_t GetJPG(std::string _filename, httpd_req_t *req); esp_err_t GetJPG(std::string _filename, httpd_req_t *req);
esp_err_t GetRawJPG(httpd_req_t *req); esp_err_t GetRawJPG(httpd_req_t *req);
extern bool debug_detail_heap;

View File

@@ -26,12 +26,8 @@
#include "server_main.h" #include "server_main.h"
#include "server_camera.h" #include "server_camera.h"
#include "server_GPIO.h" #include "server_GPIO.h"
static const char *TAGMAIN = "connect_wlan_main"; static const char *TAGMAIN = "connect_wlan_main";
bool debug_detail_heap = false;
#define FLASH_GPIO GPIO_NUM_4 #define FLASH_GPIO GPIO_NUM_4
void Init_NVS_SDCard() void Init_NVS_SDCard()
@@ -144,7 +140,6 @@ extern "C" void app_main(void)
register_server_tflite_uri(server); register_server_tflite_uri(server);
register_server_file_uri(server, "/sdcard"); register_server_file_uri(server, "/sdcard");
register_server_ota_sdcard_uri(server); register_server_ota_sdcard_uri(server);
register_server_GPIO_uri(server);
register_server_main_uri(server, "/sdcard"); register_server_main_uri(server, "/sdcard");
TFliteDoAutoStart(); TFliteDoAutoStart();

View File

@@ -15,6 +15,9 @@
#include "server_tflite.h" #include "server_tflite.h"
//#define DEBUG_DETAIL_ON
httpd_handle_t server = NULL; httpd_handle_t server = NULL;
@@ -24,7 +27,9 @@ std::string starttime = "";
/* An HTTP GET handler */ /* An HTTP GET handler */
esp_err_t info_get_handler(httpd_req_t *req) esp_err_t info_get_handler(httpd_req_t *req)
{ {
if (debug_detail_heap) LogFile.WriteHeapInfo("info_get_handler - Start"); #ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("info_get_handler - Start");
#endif
LogFile.WriteToFile("info_get_handler"); LogFile.WriteToFile("info_get_handler");
char _query[200]; char _query[200];
@@ -126,26 +131,35 @@ esp_err_t info_get_handler(httpd_req_t *req)
return ESP_OK; return ESP_OK;
} }
if (debug_detail_heap) LogFile.WriteHeapInfo("info_get_handler - Done"); #ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("info_get_handler - Done");
#endif
return ESP_OK; return ESP_OK;
} }
esp_err_t starttime_get_handler(httpd_req_t *req) esp_err_t starttime_get_handler(httpd_req_t *req)
{ {
if (debug_detail_heap) LogFile.WriteHeapInfo("starttime_get_handler - Start"); #ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("starttime_get_handler - Start");
#endif
httpd_resp_send(req, starttime.c_str(), strlen(starttime.c_str())); httpd_resp_send(req, starttime.c_str(), strlen(starttime.c_str()));
/* Respond with an empty chunk to signal HTTP response completion */ /* Respond with an empty chunk to signal HTTP response completion */
httpd_resp_send_chunk(req, NULL, 0); httpd_resp_send_chunk(req, NULL, 0);
if (debug_detail_heap) LogFile.WriteHeapInfo("starttime_get_handler - Done"); #ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("starttime_get_handler - Done");
#endif
return ESP_OK; return ESP_OK;
} }
esp_err_t hello_main_handler(httpd_req_t *req) esp_err_t hello_main_handler(httpd_req_t *req)
{ {
if (debug_detail_heap) LogFile.WriteHeapInfo("hello_main_handler - Start"); #ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("hello_main_handler - Start");
#endif
char filepath[50]; char filepath[50];
printf("uri: %s\n", req->uri); printf("uri: %s\n", req->uri);
@@ -197,7 +211,9 @@ esp_err_t hello_main_handler(httpd_req_t *req)
/* Respond with an empty chunk to signal HTTP response completion */ /* Respond with an empty chunk to signal HTTP response completion */
httpd_resp_send_chunk(req, NULL, 0); httpd_resp_send_chunk(req, NULL, 0);
if (debug_detail_heap) LogFile.WriteHeapInfo("hello_main_handler - Stop"); #ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("hello_main_handler - Stop");
#endif
return ESP_OK; return ESP_OK;
} }
@@ -228,7 +244,10 @@ esp_err_t img_tmp_handler(httpd_req_t *req)
esp_err_t img_tmp_virtual_handler(httpd_req_t *req) esp_err_t img_tmp_virtual_handler(httpd_req_t *req)
{ {
if (debug_detail_heap) LogFile.WriteHeapInfo("img_tmp_virtual_handler - Start"); #ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("img_tmp_virtual_handler - Start");
#endif
char filepath[50]; char filepath[50];
printf("uri: %s\n", req->uri); printf("uri: %s\n", req->uri);
@@ -254,7 +273,9 @@ esp_err_t img_tmp_virtual_handler(httpd_req_t *req)
return ESP_OK; return ESP_OK;
// File wird nicht intern bereit gestellt --> klassischer weg: // File wird nicht intern bereit gestellt --> klassischer weg:
if (debug_detail_heap) LogFile.WriteHeapInfo("img_tmp_virtual_handler - Done"); #ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("img_tmp_virtual_handler - Done");
#endif
return img_tmp_handler(req); return img_tmp_handler(req);
} }
@@ -265,7 +286,9 @@ esp_err_t img_tmp_virtual_handler(httpd_req_t *req)
esp_err_t sysinfo_handler(httpd_req_t *req) esp_err_t sysinfo_handler(httpd_req_t *req)
{ {
if (debug_detail_heap) LogFile.WriteHeapInfo("sysinfo_handler - Start"); #ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("sysinfo_handler - Start");
#endif
const char* resp_str; const char* resp_str;
std::string zw; std::string zw;
@@ -302,7 +325,9 @@ esp_err_t sysinfo_handler(httpd_req_t *req)
/* Respond with an empty chunk to signal HTTP response completion */ /* Respond with an empty chunk to signal HTTP response completion */
httpd_resp_send_chunk(req, NULL, 0); httpd_resp_send_chunk(req, NULL, 0);
if (debug_detail_heap) LogFile.WriteHeapInfo("sysinfo_handler - Done"); #ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("sysinfo_handler - Done");
#endif
return ESP_OK; return ESP_OK;
} }

View File

@@ -22,7 +22,4 @@ httpd_handle_t start_webserver(void);
void register_server_main_uri(httpd_handle_t server, const char *base_path); void register_server_main_uri(httpd_handle_t server, const char *base_path);
extern bool debug_detail_heap;
#endif #endif

View File

@@ -1,4 +1,4 @@
const char* GIT_REV="ae11698"; const char* GIT_REV="9c8f64f";
const char* GIT_TAG=""; const char* GIT_TAG="";
const char* GIT_BRANCH="rolling"; const char* GIT_BRANCH="rolling-update-cimage";
const char* BUILD_TIME="2020-12-31 11:13"; const char* BUILD_TIME="2021-01-01 09:32";

View File

@@ -1,4 +1,4 @@
const char* GIT_REV="ae11698"; const char* GIT_REV="9c8f64f";
const char* GIT_TAG=""; const char* GIT_TAG="";
const char* GIT_BRANCH="rolling"; const char* GIT_BRANCH="rolling-update-cimage";
const char* BUILD_TIME="2020-12-31 11:13"; const char* BUILD_TIME="2021-01-01 09:32";

Binary file not shown.

Binary file not shown.