Page 2 of 2

Re: ESP_CAM webpage code.

Posted: Tue Mar 28, 2023 3:28 pm
by esp_man
Adding this lines in cpp file is sufficient to reproduce the issue:

At the beginning (line ~75):

Code: Select all

    int LED_R;
Lines ~840...850 (cmd_handler function):

Code: Select all

    else if (!strcmp(variable, "contrast"))
        res = s->set_contrast(s, val);
    else if (!strcmp(variable, "LED_R"))
        {
        LED_R = val;
        ledcWrite(0, LED_R);
        }
    else if (!strcmp(variable, "brightness"))
        res = s->set_brightness(s, val);

Re: ESP_CAM webpage code.

Posted: Tue Mar 28, 2023 3:58 pm
by corz.org
What's the point of the "LED_R" variable? Why not just do..

Code: Select all

else if(!strcmp(variable, "LED_R")) ledcWrite(0, val);
I am assuming you have setup this LED elsewhere (ledcSetup / ledcAttachPin).

Re: ESP_CAM webpage code.

Posted: Tue Mar 28, 2023 4:16 pm
by esp_man
I am assuming you have setup this LED elsewhere (ledcSetup / ledcAttachPin).
Yes, as I wrote in post #6: is in the *.ino file in setup() function.
What's the point of the "LED_R" variable?
Only for future use.
ledcWrite(0, val) don't want to work too.
Or even:
ledcWrite(0, 100);

Don't work only because it is placed in cpp file.
Could You check it in Your environment? (only if it compile, or not)
I know there is nothing to check, because it should simply work... (compile without an error)

Re: ESP_CAM webpage code.

Posted: Tue Mar 28, 2023 5:34 pm
by corz.org
Sure, if I slam that line into my version it compiles just fine.

Are you sure you have the correct board selected and all that?

Re: ESP_CAM webpage code.

Posted: Tue Mar 28, 2023 6:00 pm
by esp_man
Yes, I have correct settings. Without this line code compiles properly and works on real hardware.
Also, as I previously said, all PWM functions compiles properly and works in the same project if it is used in CameraWebServer.ino file.

Re: ESP_CAM webpage code.

Posted: Tue Mar 28, 2023 9:43 pm
by corz.org
I can imagine the compiler having an issue with LED_R, which should be declared in the main ino file and then again in the cpp file using:

Code: Select all

extern int LED_R;
But having an issue with ledcWrite() I cannot understand.

Re: ESP_CAM webpage code.

Posted: Thu Mar 30, 2023 8:07 am
by esp_man
I installed Arduino IDE 2.0, but it changed nothing with this issue.
So I wrote function in CameraWebServer.ino file:

Code: Select all

void write_LED(int channel, int value)
    {
    ledcWrite(channel, value);
    }
Declare it as external in cpp file:

Code: Select all

external void write_LED(int channel, int value);
And it compiles without error, and works:

Code: Select all

    else if (!strcmp(variable, "contrast"))
        res = s->set_contrast(s, val);
    else if (!strcmp(variable, "LED_R"))
        {
        LED_R = val;
        write_LED(0, LED_R);
        }
    else if (!strcmp(variable, "brightness"))
        res = s->set_brightness(s, val);
So finally I got what i wanted.
Thanks to everyone.

Re: ESP_CAM webpage code.

Posted: Tue Sep 26, 2023 8:25 am
by esp_man
One more thing.
I want simplify the html code to make the webpage window smaller (remove unnecessary buttons). But when I made any small change, html code stop working (webpage appears, but buttons don't works).
So I took a close look to original code, and discovered something strange to me:

Code: Select all

<div class="close" id="close-stream">Ă—</div>
This if from decompressed index_ov2640 gz file.
What are the "Ă—" characters?
Is this proper for HTML code?
Similar but a little different strange thing here (line 286):
https://github.com/easytarget/esp32-cam ... x_ov2640.h
The "×" character (not "x" letter, only similar in graphical look).
What for are there such strange characters here?

Re: ESP_CAM webpage code.

Posted: Sat Dec 28, 2024 9:15 am
by BikerMark
For reference, here's a direct link to the "Recipe" required for decoding..

https://gchq.github.io/CyberChef/#recip ... 0x')Gunzip()

Enter the HEX in the top panel and get back HTML in the bottom panel.
Thnx! This has been very usefull to me! Evenso was the suggestion of counting words in a text-editor and use that number in the camera.index.h file.