Skip to content

Commit

Permalink
fix (#3418)
Browse files Browse the repository at this point in the history
  • Loading branch information
SybexX authored Dec 4, 2024
1 parent be7146c commit 50ada0a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 14 deletions.
16 changes: 8 additions & 8 deletions code/components/jomjol_controlcamera/ClassControllCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,12 @@ void CCamera::ledc_init(void)
#endif
}

void CCamera::SetLEDIntensity(float _intrel)
int CCamera::SetLEDIntensity(int _intrel)
{
_intrel = min(_intrel, (float)100);
_intrel = max(_intrel, (float)0);
_intrel = _intrel / 100;
CCstatus.ImageLedIntensity = (int)(_intrel * 8191);
ESP_LOGD(TAG, "Set led_intensity to %d of 8191", CCstatus.ImageLedIntensity);
// 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;
}

bool CCamera::getCameraInitSuccessful(void)
Expand Down Expand Up @@ -944,6 +943,7 @@ esp_err_t CCamera::CaptureToStream(httpd_req_t *req, bool FlashlightOn)
{
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;
}

Expand Down Expand Up @@ -1034,8 +1034,8 @@ void CCamera::LightOnOff(bool status)
#ifdef USE_PWM_LEDFLASH
if (status)
{
ESP_LOGD(TAG, "Internal Flash-LED turn on with PWM %d", CCstatus.ImageLedIntensity);
ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LEDC_CHANNEL, CCstatus.ImageLedIntensity));
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));
// Update duty to apply the new value
ESP_ERROR_CHECK(ledc_update_duty(LEDC_MODE, LEDC_CHANNEL));
}
Expand Down
4 changes: 3 additions & 1 deletion code/components/jomjol_controlcamera/ClassControllCamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ class CCamera
void SanitizeZoomParams(int imageSize, int frameSizeX, int frameSizeY, int &imageWidth, int &imageHeight, int &zoomOffsetX, int &zoomOffsetY);

public:
int LedIntensity = 4096;

CCamera(void);
esp_err_t InitCam(void);

Expand All @@ -100,7 +102,7 @@ class CCamera
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);

void SetLEDIntensity(float _intrel);
int SetLEDIntensity(int _intrel);
bool testCamera(void);
bool getCameraInitSuccessful(void);
void useDemoMode(void);
Expand Down
3 changes: 3 additions & 0 deletions code/components/jomjol_controlcamera/server_camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ esp_err_t handler_capture(httpd_req_t *req)
{
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;
}

Expand Down Expand Up @@ -159,6 +160,7 @@ esp_err_t handler_capture_with_light(httpd_req_t *req)
{
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;
}

Expand Down Expand Up @@ -241,6 +243,7 @@ esp_err_t handler_capture_save_to_file(httpd_req_t *req)
{
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;
}

Expand Down
5 changes: 3 additions & 2 deletions code/components/jomjol_flowcontroll/ClassFlowTakeImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,8 @@ bool ClassFlowTakeImage::ReadParameter(FILE *pfile, string &aktparamgraph)
{
if (isStringNumeric(splitted[1]))
{
float ledintensity = std::stof(splitted[1]);
Camera.SetLEDIntensity(ledintensity);
int ledintensity = std::stoi(splitted[1]);
CCstatus.ImageLedIntensity = Camera.SetLEDIntensity(ledintensity);
}
}

Expand Down Expand Up @@ -559,6 +559,7 @@ bool ClassFlowTakeImage::doFlow(string zwtime)
{
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;
}

Expand Down
5 changes: 2 additions & 3 deletions code/components/jomjol_flowcontroll/MainFlowControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1364,9 +1364,8 @@ esp_err_t handler_editflow(httpd_req_t *req)
std::string _ledi = std::string(_valuechar);
if (isStringNumeric(_ledi))
{
float _ImageLedIntensity = std::stof(_valuechar);
Camera.SetLEDIntensity(_ImageLedIntensity);
CFstatus.ImageLedIntensity = CCstatus.ImageLedIntensity;
int _ImageLedIntensity = std::stoi(_valuechar);
CFstatus.ImageLedIntensity = Camera.SetLEDIntensity(_ImageLedIntensity);
}
}

Expand Down

0 comments on commit 50ada0a

Please sign in to comment.