PacktPublishing / Internet-of-Things-with-ESP32

Developing IoT Projects with ESP32, published by Packt
MIT License
184 stars 50 forks source link

wrong amount of arguments in beep() for loop - dht_example #1

Closed GlenTrudgett closed 2 years ago

GlenTrudgett commented 2 years ago

Hi, The number of arguments in the for loop in the beep() function is incorrect. This causes a compilation error. See below code. If I understand this correctly, this is an attempt to set the state variable to false? Would you not do this during the declaration?

static void beep(void *arg)
{
    int cnt = 2 * (int)arg;

    bool state = true;
    for (int i = 0; i < cnt; ++i, state = !state)

    {
        gpio_set_level(BUZZER_PIN, state);
        vTaskDelay(100 / portTICK_PERIOD_MS);
    }
    vTaskDelete(NULL);
GlenTrudgett commented 2 years ago

I did some more digging and this is an example of a comma operator, https://en.wikipedia.org/wiki/Comma_operator

ozanoner commented 2 years ago

Hi, I re-compiled the project and didn't get any compile-time error. Can you copy-paste the error here so I can help you with it? Probably it is not about the usage of the comma operator.

GlenTrudgett commented 2 years ago

Hi @ozanoner, My apologies for the delay. I'll rerun the compile and provide to you

GlenTrudgett commented 2 years ago

I have checked the details of the compile that I performed and I am unable to re-create the error. It was not one of my greatest moments to not to paste the details in. If I hit the issue again. I will open another ticket. You can close this ticket,

ozanoner commented 2 years ago

Alright, just let me know if any help is needed.