Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/AsyncCam/handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ static const char FRONTPAGE[] = R"EOT(
%vflip%
%rawGma%
%lensCorrection%
%xclk%
<input type="submit" value="update">
</p></form>
<p id="controls">
Expand Down Expand Up @@ -138,6 +139,7 @@ rewriteFrontpage(const esp32cam::Settings& s, const String& var) {
SHOW_INT(brightness, -2, 2)
SHOW_INT(contrast, -2, 2)
SHOW_INT(saturation, -2, 2)
SHOW_INT(xclk, 6, 24)
SHOW_BOOL(hmirror)
SHOW_BOOL(vflip)
SHOW_BOOL(rawGma)
Expand Down Expand Up @@ -166,6 +168,7 @@ handleUpdate(AsyncWebServerRequest* req) {
SAVE_INT(gain);
SAVE_INT(lightMode);
SAVE_INT(specialEffect);
SAVE_INT(xclk);
SAVE_BOOL(hmirror);
SAVE_BOOL(vflip);
SAVE_BOOL(rawGma);
Expand Down
12 changes: 12 additions & 0 deletions src/esp32cam/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ CameraClass::status() const {
result.vflip = ss.vflip != 0;
result.rawGma = ss.raw_gma != 0;
result.lensCorrection = ss.lenc != 0;
result.xclk = sensor->xclk_freq_hz / 1000000U;
return result;
}

Expand Down Expand Up @@ -155,6 +156,7 @@ CameraClass::update(const Settings& settings, int sleepFor) {
CHECK_RANGE(lightMode, -1, 4);
CHECK_RANGE(specialEffect, 0, 6);
CHECK_RANGE(gain, -128, 31);
CHECK_RANGE(xclk, 6, 24);

UPDATE3(framesize, settings.resolution.as<framesize_t>(), framesize_t);
UPDATE1(brightness);
Expand Down Expand Up @@ -184,6 +186,16 @@ CameraClass::update(const Settings& settings, int sleepFor) {
UPDATE2(wb_mode, settings.lightMode);
}

int prev = sensor->xclk_freq_hz / 1000000U, desired = settings.xclk;
if (prev != desired) {
int res = sensor->set_xclk(sensor, LEDC_TIMER_0, desired);
ESP32CAM_LOG("update xclk %d => %d %s", prev, desired,
res == 0 ? "success" : "failure");
if (res != 0) {
return false;
}
}

#undef CHECK_RANGE
#undef UPDATE4
#undef UPDATE3
Expand Down
3 changes: 3 additions & 0 deletions src/esp32cam/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ struct Settings {
* - AGC enabled: -2,-4,-8,-16,-32,-64,-128, which corresponds to 2x ~ 128x gain.
*/
int8_t gain;

/** @brief Camera clock value in MHz. Recommended to be between 6 and 24. */
int8_t xclk;

/** @brief Image light mode. */
LightMode lightMode;
Expand Down