Skip to content

Commit 085c47b

Browse files
committed
cleanup
1 parent 20a04b8 commit 085c47b

File tree

5 files changed

+342
-166
lines changed

5 files changed

+342
-166
lines changed

code/components/jomjol_flowcontroll/ClassFlowTakeImage.cpp

+110-61
Original file line numberDiff line numberDiff line change
@@ -126,33 +126,64 @@ bool ClassFlowTakeImage::ReadParameter(FILE *pfile, string &aktparamgraph)
126126
else if ((toUpper(splitted[0]) == "CAMGAINCEILING") && (splitted.size() > 1))
127127
{
128128
std::string _ImageGainceiling = toUpper(splitted[1]);
129-
if (_ImageGainceiling == "X4")
130-
{
131-
CCstatus.ImageGainceiling = GAINCEILING_4X;
132-
}
133-
else if (_ImageGainceiling == "X8")
134-
{
135-
CCstatus.ImageGainceiling = GAINCEILING_8X;
136-
}
137-
else if (_ImageGainceiling == "X16")
138-
{
139-
CCstatus.ImageGainceiling = GAINCEILING_16X;
140-
}
141-
else if (_ImageGainceiling == "X32")
142-
{
143-
CCstatus.ImageGainceiling = GAINCEILING_32X;
144-
}
145-
else if (_ImageGainceiling == "X64")
146-
{
147-
CCstatus.ImageGainceiling = GAINCEILING_64X;
148-
}
149-
else if (_ImageGainceiling == "X128")
129+
130+
if (isStringNumeric(_ImageGainceiling))
150131
{
151-
CCstatus.ImageGainceiling = GAINCEILING_128X;
132+
int _ImageGainceiling_ = std::stoi(_ImageGainceiling);
133+
switch (_ImageGainceiling_)
134+
{
135+
case 1:
136+
CFstatus.ImageGainceiling = GAINCEILING_4X;
137+
break;
138+
case 2:
139+
CFstatus.ImageGainceiling = GAINCEILING_8X;
140+
break;
141+
case 3:
142+
CFstatus.ImageGainceiling = GAINCEILING_16X;
143+
break;
144+
case 4:
145+
CFstatus.ImageGainceiling = GAINCEILING_32X;
146+
break;
147+
case 5:
148+
CFstatus.ImageGainceiling = GAINCEILING_64X;
149+
break;
150+
case 6:
151+
CFstatus.ImageGainceiling = GAINCEILING_128X;
152+
break;
153+
default:
154+
CFstatus.ImageGainceiling = GAINCEILING_2X;
155+
}
152156
}
153157
else
154158
{
155-
CCstatus.ImageGainceiling = GAINCEILING_2X;
159+
if (_ImageGainceiling == "X4")
160+
{
161+
CCstatus.ImageGainceiling = GAINCEILING_4X;
162+
}
163+
else if (_ImageGainceiling == "X8")
164+
{
165+
CCstatus.ImageGainceiling = GAINCEILING_8X;
166+
}
167+
else if (_ImageGainceiling == "X16")
168+
{
169+
CCstatus.ImageGainceiling = GAINCEILING_16X;
170+
}
171+
else if (_ImageGainceiling == "X32")
172+
{
173+
CCstatus.ImageGainceiling = GAINCEILING_32X;
174+
}
175+
else if (_ImageGainceiling == "X64")
176+
{
177+
CCstatus.ImageGainceiling = GAINCEILING_64X;
178+
}
179+
else if (_ImageGainceiling == "X128")
180+
{
181+
CCstatus.ImageGainceiling = GAINCEILING_128X;
182+
}
183+
else
184+
{
185+
CCstatus.ImageGainceiling = GAINCEILING_2X;
186+
}
156187
}
157188
}
158189

