#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++
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Недопустимое использование нестатической функции-члена arduino IDE ESP32 Wifi
Anonymous » » в форуме C++ - 0 Ответы
- 22 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Недопустимое использование нестатической функции-члена arduino IDE ESP32 Wifi [дубликат]
Anonymous » » в форуме C++ - 0 Ответы
- 13 Просмотры
-
Последнее сообщение Anonymous
-