diff --git a/code/components/jomjol_controlcamera/ClassControllCamera.cpp b/code/components/jomjol_controlcamera/ClassControllCamera.cpp index 075b23730..cc33e3719 100644 --- a/code/components/jomjol_controlcamera/ClassControllCamera.cpp +++ b/code/components/jomjol_controlcamera/ClassControllCamera.cpp @@ -34,6 +34,8 @@ #include "ov2640_sharpness.h" #include "ov2640_specialEffect.h" #include "ov2640_contrast_brightness.h" +#include "ov5640_autofocus.h" +#include "ov5640_autofocus_config.h" #if (ESP_IDF_VERSION_MAJOR >= 5) #include "soc/periph_defs.h" @@ -126,8 +128,14 @@ esp_err_t CCamera::InitCam(void) TickType_t cam_xDelay = 100 / portTICK_PERIOD_MS; - CCstatus.ImageQuality = camera_config.jpeg_quality; - CCstatus.ImageFrameSize = camera_config.frame_size; + CCstatus.CamConfig.ImageQuality = camera_config.jpeg_quality; + CCstatus.CamConfig.ImageFrameSize = camera_config.frame_size; + SetImageWidthHeightFromResolution(&CCstatus.CamConfig, CCstatus.CamConfig.ImageFrameSize); + + CCstatus.CamConfig.CameraFocusEnabled = false; + CCstatus.CamConfig.CameraManualFocus = false; + CCstatus.CamConfig.CameraManualFocusLevel = 0; + CCstatus.CameraFocusLevel = 0; // De-init in case it was already initialized esp_camera_deinit(); @@ -144,6 +152,7 @@ esp_err_t CCamera::InitCam(void) } CCstatus.CameraInitSuccessful = true; + CCstatus.CameraAFInitSuccessful = false; // Get a reference to the sensor sensor_t *s = esp_camera_sensor_get(); @@ -167,11 +176,27 @@ esp_err_t CCamera::InitCam(void) default: ESP_LOGE(TAG, "Camera module is unknown and not properly supported!"); CCstatus.CameraInitSuccessful = false; + CCstatus.CameraAFInitSuccessful = false; } } if (CCstatus.CameraInitSuccessful) { + if (s != NULL) + { + if (CCstatus.CamSensor_id == OV2640_PID) + { + uint8_t reg = s->get_reg(s, 0x09, 0xff); + s->set_reg(s, 0x09, 0xff, (reg &= ~0x10)); + } + else + { + s->set_reg(s, 0x3008, 0x42, 0x02); + } + vTaskDelay(100 / portTICK_PERIOD_MS); + s->set_framesize(s, CCstatus.CamConfig.ImageFrameSize); + vTaskDelay(100 / portTICK_PERIOD_MS); + } return ESP_OK; } else @@ -229,12 +254,40 @@ void CCamera::ledc_init(void) #endif } -int CCamera::SetLEDIntensity(int _intrel) +int CCamera::CalculateLEDIntensity(int _intrel) { - // CCstatus.ImageLedIntensity = (int)(std::min(std::max((float)0, _intrel), (float)100) / 100 * 8191) - Camera.LedIntensity = (int)((float)(std::min(std::max(0, _intrel), 100)) / 100 * 8191); - ESP_LOGD(TAG, "Set led_intensity to %i of 8191", Camera.LedIntensity); - return Camera.LedIntensity; + int LedIntensity = (int)((float)(std::min(std::max(0, _intrel), 100)) / 100 * 8191); + ESP_LOGD(TAG, "Calculated led_intensity: %i of 8191", LedIntensity); + return LedIntensity; +} + +bool CCamera::initCameraAF(void) +{ + sensor_t *s = esp_camera_sensor_get(); + + if (s != NULL) + { + if (CCstatus.CameraAFInitSuccessful == false) + { + ESP_LOGI(TAG, "Initializing autofocus ..."); + // Load autofocus microcode into memory so it can be used when creating new reference image + if (ov5640_autofocus_init(s) == 0) { + ESP_LOGI(TAG, "Autofocus init success"); + CCstatus.CameraAFInitSuccessful = true; + // We want autofocus powered down until we want to capture an image + int rc = ov5640_autofocus_release(s); + if (rc == 0) { + ESP_LOGI(TAG, "Release autofocus success"); + } else { + ESP_LOGI(TAG, "Release autofocus failed: %d", rc); + } + } else { + ESP_LOGI(TAG, "Autofocus init failed"); + CCstatus.CameraAFInitSuccessful = false; + } + } + } + return CCstatus.CameraAFInitSuccessful; } bool CCamera::getCameraInitSuccessful(void) @@ -242,53 +295,64 @@ bool CCamera::getCameraInitSuccessful(void) return CCstatus.CameraInitSuccessful; } -esp_err_t CCamera::setSensorDatenFromCCstatus(void) +bool CCamera::getCameraAFInitSuccessful(void) +{ + return CCstatus.CameraAFInitSuccessful; +} + +esp_err_t CCamera::configureSensor(cam_config_t *camConfig) { sensor_t *s = esp_camera_sensor_get(); if (s != NULL) { - s->set_framesize(s, CCstatus.ImageFrameSize); + CameraDeepSleep(false); + + s->set_framesize(s, camConfig->ImageFrameSize); + vTaskDelay(100 / portTICK_PERIOD_MS); - // s->set_contrast(s, CCstatus.ImageContrast); // -2 to 2 - // s->set_brightness(s, CCstatus.ImageBrightness); // -2 to 2 - SetCamContrastBrightness(s, CCstatus.ImageContrast, CCstatus.ImageBrightness); + // s->set_contrast(s, camConfig->ImageContrast); // -2 to 2 + // s->set_brightness(s, camConfig->ImageBrightness); // -2 to 2 + SetCamContrastBrightness(s, camConfig->ImageContrast, camConfig->ImageBrightness); - s->set_saturation(s, CCstatus.ImageSaturation); // -2 to 2 + s->set_saturation(s, camConfig->ImageSaturation); // -2 to 2 - s->set_quality(s, CCstatus.ImageQuality); // 0 - 63 + s->set_quality(s, camConfig->ImageQuality); // 0 - 63 - // s->set_gainceiling(s, CCstatus.ImageGainceiling); // Image gain (GAINCEILING_x2, x4, x8, x16, x32, x64 or x128) - SetCamGainceiling(s, CCstatus.ImageGainceiling); + // s->set_gainceiling(s, camConfig->ImageGainceiling); // Image gain (GAINCEILING_x2, x4, x8, x16, x32, x64 or x128) + SetCamGainceiling(s, camConfig->ImageGainceiling); - s->set_gain_ctrl(s, CCstatus.ImageAgc); // 0 = disable , 1 = enable - s->set_exposure_ctrl(s, CCstatus.ImageAec); // 0 = disable , 1 = enable - s->set_hmirror(s, CCstatus.ImageHmirror); // 0 = disable , 1 = enable - s->set_vflip(s, CCstatus.ImageVflip); // 0 = disable , 1 = enable + s->set_gain_ctrl(s, camConfig->ImageAgc); // 0 = disable , 1 = enable + s->set_exposure_ctrl(s, camConfig->ImageAec); // 0 = disable , 1 = enable + s->set_hmirror(s, camConfig->ImageHmirror); // 0 = disable , 1 = enable + s->set_vflip(s, camConfig->ImageVflip); // 0 = disable , 1 = enable - s->set_whitebal(s, CCstatus.ImageAwb); // 0 = disable , 1 = enable - s->set_aec2(s, CCstatus.ImageAec2); // 0 = disable , 1 = enable - s->set_aec_value(s, CCstatus.ImageAecValue); // 0 to 1200 - // s->set_special_effect(s, CCstatus.ImageSpecialEffect); // 0 to 6 (0 - No Effect, 1 - Negative, 2 - Grayscale, 3 - Red Tint, 4 - Green Tint, 5 - Blue Tint, 6 - Sepia) - SetCamSpecialEffect(s, CCstatus.ImageSpecialEffect); - s->set_wb_mode(s, CCstatus.ImageWbMode); // 0 to 4 - if awb_gain enabled (0 - Auto, 1 - Sunny, 2 - Cloudy, 3 - Office, 4 - Home) - s->set_ae_level(s, CCstatus.ImageAeLevel); // -2 to 2 + s->set_whitebal(s, camConfig->ImageAwb); // 0 = disable , 1 = enable + s->set_aec2(s, camConfig->ImageAec2); // 0 = disable , 1 = enable + s->set_aec_value(s, camConfig->ImageAecValue); // 0 to 1200 + // s->set_special_effect(s, camConfig->ImageSpecialEffect); // 0 to 6 (0 - No Effect, 1 - Negative, 2 - Grayscale, 3 - Red Tint, 4 - Green Tint, 5 - Blue Tint, 6 - Sepia) + SetCamSpecialEffect(s, camConfig->ImageSpecialEffect); + s->set_wb_mode(s, camConfig->ImageWbMode); // 0 to 4 - if awb_gain enabled (0 - Auto, 1 - Sunny, 2 - Cloudy, 3 - Office, 4 - Home) + s->set_ae_level(s, camConfig->ImageAeLevel); // -2 to 2 - s->set_dcw(s, CCstatus.ImageDcw); // 0 = disable , 1 = enable - s->set_bpc(s, CCstatus.ImageBpc); // 0 = disable , 1 = enable - s->set_wpc(s, CCstatus.ImageWpc); // 0 = disable , 1 = enable - s->set_awb_gain(s, CCstatus.ImageAwbGain); // 0 = disable , 1 = enable - s->set_agc_gain(s, CCstatus.ImageAgcGain); // 0 to 30 + s->set_dcw(s, camConfig->ImageDcw); // 0 = disable , 1 = enable + s->set_bpc(s, camConfig->ImageBpc); // 0 = disable , 1 = enable + s->set_wpc(s, camConfig->ImageWpc); // 0 = disable , 1 = enable + s->set_awb_gain(s, camConfig->ImageAwbGain); // 0 = disable , 1 = enable + s->set_agc_gain(s, camConfig->ImageAgcGain); // 0 to 30 - s->set_raw_gma(s, CCstatus.ImageRawGma); // 0 = disable , 1 = enable - s->set_lenc(s, CCstatus.ImageLenc); // 0 = disable , 1 = enable + s->set_raw_gma(s, camConfig->ImageRawGma); // 0 = disable , 1 = enable + s->set_lenc(s, camConfig->ImageLenc); // 0 = disable , 1 = enable + + // s->set_sharpness(s, camConfig->ImageSharpness); // auto-sharpness is not officially supported, default to 0 + SetCamSharpness(camConfig->ImageAutoSharpness, camConfig->ImageSharpness); + s->set_denoise(s, camConfig->ImageDenoiseLevel); // The OV2640 does not support it, OV3660 and OV5640 (0 to 8) + + vTaskDelay(100 / portTICK_PERIOD_MS); - // s->set_sharpness(s, CCstatus.ImageSharpness); // auto-sharpness is not officially supported, default to 0 - SetCamSharpness(CCstatus.ImageAutoSharpness, CCstatus.ImageSharpness); - s->set_denoise(s, CCstatus.ImageDenoiseLevel); // The OV2640 does not support it, OV3660 and OV5640 (0 to 8) + SetQualityZoomSize(camConfig); - TickType_t cam_xDelay = 100 / portTICK_PERIOD_MS; - vTaskDelay(cam_xDelay); + vTaskDelay(100 / portTICK_PERIOD_MS); return ESP_OK; } @@ -298,6 +362,48 @@ esp_err_t CCamera::setSensorDatenFromCCstatus(void) } } +esp_err_t CCamera::setSensorDatenFromCCstatus(void) +{ + return configureSensor(&CCstatus.CamConfig); +} + +void CCamera::readSensorConfig(sensor_t *s, cam_config_t *camConfig) +{ + camConfig->ImageFrameSize = (framesize_t)s->status.framesize; + + camConfig->ImageContrast = s->status.contrast; + camConfig->ImageBrightness = s->status.brightness; + camConfig->ImageSaturation = s->status.saturation; + + camConfig->ImageQuality = s->status.quality; + + camConfig->ImageGainceiling = (gainceiling_t)s->status.gainceiling; + + camConfig->ImageAgc = s->status.agc; + camConfig->ImageAec = s->status.aec; + camConfig->ImageHmirror = s->status.hmirror; + camConfig->ImageVflip = s->status.vflip; + + camConfig->ImageAwb = s->status.awb; + camConfig->ImageAec2 = s->status.aec2; + camConfig->ImageAecValue = s->status.aec_value; + camConfig->ImageSpecialEffect = s->status.special_effect; + camConfig->ImageWbMode = s->status.wb_mode; + camConfig->ImageAeLevel = s->status.ae_level; + + camConfig->ImageDcw = s->status.dcw; + camConfig->ImageBpc = s->status.bpc; + camConfig->ImageWpc = s->status.wpc; + camConfig->ImageAwbGain = s->status.awb_gain; + camConfig->ImageAgcGain = s->status.agc_gain; + + camConfig->ImageRawGma = s->status.raw_gma; + camConfig->ImageLenc = s->status.lenc; + + // camConfig->ImageSharpness = s->status.sharpness; // gibt -1 zurück, da es nicht unterstützt wird + camConfig->ImageDenoiseLevel = s->status.denoise; +} + esp_err_t CCamera::getSensorDatenToCCstatus(void) { sensor_t *s = esp_camera_sensor_get(); @@ -305,52 +411,216 @@ esp_err_t CCamera::getSensorDatenToCCstatus(void) if (s != NULL) { CCstatus.CamSensor_id = s->id.PID; + readSensorConfig(s, &CCstatus.CamConfig); + return ESP_OK; + } + else + { + return ESP_FAIL; + } +} - CCstatus.ImageFrameSize = (framesize_t)s->status.framesize; - - CCstatus.ImageContrast = s->status.contrast; - CCstatus.ImageBrightness = s->status.brightness; - CCstatus.ImageSaturation = s->status.saturation; - - CCstatus.ImageQuality = s->status.quality; - - CCstatus.ImageGainceiling = (gainceiling_t)s->status.gainceiling; +int CCamera::PrecaptureCamSetup(bool *focusEnabled, bool *manualFocus, bool *needReloadZoomConfig) +{ + int ret = 0; + + cam_config_t *camConfig = CCstatus.isTempImage ? &CFstatus.CamConfig : &CCstatus.CamConfig; + CCstatus.isTempImage = false; + + bool _focusEnabled = camConfig->CameraFocusEnabled; + bool _manualFocus = camConfig->CameraManualFocus; + *focusEnabled = _focusEnabled; + *manualFocus = _manualFocus; + uint16_t _manualFocusLevel = camConfig->CameraManualFocusLevel; + bool _zoomEnabled = camConfig->ImageZoomEnabled; + bool _reloadZoomConfig = _zoomEnabled && _focusEnabled && !_manualFocus; + *needReloadZoomConfig = _reloadZoomConfig; + + // Autofocus does not work with zoom as it constantly overwrites zoom + // registers until autofocus is released. As a workaround, we disable + // zoom, run autofocus to find the focus level and switch to manual + // focus to capture image with zoom. + ret = ret | configureSensor(camConfig); + if (_reloadZoomConfig) + ResetZoomSizeOnCamera(camConfig); + SetCamFocus(_focusEnabled, _manualFocus, _manualFocusLevel); + if (_reloadZoomConfig) + { + ReleaseCamFocus(_focusEnabled, _manualFocus); + SetCamFocus(_focusEnabled, true, CCstatus.CameraFocusLevel); + SetQualityZoomSize(camConfig); + } - CCstatus.ImageAgc = s->status.agc; - CCstatus.ImageAec = s->status.aec; - CCstatus.ImageHmirror = s->status.hmirror; - CCstatus.ImageVflip = s->status.vflip; - - CCstatus.ImageAwb = s->status.awb; - CCstatus.ImageAec2 = s->status.aec2; - CCstatus.ImageAecValue = s->status.aec_value; - CCstatus.ImageSpecialEffect = s->status.special_effect; - CCstatus.ImageWbMode = s->status.wb_mode; - CCstatus.ImageAeLevel = s->status.ae_level; - - CCstatus.ImageDcw = s->status.dcw; - CCstatus.ImageBpc = s->status.bpc; - CCstatus.ImageWpc = s->status.wpc; - CCstatus.ImageAwbGain = s->status.awb_gain; - CCstatus.ImageAgcGain = s->status.agc_gain; - - CCstatus.ImageRawGma = s->status.raw_gma; - CCstatus.ImageLenc = s->status.lenc; + return ret; +} - // CCstatus.ImageSharpness = s->status.sharpness; // gibt -1 zurück, da es nicht unterstützt wird - CCstatus.ImageDenoiseLevel = s->status.denoise; +// only available on OV3660 and OV5640 +// https://github.com/espressif/esp32-camera/issues/672 +int CCamera::CameraDeepSleep(bool sleep) +{ + int ret = 0; + if (CCstatus.CameraDeepSleepEnable != sleep) + { + CCstatus.CameraDeepSleepEnable = sleep; - return ESP_OK; + sensor_t *s = esp_camera_sensor_get(); + + if (s != NULL) + { + if (CCstatus.CamSensor_id == OV2640_PID) + { + // OV2640 (Normal mode >>> Standby mode = OK), (Standby mode >>> Normal mode = n.OK) + // ret |= s->set_reg(s, 0x109, 0x10, enable ? 0x10 : 0); + // LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "DeepSleep is not supported by OV2640"); + uint8_t reg = s->get_reg(s, 0x09, 0xff); + ret = s->set_reg(s, 0x09, 0xff, sleep ? (reg |= 0x10) : (reg &= ~0x10)); + } + else + { + ret = s->set_reg(s, 0x3008, 0x42, sleep ? 0x42 : 0x02); + } + + std::string state = sleep ? "enabled" : "disabled"; + LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "DeepSleep: " + state); + + vTaskDelay(100 / portTICK_PERIOD_MS); + } + else + { + return -1; + } } - else + + return ret; +} + +int CCamera::SetCamFocus(bool focusEnabled, bool manualFocus, uint16_t manualFocusLevel) +{ + CameraDeepSleep(false); + + int ret = 0; + + if (CCstatus.CamSensor_id == OV5640_PID && focusEnabled) { - return ESP_FAIL; + if (initCameraAF()) + { + ESP_LOGI(TAG, "OV5640 and AF inited"); + sensor_t *s = esp_camera_sensor_get(); + if (s != NULL) + { + if (manualFocus) + { + ret = ov5640_manual_focus_set(s, manualFocusLevel); + if (ret == 0) + { + ESP_LOGI(TAG, "Set manual focus level %u success", manualFocusLevel); + CCstatus.CameraFocusLevel = manualFocusLevel; + } + else + { + ESP_LOGI(TAG, "Set manual focus level %u failed: %d", manualFocusLevel, ret); + } + } + else + { + ret = ov5640_autofocus_set_mode(s, AF_TRIG_SINGLE_AUTO_FOCUS); + if (ret == 0) + { + ESP_LOGI(TAG, "Set single autofocus mode success"); + } + else + { + ESP_LOGI(TAG, "Set single autofocus mode failed: %d", ret); + return ret; + } + + ESP_LOGI(TAG, "adjusting focus"); + + camera_fb_t *fb = esp_camera_fb_get(); + uint8_t S_Zone[5]; + uint8_t focus_status = ov5640_autofocus_get_status(s, S_Zone, 5); + for (int z = 0; z < 5; z++) + { + ESP_LOGI(TAG, "Zone[%d]: 0x%02x", z, S_Zone[z]); + } + esp_camera_fb_return(fb); + if (focus_status == FW_STATUS_S_FOCUSING) + { + ESP_LOGI(TAG, "Focusing: 0x%02x", focus_status); + } + else if (focus_status == FW_STATUS_S_FOCUSED) + { + ESP_LOGI(TAG, "Focused: 0x%02x", focus_status); + CCstatus.CameraFocusLevel = ov5640_get_focus_level(s); + ESP_LOGI(TAG, "Focus level: %u", CCstatus.CameraFocusLevel); + } + else + { + ESP_LOGI(TAG, "Focus status 0x%02x", focus_status); + } + } + } + else + { + ret = -1; + } + } + } + return ret; +} + +int CCamera::ReleaseCamFocus(bool focusEnabled, bool manualFocus) +{ + CameraDeepSleep(false); + + int ret = 0; + + if (CCstatus.CamSensor_id == OV5640_PID && focusEnabled) + { + if (CCstatus.CameraAFInitSuccessful) + { + sensor_t *s = esp_camera_sensor_get(); + if (s != NULL) + { + if (manualFocus) + { + ret = ov5640_manual_focus_release(s); + if (ret == 0) + { + ESP_LOGI(TAG, "Release manual focus success"); + } + else + { + ESP_LOGI(TAG, "Release manual focus failed: %d", ret); + } + } + else + { + ret = ov5640_autofocus_release(s); + if (ret == 0) + { + ESP_LOGI(TAG, "Release autofocus success"); + } + else + { + ESP_LOGI(TAG, "Release autofocus failed: %d", ret); + } + } + } + else + { + ret = -1; + } + } } + return ret; } // on the OV5640, gainceiling must be set with the real value (x2>>>gainceilingLevel = 2, .... x128>>>gainceilingLevel = 128) int CCamera::SetCamGainceiling(sensor_t *s, gainceiling_t gainceilingLevel) { + CameraDeepSleep(false); + int ret = 0; if (CCstatus.CamSensor_id == OV2640_PID) @@ -375,6 +645,8 @@ int CCamera::SetCamGainceiling(sensor_t *s, gainceiling_t gainceilingLevel) void CCamera::SetCamSharpness(bool autoSharpnessEnabled, int sharpnessLevel) { + CameraDeepSleep(false); + sensor_t *s = esp_camera_sensor_get(); if (s != NULL) @@ -415,6 +687,8 @@ void CCamera::SetCamSharpness(bool autoSharpnessEnabled, int sharpnessLevel) void CCamera::SetCamSpecialEffect(sensor_t *s, int specialEffect) { + CameraDeepSleep(false); + if (CCstatus.CamSensor_id == OV2640_PID) { ov2640_set_special_effect(s, specialEffect); @@ -427,6 +701,8 @@ void CCamera::SetCamSpecialEffect(sensor_t *s, int specialEffect) void CCamera::SetCamContrastBrightness(sensor_t *s, int _contrast, int _brightness) { + CameraDeepSleep(false); + if (CCstatus.CamSensor_id == OV2640_PID) { ov2640_set_contrast_brightness(s, _contrast, _brightness); @@ -442,12 +718,12 @@ void CCamera::SetCamContrastBrightness(sensor_t *s, int _contrast, int _brightne // - if imageSize = 0 then the image is not zoomed // - if imageSize = max value, then the image is fully zoomed in // - a zoom step is >>> Width + 32 px / Height + 24 px -void CCamera::SanitizeZoomParams(int imageSize, int frameSizeX, int frameSizeY, int &imageWidth, int &imageHeight, int &zoomOffsetX, int &zoomOffsetY) +void CCamera::SanitizeZoomParams(cam_config_t *camConfig, int imageSize, int frameSizeX, int frameSizeY, int &imageWidth, int &imageHeight, int &zoomOffsetX, int &zoomOffsetY) { // for OV2640, This works only if the aspect ratio of 4:3 is preserved in the window size. // use only values divisible by 8 without remainder - imageWidth = CCstatus.ImageWidth + (imageSize * 4 * 8); - imageHeight = CCstatus.ImageHeight + (imageSize * 3 * 8); + imageWidth = camConfig->ImageWidth + (imageSize * 4 * 8); + imageHeight = camConfig->ImageHeight + (imageSize * 3 * 8); int _maxX = frameSizeX - imageWidth; int _maxY = frameSizeY - imageHeight; @@ -499,7 +775,7 @@ void CCamera::SanitizeZoomParams(int imageSize, int frameSizeX, int frameSizeY, } } -void CCamera::SetZoomSize(bool zoomEnabled, int zoomOffsetX, int zoomOffsetY, int imageSize, int imageVflip) +void CCamera::SetZoomSize(cam_config_t *camConfig, bool zoomEnabled, int zoomOffsetX, int zoomOffsetY, int imageSize, int imageVflip) { sensor_t *s = esp_camera_sensor_get(); @@ -508,8 +784,8 @@ void CCamera::SetZoomSize(bool zoomEnabled, int zoomOffsetX, int zoomOffsetY, in if (zoomEnabled) { int _imageSize_temp = 0; - int _imageWidth = CCstatus.ImageWidth; - int _imageHeight = CCstatus.ImageHeight; + int _imageWidth = camConfig->ImageWidth; + int _imageHeight = camConfig->ImageHeight; int _offsetx = zoomOffsetX; int _offsety = zoomOffsetY; int frameSizeX; @@ -526,8 +802,8 @@ void CCamera::SetZoomSize(bool zoomEnabled, int zoomOffsetX, int zoomOffsetY, in { _imageSize_temp = (59 - imageSize); } - SanitizeZoomParams(_imageSize_temp, frameSizeX, frameSizeY, _imageWidth, _imageHeight, _offsetx, _offsety); - SetCamWindow(s, frameSizeX, frameSizeY, _offsetx, _offsety, _imageWidth, _imageHeight, CCstatus.ImageWidth, CCstatus.ImageHeight, imageVflip); + SanitizeZoomParams(camConfig, _imageSize_temp, frameSizeX, frameSizeY, _imageWidth, _imageHeight, _offsetx, _offsety); + SetCamWindow(s, frameSizeX, frameSizeY, _offsetx, _offsety, _imageWidth, _imageHeight, camConfig->ImageWidth, camConfig->ImageHeight, imageVflip); break; case OV3660_PID: @@ -539,8 +815,8 @@ void CCamera::SetZoomSize(bool zoomEnabled, int zoomOffsetX, int zoomOffsetY, in { _imageSize_temp = (43 - imageSize); } - SanitizeZoomParams(_imageSize_temp, frameSizeX, frameSizeY, _imageWidth, _imageHeight, _offsetx, _offsety); - SetCamWindow(s, frameSizeX, frameSizeY, _offsetx, _offsety, _imageWidth, _imageHeight, CCstatus.ImageWidth, CCstatus.ImageHeight, imageVflip); + SanitizeZoomParams(camConfig, _imageSize_temp, frameSizeX, frameSizeY, _imageWidth, _imageHeight, _offsetx, _offsety); + SetCamWindow(s, frameSizeX, frameSizeY, _offsetx, _offsety, _imageWidth, _imageHeight, camConfig->ImageWidth, camConfig->ImageHeight, imageVflip); break; case OV2640_PID: @@ -552,8 +828,8 @@ void CCamera::SetZoomSize(bool zoomEnabled, int zoomOffsetX, int zoomOffsetY, in { _imageSize_temp = (29 - imageSize); } - SanitizeZoomParams(_imageSize_temp, frameSizeX, frameSizeY, _imageWidth, _imageHeight, _offsetx, _offsety); - SetCamWindow(s, frameSizeX, frameSizeY, _offsetx, _offsety, _imageWidth, _imageHeight, CCstatus.ImageWidth, CCstatus.ImageHeight, imageVflip); + SanitizeZoomParams(camConfig, _imageSize_temp, frameSizeX, frameSizeY, _imageWidth, _imageHeight, _offsetx, _offsety); + SetCamWindow(s, frameSizeX, frameSizeY, _offsetx, _offsety, _imageWidth, _imageHeight, camConfig->ImageWidth, camConfig->ImageHeight, imageVflip); break; default: @@ -563,27 +839,37 @@ void CCamera::SetZoomSize(bool zoomEnabled, int zoomOffsetX, int zoomOffsetY, in } else { - s->set_framesize(s, CCstatus.ImageFrameSize); + s->set_framesize(s, camConfig->ImageFrameSize); } } } -void CCamera::SetQualityZoomSize(int qual, framesize_t resol, bool zoomEnabled, int zoomOffsetX, int zoomOffsetY, int imageSize, int imageVflip) +void CCamera::SetQualityZoomSize(cam_config_t *camConfig) { + int qual = camConfig->ImageQuality; + framesize_t resol = camConfig->ImageFrameSize; + bool zoomEnabled = camConfig->ImageZoomEnabled; + int zoomOffsetX = camConfig->ImageZoomOffsetX; + int zoomOffsetY = camConfig->ImageZoomOffsetY; + int imageSize = camConfig->ImageZoomSize; + int imageVflip = camConfig->ImageVflip; + + CameraDeepSleep(false); + sensor_t *s = esp_camera_sensor_get(); // OV2640 has no lower limit on jpeg quality if (CCstatus.CamSensor_id == OV5640_PID) { - qual = min(63, max(8, qual)); + qual = min(63, max(12, qual)); } - SetImageWidthHeightFromResolution(resol); + SetImageWidthHeightFromResolution(camConfig, resol); if (s != NULL) { s->set_quality(s, qual); - SetZoomSize(zoomEnabled, zoomOffsetX, zoomOffsetY, imageSize, imageVflip); + SetZoomSize(camConfig, zoomEnabled, zoomOffsetX, zoomOffsetY, imageSize, imageVflip); } else { @@ -591,8 +877,17 @@ void CCamera::SetQualityZoomSize(int qual, framesize_t resol, bool zoomEnabled, } } +void CCamera::ResetZoomSizeOnCamera(cam_config_t *camConfig) +{ + CameraDeepSleep(false); + + SetZoomSize(camConfig, false, 0, 0, 0, 0); +} + void CCamera::SetCamWindow(sensor_t *s, int frameSizeX, int frameSizeY, int xOffset, int yOffset, int xTotal, int yTotal, int xOutput, int yOutput, int imageVflip) { + CameraDeepSleep(false); + if (CCstatus.CamSensor_id == OV2640_PID) { s->set_res_raw(s, 0, 0, 0, 0, xOffset, yOffset, xTotal, yTotal, xOutput, yOutput, false, false); @@ -642,22 +937,33 @@ esp_err_t CCamera::CaptureToBasisImage(CImageBasis *_Image, int delay) _Image->EmptyImage(); // Delete previous stored raw image -> black image LEDOnOff(true); // Status-LED on - if (delay > 0) { LightOnOff(true); // Flash-LED on - const TickType_t xDelay = delay / portTICK_PERIOD_MS; - vTaskDelay(xDelay); } #ifdef DEBUG_DETAIL_ON LogFile.WriteHeapInfo("CaptureToBasisImage - After LightOn"); #endif - camera_fb_t *fb = esp_camera_fb_get(); + camera_fb_t *fb = NULL; + bool _focusEnabled = false; + bool _manualFocus = false; + bool _reloadZoomConfig = false; + PrecaptureCamSetup(&_focusEnabled, &_manualFocus, &_reloadZoomConfig); + + if (delay > 0) + { + const TickType_t xDelay = delay / portTICK_PERIOD_MS; + vTaskDelay(xDelay); + } + + fb = esp_camera_fb_get(); esp_camera_fb_return(fb); fb = esp_camera_fb_get(); + ReleaseCamFocus(_focusEnabled, _reloadZoomConfig ? true : _manualFocus); + if (!fb) { LEDOnOff(false); // Status-LED off @@ -665,6 +971,7 @@ esp_err_t CCamera::CaptureToBasisImage(CImageBasis *_Image, int delay) LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "is not working anymore (CaptureToBasisImage) - most probably caused " "by a hardware problem (instablility, ...). System will reboot."); + CameraDeepSleep(true); doReboot(); return ESP_FAIL; @@ -689,6 +996,7 @@ esp_err_t CCamera::CaptureToBasisImage(CImageBasis *_Image, int delay) } esp_camera_fb_return(fb); + CameraDeepSleep(true); #ifdef DEBUG_DETAIL_ON LogFile.WriteHeapInfo("CaptureToBasisImage - After fb_get"); @@ -716,8 +1024,8 @@ esp_err_t CCamera::CaptureToBasisImage(CImageBasis *_Image, int delay) stbi_uc *p_target; stbi_uc *p_source; int channels = 3; - int width = CCstatus.ImageWidth; - int height = CCstatus.ImageHeight; + int width = CCstatus.CamConfig.ImageWidth; + int height = CCstatus.CamConfig.ImageHeight; #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); @@ -750,27 +1058,38 @@ esp_err_t CCamera::CaptureToBasisImage(CImageBasis *_Image, int delay) esp_err_t CCamera::CaptureToFile(std::string nm, int delay) { - string ftype; - LEDOnOff(true); // Status-LED on if (delay > 0) { LightOnOff(true); // Flash-LED on + } + + camera_fb_t *fb = NULL; + bool _focusEnabled = false; + bool _manualFocus = false; + bool _reloadZoomConfig = false; + PrecaptureCamSetup(&_focusEnabled, &_manualFocus, &_reloadZoomConfig); + + if (delay > 0) + { const TickType_t xDelay = delay / portTICK_PERIOD_MS; vTaskDelay(xDelay); } - camera_fb_t *fb = esp_camera_fb_get(); + fb = esp_camera_fb_get(); esp_camera_fb_return(fb); fb = esp_camera_fb_get(); + ReleaseCamFocus(_focusEnabled, _reloadZoomConfig ? true : _manualFocus); + if (!fb) { LEDOnOff(false); // Status-LED off LightOnOff(false); // Flash-LED off LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "CaptureToFile: Capture Failed. " "Check camera module and/or proper electrical connection"); + CameraDeepSleep(true); // doReboot(); return ESP_FAIL; @@ -788,7 +1107,7 @@ esp_err_t CCamera::CaptureToFile(std::string nm, int delay) ESP_LOGD(TAG, "Save Camera to: %s", nm.c_str()); #endif - ftype = toUpper(getFileType(nm)); + std::string ftype = toUpper(getFileType(nm)); #ifdef DEBUG_DETAIL_ON ESP_LOGD(TAG, "Filetype: %s", ftype.c_str()); @@ -808,7 +1127,7 @@ esp_err_t CCamera::CaptureToFile(std::string nm, int delay) { if (fb->format != PIXFORMAT_JPEG) { - bool jpeg_converted = frame2jpg(fb, CCstatus.ImageQuality, &buf, &buf_len); + bool jpeg_converted = frame2jpg(fb, CCstatus.CamConfig.ImageQuality, &buf, &buf_len); converted = true; if (!jpeg_converted) @@ -842,6 +1161,7 @@ esp_err_t CCamera::CaptureToFile(std::string nm, int delay) } esp_camera_fb_return(fb); + CameraDeepSleep(true); if (delay > 0) { @@ -862,14 +1182,26 @@ esp_err_t CCamera::CaptureToHTTP(httpd_req_t *req, int delay) if (delay > 0) { LightOnOff(true); // Flash-LED on + } + + camera_fb_t *fb = NULL; + bool _focusEnabled = false; + bool _manualFocus = false; + bool _reloadZoomConfig = false; + PrecaptureCamSetup(&_focusEnabled, &_manualFocus, &_reloadZoomConfig); + + if (delay > 0) + { const TickType_t xDelay = delay / portTICK_PERIOD_MS; vTaskDelay(xDelay); } - camera_fb_t *fb = esp_camera_fb_get(); + fb = esp_camera_fb_get(); esp_camera_fb_return(fb); fb = esp_camera_fb_get(); + ReleaseCamFocus(_focusEnabled, _reloadZoomConfig ? true : _manualFocus); + if (!fb) { LEDOnOff(false); // Status-LED off @@ -877,6 +1209,7 @@ esp_err_t CCamera::CaptureToHTTP(httpd_req_t *req, int delay) LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "CaptureToFile: Capture Failed. " "Check camera module and/or proper electrical connection"); httpd_resp_send_500(req); + CameraDeepSleep(true); // doReboot(); return ESP_FAIL; @@ -919,6 +1252,7 @@ esp_err_t CCamera::CaptureToHTTP(httpd_req_t *req, int delay) } esp_camera_fb_return(fb); + CameraDeepSleep(true); int64_t fr_end = esp_timer_get_time(); ESP_LOGI(TAG, "JPG: %dKB %dms", (int)(fb_len / 1024), (int)((fr_end - fr_start) / 1000)); @@ -938,15 +1272,6 @@ esp_err_t CCamera::CaptureToStream(httpd_req_t *req, bool FlashlightOn) int64_t fr_start; char *part_buf[64]; - // wenn die Kameraeinstellungen durch Erstellen eines neuen Referenzbildes verändert wurden, müssen sie neu gesetzt werden - if (CFstatus.changedCameraSettings) - { - Camera.setSensorDatenFromCCstatus(); // CCstatus >>> Kamera - Camera.SetQualityZoomSize(CCstatus.ImageQuality, CCstatus.ImageFrameSize, CCstatus.ImageZoomEnabled, CCstatus.ImageZoomOffsetX, CCstatus.ImageZoomOffsetY, CCstatus.ImageZoomSize, CCstatus.ImageVflip); - Camera.LedIntensity = CCstatus.ImageLedIntensity; - CFstatus.changedCameraSettings = false; - } - LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Live stream started"); if (FlashlightOn) @@ -960,6 +1285,11 @@ esp_err_t CCamera::CaptureToStream(httpd_req_t *req, bool FlashlightOn) httpd_resp_set_type(req, _STREAM_CONTENT_TYPE); httpd_resp_send_chunk(req, _STREAM_BOUNDARY, strlen(_STREAM_BOUNDARY)); + bool _focusEnabled = false; + bool _manualFocus = false; + bool _reloadZoomConfig = false; + PrecaptureCamSetup(&_focusEnabled, &_manualFocus, &_reloadZoomConfig); + while (1) { fr_start = esp_timer_get_time(); @@ -1012,6 +1342,9 @@ esp_err_t CCamera::CaptureToStream(httpd_req_t *req, bool FlashlightOn) } } + ReleaseCamFocus(_focusEnabled, _reloadZoomConfig ? true : _manualFocus); + CameraDeepSleep(true); + LEDOnOff(false); // Status-LED off LightOnOff(false); // Flash-LED off @@ -1034,8 +1367,8 @@ void CCamera::LightOnOff(bool status) #ifdef USE_PWM_LEDFLASH if (status) { - ESP_LOGD(TAG, "Internal Flash-LED turn on with PWM %d", Camera.LedIntensity); - ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LEDC_CHANNEL, Camera.LedIntensity)); + ESP_LOGD(TAG, "Internal Flash-LED turn on with PWM %d", CCstatus.CamConfig.ImageLedIntensity); + ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LEDC_CHANNEL, CCstatus.CamConfig.ImageLedIntensity)); // Update duty to apply the new value ESP_ERROR_CHECK(ledc_update_duty(LEDC_MODE, LEDC_CHANNEL)); } @@ -1085,62 +1418,62 @@ void CCamera::LEDOnOff(bool status) } } -void CCamera::SetImageWidthHeightFromResolution(framesize_t resol) +void CCamera::SetImageWidthHeightFromResolution(cam_config_t *camConfig, framesize_t resol) { if (resol == FRAMESIZE_QVGA) { - CCstatus.ImageWidth = 320; - CCstatus.ImageHeight = 240; + camConfig->ImageWidth = 320; + camConfig->ImageHeight = 240; } else if (resol == FRAMESIZE_VGA) { - CCstatus.ImageWidth = 640; - CCstatus.ImageHeight = 480; + camConfig->ImageWidth = 640; + camConfig->ImageHeight = 480; } else if (resol == FRAMESIZE_SVGA) { - CCstatus.ImageWidth = 800; - CCstatus.ImageHeight = 600; + camConfig->ImageWidth = 800; + camConfig->ImageHeight = 600; } else if (resol == FRAMESIZE_XGA) { - CCstatus.ImageWidth = 1024; - CCstatus.ImageHeight = 768; + camConfig->ImageWidth = 1024; + camConfig->ImageHeight = 768; } else if (resol == FRAMESIZE_HD) { - CCstatus.ImageWidth = 1280; - CCstatus.ImageHeight = 720; + camConfig->ImageWidth = 1280; + camConfig->ImageHeight = 720; } else if (resol == FRAMESIZE_SXGA) { - CCstatus.ImageWidth = 1280; - CCstatus.ImageHeight = 1024; + camConfig->ImageWidth = 1280; + camConfig->ImageHeight = 1024; } else if (resol == FRAMESIZE_UXGA) { - CCstatus.ImageWidth = 1600; - CCstatus.ImageHeight = 1200; + camConfig->ImageWidth = 1600; + camConfig->ImageHeight = 1200; } else if (resol == FRAMESIZE_QXGA) { - CCstatus.ImageWidth = 2048; - CCstatus.ImageHeight = 1536; + camConfig->ImageWidth = 2048; + camConfig->ImageHeight = 1536; } else if (resol == FRAMESIZE_WQXGA) { - CCstatus.ImageWidth = 2560; - CCstatus.ImageHeight = 1600; + camConfig->ImageWidth = 2560; + camConfig->ImageHeight = 1600; } else if (resol == FRAMESIZE_QSXGA) { - CCstatus.ImageWidth = 2560; - CCstatus.ImageHeight = 1920; + camConfig->ImageWidth = 2560; + camConfig->ImageHeight = 1920; } else { - CCstatus.ImageWidth = 640; - CCstatus.ImageHeight = 480; + camConfig->ImageWidth = 640; + camConfig->ImageHeight = 480; } } @@ -1187,7 +1520,7 @@ framesize_t CCamera::TextToFramesize(const char *_size) return FRAMESIZE_VGA; // 640x480 } - // return CCstatus.ImageFrameSize; + // return CCstatus.CamConfig.ImageFrameSize; } std::vector demoFiles; diff --git a/code/components/jomjol_controlcamera/ClassControllCamera.h b/code/components/jomjol_controlcamera/ClassControllCamera.h index 51e091912..56c7918cc 100644 --- a/code/components/jomjol_controlcamera/ClassControllCamera.h +++ b/code/components/jomjol_controlcamera/ClassControllCamera.h @@ -13,56 +13,23 @@ #include #include #include "CImageBasis.h" +#include "camera_config.h" #include "../../include/defines.h" typedef struct { uint16_t CamSensor_id; - framesize_t ImageFrameSize = FRAMESIZE_VGA; // 0 - 10 - gainceiling_t ImageGainceiling; // Image gain (GAINCEILING_x2, x4, x8, x16, x32, x64 or x128) - - int ImageQuality; // 0 - 63 - int ImageBrightness; // (-2 to 2) - set brightness - int ImageContrast; //-2 - 2 - int ImageSaturation; //-2 - 2 - int ImageSharpness; //-2 - 2 - bool ImageAutoSharpness; - int ImageSpecialEffect; // 0 - 6 - int ImageWbMode; // 0 to 4 - if awb_gain enabled (0 - Auto, 1 - Sunny, 2 - Cloudy, 3 - Office, 4 - Home) - int ImageAwb; // white balance enable (0 or 1) - int ImageAwbGain; // Auto White Balance enable (0 or 1) - int ImageAec; // auto exposure off (1 or 0) - int ImageAec2; // automatic exposure sensor (0 or 1) - int ImageAeLevel; // auto exposure levels (-2 to 2) - int ImageAecValue; // set exposure manually (0-1200) - int ImageAgc; // auto gain off (1 or 0) - int ImageAgcGain; // set gain manually (0 - 30) - int ImageBpc; // black pixel correction - int ImageWpc; // white pixel correction - int ImageRawGma; // (1 or 0) - int ImageLenc; // lens correction (1 or 0) - int ImageHmirror; // (0 or 1) flip horizontally - int ImageVflip; // Invert image (0 or 1) - int ImageDcw; // downsize enable (1 or 0) - - int ImageDenoiseLevel; // The OV2640 does not support it, OV3660 and OV5640 (0 to 8) - - int ImageWidth; - int ImageHeight; - - int ImageLedIntensity; - - bool ImageZoomEnabled; - int ImageZoomOffsetX; - int ImageZoomOffsetY; - int ImageZoomSize; + cam_config_t CamConfig; + uint16_t CameraFocusLevel; // temporary storage for the latest focus level int WaitBeforePicture; bool isImageSize; + bool isTempImage; bool CameraInitSuccessful; - bool changedCameraSettings; + bool CameraAFInitSuccessful; + bool CameraDeepSleepEnable; bool DemoMode; bool SaveAllFiles; } camera_controll_config_temp_t; @@ -75,36 +42,45 @@ class CCamera void ledc_init(void); bool loadNextDemoImage(camera_fb_t *fb); long GetFileSize(std::string filename); + + int SetCamGainceiling(sensor_t *s, gainceiling_t gainceilingLevel); + void SetCamSharpness(bool autoSharpnessEnabled, int sharpnessLevel); + void SetCamSpecialEffect(sensor_t *s, int specialEffect); + void SetCamContrastBrightness(sensor_t *s, int _contrast, int _brightness); void SetCamWindow(sensor_t *s, int frameSizeX, int frameSizeY, int xOffset, int yOffset, int xTotal, int yTotal, int xOutput, int yOutput, int imageVflip); - void SetImageWidthHeightFromResolution(framesize_t resol); - void SanitizeZoomParams(int imageSize, int frameSizeX, int frameSizeY, int &imageWidth, int &imageHeight, int &zoomOffsetX, int &zoomOffsetY); + void SetImageWidthHeightFromResolution(cam_config_t *camConfig, framesize_t resol); + void SanitizeZoomParams(cam_config_t *camConfig, int imageSize, int frameSizeX, int frameSizeY, int &imageWidth, int &imageHeight, int &zoomOffsetX, int &zoomOffsetY); + void SetQualityZoomSize(cam_config_t *camConfig); + void SetZoomSize(cam_config_t *camConfig, bool zoomEnabled, int zoomOffsetX, int zoomOffsetY, int imageSize, int imageVflip); + void ResetZoomSizeOnCamera(cam_config_t *camConfig); + int SetCamFocus(bool focusEnabled, bool manualFocus, uint16_t manualFocusLevel); + int ReleaseCamFocus(bool focusEnabled, bool manualFocus); -public: - int LedIntensity = 4096; + void readSensorConfig(sensor_t *s, cam_config_t *camConfig); + + int PrecaptureCamSetup(bool *focusEnabled, bool *manualFocus, bool *needReloadZoomConfig); + + bool initCameraAF(void); + int CameraDeepSleep(bool sleep); +public: CCamera(void); esp_err_t InitCam(void); void LightOnOff(bool status); void LEDOnOff(bool status); + esp_err_t configureSensor(cam_config_t *camConfig); esp_err_t setSensorDatenFromCCstatus(void); esp_err_t getSensorDatenToCCstatus(void); - int SetCamGainceiling(sensor_t *s, gainceiling_t gainceilingLevel); - void SetCamSharpness(bool autoSharpnessEnabled, int sharpnessLevel); - void SetCamSpecialEffect(sensor_t *s, int specialEffect); - void SetCamContrastBrightness(sensor_t *s, int _contrast, int _brightness); - esp_err_t CaptureToHTTP(httpd_req_t *req, int delay = 0); esp_err_t CaptureToStream(httpd_req_t *req, bool FlashlightOn); - void SetQualityZoomSize(int qual, framesize_t resol, bool zoomEnabled, int zoomOffsetX, int zoomOffsetY, int imageSize, int imageVflip); - void SetZoomSize(bool zoomEnabled, int zoomOffsetX, int zoomOffsetY, int imageSize, int imageVflip); - - int SetLEDIntensity(int _intrel); + int CalculateLEDIntensity(int _intrel); bool testCamera(void); bool getCameraInitSuccessful(void); + bool getCameraAFInitSuccessful(void); void useDemoMode(void); framesize_t TextToFramesize(const char *text); diff --git a/code/components/jomjol_controlcamera/camera_config.h b/code/components/jomjol_controlcamera/camera_config.h new file mode 100644 index 000000000..c5ead7729 --- /dev/null +++ b/code/components/jomjol_controlcamera/camera_config.h @@ -0,0 +1,47 @@ +#include "esp_camera.h" + +typedef struct +{ + framesize_t ImageFrameSize = FRAMESIZE_VGA; // 0 - 10 + gainceiling_t ImageGainceiling; // Image gain (GAINCEILING_x2, x4, x8, x16, x32, x64 or x128) + + int ImageQuality; // 0 - 63 + int ImageBrightness; // (-2 to 2) - set brightness + int ImageContrast; //-2 - 2 + int ImageSaturation; //-2 - 2 + int ImageSharpness; //-2 - 2 + bool ImageAutoSharpness; + int ImageSpecialEffect; // 0 - 6 + int ImageWbMode; // 0 to 4 - if awb_gain enabled (0 - Auto, 1 - Sunny, 2 - Cloudy, 3 - Office, 4 - Home) + int ImageAwb; // white balance enable (0 or 1) + int ImageAwbGain; // Auto White Balance enable (0 or 1) + int ImageAec; // auto exposure off (1 or 0) + int ImageAec2; // automatic exposure sensor (0 or 1) + int ImageAeLevel; // auto exposure levels (-2 to 2) + int ImageAecValue; // set exposure manually (0-1200) + int ImageAgc; // auto gain off (1 or 0) + int ImageAgcGain; // set gain manually (0 - 30) + int ImageBpc; // black pixel correction + int ImageWpc; // white pixel correction + int ImageRawGma; // (1 or 0) + int ImageLenc; // lens correction (1 or 0) + int ImageHmirror; // (0 or 1) flip horizontally + int ImageVflip; // Invert image (0 or 1) + int ImageDcw; // downsize enable (1 or 0) + + int ImageDenoiseLevel; // The OV2640 does not support it, OV3660 and OV5640 (0 to 8) + + int ImageWidth; + int ImageHeight; + + int ImageLedIntensity = 4096; + + bool ImageZoomEnabled; + int ImageZoomOffsetX; + int ImageZoomOffsetY; + int ImageZoomSize; + + bool CameraFocusEnabled; + bool CameraManualFocus; + uint16_t CameraManualFocusLevel; +} cam_config_t; diff --git a/code/components/jomjol_controlcamera/ov5640_autofocus.cpp b/code/components/jomjol_controlcamera/ov5640_autofocus.cpp new file mode 100644 index 000000000..1f3cb2112 --- /dev/null +++ b/code/components/jomjol_controlcamera/ov5640_autofocus.cpp @@ -0,0 +1,233 @@ +#include +#include +#include +#include "esp_log.h" +#include "esp_camera.h" +#include "ov5640_autofocus.h" +#include "ov5640_autofocus_config.h" + +static const char *TAG = "CAM"; + +static bool is_ov5640(sensor_t *sensor) +{ + uint8_t vid, pid; + vid = sensor->get_reg(sensor, OV5640_CHIPID_HIGH, 0xff); + pid = sensor->get_reg(sensor, OV5640_CHIPID_LOW, 0xff); + + return (vid == 0x56) && (pid == 0x40); +} + +int ov5640_autofocus_init(sensor_t *sensor) +{ + int ret = 0; + + if (is_ov5640(sensor)) + { + uint16_t retry = 0; + uint16_t addr = 0x8000; + uint8_t state = 0x8F; + + ret = sensor->set_reg(sensor, OV5640_SYSTEM_RESET00, 0xff, 0x20); // reset MCU + if (ret < 0) + { + return -1; + } + + for (uint16_t i = 0; i < sizeof(OV5640_AF_Config); i++) + { + ret = sensor->set_reg(sensor, addr, 0xff, OV5640_AF_Config[i]); + if (ret < 0) + { + return -1; + } + addr++; + if ((i & 0x7f) == 0x7f) + { + vTaskDelay(1); // to avoid watchdog trigger + } + } + + ret |= sensor->set_reg(sensor, OV5640_CMD_MAIN, 0xff, 0x00); + ret |= sensor->set_reg(sensor, OV5640_CMD_ACK, 0xff, 0x00); + ret |= sensor->set_reg(sensor, OV5640_CMD_PARA0, 0xff, 0x00); + ret |= sensor->set_reg(sensor, OV5640_CMD_PARA1, 0xff, 0x00); + ret |= sensor->set_reg(sensor, OV5640_CMD_PARA2, 0xff, 0x00); + ret |= sensor->set_reg(sensor, OV5640_CMD_PARA3, 0xff, 0x00); + ret |= sensor->set_reg(sensor, OV5640_CMD_PARA4, 0xff, 0x00); + ret |= sensor->set_reg(sensor, OV5640_CMD_FW_STATUS, 0xff, 0x7f); + ret |= sensor->set_reg(sensor, OV5640_SYSTEM_RESET00, 0xff, 0x00); + + do + { + state = sensor->get_reg(sensor, OV5640_CMD_FW_STATUS, 0xff); + vTaskDelay(5 / portTICK_PERIOD_MS); + retry++; + if (retry > 1000) + { + return 1; + } + } while (state != FW_STATUS_S_IDLE); + } + return ret; +} + +int ov5640_autofocus_set_mode(sensor_t *sensor, uint8_t mode) +{ + if ((mode != AF_TRIG_SINGLE_AUTO_FOCUS) && (mode != AF_CONTINUE_AUTO_FOCUS) && (mode != AF_LOCK_FOCUS)) + { + return -1; + } + + int ret = 0; + uint8_t temp = 0; + uint16_t retry = 0; + + // Note: The MCU will auto clear CMD_MAIN to zero after the command is receipt, and auto clear + // CMD_ACK to zero when the command is completed. + + ret |= sensor->set_reg(sensor, OV5640_CMD_ACK, 0xff, 0x01); + ret |= sensor->set_reg(sensor, OV5640_CMD_MAIN, 0xff, mode); + + do + { + temp = sensor->get_reg(sensor, OV5640_CMD_ACK, 0xff); + retry++; + if (retry > 1000) + { + return 2; + } + vTaskDelay(30 / portTICK_PERIOD_MS); + } while (temp != 0x00); + + return ret; +} + +// returns FW_STATUS_S_FOCUSED or FW_STATUS_S_FOCUSING +int ov5640_autofocus_get_status(sensor_t *sensor, uint8_t *S_Zone, int S_Zone_len) +{ + int ret = 0; + uint8_t temp = 0; + uint16_t retry = 0; + + ret |= sensor->set_reg(sensor, OV5640_CMD_ACK, 0xff, 0x01); + ret |= sensor->set_reg(sensor, OV5640_CMD_MAIN, 0xff, 0x07); + + do + { + temp = sensor->get_reg(sensor, OV5640_CMD_ACK, 0xff); + retry++; + if (retry > 1000) + { + return 2; + } + vTaskDelay(5 / portTICK_PERIOD_MS); + } while (temp != 0x00); + + if (S_Zone_len > 5) + { + S_Zone_len = 5; + } + + for (int i = 0; i < S_Zone_len; i++) + { + S_Zone[i] = sensor->get_reg(sensor, OV5640_CMD_PARA0 + i, 0xff); + } + ret |= sensor->get_reg(sensor, OV5640_CMD_FW_STATUS, 0xff); + + return ret; +} + +int ov5640_autofocus_release(sensor_t *sensor) +{ + int ret = 0; + uint8_t temp = 0; + uint16_t retry = 0; + + ret |= sensor->set_reg(sensor, OV5640_CMD_ACK, 0xff, 0x01); + ret |= sensor->set_reg(sensor, OV5640_CMD_MAIN, 0xff, AF_RELEASE_FOCUS); + + do + { + temp = sensor->get_reg(sensor, OV5640_CMD_ACK, 0xff); + retry++; + if (retry > 1000) + { + return 2; + } + vTaskDelay(5 / portTICK_PERIOD_MS); + } while (temp != 0x00); + + return ret; +} + +int ov5640_manual_focus_set(sensor_t *sensor, uint16_t focusLevel) +{ + int ret = 0; + + uint8_t pd = 0; + uint8_t slew_rate = 0x04; + uint16_t vcm_target = focusLevel & 0x03ff; + uint16_t vcm_rdiv = 0x0605; + uint8_t vcm_rih = 0; + uint8_t vcm_ib = 0x07; + + uint8_t vcm_ctrl_0 = ((vcm_target & 0x0f) << 4) | (slew_rate & 0x0f); + uint8_t vcm_ctrl_1 = ((pd & 0x01) << 7) | ((vcm_target >> 4) & 0x3f); + uint8_t vcm_ctrl_2 = vcm_rdiv & 0xff; + uint8_t vcm_ctrl_3 = ((vcm_rih & 0x01) << 4) | ((vcm_rdiv >> 8) & 0x0f); + uint8_t vcm_ctrl_4 = (vcm_ib & 0x07); + + ret |= sensor->set_reg(sensor, OV5640_VCM_CTRL_4, 0xff, vcm_ctrl_4); + ret |= sensor->set_reg(sensor, OV5640_VCM_CTRL_3, 0xff, vcm_ctrl_3); + ret |= sensor->set_reg(sensor, OV5640_VCM_CTRL_2, 0xff, vcm_ctrl_2); + ret |= sensor->set_reg(sensor, OV5640_VCM_CTRL_0, 0xff, vcm_ctrl_0); + ret |= sensor->set_reg(sensor, OV5640_VCM_CTRL_1, 0xff, vcm_ctrl_1); + + // Wait duration depends on slew rate. Our coil supply could be 2.8V, so + // we add another 100ms to make up for the lower voltage. + vTaskDelay(500 / portTICK_PERIOD_MS); + + return ret; +} + +int ov5640_manual_focus_release(sensor_t *sensor) +{ + int ret = 0; + + // Set focus back to infinity and wait for it to physically move before + // turning off the power to prevent clicking sound caused by the focus lens + // snapping to the permanent magnet when power is removed. + ret |= sensor->set_reg(sensor, OV5640_VCM_CTRL_1, 0x3f, 0); + ret |= sensor->set_reg(sensor, OV5640_VCM_CTRL_0, 0xf0, 0); + vTaskDelay(500 / portTICK_PERIOD_MS); + ret |= sensor->set_reg(sensor, OV5640_VCM_CTRL_1, 0x80, 1 << 7); + + return ret; +} + +uint16_t ov5640_get_focus_level(sensor_t *sensor) +{ + uint8_t vcm_ctrl_0 = sensor->get_reg(sensor, OV5640_VCM_CTRL_0, 0xff); + uint8_t vcm_ctrl_1 = sensor->get_reg(sensor, OV5640_VCM_CTRL_1, 0xff); + + uint16_t vcm_target = ((uint16_t)(vcm_ctrl_1 & 0x3f) << 4) | ((vcm_ctrl_0 & 0xf0) >> 4); + return vcm_target; +} + +void ov5640_print_vcm_registers(sensor_t *sensor) +{ + uint8_t vcm_ctrl_0 = sensor->get_reg(sensor, OV5640_VCM_CTRL_0, 0xff); + uint8_t vcm_ctrl_1 = sensor->get_reg(sensor, OV5640_VCM_CTRL_1, 0xff); + uint8_t vcm_ctrl_2 = sensor->get_reg(sensor, OV5640_VCM_CTRL_2, 0xff); + uint8_t vcm_ctrl_3 = sensor->get_reg(sensor, OV5640_VCM_CTRL_3, 0xff); + uint8_t vcm_ctrl_4 = sensor->get_reg(sensor, OV5640_VCM_CTRL_4, 0xff); + + uint8_t pwr_down = vcm_ctrl_1 >> 7; + uint16_t vcm_target = ((uint16_t)(vcm_ctrl_1 & 0x3f) << 4) | ((vcm_ctrl_0 & 0xf0) >> 4); + uint8_t slew_rate = vcm_ctrl_0 & 0x0f; + uint16_t vcm_rdiv = ((uint16_t)(vcm_ctrl_3 & 0x0f) << 8) | (vcm_ctrl_2 & 0xff); + uint8_t vcm_rih = (vcm_ctrl_3 & 0x10) >> 4; + uint8_t vcm_ib = vcm_ctrl_4 & 0x07; + + ESP_LOGI(TAG, "VCM: pd %x, target 0x%04x, slew 0x%02x, rdiv 0x%04x, rih %x, ib 0x%02x", pwr_down, vcm_target, slew_rate, vcm_rdiv, vcm_rih, vcm_ib); +} diff --git a/code/components/jomjol_controlcamera/ov5640_autofocus.h b/code/components/jomjol_controlcamera/ov5640_autofocus.h new file mode 100644 index 000000000..0ba3ed0ef --- /dev/null +++ b/code/components/jomjol_controlcamera/ov5640_autofocus.h @@ -0,0 +1,21 @@ +/* + Based on work created by Eric Nam, December 08, 2021. + Released into the public domain. +*/ +#pragma once + +#ifndef OV5640_AUTOFOCUS_H +#define OV5640_AUTOFOCUS_H + +#include "esp_camera.h" + +int ov5640_autofocus_init(sensor_t *sensor); +int ov5640_autofocus_set_mode(sensor_t *sensor, uint8_t mode); +int ov5640_autofocus_get_status(sensor_t *sensor, uint8_t *S_Zone, int S_Zone_len); +int ov5640_autofocus_release(sensor_t *sensor); +int ov5640_manual_focus_set(sensor_t *sensor, uint16_t focusLevel); +int ov5640_manual_focus_release(sensor_t *sensor); +uint16_t ov5640_get_focus_level(sensor_t *sensor); +void ov5640_print_vcm_registers(sensor_t *sensor); + +#endif diff --git a/code/components/jomjol_controlcamera/ov5640_autofocus_config.h b/code/components/jomjol_controlcamera/ov5640_autofocus_config.h new file mode 100644 index 000000000..e9abf8172 --- /dev/null +++ b/code/components/jomjol_controlcamera/ov5640_autofocus_config.h @@ -0,0 +1,308 @@ +/* + Based on work created by Eric Nam, December 08, 2021. + Released into the public domain. +*/ +#pragma once + +#ifndef OV5640_AUTOFOCUS_CONFIG_H +#define OV5640_AUTOFOCUS_CONFIG_H + +#include "esp_camera.h" + +#define OV5640_CHIPID_HIGH 0x300a +#define OV5640_CHIPID_LOW 0x300b + +#define OV5640_SYSTEM_RESET00 0x3000 + +#define OV5640_CMD_MAIN 0x3022 +#define OV5640_CMD_ACK 0x3023 +#define OV5640_CMD_PARA0 0x3024 +#define OV5640_CMD_PARA1 0x3025 +#define OV5640_CMD_PARA2 0x3026 +#define OV5640_CMD_PARA3 0x3027 +#define OV5640_CMD_PARA4 0x3028 +#define OV5640_CMD_FW_STATUS 0x3029 + +#define OV5640_VCM_CTRL_0 0x3602 +#define OV5640_VCM_CTRL_1 0x3603 +#define OV5640_VCM_CTRL_2 0x3604 +#define OV5640_VCM_CTRL_3 0x3605 +#define OV5640_VCM_CTRL_4 0x3606 + +#define ACK_CMD_COMPLETED 0x00 +#define ACK_CMD_RUNNING 0x01 + +#define AF_TRIG_SINGLE_AUTO_FOCUS 0x03 +#define AF_CONTINUE_AUTO_FOCUS 0x04 +#define AF_LOCK_FOCUS 0x06 +#define AF_RELEASE_FOCUS 0x08 +#define AF_RELAUNCH_FOCUS_ZONES 0x12 + +#define FW_STATUS_S_FIRMWARE 0x7F +#define FW_STATUS_S_STARTUP 0x7E +#define FW_STATUS_S_IDLE 0x70 +#define FW_STATUS_S_FOCUSED 0x10 +#define FW_STATUS_S_ZONE_CONFIG 0x16 +#define FW_STATUS_S_FOCUSING 0x00 //0x00 - 0X0F, 0x80 - 0X8F + +// Microcode comes from https://github.com/D3Engineering/linux_kernel_qcomlt/blob/d3/release/ov5640_4.9.27/drivers/media/i2c/ov5640.c +const unsigned char OV5640_AF_Config[] = +{ + 0x02, 0x0f, 0xd6, 0x02, 0x0a, 0x39, 0xc2, 0x01, 0x22, 0x22, 0x00, 0x02, 0x0f, 0xb2, 0xe5, 0x1f, //0x8000, + 0x70, 0x72, 0xf5, 0x1e, 0xd2, 0x35, 0xff, 0xef, 0x25, 0xe0, 0x24, 0x4e, 0xf8, 0xe4, 0xf6, 0x08, //0x8010, + 0xf6, 0x0f, 0xbf, 0x34, 0xf2, 0x90, 0x0e, 0x93, 0xe4, 0x93, 0xff, 0xe5, 0x4b, 0xc3, 0x9f, 0x50, //0x8020, + 0x04, 0x7f, 0x05, 0x80, 0x02, 0x7f, 0xfb, 0x78, 0xbd, 0xa6, 0x07, 0x12, 0x0f, 0x04, 0x40, 0x04, //0x8030, + 0x7f, 0x03, 0x80, 0x02, 0x7f, 0x30, 0x78, 0xbc, 0xa6, 0x07, 0xe6, 0x18, 0xf6, 0x08, 0xe6, 0x78, //0x8040, + 0xb9, 0xf6, 0x78, 0xbc, 0xe6, 0x78, 0xba, 0xf6, 0x78, 0xbf, 0x76, 0x33, 0xe4, 0x08, 0xf6, 0x78, //0x8050, + 0xb8, 0x76, 0x01, 0x75, 0x4a, 0x02, 0x78, 0xb6, 0xf6, 0x08, 0xf6, 0x74, 0xff, 0x78, 0xc1, 0xf6, //0x8060, + 0x08, 0xf6, 0x75, 0x1f, 0x01, 0x78, 0xbc, 0xe6, 0x75, 0xf0, 0x05, 0xa4, 0xf5, 0x4b, 0x12, 0x0a, //0x8070, + 0xff, 0xc2, 0x37, 0x22, 0x78, 0xb8, 0xe6, 0xd3, 0x94, 0x00, 0x40, 0x02, 0x16, 0x22, 0xe5, 0x1f, //0x8080, + 0xb4, 0x05, 0x23, 0xe4, 0xf5, 0x1f, 0xc2, 0x01, 0x78, 0xb6, 0xe6, 0xfe, 0x08, 0xe6, 0xff, 0x78, //0x8090, + 0x4e, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0xa2, 0x37, 0xe4, 0x33, 0xf5, 0x3c, 0x90, 0x30, 0x28, 0xf0, //0x80a0, + 0x75, 0x1e, 0x10, 0xd2, 0x35, 0x22, 0xe5, 0x4b, 0x75, 0xf0, 0x05, 0x84, 0x78, 0xbc, 0xf6, 0x90, //0x80b0, + 0x0e, 0x8c, 0xe4, 0x93, 0xff, 0x25, 0xe0, 0x24, 0x0a, 0xf8, 0xe6, 0xfc, 0x08, 0xe6, 0xfd, 0x78, //0x80c0, + 0xbc, 0xe6, 0x25, 0xe0, 0x24, 0x4e, 0xf8, 0xa6, 0x04, 0x08, 0xa6, 0x05, 0xef, 0x12, 0x0f, 0x0b, //0x80d0, + 0xd3, 0x78, 0xb7, 0x96, 0xee, 0x18, 0x96, 0x40, 0x0d, 0x78, 0xbc, 0xe6, 0x78, 0xb9, 0xf6, 0x78, //0x80e0, + 0xb6, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0x90, 0x0e, 0x8c, 0xe4, 0x93, 0x12, 0x0f, 0x0b, 0xc3, 0x78, //0x80f0, + 0xc2, 0x96, 0xee, 0x18, 0x96, 0x50, 0x0d, 0x78, 0xbc, 0xe6, 0x78, 0xba, 0xf6, 0x78, 0xc1, 0xa6, //0x8100, + 0x06, 0x08, 0xa6, 0x07, 0x78, 0xb6, 0xe6, 0xfe, 0x08, 0xe6, 0xc3, 0x78, 0xc2, 0x96, 0xff, 0xee, //0x8110, + 0x18, 0x96, 0x78, 0xc3, 0xf6, 0x08, 0xa6, 0x07, 0x90, 0x0e, 0x95, 0xe4, 0x18, 0x12, 0x0e, 0xe9, //0x8120, + 0x40, 0x02, 0xd2, 0x37, 0x78, 0xbc, 0xe6, 0x08, 0x26, 0x08, 0xf6, 0xe5, 0x1f, 0x64, 0x01, 0x70, //0x8130, + 0x4a, 0xe6, 0xc3, 0x78, 0xc0, 0x12, 0x0e, 0xdf, 0x40, 0x05, 0x12, 0x0e, 0xda, 0x40, 0x39, 0x12, //0x8140, + 0x0f, 0x02, 0x40, 0x04, 0x7f, 0xfe, 0x80, 0x02, 0x7f, 0x02, 0x78, 0xbd, 0xa6, 0x07, 0x78, 0xb9, //0x8150, + 0xe6, 0x24, 0x03, 0x78, 0xbf, 0xf6, 0x78, 0xb9, 0xe6, 0x24, 0xfd, 0x78, 0xc0, 0xf6, 0x12, 0x0f, //0x8160, + 0x02, 0x40, 0x06, 0x78, 0xc0, 0xe6, 0xff, 0x80, 0x04, 0x78, 0xbf, 0xe6, 0xff, 0x78, 0xbe, 0xa6, //0x8170, + 0x07, 0x75, 0x1f, 0x02, 0x78, 0xb8, 0x76, 0x01, 0x02, 0x02, 0x4a, 0xe5, 0x1f, 0x64, 0x02, 0x60, //0x8180, + 0x03, 0x02, 0x02, 0x2a, 0x78, 0xbe, 0xe6, 0xff, 0xc3, 0x78, 0xc0, 0x12, 0x0e, 0xe0, 0x40, 0x08, //0x8190, + 0x12, 0x0e, 0xda, 0x50, 0x03, 0x02, 0x02, 0x28, 0x12, 0x0f, 0x02, 0x40, 0x04, 0x7f, 0xff, 0x80, //0x81a0, + 0x02, 0x7f, 0x01, 0x78, 0xbd, 0xa6, 0x07, 0x78, 0xb9, 0xe6, 0x04, 0x78, 0xbf, 0xf6, 0x78, 0xb9, //0x81b0, + 0xe6, 0x14, 0x78, 0xc0, 0xf6, 0x18, 0x12, 0x0f, 0x04, 0x40, 0x04, 0xe6, 0xff, 0x80, 0x02, 0x7f, //0x81c0, + 0x00, 0x78, 0xbf, 0xa6, 0x07, 0xd3, 0x08, 0xe6, 0x64, 0x80, 0x94, 0x80, 0x40, 0x04, 0xe6, 0xff, //0x81d0, + 0x80, 0x02, 0x7f, 0x00, 0x78, 0xc0, 0xa6, 0x07, 0xc3, 0x18, 0xe6, 0x64, 0x80, 0x94, 0xb3, 0x50, //0x81e0, + 0x04, 0xe6, 0xff, 0x80, 0x02, 0x7f, 0x33, 0x78, 0xbf, 0xa6, 0x07, 0xc3, 0x08, 0xe6, 0x64, 0x80, //0x81f0, + 0x94, 0xb3, 0x50, 0x04, 0xe6, 0xff, 0x80, 0x02, 0x7f, 0x33, 0x78, 0xc0, 0xa6, 0x07, 0x12, 0x0f, //0x8200, + 0x02, 0x40, 0x06, 0x78, 0xc0, 0xe6, 0xff, 0x80, 0x04, 0x78, 0xbf, 0xe6, 0xff, 0x78, 0xbe, 0xa6, //0x8210, + 0x07, 0x75, 0x1f, 0x03, 0x78, 0xb8, 0x76, 0x01, 0x80, 0x20, 0xe5, 0x1f, 0x64, 0x03, 0x70, 0x26, //0x8220, + 0x78, 0xbe, 0xe6, 0xff, 0xc3, 0x78, 0xc0, 0x12, 0x0e, 0xe0, 0x40, 0x05, 0x12, 0x0e, 0xda, 0x40, //0x8230, + 0x09, 0x78, 0xb9, 0xe6, 0x78, 0xbe, 0xf6, 0x75, 0x1f, 0x04, 0x78, 0xbe, 0xe6, 0x75, 0xf0, 0x05, //0x8240, + 0xa4, 0xf5, 0x4b, 0x02, 0x0a, 0xff, 0xe5, 0x1f, 0xb4, 0x04, 0x10, 0x90, 0x0e, 0x94, 0xe4, 0x78, //0x8250, + 0xc3, 0x12, 0x0e, 0xe9, 0x40, 0x02, 0xd2, 0x37, 0x75, 0x1f, 0x05, 0x22, 0x30, 0x01, 0x03, 0x02, //0x8260, + 0x04, 0xc0, 0x30, 0x02, 0x03, 0x02, 0x04, 0xc0, 0x90, 0x51, 0xa5, 0xe0, 0x78, 0x93, 0xf6, 0xa3, //0x8270, + 0xe0, 0x08, 0xf6, 0xa3, 0xe0, 0x08, 0xf6, 0xe5, 0x1f, 0x70, 0x3c, 0x75, 0x1e, 0x20, 0xd2, 0x35, //0x8280, + 0x12, 0x0c, 0x7a, 0x78, 0x7e, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0x78, 0x8b, 0xa6, 0x09, 0x18, 0x76, //0x8290, + 0x01, 0x12, 0x0c, 0x5b, 0x78, 0x4e, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0x78, 0x8b, 0xe6, 0x78, 0x6e, //0x82a0, + 0xf6, 0x75, 0x1f, 0x01, 0x78, 0x93, 0xe6, 0x78, 0x90, 0xf6, 0x78, 0x94, 0xe6, 0x78, 0x91, 0xf6, //0x82b0, + 0x78, 0x95, 0xe6, 0x78, 0x92, 0xf6, 0x22, 0x79, 0x90, 0xe7, 0xd3, 0x78, 0x93, 0x96, 0x40, 0x05, //0x82c0, + 0xe7, 0x96, 0xff, 0x80, 0x08, 0xc3, 0x79, 0x93, 0xe7, 0x78, 0x90, 0x96, 0xff, 0x78, 0x88, 0x76, //0x82d0, + 0x00, 0x08, 0xa6, 0x07, 0x79, 0x91, 0xe7, 0xd3, 0x78, 0x94, 0x96, 0x40, 0x05, 0xe7, 0x96, 0xff, //0x82e0, + 0x80, 0x08, 0xc3, 0x79, 0x94, 0xe7, 0x78, 0x91, 0x96, 0xff, 0x12, 0x0c, 0x8e, 0x79, 0x92, 0xe7, //0x82f0, + 0xd3, 0x78, 0x95, 0x96, 0x40, 0x05, 0xe7, 0x96, 0xff, 0x80, 0x08, 0xc3, 0x79, 0x95, 0xe7, 0x78, //0x8300, + 0x92, 0x96, 0xff, 0x12, 0x0c, 0x8e, 0x12, 0x0c, 0x5b, 0x78, 0x8a, 0xe6, 0x25, 0xe0, 0x24, 0x4e, //0x8310, + 0xf8, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0x78, 0x8a, 0xe6, 0x24, 0x6e, 0xf8, 0xa6, 0x09, 0x78, 0x8a, //0x8320, + 0xe6, 0x24, 0x01, 0xff, 0xe4, 0x33, 0xfe, 0xd3, 0xef, 0x94, 0x0f, 0xee, 0x64, 0x80, 0x94, 0x80, //0x8330, + 0x40, 0x04, 0x7f, 0x00, 0x80, 0x05, 0x78, 0x8a, 0xe6, 0x04, 0xff, 0x78, 0x8a, 0xa6, 0x07, 0xe5, //0x8340, + 0x1f, 0xb4, 0x01, 0x0a, 0xe6, 0x60, 0x03, 0x02, 0x04, 0xc0, 0x75, 0x1f, 0x02, 0x22, 0x12, 0x0c, //0x8350, + 0x7a, 0x78, 0x80, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0x12, 0x0c, 0x7a, 0x78, 0x82, 0xa6, 0x06, 0x08, //0x8360, + 0xa6, 0x07, 0x78, 0x6e, 0xe6, 0x78, 0x8c, 0xf6, 0x78, 0x6e, 0xe6, 0x78, 0x8d, 0xf6, 0x7f, 0x01, //0x8370, + 0xef, 0x25, 0xe0, 0x24, 0x4f, 0xf9, 0xc3, 0x78, 0x81, 0xe6, 0x97, 0x18, 0xe6, 0x19, 0x97, 0x50, //0x8380, + 0x0a, 0x12, 0x0c, 0x82, 0x78, 0x80, 0xa6, 0x04, 0x08, 0xa6, 0x05, 0x74, 0x6e, 0x2f, 0xf9, 0x78, //0x8390, + 0x8c, 0xe6, 0xc3, 0x97, 0x50, 0x08, 0x74, 0x6e, 0x2f, 0xf8, 0xe6, 0x78, 0x8c, 0xf6, 0xef, 0x25, //0x83a0, + 0xe0, 0x24, 0x4f, 0xf9, 0xd3, 0x78, 0x83, 0xe6, 0x97, 0x18, 0xe6, 0x19, 0x97, 0x40, 0x0a, 0x12, //0x83b0, + 0x0c, 0x82, 0x78, 0x82, 0xa6, 0x04, 0x08, 0xa6, 0x05, 0x74, 0x6e, 0x2f, 0xf9, 0x78, 0x8d, 0xe6, //0x83c0, + 0xd3, 0x97, 0x40, 0x08, 0x74, 0x6e, 0x2f, 0xf8, 0xe6, 0x78, 0x8d, 0xf6, 0x0f, 0xef, 0x64, 0x10, //0x83d0, + 0x70, 0x9e, 0xc3, 0x79, 0x81, 0xe7, 0x78, 0x83, 0x96, 0xff, 0x19, 0xe7, 0x18, 0x96, 0x78, 0x84, //0x83e0, + 0xf6, 0x08, 0xa6, 0x07, 0xc3, 0x79, 0x8c, 0xe7, 0x78, 0x8d, 0x96, 0x08, 0xf6, 0xd3, 0x79, 0x81, //0x83f0, + 0xe7, 0x78, 0x7f, 0x96, 0x19, 0xe7, 0x18, 0x96, 0x40, 0x05, 0x09, 0xe7, 0x08, 0x80, 0x06, 0xc3, //0x8400, + 0x79, 0x7f, 0xe7, 0x78, 0x81, 0x96, 0xff, 0x19, 0xe7, 0x18, 0x96, 0xfe, 0x78, 0x86, 0xa6, 0x06, //0x8410, + 0x08, 0xa6, 0x07, 0x79, 0x8c, 0xe7, 0xd3, 0x78, 0x8b, 0x96, 0x40, 0x05, 0xe7, 0x96, 0xff, 0x80, //0x8420, + 0x08, 0xc3, 0x79, 0x8b, 0xe7, 0x78, 0x8c, 0x96, 0xff, 0x78, 0x8f, 0xa6, 0x07, 0xe5, 0x1f, 0x64, //0x8430, + 0x02, 0x70, 0x69, 0x90, 0x0e, 0x91, 0x93, 0xff, 0x18, 0xe6, 0xc3, 0x9f, 0x50, 0x72, 0x12, 0x0c, //0x8440, + 0x4a, 0x12, 0x0c, 0x2f, 0x90, 0x0e, 0x8e, 0x12, 0x0c, 0x38, 0x78, 0x80, 0x12, 0x0c, 0x6b, 0x7b, //0x8450, + 0x04, 0x12, 0x0c, 0x1d, 0xc3, 0x12, 0x06, 0x45, 0x50, 0x56, 0x90, 0x0e, 0x92, 0xe4, 0x93, 0xff, //0x8460, + 0x78, 0x8f, 0xe6, 0x9f, 0x40, 0x02, 0x80, 0x11, 0x90, 0x0e, 0x90, 0xe4, 0x93, 0xff, 0xd3, 0x78, //0x8470, + 0x89, 0xe6, 0x9f, 0x18, 0xe6, 0x94, 0x00, 0x40, 0x03, 0x75, 0x1f, 0x05, 0x12, 0x0c, 0x4a, 0x12, //0x8480, + 0x0c, 0x2f, 0x90, 0x0e, 0x8f, 0x12, 0x0c, 0x38, 0x78, 0x7e, 0x12, 0x0c, 0x6b, 0x7b, 0x40, 0x12, //0x8490, + 0x0c, 0x1d, 0xd3, 0x12, 0x06, 0x45, 0x40, 0x18, 0x75, 0x1f, 0x05, 0x22, 0xe5, 0x1f, 0xb4, 0x05, //0x84a0, + 0x0f, 0xd2, 0x01, 0xc2, 0x02, 0xe4, 0xf5, 0x1f, 0xf5, 0x1e, 0xd2, 0x35, 0xd2, 0x33, 0xd2, 0x36, //0x84b0, + 0x22, 0xef, 0x8d, 0xf0, 0xa4, 0xa8, 0xf0, 0xcf, 0x8c, 0xf0, 0xa4, 0x28, 0xce, 0x8d, 0xf0, 0xa4, //0x84c0, + 0x2e, 0xfe, 0x22, 0xbc, 0x00, 0x0b, 0xbe, 0x00, 0x29, 0xef, 0x8d, 0xf0, 0x84, 0xff, 0xad, 0xf0, //0x84d0, + 0x22, 0xe4, 0xcc, 0xf8, 0x75, 0xf0, 0x08, 0xef, 0x2f, 0xff, 0xee, 0x33, 0xfe, 0xec, 0x33, 0xfc, //0x84e0, + 0xee, 0x9d, 0xec, 0x98, 0x40, 0x05, 0xfc, 0xee, 0x9d, 0xfe, 0x0f, 0xd5, 0xf0, 0xe9, 0xe4, 0xce, //0x84f0, + 0xfd, 0x22, 0xed, 0xf8, 0xf5, 0xf0, 0xee, 0x84, 0x20, 0xd2, 0x1c, 0xfe, 0xad, 0xf0, 0x75, 0xf0, //0x8500, + 0x08, 0xef, 0x2f, 0xff, 0xed, 0x33, 0xfd, 0x40, 0x07, 0x98, 0x50, 0x06, 0xd5, 0xf0, 0xf2, 0x22, //0x8510, + 0xc3, 0x98, 0xfd, 0x0f, 0xd5, 0xf0, 0xea, 0x22, 0xe8, 0x8f, 0xf0, 0xa4, 0xcc, 0x8b, 0xf0, 0xa4, //0x8520, + 0x2c, 0xfc, 0xe9, 0x8e, 0xf0, 0xa4, 0x2c, 0xfc, 0x8a, 0xf0, 0xed, 0xa4, 0x2c, 0xfc, 0xea, 0x8e, //0x8530, + 0xf0, 0xa4, 0xcd, 0xa8, 0xf0, 0x8b, 0xf0, 0xa4, 0x2d, 0xcc, 0x38, 0x25, 0xf0, 0xfd, 0xe9, 0x8f, //0x8540, + 0xf0, 0xa4, 0x2c, 0xcd, 0x35, 0xf0, 0xfc, 0xeb, 0x8e, 0xf0, 0xa4, 0xfe, 0xa9, 0xf0, 0xeb, 0x8f, //0x8550, + 0xf0, 0xa4, 0xcf, 0xc5, 0xf0, 0x2e, 0xcd, 0x39, 0xfe, 0xe4, 0x3c, 0xfc, 0xea, 0xa4, 0x2d, 0xce, //0x8560, + 0x35, 0xf0, 0xfd, 0xe4, 0x3c, 0xfc, 0x22, 0x75, 0xf0, 0x08, 0x75, 0x82, 0x00, 0xef, 0x2f, 0xff, //0x8570, + 0xee, 0x33, 0xfe, 0xcd, 0x33, 0xcd, 0xcc, 0x33, 0xcc, 0xc5, 0x82, 0x33, 0xc5, 0x82, 0x9b, 0xed, //0x8580, + 0x9a, 0xec, 0x99, 0xe5, 0x82, 0x98, 0x40, 0x0c, 0xf5, 0x82, 0xee, 0x9b, 0xfe, 0xed, 0x9a, 0xfd, //0x8590, + 0xec, 0x99, 0xfc, 0x0f, 0xd5, 0xf0, 0xd6, 0xe4, 0xce, 0xfb, 0xe4, 0xcd, 0xfa, 0xe4, 0xcc, 0xf9, //0x85a0, + 0xa8, 0x82, 0x22, 0xb8, 0x00, 0xc1, 0xb9, 0x00, 0x59, 0xba, 0x00, 0x2d, 0xec, 0x8b, 0xf0, 0x84, //0x85b0, + 0xcf, 0xce, 0xcd, 0xfc, 0xe5, 0xf0, 0xcb, 0xf9, 0x78, 0x18, 0xef, 0x2f, 0xff, 0xee, 0x33, 0xfe, //0x85c0, + 0xed, 0x33, 0xfd, 0xec, 0x33, 0xfc, 0xeb, 0x33, 0xfb, 0x10, 0xd7, 0x03, 0x99, 0x40, 0x04, 0xeb, //0x85d0, + 0x99, 0xfb, 0x0f, 0xd8, 0xe5, 0xe4, 0xf9, 0xfa, 0x22, 0x78, 0x18, 0xef, 0x2f, 0xff, 0xee, 0x33, //0x85e0, + 0xfe, 0xed, 0x33, 0xfd, 0xec, 0x33, 0xfc, 0xc9, 0x33, 0xc9, 0x10, 0xd7, 0x05, 0x9b, 0xe9, 0x9a, //0x85f0, + 0x40, 0x07, 0xec, 0x9b, 0xfc, 0xe9, 0x9a, 0xf9, 0x0f, 0xd8, 0xe0, 0xe4, 0xc9, 0xfa, 0xe4, 0xcc, //0x8600, + 0xfb, 0x22, 0x75, 0xf0, 0x10, 0xef, 0x2f, 0xff, 0xee, 0x33, 0xfe, 0xed, 0x33, 0xfd, 0xcc, 0x33, //0x8610, + 0xcc, 0xc8, 0x33, 0xc8, 0x10, 0xd7, 0x07, 0x9b, 0xec, 0x9a, 0xe8, 0x99, 0x40, 0x0a, 0xed, 0x9b, //0x8620, + 0xfd, 0xec, 0x9a, 0xfc, 0xe8, 0x99, 0xf8, 0x0f, 0xd5, 0xf0, 0xda, 0xe4, 0xcd, 0xfb, 0xe4, 0xcc, //0x8630, + 0xfa, 0xe4, 0xc8, 0xf9, 0x22, 0xeb, 0x9f, 0xf5, 0xf0, 0xea, 0x9e, 0x42, 0xf0, 0xe9, 0x9d, 0x42, //0x8640, + 0xf0, 0xe8, 0x9c, 0x45, 0xf0, 0x22, 0xe8, 0x60, 0x0f, 0xec, 0xc3, 0x13, 0xfc, 0xed, 0x13, 0xfd, //0x8650, + 0xee, 0x13, 0xfe, 0xef, 0x13, 0xff, 0xd8, 0xf1, 0x22, 0xe8, 0x60, 0x0f, 0xef, 0xc3, 0x33, 0xff, //0x8660, + 0xee, 0x33, 0xfe, 0xed, 0x33, 0xfd, 0xec, 0x33, 0xfc, 0xd8, 0xf1, 0x22, 0xe4, 0x93, 0xfc, 0x74, //0x8670, + 0x01, 0x93, 0xfd, 0x74, 0x02, 0x93, 0xfe, 0x74, 0x03, 0x93, 0xff, 0x22, 0xe6, 0xfb, 0x08, 0xe6, //0x8680, + 0xf9, 0x08, 0xe6, 0xfa, 0x08, 0xe6, 0xcb, 0xf8, 0x22, 0xec, 0xf6, 0x08, 0xed, 0xf6, 0x08, 0xee, //0x8690, + 0xf6, 0x08, 0xef, 0xf6, 0x22, 0xa4, 0x25, 0x82, 0xf5, 0x82, 0xe5, 0xf0, 0x35, 0x83, 0xf5, 0x83, //0x86a0, + 0x22, 0xd0, 0x83, 0xd0, 0x82, 0xf8, 0xe4, 0x93, 0x70, 0x12, 0x74, 0x01, 0x93, 0x70, 0x0d, 0xa3, //0x86b0, + 0xa3, 0x93, 0xf8, 0x74, 0x01, 0x93, 0xf5, 0x82, 0x88, 0x83, 0xe4, 0x73, 0x74, 0x02, 0x93, 0x68, //0x86c0, + 0x60, 0xef, 0xa3, 0xa3, 0xa3, 0x80, 0xdf, 0x90, 0x38, 0x04, 0x78, 0x52, 0x12, 0x0b, 0xfd, 0x90, //0x86d0, + 0x38, 0x00, 0xe0, 0xfe, 0xa3, 0xe0, 0xfd, 0xed, 0xff, 0xc3, 0x12, 0x0b, 0x9e, 0x90, 0x38, 0x10, //0x86e0, + 0x12, 0x0b, 0x92, 0x90, 0x38, 0x06, 0x78, 0x54, 0x12, 0x0b, 0xfd, 0x90, 0x38, 0x02, 0xe0, 0xfe, //0x86f0, + 0xa3, 0xe0, 0xfd, 0xed, 0xff, 0xc3, 0x12, 0x0b, 0x9e, 0x90, 0x38, 0x12, 0x12, 0x0b, 0x92, 0xa3, //0x8700, + 0xe0, 0xb4, 0x31, 0x07, 0x78, 0x52, 0x79, 0x52, 0x12, 0x0c, 0x13, 0x90, 0x38, 0x14, 0xe0, 0xb4, //0x8710, + 0x71, 0x15, 0x78, 0x52, 0xe6, 0xfe, 0x08, 0xe6, 0x78, 0x02, 0xce, 0xc3, 0x13, 0xce, 0x13, 0xd8, //0x8720, + 0xf9, 0x79, 0x53, 0xf7, 0xee, 0x19, 0xf7, 0x90, 0x38, 0x15, 0xe0, 0xb4, 0x31, 0x07, 0x78, 0x54, //0x8730, + 0x79, 0x54, 0x12, 0x0c, 0x13, 0x90, 0x38, 0x15, 0xe0, 0xb4, 0x71, 0x15, 0x78, 0x54, 0xe6, 0xfe, //0x8740, + 0x08, 0xe6, 0x78, 0x02, 0xce, 0xc3, 0x13, 0xce, 0x13, 0xd8, 0xf9, 0x79, 0x55, 0xf7, 0xee, 0x19, //0x8750, + 0xf7, 0x79, 0x52, 0x12, 0x0b, 0xd9, 0x09, 0x12, 0x0b, 0xd9, 0xaf, 0x47, 0x12, 0x0b, 0xb2, 0xe5, //0x8760, + 0x44, 0xfb, 0x7a, 0x00, 0xfd, 0x7c, 0x00, 0x12, 0x04, 0xd3, 0x78, 0x5a, 0xa6, 0x06, 0x08, 0xa6, //0x8770, + 0x07, 0xaf, 0x45, 0x12, 0x0b, 0xb2, 0xad, 0x03, 0x7c, 0x00, 0x12, 0x04, 0xd3, 0x78, 0x56, 0xa6, //0x8780, + 0x06, 0x08, 0xa6, 0x07, 0xaf, 0x48, 0x78, 0x54, 0x12, 0x0b, 0xb4, 0xe5, 0x43, 0xfb, 0xfd, 0x7c, //0x8790, + 0x00, 0x12, 0x04, 0xd3, 0x78, 0x5c, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0xaf, 0x46, 0x7e, 0x00, 0x78, //0x87a0, + 0x54, 0x12, 0x0b, 0xb6, 0xad, 0x03, 0x7c, 0x00, 0x12, 0x04, 0xd3, 0x78, 0x58, 0xa6, 0x06, 0x08, //0x87b0, + 0xa6, 0x07, 0xc3, 0x78, 0x5b, 0xe6, 0x94, 0x08, 0x18, 0xe6, 0x94, 0x00, 0x50, 0x05, 0x76, 0x00, //0x87c0, + 0x08, 0x76, 0x08, 0xc3, 0x78, 0x5d, 0xe6, 0x94, 0x08, 0x18, 0xe6, 0x94, 0x00, 0x50, 0x05, 0x76, //0x87d0, + 0x00, 0x08, 0x76, 0x08, 0x78, 0x5a, 0x12, 0x0b, 0xc6, 0xff, 0xd3, 0x78, 0x57, 0xe6, 0x9f, 0x18, //0x87e0, + 0xe6, 0x9e, 0x40, 0x0e, 0x78, 0x5a, 0xe6, 0x13, 0xfe, 0x08, 0xe6, 0x78, 0x57, 0x12, 0x0c, 0x08, //0x87f0, + 0x80, 0x04, 0x7e, 0x00, 0x7f, 0x00, 0x78, 0x5e, 0x12, 0x0b, 0xbe, 0xff, 0xd3, 0x78, 0x59, 0xe6, //0x8800, + 0x9f, 0x18, 0xe6, 0x9e, 0x40, 0x0e, 0x78, 0x5c, 0xe6, 0x13, 0xfe, 0x08, 0xe6, 0x78, 0x59, 0x12, //0x8810, + 0x0c, 0x08, 0x80, 0x04, 0x7e, 0x00, 0x7f, 0x00, 0xe4, 0xfc, 0xfd, 0x78, 0x62, 0x12, 0x06, 0x99, //0x8820, + 0x78, 0x5a, 0x12, 0x0b, 0xc6, 0x78, 0x57, 0x26, 0xff, 0xee, 0x18, 0x36, 0xfe, 0x78, 0x66, 0x12, //0x8830, + 0x0b, 0xbe, 0x78, 0x59, 0x26, 0xff, 0xee, 0x18, 0x36, 0xfe, 0xe4, 0xfc, 0xfd, 0x78, 0x6a, 0x12, //0x8840, + 0x06, 0x99, 0x12, 0x0b, 0xce, 0x78, 0x66, 0x12, 0x06, 0x8c, 0xd3, 0x12, 0x06, 0x45, 0x40, 0x08, //0x8850, + 0x12, 0x0b, 0xce, 0x78, 0x66, 0x12, 0x06, 0x99, 0x78, 0x54, 0x12, 0x0b, 0xd0, 0x78, 0x6a, 0x12, //0x8860, + 0x06, 0x8c, 0xd3, 0x12, 0x06, 0x45, 0x40, 0x0a, 0x78, 0x54, 0x12, 0x0b, 0xd0, 0x78, 0x6a, 0x12, //0x8870, + 0x06, 0x99, 0x78, 0x61, 0xe6, 0x90, 0x60, 0x01, 0xf0, 0x78, 0x65, 0xe6, 0xa3, 0xf0, 0x78, 0x69, //0x8880, + 0xe6, 0xa3, 0xf0, 0x78, 0x55, 0xe6, 0xa3, 0xf0, 0x7d, 0x01, 0x78, 0x61, 0x12, 0x0b, 0xe9, 0x24, //0x8890, + 0x01, 0x12, 0x0b, 0xa6, 0x78, 0x65, 0x12, 0x0b, 0xe9, 0x24, 0x02, 0x12, 0x0b, 0xa6, 0x78, 0x69, //0x88a0, + 0x12, 0x0b, 0xe9, 0x24, 0x03, 0x12, 0x0b, 0xa6, 0x78, 0x6d, 0x12, 0x0b, 0xe9, 0x24, 0x04, 0x12, //0x88b0, + 0x0b, 0xa6, 0x0d, 0xbd, 0x05, 0xd4, 0xc2, 0x0e, 0xc2, 0x06, 0x22, 0x85, 0x08, 0x41, 0x90, 0x30, //0x88c0, + 0x24, 0xe0, 0xf5, 0x3d, 0xa3, 0xe0, 0xf5, 0x3e, 0xa3, 0xe0, 0xf5, 0x3f, 0xa3, 0xe0, 0xf5, 0x40, //0x88d0, + 0xa3, 0xe0, 0xf5, 0x3c, 0xd2, 0x34, 0xe5, 0x41, 0x12, 0x06, 0xb1, 0x09, 0x31, 0x03, 0x09, 0x35, //0x88e0, + 0x04, 0x09, 0x3b, 0x05, 0x09, 0x3e, 0x06, 0x09, 0x41, 0x07, 0x09, 0x4a, 0x08, 0x09, 0x5b, 0x12, //0x88f0, + 0x09, 0x73, 0x18, 0x09, 0x89, 0x19, 0x09, 0x5e, 0x1a, 0x09, 0x6a, 0x1b, 0x09, 0xad, 0x80, 0x09, //0x8900, + 0xb2, 0x81, 0x0a, 0x1d, 0x8f, 0x0a, 0x09, 0x90, 0x0a, 0x1d, 0x91, 0x0a, 0x1d, 0x92, 0x0a, 0x1d, //0x8910, + 0x93, 0x0a, 0x1d, 0x94, 0x0a, 0x1d, 0x98, 0x0a, 0x17, 0x9f, 0x0a, 0x1a, 0xec, 0x00, 0x00, 0x0a, //0x8920, + 0x38, 0x12, 0x0f, 0x74, 0x22, 0x12, 0x0f, 0x74, 0xd2, 0x03, 0x22, 0xd2, 0x03, 0x22, 0xc2, 0x03, //0x8930, + 0x22, 0xa2, 0x37, 0xe4, 0x33, 0xf5, 0x3c, 0x02, 0x0a, 0x1d, 0xc2, 0x01, 0xc2, 0x02, 0xc2, 0x03, //0x8940, + 0x12, 0x0d, 0x0d, 0x75, 0x1e, 0x70, 0xd2, 0x35, 0x02, 0x0a, 0x1d, 0x02, 0x0a, 0x04, 0x85, 0x40, //0x8950, + 0x4a, 0x85, 0x3c, 0x4b, 0x12, 0x0a, 0xff, 0x02, 0x0a, 0x1d, 0x85, 0x4a, 0x40, 0x85, 0x4b, 0x3c, //0x8960, + 0x02, 0x0a, 0x1d, 0xe4, 0xf5, 0x22, 0xf5, 0x23, 0x85, 0x40, 0x31, 0x85, 0x3f, 0x30, 0x85, 0x3e, //0x8970, + 0x2f, 0x85, 0x3d, 0x2e, 0x12, 0x0f, 0x46, 0x80, 0x1f, 0x75, 0x22, 0x00, 0x75, 0x23, 0x01, 0x74, //0x8980, + 0xff, 0xf5, 0x2d, 0xf5, 0x2c, 0xf5, 0x2b, 0xf5, 0x2a, 0x12, 0x0f, 0x46, 0x85, 0x2d, 0x40, 0x85, //0x8990, + 0x2c, 0x3f, 0x85, 0x2b, 0x3e, 0x85, 0x2a, 0x3d, 0xe4, 0xf5, 0x3c, 0x80, 0x70, 0x12, 0x0f, 0x16, //0x89a0, + 0x80, 0x6b, 0x85, 0x3d, 0x45, 0x85, 0x3e, 0x46, 0xe5, 0x47, 0xc3, 0x13, 0xff, 0xe5, 0x45, 0xc3, //0x89b0, + 0x9f, 0x50, 0x02, 0x8f, 0x45, 0xe5, 0x48, 0xc3, 0x13, 0xff, 0xe5, 0x46, 0xc3, 0x9f, 0x50, 0x02, //0x89c0, + 0x8f, 0x46, 0xe5, 0x47, 0xc3, 0x13, 0xff, 0xfd, 0xe5, 0x45, 0x2d, 0xfd, 0xe4, 0x33, 0xfc, 0xe5, //0x89d0, + 0x44, 0x12, 0x0f, 0x90, 0x40, 0x05, 0xe5, 0x44, 0x9f, 0xf5, 0x45, 0xe5, 0x48, 0xc3, 0x13, 0xff, //0x89e0, + 0xfd, 0xe5, 0x46, 0x2d, 0xfd, 0xe4, 0x33, 0xfc, 0xe5, 0x43, 0x12, 0x0f, 0x90, 0x40, 0x05, 0xe5, //0x89f0, + 0x43, 0x9f, 0xf5, 0x46, 0x12, 0x06, 0xd7, 0x80, 0x14, 0x85, 0x40, 0x48, 0x85, 0x3f, 0x47, 0x85, //0x8a00, + 0x3e, 0x46, 0x85, 0x3d, 0x45, 0x80, 0x06, 0x02, 0x06, 0xd7, 0x12, 0x0d, 0x7e, 0x90, 0x30, 0x24, //0x8a10, + 0xe5, 0x3d, 0xf0, 0xa3, 0xe5, 0x3e, 0xf0, 0xa3, 0xe5, 0x3f, 0xf0, 0xa3, 0xe5, 0x40, 0xf0, 0xa3, //0x8a20, + 0xe5, 0x3c, 0xf0, 0x90, 0x30, 0x23, 0xe4, 0xf0, 0x22, 0xc0, 0xe0, 0xc0, 0x83, 0xc0, 0x82, 0xc0, //0x8a30, + 0xd0, 0x90, 0x3f, 0x0c, 0xe0, 0xf5, 0x32, 0xe5, 0x32, 0x30, 0xe3, 0x74, 0x30, 0x36, 0x66, 0x90, //0x8a40, + 0x60, 0x19, 0xe0, 0xf5, 0x0a, 0xa3, 0xe0, 0xf5, 0x0b, 0x90, 0x60, 0x1d, 0xe0, 0xf5, 0x14, 0xa3, //0x8a50, + 0xe0, 0xf5, 0x15, 0x90, 0x60, 0x21, 0xe0, 0xf5, 0x0c, 0xa3, 0xe0, 0xf5, 0x0d, 0x90, 0x60, 0x29, //0x8a60, + 0xe0, 0xf5, 0x0e, 0xa3, 0xe0, 0xf5, 0x0f, 0x90, 0x60, 0x31, 0xe0, 0xf5, 0x10, 0xa3, 0xe0, 0xf5, //0x8a70, + 0x11, 0x90, 0x60, 0x39, 0xe0, 0xf5, 0x12, 0xa3, 0xe0, 0xf5, 0x13, 0x30, 0x01, 0x06, 0x30, 0x33, //0x8a80, + 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92, 0x09, 0x30, 0x02, 0x06, 0x30, 0x33, 0x03, 0xd3, 0x80, 0x01, //0x8a90, + 0xc3, 0x92, 0x0a, 0x30, 0x33, 0x0c, 0x30, 0x03, 0x09, 0x20, 0x02, 0x06, 0x20, 0x01, 0x03, 0xd3, //0x8aa0, + 0x80, 0x01, 0xc3, 0x92, 0x0b, 0x90, 0x30, 0x01, 0xe0, 0x44, 0x40, 0xf0, 0xe0, 0x54, 0xbf, 0xf0, //0x8ab0, + 0xe5, 0x32, 0x30, 0xe1, 0x14, 0x30, 0x34, 0x11, 0x90, 0x30, 0x22, 0xe0, 0xf5, 0x08, 0xe4, 0xf0, //0x8ac0, + 0x30, 0x00, 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92, 0x08, 0xe5, 0x32, 0x30, 0xe5, 0x12, 0x90, 0x56, //0x8ad0, + 0xa1, 0xe0, 0xf5, 0x09, 0x30, 0x31, 0x09, 0x30, 0x05, 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92, 0x0d, //0x8ae0, + 0x90, 0x3f, 0x0c, 0xe5, 0x32, 0xf0, 0xd0, 0xd0, 0xd0, 0x82, 0xd0, 0x83, 0xd0, 0xe0, 0x32, 0x90, //0x8af0, + 0x0e, 0x7e, 0xe4, 0x93, 0xfe, 0x74, 0x01, 0x93, 0xff, 0xc3, 0x90, 0x0e, 0x7c, 0x74, 0x01, 0x93, //0x8b00, + 0x9f, 0xff, 0xe4, 0x93, 0x9e, 0xfe, 0xe4, 0x8f, 0x3b, 0x8e, 0x3a, 0xf5, 0x39, 0xf5, 0x38, 0xab, //0x8b10, + 0x3b, 0xaa, 0x3a, 0xa9, 0x39, 0xa8, 0x38, 0xaf, 0x4b, 0xfc, 0xfd, 0xfe, 0x12, 0x05, 0x28, 0x12, //0x8b20, + 0x0d, 0xe1, 0xe4, 0x7b, 0xff, 0xfa, 0xf9, 0xf8, 0x12, 0x05, 0xb3, 0x12, 0x0d, 0xe1, 0x90, 0x0e, //0x8b30, + 0x69, 0xe4, 0x12, 0x0d, 0xf6, 0x12, 0x0d, 0xe1, 0xe4, 0x85, 0x4a, 0x37, 0xf5, 0x36, 0xf5, 0x35, //0x8b40, + 0xf5, 0x34, 0xaf, 0x37, 0xae, 0x36, 0xad, 0x35, 0xac, 0x34, 0xa3, 0x12, 0x0d, 0xf6, 0x8f, 0x37, //0x8b50, + 0x8e, 0x36, 0x8d, 0x35, 0x8c, 0x34, 0xe5, 0x3b, 0x45, 0x37, 0xf5, 0x3b, 0xe5, 0x3a, 0x45, 0x36, //0x8b60, + 0xf5, 0x3a, 0xe5, 0x39, 0x45, 0x35, 0xf5, 0x39, 0xe5, 0x38, 0x45, 0x34, 0xf5, 0x38, 0xe4, 0xf5, //0x8b70, + 0x22, 0xf5, 0x23, 0x85, 0x3b, 0x31, 0x85, 0x3a, 0x30, 0x85, 0x39, 0x2f, 0x85, 0x38, 0x2e, 0x02, //0x8b80, + 0x0f, 0x46, 0xe0, 0xa3, 0xe0, 0x75, 0xf0, 0x02, 0xa4, 0xff, 0xae, 0xf0, 0xc3, 0x08, 0xe6, 0x9f, //0x8b90, + 0xf6, 0x18, 0xe6, 0x9e, 0xf6, 0x22, 0xff, 0xe5, 0xf0, 0x34, 0x60, 0x8f, 0x82, 0xf5, 0x83, 0xec, //0x8ba0, + 0xf0, 0x22, 0x78, 0x52, 0x7e, 0x00, 0xe6, 0xfc, 0x08, 0xe6, 0xfd, 0x02, 0x04, 0xc1, 0xe4, 0xfc, //0x8bb0, + 0xfd, 0x12, 0x06, 0x99, 0x78, 0x5c, 0xe6, 0xc3, 0x13, 0xfe, 0x08, 0xe6, 0x13, 0x22, 0x78, 0x52, //0x8bc0, + 0xe6, 0xfe, 0x08, 0xe6, 0xff, 0xe4, 0xfc, 0xfd, 0x22, 0xe7, 0xc4, 0xf8, 0x54, 0xf0, 0xc8, 0x68, //0x8bd0, + 0xf7, 0x09, 0xe7, 0xc4, 0x54, 0x0f, 0x48, 0xf7, 0x22, 0xe6, 0xfc, 0xed, 0x75, 0xf0, 0x04, 0xa4, //0x8be0, + 0x22, 0x12, 0x06, 0x7c, 0x8f, 0x48, 0x8e, 0x47, 0x8d, 0x46, 0x8c, 0x45, 0x22, 0xe0, 0xfe, 0xa3, //0x8bf0, + 0xe0, 0xfd, 0xee, 0xf6, 0xed, 0x08, 0xf6, 0x22, 0x13, 0xff, 0xc3, 0xe6, 0x9f, 0xff, 0x18, 0xe6, //0x8c00, + 0x9e, 0xfe, 0x22, 0xe6, 0xc3, 0x13, 0xf7, 0x08, 0xe6, 0x13, 0x09, 0xf7, 0x22, 0xad, 0x39, 0xac, //0x8c10, + 0x38, 0xfa, 0xf9, 0xf8, 0x12, 0x05, 0x28, 0x8f, 0x3b, 0x8e, 0x3a, 0x8d, 0x39, 0x8c, 0x38, 0xab, //0x8c20, + 0x37, 0xaa, 0x36, 0xa9, 0x35, 0xa8, 0x34, 0x22, 0x93, 0xff, 0xe4, 0xfc, 0xfd, 0xfe, 0x12, 0x05, //0x8c30, + 0x28, 0x8f, 0x37, 0x8e, 0x36, 0x8d, 0x35, 0x8c, 0x34, 0x22, 0x78, 0x84, 0xe6, 0xfe, 0x08, 0xe6, //0x8c40, + 0xff, 0xe4, 0x8f, 0x37, 0x8e, 0x36, 0xf5, 0x35, 0xf5, 0x34, 0x22, 0x90, 0x0e, 0x8c, 0xe4, 0x93, //0x8c50, + 0x25, 0xe0, 0x24, 0x0a, 0xf8, 0xe6, 0xfe, 0x08, 0xe6, 0xff, 0x22, 0xe6, 0xfe, 0x08, 0xe6, 0xff, //0x8c60, + 0xe4, 0x8f, 0x3b, 0x8e, 0x3a, 0xf5, 0x39, 0xf5, 0x38, 0x22, 0x78, 0x4e, 0xe6, 0xfe, 0x08, 0xe6, //0x8c70, + 0xff, 0x22, 0xef, 0x25, 0xe0, 0x24, 0x4e, 0xf8, 0xe6, 0xfc, 0x08, 0xe6, 0xfd, 0x22, 0x78, 0x89, //0x8c80, + 0xef, 0x26, 0xf6, 0x18, 0xe4, 0x36, 0xf6, 0x22, 0x75, 0x89, 0x03, 0x75, 0xa8, 0x01, 0x75, 0xb8, //0x8c90, + 0x04, 0x75, 0x34, 0xff, 0x75, 0x35, 0x0e, 0x75, 0x36, 0x15, 0x75, 0x37, 0x0d, 0x12, 0x0e, 0x9a, //0x8ca0, + 0x12, 0x00, 0x09, 0x12, 0x0f, 0x16, 0x12, 0x00, 0x06, 0xd2, 0x00, 0xd2, 0x34, 0xd2, 0xaf, 0x75, //0x8cb0, + 0x34, 0xff, 0x75, 0x35, 0x0e, 0x75, 0x36, 0x49, 0x75, 0x37, 0x03, 0x12, 0x0e, 0x9a, 0x30, 0x08, //0x8cc0, + 0x09, 0xc2, 0x34, 0x12, 0x08, 0xcb, 0xc2, 0x08, 0xd2, 0x34, 0x30, 0x0b, 0x09, 0xc2, 0x36, 0x12, //0x8cd0, + 0x02, 0x6c, 0xc2, 0x0b, 0xd2, 0x36, 0x30, 0x09, 0x09, 0xc2, 0x36, 0x12, 0x00, 0x0e, 0xc2, 0x09, //0x8ce0, + 0xd2, 0x36, 0x30, 0x0e, 0x03, 0x12, 0x06, 0xd7, 0x30, 0x35, 0xd3, 0x90, 0x30, 0x29, 0xe5, 0x1e, //0x8cf0, + 0xf0, 0xb4, 0x10, 0x05, 0x90, 0x30, 0x23, 0xe4, 0xf0, 0xc2, 0x35, 0x80, 0xc1, 0xe4, 0xf5, 0x4b, //0x8d00, + 0x90, 0x0e, 0x7a, 0x93, 0xff, 0xe4, 0x8f, 0x37, 0xf5, 0x36, 0xf5, 0x35, 0xf5, 0x34, 0xaf, 0x37, //0x8d10, + 0xae, 0x36, 0xad, 0x35, 0xac, 0x34, 0x90, 0x0e, 0x6a, 0x12, 0x0d, 0xf6, 0x8f, 0x37, 0x8e, 0x36, //0x8d20, + 0x8d, 0x35, 0x8c, 0x34, 0x90, 0x0e, 0x72, 0x12, 0x06, 0x7c, 0xef, 0x45, 0x37, 0xf5, 0x37, 0xee, //0x8d30, + 0x45, 0x36, 0xf5, 0x36, 0xed, 0x45, 0x35, 0xf5, 0x35, 0xec, 0x45, 0x34, 0xf5, 0x34, 0xe4, 0xf5, //0x8d40, + 0x22, 0xf5, 0x23, 0x85, 0x37, 0x31, 0x85, 0x36, 0x30, 0x85, 0x35, 0x2f, 0x85, 0x34, 0x2e, 0x12, //0x8d50, + 0x0f, 0x46, 0xe4, 0xf5, 0x22, 0xf5, 0x23, 0x90, 0x0e, 0x72, 0x12, 0x0d, 0xea, 0x12, 0x0f, 0x46, //0x8d60, + 0xe4, 0xf5, 0x22, 0xf5, 0x23, 0x90, 0x0e, 0x6e, 0x12, 0x0d, 0xea, 0x02, 0x0f, 0x46, 0xe5, 0x40, //0x8d70, + 0x24, 0xf2, 0xf5, 0x37, 0xe5, 0x3f, 0x34, 0x43, 0xf5, 0x36, 0xe5, 0x3e, 0x34, 0xa2, 0xf5, 0x35, //0x8d80, + 0xe5, 0x3d, 0x34, 0x28, 0xf5, 0x34, 0xe5, 0x37, 0xff, 0xe4, 0xfe, 0xfd, 0xfc, 0x78, 0x18, 0x12, //0x8d90, + 0x06, 0x69, 0x8f, 0x40, 0x8e, 0x3f, 0x8d, 0x3e, 0x8c, 0x3d, 0xe5, 0x37, 0x54, 0xa0, 0xff, 0xe5, //0x8da0, + 0x36, 0xfe, 0xe4, 0xfd, 0xfc, 0x78, 0x07, 0x12, 0x06, 0x56, 0x78, 0x10, 0x12, 0x0f, 0x9a, 0xe4, //0x8db0, + 0xff, 0xfe, 0xe5, 0x35, 0xfd, 0xe4, 0xfc, 0x78, 0x0e, 0x12, 0x06, 0x56, 0x12, 0x0f, 0x9d, 0xe4, //0x8dc0, + 0xff, 0xfe, 0xfd, 0xe5, 0x34, 0xfc, 0x78, 0x18, 0x12, 0x06, 0x56, 0x78, 0x08, 0x12, 0x0f, 0x9a, //0x8dd0, + 0x22, 0x8f, 0x3b, 0x8e, 0x3a, 0x8d, 0x39, 0x8c, 0x38, 0x22, 0x12, 0x06, 0x7c, 0x8f, 0x31, 0x8e, //0x8de0, + 0x30, 0x8d, 0x2f, 0x8c, 0x2e, 0x22, 0x93, 0xf9, 0xf8, 0x02, 0x06, 0x69, 0x00, 0x00, 0x00, 0x00, //0x8df0, + 0x12, 0x01, 0x17, 0x08, 0x31, 0x15, 0x53, 0x54, 0x44, 0x20, 0x20, 0x20, 0x20, 0x20, 0x13, 0x01, //0x8e00, + 0x10, 0x01, 0x56, 0x40, 0x1a, 0x30, 0x29, 0x7e, 0x00, 0x30, 0x04, 0x20, 0xdf, 0x30, 0x05, 0x40, //0x8e10, + 0xbf, 0x50, 0x03, 0x00, 0xfd, 0x50, 0x27, 0x01, 0xfe, 0x60, 0x00, 0x11, 0x00, 0x3f, 0x05, 0x30, //0x8e20, + 0x00, 0x3f, 0x06, 0x22, 0x00, 0x3f, 0x01, 0x2a, 0x00, 0x3f, 0x02, 0x00, 0x00, 0x36, 0x06, 0x07, //0x8e30, + 0x00, 0x3f, 0x0b, 0x0f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x30, 0x01, 0x40, 0xbf, 0x30, 0x01, 0x00, //0x8e40, + 0xbf, 0x30, 0x29, 0x70, 0x00, 0x3a, 0x00, 0x00, 0xff, 0x3a, 0x00, 0x00, 0xff, 0x36, 0x03, 0x36, //0x8e50, + 0x02, 0x41, 0x44, 0x58, 0x20, 0x18, 0x10, 0x0a, 0x04, 0x04, 0x00, 0x03, 0xff, 0x64, 0x00, 0x00, //0x8e60, + 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x06, 0x06, 0x00, 0x03, 0x51, 0x00, 0x7a, //0x8e70, + 0x50, 0x3c, 0x28, 0x1e, 0x10, 0x10, 0x50, 0x2d, 0x28, 0x16, 0x10, 0x10, 0x02, 0x00, 0x10, 0x0c, //0x8e80, + 0x10, 0x04, 0x0c, 0x6e, 0x06, 0x05, 0x00, 0xa5, 0x5a, 0x00, 0xae, 0x35, 0xaf, 0x36, 0xe4, 0xfd, //0x8e90, + 0xed, 0xc3, 0x95, 0x37, 0x50, 0x33, 0x12, 0x0f, 0xe2, 0xe4, 0x93, 0xf5, 0x38, 0x74, 0x01, 0x93, //0x8ea0, + 0xf5, 0x39, 0x45, 0x38, 0x60, 0x23, 0x85, 0x39, 0x82, 0x85, 0x38, 0x83, 0xe0, 0xfc, 0x12, 0x0f, //0x8eb0, + 0xe2, 0x74, 0x03, 0x93, 0x52, 0x04, 0x12, 0x0f, 0xe2, 0x74, 0x02, 0x93, 0x42, 0x04, 0x85, 0x39, //0x8ec0, + 0x82, 0x85, 0x38, 0x83, 0xec, 0xf0, 0x0d, 0x80, 0xc7, 0x22, 0x78, 0xbe, 0xe6, 0xd3, 0x08, 0xff, //0x8ed0, + 0xe6, 0x64, 0x80, 0xf8, 0xef, 0x64, 0x80, 0x98, 0x22, 0x93, 0xff, 0x7e, 0x00, 0xe6, 0xfc, 0x08, //0x8ee0, + 0xe6, 0xfd, 0x12, 0x04, 0xc1, 0x78, 0xc1, 0xe6, 0xfc, 0x08, 0xe6, 0xfd, 0xd3, 0xef, 0x9d, 0xee, //0x8ef0, + 0x9c, 0x22, 0x78, 0xbd, 0xd3, 0xe6, 0x64, 0x80, 0x94, 0x80, 0x22, 0x25, 0xe0, 0x24, 0x0a, 0xf8, //0x8f00, + 0xe6, 0xfe, 0x08, 0xe6, 0xff, 0x22, 0xe5, 0x3c, 0xd3, 0x94, 0x00, 0x40, 0x0b, 0x90, 0x0e, 0x88, //0x8f10, + 0x12, 0x0b, 0xf1, 0x90, 0x0e, 0x86, 0x80, 0x09, 0x90, 0x0e, 0x82, 0x12, 0x0b, 0xf1, 0x90, 0x0e, //0x8f20, + 0x80, 0xe4, 0x93, 0xf5, 0x44, 0xa3, 0xe4, 0x93, 0xf5, 0x43, 0xd2, 0x06, 0x30, 0x06, 0x03, 0xd3, //0x8f30, + 0x80, 0x01, 0xc3, 0x92, 0x0e, 0x22, 0xa2, 0xaf, 0x92, 0x32, 0xc2, 0xaf, 0xe5, 0x23, 0x45, 0x22, //0x8f40, + 0x90, 0x0e, 0x5d, 0x60, 0x0e, 0x12, 0x0f, 0xcb, 0xe0, 0xf5, 0x2c, 0x12, 0x0f, 0xc8, 0xe0, 0xf5, //0x8f50, + 0x2d, 0x80, 0x0c, 0x12, 0x0f, 0xcb, 0xe5, 0x30, 0xf0, 0x12, 0x0f, 0xc8, 0xe5, 0x31, 0xf0, 0xa2, //0x8f60, + 0x32, 0x92, 0xaf, 0x22, 0xd2, 0x01, 0xc2, 0x02, 0xe4, 0xf5, 0x1f, 0xf5, 0x1e, 0xd2, 0x35, 0xd2, //0x8f70, + 0x33, 0xd2, 0x36, 0xd2, 0x01, 0xc2, 0x02, 0xf5, 0x1f, 0xf5, 0x1e, 0xd2, 0x35, 0xd2, 0x33, 0x22, //0x8f80, + 0xfb, 0xd3, 0xed, 0x9b, 0x74, 0x80, 0xf8, 0x6c, 0x98, 0x22, 0x12, 0x06, 0x69, 0xe5, 0x40, 0x2f, //0x8f90, + 0xf5, 0x40, 0xe5, 0x3f, 0x3e, 0xf5, 0x3f, 0xe5, 0x3e, 0x3d, 0xf5, 0x3e, 0xe5, 0x3d, 0x3c, 0xf5, //0x8fa0, + 0x3d, 0x22, 0xc0, 0xe0, 0xc0, 0x83, 0xc0, 0x82, 0x90, 0x3f, 0x0d, 0xe0, 0xf5, 0x33, 0xe5, 0x33, //0x8fb0, + 0xf0, 0xd0, 0x82, 0xd0, 0x83, 0xd0, 0xe0, 0x32, 0x90, 0x0e, 0x5f, 0xe4, 0x93, 0xfe, 0x74, 0x01, //0x8fc0, + 0x93, 0xf5, 0x82, 0x8e, 0x83, 0x22, 0x78, 0x7f, 0xe4, 0xf6, 0xd8, 0xfd, 0x75, 0x81, 0xcd, 0x02, //0x8fd0, + 0x0c, 0x98, 0x8f, 0x82, 0x8e, 0x83, 0x75, 0xf0, 0x04, 0xed, 0x02, 0x06, 0xa5, //0x8fe0 +}; + +#endif diff --git a/code/components/jomjol_controlcamera/server_camera.cpp b/code/components/jomjol_controlcamera/server_camera.cpp index d79fbcdb7..5be4b09db 100644 --- a/code/components/jomjol_controlcamera/server_camera.cpp +++ b/code/components/jomjol_controlcamera/server_camera.cpp @@ -98,15 +98,6 @@ esp_err_t handler_capture(httpd_req_t *req) if (Camera.getCameraInitSuccessful()) { - // If the camera settings were changed by creating a new reference image, they must be reset - if (CFstatus.changedCameraSettings) - { - Camera.setSensorDatenFromCCstatus(); // CCstatus >>> Kamera - Camera.SetQualityZoomSize(CCstatus.ImageQuality, CCstatus.ImageFrameSize, CCstatus.ImageZoomEnabled, CCstatus.ImageZoomOffsetX, CCstatus.ImageZoomOffsetY, CCstatus.ImageZoomSize, CCstatus.ImageVflip); - Camera.LedIntensity = CCstatus.ImageLedIntensity; - CFstatus.changedCameraSettings = false; - } - #ifdef DEBUG_DETAIL_ON ESP_LOGD(TAG, "Size: %d, Quality: %d", CCstatus.ImageFrameSize, CCstatus.ImageQuality); #endif @@ -157,15 +148,6 @@ esp_err_t handler_capture_with_light(httpd_req_t *req) } } - // If the camera settings were changed by creating a new reference image, they must be reset - if (CFstatus.changedCameraSettings) - { - Camera.setSensorDatenFromCCstatus(); // CCstatus >>> Kamera - Camera.SetQualityZoomSize(CCstatus.ImageQuality, CCstatus.ImageFrameSize, CCstatus.ImageZoomEnabled, CCstatus.ImageZoomOffsetX, CCstatus.ImageZoomOffsetY, CCstatus.ImageZoomSize, CCstatus.ImageVflip); - Camera.LedIntensity = CCstatus.ImageLedIntensity; - CFstatus.changedCameraSettings = false; - } - #ifdef DEBUG_DETAIL_ON ESP_LOGD(TAG, "Size: %d, Quality: %d", CCstatus.ImageFrameSize, CCstatus.ImageQuality); #endif @@ -240,15 +222,6 @@ esp_err_t handler_capture_save_to_file(httpd_req_t *req) fn.append("noname.jpg"); } - // If the camera settings were changed by creating a new reference image, they must be reset - if (CFstatus.changedCameraSettings) - { - Camera.setSensorDatenFromCCstatus(); // CCstatus >>> Kamera - Camera.SetQualityZoomSize(CCstatus.ImageQuality, CCstatus.ImageFrameSize, CCstatus.ImageZoomEnabled, CCstatus.ImageZoomOffsetX, CCstatus.ImageZoomOffsetY, CCstatus.ImageZoomSize, CCstatus.ImageVflip); - Camera.LedIntensity = CCstatus.ImageLedIntensity; - CFstatus.changedCameraSettings = false; - } - #ifdef DEBUG_DETAIL_ON ESP_LOGD(TAG, "Size: %d, Quality: %d", CCstatus.ImageFrameSize, CCstatus.ImageQuality); #endif diff --git a/code/components/jomjol_flowcontroll/ClassFlowTakeImage.cpp b/code/components/jomjol_flowcontroll/ClassFlowTakeImage.cpp index 380c02332..95b1fca70 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowTakeImage.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowTakeImage.cpp @@ -36,8 +36,8 @@ esp_err_t ClassFlowTakeImage::camera_capture(void) void ClassFlowTakeImage::takePictureWithFlash(int flash_duration) { // in case the image is flipped, it must be reset here // - rawImage->width = CCstatus.ImageWidth; - rawImage->height = CCstatus.ImageHeight; + rawImage->width = CCstatus.CamConfig.ImageWidth; + rawImage->height = CCstatus.CamConfig.ImageHeight; ESP_LOGD(TAG, "flash_duration: %d", flash_duration); @@ -133,56 +133,56 @@ bool ClassFlowTakeImage::ReadParameter(FILE *pfile, string &aktparamgraph) switch (_ImageGainceiling_) { case 1: - CCstatus.ImageGainceiling = GAINCEILING_4X; + CCstatus.CamConfig.ImageGainceiling = GAINCEILING_4X; break; case 2: - CCstatus.ImageGainceiling = GAINCEILING_8X; + CCstatus.CamConfig.ImageGainceiling = GAINCEILING_8X; break; case 3: - CCstatus.ImageGainceiling = GAINCEILING_16X; + CCstatus.CamConfig.ImageGainceiling = GAINCEILING_16X; break; case 4: - CCstatus.ImageGainceiling = GAINCEILING_32X; + CCstatus.CamConfig.ImageGainceiling = GAINCEILING_32X; break; case 5: - CCstatus.ImageGainceiling = GAINCEILING_64X; + CCstatus.CamConfig.ImageGainceiling = GAINCEILING_64X; break; case 6: - CCstatus.ImageGainceiling = GAINCEILING_128X; + CCstatus.CamConfig.ImageGainceiling = GAINCEILING_128X; break; default: - CCstatus.ImageGainceiling = GAINCEILING_2X; + CCstatus.CamConfig.ImageGainceiling = GAINCEILING_2X; } } else { if (_ImageGainceiling == "X4") { - CCstatus.ImageGainceiling = GAINCEILING_4X; + CCstatus.CamConfig.ImageGainceiling = GAINCEILING_4X; } else if (_ImageGainceiling == "X8") { - CCstatus.ImageGainceiling = GAINCEILING_8X; + CCstatus.CamConfig.ImageGainceiling = GAINCEILING_8X; } else if (_ImageGainceiling == "X16") { - CCstatus.ImageGainceiling = GAINCEILING_16X; + CCstatus.CamConfig.ImageGainceiling = GAINCEILING_16X; } else if (_ImageGainceiling == "X32") { - CCstatus.ImageGainceiling = GAINCEILING_32X; + CCstatus.CamConfig.ImageGainceiling = GAINCEILING_32X; } else if (_ImageGainceiling == "X64") { - CCstatus.ImageGainceiling = GAINCEILING_64X; + CCstatus.CamConfig.ImageGainceiling = GAINCEILING_64X; } else if (_ImageGainceiling == "X128") { - CCstatus.ImageGainceiling = GAINCEILING_128X; + CCstatus.CamConfig.ImageGainceiling = GAINCEILING_128X; } else { - CCstatus.ImageGainceiling = GAINCEILING_2X; + CCstatus.CamConfig.ImageGainceiling = GAINCEILING_2X; } } } @@ -192,7 +192,7 @@ bool ClassFlowTakeImage::ReadParameter(FILE *pfile, string &aktparamgraph) if (isStringNumeric(splitted[1])) { int _ImageQuality = std::stoi(splitted[1]); - CCstatus.ImageQuality = clipInt(_ImageQuality, 63, 6); + CCstatus.CamConfig.ImageQuality = clipInt(_ImageQuality, 63, 6); } } @@ -201,7 +201,7 @@ bool ClassFlowTakeImage::ReadParameter(FILE *pfile, string &aktparamgraph) if (isStringNumeric(splitted[1])) { int _ImageBrightness = std::stoi(splitted[1]); - CCstatus.ImageBrightness = clipInt(_ImageBrightness, 2, -2); + CCstatus.CamConfig.ImageBrightness = clipInt(_ImageBrightness, 2, -2); } } @@ -210,7 +210,7 @@ bool ClassFlowTakeImage::ReadParameter(FILE *pfile, string &aktparamgraph) if (isStringNumeric(splitted[1])) { int _ImageContrast = std::stoi(splitted[1]); - CCstatus.ImageContrast = clipInt(_ImageContrast, 2, -2); + CCstatus.CamConfig.ImageContrast = clipInt(_ImageContrast, 2, -2); } } @@ -219,7 +219,7 @@ bool ClassFlowTakeImage::ReadParameter(FILE *pfile, string &aktparamgraph) if (isStringNumeric(splitted[1])) { int _ImageSaturation = std::stoi(splitted[1]); - CCstatus.ImageSaturation = clipInt(_ImageSaturation, 2, -2); + CCstatus.CamConfig.ImageSaturation = clipInt(_ImageSaturation, 2, -2); } } @@ -230,18 +230,18 @@ bool ClassFlowTakeImage::ReadParameter(FILE *pfile, string &aktparamgraph) int _ImageSharpness = std::stoi(splitted[1]); if (CCstatus.CamSensor_id == OV2640_PID) { - CCstatus.ImageSharpness = clipInt(_ImageSharpness, 2, -2); + CCstatus.CamConfig.ImageSharpness = clipInt(_ImageSharpness, 2, -2); } else { - CCstatus.ImageSharpness = clipInt(_ImageSharpness, 3, -3); + CCstatus.CamConfig.ImageSharpness = clipInt(_ImageSharpness, 3, -3); } } } else if ((toUpper(splitted[0]) == "CAMAUTOSHARPNESS") && (splitted.size() > 1)) { - CCstatus.ImageAutoSharpness = alphanumericToBoolean(splitted[1]); + CCstatus.CamConfig.ImageAutoSharpness = alphanumericToBoolean(splitted[1]); } else if ((toUpper(splitted[0]) == "CAMSPECIALEFFECT") && (splitted.size() > 1)) @@ -251,37 +251,37 @@ bool ClassFlowTakeImage::ReadParameter(FILE *pfile, string &aktparamgraph) if (isStringNumeric(_ImageSpecialEffect)) { int _ImageSpecialEffect_ = std::stoi(_ImageSpecialEffect); - CCstatus.ImageSpecialEffect = clipInt(_ImageSpecialEffect_, 6, 0); + CCstatus.CamConfig.ImageSpecialEffect = clipInt(_ImageSpecialEffect_, 6, 0); } else { if (_ImageSpecialEffect == "NEGATIVE") { - CCstatus.ImageSpecialEffect = 1; + CCstatus.CamConfig.ImageSpecialEffect = 1; } else if (_ImageSpecialEffect == "GRAYSCALE") { - CCstatus.ImageSpecialEffect = 2; + CCstatus.CamConfig.ImageSpecialEffect = 2; } else if (_ImageSpecialEffect == "RED") { - CCstatus.ImageSpecialEffect = 3; + CCstatus.CamConfig.ImageSpecialEffect = 3; } else if (_ImageSpecialEffect == "GREEN") { - CCstatus.ImageSpecialEffect = 4; + CCstatus.CamConfig.ImageSpecialEffect = 4; } else if (_ImageSpecialEffect == "BLUE") { - CCstatus.ImageSpecialEffect = 5; + CCstatus.CamConfig.ImageSpecialEffect = 5; } else if (_ImageSpecialEffect == "RETRO") { - CCstatus.ImageSpecialEffect = 6; + CCstatus.CamConfig.ImageSpecialEffect = 6; } else { - CCstatus.ImageSpecialEffect = 0; + CCstatus.CamConfig.ImageSpecialEffect = 0; } } } @@ -293,51 +293,51 @@ bool ClassFlowTakeImage::ReadParameter(FILE *pfile, string &aktparamgraph) if (isStringNumeric(_ImageWbMode)) { int _ImageWbMode_ = std::stoi(_ImageWbMode); - CCstatus.ImageWbMode = clipInt(_ImageWbMode_, 4, 0); + CCstatus.CamConfig.ImageWbMode = clipInt(_ImageWbMode_, 4, 0); } else { if (_ImageWbMode == "SUNNY") { - CCstatus.ImageWbMode = 1; + CCstatus.CamConfig.ImageWbMode = 1; } else if (_ImageWbMode == "CLOUDY") { - CCstatus.ImageWbMode = 2; + CCstatus.CamConfig.ImageWbMode = 2; } else if (_ImageWbMode == "OFFICE") { - CCstatus.ImageWbMode = 3; + CCstatus.CamConfig.ImageWbMode = 3; } else if (_ImageWbMode == "HOME") { - CCstatus.ImageWbMode = 4; + CCstatus.CamConfig.ImageWbMode = 4; } else { - CCstatus.ImageWbMode = 0; + CCstatus.CamConfig.ImageWbMode = 0; } } } else if ((toUpper(splitted[0]) == "CAMAWB") && (splitted.size() > 1)) { - CCstatus.ImageAwb = alphanumericToBoolean(splitted[1]); + CCstatus.CamConfig.ImageAwb = alphanumericToBoolean(splitted[1]); } else if ((toUpper(splitted[0]) == "CAMAWBGAIN") && (splitted.size() > 1)) { - CCstatus.ImageAwbGain = alphanumericToBoolean(splitted[1]); + CCstatus.CamConfig.ImageAwbGain = alphanumericToBoolean(splitted[1]); } else if ((toUpper(splitted[0]) == "CAMAEC") && (splitted.size() > 1)) { - CCstatus.ImageAec = alphanumericToBoolean(splitted[1]); + CCstatus.CamConfig.ImageAec = alphanumericToBoolean(splitted[1]); } else if ((toUpper(splitted[0]) == "CAMAEC2") && (splitted.size() > 1)) { - CCstatus.ImageAec2 = alphanumericToBoolean(splitted[1]); + CCstatus.CamConfig.ImageAec2 = alphanumericToBoolean(splitted[1]); } else if ((toUpper(splitted[0]) == "CAMAELEVEL") && (splitted.size() > 1)) @@ -347,11 +347,11 @@ bool ClassFlowTakeImage::ReadParameter(FILE *pfile, string &aktparamgraph) int _ImageAeLevel = std::stoi(splitted[1]); if (CCstatus.CamSensor_id == OV2640_PID) { - CCstatus.ImageAeLevel = clipInt(_ImageAeLevel, 2, -2); + CCstatus.CamConfig.ImageAeLevel = clipInt(_ImageAeLevel, 2, -2); } else { - CCstatus.ImageAeLevel = clipInt(_ImageAeLevel, 5, -5); + CCstatus.CamConfig.ImageAeLevel = clipInt(_ImageAeLevel, 5, -5); } } } @@ -361,13 +361,13 @@ bool ClassFlowTakeImage::ReadParameter(FILE *pfile, string &aktparamgraph) if (isStringNumeric(splitted[1])) { int _ImageAecValue = std::stoi(splitted[1]); - CCstatus.ImageAecValue = clipInt(_ImageAecValue, 1200, 0); + CCstatus.CamConfig.ImageAecValue = clipInt(_ImageAecValue, 1200, 0); } } else if ((toUpper(splitted[0]) == "CAMAGC") && (splitted.size() > 1)) { - CCstatus.ImageAgc = alphanumericToBoolean(splitted[1]); + CCstatus.CamConfig.ImageAgc = alphanumericToBoolean(splitted[1]); } else if ((toUpper(splitted[0]) == "CAMAGCGAIN") && (splitted.size() > 1)) @@ -375,43 +375,43 @@ bool ClassFlowTakeImage::ReadParameter(FILE *pfile, string &aktparamgraph) if (isStringNumeric(splitted[1])) { int _ImageAgcGain = std::stoi(splitted[1]); - CCstatus.ImageAgcGain = clipInt(_ImageAgcGain, 30, 0); + CCstatus.CamConfig.ImageAgcGain = clipInt(_ImageAgcGain, 30, 0); } } else if ((toUpper(splitted[0]) == "CAMBPC") && (splitted.size() > 1)) { - CCstatus.ImageBpc = alphanumericToBoolean(splitted[1]); + CCstatus.CamConfig.ImageBpc = alphanumericToBoolean(splitted[1]); } else if ((toUpper(splitted[0]) == "CAMWPC") && (splitted.size() > 1)) { - CCstatus.ImageWpc = alphanumericToBoolean(splitted[1]); + CCstatus.CamConfig.ImageWpc = alphanumericToBoolean(splitted[1]); } else if ((toUpper(splitted[0]) == "CAMRAWGMA") && (splitted.size() > 1)) { - CCstatus.ImageRawGma = alphanumericToBoolean(splitted[1]); + CCstatus.CamConfig.ImageRawGma = alphanumericToBoolean(splitted[1]); } else if ((toUpper(splitted[0]) == "CAMLENC") && (splitted.size() > 1)) { - CCstatus.ImageLenc = alphanumericToBoolean(splitted[1]); + CCstatus.CamConfig.ImageLenc = alphanumericToBoolean(splitted[1]); } else if ((toUpper(splitted[0]) == "CAMHMIRROR") && (splitted.size() > 1)) { - CCstatus.ImageHmirror = alphanumericToBoolean(splitted[1]); + CCstatus.CamConfig.ImageHmirror = alphanumericToBoolean(splitted[1]); } else if ((toUpper(splitted[0]) == "CAMVFLIP") && (splitted.size() > 1)) { - CCstatus.ImageVflip = alphanumericToBoolean(splitted[1]); + CCstatus.CamConfig.ImageVflip = alphanumericToBoolean(splitted[1]); } else if ((toUpper(splitted[0]) == "CAMDCW") && (splitted.size() > 1)) { - CCstatus.ImageDcw = alphanumericToBoolean(splitted[1]); + CCstatus.CamConfig.ImageDcw = alphanumericToBoolean(splitted[1]); } else if ((toUpper(splitted[0]) == "CAMDENOISE") && (splitted.size() > 1)) @@ -421,18 +421,18 @@ bool ClassFlowTakeImage::ReadParameter(FILE *pfile, string &aktparamgraph) int _ImageDenoiseLevel = std::stoi(splitted[1]); if (CCstatus.CamSensor_id == OV2640_PID) { - CCstatus.ImageDenoiseLevel = 0; + CCstatus.CamConfig.ImageDenoiseLevel = 0; } else { - CCstatus.ImageDenoiseLevel = clipInt(_ImageDenoiseLevel, 8, 0); + CCstatus.CamConfig.ImageDenoiseLevel = clipInt(_ImageDenoiseLevel, 8, 0); } } } else if ((toUpper(splitted[0]) == "CAMZOOM") && (splitted.size() > 1)) { - CCstatus.ImageZoomEnabled = alphanumericToBoolean(splitted[1]); + CCstatus.CamConfig.ImageZoomEnabled = alphanumericToBoolean(splitted[1]); } else if ((toUpper(splitted[0]) == "CAMZOOMOFFSETX") && (splitted.size() > 1)) @@ -442,15 +442,15 @@ bool ClassFlowTakeImage::ReadParameter(FILE *pfile, string &aktparamgraph) int _ImageZoomOffsetX = std::stoi(splitted[1]); if (CCstatus.CamSensor_id == OV2640_PID) { - CCstatus.ImageZoomOffsetX = clipInt(_ImageZoomOffsetX, 480, -480); + CCstatus.CamConfig.ImageZoomOffsetX = clipInt(_ImageZoomOffsetX, 480, -480); } else if (CCstatus.CamSensor_id == OV3660_PID) { - CCstatus.ImageZoomOffsetX = clipInt(_ImageZoomOffsetX, 704, -704); + CCstatus.CamConfig.ImageZoomOffsetX = clipInt(_ImageZoomOffsetX, 704, -704); } else if (CCstatus.CamSensor_id == OV5640_PID) { - CCstatus.ImageZoomOffsetX = clipInt(_ImageZoomOffsetX, 960, -960); + CCstatus.CamConfig.ImageZoomOffsetX = clipInt(_ImageZoomOffsetX, 960, -960); } } } @@ -462,15 +462,15 @@ bool ClassFlowTakeImage::ReadParameter(FILE *pfile, string &aktparamgraph) int _ImageZoomOffsetY = std::stoi(splitted[1]); if (CCstatus.CamSensor_id == OV2640_PID) { - CCstatus.ImageZoomOffsetY = clipInt(_ImageZoomOffsetY, 360, -360); + CCstatus.CamConfig.ImageZoomOffsetY = clipInt(_ImageZoomOffsetY, 360, -360); } else if (CCstatus.CamSensor_id == OV3660_PID) { - CCstatus.ImageZoomOffsetY = clipInt(_ImageZoomOffsetY, 528, -528); + CCstatus.CamConfig.ImageZoomOffsetY = clipInt(_ImageZoomOffsetY, 528, -528); } else if (CCstatus.CamSensor_id == OV5640_PID) { - CCstatus.ImageZoomOffsetY = clipInt(_ImageZoomOffsetY, 720, -720); + CCstatus.CamConfig.ImageZoomOffsetY = clipInt(_ImageZoomOffsetY, 720, -720); } } } @@ -482,15 +482,43 @@ bool ClassFlowTakeImage::ReadParameter(FILE *pfile, string &aktparamgraph) int _ImageZoomSize = std::stoi(splitted[1]); if (CCstatus.CamSensor_id == OV2640_PID) { - CCstatus.ImageZoomSize = clipInt(_ImageZoomSize, 29, 0); + CCstatus.CamConfig.ImageZoomSize = clipInt(_ImageZoomSize, 29, 0); } else if (CCstatus.CamSensor_id == OV3660_PID) { - CCstatus.ImageZoomSize = clipInt(_ImageZoomSize, 43, 0); + CCstatus.CamConfig.ImageZoomSize = clipInt(_ImageZoomSize, 43, 0); } else if (CCstatus.CamSensor_id == OV5640_PID) { - CCstatus.ImageZoomSize = clipInt(_ImageZoomSize, 59, 0); + CCstatus.CamConfig.ImageZoomSize = clipInt(_ImageZoomSize, 59, 0); + } + } + } + + else if ((toUpper(splitted[0]) == "CAMFOCUS") && (splitted.size() > 1)) + { + if (CCstatus.CamSensor_id == OV5640_PID) + { + CCstatus.CamConfig.CameraFocusEnabled = alphanumericToBoolean(splitted[1]); + } + } + + else if ((toUpper(splitted[0]) == "CAMFOCUSAUTO") && (splitted.size() > 1)) + { + if (CCstatus.CamSensor_id == OV5640_PID) + { + CCstatus.CamConfig.CameraManualFocus = !alphanumericToBoolean(splitted[1]); + } + } + + else if ((toUpper(splitted[0]) == "CAMFOCUSMANUALLEVEL") && (splitted.size() > 1)) + { + if (isStringNumeric(splitted[1])) + { + int _CameraManualFocusLevel = std::stoi(splitted[1]); + if (CCstatus.CamSensor_id == OV5640_PID) + { + CCstatus.CamConfig.CameraManualFocusLevel = clipInt(_CameraManualFocusLevel, 1023, 0); } } } @@ -500,7 +528,7 @@ bool ClassFlowTakeImage::ReadParameter(FILE *pfile, string &aktparamgraph) if (isStringNumeric(splitted[1])) { int ledintensity = std::stoi(splitted[1]); - CCstatus.ImageLedIntensity = Camera.SetLEDIntensity(ledintensity); + CCstatus.CamConfig.ImageLedIntensity = Camera.CalculateLEDIntensity(ledintensity); } } @@ -515,10 +543,9 @@ bool ClassFlowTakeImage::ReadParameter(FILE *pfile, string &aktparamgraph) } Camera.setSensorDatenFromCCstatus(); // CCstatus >>> Kamera - Camera.SetQualityZoomSize(CCstatus.ImageQuality, CCstatus.ImageFrameSize, CCstatus.ImageZoomEnabled, CCstatus.ImageZoomOffsetX, CCstatus.ImageZoomOffsetY, CCstatus.ImageZoomSize, CCstatus.ImageVflip); rawImage = new CImageBasis("rawImage"); - rawImage->CreateEmptyImage(CCstatus.ImageWidth, CCstatus.ImageHeight, 3); + rawImage->CreateEmptyImage(CCstatus.CamConfig.ImageWidth, CCstatus.CamConfig.ImageHeight, 3); return true; } @@ -554,15 +581,6 @@ bool ClassFlowTakeImage::doFlow(string zwtime) esp_wifi_stop(); // to save power usage and #endif - // wenn die Kameraeinstellungen durch Erstellen eines neuen Referenzbildes verändert wurden, müssen sie neu gesetzt werden - if (CFstatus.changedCameraSettings) - { - Camera.setSensorDatenFromCCstatus(); // CCstatus >>> Kamera - Camera.SetQualityZoomSize(CCstatus.ImageQuality, CCstatus.ImageFrameSize, CCstatus.ImageZoomEnabled, CCstatus.ImageZoomOffsetX, CCstatus.ImageZoomOffsetY, CCstatus.ImageZoomSize, CCstatus.ImageVflip); - Camera.LedIntensity = CCstatus.ImageLedIntensity; - CFstatus.changedCameraSettings = false; - } - takePictureWithFlash(flash_duration); #ifdef WIFITURNOFF diff --git a/code/components/jomjol_flowcontroll/MainFlowControl.cpp b/code/components/jomjol_flowcontroll/MainFlowControl.cpp index 14dab6413..6c06f5559 100644 --- a/code/components/jomjol_flowcontroll/MainFlowControl.cpp +++ b/code/components/jomjol_flowcontroll/MainFlowControl.cpp @@ -146,162 +146,21 @@ bool doflow(void) esp_err_t setCCstatusToCFstatus(void) { - CFstatus.CamSensor_id = CCstatus.CamSensor_id; - - CFstatus.ImageFrameSize = CCstatus.ImageFrameSize; - - CFstatus.ImageContrast = CCstatus.ImageContrast; - CFstatus.ImageBrightness = CCstatus.ImageBrightness; - CFstatus.ImageSaturation = CCstatus.ImageSaturation; - - CFstatus.ImageQuality = CCstatus.ImageQuality; - - CFstatus.ImageGainceiling = CCstatus.ImageGainceiling; - - CFstatus.ImageAgc = CCstatus.ImageAgc; - CFstatus.ImageAec = CCstatus.ImageAec; - CFstatus.ImageHmirror = CCstatus.ImageHmirror; - CFstatus.ImageVflip = CCstatus.ImageVflip; - - CFstatus.ImageAwb = CCstatus.ImageAwb; - CFstatus.ImageAec2 = CCstatus.ImageAec2; - CFstatus.ImageAecValue = CCstatus.ImageAecValue; - CFstatus.ImageSpecialEffect = CCstatus.ImageSpecialEffect; - CFstatus.ImageWbMode = CCstatus.ImageWbMode; - CFstatus.ImageAeLevel = CCstatus.ImageAeLevel; - - CFstatus.ImageDcw = CCstatus.ImageDcw; - CFstatus.ImageBpc = CCstatus.ImageBpc; - CFstatus.ImageWpc = CCstatus.ImageWpc; - CFstatus.ImageAwbGain = CCstatus.ImageAwbGain; - CFstatus.ImageAgcGain = CCstatus.ImageAgcGain; - - CFstatus.ImageRawGma = CCstatus.ImageRawGma; - CFstatus.ImageLenc = CCstatus.ImageLenc; - - CFstatus.ImageSharpness = CCstatus.ImageSharpness; - CFstatus.ImageAutoSharpness = CCstatus.ImageAutoSharpness; - - CFstatus.ImageDenoiseLevel = CCstatus.ImageDenoiseLevel; - - CFstatus.ImageLedIntensity = CCstatus.ImageLedIntensity; - - CFstatus.ImageZoomEnabled = CCstatus.ImageZoomEnabled; - CFstatus.ImageZoomOffsetX = CCstatus.ImageZoomOffsetX; - CFstatus.ImageZoomOffsetY = CCstatus.ImageZoomOffsetY; - CFstatus.ImageZoomSize = CCstatus.ImageZoomSize; - + memcpy(&CFstatus.CamConfig, &CCstatus.CamConfig, sizeof(CFstatus.CamConfig)); CFstatus.WaitBeforePicture = CCstatus.WaitBeforePicture; - return ESP_OK; } esp_err_t setCFstatusToCCstatus(void) { - // CCstatus.CamSensor_id = CFstatus.CamSensor_id; - - CCstatus.ImageFrameSize = CFstatus.ImageFrameSize; - - CCstatus.ImageContrast = CFstatus.ImageContrast; - CCstatus.ImageBrightness = CFstatus.ImageBrightness; - CCstatus.ImageSaturation = CFstatus.ImageSaturation; - - CCstatus.ImageQuality = CFstatus.ImageQuality; - - CCstatus.ImageGainceiling = CFstatus.ImageGainceiling; - - CCstatus.ImageAgc = CFstatus.ImageAgc; - CCstatus.ImageAec = CFstatus.ImageAec; - CCstatus.ImageHmirror = CFstatus.ImageHmirror; - CCstatus.ImageVflip = CFstatus.ImageVflip; - - CCstatus.ImageAwb = CFstatus.ImageAwb; - CCstatus.ImageAec2 = CFstatus.ImageAec2; - CCstatus.ImageAecValue = CFstatus.ImageAecValue; - CCstatus.ImageSpecialEffect = CFstatus.ImageSpecialEffect; - CCstatus.ImageWbMode = CFstatus.ImageWbMode; - CCstatus.ImageAeLevel = CFstatus.ImageAeLevel; - - CCstatus.ImageDcw = CFstatus.ImageDcw; - CCstatus.ImageBpc = CFstatus.ImageBpc; - CCstatus.ImageWpc = CFstatus.ImageWpc; - CCstatus.ImageAwbGain = CFstatus.ImageAwbGain; - CCstatus.ImageAgcGain = CFstatus.ImageAgcGain; - - CCstatus.ImageRawGma = CFstatus.ImageRawGma; - CCstatus.ImageLenc = CFstatus.ImageLenc; - - CCstatus.ImageSharpness = CFstatus.ImageSharpness; - CCstatus.ImageAutoSharpness = CFstatus.ImageAutoSharpness; - - CCstatus.ImageDenoiseLevel = CFstatus.ImageDenoiseLevel; - - CCstatus.ImageLedIntensity = CFstatus.ImageLedIntensity; - - CCstatus.ImageZoomEnabled = CFstatus.ImageZoomEnabled; - CCstatus.ImageZoomOffsetX = CFstatus.ImageZoomOffsetX; - CCstatus.ImageZoomOffsetY = CFstatus.ImageZoomOffsetY; - CCstatus.ImageZoomSize = CFstatus.ImageZoomSize; - + memcpy(&CCstatus.CamConfig, &CFstatus.CamConfig, sizeof(CCstatus.CamConfig)); CCstatus.WaitBeforePicture = CFstatus.WaitBeforePicture; - return ESP_OK; } esp_err_t setCFstatusToCam(void) { - sensor_t *s = esp_camera_sensor_get(); - - if (s != NULL) - { - s->set_framesize(s, CFstatus.ImageFrameSize); - - // s->set_contrast(s, CFstatus.ImageContrast); // -2 to 2 - // s->set_brightness(s, CFstatus.ImageBrightness); // -2 to 2 - Camera.SetCamContrastBrightness(s, CFstatus.ImageContrast, CFstatus.ImageBrightness); - - s->set_saturation(s, CFstatus.ImageSaturation); // -2 to 2 - - s->set_quality(s, CFstatus.ImageQuality); // 0 - 63 - - // s->set_gainceiling(s, CFstatus.ImageGainceiling); // Image gain (GAINCEILING_x2, x4, x8, x16, x32, x64 or x128) - Camera.SetCamGainceiling(s, CFstatus.ImageGainceiling); - - s->set_gain_ctrl(s, CFstatus.ImageAgc); // 0 = disable , 1 = enable - s->set_exposure_ctrl(s, CFstatus.ImageAec); // 0 = disable , 1 = enable - s->set_hmirror(s, CFstatus.ImageHmirror); // 0 = disable , 1 = enable - s->set_vflip(s, CFstatus.ImageVflip); // 0 = disable , 1 = enable - - s->set_whitebal(s, CFstatus.ImageAwb); // 0 = disable , 1 = enable - s->set_aec2(s, CFstatus.ImageAec2); // 0 = disable , 1 = enable - s->set_aec_value(s, CFstatus.ImageAecValue); // 0 to 1200 - // s->set_special_effect(s, CFstatus.ImageSpecialEffect); // 0 to 6 (0 - No Effect, 1 - Negative, 2 - Grayscale, 3 - Red Tint, 4 - Green Tint, 5 - Blue Tint, 6 - Sepia) - Camera.SetCamSpecialEffect(s, CFstatus.ImageSpecialEffect); - s->set_wb_mode(s, CFstatus.ImageWbMode); // 0 to 4 - if awb_gain enabled (0 - Auto, 1 - Sunny, 2 - Cloudy, 3 - Office, 4 - Home) - s->set_ae_level(s, CFstatus.ImageAeLevel); // -2 to 2 - - s->set_dcw(s, CFstatus.ImageDcw); // 0 = disable , 1 = enable - s->set_bpc(s, CFstatus.ImageBpc); // 0 = disable , 1 = enable - s->set_wpc(s, CFstatus.ImageWpc); // 0 = disable , 1 = enable - s->set_awb_gain(s, CFstatus.ImageAwbGain); // 0 = disable , 1 = enable - s->set_agc_gain(s, CFstatus.ImageAgcGain); // 0 to 30 - - s->set_raw_gma(s, CFstatus.ImageRawGma); // 0 = disable , 1 = enable - s->set_lenc(s, CFstatus.ImageLenc); // 0 = disable , 1 = enable - - // s->set_sharpness(s, CFstatus.ImageSharpness); // auto-sharpness is not officially supported, default to 0 - Camera.SetCamSharpness(CFstatus.ImageAutoSharpness, CFstatus.ImageSharpness); - s->set_denoise(s, CFstatus.ImageDenoiseLevel); // The OV2640 does not support it, OV3660 and OV5640 (0 to 8) - - TickType_t xDelay2 = 100 / portTICK_PERIOD_MS; - vTaskDelay(xDelay2); - - return ESP_OK; - } - else - { - return ESP_FAIL; - } + return Camera.configureSensor(&CFstatus.CamConfig); } esp_err_t handler_get_heap(httpd_req_t *req) @@ -992,49 +851,49 @@ esp_err_t handler_editflow(httpd_req_t *req) switch (_aecgc_) { case 1: - CFstatus.ImageGainceiling = GAINCEILING_4X; + CFstatus.CamConfig.ImageGainceiling = GAINCEILING_4X; break; case 2: - CFstatus.ImageGainceiling = GAINCEILING_8X; + CFstatus.CamConfig.ImageGainceiling = GAINCEILING_8X; break; case 3: - CFstatus.ImageGainceiling = GAINCEILING_16X; + CFstatus.CamConfig.ImageGainceiling = GAINCEILING_16X; break; case 4: - CFstatus.ImageGainceiling = GAINCEILING_32X; + CFstatus.CamConfig.ImageGainceiling = GAINCEILING_32X; break; case 5: - CFstatus.ImageGainceiling = GAINCEILING_64X; + CFstatus.CamConfig.ImageGainceiling = GAINCEILING_64X; break; case 6: - CFstatus.ImageGainceiling = GAINCEILING_128X; + CFstatus.CamConfig.ImageGainceiling = GAINCEILING_128X; break; default: - CFstatus.ImageGainceiling = GAINCEILING_2X; + CFstatus.CamConfig.ImageGainceiling = GAINCEILING_2X; } } else { if (_aecgc == "X4") { - CFstatus.ImageGainceiling = GAINCEILING_4X; + CFstatus.CamConfig.ImageGainceiling = GAINCEILING_4X; } else if (_aecgc == "X8") { - CFstatus.ImageGainceiling = GAINCEILING_8X; + CFstatus.CamConfig.ImageGainceiling = GAINCEILING_8X; } else if (_aecgc == "X16") { - CFstatus.ImageGainceiling = GAINCEILING_16X; + CFstatus.CamConfig.ImageGainceiling = GAINCEILING_16X; } else if (_aecgc == "X32") { - CFstatus.ImageGainceiling = GAINCEILING_32X; + CFstatus.CamConfig.ImageGainceiling = GAINCEILING_32X; } else if (_aecgc == "X64") { - CFstatus.ImageGainceiling = GAINCEILING_64X; + CFstatus.CamConfig.ImageGainceiling = GAINCEILING_64X; } else if (_aecgc == "X128") { - CFstatus.ImageGainceiling = GAINCEILING_128X; + CFstatus.CamConfig.ImageGainceiling = GAINCEILING_128X; } else { - CFstatus.ImageGainceiling = GAINCEILING_2X; + CFstatus.CamConfig.ImageGainceiling = GAINCEILING_2X; } } } @@ -1045,7 +904,7 @@ esp_err_t handler_editflow(httpd_req_t *req) if (isStringNumeric(_qual)) { int _qual_ = std::stoi(_valuechar); - CFstatus.ImageQuality = clipInt(_qual_, 63, 6); + CFstatus.CamConfig.ImageQuality = clipInt(_qual_, 63, 6); } } @@ -1055,7 +914,7 @@ esp_err_t handler_editflow(httpd_req_t *req) if (isStringNumeric(_bri)) { int _bri_ = std::stoi(_valuechar); - CFstatus.ImageBrightness = clipInt(_bri_, 2, -2); + CFstatus.CamConfig.ImageBrightness = clipInt(_bri_, 2, -2); } } @@ -1065,7 +924,7 @@ esp_err_t handler_editflow(httpd_req_t *req) if (isStringNumeric(_con)) { int _con_ = std::stoi(_valuechar); - CFstatus.ImageContrast = clipInt(_con_, 2, -2); + CFstatus.CamConfig.ImageContrast = clipInt(_con_, 2, -2); } } @@ -1075,7 +934,7 @@ esp_err_t handler_editflow(httpd_req_t *req) if (isStringNumeric(_sat)) { int _sat_ = std::stoi(_valuechar); - CFstatus.ImageSaturation = clipInt(_sat_, 2, -2); + CFstatus.CamConfig.ImageSaturation = clipInt(_sat_, 2, -2); } } @@ -1087,11 +946,11 @@ esp_err_t handler_editflow(httpd_req_t *req) int _shp_ = std::stoi(_valuechar); if (CCstatus.CamSensor_id == OV2640_PID) { - CFstatus.ImageSharpness = clipInt(_shp_, 2, -2); + CFstatus.CamConfig.ImageSharpness = clipInt(_shp_, 2, -2); } else { - CFstatus.ImageSharpness = clipInt(_shp_, 3, -3); + CFstatus.CamConfig.ImageSharpness = clipInt(_shp_, 3, -3); } } } @@ -1099,7 +958,7 @@ esp_err_t handler_editflow(httpd_req_t *req) if (httpd_query_key_value(_query, "ashp", _valuechar, 30) == ESP_OK) { std::string _ashp = std::string(_valuechar); - CFstatus.ImageAutoSharpness = alphanumericToBoolean(_ashp); + CFstatus.CamConfig.ImageAutoSharpness = alphanumericToBoolean(_ashp); } if (httpd_query_key_value(_query, "spe", _valuechar, 30) == ESP_OK) @@ -1108,30 +967,30 @@ esp_err_t handler_editflow(httpd_req_t *req) if (isStringNumeric(_spe)) { int _spe_ = std::stoi(_valuechar); - CFstatus.ImageSpecialEffect = clipInt(_spe_, 6, 0); + CFstatus.CamConfig.ImageSpecialEffect = clipInt(_spe_, 6, 0); } else { if (_spe == "negative") { - CFstatus.ImageSpecialEffect = 1; + CFstatus.CamConfig.ImageSpecialEffect = 1; } else if (_spe == "grayscale") { - CFstatus.ImageSpecialEffect = 2; + CFstatus.CamConfig.ImageSpecialEffect = 2; } else if (_spe == "red") { - CFstatus.ImageSpecialEffect = 3; + CFstatus.CamConfig.ImageSpecialEffect = 3; } else if (_spe == "green") { - CFstatus.ImageSpecialEffect = 4; + CFstatus.CamConfig.ImageSpecialEffect = 4; } else if (_spe == "blue") { - CFstatus.ImageSpecialEffect = 5; + CFstatus.CamConfig.ImageSpecialEffect = 5; } else if (_spe == "retro") { - CFstatus.ImageSpecialEffect = 6; + CFstatus.CamConfig.ImageSpecialEffect = 6; } else { - CFstatus.ImageSpecialEffect = 0; + CFstatus.CamConfig.ImageSpecialEffect = 0; } } } @@ -1142,24 +1001,24 @@ esp_err_t handler_editflow(httpd_req_t *req) if (isStringNumeric(_wbm)) { int _wbm_ = std::stoi(_valuechar); - CFstatus.ImageWbMode = clipInt(_wbm_, 4, 0); + CFstatus.CamConfig.ImageWbMode = clipInt(_wbm_, 4, 0); } else { if (_wbm == "sunny") { - CFstatus.ImageWbMode = 1; + CFstatus.CamConfig.ImageWbMode = 1; } else if (_wbm == "cloudy") { - CFstatus.ImageWbMode = 2; + CFstatus.CamConfig.ImageWbMode = 2; } else if (_wbm == "office") { - CFstatus.ImageWbMode = 3; + CFstatus.CamConfig.ImageWbMode = 3; } else if (_wbm == "home") { - CFstatus.ImageWbMode = 4; + CFstatus.CamConfig.ImageWbMode = 4; } else { - CFstatus.ImageWbMode = 0; + CFstatus.CamConfig.ImageWbMode = 0; } } } @@ -1167,25 +1026,25 @@ esp_err_t handler_editflow(httpd_req_t *req) if (httpd_query_key_value(_query, "awb", _valuechar, 30) == ESP_OK) { std::string _awb = std::string(_valuechar); - CFstatus.ImageAwb = alphanumericToBoolean(_awb); + CFstatus.CamConfig.ImageAwb = alphanumericToBoolean(_awb); } if (httpd_query_key_value(_query, "awbg", _valuechar, 30) == ESP_OK) { std::string _awbg = std::string(_valuechar); - CFstatus.ImageAwbGain = alphanumericToBoolean(_awbg); + CFstatus.CamConfig.ImageAwbGain = alphanumericToBoolean(_awbg); } if (httpd_query_key_value(_query, "aec", _valuechar, 30) == ESP_OK) { std::string _aec = std::string(_valuechar); - CFstatus.ImageAec = alphanumericToBoolean(_aec); + CFstatus.CamConfig.ImageAec = alphanumericToBoolean(_aec); } if (httpd_query_key_value(_query, "aec2", _valuechar, 30) == ESP_OK) { std::string _aec2 = std::string(_valuechar); - CFstatus.ImageAec2 = alphanumericToBoolean(_aec2); + CFstatus.CamConfig.ImageAec2 = alphanumericToBoolean(_aec2); } if (httpd_query_key_value(_query, "ael", _valuechar, 30) == ESP_OK) @@ -1196,11 +1055,11 @@ esp_err_t handler_editflow(httpd_req_t *req) int _ael_ = std::stoi(_valuechar); if (CCstatus.CamSensor_id == OV2640_PID) { - CFstatus.ImageAeLevel = clipInt(_ael_, 2, -2); + CFstatus.CamConfig.ImageAeLevel = clipInt(_ael_, 2, -2); } else { - CFstatus.ImageAeLevel = clipInt(_ael_, 5, -5); + CFstatus.CamConfig.ImageAeLevel = clipInt(_ael_, 5, -5); } } } @@ -1211,14 +1070,14 @@ esp_err_t handler_editflow(httpd_req_t *req) if (isStringNumeric(_aecv)) { int _aecv_ = std::stoi(_valuechar); - CFstatus.ImageAecValue = clipInt(_aecv_, 1200, 0); + CFstatus.CamConfig.ImageAecValue = clipInt(_aecv_, 1200, 0); } } if (httpd_query_key_value(_query, "agc", _valuechar, 30) == ESP_OK) { std::string _agc = std::string(_valuechar); - CFstatus.ImageAgc = alphanumericToBoolean(_agc); + CFstatus.CamConfig.ImageAgc = alphanumericToBoolean(_agc); } if (httpd_query_key_value(_query, "agcg", _valuechar, 30) == ESP_OK) @@ -1227,50 +1086,50 @@ esp_err_t handler_editflow(httpd_req_t *req) if (isStringNumeric(_agcg)) { int _agcg_ = std::stoi(_valuechar); - CFstatus.ImageAgcGain = clipInt(_agcg_, 30, 0); + CFstatus.CamConfig.ImageAgcGain = clipInt(_agcg_, 30, 0); } } if (httpd_query_key_value(_query, "bpc", _valuechar, 30) == ESP_OK) { std::string _bpc = std::string(_valuechar); - CFstatus.ImageBpc = alphanumericToBoolean(_bpc); + CFstatus.CamConfig.ImageBpc = alphanumericToBoolean(_bpc); } if (httpd_query_key_value(_query, "wpc", _valuechar, 30) == ESP_OK) { std::string _wpc = std::string(_valuechar); - CFstatus.ImageWpc = alphanumericToBoolean(_wpc); + CFstatus.CamConfig.ImageWpc = alphanumericToBoolean(_wpc); } if (httpd_query_key_value(_query, "rgma", _valuechar, 30) == ESP_OK) { std::string _rgma = std::string(_valuechar); - CFstatus.ImageRawGma = alphanumericToBoolean(_rgma); + CFstatus.CamConfig.ImageRawGma = alphanumericToBoolean(_rgma); } if (httpd_query_key_value(_query, "lenc", _valuechar, 30) == ESP_OK) { std::string _lenc = std::string(_valuechar); - CFstatus.ImageLenc = alphanumericToBoolean(_lenc); + CFstatus.CamConfig.ImageLenc = alphanumericToBoolean(_lenc); } if (httpd_query_key_value(_query, "mirror", _valuechar, 30) == ESP_OK) { std::string _mirror = std::string(_valuechar); - CFstatus.ImageHmirror = alphanumericToBoolean(_mirror); + CFstatus.CamConfig.ImageHmirror = alphanumericToBoolean(_mirror); } if (httpd_query_key_value(_query, "flip", _valuechar, 30) == ESP_OK) { std::string _flip = std::string(_valuechar); - CFstatus.ImageVflip = alphanumericToBoolean(_flip); + CFstatus.CamConfig.ImageVflip = alphanumericToBoolean(_flip); } if (httpd_query_key_value(_query, "dcw", _valuechar, 30) == ESP_OK) { std::string _dcw = std::string(_valuechar); - CFstatus.ImageDcw = alphanumericToBoolean(_dcw); + CFstatus.CamConfig.ImageDcw = alphanumericToBoolean(_dcw); } if (httpd_query_key_value(_query, "den", _valuechar, 30) == ESP_OK) @@ -1281,11 +1140,11 @@ esp_err_t handler_editflow(httpd_req_t *req) int _ImageDenoiseLevel = std::stoi(_valuechar); if (CCstatus.CamSensor_id == OV2640_PID) { - CFstatus.ImageDenoiseLevel = 0; + CFstatus.CamConfig.ImageDenoiseLevel = 0; } else { - CFstatus.ImageDenoiseLevel = clipInt(_ImageDenoiseLevel, 8, 0); + CFstatus.CamConfig.ImageDenoiseLevel = clipInt(_ImageDenoiseLevel, 8, 0); } } } @@ -1293,7 +1152,7 @@ esp_err_t handler_editflow(httpd_req_t *req) if (httpd_query_key_value(_query, "zoom", _valuechar, 30) == ESP_OK) { std::string _zoom = std::string(_valuechar); - CFstatus.ImageZoomEnabled = alphanumericToBoolean(_zoom); + CFstatus.CamConfig.ImageZoomEnabled = alphanumericToBoolean(_zoom); } if (httpd_query_key_value(_query, "zoomx", _valuechar, 30) == ESP_OK) @@ -1304,15 +1163,15 @@ esp_err_t handler_editflow(httpd_req_t *req) int _ImageZoomOffsetX = std::stoi(_valuechar); if (CCstatus.CamSensor_id == OV2640_PID) { - CFstatus.ImageZoomOffsetX = clipInt(_ImageZoomOffsetX, 480, -480); + CFstatus.CamConfig.ImageZoomOffsetX = clipInt(_ImageZoomOffsetX, 480, -480); } else if (CCstatus.CamSensor_id == OV3660_PID) { - CFstatus.ImageZoomOffsetX = clipInt(_ImageZoomOffsetX, 704, -704); + CFstatus.CamConfig.ImageZoomOffsetX = clipInt(_ImageZoomOffsetX, 704, -704); } else if (CCstatus.CamSensor_id == OV5640_PID) { - CFstatus.ImageZoomOffsetX = clipInt(_ImageZoomOffsetX, 960, -960); + CFstatus.CamConfig.ImageZoomOffsetX = clipInt(_ImageZoomOffsetX, 960, -960); } } } @@ -1325,15 +1184,15 @@ esp_err_t handler_editflow(httpd_req_t *req) int _ImageZoomOffsetY = std::stoi(_valuechar); if (CCstatus.CamSensor_id == OV2640_PID) { - CFstatus.ImageZoomOffsetY = clipInt(_ImageZoomOffsetY, 360, -360); + CFstatus.CamConfig.ImageZoomOffsetY = clipInt(_ImageZoomOffsetY, 360, -360); } else if (CCstatus.CamSensor_id == OV3660_PID) { - CFstatus.ImageZoomOffsetY = clipInt(_ImageZoomOffsetY, 528, -528); + CFstatus.CamConfig.ImageZoomOffsetY = clipInt(_ImageZoomOffsetY, 528, -528); } else if (CCstatus.CamSensor_id == OV5640_PID) { - CFstatus.ImageZoomOffsetY = clipInt(_ImageZoomOffsetY, 720, -720); + CFstatus.CamConfig.ImageZoomOffsetY = clipInt(_ImageZoomOffsetY, 720, -720); } } } @@ -1346,15 +1205,46 @@ esp_err_t handler_editflow(httpd_req_t *req) int _ImageZoomSize = std::stoi(_valuechar); if (CCstatus.CamSensor_id == OV2640_PID) { - CFstatus.ImageZoomSize = clipInt(_ImageZoomSize, 29, 0); + CFstatus.CamConfig.ImageZoomSize = clipInt(_ImageZoomSize, 29, 0); } else if (CCstatus.CamSensor_id == OV3660_PID) { - CFstatus.ImageZoomSize = clipInt(_ImageZoomSize, 43, 0); + CFstatus.CamConfig.ImageZoomSize = clipInt(_ImageZoomSize, 43, 0); } else if (CCstatus.CamSensor_id == OV5640_PID) { - CFstatus.ImageZoomSize = clipInt(_ImageZoomSize, 59, 0); + CFstatus.CamConfig.ImageZoomSize = clipInt(_ImageZoomSize, 59, 0); + } + } + } + + if (httpd_query_key_value(_query, "fen", _valuechar, 30) == ESP_OK) + { + if (CCstatus.CamSensor_id == OV5640_PID) + { + std::string _focus = std::string(_valuechar); + CFstatus.CamConfig.CameraFocusEnabled = alphanumericToBoolean(_focus); + } + } + + if (httpd_query_key_value(_query, "af", _valuechar, 30) == ESP_OK) + { + if (CCstatus.CamSensor_id == OV5640_PID) + { + std::string _autofocus = std::string(_valuechar); + CFstatus.CamConfig.CameraManualFocus = !alphanumericToBoolean(_autofocus); + } + } + + if (httpd_query_key_value(_query, "flvl", _valuechar, 30) == ESP_OK) + { + std::string _focusLevel = std::string(_valuechar); + if (isStringNumeric(_focusLevel)) + { + int _CameraManualFocusLevel = std::stoi(_valuechar); + if (CCstatus.CamSensor_id == OV5640_PID) + { + CFstatus.CamConfig.CameraManualFocusLevel = clipInt(_CameraManualFocusLevel, 1023, 0); } } } @@ -1365,18 +1255,18 @@ esp_err_t handler_editflow(httpd_req_t *req) if (isStringNumeric(_ledi)) { int _ImageLedIntensity = std::stoi(_valuechar); - CFstatus.ImageLedIntensity = Camera.SetLEDIntensity(_ImageLedIntensity); + CFstatus.CamConfig.ImageLedIntensity = Camera.CalculateLEDIntensity(_ImageLedIntensity); } } if (_task.compare("cam_settings") == 0) { + // Kameraeinstellungen wurden verädert + CCstatus.isTempImage = false; + // wird aufgerufen, wenn das Referenzbild + Kameraeinstellungen gespeichert wurden setCFstatusToCCstatus(); // CFstatus >>> CCstatus - // Kameraeinstellungen wurden verädert - CFstatus.changedCameraSettings = true; - ESP_LOGD(TAG, "Cam Settings set"); std::string _zw = "CamSettingsSet"; httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*"); @@ -1386,13 +1276,9 @@ esp_err_t handler_editflow(httpd_req_t *req) { // wird aufgerufen, wenn ein neues Referenzbild erstellt oder aktualisiert wurde // CFstatus >>> Kamera - setCFstatusToCam(); - - Camera.SetQualityZoomSize(CFstatus.ImageQuality, CFstatus.ImageFrameSize, CFstatus.ImageZoomEnabled, CFstatus.ImageZoomOffsetX, CFstatus.ImageZoomOffsetY, CFstatus.ImageZoomSize, CFstatus.ImageVflip); - // Camera.SetZoomSize(CFstatus.ImageZoomEnabled, CFstatus.ImageZoomOffsetX, CFstatus.ImageZoomOffsetY, CFstatus.ImageZoomSize, CFstatus.ImageVflip); // Kameraeinstellungen wurden verädert - CFstatus.changedCameraSettings = true; + CCstatus.isTempImage = true; ESP_LOGD(TAG, "test_take - vor TakeImage"); std::string image_temp = flowctrl.doSingleStep("[TakeImage]", _host); @@ -1401,6 +1287,20 @@ esp_err_t handler_editflow(httpd_req_t *req) } } + if (_task.compare("get_focus_level") == 0) + { + std::string _host = ""; + + if (httpd_query_key_value(_query, "host", _valuechar, 30) == ESP_OK) + { + _host = std::string(_valuechar); + } + + std::string zw = to_string(CCstatus.CameraFocusLevel); + httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*"); + httpd_resp_send(req, zw.c_str(), zw.length()); + } + if (_task.compare("test_align") == 0) { std::string _host = ""; diff --git a/code/components/jomjol_flowcontroll/MainFlowControl.h b/code/components/jomjol_flowcontroll/MainFlowControl.h index a2c2047e3..86b31d4aa 100644 --- a/code/components/jomjol_flowcontroll/MainFlowControl.h +++ b/code/components/jomjol_flowcontroll/MainFlowControl.h @@ -13,52 +13,13 @@ typedef struct { - uint16_t CamSensor_id; - - framesize_t ImageFrameSize = FRAMESIZE_VGA; // 0 - 10 - gainceiling_t ImageGainceiling; // Image gain (GAINCEILING_x2, x4, x8, x16, x32, x64 or x128) - - int ImageQuality; // 0 - 63 - int ImageBrightness; // (-2 to 2) - set brightness - int ImageContrast; //-2 - 2 - int ImageSaturation; //-2 - 2 - int ImageSharpness; //-2 - 2 - bool ImageAutoSharpness; - int ImageSpecialEffect; // 0 - 6 - int ImageWbMode; // 0 to 4 - if awb_gain enabled (0 - Auto, 1 - Sunny, 2 - Cloudy, 3 - Office, 4 - Home) - int ImageAwb; // white balance enable (0 or 1) - int ImageAwbGain; // Auto White Balance enable (0 or 1) - int ImageAec; // auto exposure off (1 or 0) - int ImageAec2; // automatic exposure sensor (0 or 1) - int ImageAeLevel; // auto exposure levels (-2 to 2) - int ImageAecValue; // set exposure manually (0-1200) - int ImageAgc; // auto gain off (1 or 0) - int ImageAgcGain; // set gain manually (0 - 30) - int ImageBpc; // black pixel correction - int ImageWpc; // white pixel correction - int ImageRawGma; // (1 or 0) - int ImageLenc; // lens correction (1 or 0) - int ImageHmirror; // (0 or 1) flip horizontally - int ImageVflip; // Invert image (0 or 1) - int ImageDcw; // downsize enable (1 or 0) - - int ImageDenoiseLevel; // The OV2640 does not support it, OV3660 and OV5640 (0 to 8) - - int ImageWidth; - int ImageHeight; - - int ImageLedIntensity; - - bool ImageZoomEnabled; - int ImageZoomOffsetX; - int ImageZoomOffsetY; - int ImageZoomSize; + cam_config_t CamConfig; int WaitBeforePicture; bool isImageSize; bool CameraInitSuccessful; - bool changedCameraSettings; + bool CameraInitAFSuccessful; bool DemoMode; bool SaveAllFiles; } camera_flow_config_temp_t; diff --git a/code/components/jomjol_tfliteclass/CTfLiteClass.cpp b/code/components/jomjol_tfliteclass/CTfLiteClass.cpp index bf022d7a7..b6ad9c3b0 100644 --- a/code/components/jomjol_tfliteclass/CTfLiteClass.cpp +++ b/code/components/jomjol_tfliteclass/CTfLiteClass.cpp @@ -206,7 +206,7 @@ bool CTfLiteClass::MakeAllocate() LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "CTfLiteClass::MakeAllocate"); this->interpreter = new tflite::MicroInterpreter(this->model, resolver, this->tensor_arena, this->kTensorArenaSize); - LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Trying to load the model. If it crashes here, it ist most likely due to a corrupted model!"); + LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Trying to load the model. If it crashes here, it is most likely due to a corrupted model!"); if (this->interpreter) { diff --git a/code/main/main.cpp b/code/main/main.cpp index 0c494ef92..b6c3ff4e2 100644 --- a/code/main/main.cpp +++ b/code/main/main.cpp @@ -993,6 +993,14 @@ bool setCpuFrequency(void) { return false; } } + else if (cpuFrequency == "80") { + pm_config.max_freq_mhz = 80; + pm_config.min_freq_mhz = pm_config.max_freq_mhz; + if (esp_pm_configure(&pm_config) != ESP_OK) { + LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Failed to set new CPU frequency!"); + return false; + } + } else { LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Unknown CPU frequency: " + cpuFrequency + "! " "It must be 160 or 240!"); diff --git a/code/main/server_main.cpp b/code/main/server_main.cpp index a38a7e129..f76a58751 100644 --- a/code/main/server_main.cpp +++ b/code/main/server_main.cpp @@ -123,6 +123,43 @@ esp_err_t info_get_handler(httpd_req_t *req) httpd_resp_sendstr(req, formated); return ESP_OK; } + else if (_task.compare("CamId") == 0) + { + switch (CCstatus.CamSensor_id) { + case OV2640_PID: + httpd_resp_sendstr(req, "OV2640"); + break; + case OV3660_PID: + httpd_resp_sendstr(req, "OV3660"); + break; + case OV5640_PID: + httpd_resp_sendstr(req, "OV5640"); + break; + default: + httpd_resp_sendstr(req, "unknown"); + } + return ESP_OK; + } + else if (_task.compare("CamInit") == 0) + { + if (CCstatus.CameraInitSuccessful) { + httpd_resp_sendstr(req, "ok"); + } + else { + httpd_resp_sendstr(req, "Nok"); + } + return ESP_OK; + } + else if (_task.compare("CamFocus") == 0) + { + if (CCstatus.CameraAFInitSuccessful) { + httpd_resp_sendstr(req, "available"); + } + else { + httpd_resp_sendstr(req, "unavailable"); + } + return ESP_OK; + } else if (_task.compare("SDCardPartitionSize") == 0) { std::string zw; diff --git a/param-docs/expert-params.txt b/param-docs/expert-params.txt index f53170964..be5d33b59 100644 --- a/param-docs/expert-params.txt +++ b/param-docs/expert-params.txt @@ -24,6 +24,9 @@ CamZoom CamZoomSize CamZoomOffsetX CamZoomOffsetY +CamFocus +CamFocusAuto +CamFocusManualLevel demo SearchFieldX SearchFieldY diff --git a/param-docs/parameter-pages/System/CPUFrequency.md b/param-docs/parameter-pages/System/CPUFrequency.md index 971527940..8026e7c40 100644 --- a/param-docs/parameter-pages/System/CPUFrequency.md +++ b/param-docs/parameter-pages/System/CPUFrequency.md @@ -9,5 +9,6 @@ Set the CPU Frequency. Possible values: +- 80 - 160 - 240 diff --git a/param-docs/parameter-pages/TakeImage/CamFocus.md b/param-docs/parameter-pages/TakeImage/CamFocus.md new file mode 100644 index 000000000..d45b736e7 --- /dev/null +++ b/param-docs/parameter-pages/TakeImage/CamFocus.md @@ -0,0 +1,18 @@ +# Parameter `CamFocus` + +**Focus** + +- Enable/Disable focus control. + +Default Value: `false` + +!!! Warning + This is an **Expert Parameter**! Only change it if you understand what it does! + + After changing this parameter you need to update your reference image and alignment markers! + +!!! Note + This parameter only applies to OV5640 camera. + +!!! Note + This parameter can also be set on the Reference Image configuration page! diff --git a/param-docs/parameter-pages/TakeImage/CamFocusAuto.md b/param-docs/parameter-pages/TakeImage/CamFocusAuto.md new file mode 100644 index 000000000..ede3f049a --- /dev/null +++ b/param-docs/parameter-pages/TakeImage/CamFocusAuto.md @@ -0,0 +1,18 @@ +# Parameter `CamFocusAuto` + +**Autofocus** + +- Enable/Disable autofocus. + +Default Value: `false` + +!!! Warning + This is an **Expert Parameter**! Only change it if you understand what it does! + + After changing this parameter you need to update your reference image and alignment markers! + +!!! Note + This parameter only applies to OV5640 camera. + +!!! Note + This parameter can also be set on the Reference Image configuration page! diff --git a/param-docs/parameter-pages/TakeImage/CamFocusManualLevel.md b/param-docs/parameter-pages/TakeImage/CamFocusManualLevel.md new file mode 100644 index 000000000..b4e537dcb --- /dev/null +++ b/param-docs/parameter-pages/TakeImage/CamFocusManualLevel.md @@ -0,0 +1,21 @@ +# Parameter `CamFocusManualLevel` + +**Manual-Focus-Level** + +range on OV5640 (`0` .. `1023`) + +Default Value: `0` + +!!! Warning + This is an **Expert Parameter**! Only change it if you understand what it does! + + After changing this parameter you need to update your reference image and alignment markers! + +!!! Note + Lower value for further focus, higher value for nearer focus. + +!!! Note + This parameter only applies to OV5640 camera. + +!!! Note + This parameter can also be set on the Reference Image configuration page! diff --git a/sd-card/html/edit_config_template.html b/sd-card/html/edit_config_template.html index 66058ba98..46b5734a6 100644 --- a/sd-card/html/edit_config_template.html +++ b/sd-card/html/edit_config_template.html @@ -185,17 +185,17 @@ -ms-transform: translate(-50%,-50%); } - #reboot_button { - float: none; - background-color: #f44336; - color: white; - padding: 5px; - border-radius: - 5px; font-weight: bold; - text-align: center; - text-decoration: none; - display: inline-block; - } + #reboot_button { + float: none; + background-color: #f44336; + color: white; + padding: 5px; + border-radius: + 5px; font-weight: bold; + text-align: center; + text-decoration: none; + display: inline-block; + } @@ -321,8 +321,8 @@

