Skip to content

Sphinkie/ArrayQueue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ArrayQueue

Description

Small Arduino library to deal with a FIFO queue (First in , First Out).

The library is rather compact but has the main functionalities of a fifo (ie: enqueue and dequeue). Each item of the queue has 2 fields (int and string).
I use it associated to an I2C bus receiver: the queue stores the received messages until they are processed.

Example:
---FxxxxL----
F = First item
L = Last item


Usage

See the given file: example.ino

API description

Customisation

These values can be adjusted in the header file, in order to fit your needs.

MAX_QUEUE_SIZE
MAX_DATA_SIZE

Functions


ArrayQueue::ArrayQueue()

Object constructor.


void ArrayQueue::enQueue(int element, char* text)

Add a item in the FIFO queue (the Last item). The item has two fields (element and text) . When MAX_QUEUE_SIZE is reached, the queue is full and the new items are ignored.

Examples:
xL---------
--FxxxxL---
xL----Fxxxx


int ArrayQueue::deQueue()

Read an item of the Queue. The item is also removed from the Queue. Returns -1 if the Queue is empty.


int ArrayQueue::getFirst()

Returns the first item of the FIFO, but without removing it. Returns -1 if the Queue is empty.


int ArrayQueue::getSize()

Returns the number of items in the Queue.


bool ArrayQueue::isEmpty()

Returns TRUE if the Queue is empty.


String ArrayQueue::getData(int index)

Returns the second field of the poped item