Skip to content

Commit f1c8c7f

Browse files
committed
config: disable awb_gain
1 parent d23dbfe commit f1c8c7f

File tree

3 files changed

+27
-18
lines changed

3 files changed

+27
-18
lines changed

examples/AsyncCam/handlers.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ rewriteFrontpage(const esp32cam::Settings& s, const String& var) {
8383
b.printf("<option value=\"%d\" title=\"%s\"%s>%s</option>", \
8484
static_cast<int>(esp32cam::LightMode::MODE), #MODE, \
8585
s.lightMode == esp32cam::LightMode::MODE ? " selected" : "", SYMBOL)
86+
SHOW_LM(NONE, "&#x1F6AB;");
8687
SHOW_LM(AUTO, "&#x2B55;");
8788
SHOW_LM(SUNNY, "&#x2600;&#xFE0F;");
8889
SHOW_LM(CLOUDY, "&#x2601;&#xFE0F;");

src/esp32cam/config.cpp

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,15 @@ CameraClass::status() const {
100100
return result;
101101
}
102102

103-
result.resolution = Resolution(sensor->status.framesize);
104-
result.brightness = sensor->status.brightness;
105-
result.contrast = sensor->status.contrast;
106-
result.saturation = sensor->status.saturation;
107-
result.lightMode = static_cast<LightMode>(sensor->status.wb_mode);
108-
result.specialEffect = static_cast<SpecialEffect>(sensor->status.special_effect);
109-
result.hmirror = sensor->status.hmirror != 0;
110-
result.vflip = sensor->status.vflip != 0;
103+
const auto& ss = sensor->status;
104+
result.resolution = Resolution(ss.framesize);
105+
result.brightness = ss.brightness;
106+
result.contrast = ss.contrast;
107+
result.saturation = ss.saturation;
108+
result.lightMode = ss.awb_gain ? static_cast<LightMode>(ss.wb_mode) : LightMode::NONE;
109+
result.specialEffect = static_cast<SpecialEffect>(ss.special_effect);
110+
result.hmirror = ss.hmirror != 0;
111+
result.vflip = ss.vflip != 0;
111112
return result;
112113
}
113114

@@ -127,33 +128,39 @@ CameraClass::update(const Settings& settings, int sleepFor) {
127128
} \
128129
} while (false)
129130

130-
#define UPDATE(STATUS_MEM, SETTING_MEM, SETTER_TYP) \
131+
#define UPDATE(STATUS_MEM, value, SETTER_TYP) \
131132
do { \
132133
int prev = static_cast<int>(sensor->status.STATUS_MEM); \
133-
int next = static_cast<int>(settings.SETTING_MEM); \
134-
if (prev != static_cast<int>(settings.SETTING_MEM)) { \
135-
int res = sensor->set_##STATUS_MEM(sensor, static_cast<SETTER_TYP>(next)); \
136-
ESP32CAM_LOG("update " #STATUS_MEM " %d => %d %s", prev, next, \
134+
int desired = static_cast<int>(value); \
135+
if (prev != desired) { \
136+
int res = sensor->set_##STATUS_MEM(sensor, static_cast<SETTER_TYP>(desired)); \
137+
ESP32CAM_LOG("update " #STATUS_MEM " %d => %d %s", prev, desired, \
137138
res == 0 ? "success" : "failure"); \
138139
if (res != 0) { \
139140
return false; \
140141
} \
141142
} \
142143
} while (false)
143-
#define UPDATE1(MEM) UPDATE(MEM, MEM, int)
144+
#define UPDATE1(MEM) UPDATE(MEM, settings.MEM, int)
144145

145146
CHECK_RANGE(brightness, -2, 2);
146147
CHECK_RANGE(contrast, -2, 2);
147148
CHECK_RANGE(saturation, -2, 2);
148-
CHECK_RANGE(lightMode, 0, 4);
149+
CHECK_RANGE(lightMode, -1, 4);
149150
CHECK_RANGE(specialEffect, 0, 6);
150151

151-
UPDATE(framesize, resolution.as<framesize_t>(), framesize_t);
152+
UPDATE(framesize, settings.resolution.as<framesize_t>(), framesize_t);
152153
UPDATE1(brightness);
153154
UPDATE1(contrast);
154155
UPDATE1(saturation);
155-
UPDATE(wb_mode, lightMode, int);
156-
UPDATE(special_effect, specialEffect, int);
156+
if (settings.lightMode == LightMode::NONE) {
157+
UPDATE(awb_gain, 0, int);
158+
UPDATE(wb_mode, 0, int);
159+
} else {
160+
UPDATE(awb_gain, 1, int);
161+
UPDATE(wb_mode, settings.lightMode, int);
162+
}
163+
UPDATE(special_effect, settings.specialEffect, int);
157164
UPDATE1(hmirror);
158165
UPDATE1(vflip);
159166

src/esp32cam/config.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class Config {
5454

5555
/** @brief Light mode / white balance values. */
5656
enum class LightMode {
57+
NONE = -1,
5758
AUTO = 0,
5859
SUNNY = 1,
5960
CLOUDY = 2,

0 commit comments

Comments
 (0)