bkeevil / esp32-cam

A webcam firmware for ESP32 based camera modules
150 stars 42 forks source link

The LED illuminator range set in the settings is not reflected in the HTML #15

Closed karlitos closed 4 years ago

karlitos commented 4 years ago

Even thought if I set the maximum level of the LED illuminator under under Camera Web Server -> LED Illuminator the slider-range for the illuminator is har-coded to go from 0 to 255. When the defined maximum range could be retrieved as other settings, it would be easy to adjust the slider range in the Webpage.

karlitos commented 4 years ago

The fix was easier as thought.

In app_httpd.c I extended the __status_handler__:

#ifdef CONFIG_LED_ILLUMINATOR_ENABLED
    p+= sprintf(p, ",\"led_intensity\":%u", led_duty);
    p+= sprintf(p, ",\"led_max_intensity\":%u", CONFIG_LED_MAX_INTENSITY);

And in the script.js javascript file I extended the fetchSettings:

if (state.led_intensity !== -1) {
          let led_intensity_slider = document.getElementById("led_intensity");
          led_intensity_slider.max = state.led_max_intensity;
          let led_intensity_range_max = document.querySelector('#led-group > div.range-max');
          led_intensity_range_max.innerText = state.led_max_intensity;
        }

I try to do a propper PR

bkeevil commented 4 years ago

Can you put the stylesheet rename in the PR too?

karlitos commented 4 years ago

Sure, I try to find some time soon

bkeevil commented 4 years ago

If I remember correctly, the original behavior was that the user would adjust led_max_intensity and then they would have to "save settings" before the led_intensity slider would adjust to the new range.