@@ -216,58 +247,76 @@ bool ClassFlowTakeImage::ReadParameter(FILE *pfile, string &aktparamgraph)
216247
else if ((toUpper(splitted[0]) == "CAMSPECIALEFFECT") && (splitted.size() > 1))
217248
{
218249
std::string _ImageSpecialEffect = toUpper(splitted[1]);
219-
if (_ImageSpecialEffect == "NEGATIVE")
220-
{
221-
CCstatus.ImageSpecialEffect = 1;
222-
}
223-
else if (_ImageSpecialEffect == "GRAYSCALE")
224-
{
225-
CCstatus.ImageSpecialEffect = 2;
226-
}
227-
else if (_ImageSpecialEffect == "RED")
228-
{
229-
CCstatus.ImageSpecialEffect = 3;
230-
}
231-
else if (_ImageSpecialEffect == "GREEN")
232-
{
233-
CCstatus.ImageSpecialEffect = 4;
234-
}
235-
else if (_ImageSpecialEffect == "BLUE")
236-
{
237-
CCstatus.ImageSpecialEffect = 5;
238-
}
239-
else if (_ImageSpecialEffect == "RETRO")
250+
251+
if (isStringNumeric(_ImageSpecialEffect))
240252
{
241-
CCstatus.ImageSpecialEffect = 6;
253+
int _ImageSpecialEffect_ = std::stoi(_ImageSpecialEffect);
254+
CFstatus.ImageSpecialEffect = clipInt(_ImageSpecialEffect_, 6, 0);
242255
}
243256
else
244257
{
245-
CCstatus.ImageSpecialEffect = 0;
258+
if (_ImageSpecialEffect == "NEGATIVE")
259+
{
260+
CCstatus.ImageSpecialEffect = 1;
261+
}
262+
else if (_ImageSpecialEffect == "GRAYSCALE")
263+
{
264+
CCstatus.ImageSpecialEffect = 2;
265+
}
266+
else if (_ImageSpecialEffect == "RED")
267+
{
268+
CCstatus.ImageSpecialEffect = 3;
269+
}
270+
else if (_ImageSpecialEffect == "GREEN")
271+
{
272+
CCstatus.ImageSpecialEffect = 4;
273+
}
274+
else if (_ImageSpecialEffect == "BLUE")
275+
{
276+
CCstatus.ImageSpecialEffect = 5;
277+
}
278+
else if (_ImageSpecialEffect == "RETRO")
279+
{
280+
CCstatus.ImageSpecialEffect = 6;
281+
}
282+
else
283+
{
284+
CCstatus.ImageSpecialEffect = 0;
285+
}
246286
}
247287
}
248288

249289
else if ((toUpper(splitted[0]) == "CAMWBMODE") && (splitted.size() > 1))
250290
{
251291
std::string _ImageWbMode = toUpper(splitted[1]);
252-
if (_ImageWbMode == "SUNNY")
253-
{
254-
CCstatus.ImageWbMode = 1;
255-
}
256-
else if (_ImageWbMode == "CLOUDY")
257-
{
258-
CCstatus.ImageWbMode = 2;
259-
}
260-
else if (_ImageWbMode == "OFFICE")
261-
{
262-
CCstatus.ImageWbMode = 3;
263-
}
264-
else if (_ImageWbMode == "HOME")
292+
293+
if (isStringNumeric(_ImageWbMode))
265294
{
266-
CCstatus.ImageWbMode = 4;
295+
int _ImageWbMode_ = std::stoi(_ImageWbMode);
296+
CFstatus.ImageWbMode = clipInt(_ImageWbMode_, 4, 0);
267297
}
268298
else
269299
{
270-
CCstatus.ImageWbMode = 0;
300+
if (_ImageWbMode == "SUNNY")
301+
{
302+
CCstatus.ImageWbMode = 1;
303+
}
304+
else if (_ImageWbMode == "CLOUDY")
305+
{
306+
CCstatus.ImageWbMode = 2;
307+
}
308+
else if (_ImageWbMode == "OFFICE")
309+
{
310+
CCstatus.ImageWbMode = 3;
311+
}
312+
else if (_ImageWbMode == "HOME")
313+
{
314+
CCstatus.ImageWbMode = 4;
315+
}
316+
else
317+
{
318+
CCstatus.ImageWbMode = 0;
319+
}
271320
}
272321
}
273322

code/components/jomjol_flowcontroll/MainFlowControl.cpp

+68-2
Original file line numberDiff line numberDiff line change
@@ -790,11 +790,11 @@ esp_err_t handler_editflow(httpd_req_t *req)
790790

