#include
#define SEND_LEDC_CHANNEL 0
#include
// Define the GPIO pin connected to the IR receiver
#define IR_RECEIVE_PIN 27
// Queue to hold IR commands
QueueHandle_t irQueue;
// Declare task functions
void readIrTask(void *parameter);
void displayIrTask(void *parameter);
void setup()
{
Serial.begin(115200);
Serial.println("IR Receiver Example");
// Start the IR receiver
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
// Create a queue capable of containing 10 IR commands
irQueue = xQueueCreate(10, sizeof(uint32_t));
// Create the tasks
xTaskCreatePinnedToCore(readIrTask, "ReadIR", 2048, NULL, 1, NULL, 1);
xTaskCreatePinnedToCore(displayIrTask, "DisplayIR", 2048, NULL, 2, NULL, 1);
}
void loop()
{
// No need to use loop since tasks handle execution
}
// Task to read IR commands
void readIrTask(void *parameter)
{
while (true)
{
if (IrReceiver.decode())
{
//Serial.print("Decoded IR Command: ");
//Serial.println(IrReceiver.decodedIRData.decodedRawData, HEX);
uint32_t commandValue = IrReceiver.decodedIRData.decodedRawData;
// Send the command to the queue
xQueueSend(irQueue, &commandValue, portMAX_DELAY);
Serial.println("Command sent to queue.");
IrReceiver.resume(); // Prepare for the next value
}
vTaskDelay(10 / portTICK_PERIOD_MS); // Delay to yield control
}
}
// Task to display IR commands
void displayIrTask(void *parameter)
{
uint32_t receivedValue;
while (true)
{
// Wait for a command from the queue
if (xQueueReceive(irQueue, &receivedValue, portMAX_DELAY) == pdPASS)
{
Serial.print("Received IR Command: ");
Serial.println(receivedValue, HEX);
}
vTaskDelay(10 / portTICK_PERIOD_MS); // Delay to yield control
}
}
< /code>
Я загрузил этот код из Arduino IDE 2 на мою доску Nodemcu32S и всю работу serial.print. Я проверил как с последовательным монитором Arduino IDE, так и с платформой. Но когда я открываю последовательный монитор, напечатано только сообщение «ИК -пример». Я также немедленно открыл серийный монитор Arduino IDE сразу после закрытия серийного монитора Platformio, и увидел ту же проблему. Я не знаю, в чем может быть проблема. Почему только сообщение в печати void setup. Как мне проверить какие -либо теории о том, что может быть неправильно, и как мне это решить? < /P>
Спасибо за помощь. Я новичок в платформе.
Подробнее здесь: https://stackoverflow.com/questions/796 ... ly-with-pl
Code Irmote и Freertos для ESP32 работает с Arduino IDE, но не полностью с Platformio ⇐ C++
Программы на C++. Форум разработчиков
1752352774
Anonymous
#include
#define SEND_LEDC_CHANNEL 0
#include
// Define the GPIO pin connected to the IR receiver
#define IR_RECEIVE_PIN 27
// Queue to hold IR commands
QueueHandle_t irQueue;
// Declare task functions
void readIrTask(void *parameter);
void displayIrTask(void *parameter);
void setup()
{
Serial.begin(115200);
Serial.println("IR Receiver Example");
// Start the IR receiver
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
// Create a queue capable of containing 10 IR commands
irQueue = xQueueCreate(10, sizeof(uint32_t));
// Create the tasks
xTaskCreatePinnedToCore(readIrTask, "ReadIR", 2048, NULL, 1, NULL, 1);
xTaskCreatePinnedToCore(displayIrTask, "DisplayIR", 2048, NULL, 2, NULL, 1);
}
void loop()
{
// No need to use loop since tasks handle execution
}
// Task to read IR commands
void readIrTask(void *parameter)
{
while (true)
{
if (IrReceiver.decode())
{
//Serial.print("Decoded IR Command: ");
//Serial.println(IrReceiver.decodedIRData.decodedRawData, HEX);
uint32_t commandValue = IrReceiver.decodedIRData.decodedRawData;
// Send the command to the queue
xQueueSend(irQueue, &commandValue, portMAX_DELAY);
Serial.println("Command sent to queue.");
IrReceiver.resume(); // Prepare for the next value
}
vTaskDelay(10 / portTICK_PERIOD_MS); // Delay to yield control
}
}
// Task to display IR commands
void displayIrTask(void *parameter)
{
uint32_t receivedValue;
while (true)
{
// Wait for a command from the queue
if (xQueueReceive(irQueue, &receivedValue, portMAX_DELAY) == pdPASS)
{
Serial.print("Received IR Command: ");
Serial.println(receivedValue, HEX);
}
vTaskDelay(10 / portTICK_PERIOD_MS); // Delay to yield control
}
}
< /code>
Я загрузил этот код из Arduino IDE 2 на мою доску Nodemcu32S и всю работу serial.print. Я проверил как с последовательным монитором Arduino IDE, так и с платформой. Но когда я открываю последовательный монитор, напечатано только сообщение «ИК -пример». Я также немедленно открыл серийный монитор Arduino IDE сразу после закрытия серийного монитора Platformio, и увидел ту же проблему. Я не знаю, в чем может быть проблема. Почему только сообщение в печати void setup. Как мне проверить какие -либо теории о том, что может быть неправильно, и как мне это решить? < /P>
Спасибо за помощь. Я новичок в платформе.
Подробнее здесь: [url]https://stackoverflow.com/questions/79699574/irremote-and-freertos-code-for-esp32-runs-with-arduino-ide-but-not-fully-with-pl[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия