Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed 4DGL-uLCD-SE mbed-rtos nRF24L01P
CircularBuf.h@16:d0d3bb2fc3ce, 2018-04-20 (annotated)
- Committer:
- Nurchu
- Date:
- Fri Apr 20 15:23:53 2018 +0000
- Revision:
- 16:d0d3bb2fc3ce
- Parent:
- 14:4637a9f02919
- Child:
- 17:604f9c4bd6d3
Updating CircularBuf
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Nurchu | 16:d0d3bb2fc3ce | 1 | template <class T> |
Nurchu | 14:4637a9f02919 | 2 | class CircularBuff { |
Nurchu | 14:4637a9f02919 | 3 | public: |
Nurchu | 16:d0d3bb2fc3ce | 4 | // Arguement: |
Nurchu | 16:d0d3bb2fc3ce | 5 | // size, The size of the underlying array to use |
Nurchu | 14:4637a9f02919 | 6 | CircularBuff(unsigned int size); |
Nurchu | 14:4637a9f02919 | 7 | ~CircularBuff(); |
Nurchu | 14:4637a9f02919 | 8 | |
Nurchu | 14:4637a9f02919 | 9 | // Pushes data onto the buffer |
Nurchu | 14:4637a9f02919 | 10 | // Arguement: |
Nurchu | 14:4637a9f02919 | 11 | // data, The array of data to push |
Nurchu | 14:4637a9f02919 | 12 | // size, The amount of data in the array |
Nurchu | 14:4637a9f02919 | 13 | void push(T* data, unsigned int size); |
Nurchu | 14:4637a9f02919 | 14 | |
Nurchu | 14:4637a9f02919 | 15 | |
Nurchu | 14:4637a9f02919 | 16 | // Pops data from the buffer |
Nurchu | 14:4637a9f02919 | 17 | // Arguement: |
Nurchu | 14:4637a9f02919 | 18 | // data, The array of data popped |
Nurchu | 14:4637a9f02919 | 19 | // size, The amount of data to pop |
Nurchu | 14:4637a9f02919 | 20 | // Return: |
Nurchu | 14:4637a9f02919 | 21 | // Amount of data actually popped |
Nurchu | 14:4637a9f02919 | 22 | unsigned int pop(T* data, unsigned int size); |
Nurchu | 14:4637a9f02919 | 23 | |
Nurchu | 14:4637a9f02919 | 24 | // Amount of data in the buffer |
Nurchu | 14:4637a9f02919 | 25 | unsigned int size(); |
Nurchu | 14:4637a9f02919 | 26 | |
Nurchu | 14:4637a9f02919 | 27 | // Clears the buffer completely |
Nurchu | 14:4637a9f02919 | 28 | void clear(); |
Nurchu | 14:4637a9f02919 | 29 | |
Nurchu | 14:4637a9f02919 | 30 | private: |
Nurchu | 14:4637a9f02919 | 31 | T* _data; |
Nurchu | 14:4637a9f02919 | 32 | unsigned int _size; |
Nurchu | 14:4637a9f02919 | 33 | unsigned int _start; |
Nurchu | 14:4637a9f02919 | 34 | unsigned int _end; |
Nurchu | 14:4637a9f02919 | 35 | }; |