Configuration

$TOOLTIP_TakeImage_CamGainceiling - - + + Image Quality @@ -400,16 +400,16 @@

Configuration

$TOOLTIP_TakeImage_CamSpecialEffect - + White Balance Mode @@ -511,7 +511,7 @@

Configuration

$TOOLTIP_TakeImage_CamAgc - + @@ -537,7 +537,7 @@

Configuration

$TOOLTIP_TakeImage_CamBpc - + White Pixel Correction @@ -576,7 +576,7 @@

Configuration

$TOOLTIP_TakeImage_CamLenc - + Mirror Image @@ -588,8 +588,8 @@

Configuration

$TOOLTIP_TakeImage_CamHmirror - - + + Flip Image @@ -648,7 +648,7 @@

Configuration

- $TOOLTIP_TakeImage_CamZoomSize + $TOOLTIP_TakeImage_CamZoomSize @@ -673,6 +673,43 @@

Configuration

$TOOLTIP_TakeImage_CamZoomOffsetY + + + Focus + + + + + $TOOLTIP_TakeImage_CamFocus + + + + + Auto focus + + + + + $TOOLTIP_TakeImage_CamFocusAuto + + + + + Manual focus level + + + + + $TOOLTIP_TakeImage_CamFocusManualLevel + + LED Intensity @@ -683,7 +720,7 @@

Configuration

$TOOLTIP_TakeImage_LEDIntensity - +