@@ -81,60 +81,57 @@ int CLAppCam::stop() {
8181}
8282
8383int CLAppCam::loadPrefs () {
84- jparse_ctx_t jctx ;
85- int ret = parsePrefs (&jctx );
84+ JsonDocument json ;
85+ int ret = parsePrefs (json );
8686 if (ret != OS_SUCCESS) {
8787 return ret;
8888 }
8989
9090 // process local settings
9191
92- json_obj_get_int (&jctx, ( char *) " frame_rate" , &frameRate) ;
93- json_obj_get_int (&jctx, ( char *) " xclk" , &xclk) ;
94- json_obj_get_int (&jctx, ( char *) " rotate" , &myRotation) ;
92+ this -> frameRate = json[ " frame_rate" ] ;
93+ this -> xclk = json[ " xclk" ] ;
94+ this -> myRotation = json[ " rotate" ] ;
9595
9696 // get sensor reference
9797 sensor_t * s = esp_camera_sensor_get ();
9898 // process camera settings
9999 if (s) {
100- s->set_framesize (s, (framesize_t )readJsonIntVal (&jctx, " framesize" ) );
101- s->set_quality (s, readJsonIntVal (&jctx, " quality" ) );
100+ s->set_framesize (s, (framesize_t )json[ " framesize" ] );
101+ s->set_quality (s, json[ " quality" ] );
102102 s->set_xclk (s, LEDC_TIMER_0, xclk);
103- s->set_brightness (s, readJsonIntVal (&jctx, " brightness" ));
104- s->set_contrast (s, readJsonIntVal (&jctx, " contrast" ));
105- s->set_saturation (s, readJsonIntVal (&jctx, " saturation" ));
106- s->set_sharpness (s, readJsonIntVal (&jctx, " sharpness" ));
107- s->set_denoise (s, readJsonIntVal (&jctx, " denoise" ));
108- s->set_special_effect (s, readJsonIntVal (&jctx, " special_effect" ));
109- s->set_wb_mode (s, readJsonIntVal (&jctx, " wb_mode" ));
110- s->set_whitebal (s, readJsonIntVal (&jctx, " awb" ));
111- s->set_awb_gain (s, readJsonIntVal (&jctx, " awb_gain" ));
112- s->set_exposure_ctrl (s, readJsonIntVal (&jctx, " aec" ));
113- s->set_aec2 (s, readJsonIntVal (&jctx, " aec2" ));
114- s->set_ae_level (s, readJsonIntVal (&jctx, " ae_level" ));
115- s->set_aec_value (s, readJsonIntVal (&jctx, " aec_value" ));
116- s->set_gain_ctrl (s, readJsonIntVal (&jctx, " agc" ));
117- s->set_agc_gain (s, readJsonIntVal (&jctx, " agc_gain" ));
118- s->set_gainceiling (s, (gainceiling_t )readJsonIntVal (&jctx, " gainceiling" ));
119- s->set_bpc (s, readJsonIntVal (&jctx, " bpc" ));
120- s->set_wpc (s, readJsonIntVal (&jctx, " wpc" ));
121- s->set_raw_gma (s, readJsonIntVal (&jctx, " raw_gma" ));
122- s->set_lenc (s, readJsonIntVal (&jctx, " lenc" ));
123- s->set_vflip (s, readJsonIntVal (&jctx, " vflip" ));
124- s->set_hmirror (s, readJsonIntVal (&jctx, " hmirror" ));
125- s->set_dcw (s, readJsonIntVal (&jctx, " dcw" ));
126- s->set_colorbar (s, readJsonIntVal (&jctx, " colorbar" ));
103+ s->set_brightness (s, json[" brightness" ]);
104+ s->set_contrast (s, json[" contrast" ]);
105+ s->set_saturation (s, json[" saturation" ]);
106+ s->set_sharpness (s, json[" sharpness" ]);
107+ s->set_denoise (s, json[" denoise" ]);
108+ s->set_special_effect (s, json[" special_effect" ]);
109+ s->set_wb_mode (s, json[" wb_mode" ]);
110+ s->set_whitebal (s, json[" awb" ]);
111+ s->set_awb_gain (s, json[" awb_gain" ]);
112+ s->set_exposure_ctrl (s, json[" aec" ]);
113+ s->set_aec2 (s, json[" aec2" ]);
114+ s->set_ae_level (s, json[" ae_level" ]);
115+ s->set_aec_value (s, json[" aec_value" ]);
116+ s->set_gain_ctrl (s, json[" agc" ]);
117+ s->set_agc_gain (s, json[" agc_gain" ]);
118+ s->set_gainceiling (s, (gainceiling_t )json[" gainceiling" ]);
119+ s->set_bpc (s, json[" bpc" ]);
120+ s->set_wpc (s, json[" wpc" ]);
121+ s->set_raw_gma (s, json[" raw_gma" ]);
122+ s->set_lenc (s, json[" lenc" ]);
123+ s->set_vflip (s, json[" vflip" ]);
124+ s->set_hmirror (s, json[" hmirror" ]);
125+ s->set_dcw (s, json[" dcw" ]);
126+ s->set_colorbar (s, json[" colorbar" ]);
127+
128+ if (json[" debug_mode" ]) setDebugMode (json[" debug_mode" ]);
127129
128- bool dbg;
129- if (json_obj_get_bool (&jctx, (char *)" debug_mode" , &dbg) == OS_SUCCESS)
130- setDebugMode (dbg);
131130 }
132131 else {
133132 Serial.println (" Failed to get camera handle. Camera settings skipped" );
134133 }
135-
136- // close the file
137- json_parse_end (&jctx);
134+
138135 return ret;
139136}
140137
0 commit comments