diff --git a/README.md b/README.md index aabf5733..f08816a1 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,21 @@ In other cases you can contact the developer via email: -100) _contrast = min(2, max(-2, _contrast)); -// _saturation = min(2, max(-2, _saturation)); + if (_saturation > -100) + _saturation = min(2, max(-2, _saturation)); -// s->set_saturation(s, _saturation); + if (_saturation > -100) + s->set_saturation(s, _saturation); if (_contrast > -100) s->set_contrast(s, _contrast); if (_brightness > -100) @@ -521,15 +547,31 @@ void CCamera::LightOnOff(bool status) printf("Use gpioHandler flashLigh\n"); gpioHandler->flashLightEnable(status); } else { + #ifdef USE_PWM_LEDFLASH + if (status) + { + printf("Internal Flash-LED turn on with PWMy\n"); + ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LEDC_CHANNEL, led_intensity)); + // Update duty to apply the new value + ESP_ERROR_CHECK(ledc_update_duty(LEDC_MODE, LEDC_CHANNEL)); + } + else + { + printf("Internal Flash-LED turn off PWM\n"); + ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LEDC_CHANNEL, 0)); + ESP_ERROR_CHECK(ledc_update_duty(LEDC_MODE, LEDC_CHANNEL)); + } + #else // Init the GPIO gpio_pad_select_gpio(FLASH_GPIO); - /* Set the GPIO as a push/pull output */ + // Set the GPIO as a push/pull output gpio_set_direction(FLASH_GPIO, GPIO_MODE_OUTPUT); if (status) gpio_set_level(FLASH_GPIO, 1); else gpio_set_level(FLASH_GPIO, 0); + #endif } } @@ -620,20 +662,12 @@ CCamera::CCamera() contrast = -5; saturation = -5; isFixedExposure = false; + + ledc_init(); } esp_err_t CCamera::InitCam() { -/* - if( CAM_PIN_PWDN != -1){ - // Init the GPIO - gpio_pad_select_gpio((gpio_num_t) CAM_PIN_PWDN); - // Set the GPIO as a push/pull output - gpio_set_direction((gpio_num_t) CAM_PIN_PWDN, GPIO_MODE_OUTPUT); - gpio_set_level((gpio_num_t) CAM_PIN_PWDN, 0); - } -*/ - printf("Init Camera\n"); ActualQuality = camera_config.jpeg_quality; ActualResolution = camera_config.frame_size; @@ -645,4 +679,13 @@ esp_err_t CCamera::InitCam() } return ESP_OK; -} \ No newline at end of file +} + +void CCamera::SetLEDIntensity(float _intrel) +{ + _intrel = min(_intrel, (float) 100); + _intrel = max(_intrel, (float) 0); + _intrel = _intrel / 100; + led_intensity = (int) (_intrel * 8191); + printf("Set led_intensity to %d of 8191\n", led_intensity); +} diff --git a/code/components/jomjol_controlcamera/ClassControllCamera.h b/code/components/jomjol_controlcamera/ClassControllCamera.h index 796a298e..86065006 100644 --- a/code/components/jomjol_controlcamera/ClassControllCamera.h +++ b/code/components/jomjol_controlcamera/ClassControllCamera.h @@ -23,6 +23,9 @@ class CCamera { int brightness, contrast, saturation; bool isFixedExposure; int waitbeforepicture_org; + int led_intensity = 4095; + + void ledc_init(void); public: int image_height, image_width; @@ -36,6 +39,7 @@ class CCamera { 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 SetLEDIntensity(float _intrel); void EnableAutoExposure(int flashdauer); diff --git a/code/components/jomjol_controlcamera/server_camera.cpp b/code/components/jomjol_controlcamera/server_camera.cpp index 5caba889..09cef729 100644 --- a/code/components/jomjol_controlcamera/server_camera.cpp +++ b/code/components/jomjol_controlcamera/server_camera.cpp @@ -8,15 +8,15 @@ #include "ClassLogFile.h" -// #define SCRATCH_BUFSIZE2 8192 -// char scratch2[SCRATCH_BUFSIZE2]; +#define SCRATCH_BUFSIZE2 8192 +char scratch2[SCRATCH_BUFSIZE2]; //#define DEBUG_DETAIL_ON static const char *TAGPARTCAMERA = "server_camera"; void PowerResetCamera(){ - printf("Resetting camera by power down line\n"); + ESP_LOGD(TAGPARTCAMERA, "Resetting camera by power down line"); gpio_config_t conf; conf.intr_type = GPIO_INTR_DISABLE; conf.pin_bit_mask = 1LL << GPIO_NUM_32; diff --git a/code/components/jomjol_flowcontroll/ClassFlowMakeImage.cpp b/code/components/jomjol_flowcontroll/ClassFlowMakeImage.cpp index 129882ec..7aee0062 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowMakeImage.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowMakeImage.cpp @@ -5,10 +5,14 @@ #include "CImageBasis.h" #include "ClassControllCamera.h" +#include "esp_wifi.h" + #include // #define DEBUG_DETAIL_ON +// #define WIFITURNOFF + static const char* TAG = "flow_make_image"; esp_err_t ClassFlowMakeImage::camera_capture(){ @@ -118,7 +122,15 @@ bool ClassFlowMakeImage::ReadParameter(FILE* pfile, string& aktparamgraph) if ((toUpper(zerlegt[0]) == "FIXEDEXPOSURE") && (zerlegt.size() > 1)) { if (toUpper(zerlegt[1]) == "TRUE") - FixedExposure = true; + FixedExposure = true; + } + + if ((toUpper(zerlegt[0]) == "LEDINTENSITY") && (zerlegt.size() > 1)) + { + float ledintensity = stof(zerlegt[1]); + ledintensity = min((float) 1, ledintensity); + ledintensity = max((float) 0, ledintensity); + Camera.SetLEDIntensity(ledintensity); } } @@ -162,8 +174,18 @@ bool ClassFlowMakeImage::doFlow(string zwtime) LogFile.WriteHeapInfo("ClassFlowMakeImage::doFlow - Before takePictureWithFlash"); #endif + +#ifdef WIFITURNOFF + esp_wifi_stop(); // to save power usage and +#endif + takePictureWithFlash(flashdauer); +#ifdef WIFITURNOFF + esp_wifi_start(); +#endif + + #ifdef DEBUG_DETAIL_ON LogFile.WriteHeapInfo("ClassFlowMakeImage::doFlow - After takePictureWithFlash"); #endif diff --git a/code/components/jomjol_tfliteclass/server_tflite.cpp b/code/components/jomjol_tfliteclass/server_tflite.cpp index 56fab3c6..4e06ce73 100644 --- a/code/components/jomjol_tfliteclass/server_tflite.cpp +++ b/code/components/jomjol_tfliteclass/server_tflite.cpp @@ -199,7 +199,7 @@ esp_err_t handler_json(httpd_req_t *req) printf("handler_JSON uri:\n"); printf(req->uri); printf("\n"); char _query[100]; - char _size[10]; +// char _size[10]; httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*"); httpd_resp_set_type(req, "application/json"); @@ -491,13 +491,19 @@ esp_err_t handler_editflow(httpd_req_t *req) std::string _bri = ""; std::string _con = ""; std::string _sat = ""; + std::string _int = ""; int bri = -100; int sat = -100; int con = -100; + int intens = -100; if (httpd_query_key_value(_query, "host", _valuechar, 30) == ESP_OK) { _host = std::string(_valuechar); } + if (httpd_query_key_value(_query, "int", _valuechar, 30) == ESP_OK) { + _int = std::string(_valuechar); + intens = stoi(_int); + } if (httpd_query_key_value(_query, "bri", _valuechar, 30) == ESP_OK) { _bri = std::string(_valuechar); bri = stoi(_bri); @@ -515,7 +521,9 @@ esp_err_t handler_editflow(httpd_req_t *req) // printf("Parameter host: "); printf(_host.c_str()); printf("\n"); // string zwzw = "Do " + _task + " start\n"; printf(zwzw.c_str()); Camera.SetBrightnessContrastSaturation(bri, con, sat); + Camera.SetLEDIntensity(intens); std::string zw = tfliteflow.doSingleStep("[MakeImage]", _host); + httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*"); httpd_resp_sendstr_chunk(req, zw.c_str()); } diff --git a/code/main/version.cpp b/code/main/version.cpp index 0301fa67..46779fee 100644 --- a/code/main/version.cpp +++ b/code/main/version.cpp @@ -1,4 +1,4 @@ -const char* GIT_REV="53606d5"; +const char* GIT_REV="567dc74"; const char* GIT_TAG=""; const char* GIT_BRANCH="rolling"; -const char* BUILD_TIME="2022-01-23 19:34"; \ No newline at end of file +const char* BUILD_TIME="2022-01-27 21:04"; \ No newline at end of file diff --git a/code/version.cpp b/code/version.cpp index 0301fa67..46779fee 100644 --- a/code/version.cpp +++ b/code/version.cpp @@ -1,4 +1,4 @@ -const char* GIT_REV="53606d5"; +const char* GIT_REV="567dc74"; const char* GIT_TAG=""; const char* GIT_BRANCH="rolling"; -const char* BUILD_TIME="2022-01-23 19:34"; \ No newline at end of file +const char* BUILD_TIME="2022-01-27 21:04"; \ No newline at end of file diff --git a/firmware/bootloader.bin b/firmware/bootloader.bin index 2bfac8a0..935fd897 100644 Binary files a/firmware/bootloader.bin and b/firmware/bootloader.bin differ diff --git a/firmware/firmware.bin b/firmware/firmware.bin index ecc27c26..3e40f86f 100644 Binary files a/firmware/firmware.bin and b/firmware/firmware.bin differ diff --git a/firmware/html.zip b/firmware/html.zip index 7cc1d206..685262b0 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 f6161278..dbc0fbe5 100644 --- a/sd-card/config/config.ini +++ b/sd-card/config/config.ini @@ -3,9 +3,10 @@ WaitBeforeTakingPicture = 5 ;LogfileRetentionInDays = 15 Brightness = 0 -;Contrast = 0 -;Saturation = 0 -ImageQuality = 5 +Contrast = 0 +Saturation = 0 +LEDIntensity = 50 +ImageQuality = 12 ImageSize = VGA FixedExposure = false diff --git a/sd-card/html/edit_reference.html b/sd-card/html/edit_reference.html index 4cbbddc4..fa65a39d 100644 --- a/sd-card/html/edit_reference.html +++ b/sd-card/html/edit_reference.html @@ -45,34 +45,37 @@ table { + + LEDIntensity: + + + + Brightness: + + Degrees - Brightness: - + Contrast + Degrees - + @@ -104,10 +107,13 @@ table { var xhttp = new XMLHttpRequest(); if (param["MakeImage"]["Brightness"].found && param["MakeImage"]["Brightness"].enabled) { + _intensity = document.getElementById("MakeImage_LEDIntensity_value1").value; + if (_intensity == "") _intensity = "50"; _brightness = document.getElementById("MakeImage_Brightness_value1").value; -// _contrast = document.getElementById("MakeImage_Contrast_value1").value; -// _saturation = document.getElementById("MakeImage_Saturation_value1").value; - url = basepath + "/editflow.html?task=test_take&bri=" + _brightness; + _contrast = document.getElementById("MakeImage_Contrast_value1").value; + _saturation = document.getElementById("MakeImage_Saturation_value1").value; + url = basepath + "/editflow.html?task=test_take&bri=" + _brightness; + url = url + "&con=" + _saturation + "&sat=" + _saturation + "&int=" + _intensity; } else { @@ -116,8 +122,11 @@ table { if (basepath.length > 0){ url = url + "&host=" + basepath; } + xhttp.open("GET", url, false); xhttp.send(); + + loadRawImage(); } @@ -142,7 +151,12 @@ table { } if (param["MakeImage"]["Brightness"].found && param["MakeImage"]["Brightness"].enabled) + { document.getElementById("MakeImage_Brightness_value1").disabled = false; + document.getElementById("MakeImage_Contrast_value1").disabled = false; + document.getElementById("MakeImage_Saturation_value1").disabled = false; + document.getElementById("MakeImage_LEDIntensity_value1").disabled = false; + } else { document.getElementById("MakeImage_Brightness_value1").type = "hidden"; @@ -176,8 +190,9 @@ table { document.getElementById("updatereferenceimage").disabled = true; document.getElementById("take").disabled = true; document.getElementById("MakeImage_Brightness_value1").disabled = true; -// document.getElementById("MakeImage_Saturation_value1").disabled = true; -// document.getElementById("MakeImage_Contrast_value1").disabled = true; + document.getElementById("MakeImage_Saturation_value1").disabled = true; + document.getElementById("MakeImage_Contrast_value1").disabled = true; + document.getElementById("MakeImage_LEDIntensity_value1").disabled = true; document.getElementById("mirror").disabled = false; document.getElementById("flip").disabled = false; if (!(param["MakeImage"]["Brightness"].found)) @@ -225,8 +240,9 @@ table { if (param["MakeImage"]["Brightness"].found && param["MakeImage"]["Brightness"].enabled) { ReadParameter(param, "MakeImage", "Brightness", false); - // ReadParameter(param, "MakeImage", "Contrast", false); - // ReadParameter(param, "MakeImage", "Saturation", false); + ReadParameter(param, "MakeImage", "Contrast", false); + ReadParameter(param, "MakeImage", "Saturation", false); + ReadParameter(param, "MakeImage", "LEDIntensity", false); } var canvas = document.getElementById("canvas"); @@ -238,6 +254,7 @@ table { SaveCanvasToImage(canvas, "/config/reference.jpg", true, basepath); showReference(); UpdatePage(); + alert("Reference is updated!"); } } @@ -274,14 +291,42 @@ table { loadConfig(basepath); ParseConfig(); param = getConfigParameters(); + + param["MakeImage"]["LEDIntensity"]["enabled"] = true; + param["MakeImage"]["Brightness"]["enabled"] = true; + param["MakeImage"]["Contrast"]["enabled"] = true; + param["MakeImage"]["Saturation"]["enabled"] = true; + + if (!param["MakeImage"]["LEDIntensity"]["found"]) + { + param["MakeImage"]["LEDIntensity"]["found"] = true; + param["MakeImage"]["LEDIntensity"]["value1"] = "50"; + } + if (!param["MakeImage"]["Brightness"]["found"]) + { + param["MakeImage"]["Brightness"]["found"] = true; + param["MakeImage"]["Brightness"]["value1"] = "0"; + } + if (!param["MakeImage"]["Contrast"]["found"]) + { + param["MakeImage"]["Contrast"]["found"] = true; + param["MakeImage"]["Contrast"]["value1"] = "0"; + } + if (!param["MakeImage"]["Saturation"]["found"]) + { + param["MakeImage"]["Saturation"]["found"] = true; + param["MakeImage"]["Saturation"]["value1"] = "0"; + } + UpdateInput(); showReference(param); } function UpdateInput() { WriteParameter(param, category, "MakeImage", "Brightness", false); -// WriteParameter(param, category, "MakeImage", "Contrast", false); -// WriteParameter(param, category, "MakeImage", "Saturation", false); + WriteParameter(param, category, "MakeImage", "Contrast", false); + WriteParameter(param, category, "MakeImage", "Saturation", false); + WriteParameter(param, category, "MakeImage", "LEDIntensity", false); } diff --git a/sd-card/html/gethost.js b/sd-card/html/gethost.js index 8a9df763..101660e0 100644 --- a/sd-card/html/gethost.js +++ b/sd-card/html/gethost.js @@ -13,7 +13,7 @@ function getbasepath(){ { // host = "http://192.168.2.219"; // jomjol interner test // host = "http://192.168.178.46"; // jomjol interner test - host = "http://192.168.178.34"; // jomjol interner Real + host = "http://192.168.178.60"; // jomjol interner Real // host = "http://192.168.43.191"; // host = "."; // jomjol interner localhost diff --git a/sd-card/html/readconfigparam.js b/sd-card/html/readconfigparam.js index 6b1f725c..a28ff19b 100644 --- a/sd-card/html/readconfigparam.js +++ b/sd-card/html/readconfigparam.js @@ -28,6 +28,7 @@ function ParseConfig() { ParamAddValue(param, catname, "Brightness"); ParamAddValue(param, catname, "Contrast"); ParamAddValue(param, catname, "Saturation"); + ParamAddValue(param, catname, "LEDIntensity"); ParamAddValue(param, catname, "ImageQuality"); ParamAddValue(param, catname, "ImageSize"); ParamAddValue(param, catname, "FixedExposure"); diff --git a/sd-card/html/version.txt b/sd-card/html/version.txt index 1709bb98..b0d36450 100644 --- a/sd-card/html/version.txt +++ b/sd-card/html/version.txt @@ -1 +1 @@ -11.4.1 \ No newline at end of file +12.0.0 \ No newline at end of file