MicroController wrote: ↑Fri Aug 18, 2023 5:13 pm
But for some reason, the condition... is not satisfied.
The reason is that xTicksToWait = 1000 / portTICK_PERIOD_MS causes txEventGroupWaitBits to time out and return after 1 second when no even bits are set.
And you want to pass xClearOnExit as pdTRUE to the function, else the bits never get cleared and once a bit has been set all following iterations will immediately return the still set bits.
You are aware of the FreeRTOS
documentation, right?
This is actually my first project using freeRTOS. I used ESP-IDF's own sample wifi station.
Even if I use a longer delay time "portMAX_DELAY", for example, the bits are not set correctly.
the original condition was
and then the code never went any further, when I removed uxBits
the condition was met.
I'm sorry, but maybe I didn't understand the real usefulness of "uxBits".
All I need is for the code to step up to the switch and wait for the user to press the button. Any tips?
Code: Select all
if (uxBits & WIFI_CONNECTED_BIT) {
switch (current_status)
{
case STATUS_WAIT_USER_INPUT:
if (primeira_vez == true) {
ESP_LOGI(TAG, "ENTER SWITCH");
sprintf(info, "PRESS BUTTON");
lcdDrawString(&dev, fx24G, 6, 46, (uint8_t *) info, YELLOW);
lcdDrawString(&dev, fx24G, 6, 76, (uint8_t *) info, YELLOW);
primeira_vez = false;
}
if (gpio_get_level(BUTTON_INPUT) == 0)
{
if (tickNumber == 50) {
current_status = STATUS_REQUEST_QRCODE;
last_id++;
save_nvs_data(&nvs_handle, last_id);
print_last_order(&dev, info, last_id);
}
} else {
tickNumber = 0;
}
break;
I would like to wait until the user presses the button, at which point the status changes and the code moves on to the next case, and so on.
But the code enters the first case and then returns to the while loop.