Hi all,
I am trying to create a queue that will use string (char) variables, but I am having trouble understanding how it works and therefore it doesn't work.
The queue library:
My code:
/*
Author: Vasco Baptista
email: vascojdb@gmail.com
An example of using Einar Arnason's queue
In this example we create a queue of int's
limited by the maximum amount of items
Usage and further info:
https://github.com/EinarArnason/ArduinoQueue
*/
#include "Queue.h"
#define QUEUE_SIZE_ITEMS 10
// Queue creation:
ArduinoQueue<char> charQueue(QUEUE_SIZE_ITEMS);
void printQueueStats() {
Serial.println("");
Serial.printf("Size of each element: %u bytes\r\n", charQueue.item_size());
Serial.printf("Items in queue now: %u items\r\n", charQueue.item_count());
Serial.printf("Queue actual max items: %u items\r\n",
charQueue.maxQueueSize());
Serial.printf("Queue actual max memory: %u bytes\r\n",
charQueue.maxMemorySize());
Serial.println("");
}
void setup() {
Serial.begin(115200);
Serial.println("");
Serial.println("========== Queue example ==========");
Serial.printf("Desired max item size: %u items\r\n", QUEUE_SIZE_ITEMS);
Serial.println("===================================");
}
void loop() {
printQueueStats();
// Add elements: (add more than the queue size for demo purposes)
if (!charQueue.isFull()) {
char n[] = "1";
Serial.printf("Adding value: %i\r\n", n);
charQueue.enqueue(n);
}
printQueueStats();
if (!charQueue.isEmpty()) {
char result[] = intQueue.dequeue();
Serial.printf("Removed value: %i\r\n", result);
}
else {
Serial.println("Queue is empty!");
}
printQueueStats();
// Loop forever
while (true) {
#ifdef ESP8266
ESP.wdtFeed();
#endif
}
}
Shows this error:
invalid conversion from 'char*' to 'char' [-fpermissive]
About this line:
charQueue.enqueue(n);
Any help would be awesome.
Thanks,
Zeb