791791
ESP_LOGD(TAG, "handler_editflow uri: %s", req->uri);
792792

793-
char _query[200];
793+
char _query[512];
794794
char _valuechar[30];
795795
std::string _task;
796796

797-
if (httpd_req_get_url_query_str(req, _query, 200) == ESP_OK)
797+
if (httpd_req_get_url_query_str(req, _query, 512) == ESP_OK)
798798
{
799799
if (httpd_query_key_value(_query, "task", _valuechar, 30) == ESP_OK)
800800
{
@@ -997,6 +997,30 @@ esp_err_t handler_editflow(httpd_req_t *req)
997997
CFstatus.ImageGainceiling = GAINCEILING_2X;
998998
}
999999
}
1000+
else
1001+
{
1002+
if (_aecgc == "X4") {
1003+
CFstatus.ImageGainceiling = GAINCEILING_4X;
1004+
}
1005+
else if (_aecgc == "X8") {
1006+
CFstatus.ImageGainceiling = GAINCEILING_8X;
1007+
}
1008+
else if (_aecgc == "X16") {
1009+
CFstatus.ImageGainceiling = GAINCEILING_16X;
1010+
}
1011+
else if (_aecgc == "X32") {
1012+
CFstatus.ImageGainceiling = GAINCEILING_32X;
1013+
}
1014+
else if (_aecgc == "X64") {
1015+
CFstatus.ImageGainceiling = GAINCEILING_64X;
1016+
}
1017+
else if (_aecgc == "X128") {
1018+
CFstatus.ImageGainceiling = GAINCEILING_128X;
1019+
}
1020+
else {
1021+
CFstatus.ImageGainceiling = GAINCEILING_2X;
1022+
}
1023+
}
10001024
}
10011025

10021026
if (httpd_query_key_value(_query, "qual", _valuechar, 30) == ESP_OK)
@@ -1070,6 +1094,30 @@ esp_err_t handler_editflow(httpd_req_t *req)
10701094
int _spe_ = std::stoi(_valuechar);
10711095
CFstatus.ImageSpecialEffect = clipInt(_spe_, 6, 0);
10721096
}
1097+
else
1098+
{
1099+
if (_spe == "negative") {
1100+
CFstatus.ImageSpecialEffect = 1;
1101+
}
1102+
else if (_spe == "grayscale") {
1103+
CFstatus.ImageSpecialEffect = 2;
1104+
}
1105+
else if (_spe == "red") {
1106+
CFstatus.ImageSpecialEffect = 3;
1107+
}
1108+
else if (_spe == "green") {
1109+
CFstatus.ImageSpecialEffect = 4;
1110+
}
1111+
else if (_spe == "blue") {
1112+
CFstatus.ImageSpecialEffect = 5;
1113+
}
1114+
else if (_spe == "retro") {
1115+
CFstatus.ImageSpecialEffect = 6;
1116+
}
1117+
else {
1118+
CFstatus.ImageSpecialEffect = 0;
1119+
}
1120+
}
10731121
}
10741122

10751123
if (httpd_query_key_value(_query, "wbm", _valuechar, 30) == ESP_OK)
@@ -1080,6 +1128,24 @@ esp_err_t handler_editflow(httpd_req_t *req)
10801128
int _wbm_ = std::stoi(_valuechar);
10811129
CFstatus.ImageWbMode = clipInt(_wbm_, 4, 0);
10821130
}
1131+
else
1132+
{
1133+
if (_wbm == "sunny") {
1134+
CFstatus.ImageWbMode = 1;
1135+
}
1136+
else if (_wbm == "cloudy") {
1137+
CFstatus.ImageWbMode = 2;
1138+
}
1139+
else if (_wbm == "office") {
1140+
CFstatus.ImageWbMode = 3;
1141+
}
1142+
else if (_wbm == "home") {
1143+
CFstatus.ImageWbMode = 4;
1144+
}
1145+
else {
1146+
CFstatus.ImageWbMode = 0;
1147+
}
1148+
}
10831149
}
10841150

10851151
if (httpd_query_key_value(_query, "awb", _valuechar, 30) == ESP_OK)

0 commit comments

Comments
 (0)