Skip to content

Commit

Permalink
config: raw gamma & lens correction
Browse files Browse the repository at this point in the history
refs #16
  • Loading branch information
yoursunny committed Jan 13, 2025
1 parent 04601d8 commit 73611fc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
10 changes: 8 additions & 2 deletions examples/AsyncCam/handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ static const char FRONTPAGE[] = R"EOT(
<select name="specialEffect" title="special effect">%specialEffect%</select>
%hmirror%
%vflip%
%rawGma%
%lensCorrection%
<input type="submit" value="update">
</p></form>
<p id="controls">
Expand Down Expand Up @@ -82,12 +84,12 @@ rewriteFrontpage(const esp32cam::Settings& s, const String& var) {
} else if (var == "gain") {
#define SHOW_GAIN(val, dsp) \
b.printf("<option value=\"%d\"%s>%dx</option>", val, s.gain == val ? " selected" : "", dsp)
b.printf("<optgroup label=\"AGC=off\">");
b.printf("<optgroup label=\"AGC=0\">");
for (int i = 1; i <= 31; ++i) {
SHOW_GAIN(i, i);
}
b.printf("</optgroup>");
b.printf("<optgroup label=\"AGC=on\">");
b.printf("<optgroup label=\"AGC=1\">");
for (int i = 2; i <= 128; i <<= 1) {
SHOW_GAIN(-i, i);
}
Expand Down Expand Up @@ -138,6 +140,8 @@ rewriteFrontpage(const esp32cam::Settings& s, const String& var) {
SHOW_INT(saturation, -2, 2)
SHOW_BOOL(hmirror)
SHOW_BOOL(vflip)
SHOW_BOOL(rawGma)
SHOW_BOOL(lensCorrection)
#undef SHOW_INT
#undef SHOW_BOOL
return b;
Expand All @@ -164,6 +168,8 @@ handleUpdate(AsyncWebServerRequest* req) {
SAVE_INT(specialEffect);
SAVE_BOOL(hmirror);
SAVE_BOOL(vflip);
SAVE_BOOL(rawGma);
SAVE_BOOL(lensCorrection);
#undef SAVE_BOOL
#undef SAVE_INT
});
Expand Down
10 changes: 5 additions & 5 deletions src/esp32cam/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,11 @@ CameraClass::status() const {
result.saturation = ss.saturation;
result.lightMode = ss.awb_gain ? static_cast<LightMode>(ss.wb_mode) : LightMode::NONE;
result.specialEffect = static_cast<SpecialEffect>(ss.special_effect);
if (ss.agc) {
result.gain = (-2) << ss.gainceiling;
} else {
result.gain = 1 + static_cast<int8_t>(ss.agc_gain);
}
result.gain = ss.agc ? ((-2) << ss.gainceiling) : (1 + static_cast<int8_t>(ss.agc_gain));
result.hmirror = ss.hmirror != 0;
result.vflip = ss.vflip != 0;
result.rawGma = ss.raw_gma != 0;
result.lensCorrection = ss.lenc != 0;
return result;
}

Expand Down Expand Up @@ -165,6 +163,8 @@ CameraClass::update(const Settings& settings, int sleepFor) {
UPDATE2(special_effect, settings.specialEffect);
UPDATE1(hmirror);
UPDATE1(vflip);
UPDATE2(raw_gma, settings.rawGma);
UPDATE2(lenc, settings.lensCorrection);

if (settings.gain > 0) {
UPDATE4(agc, 0, set_gain_ctrl, int);
Expand Down
6 changes: 6 additions & 0 deletions src/esp32cam/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ struct Settings {

/** @brief Vertical flip. */
bool vflip = false;

/** @brief Raw gamma mode. */
bool rawGma = false;

/** @brief Lens correction mode. */
bool lensCorrection = false;
};

} // namespace esp32cam
Expand Down

0 comments on commit 73611fc

Please sign in to comment.