ESP_CAM webpage code.

esp_man
Posts: 14
Joined: Tue Mar 21, 2023 12:04 pm

Re: ESP_CAM webpage code.

Postby esp_man » Tue Mar 28, 2023 3:28 pm

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);

User avatar
corz.org
Posts: 80
Joined: Fri Feb 03, 2023 10:44 pm
Location: Aberdeen
Contact:

Re: ESP_CAM webpage code.

Postby corz.org » Tue Mar 28, 2023 3:58 pm

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).

esp_man
Posts: 14
Joined: Tue Mar 21, 2023 12:04 pm

Re: ESP_CAM webpage code.

Postby esp_man » Tue Mar 28, 2023 4:16 pm

corz.org wrote:
Tue Mar 28, 2023 3:58 pm
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.
corz.org wrote:
Tue Mar 28, 2023 3:58 pm
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)

User avatar
corz.org
Posts: 80
Joined: Fri Feb 03, 2023 10:44 pm
Location: Aberdeen
Contact:

Re: ESP_CAM webpage code.

Postby corz.org » Tue Mar 28, 2023 5:34 pm

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?

esp_man
Posts: 14
Joined: Tue Mar 21, 2023 12:04 pm

Re: ESP_CAM webpage code.

Postby esp_man » Tue Mar 28, 2023 6:00 pm

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.

User avatar
corz.org
Posts: 80
Joined: Fri Feb 03, 2023 10:44 pm
Location: Aberdeen
Contact:

Re: ESP_CAM webpage code.

Postby corz.org » Tue Mar 28, 2023 9:43 pm

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.

esp_man
Posts: 14
Joined: Tue Mar 21, 2023 12:04 pm

Re: ESP_CAM webpage code.

Postby esp_man » Thu Mar 30, 2023 8:07 am

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.

esp_man
Posts: 14
Joined: Tue Mar 21, 2023 12:04 pm

Re: ESP_CAM webpage code.

Postby esp_man » Tue Sep 26, 2023 8:25 am

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?

Who is online

Users browsing this forum: Bing [Bot] and 47 guests