diff --git a/configuration.cc b/configuration.cc index 0a3e948..9ba2f64 100644 --- a/configuration.cc +++ b/configuration.cc @@ -286,6 +286,14 @@ void Configuration::SetValue(std::string name, std::string value) { filter_ratio = atof(value.c_str()); debug ("Filter Ration set to : %g", filter_ratio); } + if (name.compare("auto_birghtness") == 0) { + auto_brightness = atol(value.c_str()); + debug ("Auto Brightness set to : %ld", auto_brightness); + } + if (name.compare("auto_birghtness_target") == 0) { + auto_brightness_target = atof(value.c_str()); + debug ("Filter Ration set to : %g", auto_brightness_target); + } }; @@ -303,7 +311,20 @@ std::string Configuration::GetValues() { jpe.AddObject("name", "filter_ratio"); jpe.AddObject("value", filter_ratio); jpe.AddObject("desc", "Ratio between new to old image (1.0 = new image)"); - + je.SetAddArray("variables", jpe.ToString()); + + // + jpe.Clear(); + jpe.AddObject("name", "auto_brightness"); + jpe.AddObject("value", (int64_t) auto_brightness); + jpe.AddObject("desc", "Ctrl_ID for the brightness"); + je.SetAddArray("variables", jpe.ToString()); + + // + jpe.Clear(); + jpe.AddObject("name", "auto_brightness_target"); + jpe.AddObject("value", auto_brightness_target); + jpe.AddObject("desc", "target value for auto brightness"); je.SetAddArray("variables", jpe.ToString()); // diff --git a/configuration.h b/configuration.h index 38f84a6..76efa5c 100644 --- a/configuration.h +++ b/configuration.h @@ -47,6 +47,8 @@ public: std::string vdev_dumpfile; std::string vdev_dumppath; + unsigned int auto_brightness; + float auto_brightness_target; float filter_ratio; Configuration(); diff --git a/main.cc b/main.cc index 9566f74..e795018 100644 --- a/main.cc +++ b/main.cc @@ -43,6 +43,7 @@ static void *thread_webserver(void *ignored_argument) { static void *thread_video(void *ignored_argument) { + int cycle = 0; if (config.vdev_dumpfile.length() > 0) { vdev = new VideoDevice_Dump(); @@ -71,6 +72,7 @@ static void *thread_video(void *ignored_argument) { vdev->Stop(); vdev->Start(); } + if ((cycle++ % 2) == 0) vdev->RefreshCtrls(); Lock(); inputimage.CopyTo(¤timage, config.web_width, config.web_height); if (inputfloatfilter.AddScaledImage(&inputfloat, config.filter_ratio) == 0) diff --git a/video.cc b/video.cc index 520fb04..eb44e5e 100644 --- a/video.cc +++ b/video.cc @@ -42,3 +42,13 @@ int VideoDevice::UnLock() { if (pthread_mutex_unlock(&mtx) == 0) return 1; else return 0; }; + + +void VideoDevice::RefreshCtrls() { + std::list::iterator i; + + for (i = vidctrls.begin(); i != vidctrls.end(); i++) { + GetDevCtrl(i->id, &(i->value)); + } + +}; diff --git a/video.h b/video.h index 732b366..327171d 100644 --- a/video.h +++ b/video.h @@ -88,6 +88,7 @@ class VideoDevice { virtual int SetDevCtrl(unsigned int id, int value) { debug (""); return 0; }; virtual int GetDevCtrl(unsigned int id, int *value) { debug (""); return 0; }; virtual std::list GetDevCtrls() { return vidctrls; }; + virtual void RefreshCtrls(); }; #include "videodevice_v4l2.h" diff --git a/www/index.html b/www/index.html index a5d7a61..d927719 100644 --- a/www/index.html +++ b/www/index.html @@ -71,7 +71,7 @@ function refreshCtrls() { ctrls.ctrls.forEach(function (elm, idx) { t += ""+elm.name+""+elm.min+""+ ""+elm.max+"" + - ""; + ""; datalist.innerHTML += "